diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-16 10:29:07 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-16 10:29:07 +0100 |
commit | 82e401a77303fca1dc977ee3662d7364bb946ff3 (patch) | |
tree | 0a692769cccf459bed1fcd5f0b76cf0e70fdf2db /src/helpers.ts | |
parent | 665c1d80726ce2ffdf0020de9c4dd293ccbee849 (diff) |
make fractional base a constant
Diffstat (limited to 'src/helpers.ts')
-rw-r--r-- | src/helpers.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/helpers.ts b/src/helpers.ts index 2e7a701c3..d9b62aa22 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -23,7 +23,7 @@ /// <reference path="../decl/urijs/URIjs.d.ts" /> -import {AmountJson} from "./types"; +import {AmountJson, Amounts} from "./types"; import URI = uri.URI; export function substituteFulfillmentUrl(url: string, vars: any) { @@ -34,7 +34,7 @@ export function substituteFulfillmentUrl(url: string, vars: any) { export function amountToPretty(amount: AmountJson): string { - let x = amount.value + amount.fraction / 1e6; + let x = amount.value + amount.fraction / Amounts.fractionalBase; return `${x} ${amount.currency}`; } @@ -63,7 +63,7 @@ export function parsePrettyAmount(pretty: string): AmountJson|undefined { } return { value: parseInt(res[1], 10), - fraction: res[2] ? (parseFloat(`0.${res[2]}`) * 1e-6) : 0, + fraction: res[2] ? (parseFloat(`0.${res[2]}`) / Amounts.fractionalBase) : 0, currency: res[3] } } |