Pages

Monday, October 28, 2013

Automatic Conversion of Sales on the Exchange Rate of the Day (Utilizing of Currency API)

"Sales Report" from each branch, want preliminary aggregation of them?

With the Daily Report Workflow (*) which was introduced last time, you can grasp daily sales fluctuations. You can easily aggregate the sales of any period of time using the filtering function. But if some parts of the sales report were in different currencies???
* "Meanings of Taking In the Meteorological Data to 'Daily Reports' (Utilizing Weather API)"


The following Workflow is based on the "Daily Report flow" of the last time, added a function to convert the sales according to the exchange rate of the day. With the exchange rate information retrieved automatically from the internet, it converts the sales that the managers of the oversea brunches entered local in currency to the currency of the head office automatically. Isn't it wonderful, the automatic 'preliminary' aggregation of the sales, even though the actual value differs a little because the timing of exchange might be different?

[Daily Report flow-Currency Exchange]



[Daily Report flow-Currency Exchange: '1. Submit Daily Report' screen]


In this example, it calls API published by the Google (unofficial API). The practical "request" to be sent and "response" to be returned are as follows.

- API Request
http://www.google.com/ig/calculator?hl=en&q=1USD=?JPY

- JSON Response
{lhs: "1 U.S. dollar",rhs: "98.0392157 Japanese yen",error: "",icc: true}

The script (the contents of the setting in Script Task) to convert to business data of "Sales in JPY" from "Sales in USD" by utilizing currency exchange data that is retrieved automatically, is as follows. If you are a master of Excel, you will come up with a variety of applications.

var exchangerate = data.get("15").match(/rhs: "([0-9]*.[0-9]*)/);
retVal.put("9", java.math.BigDecimal( Math.floor(exchangerate[1] * data.get("17")) ) );
retVal.put("10", java.math.BigDecimal( Math.floor(exchangerate[1] * data.get("18")) ) );

[Process Data Item setting screen]

[Download]
<Similar Models>
<<Related Articles>>