Auto settlement sample code

Hi all,

Anybody have done for auto settlement?may i know how the code design, because my current code its still not function…
i need to know by refer the sample…
somebody can share? :frowning:

Hi,

static void settlePayment(Args _args)
{
CustTable custTable;
CustTrans invCustTrans, payCustTrans;
SpecTransManager manager;
CustVendTransData custVendTransData;
;
custTable = CustTable::find(“3001″);
// Find the oldest invoice that has not been settled yet
// for this customer you can customize the query find the invoice that you
want
//to settle
select firstonly invCustTrans
order by TransDate asc
where invCustTrans.AccountNum == custTable.AccountNum &&
invCustTrans.TransType == LedgerTransType::Sales &&
!invCustTrans.LastSettleDate;
// Find the oldest payment that has not 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”);
}

hi chatiya,

Thanks for ur reply…

i have using the same code. but after i running, its still appear the balance (-200).
is it use the different table or use the custTable as well?

Dear ,

This Code is not Working.

You can use, \Classes\CustVendOpenTransManager

Hi kran…

I did’nt get your point please explain

You can use that class to settle the open transactions.

Dear Kran sorry tom ask u again how to change & where to change these codes given above.

:frowning:

Can you please create a separate post and explain your problem/requirement?

I want o settle customer invoices & payments automatically with X++ codes ,I applies below codes but it does not work.Any modification required?

static void settlePayment(Args _args)
{
CustTable custTable;
CustTrans invCustTrans, payCustTrans;
SpecTransManager manager;
CustVendTransData custVendTransData;
;
custTable = CustTable::find(“3001″);
// Find the oldest invoice that has not been settled yet
// for this customer you can customize the query find the invoice that you
want
//to settle
select firstonly invCustTrans
order by TransDate asc
where invCustTrans.AccountNum == custTable.AccountNum &&
invCustTrans.TransType == LedgerTransType::Sales &&
!invCustTrans.LastSettleDate;
// Find the oldest payment that has not 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”);
}

I want to settle customer payments & invoices but it is not working, does any modification required.

static void settlePayment(Args _args)
{
CustTable custTable;
CustTrans invCustTrans, payCustTrans;
SpecTransManager manager;
CustVendTransData custVendTransData;
;
custTable = CustTable::find(“3001″);
// Find the oldest invoice that has not been settled yet
// for this customer you can customize the query find the invoice that you
want
//to settle
select firstonly invCustTrans
order by TransDate asc
where invCustTrans.AccountNum == custTable.AccountNum &&
invCustTrans.TransType == LedgerTransType::Sales &&
!invCustTrans.LastSettleDate;
// Find the oldest payment that has not 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”);
}

My suggestion is to use the class i mentioned (to know how to use that class, see the cross references).