static void MyCode_Cust_Settlement_Settle_Zero(Args _args)
{
CustTrans _custTransMark;
CustTable _custTable, _custTableMark;
MyCode_CustTransOpenSumZeroView _transOpenZero;
CustTransOpen _custTransOpen;
AmountCur amountCur,netSettledAmt;
AccountNum custNum;
TransDate asOfDate,settleDate;
CustVendTransData custVendTransData;
CustVendOpenTransManager manager;
Boolean goProcess, isInfolog;
int countCust,countTrans;
;
netSettledAmt = 0;
isInfolog = true;
goProcess = false;
asOfDate = str2date('30-09-2019', 123);
settleDate = str2date('01-10-2019', 123);
/** 1. Get list from customer open transaction view (customized), summarized by AccountNum, having sum AmountMST = 0 **/
while select _transOpenZero
join _custTable
where _transOpenZero.MaxOfTransDate <= asOfDate
&& _custTable.AccountNum == _transOpenZero.AccountNum
&& _custTable.CustGroup == 'CORPORATE'
&& _custTable.AccountNum == 'CUST01'
{
//1.a. Reset marked settlement per customer
countCust++;
if(goProcess)
{
_custTableMark = CustTable::find(_transOpenZero.AccountNum);
manager = CustVendOpenTransManager::construct(_custTableMark);
if (manager.getSpecTransCount() > 0)
manager.resetMarkedTrans();
}
/** 2. Get list customer open transaction per customer **/
while select _custTransOpen
where _custTransOpen.AccountNum == _transOpenZero.AccountNum
{
/** 3. Get CustTrans based on CustTransOpen**/
countTrans++;
select firstonly _custTransMark
where _custTransMark.RecId == _custTransOpen.RefRecId;
//netSettledAmt += _custTransMark.remainAmountCur();
if(isInfolog) info(strfmt("CustTrans %1 %2 %3 %4 %5", _custTransMark.AccountNum,_custTransMark.Voucher, _custTransMark.remainAmountCur(), _custTransMark.Txt, _custTransMark.RecId));
if(goProcess) custVendTransData = CustVendTransData::construct(_custTransMark);
if(goProcess) custVendTransData.markForSettlement(_custTableMark);
}
if(goProcess) CustTrans::settleTransact(_custTableMark, null, true,SettleDatePrinc::SelectDate, settleDate);
}
info(strfmt('Settled done! Customers: %1 Transactions: %2', countCust, countTrans ));
info(strfmt('As of date: %1', asOfDate));
}
No comments:
Post a Comment