Configure Exchange Rate according to Document Date in D365 BC

Configure Exchange Rate according to Document Date in D365:

(1) According to the Microsoft Dynamics 365 Business Central, we get the Exchange Rate value according to the “Posting Date” of documents.

(2) But in this blog, we will see how to configure a custom setup for Exchange Rate value according to the “Document Date” of the document.

(3) For this, we will take an example of “Purchase Order”. First configured “Currency Setup” as shown.

  • Currency Setup: Open Currencies page.
search currencies in business central
  • The currencies list opens as shown.
currencies list opens in bc d365
  • After that, select the currency and set up its Exchange Rate as shown.
select the currency and set up its Exchange Rate in dynamics 365
  • The Exchange Rate page opens and enters the currency rate date wise as shown.
Exchange Rate page opens and enters the currency rate date wise in d365 bc

(4) Now go to the search box and type “Purchase Order”, as shown.

Search Purchase Orders in Business Central

(5) Purchase Order list opens and creates a new Purchase order or opens existing Purchase Order. In this example, the existing Purchase Order opens and sees the functionality of the Exchange Rate value.

By default, Functionality by Microsoft:

  • Exchange Rate Value gets according to the “Posting Date of Purchase Order as shown.
Exchange Rate Value gets according to the Posting Date in bc d365
  • The system asks for confirmation, Press Yes, as shown.
click on yes to update the exchnage rate in bc d365
  • The system again asks for confirmation, Press Yes, as shown.
Press yes to update line for exchnage rate in bc d365
  • Now go to the “Invoice Details” tab and click on the Assist button of the “Currency Code” field, as shown.
change exchange rate in business central

Custom Setup:

  • Custom Functionality developed in which Exchange Rate Value gets according to the “Document Date” of Purchase Order as shown.
custom set up for exchnage rate in bc d365
  • The system asks for confirmation, Press Yes, as shown.
click on yes to update the exchnage rate in bc d365
  • The system again asks for confirmation, Press Yes, as shown.
Press yes to update line for exchnage rate in bc d365
  • Now go to the “Invoice Details” tab and click on the Assist button of the “Currency Code” field, as shown.
change exchange rate in business central
  • For the above custom functionality, do the below development, as shown.
Source code for exchange rate set up in business central

Source Code:

codeunit 50102 CurrenctExchangeRateSetup
{
 
    [EventSubscriber(ObjectType::Table, Database::”Purchase Header”,
    ‘OnUpdateCurrencyFactorOnAfterCurrencyDateSet’, ”, False, false)]
    procedure UpdateExchangeRate(var PurchaseHeader: Record “Purchase Header”; var CurrencyDate: Date; CurrentFieldNo: Integer)
    var
    begin
CurrencyDate := PurchaseHeader.”Document Date”;
CurrentFieldNo := PurchaseHeader.fieldno(“Document Date”);
    end;
 
    [EventSubscriber(ObjectType::Table, Database::”Purchase Header”,
    ‘OnAfterValidateEvent’, ‘Document Date’, False, false)]
    procedure CallOnUpdateExchangeRate(var Rec: Record “Purchase Header”; xRec: Record “Purchase Header”; CurrFieldNo: Integer)
    var
    begin
        if Rec.”Currency Code” <> ” then begin
Rec.UpdateCurrencyFactor();
            if Rec.”Currency Factor” <>xRec.”Currency Factor” then
Rec.ConfirmCurrencyFactorUpdate();
        end;
    end;
}

How to Attach and Download Files and Images in Documents in D365 BC
System Requirement and Architecture of D365 BC SAAS and On-Prem version
Correct or Cancel a Posted Purchase Invoice in D365 BC
Purchase Order Report in D365 BC Format and Development
Update Currency Exchange Rates– Microsoft Docs

Leave a Reply