Showing posts with label customer. Show all posts
Showing posts with label customer. Show all posts

Thursday, December 3, 2020

Get Open Closed Transactions of selected customer in Ax 2012 using x++

 Hi guys, Today we see how to get Open Closed Transactions of selected customer in Ax 2012 using x++.

Run the below job.

static void OpenClosedTransactions(Args _args)

{

    CustTable       custtable;

    CustTrans       custtrans;

    CustTransOpen   custtransopen;

    CustSettlement  custsettlement;


    //OpenTransactions


    while  select custtable

        where custtable.AccountNum == 'US-004'

    join custtrans

        where  custtable.AccountNum == custtrans.AccountNum

    join  custtransopen

        where custtrans.RecId == custtransopen.RefRecId

    {

        info(strfmt('%1,%2,%3,%4,%5',custtable.AccountNum,custtrans.Voucher,custtransopen.AmountCur,custtrans.TransDate,custtransopen.DueDate));

    }


    //ClosedTransactions


    while  select custtable

        where custtable.AccountNum == 'US-004'

    join custtrans

        where  custtable.AccountNum == custtrans.AccountNum

    join  custsettlement

        where custtrans.RecId == custsettlement.TransRecId

    {

        info(strfmt('%1,%2,%3,%4,%5',custtable.AccountNum,custtrans.Voucher,custsettlement.settleAmountCur,custtrans.TransDate,custsettlement.DueDate));

    }


    //sum of open and closed transactions


     while select sum(settleAmountCur) from custsettlement

        where custsettlement.AccountNum == 'US-010'

    {

        info(strfmt('%1',custsettlement.settleAmountCur));

    }



     while select sum(AmountCur) from custtransopen

        where custtransopen.AccountNum == 'US-010'

    {

        info(strfmt('%1',custtransopen.AmountCur));

    }

}

Keep Daxing!!