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;
    }

}

2 comments:

  1. 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...