@medipass/utils 11.58.1 → 11.58.3

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
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [11.58.3](https://github.com/medipass/web/compare/@medipass/utils@11.58.2...@medipass/utils@11.58.3) (2021-12-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * item totals section ([#605](https://github.com/medipass/web/issues/605)) ([1b12e67](https://github.com/medipass/web/commit/1b12e67))
12
+
13
+
14
+
15
+
16
+
17
+ ## [11.58.2](https://github.com/medipass/web/compare/@medipass/utils@11.58.1...@medipass/utils@11.58.2) (2021-12-17)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * calculate item totals in services section ([#602](https://github.com/medipass/web/issues/602)) ([e6267fe](https://github.com/medipass/web/commit/e6267fe))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [11.58.1](https://github.com/medipass/web/compare/@medipass/utils@11.58.0...@medipass/utils@11.58.1) (2021-12-15)
7
29
 
8
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medipass/utils",
3
- "version": "11.58.1",
3
+ "version": "11.58.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -47,5 +47,5 @@
47
47
  "redux-thunk": "^2.2.0",
48
48
  "rimraf": "^2.6.2"
49
49
  },
50
- "gitHead": "c49f7daca78a8752ab17653f2d711695add164d5"
50
+ "gitHead": "f524d6cfe9e2383b8a1bc07b85efc3057504cbc5"
51
51
  }
package/service-items.js CHANGED
@@ -33,11 +33,9 @@ var calculateTotalAmount = function calculateTotalAmount(serviceItems, opts) {
33
33
  includeQuantity = false;
34
34
  }
35
35
 
36
- var prices = calculatePrices({
36
+ var prices = calculateAmounts({
37
37
  isTaxable: Boolean(opts.includeGST && item.isTaxable),
38
- isGross: item.isGross,
39
- initialFeeAmount: (item == null ? void 0 : item.feeAmount) ? parseFloat((item == null ? void 0 : item.feeAmount) || 0) : parseFloat((item == null ? void 0 : item.initialFeeAmount) || 0),
40
- isExtendedPrice: item == null ? void 0 : item.isExtendedPrice,
38
+ initialGrossAmount: parseFloat((item == null ? void 0 : item.grossAmount) || 0),
41
39
  quantity: includeQuantity ? item.quantity : 1
42
40
  });
43
41
  var itemTotal = undefined;
@@ -74,11 +72,9 @@ var calculateTotalGSTAmount = function calculateTotalGSTAmount(serviceItems, opt
74
72
  includeQuantity = false;
75
73
  }
76
74
 
77
- var prices = calculatePrices({
75
+ var prices = calculateAmounts({
78
76
  isTaxable: item.isTaxable,
79
- isGross: item.isGross,
80
- initialFeeAmount: (item == null ? void 0 : item.feeAmount) ? parseFloat((item == null ? void 0 : item.feeAmount) || 0) : parseFloat((item == null ? void 0 : item.initialFeeAmount) || 0),
81
- isExtendedPrice: item == null ? void 0 : item.isExtendedPrice,
77
+ initialGrossAmount: parseFloat((item == null ? void 0 : item.grossAmount) || 0),
82
78
  quantity: includeQuantity ? item.quantity : 1
83
79
  });
84
80
  var gstAmount = prices == null ? void 0 : prices.taxAmount;
@@ -196,64 +192,32 @@ function mapItemsToClaimItems(transaction) {
196
192
  });
197
193
  return newItems;
198
194
  }
199
-
200
- var round2DecimalPlaces = function round2DecimalPlaces(num) {
201
- return Math.round((num + Number.EPSILON) * 100) / 100;
202
- };
203
-
204
- var calculatePrices = function calculatePrices(_ref3) {
195
+ var calculateAmounts = function calculateAmounts(_ref3) {
205
196
  var isTaxable = _ref3.isTaxable,
206
- isGross = _ref3.isGross,
207
- initialFeeAmount = _ref3.initialFeeAmount,
208
- isExtendedPrice = _ref3.isExtendedPrice,
209
- _ref3$quantity = _ref3.quantity,
210
- quantity = _ref3$quantity === void 0 ? 1 : _ref3$quantity;
211
-
212
- function getTotalsWithQuantity(_ref4) {
213
- var taxAmount = _ref4.taxAmount,
214
- feeAmount = _ref4.feeAmount,
215
- grossAmount = _ref4.grossAmount;
216
- if (isExtendedPrice) return {
217
- taxAmount: taxAmount,
218
- feeAmount: feeAmount,
219
- grossAmount: grossAmount
220
- };
221
- return {
222
- grossAmount: grossAmount * quantity,
223
- feeAmount: feeAmount * quantity,
224
- taxAmount: taxAmount * quantity
225
- };
226
- }
227
-
228
- var grossAmount = parseFloat(initialFeeAmount || 0);
229
- var feeAmount = parseFloat(initialFeeAmount || 0);
197
+ initialGrossAmount = _ref3.initialGrossAmount;
198
+ var grossAmount = parseFloat(initialGrossAmount || 0);
199
+ var feeAmount = parseFloat(initialGrossAmount || 0);
230
200
  var taxAmount = 0;
231
201
 
232
202
  if (!isTaxable) {
233
- return getTotalsWithQuantity({
234
- grossAmount: grossAmount,
203
+ return {
204
+ taxAmount: taxAmount,
235
205
  feeAmount: feeAmount,
236
- taxAmount: taxAmount
237
- });
238
- }
239
-
240
- if (isGross) {
241
- taxAmount = parseFloat(round2DecimalPlaces(grossAmount / 11).toFixed(2) || 0);
242
- feeAmount = grossAmount - taxAmount;
243
- } else {
244
- taxAmount = parseFloat((feeAmount * 1.1).toFixed(6)) - feeAmount;
245
- grossAmount = feeAmount + taxAmount;
206
+ grossAmount: grossAmount
207
+ };
246
208
  }
247
209
 
248
- return getTotalsWithQuantity({
249
- grossAmount: grossAmount,
210
+ feeAmount = feeAmount - feeAmount / 11;
211
+ taxAmount = parseFloat((feeAmount * 1.1).toFixed(6)) - feeAmount;
212
+ return {
213
+ taxAmount: taxAmount,
250
214
  feeAmount: feeAmount,
251
- taxAmount: taxAmount
252
- });
215
+ grossAmount: grossAmount
216
+ };
253
217
  };
254
218
 
255
219
  exports.applyDiscountToServiceItems = applyDiscountToServiceItems;
256
- exports.calculatePrices = calculatePrices;
220
+ exports.calculateAmounts = calculateAmounts;
257
221
  exports.calculateTotalAmount = calculateTotalAmount;
258
222
  exports.calculateTotalDiscountAmount = calculateTotalDiscountAmount;
259
223
  exports.calculateTotalGSTAmount = calculateTotalGSTAmount;