...
TempDtldVATEntry.RESET;
// Delete the following line.
TempDtldVATEntry.SETCURRENTKEY(Type,"Document No.","Posting Date","Document Receipt/Sales Date",
"VAT Date","Postponed VAT","Document Type","VAT Bus. Posting Group","VAT Prod. Posting Group");
TempDtldVATEntry.COPYFILTERS(TempDtldVATEntry2);
...
...
TempDtldVATEntry.RESET;
// Add the following line
TempDtldVATEntry.SETCURRENTKEY("Realized VAT Entry",Type,"Document No.","Posting Date","Document Receipt/Sales Date",
"VAT Date","Postponed VAT","Document Type","VAT Bus. Posting Group","VAT Prod. Posting Group");
TempDtldVATEntry.COPYFILTERS(TempDtldVATEntry2);
...
...
"VAT Date","Postponed VAT","Document Type","VAT Bus. Posting Group","VAT Prod. Posting Group");
TempDtldVATEntry.COPYFILTERS(TempDtldVATEntry2);
IF TempDtldVATEntry.CALCSUMS("VAT Base","VAT Amount","Postponed VAT Base","Postponed VAT Amount") THEN BEGIN
TotalUnrealizedVATBase := TempDtldVATEntry."Postponed VAT Base";
TotalUnrealizedVATAmount := TempDtldVATEntry."Postponed VAT Amount";
...
...
"VAT Date","Postponed VAT","Document Type","VAT Bus. Posting Group","VAT Prod. Posting Group");
TempDtldVATEntry.COPYFILTERS(TempDtldVATEntry2);
// Add the following line
TempDtldVATEntry.SETRANGE("Realized VAT Entry",FALSE);
IF TempDtldVATEntry.CALCSUMS("VAT Base","VAT Amount","Postponed VAT Base","Postponed VAT Amount") THEN BEGIN
TotalUnrealizedVATBase := TempDtldVATEntry."Postponed VAT Base";
TotalUnrealizedVATAmount := TempDtldVATEntry."Postponed VAT Amount";
...