@zeniai/client-epic-state 4.19.52 → 4.19.53-betaAR1

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.
Files changed (92) hide show
  1. package/lib/entity/account/accountSelector.d.ts +18 -0
  2. package/lib/entity/account/accountSelector.js +31 -1
  3. package/lib/entity/account/accountState.d.ts +5 -0
  4. package/lib/entity/account/accountState.js +11 -4
  5. package/lib/entity/chargeCardRepayment/chargeCardRepayment.d.ts +6 -1
  6. package/lib/entity/chargeCardRepayment/chargeCardRepayment.js +4 -1
  7. package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.d.ts +8 -3
  8. package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.js +5 -2
  9. package/lib/entity/class/classSelector.d.ts +5 -0
  10. package/lib/entity/class/classSelector.js +8 -0
  11. package/lib/epic.d.ts +3 -1
  12. package/lib/epic.js +3 -1
  13. package/lib/esm/entity/account/accountSelector.js +29 -1
  14. package/lib/esm/entity/account/accountState.js +7 -1
  15. package/lib/esm/entity/chargeCardRepayment/chargeCardRepayment.js +2 -0
  16. package/lib/esm/entity/chargeCardRepayment/chargeCardRepaymentPayload.js +6 -3
  17. package/lib/esm/entity/class/classSelector.js +7 -0
  18. package/lib/esm/epic.js +3 -1
  19. package/lib/esm/index.js +17 -11
  20. package/lib/esm/reducer.js +3 -0
  21. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +11 -1
  22. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +57 -8
  23. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +10 -1
  24. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +4 -2
  25. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +5 -2
  26. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.js +32 -0
  27. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +22 -0
  28. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.js +79 -0
  29. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryPayload.js +1 -0
  30. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +83 -0
  31. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +104 -0
  32. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentHistoryEpic.js +31 -0
  33. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +31 -0
  34. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +12 -6
  35. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -2
  36. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +5 -0
  37. package/lib/esm/view/spendManagement/chargeCards/chargeCardSetUp/epic/fetchChargeCardSetupViewEpic.js +1 -1
  38. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +15 -0
  39. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +10 -1
  40. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +4 -2
  41. package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +226 -16
  42. package/lib/esm/view/spendManagement/zeniAccounts/depositAccountList/fetchDepositAccountListEpic.js +5 -3
  43. package/lib/index.d.ts +20 -14
  44. package/lib/index.js +55 -29
  45. package/lib/reducer.d.ts +3 -0
  46. package/lib/reducer.js +3 -0
  47. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  48. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +5 -1
  49. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +12 -2
  50. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +4 -1
  51. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +59 -8
  52. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -0
  53. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +1 -1
  54. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +11 -2
  55. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +4 -2
  56. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelectorTypes.d.ts +2 -0
  57. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +1 -0
  58. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -0
  59. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +5 -2
  60. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +2 -0
  61. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +50 -0
  62. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.js +35 -0
  63. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.d.ts +8 -0
  64. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +26 -0
  65. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.d.ts +7 -0
  66. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.js +87 -0
  67. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryPayload.d.ts +13 -0
  68. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryPayload.js +2 -0
  69. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +19 -0
  70. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +87 -0
  71. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.d.ts +24 -0
  72. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +108 -0
  73. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentHistoryEpic.d.ts +9 -0
  74. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentHistoryEpic.js +35 -0
  75. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.d.ts +7 -0
  76. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +35 -0
  77. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +10 -4
  78. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -2
  79. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.d.ts +2 -1
  80. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +5 -0
  81. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/fetchChargeCardSetupViewEpic.js +1 -1
  82. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +2 -1
  83. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +17 -1
  84. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +1 -1
  85. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +11 -2
  86. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +4 -2
  87. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelectorTypes.d.ts +2 -0
  88. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +1 -0
  89. package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +47 -4
  90. package/lib/view/spendManagement/spendManagementFilterHelpers.js +227 -17
  91. package/lib/view/spendManagement/zeniAccounts/depositAccountList/fetchDepositAccountListEpic.js +5 -3
  92. package/package.json +1 -1
@@ -1,15 +1,22 @@
1
+ import { Amount } from '../../commonStateTypes/amount';
2
+ import { ID } from '../../commonStateTypes/common';
1
3
  import { TimePeriod } from '../../commonStateTypes/timePeriod';
