Tuesday, 18 August 2015

Settle Vendor Invoice/Payment through X++ code - AX 2012

Hello Guys..!

Here I'm sharing code for Settle Vendor Invoice/Payment through X++ 

Code:
-----------
static void VendorSettlement(Args _args)
{
VendTable vendTable;
VendTrans invVendTrans, payVendTrans;
SpecTransManager manager;
CustVendTransData custVendTransData;
;
vendTable = VendTable::find("12345");
// Find the oldest unsettled invoice
select firstonly invVendTrans  order by TransDate asc
                            where invVendTrans.AccountNum == vendTable.AccountNum &&
                            invVendTrans.TransType == LedgerTransType::Purch &&
                            !invVendTrans.closed;
// Find the oldest unsettled payment
select firstonly payVendTrans order by TransDate asc
                    where payVendTrans.AccountNum == vendTable.AccountNum &&
                    payVendTrans.TransType == LedgerTransType::Payment &&
                    !payVendTrans.closed;
ttsbegin;
// Create an object of the CustVendTransData class with the invoice transaction as parameter
custVendTransData = CustVendTransData::construct(invVendTrans);
// Mark it for settlement
custVendTransData.markForSettlement(vendTable);
// Create an object of the CustVendTransData class with the payment transaction as parameter
custVendTransData = CustVendTransData::construct(payVendTrans);
//mark it for settlement
custVendTransData.markForSettlement(vendTable);
ttscommit;
// Settle all marked transactions
if(VendTrans::settleTransact(vendTable, null, true,SettleDatePrinc::DaysDate, systemdateget()))
info("Transactions settled");
}


@Rahul Talasila

7 comments:

  1. The code runs but does not do the update, probably u left out this step

    ReplyDelete
  2. I have same problem code runs but can't mark settlement. Can you share me the missing setps

    ReplyDelete
    Replies
    1. Hi Rahul,
      I have a scenario where I mark the vendor open transactions via x++ and update amount to settle column. Then I post PO invoice via x++. Then I need to settle partial payment (value given in update settlement amount)against the posted invoice. The method you posted completely settles payment against invoice, where as I want to settle partial payment. Plz share the sample code.
      Thanks
      Anamika

      Delete
  3. Hi
    is this code used with d365fo or just for ax 2012

    ReplyDelete
  4. 정보이용료(콘텐츠이용료)는 소액결제 진행방법과는 다르게 휴대폰 사용자가 직접 어플을 본인읜 휴대폰에 다운받고, 콘텐츠를 구매하여 매입자에게 판매하는 방식인데, 어렵다고 생각 되어도 직접 해보시면 실제로 소액결제 현금화 보다 훨씬 간단하다고 느끼실 겁니다.  정보이용료 현금화

    ReplyDelete

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...