LOCAL PROCEDURE UpdateSalesLines@62(VAR StateIndicator@1000 : Record 104037);
VAR
SalesLine@1001 : Record 37;
LastDocumentNo@1002 : Code[20];
PrepmtInvReminderAmount@1003 : Decimal;
BEGIN
WITH SalesLine DO
IF StateIndicator.UpdateTable(TABLENAME) THEN BEGIN
TimeLog.TimeLogInsert(TimeLog,TABLENAME,TRUE);
SETCURRENTKEY("Document Type","Document No.","Line No.");
IF FINDSET THEN
REPEAT
StateIndicator.Update;
IF ("Document Type" = "Document Type"::Order) AND ("Prepayment Amount" <> "Prepmt. Amt. Incl. VAT") THEN BEGIN
IF "Document No." <> LastDocumentNo THEN BEGIN
LastDocumentNo := "Document No.";
PrepmtInvReminderAmount := 0;
END;
IF ("Prepmt. Amount Inv. (LCY)" <> 0) AND ("Prepmt. VAT Amount Inv. (LCY)" = 0) THEN BEGIN
"Prepmt. VAT Amount Inv. (LCY)" :=
CalcRndedAmount("Prepmt. Amount Inv. (LCY)","Prepayment VAT %" / 100,PrepmtInvReminderAmount);
MODIFY;
END;
END;
UNTIL NEXT = 0;
TimeLog.TimeLogInsert(TimeLog,TABLENAME,FALSE);
StateIndicator.EndUpdateTable(TABLENAME);
END;
LOCAL PROCEDURE UpdatePurchLines@63(VAR StateIndicator@1000 : Record 104037);
VAR
PurchaseLine@1001 : Record 39;
LastDocumentNo@1002 : Code[20];
PrepmtInvReminderAmount@1003 : Decimal;
BEGIN
WITH PurchaseLine DO
IF StateIndicator.UpdateTable(TABLENAME) THEN BEGIN
TimeLog.TimeLogInsert(TimeLog,TABLENAME,TRUE);
IF FINDSET THEN
REPEAT
StateIndicator.Update;
IF ("Document Type" = "Document Type"::Order) AND ("Prepayment Amount" <> "Prepmt. Amt. Incl. VAT") THEN BEGIN
IF "Document No." <> LastDocumentNo THEN BEGIN
LastDocumentNo := "Document No.";
PrepmtInvReminderAmount := 0;
END;
IF ("Prepmt. Amount Inv. (LCY)" <> 0) AND ("Prepmt. VAT Amount Inv. (LCY)" = 0) THEN BEGIN
"Prepmt. VAT Amount Inv. (LCY)" :=
CalcRndedAmount("Prepmt. Amount Inv. (LCY)","Prepayment VAT %" / 100,PrepmtInvReminderAmount);
MODIFY;
END;
END;
UNTIL NEXT = 0;
TimeLog.TimeLogInsert(TimeLog,TABLENAME,FALSE);
StateIndicator.EndUpdateTable(TABLENAME);
END;
LOCAL PROCEDURE CalcRndedAmount@64(LineAmount@1000 : Decimal;Ratio@1001 : Decimal;VAR Reminder@1002 : Decimal) RndedAmount : Decimal;
VAR
Amount@1003 : Decimal;
BEGIN
Amount := Reminder + LineAmount * Ratio;
RndedAmount := ROUND(Amount);
Reminder := Amount - RndedAmount;
END;