@zeniai/client-epic-state 4.19.99-betaSS4 → 4.19.99

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 (122) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/entity/aiCfo/aiCfoSelector.d.ts +2 -1
  3. package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +2 -2
  4. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +0 -38
  5. package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -78
  6. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +1 -4
  7. package/lib/entity/jeSchedules/jeSchedulesSelector.js +1 -5
  8. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -37
  9. package/lib/entity/tenant/tenantPayload.d.ts +0 -1
  10. package/lib/entity/tenant/tenantReducer.js +0 -1
  11. package/lib/entity/tenant/tenantSelector.d.ts +0 -1
  12. package/lib/entity/tenant/tenantSelector.js +1 -9
  13. package/lib/entity/tenant/tenantState.d.ts +0 -1
  14. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +1 -4
  15. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -1
  16. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +0 -3
  17. package/lib/entity/transaction/payloadTypes/transactionPayload.js +1 -17
  18. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -1
  19. package/lib/entity/transaction/stateTypes/transaction.d.ts +0 -5
  20. package/lib/entity/transaction/stateTypes/transactionLine.d.ts +1 -1
  21. package/lib/epic.d.ts +1 -2
  22. package/lib/epic.js +1 -2
  23. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -78
  24. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +1 -5
  25. package/lib/esm/entity/tenant/tenantReducer.js +0 -1
  26. package/lib/esm/entity/tenant/tenantSelector.js +0 -7
  27. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -1
  28. package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +1 -17
  29. package/lib/esm/epic.js +1 -2
  30. package/lib/esm/index.js +7 -8
  31. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +1 -82
  32. package/lib/esm/view/aiCfoView/aiCfoViewSelector.js +2 -8
  33. package/lib/esm/view/classList/fetchClassListEpic.js +2 -9
  34. package/lib/esm/view/commonVendorView/vendorView/vendorViewSelector.js +5 -18
  35. package/lib/esm/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector.js +2 -6
  36. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -2
  37. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +2 -2
  38. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +3 -4
  39. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -0
  40. package/lib/esm/view/expenseAutomationView/helpers/saveTransactionHelper.js +2 -2
  41. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  42. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -17
  43. package/lib/esm/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -10
  44. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +6 -63
  45. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +4 -12
  46. package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +9 -22
  47. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +6 -12
  48. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -18
  49. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +8 -3
  50. package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +63 -144
  51. package/lib/esm/view/spendManagement/billPay/billList/billListSelector.js +0 -10
  52. package/lib/esm/view/spendManagement/billPay/billList/billListState.js +0 -1
  53. package/lib/esm/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +3 -7
  54. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +5 -5
  55. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPayApproversDetailsEpic.js +2 -7
  56. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +6 -13
  57. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +0 -1
  58. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -2
  59. package/lib/esm/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.js +4 -7
  60. package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListSelector.js +0 -12
  61. package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListState.js +0 -1
  62. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +2 -2
  63. package/lib/esm/view/transactionDetail/epics/saveTransactionHelper.js +2 -2
  64. package/lib/esm/view/transactionDetail/transactionDetailLocalDataHelper.js +14 -16
  65. package/lib/index.d.ts +10 -13
  66. package/lib/index.js +32 -42
  67. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  68. package/lib/view/aiCfoView/aiCfoViewPayload.d.ts +0 -7
  69. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +1 -15
  70. package/lib/view/aiCfoView/aiCfoViewReducer.js +2 -83
  71. package/lib/view/aiCfoView/aiCfoViewSelector.d.ts +1 -4
  72. package/lib/view/aiCfoView/aiCfoViewSelector.js +2 -9
  73. package/lib/view/aiCfoView/aiCfoViewState.d.ts +1 -18
  74. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  75. package/lib/view/classList/fetchClassListEpic.d.ts +1 -1
  76. package/lib/view/classList/fetchClassListEpic.js +1 -8
  77. package/lib/view/commonVendorView/vendorView/vendorViewSelector.d.ts +0 -1
  78. package/lib/view/commonVendorView/vendorView/vendorViewSelector.js +5 -18
  79. package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector.d.ts +0 -1
  80. package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector.js +2 -6
  81. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -2
  82. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +1 -1
  83. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +3 -4
  84. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -0
  85. package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +2 -2
  86. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  87. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +1 -1
  88. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -2
  89. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -18
  90. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
  91. package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -10
  92. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +6 -63
  93. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +4 -12
  94. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +9 -22
  95. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +5 -11
  96. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -5
  97. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +0 -20
  98. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +8 -3
  99. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +63 -144
  100. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  101. package/lib/view/spendManagement/billPay/billList/billListSelector.js +0 -10
  102. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  103. package/lib/view/spendManagement/billPay/billList/billListState.js +0 -1
  104. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +3 -7
  105. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +5 -5
  106. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPayApproversDetailsEpic.js +2 -7
  107. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +6 -13
  108. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  109. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +0 -1
  110. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -2
  111. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.js +3 -6
  112. package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.d.ts +0 -1
  113. package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.js +0 -12
  114. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
  115. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.js +0 -1
  116. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +2 -2
  117. package/lib/view/transactionDetail/epics/saveTransactionHelper.js +2 -2
  118. package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +14 -16
  119. package/package.json +1 -1
  120. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +0 -29
  121. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +0 -8
  122. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +0 -33
