@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
@@ -1,5 +1,11 @@
1
1
  # @commercetools/connect-payments-sdk
2
2
 
3
+ ## 0.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 36f0d66: Fix the issue with rounding currency amounts
8
+
3
9
  ## 0.16.0
4
10
 
5
11
  ### Minor Changes
@@ -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
- return amount * (1 * Math.pow(10, fractionDigit));
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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/connect-payments-sdk",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Payment SDK for commercetools payment connectors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",