@zeniai/client-epic-state 5.0.55-betaAR1 → 5.0.55-betaAR3

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 (46) hide show
  1. package/lib/entity/account/accountSelector.d.ts +20 -1
  2. package/lib/entity/account/accountSelector.js +35 -1
  3. package/lib/entity/account/accountState.d.ts +5 -0
  4. package/lib/entity/account/accountState.js +11 -4
  5. package/lib/entity/approvalRule/approvalRulePayload.d.ts +5 -27
  6. package/lib/entity/approvalRule/approvalRulePayload.js +10 -131
  7. package/lib/entity/approvalRule/approvalRuleSelector.d.ts +1 -25
  8. package/lib/entity/approvalRule/approvalRuleSelector.js +0 -40
  9. package/lib/entity/approvalRule/approvalRuleState.d.ts +7 -48
  10. package/lib/entity/class/classSelector.d.ts +5 -0
  11. package/lib/entity/class/classSelector.js +8 -0
  12. package/lib/esm/entity/account/accountSelector.js +33 -1
  13. package/lib/esm/entity/account/accountState.js +7 -1
  14. package/lib/esm/entity/approvalRule/approvalRulePayload.js +10 -131
  15. package/lib/esm/entity/approvalRule/approvalRuleSelector.js +0 -35
  16. package/lib/esm/entity/class/classSelector.js +7 -0
  17. package/lib/esm/index.js +5 -5
  18. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +11 -1
  19. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +57 -8
  20. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +7 -5
  21. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +16 -46
  22. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +2 -7
  23. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +7 -5
  24. package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +185 -15
  25. package/lib/index.d.ts +6 -7
  26. package/lib/index.js +35 -37
  27. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  28. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
  29. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  30. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +5 -1
  31. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +12 -2
  32. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +4 -1
  33. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +59 -8
  34. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -0
  35. package/lib/view/people/peopleTypes.d.ts +1 -1
  36. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +6 -4
  37. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -1
  38. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +16 -46
  39. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +3 -15
  40. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +2 -7
  41. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  42. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +6 -4
  43. package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +45 -4
  44. package/lib/view/spendManagement/spendManagementFilterHelpers.js +186 -16
  45. package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
  46. package/package.json +1 -1
@@ -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;
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
+ }
37
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
@@ -119,7 +172,11 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
119
172
  ? getCategoryValueForReimbursement(key, item)
120
173
  : entity === 'task_management'
121
174
  ? getCategoryValueForTaskList(key, item)
