Thursday, June 13, 2019

How to mark Vendor open settlement transaction using x++ code in Ax 2012

How to mark Vendor open settlement transaction using x++ code in Ax 2012
public void settlementnew(InvoiceId   _invoice)
{
    custvendopentransmanager            manager;
    VendTransOpen                       vendTransOpen;
    VendTrans                           vendTrans;
    ExchangeRateHelper                  exchangeRateHelper;
    AmountCur                           totalSettlement;

    //To mark particular invoice based on Acc num
    select vendtransopen where vendTransOpen.AccountNum ==AccountNumb
                join vendTrans where vendTrans.Invoice == _invoice
                     && vendTrans.RecId == vendtransopen.RefRecId
                    && vendTrans.AccountNum == vendTransOpen.AccountNum;
 
    if(vendtransopen)
    {
        //To check transaction line which we want to settle
        manager = custvendopentransmanager::construct(ledgerJournalTrans);
        manager.updateTransMarked(vendTransOpen,true);
 
        //To get total settlement
        exchangeRateHelper = ExchangeRateHelper::newCurrency(Ledger::primaryLedger(CompanyInfo::findDataArea(ledgerJournalTrans.Company).RecId),ledgerJournalTrans.CurrencyCode);
        totalSettlement    = SpecTransManager::getTotalSettleAmountForSpecReference(
                                ledgerJournalTrans.Company,
                                ledgerJournalTrans.TableId,
                                ledgerJournalTrans.RecId,
                                ledgerJournalTrans.CurrencyCode,
                                ledgerJournalTrans.Company,
                                ledgerJournalTrans.TransDate,
                                exchangeRateHelper.prepareExchangeRateForStorage(ledgerJournalTrans.crossrate()));
        //To update in ledgerJournal trans
        ttsBegin;
        ledgerJournalTrans.selectForUpdate(true);
        ledgerJournalTrans.AmountCurDebit   = abs(totalSettlement);
        ledgerJournalTrans.SettleVoucher    = SettlementType::SelectedTransact;
        ledgerJournalTrans.update();
        ttsCommit;
    }

}

4 comments:

  1. Thanks for sharing this informative content , Great work
    Leanpitch provides online training in Devops Online Training during this lockdown period everyone can use it wisely.
    Devops Online Training

    ReplyDelete
  2. It's really Nice Blog!! Thank you for sharing with us..
    DevOps Training
    DevOps Online Training

    ReplyDelete
  3. My name is Jennifer from New Jersey , I saw comments from people who had already got their loan from Anderson Loan Finance. Honestly, I thought it was a scam, and then I decided to make a request based on their recommendations. A few days ago, I confirmed in my personal bank account amounting to $63,000 dollars which I applied for. This is really good news and I am so very happy that I advise all those who need a real loan and who are sure to reimburse to apply through their email pedroloanss@gmail.com. There are sincere loan lenders! They are capable of lending you a loan. Contact Mr Pedro E-mail: pedroloanss@gmail.com

    ReplyDelete

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...