4
+ import { TransactionType } from '../../entity/transaction/stateTypes/transactionType';
5
+ import { SupportedTransactionWithCOT } from '../../entity/transaction/transactionState';
2
6
  import { UserRoleType } from '../../entity/userRole/userRoleType';
3
7
  import { RootState } from '../../reducer';
4
8
  import { ZeniDate } from '../../zeniDayJS';
9
+ import { TransactionReviewLocalDataSelectorView } from '../expenseAutomationView/selectorTypes/transactionsViewSelectorTypes';
5
10
  import { TaskListFilterCategoryField, TaskListFilters } from '../taskManager/taskListView/taskList';
6
11
  import { TaskWithUserDetails } from '../taskManager/taskListView/taskListSelector';
7
12
  import { BillTransactionView } from './billPay/billList/billListSelector';
8
13
  import { BillListViewFilterCategoryField, BillPayFilters } from './billPay/billList/billListState';
14
+ import { PaymentHistoryFilterCategoryDropdownOption, PaymentHistoryFilters } from './chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory';
15
+ import { ChargeCardRepaymentWithUser } from './chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector';
9
16
  import { ReimbursementView } from './reimbursement/remiListView/remiListSelector';
10
17
  import { ReimbursementFilters, RemiListViewFilterCategoryField } from './reimbursement/remiListView/remiListState';
11
- export type SpendManagementFiltersType = BillPayFilters | ReimbursementFilters | TaskListFilters;
12
- export type SpendManagementFilterEntityType = 'bill_pay' | 'reimbursement' | 'task_management';
18
+ export type SpendManagementFiltersType = BillPayFilters | ReimbursementFilters | TaskListFilters | TransactionFilters | PaymentHistoryFilters;
19
+ export type SpendManagementFilterEntityType = 'bill_pay' | 'reimbursement' | 'task_management' | 'transaction_categorization' | 'charge_card_payment_history';
13
20
  export type FilterCategoryType = 'searchAutocomplete' | 'user' | 'dateRange' | 'numberRange' | 'dropdown';
14
21
  export interface MatchingOperatorDropdownOption {
15
22
  label: 'is' | 'is not';
@@ -31,9 +38,45 @@ export interface TaskFilterCategoryDropdownOption {
31
38
  multiple?: boolean;
32
39
  type?: FilterCategoryType;
33
40
  }
34
- export type SpendManagementFilterCategoryDropdownOption = BillPayFilterCategoryDropdownOption | ReimbursementFilterCategoryDropdownOption | TaskFilterCategoryDropdownOption;
41
+ export type SpendManagementFilterCategoryDropdownOption = BillPayFilterCategoryDropdownOption | ReimbursementFilterCategoryDropdownOption | TaskFilterCategoryDropdownOption | TransactionFilterCategoryDropdownOption | PaymentHistoryFilterCategoryDropdownOption;
42
+ export interface TransactionFilterCategoryDropdownOption {
43
+ value: TransactionFilterCategoryField;
44
+ multiple?: boolean;
45
+ type?: FilterCategoryType;
46
+ }
47
+ export type TransactionFilterEntityType = 'transaction_categorization' | 'customer' | 'vendor' | 'merchant';
48
+ export type TransactionFilterCategoryField = 'payment_account_name' | 'payment_account_type' | 'payee' | 'category' | 'class' | 'amount';
49
+ export declare const TRANSACTION_FILTER_CATEGORIES: TransactionFilterCategoryDropdownOption[];
50
+ export interface TransactionFilters {
51
+ categories: TransactionFilterCategory[];
52
+ categoryCombinationOperator: CategoryCombinationOperator;
53
+ }
54
+ /** Amount filter operators for transaction_categorization (expense automation). Other entities use only equal/not-equal. */
55
+ export type TransactionFilterAmountMatchingOperator = 'equal' | 'not-equal' | 'lessThan' | 'greaterThan' | 'inBetween';
56
+ export interface TransactionFilterCategory {
57
+ field: TransactionFilterCategoryField;
58
+ matchingOperator: TransactionFilterAmountMatchingOperator;
59
+ values: (string | ZeniDate)[];
60
+ valuesCombinationOperator: 'ANY';
61
+ }
62
+ export interface TransactionView {
63
+ amount: Amount;
64
+ createTime: ZeniDate;
65
+ date: ZeniDate;
66
+ description: string;
67
+ id: ID;
68
+ memo: string;
69
+ transaction: SupportedTransactionWithCOT;
70
+ type: TransactionType;
71
+ customerId?: ID;
72
+ customerName?: string;
73
+ transactionLocalData?: TransactionReviewLocalDataSelectorView;
74
+ typeName?: string;
75
+ vendorId?: ID;
76
+ vendorName?: string;
77
+ }
35
78
  export type FilterCategoryValueType = string | number | ZeniDate;
36
- export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[], filters?: BillPayFilters | ReimbursementFilters | TaskListFilters, filteredItems?: (BillTransactionView | ReimbursementView | TaskWithUserDetails)[], index?: number) => (BillTransactionView | ReimbursementView | TaskWithUserDetails)[];
79
+ export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[] | TransactionView[] | ChargeCardRepaymentWithUser[], filters?: BillPayFilters | ReimbursementFilters | TaskListFilters | TransactionFilters | PaymentHistoryFilters, filteredItems?: (BillTransactionView | ReimbursementView | TaskWithUserDetails | TransactionView | ChargeCardRepaymentWithUser)[], index?: number) => (BillTransactionView | ReimbursementView | TaskWithUserDetails | TransactionView | ChargeCardRepaymentWithUser)[];
37
80
  export declare const isBillListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
