On the "Purchase Invoices" page, I want to create a "Totals" section, where the "Amount" and "Amount including VAT" fields of all records are added. To achieve this, I am using the following code:
On the "Purchase Invoices" page, I want to create a "Totals" section, where the "Amount" and "Amount including VAT" fields of all records are added. To achieve this, I am using the following code:
Hi, just adding some info.
If you need to sum all the invoices on the page, please refer to Natin's code.
If you just need the total of the current invoice, these are the standard fields, you just need to display them on the page.
Hope this helps.
Thanks.
ZHU
Hi
you can also create a function within the page that performs the calculation you want to obtain and create a section where you can insert your function that will output your two fields
DAniele
Hi,
I think you should think about your requirement once again, if you are thinking to sum of all the records amount and show, so I would suggest please use the Fact box and in the fact box do the sum of all records and show the total amount of all the records while opening.
Factbox
trigger OnOpenPage()
var
PurchaseHeader: Record "Purchase Header";
begin
PurchaseHeader.reset;
PurchaseHeader.setrange("Document Type",PurchaseHeader."Document Type"::Invoice);
PurchaseHeader.setloadfields(Amount, "Amount Including VAT");
if PurchaseHeader.findset then
begin
PurchaseHeader.CalcSums(Amount, "Amount Including VAT");
TotalAmount := PurchaseHeader.Amount;
TotalAmountIncludingVAT := PurchaseHeader."Amount Including VAT";
end;
end;
André Arnaud de Cal... 291,791 Super User 2024 Season 2
Martin Dráb 230,488 Most Valuable Professional
nmaenpaa 101,156