@zeniai/client-epic-state 4.10.29 → 4.10.30

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.
@@ -44,7 +44,7 @@ const getNestedAgingBalancesByCustomer = (customerState, agingBalancesByCustomer
44
44
  });
45
45
  const filteredAgingBalancesByCustomer = agingBalancesByCustomer.filter((balance) => balance.customer.name.toLowerCase().includes(searchString.toLowerCase()));
46
46
  const sortedAgingBalancesByCustomer = (0, orderBy_1.default)(filteredAgingBalancesByCustomer, (balance) => {
47
- var _a;
47
+ var _a, _b, _c;
48
48
  switch (sortKey) {
49
49
  case 'customer':
50
50
  return balance.customer.name.toLowerCase();
@@ -53,8 +53,13 @@ const getNestedAgingBalancesByCustomer = (customerState, agingBalancesByCustomer
53
53
  ? balance.totalWithChildren.amount
54
54
  : balance.total.amount;
55
55
  default: {
56
- const obj = balance.arAgingBalances.find((balance) => balance.period === sortKey);
57
- return (_a = obj === null || obj === void 0 ? void 0 : obj.balance.amount) !== null && _a !== void 0 ? _a : 0;
56
+ const customerRecord = balance.arAgingBalances.find((balance) => balance.period === sortKey);
57
+ if (balance.children.length > 0) {
58
+ return (_b = (_a = customerRecord === null || customerRecord === void 0 ? void 0 : customerRecord.totalBalance) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0;
59
+ }
60
+ else {
61
+ return (_c = customerRecord === null || customerRecord === void 0 ? void 0 : customerRecord.balance.amount) !== null && _c !== void 0 ? _c : 0;
62
+ }
58
63
  }
59
64
  }
60
65
  }, sortOrder === 'ascending' ? 'asc' : 'desc');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.10.29",
3
+ "version": "4.10.30",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",