hello everyone
i have open transaction for more than 20000 customers, for more than 2 years accountants insert payment journal and sales orders but didn't settled both transactions ,i need to settle this transactions by x++ code
i searched about that i found next code but this code didn't settled any transaction (without error)
static void settlePayment(Args _args)
{
CustTable custTable;
CustTrans invCustTrans, payCustTrans;
SpecTransManager manager;
CustVendTransData custVendTransData;
custTable = CustTable::find("3001");
// Find the oldest invoice that hasn't been settled yet
// for this customer
select firstonly invCustTrans
order by TransDate asc
where invCustTrans.AccountNum == custTable.AccountNum &&
invCustTrans.TransType == LedgerTransType::Sales &&
!invCustTrans.LastSettleDate;
// Find the oldest payment that hasn't been settled yet
// for this customer
select firstonly payCustTrans
order by TransDate asc
where payCustTrans.AccountNum == custTable.AccountNum &&
payCustTrans.TransType == LedgerTransType::Payment &&
!payCustTrans.LastSettleDate;
ttsbegin;
// Create an object of the CustVendTransData class
// with the invoice transaction as parameter and mark
// it for settlement
custVendTransData = CustVendTransData::construct(invCustTrans);
custVendTransData.markForSettlement(CustTable);
// Create an object of the CustVendTransData class
// with the payment transaction as parameter and mark
// it for settlement
custVendTransData = CustVendTransData::construct(payCustTrans);
custVendTransData.markForSettlement(CustTable);
ttscommit;
// Settle all transactions marked for settlement for this customer
if(CustTrans::settleTransact(custTable, null, true,
SettleDatePrinc::DaysDate, systemdateget()))
info("Transactions settled");
}
any help ?
thanks in advance.
*This post is locked for comments
I have the same question (0)