web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

how to settle open customer transaction by using settle open transactions form in ax 2012

(0) ShareShare
ReportReport
Posted on by 576

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)
  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

    Is it really that your accountants want to match the oldest invoices first?

    I am used to settling invoices by invoice number, payment amount, etc. and not by the date the invoice was created.

    Are your accoutants ok with this settlement procedure?

    Best regards,

    Ludwig

  • Ismail Mohamed Profile Picture
    576 on at

    Just we need to close all old open transaction , to start correctly  

    thanks

    Are your accountants OK with this settlement procedure?

    we don't have any option now , so yes

    Best regards,

  • Suggested answer
    guk1964 Profile Picture
    10,888 on at

    Do they have fiscal periods open for the last 2 years?

    Has there been no year end close?

    If you have 20,000 customer ids to deal with  then your  code needs to pass in the relevant id 20,000 times. It ahs hard coded for one customer.

    Your code should check  whether an invoice is already marked with some payment, or not.

    protected boolean checkIfAlreadyMark(CustVendTransOpen _custVendTransOpen)

    {

       specTransManager specTransManager = specTransManager::construct(_custVendTransOpen);

       return specTransManager.existForOtherSpec(_custVendTransOpen.company(), _custVendTransOpen.TableId, _custVendTransOpen.RecId);

    }

    Then settle  the invoice with the payment.

    protected void markSettlement(CustVendTransOpen _custVendTransOpen)

    {

       CustVendOpenTransManager manager = CustVendOpenTransManager::construct(ledgerJournalTrans);

       manager.updateTransMarked(_custVendTransOpen, true);

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

    I'm not a developer who can help you with that code but there is a standard functionality available that is exactly doing this automatic settlement based on the date transactions were recorded. Maybe you are able to borrow from the way how this is implemented. You can find additional information here: docs.microsoft.com/.../scenario-automatic-settlement-and-prioritization Best regards, Ludwig

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans