Skip to content

Commit

Permalink
feat(currency): add XTS currency (#44)
Browse files Browse the repository at this point in the history
* feat(currency): add XTS

* fix(currency): fix xts currency generation

* fix(currency): fix override condition
  • Loading branch information
kzmnbrs authored Sep 24, 2024
1 parent e32a1bb commit e3e8dfc
Show file tree
Hide file tree
Showing 3 changed files with 6,111 additions and 6,084 deletions.
24 changes: 21 additions & 3 deletions currency/.generator/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ const xml2js = require("xml2js");
const yaml = require("yaml");
const fs = require("fs");

const currencyOverrides = {
XTS: {
country: '[TEST] XTS',
decimalPlaces: 1,
}
}

let resp = request(
"GET",
"https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list-one.xml"
Expand Down Expand Up @@ -236,15 +243,18 @@ let goCodePromise = xml2js
return;
}

if (row["CcyMnrUnts"][0] === "N.A.") {
const currencyCode = row["Ccy"][0]
const override = currencyOverrides[currencyCode]

if (row["CcyMnrUnts"][0] === "N.A." && (!override || !override.decimalPlaces)) {
return;
}

if (row["CcyNm"][0] === "No universal currency") {
if (row["CcyNm"][0] === "No universal currency" && (!override || !override.country)) {
return;
}

return {
let parsedCurrency = {
country: row["CtryNm"][0],
currency:
typeof row["CcyNm"][0] !== "object"
Expand All @@ -254,6 +264,14 @@ let goCodePromise = xml2js
number: row["CcyNbr"][0],
decimalPlaces: isNaN(row["CcyMnrUnts"]) ? 0 : parseInt(row["CcyMnrUnts"]),
};

if (override && typeof override === "object") {
Object.entries(override).forEach(([key, value]) => {
parsedCurrency[key] = value;
})
}

return parsedCurrency
});

result = result
Expand Down
Loading

0 comments on commit e3e8dfc

Please sign in to comment.