Hi Khoa,
This is what is inside the loop. Also look at the first line after the loop.
i.e.: SalesInvoiceHeader.CALCFIELDS("Amount Including VAT",Amount);
This also gives the wrong results (sometimes) for the cumulative values.
In the same cu i also calculate the vat s from table 254 Vat Entry.
The strange thing is that this gives the correct values.
I also have a comparible problem with delivery lines in another codeunit.
A difficulty is that i cannot reproduce the problem.
IF SalesInvoiceLine.FIND('-') THEN BEGIN
REPEAT
GTIN:='';
IF SalesInvoiceLine.Type = SalesInvoiceLine.Type::Item THEN BEGIN
IF Item.GET(SalesInvoiceLine."No.") THEN BEGIN
GTIN:= FORMAT(Item.GTIN)
END;
END;
IF SalesInvoiceLine.Type = SalesInvoiceLine.Type::Resource THEN BEGIN
IF Resource.GET(SalesInvoiceLine."No.") THEN BEGIN
GTIN:= FORMAT(Resource.GTIN);
END;
END;
IF SalesInvoiceLine.Type = SalesInvoiceLine.Type::"G/L Account" THEN BEGIN
GTIN:= '8716376999832';
END;
//Door te controleren op aantal = 0 worden tekstregels (staan ook in resources) niet meegenomen.
IF SalesInvoiceLine.Quantity <> 0 THEN BEGIN
XMLDOMMgt.AddElement(XMLLinesNode, 'Line', '', XMLRootNode.NamespaceURI, XMLCreatedNode);
XMLDOMMgt.AddElement(XMLCreatedNode, 'Article_Eancode', GTIN, XMLRootNode.NamespaceURI, XMLCreatedNode2);
END;
UNTIL SalesInvoiceLine.NEXT=0
END;
SalesInvoiceHeader.CALCFIELDS("Amount Including VAT",Amount);
Thanks.