fix: don't divide zero decimal currencies

This commit is contained in:
Sebastian Rindom committed 2021-03-22 10:31:22 +01:00
1 parent 2b282bd742
commit cfab2d408a
5 files changed
+95 -24

No files matched your search

@@ -0,0 +1,13 @@
import zeroDecimalCurrencies from "./zero-decimal-currencies"
const humanizeAmount = (amount, currency) => {
let divisor = 100
if (zeroDecimalCurrencies.includes(currency.toLowerCase())) {
divisor = 1
}
return amount / divisor
}
export default humanizeAmount
+2
View File
@@ -5,3 +5,5 @@ export { default as MedusaError } from "./errors"
export { default as getConfigFile } from "./get-config-file"
export { default as createRequireFromPath } from "./create-require-from-path"
export { default as compareObjectsByProp } from "./compare-objects"
export { default as zeroDecimalCurrencies } from "./zero-decimal-currencies"
export { default as humanizeAmount } from "./humanize-amount"
@@ -0,0 +1,20 @@
const zeroDecimalCurrencies = [
"bif",
"clp",
"djf",
"gnf",
"jpy",
"kmf",
"krw",
"mga",
"pyg",
"rwf",
"ugx",
"vnd",
"vuv",
"xaf",
"xof",
"xpf",
]
export default zeroDecimalCurrencies