LOCAL PROCEDURE CalcVATDiffFromVATEntry@1220002(CVLedgEntryBuf@1220002 : Record 382) VATDiffAmt : Decimal;
VAR
CalcVATEntry@1220001 : Record 254;
BEGIN
IF NOT (CVLedgEntryBuf."Document Type" IN
[CVLedgEntryBuf."Document Type"::Invoice,CVLedgEntryBuf."Document Type"::"Credit Memo"])
THEN
EXIT;
WITH CalcVATEntry DO BEGIN
SETRANGE("Transaction No.",CVLedgEntryBuf."Transaction No.");
IF FINDSET THEN
REPEAT
VATDiffAmt := VATDiffAmt + "VAT Difference";
UNTIL NEXT = 0;
END;
END;
LOCAL PROCEDURE CalcVATDiffLCY@1220000() VATDifferenceLCY : Decimal;
BEGIN
WITH GenJnlLine DO BEGIN
IF ("VAT Difference" = 0) AND ("VAT Difference (LCY)" = 0) THEN
EXIT(0);
IF ("VAT Amount (LCY)" <> CalculatedVATAmountLCY) AND
("Currency Code" <> '')
THEN
EXIT("VAT Amount (LCY)" - CalculatedVATAmountLCY);
IF ("VAT Difference" = 0) AND ("VAT Difference (LCY)" <> 0) THEN
VATDifferenceLCY := "VAT Difference (LCY)"
ELSE
IF "Currency Code" = '' THEN
VATDifferenceLCY := "VAT Difference"
ELSE
VATDifferenceLCY :=
ROUND(
CurrExchRate.ExchangeAmtFCYToLCY(
"Posting Date","Currency Code","VAT Difference",
CurrExchRate.ExchangeRate("Posting Date","Currency Code")));
END;
END;