@zeniai/client-epic-state 4.10.28 → 4.10.29

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.
@@ -6,7 +6,7 @@ export interface CustomerBasePayload {
6
6
  qbo_id?: string;
7
7
  logo?: URLPayload;
8
8
  }
9
- export declare const toCustomerBase: (payload: CustomerBasePayload) => CustomerBase;
9
+ export declare const toCustomerBase: (payload: CustomerBasePayload, parseOutParentName: boolean) => CustomerBase;
10
10
  export declare const toCustomerBasePayload: (customer: CustomerBase | undefined) => CustomerBasePayload;
11
11
  export interface CustomerPayload extends CustomerBasePayload {
12
12
  currency_symbol: string | null;
@@ -44,4 +44,4 @@ export interface CustomerPayload extends CustomerBasePayload {
44
44
  qbo_update_time?: string;
45
45
  accounting_class_id?: string | null;
46
46
  }
47
- export declare const toCustomer: (payload: CustomerPayload) => Customer;
47
+ export declare const toCustomer: (payload: CustomerPayload, parseOutParentName?: boolean) => Customer;
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toCustomer = exports.toCustomerBasePayload = exports.toCustomerBase = void 0;
4
4
  const urlPayload_1 = require("../../commonPayloadTypes/urlPayload");
5
5
  const zeniDayJS_1 = require("../../zeniDayJS");
6
- const toCustomerBase = (payload) => ({
6
+ const toCustomerBase = (payload, parseOutParentName) => ({
7
7
  id: payload.customer_id,
8
- name: payload.customer_name,
8
+ name: parseOutParentName
9
+ ? removeParentName(payload.customer_name)
10
+ : payload.customer_name,
9
11
  qboId: payload.qbo_id,
10
12
  logo: payload.logo != null ? (0, urlPayload_1.toURL)(payload.logo) : undefined,
11
13
  });
@@ -19,8 +21,27 @@ const toCustomerBasePayload = (customer) => {
19
21
  });
20
22
  };
21
23
  exports.toCustomerBasePayload = toCustomerBasePayload;
22
- const toCustomer = (payload) => {
24
+ const toCustomer = (payload, parseOutParentName = false) => {
23
25
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
24
- return (Object.assign(Object.assign({}, (0, exports.toCustomerBase)(payload)), { addressId: (_a = payload.address_id) !== null && _a !== void 0 ? _a : undefined, lastName: (_b = payload.last_name) !== null && _b !== void 0 ? _b : undefined, paymentMethodId: (_c = payload.payment_method_id) !== null && _c !== void 0 ? _c : undefined, suffix: (_d = payload.suffix) !== null && _d !== void 0 ? _d : undefined, createTime: payload.create_time != null ? (0, zeniDayJS_1.date)(payload.create_time) : undefined, qboCreateTime: payload.qbo_create_time != null ? (0, zeniDayJS_1.date)(payload.qbo_create_time) : undefined, nameOnCheck: (_e = payload.name_on_check) !== null && _e !== void 0 ? _e : undefined, firstName: (_f = payload.first_name) !== null && _f !== void 0 ? _f : undefined, middleName: (_g = payload.middle_name) !== null && _g !== void 0 ? _g : undefined, contacts: (_h = payload.contacts) !== null && _h !== void 0 ? _h : undefined, termId: (_j = payload.term_id) !== null && _j !== void 0 ? _j : undefined, note: (_k = payload.note) !== null && _k !== void 0 ? _k : undefined, syncToken: payload.sync_token, email: (_l = payload.email) !== null && _l !== void 0 ? _l : undefined, websiteUrl: (_m = payload.website_url) !== null && _m !== void 0 ? _m : undefined, parentCustomerId: (_o = payload.parent_customer_id) !== null && _o !== void 0 ? _o : undefined, qboParentCustomerId: (_p = payload.qbo_parent_customer_id) !== null && _p !== void 0 ? _p : undefined, isBillWithParent: Boolean(payload.is_bill_with_parent), updateTime: payload.update_time != null ? (0, zeniDayJS_1.date)(payload.update_time) : undefined, accountId: (_q = payload.account_id) !== null && _q !== void 0 ? _q : undefined, phone: (_r = payload.phone) !== null && _r !== void 0 ? _r : undefined, bankAccountIds: (_s = payload.bank_account_ids) !== null && _s !== void 0 ? _s : undefined, balance: (_t = payload.balance) !== null && _t !== void 0 ? _t : undefined, isDeleted: Boolean(payload.is_deleted), tenantId: payload.tenant_id, title: (_u = payload.title) !== null && _u !== void 0 ? _u : undefined, isSubCustomer: Boolean(payload.is_sub_customer), isTaxable: Boolean(payload.is_taxable), shippingAddressId: (_v = payload.shipping_address_id) !== null && _v !== void 0 ? _v : undefined, billingAddressId: (_w = payload.billing_address_id) !== null && _w !== void 0 ? _w : undefined, currencySymbol: (_x = payload.currency_symbol) !== null && _x !== void 0 ? _x : undefined, qboUpdateTime: payload.qbo_update_time != null ? (0, zeniDayJS_1.date)(payload.qbo_update_time) : undefined, accountingClassId: (_y = payload.accounting_class_id) !== null && _y !== void 0 ? _y : undefined, currencyCode: (_z = payload.currency_code) !== null && _z !== void 0 ? _z : undefined }));
26
+ return (Object.assign(Object.assign({}, (0, exports.toCustomerBase)(payload, parseOutParentName)), { addressId: (_a = payload.address_id) !== null && _a !== void 0 ? _a : undefined, lastName: (_b = payload.last_name) !== null && _b !== void 0 ? _b : undefined, paymentMethodId: (_c = payload.payment_method_id) !== null && _c !== void 0 ? _c : undefined, suffix: (_d = payload.suffix) !== null && _d !== void 0 ? _d : undefined, createTime: payload.create_time != null ? (0, zeniDayJS_1.date)(payload.create_time) : undefined, qboCreateTime: payload.qbo_create_time != null ? (0, zeniDayJS_1.date)(payload.qbo_create_time) : undefined, nameOnCheck: (_e = payload.name_on_check) !== null && _e !== void 0 ? _e : undefined, firstName: (_f = payload.first_name) !== null && _f !== void 0 ? _f : undefined, middleName: (_g = payload.middle_name) !== null && _g !== void 0 ? _g : undefined, contacts: (_h = payload.contacts) !== null && _h !== void 0 ? _h : undefined, termId: (_j = payload.term_id) !== null && _j !== void 0 ? _j : undefined, note: (_k = payload.note) !== null && _k !== void 0 ? _k : undefined, syncToken: payload.sync_token, email: (_l = payload.email) !== null && _l !== void 0 ? _l : undefined, websiteUrl: (_m = payload.website_url) !== null && _m !== void 0 ? _m : undefined, parentCustomerId: (_o = payload.parent_customer_id) !== null && _o !== void 0 ? _o : undefined, qboParentCustomerId: (_p = payload.qbo_parent_customer_id) !== null && _p !== void 0 ? _p : undefined, isBillWithParent: Boolean(payload.is_bill_with_parent), updateTime: payload.update_time != null ? (0, zeniDayJS_1.date)(payload.update_time) : undefined, accountId: (_q = payload.account_id) !== null && _q !== void 0 ? _q : undefined, phone: (_r = payload.phone) !== null && _r !== void 0 ? _r : undefined, bankAccountIds: (_s = payload.bank_account_ids) !== null && _s !== void 0 ? _s : undefined, balance: (_t = payload.balance) !== null && _t !== void 0 ? _t : undefined, isDeleted: Boolean(payload.is_deleted), tenantId: payload.tenant_id, title: (_u = payload.title) !== null && _u !== void 0 ? _u : undefined, isSubCustomer: Boolean(payload.is_sub_customer), isTaxable: Boolean(payload.is_taxable), shippingAddressId: (_v = payload.shipping_address_id) !== null && _v !== void 0 ? _v : undefined, billingAddressId: (_w = payload.billing_address_id) !== null && _w !== void 0 ? _w : undefined, currencySymbol: (_x = payload.currency_symbol) !== null && _x !== void 0 ? _x : undefined, qboUpdateTime: payload.qbo_update_time != null ? (0, zeniDayJS_1.date)(payload.qbo_update_time) : undefined, accountingClassId: (_y = payload.accounting_class_id) !== null && _y !== void 0 ? _y : undefined, currencyCode: (_z = payload.currency_code) !== null && _z !== void 0 ? _z : undefined }));
25
27
  };
26
28
  exports.toCustomer = toCustomer;
29
+ /**
30
+ * In case of AR Aging detail reports, the customer name comes back prepended
31
+ * with the parent hierarchy looking like abc:xyz:Customer123
32
+ * In this case we want to continue to keep just `Customer Name` as name parameter
33
+ * This function parses the name and discards the parent hierarchy. In this
34
+ * case `Customer123`
35
+ * @param name
36
+ * @returns
37
+ */
38
+ const removeParentName = (name) => {
39
+ const allNames = name.split(':');
40
+ const length = allNames.length;
41
+ if (length === 0) {
42
+ return name;
43
+ }
44
+ else {
45
+ return allNames[length - 1];
46
+ }
47
+ };
@@ -1,6 +1,12 @@
1
1
  import { CustomerState } from './customerState';
2
2
  import { CustomerPayload } from './customerPayload';
3
3
  export declare const initialState: CustomerState;
4
- export declare const updateCustomers: import("@reduxjs/toolkit").ActionCreatorWithPayload<CustomerPayload[], string>, updateCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<CustomerPayload, string>, removeCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, clearAllCustomers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
4
+ export declare const updateCustomers: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[customersPayload: CustomerPayload[], parseOutParentName?: boolean | undefined], {
5
+ customersPayload: CustomerPayload[];
6
+ parseOutParentName: boolean | undefined;
7
+ }, string, never, never>, updateCustomer: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[customerPayload: CustomerPayload, parseOutParentName?: boolean | undefined], {
8
+ customerPayload: CustomerPayload;
9
+ parseOutParentName: boolean | undefined;
10
+ }, string, never, never>, removeCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, clearAllCustomers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
5
11
  declare const _default: import("@reduxjs/toolkit").Reducer<CustomerState, import("@reduxjs/toolkit").AnyAction>;
6
12
  export default _default;
@@ -11,15 +11,26 @@ const customer = (0, toolkit_1.createSlice)({
11
11
  name: 'customer',
12
12
  initialState: exports.initialState,
13
13
  reducers: {
14
- updateCustomers(draft, action) {
15
- action.payload.forEach((customerPayload) => {
16
- const customer = (0, customerPayload_1.toCustomer)(customerPayload);
17
- draft.byCustomerId[customer.id] = customer;
18
- });
14
+ updateCustomers: {
15
+ reducer(draft, action) {
16
+ const customersPayload = action.payload.customersPayload;
17
+ customersPayload.forEach((customerPayload) => {
18
+ const customer = (0, customerPayload_1.toCustomer)(customerPayload, action.payload.parseOutParentName);
19
+ draft.byCustomerId[customer.id] = customer;
20
+ });
21
+ },
22
+ prepare(customersPayload, parseOutParentName) {
23
+ return { payload: { customersPayload, parseOutParentName } };
24
+ },
19
25
  },
20
- updateCustomer(draft, action) {
21
- const customer = (0, customerPayload_1.toCustomer)(action.payload);
22
- draft.byCustomerId[customer.id] = customer;
26
+ updateCustomer: {
27
+ reducer(draft, action) {
28
+ const customer = (0, customerPayload_1.toCustomer)(action.payload.customerPayload, action.payload.parseOutParentName);
29
+ draft.byCustomerId[customer.id] = customer;
30
+ },
31
+ prepare(customerPayload, parseOutParentName) {
32
+ return { payload: { customerPayload, parseOutParentName } };
33
+ },
23
34
  },
24
35
  removeCustomer(draft, action) {
25
36
  delete draft.byCustomerId[action.payload];
@@ -5,13 +5,12 @@ const amount_1 = require("../../../commonStateTypes/amount");
5
5
  const customerPayload_1 = require("../../customer/customerPayload");
6
6
  const paymentType_1 = require("../stateTypes/paymentType");
7
7
  const transactionType_1 = require("../stateTypes/transactionType");
8
- // import {CustomerPayload, mapCustomerPayloadToCustomer} from './customerPayload';
9
8
  const transactionPayload_1 = require("./transactionPayload");
10
9
  const isCustomerTransactionPayload = (payload) => (0, transactionType_1.toCustomerTransactionTypeStrict)(payload.transaction_type) != null;
11
10
  exports.isCustomerTransactionPayload = isCustomerTransactionPayload;
12
11
  const toCustomerTransaction = (payload) => {
13
12
  const transaction = (0, transactionPayload_1.toTransaction)(payload);
14
- return Object.assign(Object.assign({}, transaction), { customer: payload.customer_id != null ? (0, customerPayload_1.toCustomerBase)(payload) : undefined, documentId: payload.document_id, paymentType: (0, paymentType_1.toPaymentTypeStrict)(payload.payment_type), paymentTypeName: payload.payment_type_name, paymentMethodName: payload.payment_method_name, balance: payload.balance != null
13
+ return Object.assign(Object.assign({}, transaction), { customer: payload.customer_id != null ? (0, customerPayload_1.toCustomerBase)(payload, false) : undefined, documentId: payload.document_id, paymentType: (0, paymentType_1.toPaymentTypeStrict)(payload.payment_type), paymentTypeName: payload.payment_type_name, paymentMethodName: payload.payment_method_name, balance: payload.balance != null
15
14
  ? (0, amount_1.toAmountWC)(payload.balance, transaction.amount)
16
15
  : undefined });
17
16
  };
@@ -23,7 +23,7 @@ const toTransactionWithAccountAndClassLine = (payload, currency, type = 'transac
23
23
  var _a, _b, _c, _d;
24
24
  return (Object.assign(Object.assign({}, (0, exports.toTransactionLineBase)(payload, type, currency)), { class: (0, classPayload_1.mapClassBasePayloadToClassBase)((_a = payload.line_detail.class) !== null && _a !== void 0 ? _a : {}), account: (0, accountPayload_1.mapAccountBasePayloadToAccountBase)(payload.line_detail.account), customer: payload.line_detail.customer != null &&
25
25
  payload.line_detail.customer.customer_id != null
26
- ? (0, customerPayload_1.toCustomerBase)(payload.line_detail.customer)
26
+ ? (0, customerPayload_1.toCustomerBase)(payload.line_detail.customer, false)
27
27
  : undefined, vendor: payload.line_detail.vendor != null &&
28
28
  payload.line_detail.vendor.vendor_id != null
29
29
  ? (0, vendorPayload_1.mapVendorBasePayloadToVendorBase)(payload.line_detail.vendor)
@@ -10,8 +10,8 @@ const zeniDayJS_1 = require("../../../zeniDayJS");
10
10
  const vendorState_1 = require("../../../entity/vendor/vendorState");
11
11
  exports.inititalUIState = {
12
12
  searchString: '',
13
- sortKey: 'vendor',
14
- sortOrder: 'ascending',
13
+ sortKey: 'total',
14
+ sortOrder: 'descending',
15
15
  downloadState: 'Not-Started',
16
16
  selectedDate: (0, zeniDayJS_1.dateNow)(),
17
17
  agingDateSelectionType: 'custom_date',
@@ -17,7 +17,7 @@ const fetchArAgingDetailEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0,
17
17
  .pipe((0, operators_1.mergeMap)((response) => {
18
18
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
19
19
  const actions = [
20
- (0, customerReducer_1.updateCustomers)(response.data.report.customers),
20
+ (0, customerReducer_1.updateCustomers)(response.data.report.customers, true),
21
21
  (0, arAgingDetailReducer_1.updateArAgingDetailOnSuccess)(response.data.report, customerId, reportDate),
22
22
  ];
23
23
  return (0, rxjs_1.from)(actions);
@@ -12,8 +12,8 @@ const customerState_1 = require("../../../entity/customer/customerState");
12
12
  const getNestedCustomerHierarchy_1 = require("../../../commonStateTypes/customerView/getNestedCustomerHierarchy");
13
13
  exports.inititalUIState = {
14
14
  searchString: '',
15
- sortKey: 'customer',
16
- sortOrder: 'ascending',
15
+ sortKey: 'total',
16
+ sortOrder: 'descending',
17
17
  downloadState: 'Not-Started',
18
18
  selectedDate: (0, zeniDayJS_1.dateNow)(),
19
19
  agingDateSelectionType: 'custom_date',
@@ -49,7 +49,9 @@ const getNestedAgingBalancesByCustomer = (customerState, agingBalancesByCustomer
49
49
  case 'customer':
50
50
  return balance.customer.name.toLowerCase();
51
51
  case 'total':
52
- return balance.total.amount;
52
+ return balance.children.length > 0
53
+ ? balance.totalWithChildren.amount
54
+ : balance.total.amount;
53
55
  default: {
54
56
  const obj = balance.arAgingBalances.find((balance) => balance.period === sortKey);
55
57
  return (_a = obj === null || obj === void 0 ? void 0 : obj.balance.amount) !== null && _a !== void 0 ? _a : 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.10.28",
3
+ "version": "4.10.29",
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",