@@ -13,7 +13,7 @@ import { getAccountList, getNestedAccountListHierarchy, } from '../../accountLis
13
13
  import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
14
14
  import { initialActionFetchState, initialReconciliationTabsState, initialState, } from '../reducers/reconciliationViewReducer';
15
15
  import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
16
- export const getExpenseAutomationReconciliationView = createSelector((state) => state, (state) => getCurrentTenant(state), (state) => state.expenseAutomationReconciliationViewState, (state) => state.expenseAutomationViewState, (state) => state.plaidAccountViewState, (state) => state.accountListState, (state) => state.accountState, (state) => state.classListState, (state) => state.classState, (state) => state.monthEndCloseChecksState, (state) => state.vendorState, (state) => state.monthEndCloseChecksViewState, (state, currentTenant, reconciliationViewState, expenseAutomationViewState, plaidAccountViewState, accountListState, accountState, classListState, classState, monthEndCloseChecksState, vendorState, monthEndCloseChecksViewState) => {
16
+ export const getExpenseAutomationReconciliationView = createSelector((state) => state, (state) => getCurrentTenant(state), (state) => state.expenseAutomationReconciliationViewState, (state) => state.expenseAutomationViewState, (state) => state.plaidAccountViewState, (state) => state.accountListState, (state) => state.accountState, (state) => state.classListState, (state) => state.classState, (state) => state.monthEndCloseChecksState, (state) => state.vendorState, (state, currentTenant, reconciliationViewState, expenseAutomationViewState, plaidAccountViewState, accountListState, accountState, classListState, classState, monthEndCloseChecksState, vendorState) => {
17
17
  const { selectedPeriodByTenantId } = expenseAutomationViewState;
18
18
  const reconcileTabUiState = reconciliationViewState.reconTabsState.reconcile.uiState;
19
19
  const reviewTabUiState = reconciliationViewState.reconTabsState.review.uiState;
@@ -35,13 +35,6 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
35
35
  }
36
36
  return acc;
37
37
  }, []);
38
- const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
39
- const monthEndFetchState = monthYearPeriodId != null
40
- ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? {
41
- fetchState: 'Not-Started',
42
- error: undefined,
43
- })
44
- : { fetchState: 'Not-Started', error: undefined };
45
38
  if (accountReconForMonthYearPeriod == null) {
46
39
  return {
47
40
  bankAccounts: [],
@@ -51,13 +44,10 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
51
44
  classListNestedAccountHierarchy: [],
52
45
  allAccountList: [],
53
46
  allClassList: [],
54
- fetchStatus: reduceAnyFetchState([
55
- {
56
- fetchState: reconciliationViewState.fetchState,
57
- error: reconciliationViewState.error,
58
- },
59
- monthEndFetchState,
60
- ]),
47
+ fetchStatus: {
48
+ fetchState: reconciliationViewState.fetchState,
49
+ error: reconciliationViewState.error,
50
+ },
61
51
  plaidConnectionDetails: plaidAccountViewState['expense_automation_reconcile']
62
52
  .plaidConnectionDetails,
63
53
  completionStatus: 'incomplete',
@@ -280,13 +270,10 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
280
270
  bankAccounts: uniqueBankAccounts,
281
271
  creditCards: uniqueCreditCards,
282
272
  accountReconciliationsByAccountID: reconList,
283
- fetchStatus: reduceAnyFetchState([
284
- {
285
- fetchState: reconciliationViewState.fetchState,
286
- error: reconciliationViewState.error,
287
- },
288
- monthEndFetchState,
289
- ]),
273
+ fetchStatus: {
274
+ fetchState: reconciliationViewState.fetchState,
275
+ error: reconciliationViewState.error,
276
+ },
290
277
  plaidConnectionDetails: plaidAccountViewState['expense_automation_reconcile']
291
278
  .plaidConnectionDetails,
292
279
  reconciliationTabsState: reconciliationViewState.reconTabsState,
@@ -1,5 +1,5 @@
1
1
  import omit from 'lodash/omit';
2
- import { reduceAllFetchState, reduceAnyFetchState, } from '../../../commonStateTypes/reduceFetchState';
2
+ import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState';
3
3
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
4
4
  import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
5
5
  import { getTransactionWithCOT } from '../../../entity/transaction/transactionHelper';
@@ -8,7 +8,7 @@ import { getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts
8
8
  import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
9
9
  import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
10
10
  export function getExpenseAutomationTransactionView(state) {
11
- const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
11
+ const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
12
12
  const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
13
13
  const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
14
14
  const uncategorizedIncomeExpense = getUncategorizedAccounts(accountState, accountListState, 'accountList');
@@ -41,16 +41,10 @@ export function getExpenseAutomationTransactionView(state) {
41
41
  .filter((transaction) => transaction != null);
42
42
  const transactions = getSupportedTransactionsByIds(transactionState, transactionIds);
43
43
  const transactionsWithCOT = transactions.map((transaction) => getTransactionWithCOT(transaction));
44
- const monthEndFetchState = monthYearPeriodId != null
45
- ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
46
- : { fetchState: 'Not-Started', error: undefined };
47
- const fetchStatus = reduceAnyFetchState([
48
- reduceAllFetchState([
49
- accountList,
50
- classList,
51
- expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab],
52
- ]),
53
- monthEndFetchState,
44
+ const fetchStatus = reduceAllFetchState([
45
+ accountList,
46
+ classList,
47
+ expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab],
54
48
  ]);
55
49
  const totalCountByReview = expenseAutomationTransactionsViewState.transactionCategorizationView.review
56
50
  .uiState.totalCount;
@@ -1,18 +1 @@
1
- import { stringToUnion } from '../../../commonStateTypes/stringToUnion';
2
- const JE_SCHEDULE_SORT_KEYS = [
3
- 'vendor',
4
- 'category',
5
- 'class',
6
- 'depCategory',
7
- 'scheduleCategory',
8
- 'startMonth',
9
- 'type',
10
- 'amortizationPeriod',
11
- 'jePostingDate',
12
- 'remainingMonths',
13
- 'runningBalance',
14
- 'totalAmount',
15
- 'transactionDate',
16
- 'memo',
17
- ];
18
- export const toJEScheduleSortKey = (v) => stringToUnion(v, JE_SCHEDULE_SORT_KEYS);
1
+ export {};
@@ -49,11 +49,16 @@ export const getProfitAndLossClassesHorizontalView = (filter, accountState, clas
49
49
  const calculatedSections = {};
50
50
  let reportCurrency = defaultCustomerCurrency;
51
51
  if (fetchState.fetchState === 'Completed' && selectedPeriod != null) {
52
+ // Get section reports using existing selector infrastructure
53
+ const sectionReports = {};
54
+ HORIZONTAL_PANDL_SECTION_IDS.forEach((sectionId) => {
55
+ sectionReports[sectionId] = getSectionClassesViewReport(accountState, classState, sectionsState, { reportId, sectionId }, filter);
56
+ });
52
57
  reportCurrency =
53
58
  profitAndLossClassesViewState.currency ?? defaultCustomerCurrency;
54
- // Fetch each section and pivot class→account to account→class in one pass
59
+ // Pivot each section from class→account to account→class
55
60
  HORIZONTAL_PANDL_SECTION_IDS.forEach((sectionId) => {
56
- const sectionReport = getSectionClassesViewReport(accountState, classState, sectionsState, { reportId, sectionId }, filter);
61
+ const sectionReport = sectionReports[sectionId];
57
62
  if (sectionReport != null) {
58
63
  sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns, SECTION_TITLES[sectionId] ?? sectionId, reportCurrency);
59
64
  }
@@ -256,7 +261,7 @@ function sumBalancesInSlice(balances) {
256
261
  if (balances.length === 0) {
257
262
  return 0;
258
263
  }
259
- const summed = getSummationFreeRangeTotalBalance(balances);
264
+ const summed = getSummationFreeRangeTotalBalance([...balances]);
260
265
  return summed?.balance.amount ?? 0;
261
266
  }
262
267
  /**
@@ -25,31 +25,30 @@ function enrichHorizontalSection(report, section) {
25
25
  return total?.balance.amount ?? 0;
26
26
  });
27
27
  section.sectionHeaderBalancesSlice = buildHorizontalClassColumnBalancesSlice(report, classAmounts, section.sectionTotal.amount);
28
- const parentIndices = computeHorizontalAccountParentIndices(section.accounts);
29
- const childrenRowIndicesByParent = buildHorizontalAccountChildIndicesByParent(parentIndices);
28
+ const childrenRowIndicesByParent = buildHorizontalAccountChildIndicesByParent(section.accounts);
30
29
  const childrenRecord = {};
31
30
  childrenRowIndicesByParent.forEach((childIndices, parentIndex) => {
32
31
  childrenRecord[parentIndex] = childIndices;
33
32
  });
34
33
  section.treeLayout = {
35
34
  rootAccountRowIndices: section.accounts
36
- .map((_, i) => (parentIndices[i] === -1 ? i : -1))
35
+ .map((_, i) => findHorizontalAccountParentIndex(section.accounts, i) === -1 ? i : -1)
37
36
  .filter((i) => i >= 0),
38
37
  childrenRowIndicesByParent: childrenRecord,
39
38
  };
40
- const siblingsPerRow = buildSiblingIndicesPerRow(section.accounts, parentIndices);
41
- const hasChildFlags = computeHorizontalHasChildFlags(parentIndices);
42
- for (let accountIndex = 0; accountIndex < section.accounts.length; accountIndex++) {
43
- const row = section.accounts[accountIndex];
44
- // Same column order as `report.classColumns` (see `pivotSectionToHorizontal`).
45
- const classRowAmounts = row.classBalances.map((classBalance) => classBalance.balance.amount);
39
+ for (let i = 0; i < section.accounts.length; i++) {
40
+ const row = section.accounts[i];
41
+ const classRowAmounts = report.classColumns.map((col) => {
42
+ const cb = row.classBalances.find((b) => b.classId === col.classId);
43
+ return cb?.balance.amount ?? 0;
44
+ });
46
45
  row.accountReportData = {
47
46
  accountId: row.accountId,
48
47
  accountName: row.accountName,
49
48
  accountType: row.accountType,
50
49
  depth: row.depth,
51
50
  balancesInTimeframe: buildHorizontalClassColumnBalancesSlice(report, classRowAmounts, row.rowTotal.amount),
52
- horizontalTreeView: buildHorizontalTreeViewFromPrecomputed(section.accounts, accountIndex, parentIndices, siblingsPerRow, hasChildFlags),
51
+ horizontalTreeView: buildHorizontalTreeView(section.accounts, i),
53
52
  };
54
53
  }
55
54
  }
@@ -81,9 +80,9 @@ function buildHorizontalClassColumnBalancesSlice(report, classAmounts, totalAmou
81
80
  return emptySlice;
82
81
  }
83
82
  const { startDate, endDate } = report.selectedPeriod;
84
- const balances = report.classColumns.map((col, columnIndex) => ({
83
+ const balances = report.classColumns.map((col, i) => ({
85
84
  balance: {
86
- amount: classAmounts[columnIndex] ?? 0,
85
+ amount: classAmounts[i] ?? 0,
87
86
  currencyCode,
88
87
  currencySymbol,
89
88
  },
@@ -121,157 +120,64 @@ function buildHorizontalClassColumnBalancesSlice(report, classAmounts, totalAmou
121
120
  },
122
121
  };
123
122
  }
124
- /**
125
- * Parent index per DFS row — O(n). Matches the scan in the former
126
- * `findHorizontalAccountParentIndex` (depth &lt;= 2 rows have no parent).
127
- */
128
- function computeHorizontalAccountParentIndices(rows) {
129
- const accountRowCount = rows.length;
130
- const parentIndex = new Array(accountRowCount).fill(-1);
131
- const stack = [];
132
- for (let rowIndex = 0; rowIndex < accountRowCount; rowIndex++) {
133
- const accountRow = rows[rowIndex];
134
- if (accountRow == null) {
135
- continue;
136
- }
137
- const depth = accountRow.depth;
138
- while (stack.length > 0) {
139
- const topIndex = stack[stack.length - 1];
140
- if (topIndex == null) {
141
- break;
142
- }
143
- const topRow = rows[topIndex];
144
- if (topRow == null) {
145
- stack.pop();
146
- continue;
147
- }
148
- if (topRow.depth < depth) {
149
- break;
150
- }
151
- stack.pop();
152
- }
153
- if (depth <= 2) {
154
- parentIndex[rowIndex] = -1;
155
- }
156
- else if (stack.length === 0) {
157
- parentIndex[rowIndex] = -1;
158
- }
159
- else {
160
- const peek = stack[stack.length - 1];
161
- if (peek == null) {
162
- parentIndex[rowIndex] = -1;
163
- }
164
- else {
165
- const parentRow = rows[peek];
166
- parentIndex[rowIndex] =
167
- parentRow != null && parentRow.depth === depth - 1 ? peek : -1;
123
+ function findHorizontalAccountParentIndex(dfsOrderedAccountRows, childRowIndex) {
124
+ const childDepth = dfsOrderedAccountRows[childRowIndex].depth;
125
+ if (childDepth <= 2) {
126
+ return -1;
127
+ }
128
+ for (let earlierRowIndex = childRowIndex - 1; earlierRowIndex >= 0; earlierRowIndex--) {
129
+ const earlierDepth = dfsOrderedAccountRows[earlierRowIndex].depth;
130
+ if (earlierDepth < childDepth) {
131
+ if (earlierDepth === childDepth - 1) {
132
+ return earlierRowIndex;
168
133
  }
134
+ return -1;
169
135
  }
170
- stack.push(rowIndex);
171
136
  }
172
- return parentIndex;
137
+ return -1;
173
138
  }
174
- /** Sibling row indices (same parent + depth), in traversal order — O(n). */
175
- function buildSiblingIndicesPerRow(rows, parentIndices) {
176
- const accountRowCount = rows.length;
177
- const keyToIndices = new Map();
178
- for (let rowIndex = 0; rowIndex < accountRowCount; rowIndex++) {
179
- const parentRowIndex = parentIndices[rowIndex];
180
- const accountRow = rows[rowIndex];
181
- if (parentRowIndex == null || accountRow == null) {
182
- continue;
183
- }
184
- const key = `${parentRowIndex}:${accountRow.depth}`;
185
- let siblingGroup = keyToIndices.get(key);
186
- if (siblingGroup == null) {
187
- siblingGroup = [];
188
- keyToIndices.set(key, siblingGroup);
139
+ function getHorizontalAccountSiblingIndices(dfsOrderedAccountRows, rowIndex) {
140
+ const parentRowIndex = findHorizontalAccountParentIndex(dfsOrderedAccountRows, rowIndex);
141
+ const rowDepth = dfsOrderedAccountRows[rowIndex].depth;
142
+ const siblings = [];
143
+ for (let i = 0; i < dfsOrderedAccountRows.length; i++) {
144
+ if (dfsOrderedAccountRows[i].depth === rowDepth &&
145
+ findHorizontalAccountParentIndex(dfsOrderedAccountRows, i) ===
146
+ parentRowIndex) {
147
+ siblings.push(i);
189
148
  }
190
- siblingGroup.push(rowIndex);
191
149
  }
192
- const siblingsPerRow = new Array(accountRowCount);
193
- for (let rowIndex = 0; rowIndex < accountRowCount; rowIndex++) {
194
- const parentRowIndex = parentIndices[rowIndex];
195
- const accountRow = rows[rowIndex];
196
- if (parentRowIndex == null || accountRow == null) {
197
- siblingsPerRow[rowIndex] = [rowIndex];
198
- continue;
199
- }
200
- const key = `${parentRowIndex}:${accountRow.depth}`;
201
- const group = keyToIndices.get(key);
202
- siblingsPerRow[rowIndex] = group != null ? group : [rowIndex];
203
- }
204
- return siblingsPerRow;
150
+ return siblings;
205
151
  }
206
- function computeHorizontalHasChildFlags(parentIndices) {
207
- const rowCount = parentIndices.length;
208
- const flags = new Array(rowCount).fill(false);
209
- for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
210
- const parentRowIndex = parentIndices[rowIndex];
211
- if (parentRowIndex != null &&
212
- parentRowIndex >= 0 &&
213
- parentRowIndex < rowCount) {
214
- flags[parentRowIndex] = true;
215
- }
216
- }
217
- return flags;
152
+ function horizontalAccountHasChildRows(dfsOrderedAccountRows, parentRowIndex) {
153
+ return dfsOrderedAccountRows.some((_, rowIndex) => findHorizontalAccountParentIndex(dfsOrderedAccountRows, rowIndex) ===
154
+ parentRowIndex);
218
155
  }
219
- function buildHorizontalSubAccountAncestorMetadataFromPrecomputed(dfsOrderedAccountRows, currentRowIndex, parentIndices, siblingsPerRow, hasChildFlags) {
220
- const chain = [];
156
+ function buildHorizontalSubAccountAncestorMetadata(dfsOrderedAccountRows, currentRowIndex) {
157
+ const ancestorRowIndicesRootToLeaf = [];
221
158
  let walkRowIndex = currentRowIndex;
222
159
  while (walkRowIndex >= 0) {
223
- chain.unshift(walkRowIndex);
224
- const parentRowIndex = parentIndices[walkRowIndex];
225
- if (parentRowIndex == null) {
226
- break;
227
- }
228
- walkRowIndex = parentRowIndex;
160
+ ancestorRowIndicesRootToLeaf.unshift(walkRowIndex);
161
+ walkRowIndex = findHorizontalAccountParentIndex(dfsOrderedAccountRows, walkRowIndex);
229
162
  }
230
- return chain.map((rowIndex) => {
231
- const accountRow = dfsOrderedAccountRows[rowIndex];
232
- const siblingIndices = siblingsPerRow[rowIndex];
233
- const hasChild = hasChildFlags[rowIndex];
234
- if (accountRow == null || siblingIndices == null) {
235
- return {
236
- depth: 0,
237
- hasSibling: false,
238
- hasChildren: hasChild === true,
239
- isLastNode: true,
240
- name: '',
241
- };
242
- }
163
+ return ancestorRowIndicesRootToLeaf.map((rowIndex) => {
164
+ const siblingIndices = getHorizontalAccountSiblingIndices(dfsOrderedAccountRows, rowIndex);
243
165
  return {
244
- depth: accountRow.depth - 2,
166
+ depth: dfsOrderedAccountRows[rowIndex].depth - 2,
245
167
  hasSibling: siblingIndices.length > 1,
246
- hasChildren: hasChild === true,
168
+ hasChildren: horizontalAccountHasChildRows(dfsOrderedAccountRows, rowIndex),
247
169
  isLastNode: rowIndex === siblingIndices[siblingIndices.length - 1],
248
- name: accountRow.accountName,
170
+ name: dfsOrderedAccountRows[rowIndex].accountName,
249
171
  };
250
172
  });
251
173
  }
252
- function buildHorizontalTreeViewFromPrecomputed(dfsOrderedAccountRows, currentRowIndex, parentIndices, siblingsPerRow, hasChildFlags) {
253
- const siblingIndices = siblingsPerRow[currentRowIndex];
254
- const accountRow = dfsOrderedAccountRows[currentRowIndex];
255
- const hasChildrenFlag = hasChildFlags[currentRowIndex];
256
- const treeDepth = accountRow != null ? Math.max(0, accountRow.depth - 2) : 0;
257
- const hasChildren = hasChildrenFlag === true;
258
- const siblings = siblingIndices ?? [currentRowIndex];
259
- return {
260
- subAccountAncestorMetadata: buildHorizontalSubAccountAncestorMetadataFromPrecomputed(dfsOrderedAccountRows, currentRowIndex, parentIndices, siblingsPerRow, hasChildFlags),
261
- treeDepth,
262
- hasChildren,
263
- hasSiblings: siblings.length > 1,
264
- isLeaf: !hasChildren,
265
- isLastNode: currentRowIndex === siblings[siblings.length - 1],
266
- };
267
- }
268
- function buildHorizontalAccountChildIndicesByParent(parentIndices) {
174
+ function buildHorizontalAccountChildIndicesByParent(dfsOrderedAccountRows) {
269
175
  const childIndicesByParentRowIndex = new Map();
270
- for (let rowIndex = 0; rowIndex < parentIndices.length; rowIndex++) {
271
- const parentRowIndex = parentIndices[rowIndex];
272
- if (parentRowIndex != null && parentRowIndex >= 0) {
176
+ for (let rowIndex = 0; rowIndex < dfsOrderedAccountRows.length; rowIndex++) {
177
+ const parentRowIndex = findHorizontalAccountParentIndex(dfsOrderedAccountRows, rowIndex);
178
+ if (parentRowIndex >= 0) {
273
179
  let childRowIndices = childIndicesByParentRowIndex.get(parentRowIndex);
274
- if (childRowIndices == null) {
180
+ if (childRowIndices === undefined) {
275
181
  childRowIndices = [];
276
182
  childIndicesByParentRowIndex.set(parentRowIndex, childRowIndices);
277
183
  }
@@ -280,3 +186,16 @@ function buildHorizontalAccountChildIndicesByParent(parentIndices) {
280
186
  }
281
187
  return childIndicesByParentRowIndex;
282
188
  }
189
+ function buildHorizontalTreeView(dfsOrderedAccountRows, currentRowIndex) {
190
+ const treeDepth = Math.max(0, dfsOrderedAccountRows[currentRowIndex].depth - 2);
191
+ const siblingIndices = getHorizontalAccountSiblingIndices(dfsOrderedAccountRows, currentRowIndex);
192
+ const hasChildren = horizontalAccountHasChildRows(dfsOrderedAccountRows, currentRowIndex);
193
+ return {
194
+ subAccountAncestorMetadata: buildHorizontalSubAccountAncestorMetadata(dfsOrderedAccountRows, currentRowIndex),
195
+ treeDepth,
196
+ hasChildren,
197
+ hasSiblings: siblingIndices.length > 1,
198
+ isLeaf: !hasChildren,
199
+ isLastNode: currentRowIndex === siblingIndices[siblingIndices.length - 1],
200
+ };
201
+ }
@@ -416,14 +416,6 @@ export const getBillListOnSort = (sortKey, sortOrder, currentTab, transactions)
416
416
  transactionsWithNoSortKeyValue.push(transaction);
417
417
  }
418
418
  break;
419
- case 'invoiceNumber':
420
- if (transaction.documentId != null) {
421
- transactionsWithSortKeyValue.push(transaction);
422
- }
423
- else {
424
- transactionsWithNoSortKeyValue.push(transaction);
425
- }
426
- break;
427
419
  case 'dueDate':
428
420
  if (currentTab === 'draft') {
429
421
  if (Boolean(transaction.dueDate) === true) {
@@ -526,8 +518,6 @@ export const getBillListOnSort = (sortKey, sortOrder, currentTab, transactions)
526
518
  return transaction.totalAmountInUSD?.amount ?? 0;
527
519
  case 'paymentMethod':
528
520
  return transaction.billPayInfo.billPaymentMethodType.name;
529
- case 'invoiceNumber':
530
- return transaction.documentId;
531
521
  }
532
522
  }, getColumnWiseSortOrder(sortOrder));
533
523
  return [
@@ -43,7 +43,6 @@ const ALL_BILL_PAY_SORT_KEYS = [
43
43
  'invoiceDate',
44
44
  'name',
45
45
  'paymentMethod',
46
- 'invoiceNumber',
47
46
  ];
48
47
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
48
  const toBillPaySortKeyType = (v) => stringToUnion(v, ALL_BILL_PAY_SORT_KEYS);
@@ -2,7 +2,6 @@ import recordGet from 'lodash/get';
2
2
  import { reduceFetchState } from '../../../../commonStateTypes/reduceFetchState';
3
3
  import { getContactsByIds } from '../../../../entity/billPay/contact/contactSelector';
4
4
  import { getPaymentAccountsByPaymentAccountIds } from '../../../../entity/paymentAccount/paymentAccountSelector';
5
- import { getIsAccountingClassesEnabled } from '../../../../entity/tenant/tenantSelector';
6
5
  import { getVendorByVendorId } from '../../../../entity/vendor/vendorSelector';
7
6
  import { getAccountList } from '../../../accountList/accountListSelector';
8
7
  import { getAllFundingAccounts, } from '../../commonSetup/setupViewSelector';
@@ -74,14 +73,11 @@ export const getReviewPageBillDetail = (state, billId) => {
74
73
  }
75
74
  }
76
75
  if (sourceBillDetail != null) {
77
- const fetchStateList = [
76
+ sourceBillDetailFetchState = reduceFetchState([
78
77
  sourceBillDetail.fetchStatus,
79
78
  accountListState.byReportId['billPayAccountList'],
80
- ];
81
- if (getIsAccountingClassesEnabled(state)) {
82
- fetchStateList.push(classListState);
83
- }
84
- sourceBillDetailFetchState = reduceFetchState(fetchStateList).fetchState;
79
+ classListState,
80
+ ]).fetchState;
85
81
  }
86
82
  }
87
83
  else {
@@ -3,7 +3,6 @@ import cloneDeep from 'lodash/cloneDeep';
3
3
  import { reduceAllFetchState, reduceAnyFetchState, } from '../../../../commonStateTypes/reduceFetchState';
4
4
  import { getApprovalRulesByIds } from '../../../../entity/approvalRule/approvalRuleSelector';
5
5
  import { getClassesByIds } from '../../../../entity/class/classSelector';
6
- import { getIsAccountingClassesEnabled } from '../../../../entity/tenant/tenantSelector';
7
6
  import { getUserByUserId } from '../../../../entity/user/userSelector';
8
7
  import { getUserRoleByUserId } from '../../../../entity/userRole/userRoleSelector';
9
8
  export const getBillPaySetupApproverView = createSelector((state) => state.billPaySetupApproverViewState, (state) => state.approvalRuleState, (state) => state.userState, (billPaySetupApproverViewState, approvalRuleState, userState) => {
@@ -45,7 +44,7 @@ export const getBillPaySetupApproverView = createSelector((state) => state.billP
45
44
  newApprovalRuleId,
46
45
  };
47
46
  });
48
- export const getBillPaySetupApproverUpdateDataView = createSelector((state) => state.billPaySetupApproverViewState, (state) => state.approvalRuleState, (state) => state.userState, (state) => state.classState, (state) => state.classListState, (state) => state.userRoleState, (state) => getIsAccountingClassesEnabled(state), (billPaySetupApproverViewState, approvalRuleState, userState, classState, classListState, userRoleState, isAccountingClassesEnabled) => {
47
+ export const getBillPaySetupApproverUpdateDataView = createSelector((state) => state.billPaySetupApproverViewState, (state) => state.approvalRuleState, (state) => state.userState, (state) => state.classState, (state) => state.classListState, (state) => state.userRoleState, (billPaySetupApproverViewState, approvalRuleState, userState, classState, classListState, userRoleState) => {
49
48
  const { affectedEntityIds, approvalRuleIds, approverListState, billPaySetupApproverViewUpdateData, fetchState, error, listeningToPusherEvent, } = billPaySetupApproverViewState;
50
49
  const { approverIds, attributes } = approverListState;
51
50
  const allApprovalRules = getApprovalRulesByIds(approvalRuleState, approvalRuleIds);
@@ -93,9 +92,10 @@ export const getBillPaySetupApproverUpdateDataView = createSelector((state) => s
93
92
  allAttributes,
94
93
  filteredAttributes,
95
94
  billPaySetupApproverViewUpdateData,
96
- approverListFetchStatus: isAccountingClassesEnabled
97
- ? reduceAllFetchState([approverListState.fetchStatus, classListState])
98
- : approverListState.fetchStatus,
95
+ approverListFetchStatus: reduceAllFetchState([
96
+ approverListState.fetchStatus,
97
+ classListState,
98
+ ]),
99
99
  fetchState,
100
100
  allAccountingClasses,
101
101
  error,
@@ -1,27 +1,22 @@
1
1
  import { concat, from } from 'rxjs';
2
2
  import { filter, mergeMap } from 'rxjs/operators';
3
- import { getIsAccountingClassesEnabled } from '../../../../../entity/tenant/tenantSelector';
4
3
  import { fetchClassList } from '../../../../classList/classListReducer';
5
4
  import { fetchBillPayApproversDetails, fetchBillPayApproversList, } from '../billPaySetupApproverViewReducer';
6
5
  export const fetchBillPayApproversDetailsEpic = (actions$, state$) => actions$.pipe(filter(fetchBillPayApproversDetails.match), mergeMap((action) => {
7
6
  const { cacheOverride, includeUserRoles } = action.payload;
8
7
  const { billPaySetupApproverViewState, classListState } = state$.value;
9
8
  const { approverListState } = billPaySetupApproverViewState;
10
- const isAccountingClassesEnabled = getIsAccountingClassesEnabled(state$.value);
11
9
  const actions = [];
12
10
  if (cacheOverride === true) {
13
11
  actions.push(fetchBillPayApproversList(cacheOverride, includeUserRoles));
14
- if (isAccountingClassesEnabled) {
15
- actions.push(fetchClassList());
16
- }
12
+ actions.push(fetchClassList());
17
13
  }
18
14
  else {
19
15
  if (billPaySetupApproverViewState.hasValidState() === false &&
20
16
  approverListState.fetchStatus.fetchState !== 'In-Progress') {
21
17
  actions.push(fetchBillPayApproversList(true, includeUserRoles));
22
18
  }
23
- if (isAccountingClassesEnabled &&
24
- classListState.hasValidState() === false &&
19
+ if (classListState.hasValidState() === false &&
25
20
  classListState.fetchState !== 'In-Progress') {
26
21
  actions.push(fetchClassList());
27
22
  }
@@ -7,7 +7,6 @@ import { getCompanyByCompanyId } from '../../../../entity/company/companySelecto
7
7
  import { getDepositAccountByDepositAccountId } from '../../../../entity/depositAccount/depositAccountSelector';
8
8
  import { getPaymentAccountByPaymentAccountId, getPaymentAccountsByPaymentAccountIds, } from '../../../../entity/paymentAccount/paymentAccountSelector';
9
9
  import { getPaymentInstrumentById, getPaymentInstrumentsByIds, } from '../../../../entity/paymentInstrument/paymentInstrumentSelector';
10
- import { getIsAccountingClassesEnabled } from '../../../../entity/tenant/tenantSelector';
11
10
  import { getUserByUserId } from '../../../../entity/user/userSelector';
12
11
  import { getVendorByQboId, getVendorByVendorId, } from '../../../../entity/vendor/vendorSelector';
13
12
  import { dateNow } from '../../../../zeniDayJS';
@@ -173,15 +172,12 @@ export const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, i
173
172
  isCancelled = sourceBillDetail.billDetailLocalData.isCancelled;
174
173
  billStage = billPayInfo?.stage.code ?? 'draft';
175
174
  if (billViewState != null) {
176
- const fetchStateList = [
175
+ fetchState = reduceFetchState([
177
176
  sourceBillDetail.fetchStatus,
178
177
  accountListState.byReportId.billPayAccountList,
178
+ classListState,
179
179
  billPaySetupApproverViewState,
180
- ];
181
- if (getIsAccountingClassesEnabled(state)) {
182
- fetchStateList.push(classListState);
183
- }
184
- fetchState = reduceFetchState(fetchStateList).fetchState;
180
+ ]).fetchState;
185
181
  deleteStatus = billViewState.deleteStatus;
186
182
  billActivities = getBillActivities(state, billId, billPayInfo?.stage.code);
187
183
  }
@@ -195,14 +191,11 @@ export const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, i
195
191
  }
196
192
  }
197
193
  else {
198
- const newBillFetchStateList = [
194
+ fetchState = reduceFetchState([
199
195
  accountListState.byReportId.billPayAccountList,
196
+ classListState,
200
197
  billPaySetupApproverViewState,
201
- ];
202
- if (getIsAccountingClassesEnabled(state)) {
203
- newBillFetchStateList.push(classListState);
204
- }
205
- fetchState = reduceFetchState(newBillFetchStateList).fetchState;
198
+ ]).fetchState;
206
199
  }
207
200
  if (sourceBillDetail != null && fetchState == 'Completed') {
208
201
  const updatedRecord = sourceBillDetail.billDetailLocalData;
@@ -75,7 +75,6 @@ const ALL_CHARGE_CARD_SORT_KEYS = [
75
75
  'cardName',
76
76
  'department',
77
77
  'cardType',
78
- 'accountType',
79
78
  'status',
80
79
  'utilisation',
81
80
  'limit',
@@ -219,8 +219,6 @@ const getCardsBySortKey = (card, sortKey) => {
219
219
  return card.cardName.toLowerCase();
220
220
  case 'cardType':
221
221
  return card.type.code;
222
- case 'accountType':
223
- return card.type.code.includes('credit') ? 'credit' : 'debit';
224
222
  case 'status':
225
223
  return card.status.code;
226
224
  case 'utilisation':
@@ -2,7 +2,7 @@ import recordGet from 'lodash/get';
2
2
  import { reduceFetchState } from '../../../../commonStateTypes/reduceFetchState';
3
3
  import { getBankAccountByBankAccountId } from '../../../../entity/bankAccount/bankAccountSelector';
4
4
  import { getAllCurrencies } from '../../../../entity/currency/currencySelector';
5
- import { getCurrentTenant, getIsAccountingClassesEnabled, } from '../../../../entity/tenant/tenantSelector';
5
+ import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
6
6
  import { getUserByUserId } from '../../../../entity/user/userSelector';
7
7
  import { getAccountList, getNestedAccountListHierarchy, } from '../../../accountList/accountListSelector';
8
8
  import { getBankAccount, } from '../../../bankAccountView/bankAccountViewSelector';
@@ -63,16 +63,13 @@ export const getEditRemiDetail = (state, reimbursementId) => {
63
63
  paymentTo: reimbursementInfo?.toAccount.billAccountId,
64
64
  };
65
65
  if (sourceRemiDetail != null) {
66
- const fetchStateList = [
66
+ fetchState = reduceFetchState([
67
67
  sourceRemiDetail.fetchStatus,
68
68
  accountListState.byReportId.reimbursementAccountList,
69
+ classListState,
69
70
  merchantListState,
70
71
  reimbursementConfigState,
71
- ];
72
- if (getIsAccountingClassesEnabled(state)) {
73
- fetchStateList.push(classListState);
74
- }
75
- fetchState = reduceFetchState(fetchStateList).fetchState;
72
+ ]).fetchState;
76
73
  remiStage = reimbursementInfo?.stage.code ?? 'draft';
77
74
  createdBy = getUserByUserId(userState, reimbursement?.createdBy ?? '');
78
75
  createTime = reimbursement?.createTime;