When unapplying a customer or a vendor ledger entry you sometimes get the error “The latest Transaction No. must be an application in Vendor Ledger Entry No. ######”. I have found that this can be triggered if “Adjust Exchage Rates” batch has been executed after the prior application posting.
This can be avoided by changing the function FindLastTransactioNo in Codeunit 227.
[code]FindLastTransactionNo(VendLedgEntryNo : Integer) : Integer
DtldVendLedgEntry.SETCURRENTKEY(
"Vendor Ledger Entry No.","Entry Type");
DtldVendLedgEntry.SETRANGE(
"Vendor Ledger Entry No.",VendLedgEntryNo);
LastTransactionNo := 0;
IF DtldVendLedgEntry.FIND(‘-‘) THEN
REPEAT
//# Changes Start
IF SourceCodeSetup."Exchange Rate Adjmt." = ” THEN
SourceCodeSetup.GET;
IF DtldVendLedgEntry."Source Code" <>
SourceCodeSetup."Exchange Rate Adjmt."
THEN
//# Changes End
IF (DtldVendLedgEntry."Transaction No." > LastTransactionNo) AND
NOT DtldVendLedgEntry.Unapplied
THEN
LastTransactionNo := DtldVendLedgEntry."Transaction No.";
UNTIL DtldVendLedgEntry.NEXT = 0;
EXIT(LastTransactionNo);[/code]