hello,
I'am trying to settle Sales invoices while integrating the Payments through x++, i have all the invoices numbers and the amounts to be settled ( it can be partial or full settlement); Below is my code;
I need your help in fixing the below since the settlement is not working properly;
public void ApplyToInvoices(JournalId _journalNum, str _paymentCode, LedgerAccount _customerAccount )
{
CustVendOpenTransManager manager;
CustTrans custTrans;
CustTransOpen custTransOpen;
LedgerJournalTrans ledgerJournalTrans;
AxLedgerJournalTable axLedgerJournalTable;
AxLedgerJournalTrans axLedgerJournalTrans;
ExchangeRateHelper exchangeRateHelper;
AmountCur totalSettleAmount;
InvoiceId _ledgerJournalId;
ResultSet AppliedInvoices;
try
{
AxLedgerJournalTable = AxLedgerJournalTable::newLedgerJournalTable(LedgerJournalTable::find(_journalNum));
ttsBegin;
//details journal lines from Pay Journal Details
AppliedInvoices = this.getAppliedInvoices(_paymentCode);
while (AppliedInvoices.next())
{
_ledgerJournalId = AppliedInvoices.getString(1);
totalSettleAmount = AppliedInvoices.getReal(2);
CustTrans = CustTrans::findFromInvoice(_ledgerJournalId,_customerAccount);
CustTransOpen = CustTransOpen::findRefId(CustTrans.RecId);
//Create Trans ...
axLedgerJournalTrans = new axLedgerJournalTrans();
axLedgerJournalTrans.parmJournalNum(AxLedgerJournalTable.ledgerJournalTable().JournalNum);
axLedgerJournalTrans.parmTransDate(today());
axLedgerJournalTrans.parmDue(today());
axLedgerJournalTrans.parmAccountType(LedgerJournalACType::Cust);
axLedgerJournalTrans.parmLedgerDimension(DimensionStorage::getDynamicAccount((_customerAccount), LedgerJournalACType::Cust));
axLedgerJournalTrans.save();
manager = CustVendOpenTransManager::construct(axLedgerJournalTrans.ledgerJournalTrans());
manager.updateTransMarked(custTransOpen,true);
manager.updateSettleAmount(custTransOpen,totalSettleAmount);
//update after settle
ledgerJournalTrans = axLedgerJournalTrans.ledgerJournalTrans();
ledgerJournalTrans.selectForUpdate(true);
ledgerJournalTrans.AmountCurDebit = abs(totalSettleAmount);
ledgerJournalTrans.SettleVoucher = SettlementType::SelectedTransact;
ledgerJournalTrans.MarkedInvoice = _ledgerJournalId;
ledgerJournalTrans.update();
}
ttsCommit;
}
catch
{
info ("Auto Settlement Error in Integration Code");
}
}
*This post is locked for comments
I have the same question (0)