...
IF IsFromJournal THEN BEGIN
GLEntry.SETCURRENTKEY("Document No.","Posting Date");
GLEntry.SETRANGE("Document No.",CustLedgEntry4."Document No.");
// Delete the following lines.
{IF GLEntry.FIND('-') THEN BEGIN
PostingGroup := GLEntry."VAT Prod. Posting Group";
VATSetup.SETRANGE(VATSetup."VAT Prod. Posting Group",PostingGroup);
IF (VATSetup.FIND('-') AND (VATSetup."Unrealized VAT Type" >= VATSetup."Unrealized VAT Type"::Percentage)) THEN
IF VATSetup."Unrealized VAT Type" > VATSetup."Unrealized VAT Type"::Percentage THEN
ErrorMessage := TRUE
ELSE
ExistsVATNoReal := TRUE;
END;
END ELSE BEGIN
SalesLine2.SETRANGE("Document No.",CustLedgEntry4."Document No.");
SalesLine2.FIND('-');
REPEAT
CASE SalesLine2.Type OF
SalesLine2.Type::Item:
BEGIN
PostingGroup := SalesLine2."VAT Prod. Posting Group";
VATSetup.SETRANGE(VATSetup."VAT Prod. Posting Group",PostingGroup);
IF (VATSetup.FIND('-') AND (VATSetup."Unrealized VAT Type" >= VATSetup."Unrealized VAT Type"::Percentage)) THEN
IF VATSetup."Unrealized VAT Type" > VATSetup."Unrealized VAT Type"::Percentage THEN
ErrorMessage := TRUE
ELSE
ExistsVATNoReal := TRUE;
END;
SalesLine2.Type::Resource:
BEGIN
PostingGroup := SalesLine2."VAT Prod. Posting Group";
VATSetup.SETRANGE(VATSetup."VAT Prod. Posting Group",PostingGroup);
IF (VATSetup.FIND('-') AND (VATSetup."Unrealized VAT Type" >= VATSetup."Unrealized VAT Type"::Percentage)) THEN
IF VATSetup."Unrealized VAT Type" > VATSetup."Unrealized VAT Type"::Percentage THEN
ErrorMessage := TRUE
ELSE
ExistsVATNoReal := TRUE;
END;
SalesLine2.Type::"G/L Account":
BEGIN
PostingGroup := SalesLine2."VAT Prod. Posting Group";
VATSetup.SETRANGE(VATSetup."VAT Prod. Posting Group",PostingGroup);
IF (VATSetup.FIND('-') AND (VATSetup."Unrealized VAT Type" >= VATSetup."Unrealized VAT Type"::Percentage)) THEN
IF VATSetup."Unrealized VAT Type" > VATSetup."Unrealized VAT Type"::Percentage THEN
ErrorMessage := TRUE
ELSE
ExistsVATNoReal := TRUE;
END;
END;
UNTIL SalesLine2.NEXT = 0;}
// End of the lines.
END;
...
...
IF IsFromJournal THEN BEGIN
GLEntry.SETCURRENTKEY("Document No.","Posting Date");
GLEntry.SETRANGE("Document No.",CustLedgEntry4."Document No.");
// Add the following lines.
IF GLEntry.FINDFIRST THEN
CheckVATSetup(VATSetup,GLEntry."VAT Prod. Posting Group",ErrorMessage,ExistsVATNoReal);
END ELSE BEGIN
SourceCodeSetup.GET;
IF CustLedgEntry4."Source Code" = SourceCodeSetup."Service Management" THEN BEGIN
ServiceLine2.SETRANGE("Document No.",CustLedgEntry4."Document No.");
IF ServiceLine2.FINDSET THEN BEGIN
REPEAT
IF ServiceLine2.Type IN [ServiceLine2.Type::Item,ServiceLine2.Type::Resource,ServiceLine2.Type::"G/L Account"] THEN
CheckVATSetup(VATSetup,ServiceLine2."VAT Prod. Posting Group",ErrorMessage,ExistsVATNoReal);
UNTIL ServiceLine2.NEXT = 0;
END;
END ELSE BEGIN
SalesLine2.SETRANGE("Document No.",CustLedgEntry4."Document No.");
IF SalesLine2.FINDSET THEN BEGIN
REPEAT
IF SalesLine2.Type IN [SalesLine2.Type::Item,SalesLine2.Type::Resource,SalesLine2.Type::"G/L Account"] THEN
CheckVATSetup(VATSetup,SalesLine2."VAT Prod. Posting Group",ErrorMessage,ExistsVATNoReal);
UNTIL SalesLine2.NEXT = 0;
END;
END;
// End of the lines.
END;
...