@medipass/utils 11.54.4 → 11.55.1-fix-comcare-verify.0

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.55.0](https://github.com/medipass/web/compare/@medipass/utils@11.54.5...@medipass/utils@11.55.0) (2021-10-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * worksafe victoria ([#573](https://github.com/medipass/web/issues/573)) ([5a329ba](https://github.com/medipass/web/commit/5a329ba))
12
+
13
+
14
+
15
+
16
+
17
+ ## [11.54.5](https://github.com/medipass/web/compare/@medipass/utils@11.54.4...@medipass/utils@11.54.5) (2021-10-22)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * service item totals ([#574](https://github.com/medipass/web/issues/574)) ([04b60ae](https://github.com/medipass/web/commit/04b60ae))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [11.54.4](https://github.com/medipass/web-medicules/compare/@medipass/utils@11.54.3...@medipass/utils@11.54.4) (2021-10-21)
7
29
 
8
30
  **Note:** Version bump only for package @medipass/utils
package/constants.js CHANGED
@@ -100,9 +100,10 @@ var FUNDERS = {
100
100
  NDIS: 'ndis',
101
101
  OHC: 'ohc',
102
102
  PATIENT: 'patient-funded',
103
- WCQ: 'wcq'
103
+ WCQ: 'wcq',
104
+ WSV: 'wsv'
104
105
  };
105
- var FUNDERS_FORMATTED = (_FUNDERS_FORMATTED = {}, _FUNDERS_FORMATTED[FUNDERS.ADF] = 'Australian Defence Force', _FUNDERS_FORMATTED[FUNDERS.COMCARE] = 'Comcare', _FUNDERS_FORMATTED[FUNDERS.GARRISON] = 'Garrison', _FUNDERS_FORMATTED[FUNDERS.HBF] = 'HBF', _FUNDERS_FORMATTED[FUNDERS.HEALTHPOINT] = 'HEALTHPOINT', _FUNDERS_FORMATTED[FUNDERS.HICAPS] = 'HICAPS', _FUNDERS_FORMATTED[FUNDERS.ICARE] = 'icare', _FUNDERS_FORMATTED[FUNDERS.MEDICARE] = 'Medicare', _FUNDERS_FORMATTED[FUNDERS.NDIS] = 'NDIS', _FUNDERS_FORMATTED[FUNDERS.OHC] = 'Overseas health cover', _FUNDERS_FORMATTED[FUNDERS.PATIENT] = 'Patient funded', _FUNDERS_FORMATTED[FUNDERS.WCQ] = 'Workcover Queensland', _FUNDERS_FORMATTED);
106
+ var FUNDERS_FORMATTED = (_FUNDERS_FORMATTED = {}, _FUNDERS_FORMATTED[FUNDERS.ADF] = 'Australian Defence Force', _FUNDERS_FORMATTED[FUNDERS.COMCARE] = 'Comcare', _FUNDERS_FORMATTED[FUNDERS.GARRISON] = 'Garrison', _FUNDERS_FORMATTED[FUNDERS.HBF] = 'HBF', _FUNDERS_FORMATTED[FUNDERS.HEALTHPOINT] = 'HEALTHPOINT', _FUNDERS_FORMATTED[FUNDERS.HICAPS] = 'HICAPS', _FUNDERS_FORMATTED[FUNDERS.ICARE] = 'icare', _FUNDERS_FORMATTED[FUNDERS.MEDICARE] = 'Medicare', _FUNDERS_FORMATTED[FUNDERS.NDIS] = 'NDIS', _FUNDERS_FORMATTED[FUNDERS.OHC] = 'Overseas health cover', _FUNDERS_FORMATTED[FUNDERS.PATIENT] = 'Patient funded', _FUNDERS_FORMATTED[FUNDERS.WCQ] = 'Workcover Queensland', _FUNDERS_FORMATTED[FUNDERS.WSV] = 'WorkSafe Victoria', _FUNDERS_FORMATTED);
106
107
  /* ====== END: FUNDERS ======= */
107
108
 
108
109
  /* ====== START: FUTURES ======= */
@@ -334,6 +335,7 @@ var INVOICE_ORIGINATING_FLOW = {
334
335
  ALLIED_PHI: 'allied-phi',
335
336
  COMCARE: 'comcare',
336
337
  DVA: 'dva',
338
+ HEALTHPOINT: 'healthpoint',
337
339
  ICARE: 'icare',
338
340
  INSTALMENT_PLAN: 'instalment-plan',
339
341
  MEDICARE_BULK_BILLED: 'medicare-bulk-billed',
@@ -343,7 +345,7 @@ var INVOICE_ORIGINATING_FLOW = {
343
345
  PATIENT_FUNDED: 'patient-funded',
344
346
  VIRTUAL_TERMINAL: 'virtual-terminal',
345
347
  WORK_COVER_QUEENSLAND: 'wcq',
346
- HEALTHPOINT: 'healthpoint'
348
+ WORKSAFE_VICTORIA: 'wsv'
347
349
  };
348
350
  /* ====== END: INVOICE_ORIGINATING_FLOW ======= */
349
351
 
package/funders.js CHANGED
@@ -7,8 +7,8 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var constants = require('./constants.js');
8
8
  var _get = _interopDefault(require('lodash/get'));
9
9
 
10
- var FUNDERS_WITH_ONBOARDING = [constants.FUNDERS.HICAPS, constants.FUNDERS.MEDICARE, constants.FUNDERS.ICARE, constants.FUNDERS.WCQ, constants.FUNDERS.COMCARE];
11
- var CLAIMABLE_FUNDERS = [constants.FUNDERS.ADF, constants.FUNDERS.COMCARE, constants.FUNDERS.DVA, constants.FUNDERS.GARRISON, constants.FUNDERS.HEALTHPOINT, constants.FUNDERS.HICAPS, constants.FUNDERS.ICARE, constants.FUNDERS.MEDICARE, constants.FUNDERS.OHC, constants.FUNDERS.WCQ];
10
+ var FUNDERS_WITH_ONBOARDING = [constants.FUNDERS.HICAPS, constants.FUNDERS.MEDICARE, constants.FUNDERS.ICARE, constants.FUNDERS.WCQ, constants.FUNDERS.COMCARE, constants.FUNDERS.WSV];
11
+ var CLAIMABLE_FUNDERS = [constants.FUNDERS.ADF, constants.FUNDERS.COMCARE, constants.FUNDERS.DVA, constants.FUNDERS.GARRISON, constants.FUNDERS.HEALTHPOINT, constants.FUNDERS.HICAPS, constants.FUNDERS.ICARE, constants.FUNDERS.MEDICARE, constants.FUNDERS.OHC, constants.FUNDERS.WCQ, constants.FUNDERS.WSV];
12
12
  var getFunderCodeFromTransaction = function getFunderCodeFromTransaction(transaction, funderCode) {
13
13
  if (transaction.isPatientFunded || _get(transaction, 'claims[0].isPatientFunded')) {
14
14
  return constants.FUNDERS.PATIENT;
@@ -38,6 +38,8 @@ var getFunderCodeFromTransaction = function getFunderCodeFromTransaction(transac
38
38
  return constants.FUNDERS.COMCARE;
39
39
  } else if (funderCode === constants.FUNDERS.HEALTHPOINT) {
40
40
  return constants.FUNDERS.HEALTHPOINT;
41
+ } else if (funderCode === constants.FUNDERS.WSV) {
42
+ return constants.FUNDERS.WSV;
41
43
  }
42
44
 
43
45
  return constants.FUNDERS.PATIENT;
@@ -81,6 +83,9 @@ var isPatientFunded = function isPatientFunded(funderCode) {
81
83
  var isWCQ = function isWCQ(funderCode) {
82
84
  return funderCode === constants.FUNDERS.WCQ;
83
85
  };
86
+ var isWSV = function isWSV(funderCode) {
87
+ return funderCode === constants.FUNDERS.WSV;
88
+ };
84
89
  var isFunderClaimable = function isFunderClaimable(funderCode) {
85
90
  return CLAIMABLE_FUNDERS.includes(funderCode);
86
91
  };
@@ -102,3 +107,4 @@ exports.isNDIS = isNDIS;
102
107
  exports.isOHC = isOHC;
103
108
  exports.isPatientFunded = isPatientFunded;
104
109
  exports.isWCQ = isWCQ;
110
+ exports.isWSV = isWSV;
package/get-env.js CHANGED
@@ -11,7 +11,7 @@ var _omitBy = _interopDefault(require('lodash/omitBy'));
11
11
 
12
12
  function _createForOfIteratorHelperLoose(o) { var i = 0; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } i = o[Symbol.iterator](); return i.next.bind(i); }
13
13
 
14
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
15
 
16
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medipass/utils",
3
- "version": "11.54.4",
3
+ "version": "11.55.1-fix-comcare-verify.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@babel/plugin-transform-runtime": "7.8.3",
47
- "@medipass/web-sdk": "^11.18.4",
47
+ "@medipass/web-sdk": "^11.18.7-fix-comcare-verify.0",
48
48
  "redux-mock-store": "^1.3.0",
49
49
  "redux-thunk": "^2.2.0",
50
50
  "rimraf": "^2.6.2"
51
51
  },
52
- "gitHead": "dd3fe3619ffe657c1b29c2bafe635d5410271715"
52
+ "gitHead": "70caac05636eff1b5bd2b1faad93074b4e98423b"
53
53
  }
package/service-items.js CHANGED
@@ -27,32 +27,25 @@ var calculateTotalAmount = function calculateTotalAmount(serviceItems, opts) {
27
27
  }
28
28
 
29
29
  var total = serviceItems.reduce(function (total, item) {
30
- var itemTotal = parseFloat(_get(item, 'feeAmount', '0'));
31
-
32
- if (parseFloat(_get(item, 'initialGrossAmount', '0'))) {
33
- itemTotal = parseFloat(_get(item, 'initialGrossAmount', '0'));
34
- }
35
-
36
30
  var includeQuantity = _get(opts, 'includeQuantity');
37
31
 
38
32
  if (funders.isIcare(_get(opts, 'funder.code')) && _get(item, 'unit') === 'minutes') {
39
33
  includeQuantity = false;
40
34
  }
41
35
 
42
- if (includeQuantity && item.quantity && !item.isExtendedPrice) {
43
- itemTotal = parseFloat((itemTotal * item.quantity).toFixed(6));
44
- }
36
+ var prices = calculatePrices({
37
+ isTaxable: Boolean(opts.includeGST && item.isTaxable),
38
+ isGross: item.isGross,
39
+ initialFeeAmount: (item == null ? void 0 : item.initialFeeAmount) ? parseFloat((item == null ? void 0 : item.initialFeeAmount) || 0) : parseFloat((item == null ? void 0 : item.feeAmount) || 0),
40
+ isExtendedPrice: item == null ? void 0 : item.isExtendedPrice,
41
+ quantity: includeQuantity ? item.quantity : 1
42
+ });
43
+ var itemTotal = undefined;
45
44
 
46
- if (opts.includeGST && item.isTaxable) {
47
- if (opts.isSubTotal) {
48
- if (item.isGross) {
49
- itemTotal -= parseFloat((itemTotal / 11).toFixed(6));
50
- }
51
- } else {
52
- if (!item.isGross) {
53
- itemTotal = parseFloat((itemTotal * 1.1).toFixed(6));
54
- }
55
- }
45
+ if (opts.isSubTotal) {
46
+ itemTotal = prices == null ? void 0 : prices.feeAmount;
47
+ } else {
48
+ itemTotal = prices == null ? void 0 : prices.grossAmount;
56
49
  }
57
50
 
58
51
  if (opts.includeDiscount && item.discountAmount) {
@@ -81,27 +74,15 @@ var calculateTotalGSTAmount = function calculateTotalGSTAmount(serviceItems, opt
81
74
  includeQuantity = false;
82
75
  }
83
76
 
84
- if (item.isTaxable) {
85
- var itemTotal = parseFloat(_get(item, 'feeAmount', '0'));
86
-
87
- if (parseFloat(_get(item, 'initialGrossAmount', '0'))) {
88
- itemTotal = parseFloat(_get(item, 'initialGrossAmount', '0'));
89
- }
90
-
91
- if (includeQuantity && item.quantity && !item.isExtendedPrice) {
92
- itemTotal = parseFloat((itemTotal * item.quantity).toFixed(6));
93
- }
94
-
95
- if (item.isGross) {
96
- itemTotal = parseFloat((itemTotal / 11).toFixed(6));
97
- } else {
98
- itemTotal = parseFloat((itemTotal * 0.1).toFixed(6));
99
- }
100
-
101
- return total + itemTotal;
102
- }
103
-
104
- return total;
77
+ var prices = calculatePrices({
78
+ isTaxable: item.isTaxable,
79
+ isGross: item.isGross,
80
+ initialFeeAmount: (item == null ? void 0 : item.initialFeeAmount) ? parseFloat((item == null ? void 0 : item.initialFeeAmount) || 0) : parseFloat((item == null ? void 0 : item.feeAmount) || 0),
81
+ isExtendedPrice: item == null ? void 0 : item.isExtendedPrice,
82
+ quantity: includeQuantity ? item.quantity : 1
83
+ });
84
+ var gstAmount = prices == null ? void 0 : prices.taxAmount;
85
+ return total + gstAmount;
105
86
  }, 0);
106
87
  };
107
88
  var applyDiscountToServiceItems = function applyDiscountToServiceItems(serviceItems, _ref) {
@@ -216,7 +197,51 @@ function mapItemsToClaimItems(transaction) {
216
197
  return newItems;
217
198
  }
218
199
 
200
+ var round2DecimalPlaces = function round2DecimalPlaces(num) {
201
+ return Math.round((num + Number.EPSILON) * 100) / 100;
202
+ };
203
+
204
+ var calculatePrices = function calculatePrices(_ref3) {
205
+ var isTaxable = _ref3.isTaxable,
206
+ isGross = _ref3.isGross,
207
+ initialFeeAmount = _ref3.initialFeeAmount,
208
+ isExtendedPrice = _ref3.isExtendedPrice,
209
+ quantity = _ref3.quantity;
210
+ var grossAmount = parseFloat(initialFeeAmount || 0);
211
+ var feeAmount = parseFloat(initialFeeAmount || 0);
212
+ var taxAmount = 0;
213
+
214
+ if (!isTaxable) {
215
+ return {
216
+ grossAmount: grossAmount,
217
+ feeAmount: feeAmount,
218
+ taxAmount: taxAmount
219
+ };
220
+ }
221
+
222
+ if (isGross) {
223
+ taxAmount = parseFloat(round2DecimalPlaces(grossAmount / 11).toFixed(2) || 0);
224
+ feeAmount = grossAmount - taxAmount;
225
+ } else {
226
+ taxAmount = parseFloat((feeAmount * 1.1).toFixed(6)) - feeAmount;
227
+ grossAmount = feeAmount + taxAmount;
228
+ }
229
+
230
+ if (!isExtendedPrice) {
231
+ taxAmount = taxAmount * quantity;
232
+ feeAmount = feeAmount * quantity;
233
+ grossAmount = grossAmount * quantity;
234
+ }
235
+
236
+ return {
237
+ grossAmount: grossAmount,
238
+ feeAmount: feeAmount,
239
+ taxAmount: taxAmount
240
+ };
241
+ };
242
+
219
243
  exports.applyDiscountToServiceItems = applyDiscountToServiceItems;
244
+ exports.calculatePrices = calculatePrices;
220
245
  exports.calculateTotalAmount = calculateTotalAmount;
221
246
  exports.calculateTotalDiscountAmount = calculateTotalDiscountAmount;
222
247
  exports.calculateTotalGSTAmount = calculateTotalGSTAmount;