PROCEDURE CalcTotalAmountIncludingVAT(DocumentNo : Code[20];EndLineNo : Integer) AmountIncludingVAT : Decimal
Count := -1;
BeginLineNo := 0;
SalesInvoiceLine.RESET;
SalesInvoiceLine.SETRANGE("Document No.",DocumentNo);
SalesInvoiceLine.SETRANGE("Line No.",0,EndLineNo);
IF SalesInvoiceLine.FINDLAST THEN
REPEAT
IF SalesInvoiceLine.Type = SalesInvoiceLine.Type::"Begin-Total" THEN
IF Count = 0 THEN
BeginLineNo := SalesInvoiceLine."Line No."
ELSE
Count := Count - 1
ELSE
IF SalesInvoiceLine.Type = SalesInvoiceLine.Type::"End-Total" THEN
Count := Count + 1;
UNTIL (SalesInvoiceLine.NEXT(-1) = 0) OR (BeginLineNo <> 0);
SalesInvoiceLine.SETRANGE("Line No.",BeginLineNo,EndLineNo);
SalesInvoiceLine.CALCSUMS("Amount Including VAT");
AmountIncludingVAT := SalesInvoiceLine."Amount Including VAT";CalcTotalAmountIncludingVAT(DocumentNo : Code[20];EndLineNo : Integer) AmountIncludingVAT : Decimal
Count := -1;
BeginLineNo := 0;
SalesInvoiceLine.RESET;
SalesInvoiceLine.SETRANGE("Document No.",DocumentNo);
SalesInvoiceLine.SETRANGE("Line No.",0,EndLineNo);
IF SalesInvoiceLine.FINDLAST THEN
REPEAT
IF SalesInvoiceLine.Type = SalesInvoiceLine.Type::"Begin-Total" THEN
IF Count = 0 THEN
BeginLineNo := SalesInvoiceLine."Line No."
ELSE
Count := Count - 1
ELSE
IF SalesInvoiceLine.Type = SalesInvoiceLine.Type::"End-Total" THEN
Count := Count + 1;
UNTIL (SalesInvoiceLine.NEXT(-1) = 0) OR (BeginLineNo <> 0);
SalesInvoiceLine.SETRANGE("Line No.",BeginLineNo,EndLineNo);
SalesInvoiceLine.CALCSUMS("Amount Including VAT");
AmountIncludingVAT := SalesInvoiceLine."Amount Including VAT";