web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to get vendor/invoice settlement amount and balance in foreign currency in x++? AX 2012 R2

(0) ShareShare
ReportReport
Posted on by 1,813

Hii,

I have a customized SSRS report based on RDP class that shows vendor advance payments.

vend-settlement-on-foreign-currency.png

The requirement is to show both currencies. Local accounting currency is SAR.

If all transactions/payments currency is e.g. EUR then dr, cr and balance is correct in Foreign Currency and SAR in above report.

But if pay in different currency as in above case SAR is not converting to foreign currency.

Please guide how we can convert SAR to foreign currency in this case. I am using RDP for business logic.

Here is the x++.

[SysEntryPointAttribute]
public void processReport()
{
    CustVendTransDetails vendTransDetails;

    VendPrepaymentContract4 vendPrepaymentContact4 = this.parmDataContract();
    QueryRun queryRun_VendAccountStatementInt;

    fromDate = vendPrepaymentContact4.parmFromDate();
    toDate = vendPrepaymentContact4.parmToDate();
    invoiceType = vendPrepaymentContact4.parmInvoiceType();

    if (BankLCImportFeatureChecker::checkBankLCImportEnabled())
    {
        bankLCBankDocumentType = vendPrepaymentContact4.parmBankLCBankDocumentType();
    }

    custVendTransDetails = new CustVendTransDetails(vendTrans, this.assessmentDate());
    queryRun_VendAccountStatementInt = new QueryRun(this.parmQuery());


    this.initVendTransQuery();
    this.init();

    while (queryRun_VendAccountStatementInt.next())
    {
        vendTable = queryRun_VendAccountStatementInt.get(tableNum(VendTable));

        vendTransQueryRun.reset();
        vendTransQueryRun.query().dataSourceTable(tableNum(VendTrans)).rangeField(fieldNum(VendTrans,AccountNum)).value(SysQuery::value(vendTable.AccountNum));

        while (vendTransQueryRun.next())
        {
            if (SysReportRun::changed(vendTransQueryRun,tableNum(VendTrans)))
            {
                vendTrans = vendTransQueryRun.get(tableNum(VendTrans));
                select firstFast vendInvoiceJour where vendInvoiceJour.InvoiceId == vendTrans.Invoice;
                this.insertVendPrepaymentTmp4();
            }
        }
    }
}


private void insertVendPrepaymentTmp4()
{
    vendPrepaymentTmp4.clear();
    vendPrepaymentTmp4.AccountNum = vendTable.AccountNum;
    vendPrepaymentTmp4.Voucher = vendTrans.Voucher;
    vendPrepaymentTmp4.TransDate = vendTrans.TransDate;
    vendPrepaymentTmp4.Txt = vendTrans.Txt;
    vendPrepaymentTmp4.Debit = this.debitBalanceMST();
    vendPrepaymentTmp4.Credit = -(this.creditBalanceMST());
    vendPrepaymentTmp4.CurrencyCode = vendTrans.CurrencyCode;
    vendPrepaymentTmp4.TraceNum =  vendTrans.traceNum();
    vendPrepaymentTmp4.Reversed = this.reversed();
    vendPrepaymentTmp4.Name = vendTable.name();
    vendPrepaymentTmp4.InternalInvoiceId = vendInvoiceJour.InternalInvoiceId;
    vendPrepaymentTmp4.TransType = vendTrans.TransType;
vendPrepaymentTmp4.AmountCurrencyDebit = this.debitBalanceCur();
vendPrepaymentTmp4.AmountCurrencyCredit = -(this.creditBalanceCur());

balance = vendPrepaymentTmp4.Debit + this.creditBalanceMST(); 
balanceCur = vendPrepaymentTmp4.AmountCurrencyDebit + this.creditBalanceCur();

vendPrepaymentTmp4.Balance = balance;
vendPrepaymentTmp4.BalanceCur = balanceCur;


    if(vendTrans.Invoice)
        vendPrepaymentTmp4.DocumentNum = vendTrans.Invoice;
    else
        vendPrepaymentTmp4.DocumentNum = vendTrans.DocumentNum;

        
             vendPrepaymentTmp4.insert();
       
    }

}


 

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
Basit Profile Picture

Basit 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans