...
TempOldCustLedgEntry.SETCURRENTKEY("Customer No.","Applies-to ID",Open,Positive,"Due Date");
OldCustLedgEntry.SETRANGE("Customer No.",NewCVLedgEntryBuf."CV No.");
OldCustLedgEntry.SETRANGE(Open,TRUE);
// Delete the following line.
OldCustLedgEntry.SETRANGE("Bank Receipt Issued", FALSE);
OldCustLedgEntry.SETFILTER("Entry No.",'<>%1',NewCVLedgEntryBuf."Entry No.");
OldCustLedgEntry.SETRANGE("Applies-to ID",GenJnlLine."Applies-to ID");
IF NOT(Cust."Application Method" = Cust."Application Method"::"Apply to Oldest") THEN
...
...
TempOldCustLedgEntry.SETCURRENTKEY("Customer No.","Applies-to ID",Open,Positive,"Due Date");
OldCustLedgEntry.SETRANGE("Customer No.",NewCVLedgEntryBuf."CV No.");
OldCustLedgEntry.SETRANGE(Open,TRUE);
// Add the following line.
OldCustLedgEntry.SETRANGE("Bank Receipt Issued", TRUE);
OldCustLedgEntry.SETFILTER("Entry No.",'<>%1',NewCVLedgEntryBuf."Entry No.");
OldCustLedgEntry.SETRANGE("Applies-to ID",GenJnlLine."Applies-to ID");
IF NOT(Cust."Application Method" = Cust."Application Method"::"Apply to Oldest") THEN
...