...
BEGIN
VATEntry3.SETCURRENTKEY(Type,"Country/Region Code","VAT Registration No.");
VATEntry3.SETRANGE("Country/Region Code",CountryCode);
IF IsCustomer THEN BEGIN
VATEntry3.SETRANGE(Type,VATEntry3.Type::Sale);
// Delete the following line.
VATEntry3.SETRANGE("VAT Registration No.",Customer."VAT Registration No.");
VATEntry3.SETFILTER("Bill-to/Pay-to No.",'<>%1', Customer."No.");
END ELSE BEGIN
VATEntry3.SETRANGE(Type,VATEntry3.Type::Purchase);
VATEntry3.SETRANGE("VAT Registration No.",Vendor."VAT Registration No.");
// End of the deleted line.
VATEntry3.SETFILTER("Bill-to/Pay-to No.",'<>%1', Vendor."No.");
END;
VATEntry3.SETRANGE("Document Date",FromDate,ToDate);
IF VATEntry3.FINDFIRST THEN
REPEAT
...
...
BEGIN
VATEntry3.SETCURRENTKEY(Type,"Country/Region Code","VAT Registration No.");
VATEntry3.SETRANGE("Country/Region Code",CountryCode);
IF IsCustomer THEN BEGIN
VATEntry3.SETRANGE(Type,VATEntry3.Type::Sale);
// Add the following lines.
VATEntry3.SETRANGE("VAT Registration No.",UPPERCASE(Customer."VAT Registration No."));
VATEntry3.SETFILTER("Bill-to/Pay-to No.",'<>%1', Customer."No.");
END ELSE BEGIN
VATEntry3.SETRANGE(Type,VATEntry3.Type::Purchase);
VATEntry3.SETRANGE("VAT Registration No.",UPPERCASE(Vendor."VAT Registration No."));
// End of the added lines.
VATEntry3.SETFILTER("Bill-to/Pay-to No.",'<>%1', Vendor."No.");
END;
VATEntry3.SETRANGE("Document Date",FromDate,ToDate);
IF VATEntry3.FINDFIRST THEN
REPEAT
...