RE: How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?
You can use SpecTransManager class for it. It has to be initialize from the originator record , in your scenario its free text invoice . See below code for initialize part
SpecTransManager writeOffSpecTransManager = SpecTransManager::newFromSpec(_ledgerJournalTrans);
Once you initialize spectrans manager find the Open transaction (CustTransOpen) and use insert method to mark the transaction against originating transaction for example , Sales order , customer , free text invoice etc.
specTransManager.insert(
custtransopenOrigPaym.company(),
custtransopenOrigPaym.TableId,
custtransopenOrigPaym.RecId,
custtransopenOrigPaym.AmountCur,
custtransopenOrigPaym.custTrans().CurrencyCode);
You can use CustVendOpenTransManager class as well for settlement of two transactions with each other . For example , If you would like to settle invoice and payment for a specific customer together , You can initialize it like below
CustVendOpenTransManager manager = CustVendOpenTransManager::construct(custTable);
//Select open tranasction for invoice , You can find it as per your requirement
custTransOpenInvoice = CustTransOpen::find(markedCustTransOpen.RecId);
custTransopenPayment = CustTransOpen::findRefId(custTransrefund.RecId);
//mark payment and Invoice for settlement
manager.updateTransMarked(custTransOpenInvoice,NoYes::Yes);
manager.updateTransMarked(custTransopenPayment,NoYes::Yes);
manager.updateSpecTransWithSelectedDate();
manager.settleMarkedTrans();