Calculate purchase invoice total

Sl1m4erSl1m4er Member Posts: 42
Hi guys,

Is there a simple way to calculate purchase invoice total amount to receive the same value as it is in the Purchase Statistics form in 'Total Incl. VAT' field.
Important note: Amount I'm looking for should be calculated only for those lines that will be invoiced (Qty To Invoice <> 0)

Looking into the OnAfterGetRecord trigger of Purchase Statistics form:
...
PurchPost.GetPurchLines(Rec,TempPurchLine,0);
CLEAR(PurchPost);
PurchPost.SumPurchLinesTemp(
  Rec,TempPurchLine,0,TotalPurchLine,TotalPurchLineLCY,VATAmount,VATAmountText);

IF "Prices Including VAT" THEN BEGIN
  TotalAmount2 := TotalPurchLine.Amount;
  TotalAmount1 := TotalAmount2 + VATAmount;
  TotalPurchLine."Line Amount" := TotalAmount1 + TotalPurchLine."Inv. Discount Amount";
END ELSE BEGIN
  TotalAmount1 := TotalPurchLine.Amount;
  TotalAmount2 := TotalPurchLine."Amount Including VAT";
END;

IF Vend.GET("Pay-to Vendor No.") THEN
  Vend.CALCFIELDS("Balance (LCY)")
ELSE
  CLEAR(Vend);

PurchLine.CalcVATAmountLines(0,Rec,TempPurchLine,TempVATAmountLine);
TempVATAmountLine.MODIFYALL(Modified,FALSE);
SetVATSpecification;

Is it true that the amount incl. VAT I'm looking for is stored in TotalAmount2 variable, and basically, I can re-use the same code in my application or will it be necessary to run additional functions from CU 90?

Also, what is this code for:
PurchLine.CalcVATAmountLines(0,Rec,TempPurchLine,TempVATAmountLine);
TempVATAmountLine.MODIFYALL(Modified,FALSE);
SetVATSpecification;

Thank you in advance.
Sign In or Register to comment.