...
NextDtldLedgEntryEntryNo := DtldCustLedgEntry2."Entry No." + 1;
DtldCustLedgEntry2.SETCURRENTKEY("Transaction No.","Customer No.","Entry Type");
IF GenJnlLine."Prepmt. Appl. Transaction No." <> 0 THEN
DtldCustLedgEntry2.SETRANGE("Transaction No.",GenJnlLine."Prepmt. Appl. Transaction No.",DtldCustLedgEntry."Transaction No.")
ELSE
DtldCustLedgEntry2.SETRANGE("Transaction No.",DtldCustLedgEntry."Transaction No.");
DtldCustLedgEntry2.SETRANGE("Customer No.",DtldCustLedgEntry."Customer No.");
DtldCustLedgEntry2.SETRANGE("Entry Type",DtldCustLedgEntry."Entry Type"::Application);
DtldCustLedgEntry2.FINDSET;
...
...
NextDtldLedgEntryEntryNo := DtldCustLedgEntry2."Entry No." + 1;
DtldCustLedgEntry2.SETCURRENTKEY("Transaction No.","Customer No.","Entry Type");
IF GenJnlLine."Prepmt. Appl. Transaction No." <> 0 THEN
// Add the following line.
IF GenJnlLine."Prepmt. Appl. Transaction No." < DtldCustLedgEntry."Transaction No." THEN
DtldCustLedgEntry2.SETRANGE("Transaction No.",GenJnlLine."Prepmt. Appl. Transaction No.",DtldCustLedgEntry."Transaction No.")
// Add the following lines.
ELSE
DtldCustLedgEntry2.SETRANGE("Transaction No.",DtldCustLedgEntry."Transaction No.",GenJnlLine."Prepmt. Appl. Transaction No.")
// End of the lines.
ELSE
DtldCustLedgEntry2.SETRANGE("Transaction No.",DtldCustLedgEntry."Transaction No.");
DtldCustLedgEntry2.SETRANGE("Customer No.",DtldCustLedgEntry."Customer No.");
DtldCustLedgEntry2.SETRANGE("Entry Type",DtldCustLedgEntry."Entry Type"::Application);
DtldCustLedgEntry2.FINDSET;
...
...
IF DtldCustLedgEntry2."Entry Type" = DtldCustLedgEntry2."Entry Type"::Application THEN
PrepareAdvCustUnapply(
DtldCustLedgEntry2."Cust. Ledger Entry No.",TempCustLedgEntryForAppln,
UnapplyAdvVATEntries,ReverseAdvVATTransNo,ApplCustLedgEntryNo,CurrencyCode);
...
...
IF DtldCustLedgEntry2."Entry Type" = DtldCustLedgEntry2."Entry Type"::Application THEN
// Add the following line.
IF GenJnlLine."Prepmt. Appl. Transaction No." <> 0 THEN
PrepareAdvCustUnapply(
DtldCustLedgEntry2."Cust. Ledger Entry No.",TempCustLedgEntryForAppln,
UnapplyAdvVATEntries,ReverseAdvVATTransNo,ApplCustLedgEntryNo,CurrencyCode);
...
...
NegativeLCYAppAmt := NegativeLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
NegativeACYAppAmt :=
NegativeACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
END;
IF GenJnlLine."Prepmt. Appl. Transaction No." = 0 THEN BEGIN
CustLedgEntry.GET(DtldCustLedgEntry2."Cust. Ledger Entry No.");
IF DtldCVLedgEntryBuf.Advance AND (CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::Payment) THEN
SalesPostAdvances.InsertTempApplnAdvanceLink(DtldCVLedgEntryBuf."Entry No.")
END;
END;
...
...
NegativeLCYAppAmt := NegativeLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
NegativeACYAppAmt :=
NegativeACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
END;
IF GenJnlLine."Prepmt. Appl. Transaction No." = 0 THEN BEGIN
CustLedgEntry.GET(DtldCustLedgEntry2."Cust. Ledger Entry No.");
IF DtldCVLedgEntryBuf.Advance AND (CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::Payment) THEN
SalesPostAdvances.InsertTempApplnAdvanceLink(DtldCVLedgEntryBuf."Entry No.")
END;
END;
...