...
SalesSetup@1003 : Record 311;
TempServiceChargeLine@1005 : TEMPORARY Record 37;
GLAcc@1100000 : Record 15;
BEGIN
SalesSetup.GET;
WITH SalesLine DO BEGIN
...
...
SalesSetup@1003 : Record 311;
TempServiceChargeLine@1005 : TEMPORARY Record 37;
GLAcc@1100000 : Record 15;
// Add the following line.
TempSalesLine@1100001 : TEMPORARY Record 37;
// End of the line.
BEGIN
SalesSetup.GET;
WITH SalesLine DO BEGIN
...
...
(SalesLine2."Prepayment %" = 0)
THEN
SalesLine2.VALIDATE("Inv. Discount Amount");
// Delete the following lines.
IF SalesLine2."Allow Invoice Disc." THEN
CASE GLSetup."Discount Calculation" OF
GLSetup."Discount Calculation"::" ",
GLSetup."Discount Calculation"::"Line Disc. * Inv. Disc. + Payment Disc.",
GLSetup."Discount Calculation"::"Line Disc. * Inv. Disc. * Payment Disc.":
SalesLine2."Inv. Discount Amount" :=
ROUND(SalesLine2."Line Amount" * CustInvDisc."Discount %" / 100,0.000001);
GLSetup."Discount Calculation"::"Line Disc. + Inv. Disc. + Payment Disc.",
GLSetup."Discount Calculation"::"Line Disc. + Inv. Disc. * Payment Disc.":
SalesLine2."Inv. Discount Amount" :=
ROUND(
(SalesLine2."Line Amount" + SalesLine2."Line Discount Amount" ) *
CustInvDisc."Discount %" / 100,0.000001);
END;
IF GLSetup."Payment Discount Type" =
GLSetup."Payment Discount Type"::"Calc. Pmt. Disc. on Lines"
THEN BEGIN
GLSetup.TESTFIELD("Discount Calculation");
CASE GLSetup."Discount Calculation" OF
GLSetup."Discount Calculation"::"Line Disc. + Inv. Disc. + Payment Disc.",
GLSetup."Discount Calculation"::"Line Disc. * Inv. Disc. + Payment Disc.":
SalesLine2."Pmt. Disc. Given Amount" :=
ROUND(
(SalesLine2."Line Amount" + SalesLine2."Line Discount Amount")
* SalesHeader."Payment Discount %" / 100,0.01);
GLSetup."Discount Calculation"::"Line Disc. + Inv. Disc. * Payment Disc.",
GLSetup."Discount Calculation"::"Line Disc. * Inv. Disc. * Payment Disc.":
SalesLine2."Pmt. Disc. Given Amount" :=
ROUND(
(SalesLine2."Line Amount" - SalesLine2."Inv. Discount Amount") *
SalesHeader."Payment Discount %" / 100,0.01);
END;
END;
// End of the lines.
IF (SalesLine2.Type <> SalesLine2.Type::"Charge (Item)") AND
(SalesLine2."Prepayment %" = 0)
...
...
(SalesLine2."Prepayment %" = 0)
THEN
SalesLine2.VALIDATE("Inv. Discount Amount");
// Add the following lines.
IF SalesLine2."Allow Invoice Disc." THEN BEGIN
CASE GLSetup."Discount Calculation" OF
GLSetup."Discount Calculation"::" ",
GLSetup."Discount Calculation"::"Line Disc. * Inv. Disc. + Payment Disc.",
GLSetup."Discount Calculation"::"Line Disc. * Inv. Disc. * Payment Disc.":
BEGIN
TempSalesLine."Inv. Discount Amount" :=
TempSalesLine."Inv. Discount Amount" +
SalesLine2."Line Amount" * CustInvDisc."Discount %" / 100;
SalesLine2."Inv. Discount Amount" := ROUND(TempSalesLine."Inv. Discount Amount",0.000001);
END;
GLSetup."Discount Calculation"::"Line Disc. + Inv. Disc. + Payment Disc.",
GLSetup."Discount Calculation"::"Line Disc. + Inv. Disc. * Payment Disc.":
BEGIN
TempSalesLine."Inv. Discount Amount" :=
TempSalesLine."Inv. Discount Amount" +
(SalesLine2."Line Amount" + SalesLine2."Line Discount Amount") *
CustInvDisc."Discount %" / 100;
SalesLine2."Inv. Discount Amount" := ROUND(TempSalesLine."Inv. Discount Amount",0.000001);
END;
END;
TempSalesLine."Inv. Discount Amount" :=
TempSalesLine."Inv. Discount Amount" - SalesLine2."Inv. Discount Amount";
END;
IF GLSetup."Payment Discount Type" =
GLSetup."Payment Discount Type"::"Calc. Pmt. Disc. on Lines"
THEN BEGIN
GLSetup.TESTFIELD("Discount Calculation");
CASE GLSetup."Discount Calculation" OF
GLSetup."Discount Calculation"::"Line Disc. + Inv. Disc. + Payment Disc.",
GLSetup."Discount Calculation"::"Line Disc. * Inv. Disc. + Payment Disc.":
BEGIN
TempSalesLine."Pmt. Disc. Given Amount" :=
TempSalesLine."Pmt. Disc. Given Amount" +
(SalesLine2."Line Amount" + SalesLine2."Line Discount Amount") *
SalesHeader."Payment Discount %" / 100;
SalesLine2."Pmt. Disc. Given Amount" := ROUND(TempSalesLine."Pmt. Disc. Given Amount",0.01);
END;
GLSetup."Discount Calculation"::"Line Disc. + Inv. Disc. * Payment Disc.",
GLSetup."Discount Calculation"::"Line Disc. * Inv. Disc. * Payment Disc.":
BEGIN
TempSalesLine."Pmt. Disc. Given Amount" :=
TempSalesLine."Pmt. Disc. Given Amount" +
(SalesLine2."Line Amount" - SalesLine2."Inv. Discount Amount") *
SalesHeader."Payment Discount %" / 100;
SalesLine2."Pmt. Disc. Given Amount" :=
ROUND(TempSalesLine."Pmt. Disc. Given Amount",0.01);
END;
END;
TempSalesLine."Pmt. Disc. Given Amount" :=
TempSalesLine."Pmt. Disc. Given Amount" - SalesLine2."Pmt. Disc. Given Amount";
END;
// End of the lines.
IF (SalesLine2.Type <> SalesLine2.Type::"Charge (Item)") AND
(SalesLine2."Prepayment %" = 0)
...