38
81
  export declare const isRemiListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
39
82
  export declare const hideCreatedByFilter: (userRole: UserRoleType[]) => boolean;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.hideCreatedByFilter = exports.isRemiListDownloadable = exports.isBillListDownloadable = exports.applyAdvancedFiltersOnList = void 0;
6
+ exports.hideCreatedByFilter = exports.isRemiListDownloadable = exports.isBillListDownloadable = exports.applyAdvancedFiltersOnList = exports.TRANSACTION_FILTER_CATEGORIES = void 0;
7
7
  const get_1 = __importDefault(require("lodash/get"));
8
8
  const userSelector_1 = require("../../entity/user/userSelector");
9
9
  const userRoleType_1 = require("../../entity/userRole/userRoleType");
@@ -13,28 +13,81 @@ const billListState_1 = require("./billPay/billList/billListState");
13
13
  const helpers_1 = require("./helpers");
14
14
  const remiListSelector_1 = require("./reimbursement/remiListView/remiListSelector");
15
15
  const remiListState_1 = require("./reimbursement/remiListView/remiListState");
16
+ exports.TRANSACTION_FILTER_CATEGORIES = [
17
+ { value: 'payment_account_name', type: 'dropdown' },
18
+ { value: 'payment_account_type', type: 'dropdown' },
19
+ { value: 'payee', type: 'searchAutocomplete' },
20
+ { value: 'category', type: 'dropdown' },
21
+ { value: 'class', type: 'dropdown' },
22
+ { value: 'amount', type: 'numberRange' },
23
+ ];
16
24
  //filters items against filter values representing a range. ex: date (from-to), amount(1k<-->5k)
