Subscribe via RSS Feed Connect on LinkedIn

Dynamics NAV 1013R2 Global Currency Part 2

2nd November 2014 0 Comments

This post is the Forth in a Series on Microsoft Dynamics Nav 2013R2 Development, Parts One and Two Covered Module 1, this Post is the “Code Behind” Module 2 a Global Currency Dashboard Shown in Part One this Module, “Objects in Text Format can be Downloaded” at the Foot of this Post.

This Scenario has come up before on several occasions however I had never Designed a Solution, many Companies Deal with Multi-Currencies in multiple Companies, when they want to Update the Currency Rates they go into each Company and manually Update the Rates one Line at a Time, if there are a few Companies this can be very Time Consuming.

Module Two requires a more advanced solution than Module 1 and can be run in a Parent Company, the Global Currency Workbook has the following Functions, Get Currencies across all Companies, Get Currency Exchange Rates across all Companies, update the Rates by Triangulation of the Rates from the Parent Company and Insert or Update the Rates across all Companies.

In this Post I will only be showing some of the Code Behind Module two as all the code can be downloaded at the Foot of This Page, there are some field name changes from Module 1, if you have a working copy of Module 1 then delete the Table Contents before Importing the Changed Objects.

 

New Table 50003: Currency Setup

This Table is used to Hold some Default Values, More Fields will be added for the third and Final Module.

20141102190818

 

There is a little Validation Code in two of the Fields when the Management is set as “Manage All” the two fields cannot be Blank.

20141102191129

 

Table 50002: Global Exchange Rate

This table has had a couple of Fields Re-Named and New Validation Code to Maintain the “Inverse Exchange Rate” Calculation, and “Exchange Rate” Calculation.

20141102191553

 

Page: 50008: Global Currency Worksheet

This Page is Used to Manage the Global Currencies and has Page Actions like the Currency Worksheet to Populate and Assign the Data and has a Table Relation to the Currency Setup Table.

20141102191948

 

Codeunit 50002 Currency Dashboard Management

Some of the Functions from Module 1 have been Updated to Deal with Global Currencies by Populating the Company Name into the Name Field, the ApplyCurrencyRates function had an error where it only Updated One line at a time this has been fixed.

Function: GetGlobalCurrencies

The Function GetGlobalCurrencies populated the Global Currencies from the existing records from the Companies, which are populated on the Currency Dashboard, new Variables GlobalName and LCYCode are now used in the different Functions, the first part of code checks if there are Global Currencies .

20141102192742

The Code Loops through the Company Currencies adding a record for the “Global Company” if it does not already exist.

20141102192926

 

Function GetGlobalRates

This function Loops Through the Different Company and Updates the “Currency Workbooks” with Related Records, it starts deleting all “Global Exchange Rates” and entering a “Global Name” Locked Record for the LCY Code.

20141102193455

 

Looping Through the Company Table to see if there are any Currency Records, getting the G/L Setup and testing the “LCY Code”.

20141102193534

 

Only if there is a Global Currency as well as a Global Currency a Locked Company Record is Inserted, if the “LCY Code” is equal to the Global LCY Code then an Un-Locked Global Record is Entered.

20141102193634

 

Function GetGlobalCurrencyRates

This Function adds any Missing Global Currency Exchange Rates after calling the GetGlobalRates Function.

20141102193026

When the Currencies are found the code Loops through and Adds a record for the ‘GlobalName’ if one does not already Exist, note the use of the Variables GlobalName and LCYCode and the “Exchange Rate Amount” Rate is set as 1.

20141102193127

 

Function SetGlobalCurrencyRate

The Code that Triangulates the Company Currency Exchange Rates can be found if this Function, if the Global Currency was GBP and the Company Exchange Rate Record had an LCY Code of EUR and a Currency Code of USD, then the Global EUR and USD records are found and the Currency Rate is Triangulated.

20141102193852

 

I hope this Post is of Use, Please take time to Comment and Feedback, I will Post Module 3 in about a Weeks Time.

[download id=”509″]

Please Share this Post:

Leave a Reply

Spam protection by WP Captcha-Free