Showing posts with label AX2012. Show all posts
Showing posts with label AX2012. Show all posts

Friday, May 31, 2019

Get Invoice Journal Id after posting Sales Invoice from multiple packing slips using X++

SalesFormLetter_Invoice SalesFormLetter;
TmpFrmVirtual           tmpFrmVirtual;
List                    il;
;
il = new List(Types::Record);
// insert each packing slip RecId into the TmpFrmVirtual table
for (i = 1; i <= conlen(PScontainer); i++)
{
            packingSlipRecId = conpeek(PScontainer, i);
            custPackingSlipJour = custPackingSlipJour::findRecId(packingSlipRecId);     

            tmpFrmVirtual.NoYes     = true;
            tmpFrmVirtual.TableNum  = custPackingSlipJour.TableId;
            tmpFrmVirtual.RecordNo  = custPackingSlipJour.RecId;
            tmpFrmVirtual.Id        = custPackingSlipJour.SalesId;
            ttsBegin;
            tmpFrmVirtual.insert();
            ttsCommit;
            // add record into the List
            il.addEnd(tmpFrmVirtual);
}
// post invoice from multiple packing slips
        salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
        salesFormLetter.printFormLetter(false);
        salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::PackingSlip, AccountOrder::None, false, false, false, false, il.pack());
        // get the posted invoice journal recid
        invoiceJourRecId    = salesFormLetter.getOutputContract().parmJournal().RecId;


or  get a container of posted journals

CustInvoiceTrans        custInvTrans;
Set                     postedJournalList;
Set                     allPostedJournals = new Set(Types::Record);
SetEnumerator           enumAllPostedJournal;
Set                     postedJournalTransList;
SetEnumerator           enumPostedJournalTransList;


postedJournalList   = Set::create(SysOperationHelper::base64Decode(salesFormLetter.getOutputContract().parmAllJournals()));
allPostedJournals   = Set::union(allPostedJournals, postedJournalList);
postedJournalTransList      = Set::create(SysOperationHelper::base64Decode(salesFormLetter.getOutputContract().parmJournalLines()));
enumPostedJournalTransList  = postedJournalTransList.getEnumerator();

while(enumPostedJournalTransList.moveNext())
 {
        custInvTrans      = enumPostedJournalTransList.current();
        // process the data here
 }




Thursday, May 30, 2019

Convert from Transaction currency to Accounting currency

CurrencyExchangeHelper  currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), _invoicejournal.InvoiceDate);

lineCharges = currencyExchangeHelper.calculateTransactionToAccounting(_invoicejournal.CurrencyCode, lineCharges, true);


Thursday, November 29, 2018

Thursday, May 31, 2018

Rounding amount based on Rounding Rule setup in Currency

customsInfo.InvoiceAmount  = CurrencyExchangeHelper::roundWithRuleType(customsInfo.InvoiceAmount,param.CurrencyCode,CurrencyRoundingRuleType::SalesOrder);

Debug in a Tier-2 (UAT) environment

 From time to time, you may have to debug a copy of the production database, but you are unable to export & import the DB to your dev ma...