25
+ // For amount: supports new transaction_categorization operators (inBetween, lessThan, greaterThan) and
26
+ // backward compatibility for old format values: ["1000<->5000"] with matchingOperator "equal".
27
+ // Other entities (bill_pay, reimbursement, etc.) use only equal/not-equal and are unchanged.
17
28
  const filterItemOnRangeCategoryType = (valueForItem, currentFilter) => {
18
29
  let doesItemFallInValueRange = false;
19
30
  const filterField = currentFilter.field;
20
31
  if (filterField === 'amount') {
21
- for (const filterValue of currentFilter.values) {
22
- const currentValue = parseInt(valueForItem.toString());
23
- const lowerValue = parseInt(filterValue?.toString()?.split('<->')[0] ?? '');
24
- const higherValue = parseInt(filterValue?.toString()?.split('<->')[1] ?? '');
25
- if (currentValue >= lowerValue && currentValue <= higherValue) {
26
- doesItemFallInValueRange = true;
32
+ const currentValue = Number(valueForItem);
33
+ const op = currentFilter.matchingOperator;
34
+ const values = currentFilter.values;
35
+ if (op === 'inBetween') {
36
+ // New format: values = [min, max] (expense automation transaction_categorization only)
37
+ if (values.length >= 2) {
38
+ const min = Number(values[0]);
39
+ const max = Number(values[1]);
40
+ doesItemFallInValueRange = currentValue >= min && currentValue <= max;
27
41
  }
28
42
  }
29
- }
30
- else {
31
- const currentValue = valueForItem;
32
- const lowerValue = currentFilter.values[0];
33
- const higherValue = currentFilter.values[1];
34
- if (currentValue.isSameOrAfter(lowerValue) &&
35
- currentValue.isSameOrBefore(higherValue)) {
36
- doesItemFallInValueRange = true;
43
+ else if (op === 'lessThan') {
44
+ if (values.length >= 1) {
45
+ const threshold = Number(values[0]);
46
+ doesItemFallInValueRange = currentValue < threshold;
47
+ }
48
+ }
49
+ else if (op === 'greaterThan') {
50
+ if (values.length >= 1) {
51
+ const threshold = Number(values[0]);
52
+ doesItemFallInValueRange = currentValue > threshold;
53
+ }
54
+ }
55
+ else if (op === 'equal' &&
56
+ values.length === 1 &&
57
+ String(values[0]).includes('<->')) {
58
+ // Backward compatibility: old format ["1000<->5000"] with matchingOperator "equal"
59
+ const parts = String(values[0]).split('<->');
60
+ const lowerValue = Number(parts[0] ?? '');
61
+ const higherValue = Number(parts[1] ?? '');
62
+ doesItemFallInValueRange =
63
+ currentValue >= lowerValue && currentValue <= higherValue;
37
64
  }
65
+ else if (op === 'equal' && values.length === 1) {
66
+ // New format: exact match on single value (expense automation)
67
+ const val = Number(values[0]);
68
+ doesItemFallInValueRange = currentValue === val;
69
+ }
70
+ else {
71
+ // Existing logic for equal/not-equal (bill_pay, reimbursement, etc. or multiple range values)
72
+ for (const filterValue of values) {
73
+ const lowerValue = Number.parseInt(filterValue?.toString()?.split('<->')[0] ?? '', 10);
74
+ const higherValue = Number.parseInt(filterValue?.toString()?.split('<->')[1] ?? '', 10);
75
+ if (currentValue >= lowerValue && currentValue <= higherValue) {
76
+ doesItemFallInValueRange = true;
77
+ }
78
+ }
79
+ }
80
+ return op === 'not-equal'
81
+ ? !doesItemFallInValueRange
82
+ : doesItemFallInValueRange;
83
+ }
84
+ // Date range and other range fields (unchanged for other entities)
85
+ const currentValue = valueForItem;
86
+ const lowerValue = currentFilter.values[0];
87
+ const higherValue = currentFilter.values[1];
88
+ if (currentValue.isSameOrAfter(lowerValue) &&
89
+ currentValue.isSameOrBefore(higherValue)) {
90
+ doesItemFallInValueRange = true;
38
91
  }
39
92
  return currentFilter.matchingOperator === 'equal'
40
93
  ? doesItemFallInValueRange
@@ -72,10 +125,17 @@ const filterItemOnCategoriesWithMultipleValues = (categoryValue, currentFilter)
72
125
  return true;
73
126
  }
74
127
  };
128
+ const getItemId = (item) => {
129
+ if ('cardRepaymentId' in item) {
130
+ return item.cardRepaymentId;
131
+ }
132
+ return item
133
+ .id;
134
+ };
75
135
  const removeDuplicatesFromList = (list) => {
76
136
  const foundIds = [];
77
137
  return list.filter((item) => {
78
- const itemId = item.id;
138
+ const itemId = getItemId(item);
79
139
  if (foundIds.indexOf(itemId) === -1) {
80
140
  foundIds.push(itemId);
81
141
  return true;
@@ -110,7 +170,13 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
110
170
  ? getCategoryValueForBill(key, item)
111
171
  : entity === 'reimbursement'
112
172
  ? getCategoryValueForReimbursement(key, item)
113
- : getCategoryValueForTaskList(key, item);
173
+ : entity === 'task_management'
174
+ ? getCategoryValueForTaskList(key, item)
175
+ : entity === 'transaction_categorization'
176
+ ? getCategoryValueForTransaction(key, item)
177
+ : entity === 'charge_card_payment_history'
178
+ ? getCategoryValueForPaymentHistory(key, item)
179
+ : undefined;
114
180
  if (categoryValue == null) {
115
181
  if (currentFilter.matchingOperator === 'not-equal') {
116
182
  return true;
@@ -130,6 +196,7 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
130
196
  'dueDate',
131
197
  'creationDate',
132
198
  'receiptDate',
199
+ 'repaymentDate',
133
200
  ]);
134
201
  }
135
202
  });
@@ -231,6 +298,149 @@ const getCategoryValueForReimbursement = (key, reimbursement) => {
231
298
  return undefined;
232
299
  }
233
300
  };
301
+ const getCategoryValueForTransaction = (key, transaction) => {
302
+ switch (key) {
303
+ case 'amount': {
304
+ // Get from transactionLocalData line items (preferred) - sum all line item amounts
305
+ const localDataForAmount = transaction.transactionLocalData?.transactionReviewLocalData;
306
+ if (localDataForAmount?.lineItemById) {
307
+ const lineItems = Object.values(localDataForAmount.lineItemById);
308
+ if (lineItems.length > 0) {
309
+ // Sum all line item amounts
310
+ const totalAmount = lineItems.reduce((sum, lineItem) => sum + (lineItem.amount?.amount ?? 0), 0);
311
+ return totalAmount;
312
+ }
313
+ }
314
+ // Fallback to transaction-level amount or sum from transaction lines
315
+ if (transaction.transaction.lines &&
316
+ transaction.transaction.lines.length > 0) {
317
+ const totalAmount = transaction.transaction.lines.reduce((sum, line) => sum + (line.amount?.amount ?? 0), 0);
318
+ return totalAmount;
319
+ }
320
+ // Final fallback to transaction amount
321
+ return transaction.amount.amount;
322
+ }
323
+ case 'payee': {
324
+ // Priority: vendorName > customerName > from transactionLocalData
325
+ if (transaction.vendorName) {
326
+ return transaction.vendorName;
327
+ }
328
+ if (transaction.customerName) {
329
+ return transaction.customerName;
330
+ }
331
+ // Check transactionLocalData for vendor/customer
332
+ const localData = transaction.transactionLocalData?.transactionReviewLocalData;
333
+ if (localData?.vendor?.name) {
334
+ return localData.vendor.name;
335
+ }
336
+ if (localData?.customer?.name) {
337
+ return localData.customer.name;
338
+ }
339
+ return undefined;
340
+ }
341
+ case 'payment_account_name': {
342
+ // Get from transaction.account or from lines
343
+ if (transaction.transaction.account?.accountName) {
344
+ return transaction.transaction.account.accountName;
345
+ }
346
+ // Get from first line's account
347
+ const firstLine = transaction.transaction.lines?.[0];
348
+ if (firstLine?.type === 'transaction_with_account_and_class_line' ||
349
+ firstLine?.type === 'transaction_with_product_or_service_line' ||
350
+ firstLine?.type === 'journal_entry_transaction_line') {
351
+ const accountLine = firstLine;
352
+ return accountLine.account?.accountName;
353
+ }
354
+ return undefined;
355
+ }
356
+ case 'payment_account_type': {
357
+ // Similar to payment_account_name but for type
358
+ if (transaction.transaction.account?.accountType) {
359
+ return transaction.transaction.account.accountType;
360
+ }
361
+ const firstLineForType = transaction.transaction.lines?.[0];
362
+ if (firstLineForType?.type === 'transaction_with_account_and_class_line' ||
363
+ firstLineForType?.type === 'transaction_with_product_or_service_line' ||
364
+ firstLineForType?.type === 'journal_entry_transaction_line') {
365
+ const accountLineForType = firstLineForType;
366
+ return accountLineForType.account?.accountType;
367
+ }
368
+ return undefined;
369
+ }
370
+ case 'category': {
371
+ // Get from transactionLocalData (preferred) or from transaction lines
372
+ const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
373
+ if (localDataForCategory) {
374
+ // Get category from first line item or most common
375
+ const firstLineItem = Object.values(localDataForCategory.lineItemById)[0];
376
+ if (firstLineItem?.account?.accountId) {
377
+ return firstLineItem.account.accountId;
378
+ }
379
+ if (firstLineItem?.account?.qboId) {
380
+ return firstLineItem.account.qboId;
381
+ }
382
+ if (firstLineItem?.account?.accountName) {
383
+ return firstLineItem.account.accountName;
384
+ }
385
+ }
386
+ // Fallback to transaction lines
387
+ const firstLineForCategory = transaction.transaction.lines?.[0];
388
+ if (firstLineForCategory?.type ===
389
+ 'transaction_with_account_and_class_line' ||
390
+ firstLineForCategory?.type ===
391
+ 'transaction_with_product_or_service_line' ||
392
+ firstLineForCategory?.type === 'journal_entry_transaction_line') {
393
+ const account = firstLineForCategory.account;
394
+ return account?.accountId ?? account?.qboId ?? account?.accountName;
395
+ }
396
+ return undefined;
397
+ }
398
+ case 'class': {
399
+ // Similar to category but for class
400
+ const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
401
+ if (localDataForClass) {
402
+ const firstLineItemForClass = Object.values(localDataForClass.lineItemById)[0];
403
+ if (firstLineItemForClass?.class?.classId) {
404
+ return firstLineItemForClass.class.classId;
405
+ }
406
+ if (firstLineItemForClass?.class?.qboId) {
407
+ return firstLineItemForClass.class.qboId;
408
+ }
409
+ if (firstLineItemForClass?.class?.className) {
410
+ return firstLineItemForClass.class.className;
411
+ }
412
+ }
413
+ const firstLineForClass = transaction.transaction.lines?.[0];
414
+ if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
415
+ firstLineForClass?.type ===
416
+ 'transaction_with_product_or_service_line' ||
417
+ firstLineForClass?.type === 'journal_entry_transaction_line') {
418
+ const classData = firstLineForClass.class;
419
+ return classData?.classId ?? classData?.qboId ?? classData?.className;
420
+ }
421
+ return undefined;
422
+ }
423
+ default:
424
+ return undefined;
425
+ }
426
+ };
427
+ const getCategoryValueForPaymentHistory = (key, repayment) => {
428
+ switch (key) {
429
+ case 'repaymentDate':
430
+ return repayment.repaymentDate;
431
+ case 'sourceAccount': {
432
+ return repayment.paymentAccountId;
433
+ }
434
+ case 'status':
435
+ return repayment.status;
436
+ case 'initiatedBy':
437
+ return repayment.repaymentType === 'scheduled'
438
+ ? 'autopay'
439
+ : repayment.paidById;
440
+ default:
441
+ return undefined;
442
+ }
443
+ };
234
444
  const isBillListDownloadable = (state, currentTimePeriod) => {
235
445
  const { billListState, billTransactionState, entityApprovalStatusState, userState, } = state;
236
446
  const keys = billListState_1.ALL_BILL_TABS.filter((tab) => tab !== 'draft').map((tab) => (0, billListState_1.getBillListKey)(currentTimePeriod, tab));
@@ -11,11 +11,13 @@ const fetchDepositAccountListEpic = (actions$, _state$, zeniAPI) => actions$.pip
11
11
  return zeniAPI
12
12
  .getJSON(`${zeniAPI.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts?query=${encodeURIComponent(`{"is_include_deposit_accounts_summary":true}`)}`)
13
13
  .pipe((0, operators_1.mergeMap)((response) => {
14
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
15
- return (0, rxjs_1.of)((0, depositAccountReducer_1.updateDepositAccounts)(response.data?.deposit_accounts ?? []), (0, zeniAccountListReducer_1.updateZeniAccountsSummary)({
14
+ const isSuccess = (0, responsePayload_1.isSuccessResponse)(response);
15
+ if (isSuccess) {
16
+ const depositAccounts = response.data?.deposit_accounts ?? [];
17
+ return (0, rxjs_1.of)((0, depositAccountReducer_1.updateDepositAccounts)(depositAccounts), (0, zeniAccountListReducer_1.updateZeniAccountsSummary)({
16
18
  summaryPayload: response.data?.all_deposit_accounts_summary,
17
19
  }), (0, depositAccountListReducer_1.updateDepositAccountList)({
18
- data: response.data?.deposit_accounts ?? [],
20
+ data: depositAccounts,
19
21
  updateType: 'replace',
20
22
  }));
21
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.52",
3
+ "version": "4.19.53-betaAR1",
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
  "module": "lib/esm/index.js",