122
- : getCategoryValueForPaymentHistory(key, item);
175
+ : entity === 'transaction_categorization'
176
+ ? getCategoryValueForTransaction(key, item)
177
+ : entity === 'charge_card_payment_history'
178
+ ? getCategoryValueForPaymentHistory(key, item)
179
+ : undefined;
123
180
  if (categoryValue == null) {
124
181
  if (currentFilter.matchingOperator === 'not-equal') {
125
182
  return true;
@@ -241,6 +298,119 @@ const getCategoryValueForReimbursement = (key, reimbursement) => {
241
298
  return undefined;
242
299
  }
243
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
+ // Match the value the row renders: TransactionCategorizationListRow reads
343
+ // `currentTransaction?.account?.accountName` for the Payment Account Name
344
+ // column. Returning the same field here keeps filter-match parity with the
345
+ // visible cell, so any row a user can see is also a row the filter can match.
346
+ return transaction.transaction.account?.accountName;
347
+ }
348
+ case 'payment_account_type': {
349
+ // Compare against the raw `paymentType` enum (e.g. "credit_card", "check",
350
+ // "cash"). The same enum is what TransactionCategorizationListRow uses for
351
+ // its icon switch on line ~1675, and it's what the dropdown options emit
352
+ // as `value`. Display labels come from each account's `paymentTypeName`
353
+ // field (populated by mapAccountBasePayloadToAccountBase from the backend
354
+ // payload) — no client-side label map required.
355
+ return transaction.transaction.paymentType;
356
+ }
357
+ case 'category': {
358
+ // Get from transactionLocalData (preferred) or from transaction lines
359
+ const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
360
+ if (localDataForCategory) {
361
+ // Get category from first line item or most common
362
+ const firstLineItem = Object.values(localDataForCategory.lineItemById)[0];
363
+ if (firstLineItem?.account?.accountId) {
364
+ return firstLineItem.account.accountId;
365
+ }
366
+ if (firstLineItem?.account?.qboId) {
367
+ return firstLineItem.account.qboId;
368
+ }
369
+ if (firstLineItem?.account?.accountName) {
370
+ return firstLineItem.account.accountName;
371
+ }
372
+ }
373
+ // Fallback to transaction lines
374
+ const firstLineForCategory = transaction.transaction.lines?.[0];
375
+ if (firstLineForCategory?.type ===
376
+ 'transaction_with_account_and_class_line' ||
377
+ firstLineForCategory?.type ===
378
+ 'transaction_with_product_or_service_line' ||
379
+ firstLineForCategory?.type === 'journal_entry_transaction_line') {
380
+ const account = firstLineForCategory.account;
381
+ return account?.accountId ?? account?.qboId ?? account?.accountName;
382
+ }
383
+ return undefined;
384
+ }
385
+ case 'class': {
386
+ // Similar to category but for class
387
+ const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
388
+ if (localDataForClass) {
389
+ const firstLineItemForClass = Object.values(localDataForClass.lineItemById)[0];
390
+ if (firstLineItemForClass?.class?.classId) {
391
+ return firstLineItemForClass.class.classId;
392
+ }
393
+ if (firstLineItemForClass?.class?.qboId) {
394
+ return firstLineItemForClass.class.qboId;
395
+ }
396
+ if (firstLineItemForClass?.class?.className) {
397
+ return firstLineItemForClass.class.className;
398
+ }
399
+ }
400
+ const firstLineForClass = transaction.transaction.lines?.[0];
401
+ if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
402
+ firstLineForClass?.type ===
403
+ 'transaction_with_product_or_service_line' ||
404
+ firstLineForClass?.type === 'journal_entry_transaction_line') {
405
+ const classData = firstLineForClass.class;
406
+ return classData?.classId ?? classData?.qboId ?? classData?.className;
407
+ }
408
+ return undefined;
409
+ }
410
+ default:
411
+ return undefined;
412
+ }
413
+ };
244
414
  const getCategoryValueForPaymentHistory = (key, repayment) => {
245
415
  switch (key) {
246
416
  case 'repaymentDate':
@@ -50,15 +50,15 @@ export interface TaskFilterCategory {
50
50
  }
51
51
  export type TaskListFilterCategoryField = 'status' | 'dueDate' | 'assignee' | 'creationDate' | 'priority' | 'tag';
52
52
  export declare const TASK_LIST_GROUP_BY_KEYS: readonly ["groupName", "status", "dueDate", "assignee", "priority", "tag"];
53
- export declare const toTaskListGroupByKeyType: (v: string) => "status" | "priority" | "dueDate" | "groupName" | "tag" | "assignee";
54
- export declare const toTaskListGroupByKeyTypeStrict: (v: string) => "status" | "priority" | "dueDate" | "groupName" | "tag" | "assignee" | undefined;
53
+ export declare const toTaskListGroupByKeyType: (v: string) => "status" | "dueDate" | "groupName" | "tag" | "priority" | "assignee";
54
+ export declare const toTaskListGroupByKeyTypeStrict: (v: string) => "status" | "dueDate" | "groupName" | "tag" | "priority" | "assignee" | undefined;
55
55
  export declare type TaskGroupKey = ReturnType<typeof toTaskListGroupByKeyType>;
56
56
  export interface TaskListUIState extends SpendManagementUIState {
57
57
  groupByKey: TaskGroupKey;
58
58
  searchText: string;
59
59
  sortKey: TaskListViewSortKey;
60
60
  }
61
- declare const toTaskListSortKeyType: (v: string) => "status" | "name" | "priority" | "dueDate" | "tag" | "timeSpent" | "assignee" | "creationDate" | "visibility";
61
+ declare const toTaskListSortKeyType: (v: string) => "status" | "name" | "dueDate" | "tag" | "priority" | "timeSpent" | "assignee" | "creationDate" | "visibility";
62
62
  export declare type TaskListViewSortKey = ReturnType<typeof toTaskListSortKeyType>;
63
63
  export declare const TASK_LIST_FILTER_CATEGORIES: TaskListFilterCategoryOption[];
64
64
  interface TaskListFilterCategoryOption {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.55-betaAR1",
3
+ "version": "5.0.55-betaAR3",
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",