To day we see how to auto settle vendor transactions using x++.
VendTable VendTable;
VendTrans invVendTrans, payVendTrans; CustVendTransData custVendTransData; CustVendOpenTransManager manager; VendTransOpen vendTransOpen; try { ttsBegin; VendTable = VendTable::find(AccountNum); // Find the oldest unsettled invoice select firstonly invVendTrans order by TransDate asc where invVendTrans.AccountNum == VendTable.AccountNum && invVendTrans.TransType == LedgerTransType::Vend && !invVendTrans.closed; // Find the oldest unsettled payment select firstonly payVendTrans order by TransDate asc where payVendTrans.AccountNum == VendTable.AccountNum && payVendTrans.TransType == LedgerTransType::Payment && !payVendTrans.closed; select firstonly vendTransOpen where vendTransOpen.RefRecId == payVendTrans.RecId && vendTransOpen.AccountNum == payVendTrans.AccountNum; if (invVendTrans.RecId && payVendTrans.RecId && vendTransOpen.RecId) { manager = CustVendOpenTransManager::construct(VendTable); manager.updateTransMarked(vendTransOpen,true); // manager.updateSettleAmount(vendTransOpen, Amount); //manager.settleMarkedTrans(); custVendTransData = CustVendTransData::construct(invVendTrans); custVendTransData.markForSettlement(VendTable); custVendTransData = CustVendTransData::construct(payVendTrans); custVendTransData.markForSettlement(VendTable); // Settle all marked transactions //VendTrans::settleTransact(VendTable, null, true, SettleDatePrinc::DaysDate, systemdateget()); VendTrans::settleTransact(VendTable, null, true, SettleDatePrinc::SelectDate, systemdateget()); } ttscommit; } catch (Exception::Error) { ttsAbort; continue; } catch (Exception::Deadlock) { ttsAbort; continue; } catch (Exception::Warning) { CLRInterop::getLastException(); continue; } catch (Exception::CLRError) { ttsAbort; CLRInterop::getLastException(); continue; }Keep daxing!!
No comments:
Post a Comment