IF ("VAT Base" <> 0) OR ("Amount Including VAT" <> 0) THEN BEGIN Positive := "Line Amount" >= 0; VATAmountLine := Rec; IF FIND THEN BEGIN "Line Amount" := "Line Amount" + VATAmountLine."Line Amount"; "Inv. Disc. Base Amount" := "Inv. Disc. Base Amount" + VATAmountLine."Inv. Disc. Base Amount"; "Invoice Discount Amount" := "Invoice Discount Amount" + VATAmountLine."Invoice Discount Amount"; Quantity := Quantity + VATAmountLine.Quantity; "VAT Base" := "VAT Base" + VATAmountLine."VAT Base"; "Amount Including VAT" := "Amount Including VAT" + VATAmountLine."Amount Including VAT"; "VAT Difference" := "VAT Difference" + VATAmountLine."VAT Difference"; "VAT Amount" := "Amount Including VAT" - "VAT Base"; "Calculated VAT Amount" := "Calculated VAT Amount" + VATAmountLine."Calculated VAT Amount"; MODIFY; END ELSE BEGIN "VAT Amount" := "Amount Including VAT" - "VAT Base"; INSERT; END; END;