@commercetools/connect-payments-sdk 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* @example (12345, 2) => 1234500
|
|
16
16
|
* @example (12345, 3) => 12345000
|
|
17
17
|
*
|
|
18
|
+
*
|
|
19
|
+
* @param amount Integer value to apply the fraction digit to
|
|
20
|
+
* @param fractionDigit The fraction digit to apply
|
|
18
21
|
* @throws an Error if the given fraction digit (either via mapping or directly) is not a integer value
|
|
19
22
|
*/
|
|
20
23
|
declare const convert: (amount: number, fractionDigit: number) => number;
|
|
@@ -23,11 +23,16 @@ const validateFractionDigit = (fractionDigit) => {
|
|
|
23
23
|
* @example (12345, 2) => 1234500
|
|
24
24
|
* @example (12345, 3) => 12345000
|
|
25
25
|
*
|
|
26
|
+
*
|
|
27
|
+
* @param amount Integer value to apply the fraction digit to
|
|
28
|
+
* @param fractionDigit The fraction digit to apply
|
|
26
29
|
* @throws an Error if the given fraction digit (either via mapping or directly) is not a integer value
|
|
27
30
|
*/
|
|
28
31
|
const convert = (amount, fractionDigit) => {
|
|
29
32
|
validateFractionDigit(fractionDigit);
|
|
30
|
-
|
|
33
|
+
const result = amount * Math.pow(10, fractionDigit);
|
|
34
|
+
const strResult = result.toFixed(Math.abs(fractionDigit));
|
|
35
|
+
return parseFloat(strResult);
|
|
31
36
|
};
|
|
32
37
|
exports.convert = convert;
|
|
33
38
|
/**
|