Hi,
i want to add function which sum Total VAT Amount from VAT Entry filtered by Customer (Cust. Ledger Entry).
I struggle with filter Amount per Customer. Below is my code.
Hi,
i want to add function which sum Total VAT Amount from VAT Entry filtered by Customer (Cust. Ledger Entry).
I struggle with filter Amount per Customer. Below is my code.
Hi Tony00001
Try this code instead. You were missing the repeat while looping through the VAT entries-
if VatEntry.FindSet() then repeat
VatEntry.CalcFields("ITI VAT Base");
TotalVAT += -VatEntry."ITI VAT Amount" - VatEntry."Unrealized Amount";
until VatEntry.Next() = 0;
It only get last record in VAT Entry, doesnt sum.
It doesn't work right. I get on every customer record the same result.
Hi,
Please do the yellow mark
var
CustLedgerEntry: Record "Cust. Ledger Entry";
TotalVAT: Decimal;
VatEntry: Record "VAT Entry";
procedure TotalVAT()
begin
CustLedgerEntry.reset;
CustLedgerEntry.setrange("Customer No.",Customer."No.");
CustLedgerEntry.findset;
repeat
CustLedgerEntry.CalcFields("Remaining Amt. (LCY)", "Remaining Amount", CustLedgerEntry."Original Amt. (LCY)");
TotalVAT := 0;
VatEntry.Reset();
VatEntry.SetRange("Document No.", CustLedgerEntry."Document No.");
VatEntry.SetRange("Transaction No.", CustLedgerEntry."Transaction No.");
if VatEntry.FindSet() then begin
VatEntry.CalcFields("ITI VAT Base");
TotalVAT += -VatEntry."ITI VAT Amount" - VatEntry."Unrealized Amount";
until VatEntry.Next() = 0;
end;
until CustLedgerEntry.next = 0;
Any ideas?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,570 Super User 2024 Season 2
Martin Dráb 228,683 Most Valuable Professional
nmaenpaa 101,148