...
VATPostingSetup.GET(VATEntry2."VAT Bus. Posting Group",VATEntry2."VAT Prod. Posting Group");
// Delete the following lines.
IF VATPostingSetup."Unrealized VAT Type" IN
[VATPostingSetup."Unrealized VAT Type"::Last,VATPostingSetup."Unrealized VAT Type"::"Last (Fully Paid)"] THEN
TotalUnrealVATAmountLast := TotalUnrealVATAmountLast - VATEntry2."Remaining Unrealized Amount";
IF VATPostingSetup."Unrealized VAT Type" IN
[VATPostingSetup."Unrealized VAT Type"::First,VATPostingSetup."Unrealized VAT Type"::"First (Fully Paid)"] THEN
TotalUnrealVATAmountFirst := TotalUnrealVATAmountFirst - VATEntry2."Remaining Unrealized Amount";
// End of the deleted lines.
UNTIL VATEntry2.NEXT = 0;
...
...
VATPostingSetup.GET(VATEntry2."VAT Bus. Posting Group",VATEntry2."VAT Prod. Posting Group");
// Add the following lines.
IF VATEntry2."VAT Calculation Type" = VATEntry2."VAT Calculation Type" :: "Sales Tax" THEN BEGIN
TaxJurisdiction.GET(VATEntry2."Tax Jurisdiction Code");
IF TaxJurisdiction."Unrealized VAT Type" IN
[TaxJurisdiction."Unrealized VAT Type"::Last,TaxJurisdiction."Unrealized VAT Type"::"Last (Fully Paid)"] THEN
TotalUnrealVATAmountLast := TotalUnrealVATAmountLast - VATEntry2."Remaining Unrealized Amount";
IF TaxJurisdiction."Unrealized VAT Type" IN
[TaxJurisdiction."Unrealized VAT Type"::First,TaxJurisdiction."Unrealized VAT Type"::"First (Fully Paid)"] THEN
TotalUnrealVATAmountFirst := TotalUnrealVATAmountFirst - VATEntry2."Remaining Unrealized Amount";
END ELSE BEGIN
IF VATPostingSetup."Unrealized VAT Type" IN
[VATPostingSetup."Unrealized VAT Type"::Last,VATPostingSetup."Unrealized VAT Type"::"Last (Fully Paid)"] THEN
TotalUnrealVATAmountLast := TotalUnrealVATAmountLast - VATEntry2."Remaining Unrealized Amount";
IF VATPostingSetup."Unrealized VAT Type" IN
[VATPostingSetup."Unrealized VAT Type"::First,VATPostingSetup."Unrealized VAT Type"::"First (Fully Paid)"] THEN
TotalUnrealVATAmountFirst := TotalUnrealVATAmountFirst - VATEntry2."Remaining Unrealized Amount";
END;
// End of the added lines.
UNTIL VATEntry2.NEXT = 0;
...