@zeniai/client-epic-state 4.15.26 → 4.15.28

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 (124) hide show
  1. package/lib/commonStateTypes/timePeriod.d.ts +1 -1
  2. package/lib/commonStateTypes/timePeriod.js +2 -2
  3. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  4. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +1 -0
  5. package/lib/configureStore.js +2 -1
  6. package/lib/entity/account/accountState.d.ts +1 -1
  7. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  8. package/lib/entity/accountRecon/accountReconPayload.d.ts +70 -0
  9. package/lib/entity/accountRecon/accountReconPayload.js +125 -0
  10. package/lib/entity/accountRecon/accountReconReducer.d.ts +16 -0
  11. package/lib/entity/accountRecon/accountReconReducer.js +71 -0
  12. package/lib/entity/accountRecon/accountReconSelector.d.ts +28 -0
  13. package/lib/entity/accountRecon/accountReconSelector.js +44 -0
  14. package/lib/entity/accountRecon/accountReconState.d.ts +70 -0
  15. package/lib/entity/accountRecon/accountReconState.js +28 -0
  16. package/lib/entity/class/classReducer.d.ts +4 -4
  17. package/lib/entity/class/classState.d.ts +1 -1
  18. package/lib/entity/customer/customerPayload.d.ts +1 -1
  19. package/lib/entity/customer/customerPayload.js +16 -6
  20. package/lib/entity/forecast/forecastState.d.ts +1 -1
  21. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  22. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  23. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  24. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  25. package/lib/entity/snackbar/snackbarTypes.js +4 -0
  26. package/lib/entity/task/taskState.d.ts +1 -1
  27. package/lib/entity/tenant/clearAllEpic.d.ts +4 -2
  28. package/lib/entity/tenant/clearAllEpic.js +4 -0
  29. package/lib/entity/tenant/tenantReducer.d.ts +1 -1
  30. package/lib/entity/tenant/tenantReducer.js +7 -2
  31. package/lib/entity/transaction/payloadTypes/customerTransactionPayload.d.ts +1 -1
  32. package/lib/entity/transaction/payloadTypes/customerTransactionPayload.js +1 -2
  33. package/lib/entity/transaction/payloadTypes/reconciliationTransactionPayloads.d.ts +35 -0
  34. package/lib/entity/transaction/payloadTypes/reconciliationTransactionPayloads.js +53 -0
  35. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +2 -0
  36. package/lib/entity/transaction/payloadTypes/transactionPayload.js +7 -3
  37. package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.d.ts +9 -1
  38. package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.js +23 -2
  39. package/lib/entity/transaction/stateTypes/reconciliationTransaction.d.ts +32 -0
  40. package/lib/entity/transaction/stateTypes/reconciliationTransaction.js +10 -0
  41. package/lib/entity/transaction/stateTypes/transaction.d.ts +3 -1
  42. package/lib/entity/transaction/stateTypes/transactionType.d.ts +1 -1
  43. package/lib/entity/transaction/stateTypes/transactionType.js +1 -0
  44. package/lib/entity/transaction/stateTypes/vendorTransaction.d.ts +5 -0
  45. package/lib/entity/transaction/stateTypes/vendorTransaction.js +5 -1
  46. package/lib/entity/transaction/toSupportedTransaction.js +6 -1
  47. package/lib/entity/transaction/transactionReducer.d.ts +17 -0
  48. package/lib/entity/transaction/transactionReducer.js +47 -2
  49. package/lib/entity/transaction/transactionSelector.d.ts +2 -0
  50. package/lib/entity/transaction/transactionSelector.js +5 -0
  51. package/lib/entity/transaction/transactionState.d.ts +6 -4
  52. package/lib/entity/vendorExpense/vendorExpenseSelector.d.ts +2 -2
  53. package/lib/epic.d.ts +6 -1
  54. package/lib/epic.js +6 -1
  55. package/lib/index.d.ts +14 -6
  56. package/lib/index.js +52 -27
  57. package/lib/reducer.d.ts +7 -1
  58. package/lib/reducer.js +6 -0
  59. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  60. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  61. package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
  62. package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
  63. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  64. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  65. package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewReducer.d.ts +2 -2
  66. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  67. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.d.ts +15 -0
  68. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +118 -0
  69. package/lib/view/expenseAutomationView/epics/accountRecon/initialiseLocalDataForSelectedAccountIdEpic.d.ts +10 -0
  70. package/lib/view/expenseAutomationView/epics/accountRecon/initialiseLocalDataForSelectedAccountIdEpic.js +49 -0
  71. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationDetailEpic.d.ts +14 -0
  72. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationDetailEpic.js +169 -0
  73. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.d.ts +9 -0
  74. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +154 -0
  75. package/lib/view/expenseAutomationView/epics/accountRecon/updateReconcileTabLocalDataEpic.d.ts +6 -0
  76. package/lib/view/expenseAutomationView/epics/accountRecon/updateReconcileTabLocalDataEpic.js +110 -0
  77. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +2 -1
  78. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +24 -10
  79. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +2 -1
  80. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +14 -0
  81. package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +20 -4
  82. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.d.ts +2 -2
  83. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +17 -2
  84. package/lib/view/expenseAutomationView/expenseAutomationViewState.d.ts +2 -2
  85. package/lib/view/expenseAutomationView/expenseAutomationViewState.js +1 -1
  86. package/lib/view/expenseAutomationView/helpers/reconciliationHelpers.d.ts +7 -0
  87. package/lib/view/expenseAutomationView/helpers/reconciliationHelpers.js +18 -0
  88. package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +81 -30
  89. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  90. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +54 -10
  91. package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +28 -0
  92. package/lib/view/expenseAutomationView/payload/reconciliationPayload.js +51 -0
  93. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +66 -0
  94. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +384 -0
  95. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -1
  96. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +5 -4
  97. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +2 -0
  98. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.js +1 -1
  99. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.d.ts +51 -0
  100. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.js +7 -0
  101. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.d.ts +5 -0
  102. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +250 -0
  103. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +103 -0
  104. package/lib/view/expenseAutomationView/types/reconciliationViewState.js +38 -0
  105. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +8 -0
  106. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  107. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  108. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  109. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  110. package/lib/view/spendManagement/billPay/billsBulkActionView/epics/validateBillsBulkActionEpic.ts.js +4 -3
  111. package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.js +11 -3
  112. package/lib/view/spendManagement/plaidAccount/plaidAccountViewReducer.d.ts +2 -1
  113. package/lib/view/spendManagement/plaidAccount/plaidAccountViewReducer.js +3 -1
  114. package/lib/view/spendManagement/plaidAccount/plaidAccountViewState.d.ts +1 -1
  115. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  116. package/lib/view/topEx/topExSelector.d.ts +1 -1
  117. package/lib/view/transactionDetail/epics/saveTransactionHelper.js +13 -4
  118. package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +16 -3
  119. package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +22 -5
  120. package/lib/view/transactionDetail/transactionDetailState.d.ts +1 -0
  121. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +6 -0
  122. package/lib/view/vendorReviewView/vendorGlobalReviewView/vendorGlobalReviewViewState.d.ts +1 -1
  123. package/lib/zeniAPI.d.ts +1 -0
  124. package/package.json +2 -1
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateReconcileTabLocalDataEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const accountReconSelector_1 = require("../../../../entity/accountRecon/accountReconSelector");
7
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
+ const transactionSelector_1 = require("../../../../entity/transaction/transactionSelector");
9
+ const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
10
+ const updateReconcileTabLocalDataEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(reconciliationViewReducer_1.updateReconcileTabLocalData.match), (0, operators_1.mergeMap)((action) => {
11
+ var _a, _b;
12
+ const state = state$.value;
13
+ const { transactionState, expenseAutomationReconciliationViewState, expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
14
+ const { selectedAccountId } = expenseAutomationReconciliationViewState;
15
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
16
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
17
+ const actions = [];
18
+ const { selectedTransactionIds } = action.payload;
19
+ if (selectedAccountId != null) {
20
+ const transactions = [];
21
+ const reconEntity = (0, accountReconSelector_1.getAccountReconByAccountIdAndSelectedPeriod)(state, selectedAccountId, selectedPeriod);
22
+ if (reconEntity == null) {
23
+ return (0, rxjs_1.from)(actions);
24
+ }
25
+ const initialClearedBalance = (_a = reconEntity.initialClearedBalance) !== null && _a !== void 0 ? _a : {
26
+ amount: 0,
27
+ currencyCode: reconEntity.currency.currencyCode,
28
+ currencySymbol: reconEntity.currency.currencySymbol,
29
+ };
30
+ const bankBalance = (_b = reconEntity.balance) !== null && _b !== void 0 ? _b : {
31
+ amount: 0,
32
+ currencyCode: reconEntity.currency.currencyCode,
33
+ currencySymbol: reconEntity.currency.currencySymbol,
34
+ };
35
+ selectedTransactionIds.forEach((transactionId) => {
36
+ const transaction = (0, transactionSelector_1.getMatchedTransactionById)(transactionState, transactionId);
37
+ if (transaction != null) {
38
+ transactions.push(transaction);
39
+ }
40
+ });
41
+ const updatedClearedBalance = calculateUpdatedClearedBalance(transactions, initialClearedBalance);
42
+ const { variance, variancePercentage } = calculateVariance(updatedClearedBalance, bankBalance);
43
+ const currency = {
44
+ currencyCode: bankBalance.currencyCode,
45
+ currencySymbol: bankBalance.currencySymbol,
46
+ };
47
+ const depositsLocalData = calculateSplitAmounts(transactions, 'deposit', currency);
48
+ const paymentLocalData = calculateSplitAmounts(transactions, 'payment', currency);
49
+ actions.push((0, reconciliationViewReducer_1.updateBalancesLocalData)({
50
+ clearedBalance: updatedClearedBalance,
51
+ variance: variance,
52
+ variancePercentage: variancePercentage,
53
+ deposits: depositsLocalData,
54
+ payments: paymentLocalData,
55
+ }));
56
+ }
57
+ return (0, rxjs_1.from)(actions);
58
+ }));
59
+ exports.updateReconcileTabLocalDataEpic = updateReconcileTabLocalDataEpic;
60
+ function calculateUpdatedClearedBalance(transactions, initialClearedBalance) {
61
+ // Reduce the transactions to calculate the updated cleared balance
62
+ const updatedClearedBalance = transactions.reduce((updatedBalance, transaction) => {
63
+ if (transaction.transactionDirection === 'payment') {
64
+ return updatedBalance - transaction.amount.amount; // Deduct for debit
65
+ }
66
+ else if (transaction.transactionDirection === 'deposit') {
67
+ return updatedBalance + transaction.amount.amount; // Add for credit
68
+ }
69
+ return updatedBalance; // Return unchanged balance for other cases
70
+ }, initialClearedBalance.amount);
71
+ return {
72
+ amount: updatedClearedBalance,
73
+ currencyCode: initialClearedBalance.currencyCode,
74
+ currencySymbol: initialClearedBalance.currencySymbol,
75
+ };
76
+ }
77
+ function calculateSplitAmounts(transactions, transactionDirection, currency) {
78
+ if (transactions.length === 0) {
79
+ return {
80
+ count: 0,
81
+ totalAmount: Object.assign({ amount: 0 }, currency),
82
+ };
83
+ }
84
+ let count = 0;
85
+ let totalAmount = 0;
86
+ transactions.forEach((transaction) => {
87
+ if (transaction.transactionDirection === transactionDirection) {
88
+ count = count + 1;
89
+ totalAmount = totalAmount + transaction.amount.amount;
90
+ }
91
+ });
92
+ return {
93
+ count,
94
+ totalAmount: Object.assign({ amount: totalAmount }, currency),
95
+ };
96
+ }
97
+ function calculateVariance(updatedClearedBalance, bankBalance) {
98
+ const variance = Math.abs(bankBalance.amount - updatedClearedBalance.amount);
99
+ const variancePercent = bankBalance.amount != 0
100
+ ? parseFloat(((variance / bankBalance.amount) * 100).toFixed(2))
101
+ : 0;
102
+ return {
103
+ variance: {
104
+ amount: variance,
105
+ currencyCode: bankBalance.currencyCode,
106
+ currencySymbol: bankBalance.currencySymbol,
107
+ },
108
+ variancePercentage: variancePercent,
109
+ };
110
+ }
@@ -6,6 +6,7 @@ import { fetchAllExpenseAutomationTabs } from '../../expenseAutomationViewReduce
6
6
  import { fetchFluxAnalysisView } from '../../reducers/fluxAnalysisViewReducer';
7
7
  import { fetchJeSchedulesPage } from '../../reducers/jeSchedulesViewReducer';
8
8
  import { fetchMissingReceipts } from '../../reducers/missingReceiptsViewReducer';
9
+ import { fetchReconciliation } from '../../reducers/reconciliationViewReducer';
9
10
  import { fetchTransactionCategorizationView } from '../../reducers/transactionsViewReducer';
10
- export type ActionType = ReturnType<typeof fetchAllExpenseAutomationTabs> | ReturnType<typeof fetchMissingReceipts> | ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof fetchFluxAnalysisView> | ReturnType<typeof fetchJeSchedulesPage> | ReturnType<typeof fetchTransactionCategorizationView>;
11
+ export type ActionType = ReturnType<typeof fetchAllExpenseAutomationTabs> | ReturnType<typeof fetchMissingReceipts> | ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof fetchFluxAnalysisView> | ReturnType<typeof fetchJeSchedulesPage> | ReturnType<typeof fetchReconciliation> | ReturnType<typeof fetchTransactionCategorizationView>;
11
12
  export declare const fetchAllExpenseAutomationTabsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -9,10 +9,14 @@ const expenseAutomationViewReducer_1 = require("../../expenseAutomationViewReduc
9
9
  const fluxAnalysisViewReducer_1 = require("../../reducers/fluxAnalysisViewReducer");
10
10
  const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
11
11
  const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
12
+ const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
12
13
  const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
13
14
  const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(expenseAutomationViewReducer_1.fetchAllExpenseAutomationTabs.match), (0, operators_1.switchMap)((action) => {
15
+ var _a, _b;
14
16
  const { cacheOverride, refreshViewInBackground } = action.payload;
15
17
  const state = state$.value;
18
+ const { monthEndCloseChecksState } = state;
19
+ const { monthEndCloseChecksByTenantId } = monthEndCloseChecksState;
16
20
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
17
21
  const companyId = currentTenant.companyId;
18
22
  const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
@@ -21,22 +25,24 @@ const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0
21
25
  const timePeriodStart = (0, timePeriod_1.toAbsoluteDay)(period.start);
22
26
  const timePeriodEnd = (0, timePeriod_1.toAbsoluteDay)(period.end);
23
27
  const monthYearPeriodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
28
+ const monthEndCheckState = (_a = monthEndCloseChecksByTenantId === null || monthEndCloseChecksByTenantId === void 0 ? void 0 : monthEndCloseChecksByTenantId[currentTenant.tenantId]) === null || _a === void 0 ? void 0 : _a[monthYearPeriodId];
29
+ const reconciliationEnabled = (_b = monthEndCheckState === null || monthEndCheckState === void 0 ? void 0 : monthEndCheckState.monthEndCloseCheckList.some((list) => list.id === 'reconciliation')) !== null && _b !== void 0 ? _b : false;
24
30
  if (timePeriodStart == null ||
25
31
  timePeriodEnd == null ||
26
32
  companyId == null) {
27
33
  throw Error(`Invalid start - ${timePeriodStart} and end - ${timePeriodEnd} period from given ${selectedPeriod}`);
28
34
  }
29
35
  if (cacheOverride === true) {
30
- return (0, rxjs_1.from)([
31
- (0, transactionsViewReducer_1.fetchTransactionCategorizationView)(selectedTransactionCategorizationTab, { start: timePeriodStart, end: timePeriodEnd }, cacheOverride, false, undefined, undefined, refreshViewInBackground),
32
- (0, missingReceiptsViewReducer_1.fetchMissingReceipts)({ start: timePeriodStart, end: timePeriodEnd }, {
33
- amount: 75.0,
34
- currencyCode: 'USD',
35
- currencySymbol: '$',
36
- }, cacheOverride, refreshViewInBackground),
37
- (0, fluxAnalysisViewReducer_1.fetchFluxAnalysisView)(selectedPeriod, cacheOverride, refreshViewInBackground, null),
38
- (0, jeSchedulesViewReducer_1.fetchJeSchedulesPage)({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride),
39
- ]);
36
+ const actions = [];
37
+ actions.push((0, transactionsViewReducer_1.fetchTransactionCategorizationView)(selectedTransactionCategorizationTab, { start: timePeriodStart, end: timePeriodEnd }, cacheOverride, false, undefined, undefined, refreshViewInBackground), (0, missingReceiptsViewReducer_1.fetchMissingReceipts)({ start: timePeriodStart, end: timePeriodEnd }, {
38
+ amount: 75.0,
39
+ currencyCode: 'USD',
40
+ currencySymbol: '$',
41
+ }, cacheOverride, refreshViewInBackground), (0, fluxAnalysisViewReducer_1.fetchFluxAnalysisView)(selectedPeriod, cacheOverride, refreshViewInBackground, null), (0, jeSchedulesViewReducer_1.fetchJeSchedulesPage)({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
42
+ if (reconciliationEnabled) {
43
+ actions.push((0, reconciliationViewReducer_1.fetchReconciliation)(selectedPeriod, undefined, cacheOverride, refreshViewInBackground));
44
+ }
45
+ return (0, rxjs_1.from)(actions);
40
46
  }
41
47
  else {
42
48
  const fetchActions = [];
@@ -68,6 +74,14 @@ const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0
68
74
  null)) {
69
75
  fetchActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedulesPage)({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
70
76
  }
77
+ if (state.expenseAutomationReconciliationViewState.fetchState !==
78
+ 'In-Progress' &&
79
+ state.expenseAutomationReconciliationViewState
80
+ .accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId] ==
81
+ null &&
82
+ reconciliationEnabled) {
83
+ fetchActions.push((0, reconciliationViewReducer_1.fetchReconciliation)(selectedPeriod, undefined, cacheOverride, refreshViewInBackground));
84
+ }
71
85
  if (state.expenseAutomationTransactionsViewState
72
86
  .transactionCategorizationView[selectedTransactionCategorizationTab]
73
87
  .fetchState !== 'In-Progress' &&
@@ -7,6 +7,7 @@ import { refreshExpenseAutomationCurrentTab } from '../../expenseAutomationViewR
7
7
  import { fetchFluxAnalysisView } from '../../reducers/fluxAnalysisViewReducer';
8
8
  import { fetchJeSchedulesPage } from '../../reducers/jeSchedulesViewReducer';
9
9
  import { fetchMissingReceipts } from '../../reducers/missingReceiptsViewReducer';
10
+ import { fetchReconciliation } from '../../reducers/reconciliationViewReducer';
10
11
  import { fetchTransactionCategorizationView } from '../../reducers/transactionsViewReducer';
11
- export type ActionType = ReturnType<typeof refreshExpenseAutomationCurrentTab> | ReturnType<typeof fetchCompanyMonthEndReportView> | ReturnType<typeof fetchCompanyMonthEndReportTemplates> | ReturnType<typeof fetchMissingReceipts> | ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof fetchFluxAnalysisView> | ReturnType<typeof fetchJeSchedulesPage> | ReturnType<typeof fetchTransactionCategorizationView>;
12
+ export type ActionType = ReturnType<typeof refreshExpenseAutomationCurrentTab> | ReturnType<typeof fetchCompanyMonthEndReportView> | ReturnType<typeof fetchCompanyMonthEndReportTemplates> | ReturnType<typeof fetchMissingReceipts> | ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof fetchFluxAnalysisView> | ReturnType<typeof fetchReconciliation> | ReturnType<typeof fetchJeSchedulesPage> | ReturnType<typeof fetchTransactionCategorizationView>;
12
13
  export declare const refreshExpenseAutomationCurrentTabEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -10,6 +10,7 @@ const expenseAutomationViewReducer_1 = require("../../expenseAutomationViewReduc
10
10
  const fluxAnalysisViewReducer_1 = require("../../reducers/fluxAnalysisViewReducer");
11
11
  const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
12
12
  const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
13
+ const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
13
14
  const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
14
15
  const refreshExpenseAutomationCurrentTabEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(expenseAutomationViewReducer_1.refreshExpenseAutomationCurrentTab.match), (0, operators_1.switchMap)(() => {
15
16
  const state = state$.value;
@@ -18,6 +19,7 @@ const refreshExpenseAutomationCurrentTabEpic = (actions$, state$) => actions$.pi
18
19
  const { selectedTransactionCategorizationTab } = state.expenseAutomationTransactionsViewState;
19
20
  const { selectedPeriodByTenantId, currentSelectedView } = state.expenseAutomationViewState;
20
21
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
22
+ const { selectedAccountId } = state.expenseAutomationReconciliationViewState;
21
23
  const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
22
24
  const timePeriodStart = (0, timePeriod_1.toAbsoluteDay)(period.start);
23
25
  const timePeriodEnd = (0, timePeriod_1.toAbsoluteDay)(period.end);
@@ -48,6 +50,18 @@ const refreshExpenseAutomationCurrentTabEpic = (actions$, state$) => actions$.pi
48
50
  (0, companyMonthEndReportViewReducer_1.fetchCompanyMonthEndReportView)(true, companyId, currentTenant.tenantId),
49
51
  (0, companyMonthEndReportViewReducer_1.fetchCompanyMonthEndReportTemplates)(companyId, currentTenant.tenantId),
50
52
  ]);
53
+ case 'reconciliation': {
54
+ if (selectedAccountId != null) {
55
+ return (0, rxjs_1.from)([
56
+ (0, reconciliationViewReducer_1.fetchReconciliation)(selectedPeriod, selectedAccountId, true, true),
57
+ ]);
58
+ }
59
+ else {
60
+ return (0, rxjs_1.from)([
61
+ (0, reconciliationViewReducer_1.fetchReconciliation)(selectedPeriod, undefined, true, true),
62
+ ]);
63
+ }
64
+ }
51
65
  case 'transaction_categorization':
52
66
  default:
53
67
  return (0, rxjs_1.from)([
@@ -40,11 +40,12 @@ const updateTransactionCategorizationEpic = (actions$, state$, zeniAPI) => actio
40
40
  }));
41
41
  exports.updateTransactionCategorizationEpic = updateTransactionCategorizationEpic;
42
42
  function prepareTransactionPayload(selectedTab, transactionState, vendorState, transactionsViewState, transactionId, saveUpdates) {
43
- var _a;
43
+ var _a, _b;
44
44
  const detail = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, transactionId);
45
45
  const tranDetail = (0, get_1.default)(transactionsViewState.transactionCategorizationView[selectedTab]
46
46
  .transactionReviewLocalDataById, transactionId, undefined);
47
47
  const tranVendorUpdates = (_a = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionReviewLocalData) === null || _a === void 0 ? void 0 : _a.vendorUpdates;
48
+ const tranCustomerUpdates = (_b = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionReviewLocalData) === null || _b === void 0 ? void 0 : _b.customerUpdates;
48
49
  let vendorUpdates = undefined;
49
50
  if ((tranVendorUpdates === null || tranVendorUpdates === void 0 ? void 0 : tranVendorUpdates.qboId) != null) {
50
51
  const vendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, tranVendorUpdates.qboId);
@@ -61,8 +62,15 @@ function prepareTransactionPayload(selectedTab, transactionState, vendorState, t
61
62
  };
62
63
  }
63
64
  }
65
+ let customerUpdates = undefined;
66
+ if ((tranCustomerUpdates === null || tranCustomerUpdates === void 0 ? void 0 : tranCustomerUpdates.qboId) != null) {
67
+ customerUpdates = {
68
+ id: tranCustomerUpdates.qboId,
69
+ name: tranCustomerUpdates.name,
70
+ };
71
+ }
64
72
  if (detail != null) {
65
- const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates);
73
+ const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates, customerUpdates);
66
74
  const entityUpdates = toEntityUpdatePayload(saveUpdates.entityRelatedUpdates);
67
75
  return {
68
76
  entity_related_updates: entityUpdates,
@@ -91,12 +99,14 @@ function preparePayload(selectedTab, transactionState, vendorState, transactions
91
99
  return payload;
92
100
  }
93
101
  }
94
- const toTransactionUpdatePayload = (updates, detail, vendorUpdates) => {
102
+ const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpdates) => {
95
103
  var _a, _b;
96
104
  const transaction = Object.assign({}, detail);
97
105
  transaction.memo = (_a = updates.memo) !== null && _a !== void 0 ? _a : '';
98
106
  transaction.vendorId = vendorUpdates === null || vendorUpdates === void 0 ? void 0 : vendorUpdates.id;
99
107
  transaction.vendorName = vendorUpdates === null || vendorUpdates === void 0 ? void 0 : vendorUpdates.name;
108
+ transaction.customerId = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.id;
109
+ transaction.customerName = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.name;
100
110
  const recommendationUpdates = {};
101
111
  for (const key in updates.updatesByLineId) {
102
112
  const lineUpdates = updates.updatesByLineId[key];
@@ -133,11 +143,17 @@ const toTransactionUpdatePayload = (updates, detail, vendorUpdates) => {
133
143
  transaction.lines = newLineMap;
134
144
  }
135
145
  transaction.recommendations = recommendationUpdates;
146
+ // Added this check because now customer are also part of Expense,Journal Entry and Check type of transactions
136
147
  if ((0, customerTransaction_1.isCustomerTransaction)(transaction)) {
137
148
  return (0, customerTransactionPayload_1.toCustomerTransactionPayload)(transaction);
138
149
  }
139
150
  else if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
140
- return (0, vendorTransactionPayload_1.toVendorTransactionPayload)(transaction, vendorUpdates);
151
+ if ((0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction)) {
152
+ return (0, vendorTransactionPayload_1.toVendorTransactionWithCustomerPayload)(transaction, vendorUpdates, customerUpdates);
153
+ }
154
+ else {
155
+ return (0, vendorTransactionPayload_1.toVendorTransactionPayload)(transaction, vendorUpdates);
156
+ }
141
157
  }
142
158
  else if ((0, otherTransaction_1.isTransferTransaction)(transaction)) {
143
159
  return (0, otherTransactionPayload_1.toTransferTransactionPayload)(transaction);
@@ -8,8 +8,8 @@ export declare const fetchAllExpenseAutomationTabs: import("@reduxjs/toolkit").A
8
8
  }, "expenseAutomationView/fetchAllExpenseAutomationTabs", never, never>, updateCurrentSelectedPeriod: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, newSelectedPeriod: MonthYearPeriod], {
9
9
  newSelectedPeriod: MonthYearPeriod;
10
10
  tenantId: string;
11
- }, "expenseAutomationView/updateCurrentSelectedPeriod", never, never>, updateCurrentSelectedView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[newSelectedView: "transaction_categorization" | "je_schedules" | "account_recon" | "missing_receipts" | "flux_analysis" | "month_end_insights"], {
12
- newSelectedView: "transaction_categorization" | "je_schedules" | "account_recon" | "missing_receipts" | "flux_analysis" | "month_end_insights";
11
+ }, "expenseAutomationView/updateCurrentSelectedPeriod", never, never>, updateCurrentSelectedView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[newSelectedView: "transaction_categorization" | "je_schedules" | "reconciliation" | "missing_receipts" | "flux_analysis" | "month_end_insights"], {
12
+ newSelectedView: "transaction_categorization" | "je_schedules" | "reconciliation" | "missing_receipts" | "flux_analysis" | "month_end_insights";
13
13
  }, "expenseAutomationView/updateCurrentSelectedView", never, never>, clearExpenseAutomationView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationView/clearExpenseAutomationView">, initializeSelectedPeriodForTenants: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
14
14
  selectedPeriodByTenantId: Record<ID, MonthYearPeriod>;
15
15
  }, "expenseAutomationView/initializeSelectedPeriodForTenants">, refreshExpenseAutomationCurrentTab: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationView/refreshExpenseAutomationCurrentTab">;
@@ -11,6 +11,7 @@ const expenseAutomationViewSelectorTypes_1 = require("./selectorTypes/expenseAut
11
11
  const fluxAnalysisViewSelector_1 = require("./selectors/fluxAnalysisViewSelector");
12
12
  const jeSchedulesViewSelector_1 = require("./selectors/jeSchedulesViewSelector");
13
13
  const missingReceiptsSelector_1 = require("./selectors/missingReceiptsSelector");
14
+ const reconciliationViewSelector_1 = require("./selectors/reconciliationViewSelector");
14
15
  const transactionCategorizationSelector_1 = require("./selectors/transactionCategorizationSelector");
15
16
  const isPreviousStepDisabled = (selectedTransactionCategorizationTab, allSteps, stepIndex, currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, reportEmailSentDate, auditSummary) => {
16
17
  if (stepIndex === 0) {
@@ -24,7 +25,7 @@ const isPreviousStepDisabled = (selectedTransactionCategorizationTab, allSteps,
24
25
  };
25
26
  function getExpenseAutomationView(state) {
26
27
  var _a, _b, _c;
27
- const { expenseAutomationViewState, tenantState, expenseAutomationMissingReceiptsViewState, expenseAutomationJESchedulesViewState, expenseAutomationTransactionsViewState, monthEndCloseChecksState, companyState, } = state;
28
+ const { expenseAutomationViewState, tenantState, expenseAutomationMissingReceiptsViewState, expenseAutomationJESchedulesViewState, expenseAutomationTransactionsViewState, expenseAutomationReconciliationViewState, monthEndCloseChecksState, companyState, } = state;
28
29
  const { loggedInUser, currentTenantId } = tenantState;
29
30
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
30
31
  const { currentSelectedView, selectedPeriodByTenantId } = expenseAutomationViewState;
@@ -42,9 +43,15 @@ function getExpenseAutomationView(state) {
42
43
  const missingReceipts = (0, missingReceiptsSelector_1.getExpenseAutomationMissingReceiptsView)(state);
43
44
  const fluxAnalysis = (0, fluxAnalysisViewSelector_1.getExpenseAutomationFluxAnalysisView)(state);
44
45
  const monthEndInsights = (0, companyMonthEndReportViewSelector_1.getCompanyMonthEndReportSelectorView)(state, currentTenant.companyId, loggedInUser);
46
+ const reconciliation = (0, reconciliationViewSelector_1.getExpenseAutomationReconciliationView)(state);
45
47
  const expenseAutomationTransactionsView = (0, transactionCategorizationSelector_1.getExpenseAutomationTransactionView)(state);
46
48
  const jeSchedules = (0, jeSchedulesViewSelector_1.getExpenseAutomationJESchedulesView)(state);
47
49
  switch (currentSelectedView) {
50
+ case 'reconciliation':
51
+ currentSelectedViewFetchState = reconciliation.fetchStatus;
52
+ currentSelectedViewBackgroundRefreshFetchState =
53
+ reconciliation.refreshStatus;
54
+ break;
48
55
  case 'flux_analysis':
49
56
  currentSelectedViewFetchState = fluxAnalysis.fetchStatus;
50
57
  currentSelectedViewBackgroundRefreshFetchState =
@@ -90,6 +97,7 @@ function getExpenseAutomationView(state) {
90
97
  expenseAutomationJESchedulesViewState,
91
98
  monthEndCloseChecksView,
92
99
  expenseAutomationTransactionsView,
100
+ expenseAutomationReconciliationViewState,
93
101
  ];
94
102
  let allSteps = [];
95
103
  let auditSummary = undefined;
@@ -122,6 +130,9 @@ function getExpenseAutomationView(state) {
122
130
  ? (0, monthEndCloseChecksViewSelector_1.isMonthEndInsightDisabled)(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, auditSummary)
123
131
  : true });
124
132
  return;
133
+ case 'reconciliation':
134
+ allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { completionStatus: reconciliation.completionStatus });
135
+ return;
125
136
  case 'flux_analysis':
126
137
  default:
127
138
  allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { completionStatus: fluxAnalysis.completionStatus });
@@ -131,7 +142,10 @@ function getExpenseAutomationView(state) {
131
142
  allSteps.forEach((stepDetail, index, allStepsOriginal) => {
132
143
  allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { isNextDisabled: index === allStepsOriginal.length - 1
133
144
  ? allStepsOriginal[0].isDisabled
134
- : allStepsOriginal[index + 1].isDisabled, isPrevDisabled: isPreviousStepDisabled(selectedTransactionCategorizationTab, allStepsOriginal, index, currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, reportEmailSentDate, auditSummary) });
145
+ : stepDetail.step === 'reconciliation' &&
146
+ reconciliation.selectedTab === 'review'
147
+ ? false
148
+ : allStepsOriginal[index + 1].isDisabled, isPrevDisabled: isPreviousStepDisabled(selectedTransactionCategorizationTab, allStepsOriginal, index, currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, reportEmailSentDate, auditSummary) });
135
149
  });
136
150
  }
137
151
  const reducedFetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)(fetchStateVariables); // Add more states
@@ -146,6 +160,7 @@ function getExpenseAutomationView(state) {
146
160
  jeSchedules,
147
161
  transactionView: expenseAutomationTransactionsView,
148
162
  missingReceipts,
163
+ reconciliation,
149
164
  currentSelectedViewFetchState,
150
165
  currentSelectedViewBackgroundRefreshFetchState,
151
166
  fluxAnalysis,
@@ -1,7 +1,7 @@
1
1
  import { FetchStateAndError, FetchedState, ID } from '../../commonStateTypes/common';
2
2
  import { MonthYearPeriod } from '../../commonStateTypes/timePeriod';
3
- export declare const EXPENSE_AUTOMATION_VIEW_TYPES: readonly ["transaction_categorization", "je_schedules", "account_recon", "missing_receipts", "flux_analysis", "month_end_insights"];
4
- export declare const toExpenseAutomationViewType: (v: string) => "transaction_categorization" | "je_schedules" | "account_recon" | "missing_receipts" | "flux_analysis" | "month_end_insights";
3
+ export declare const EXPENSE_AUTOMATION_VIEW_TYPES: readonly ["transaction_categorization", "je_schedules", "reconciliation", "missing_receipts", "flux_analysis", "month_end_insights"];
4
+ export declare const toExpenseAutomationViewType: (v: string) => "transaction_categorization" | "je_schedules" | "reconciliation" | "missing_receipts" | "flux_analysis" | "month_end_insights";
5
5
  export type ExpenseAutomationViewType = ReturnType<typeof toExpenseAutomationViewType>;
6
6
  export interface ExpenseAutomationViewState extends FetchedState {
7
7
  saveStatus: FetchStateAndError;
@@ -5,7 +5,7 @@ const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
5
  exports.EXPENSE_AUTOMATION_VIEW_TYPES = [
6
6
  'transaction_categorization',
7
7
  'je_schedules',
8
- 'account_recon', // Not part of scope in v1
8
+ 'reconciliation',
9
9
  'missing_receipts',
10
10
  'flux_analysis',
11
11
  'month_end_insights',
@@ -0,0 +1,7 @@
1
+ import { CurrencyPayload } from '../../../commonPayloadTypes/v2/viewAndReportPayloadv2';
2
+ import { ReconciliationDataPayload } from '../../../entity/accountRecon/accountReconPayload';
3
+ import { MatchedTransactionPayload } from '../../../entity/transaction/payloadTypes/reconciliationTransactionPayloads';
4
+ export declare const getAllReviewTransactionsFromReconcilePayload: (reconcilePayload: ReconciliationDataPayload[]) => {
5
+ allReconciledTransactions: MatchedTransactionPayload[];
6
+ currencyPayload: CurrencyPayload;
7
+ }[];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllReviewTransactionsFromReconcilePayload = void 0;
4
+ const getAllReviewTransactionsFromReconcilePayload = (reconcilePayload) => {
5
+ const transactionsPerRecon = reconcilePayload.map((reconcile) => {
6
+ const allReconciledTransactions = [];
7
+ const currencyPayload = reconcile.currency;
8
+ reconcile.transactions.reconcile.forEach((reconciledTransaction) => {
9
+ allReconciledTransactions.push(reconciledTransaction);
10
+ });
11
+ return {
12
+ allReconciledTransactions,
13
+ currencyPayload,
14
+ };
15
+ });
16
+ return transactionsPerRecon;
17
+ };
18
+ exports.getAllReviewTransactionsFromReconcilePayload = getAllReviewTransactionsFromReconcilePayload;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toTransactionUpdatesFromTransactionCategorizationLocalData = void 0;
4
4
  const entity_1 = require("../../../entity/genericEntity/entity");
5
+ const customerTransaction_1 = require("../../../entity/transaction/stateTypes/customerTransaction");
5
6
  const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
6
7
  const recommendationState_1 = require("../../recommendation/recommendationState");
7
8
  const saveTransactionHelper_1 = require("../../transactionDetail/epics/saveTransactionHelper");
@@ -10,7 +11,7 @@ const saveTransactionHelper_1 = require("../../transactionDetail/epics/saveTrans
10
11
  * @param transactionCategorizationLocalData
11
12
  */
12
13
  const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionCategorizationLocalData, transaction, uncategorizedIncomeExpense) => {
13
- var _a, _b, _c;
14
+ var _a, _b;
14
15
  const updates = {
15
16
  updatesByLineId: {},
16
17
  };
@@ -22,22 +23,18 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
22
23
  if ((0, vendorTransaction_1.isVendorTransaction)(transaction) === true) {
23
24
  updates.vendorId = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.id;
24
25
  }
25
- const entity = transaction.vendorId != null
26
- ? {
27
- id: transaction.vendorId,
28
- name: (_b = transaction.vendorName) !== null && _b !== void 0 ? _b : '',
29
- type: (0, entity_1.toEntityType)('vendor'),
30
- qboId: transaction.vendorId,
31
- zeniId: transaction.vendorId,
32
- }
33
- : undefined;
26
+ // This needs to be changed to customerUpdates as of now we are not updating customerId so we are using the one from the transaction
27
+ if ((0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction) === true) {
28
+ updates.customerId = transaction.customerId;
29
+ }
30
+ const entity = getEntityFromTransaction(transaction);
34
31
  let lastUpdatedCategory;
35
32
  let lastUpdatedClass;
36
33
  // single recommendation to just pick the last recommendation in the list of lines
37
- (_c = transaction.lines) === null || _c === void 0 ? void 0 : _c.forEach((line) => {
38
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
39
- const updatedEntityId = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.qboId;
40
- const entityDetails = getEntityDetails(entity, transactionCategorizationLocalData.lineItemById[line.id], transactionCategorizationLocalData.vendorUpdates);
34
+ (_b = transaction.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => {
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
36
+ const updatedEntityId = (_b = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.qboId) !== null && _b !== void 0 ? _b : (_c = transactionCategorizationLocalData.customerUpdates) === null || _c === void 0 ? void 0 : _c.qboId;
37
+ const entityDetails = getEntityDetails(entity, transactionCategorizationLocalData.lineItemById[line.id], transactionCategorizationLocalData.vendorUpdates, transactionCategorizationLocalData.customerUpdates);
41
38
  if (line.type === 'transaction_with_account_and_class_line' ||
42
39
  line.type === 'transaction_with_product_or_service_line' ||
43
40
  line.type === 'journal_entry_transaction_line') {
@@ -50,24 +47,28 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
50
47
  };
51
48
  if (line.type === 'journal_entry_transaction_line' ||
52
49
  line.platformLineDetailType === 'deposit_line_detail') {
53
- updatesByLineId[line.id] = Object.assign(Object.assign({}, updatesByLineId[line.id]), { vendor: lineItem.vendor });
50
+ updatesByLineId[line.id] = Object.assign(Object.assign({}, updatesByLineId[line.id]), { vendor: lineItem.vendor, customer: lineItem.customer });
54
51
  }
55
52
  let hasCategoryChanged = false;
56
53
  let hasClassChanged = false;
57
54
  const accountLine = line;
58
55
  hasCategoryChanged =
59
- ((_b = lineItem.account) === null || _b === void 0 ? void 0 : _b.qboId) !== accountLine.account.qboId &&
60
- Boolean((_c = lineItem.account) === null || _c === void 0 ? void 0 : _c.qboId);
56
+ ((_d = lineItem.account) === null || _d === void 0 ? void 0 : _d.qboId) !== accountLine.account.qboId &&
57
+ Boolean((_e = lineItem.account) === null || _e === void 0 ? void 0 : _e.qboId);
61
58
  hasClassChanged =
62
- Boolean((_d = lineItem.class) === null || _d === void 0 ? void 0 : _d.qboId) &&
63
- ((_e = lineItem.class) === null || _e === void 0 ? void 0 : _e.qboId) !== accountLine.class.qboId;
59
+ Boolean((_f = lineItem.class) === null || _f === void 0 ? void 0 : _f.qboId) &&
60
+ ((_g = lineItem.class) === null || _g === void 0 ? void 0 : _g.qboId) !== accountLine.class.qboId;
64
61
  const recommendedAccountBase = (0, saveTransactionHelper_1.toRecommendedAccountBase)(lineItem.amount.amount, lineItem.account);
65
62
  const recommendedClassBase = (0, saveTransactionHelper_1.toRecommendedClassBase)(lineItem.amount.amount, lineItem.class);
66
- const updatedLineEntityId = ((_f = accountLine.vendor) === null || _f === void 0 ? void 0 : _f.id) != null
67
- ? ((_g = accountLine.vendor) === null || _g === void 0 ? void 0 : _g.id) != ((_h = lineItem.vendor) === null || _h === void 0 ? void 0 : _h.id)
68
- ? (_j = lineItem.vendor) === null || _j === void 0 ? void 0 : _j.id
69
- : (_k = accountLine.vendor) === null || _k === void 0 ? void 0 : _k.id
70
- : undefined;
63
+ const updatedLineEntityId = ((_h = accountLine.vendor) === null || _h === void 0 ? void 0 : _h.id) != null
64
+ ? ((_j = accountLine.vendor) === null || _j === void 0 ? void 0 : _j.id) != ((_k = lineItem.vendor) === null || _k === void 0 ? void 0 : _k.id)
65
+ ? (_l = lineItem.vendor) === null || _l === void 0 ? void 0 : _l.id
66
+ : (_m = accountLine.vendor) === null || _m === void 0 ? void 0 : _m.id
67
+ : ((_o = accountLine.customer) === null || _o === void 0 ? void 0 : _o.id) != null
68
+ ? ((_p = accountLine.customer) === null || _p === void 0 ? void 0 : _p.id) != ((_q = lineItem.customer) === null || _q === void 0 ? void 0 : _q.id)
69
+ ? (_r = lineItem.customer) === null || _r === void 0 ? void 0 : _r.id
70
+ : (_s = accountLine.customer) === null || _s === void 0 ? void 0 : _s.id
71
+ : undefined;
71
72
  if (entityDetails != null &&
72
73
  (hasCategoryChanged === true || hasClassChanged === true)) {
73
74
  lastUpdatedCategory =
@@ -83,16 +84,16 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
83
84
  if (recommended.class != null ||
84
85
  recommended.account != null ||
85
86
  updatedEntityId != null) {
86
- const vendorIdToUpdate = (_l = transactionCategorizationLocalData.vendorUpdates) === null || _l === void 0 ? void 0 : _l.qboId;
87
- let entityId = entityDetails.entityId;
87
+ const vendorIdToUpdate = (_t = transactionCategorizationLocalData.vendorUpdates) === null || _t === void 0 ? void 0 : _t.qboId;
88
88
  if (line.type === 'journal_entry_transaction_line' ||
89
89
  line.platformLineDetailType === 'deposit_line_detail') {
90
- const entityId = (_m = accountLine.vendor) === null || _m === void 0 ? void 0 : _m.id;
90
+ const entityId = (_v = (_u = accountLine.vendor) === null || _u === void 0 ? void 0 : _u.id) !== null && _v !== void 0 ? _v : (_w = accountLine.customer) === null || _w === void 0 ? void 0 : _w.id;
91
91
  if (entityId != null) {
92
92
  doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, false, updatedLineEntityId);
93
93
  }
94
94
  }
95
95
  else {
96
+ let entityId = entityDetails.entityId;
96
97
  if (vendorIdToUpdate != null) {
97
98
  entityId = vendorIdToUpdate;
98
99
  }
@@ -135,8 +136,8 @@ const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendati
135
136
  entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), { recommendations: recommendation });
136
137
  }
137
138
  };
138
- const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
139
- var _a, _b, _c;
139
+ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpdates) => {
140
+ var _a, _b, _c, _d;
140
141
  if (entity != null) {
141
142
  return {
142
143
  entityId: (_a = entity.qboId) !== null && _a !== void 0 ? _a : entity.id,
@@ -155,7 +156,19 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
155
156
  entityType: 'vendor',
156
157
  };
157
158
  }
158
- if (((_c = lineItemLocalData.vendor) === null || _c === void 0 ? void 0 : _c.id) != null) {
159
+ if (customerUpdates != null && customerUpdates.id != null) {
160
+ return {
161
+ entityId: customerUpdates.id,
162
+ entityType: 'customer',
163
+ };
164
+ }
165
+ if (((_c = lineItemLocalData.customer) === null || _c === void 0 ? void 0 : _c.id) != null) {
166
+ return {
167
+ entityId: lineItemLocalData.customer.id,
168
+ entityType: 'customer',
169
+ };
170
+ }
171
+ if (((_d = lineItemLocalData.vendor) === null || _d === void 0 ? void 0 : _d.id) != null) {
159
172
  return {
160
173
  entityId: lineItemLocalData.vendor.id,
161
174
  entityType: 'vendor',
@@ -163,3 +176,41 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
163
176
  }
164
177
  return undefined;
165
178
  };
179
+ const getEntityFromTransaction = (transaction) => {
180
+ if ((0, vendorTransaction_1.isVendorTransaction)(transaction) ||
181
+ (0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction)) {
182
+ const vendor = transaction.vendor;
183
+ const customer = transaction.customer;
184
+ if (customer != null) {
185
+ return {
186
+ id: customer.id,
187
+ name: customer.name,
188
+ type: (0, entity_1.toEntityType)('customer'),
189
+ qboId: customer.id,
190
+ zeniId: customer.id,
191
+ };
192
+ }
193
+ if (vendor != null) {
194
+ return {
195
+ id: vendor.id,
196
+ name: vendor.name,
197
+ type: (0, entity_1.toEntityType)('vendor'),
198
+ qboId: vendor.id,
199
+ zeniId: vendor.id,
200
+ };
201
+ }
202
+ }
203
+ if ((0, customerTransaction_1.isCustomerTransaction)(transaction)) {
204
+ const customer = transaction.customer;
205
+ if (customer) {
206
+ return {
207
+ id: customer.id,
208
+ name: customer.name,
209
+ type: (0, entity_1.toEntityType)('customer'),
210
+ qboId: customer.id,
211
+ zeniId: customer.id,
212
+ };
213
+ }
214
+ }
215
+ return undefined;
216
+ };
@@ -8,6 +8,6 @@ import { UncategorizedAccounts } from '../../accountList/accountListSelector';
8
8
  import { TransactionReviewLocalData, TransactionsTabViewState } from '../types/transactionsViewState';
9
9
  export declare const MAX_SELECTION_LIMIT = 5;
10
10
  export declare const toTransactionDetailLocalData: (transaction: SupportedTransaction) => TransactionReviewLocalData;
11
- export declare const toSetAllLineItemsToCategoryClass: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionId: ID, transactionLineId: ID, transactionDetailLocalData: TransactionReviewLocalData, updatedItem: "category" | "class", uncategorizedAccounts: UncategorizedAccounts, vendorId?: ID, selectedAccount?: AccountBase, selectedClassBase?: ClassBase) => TransactionReviewLocalData;
11
+ export declare const toSetAllLineItemsToCategoryClass: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionId: ID, transactionLineId: ID, transactionDetailLocalData: TransactionReviewLocalData, updatedItem: "category" | "class", uncategorizedAccounts: UncategorizedAccounts, vendorId?: ID, customerId?: ID, selectedAccount?: AccountBase, selectedClassBase?: ClassBase) => TransactionReviewLocalData;
12
12
  export declare const setEntityRecommendationForLineIdInLocalData: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionDetailLocalData: TransactionReviewLocalData, entity: Entity, recommendationLineIds: ID[], uncategorizedAccounts: UncategorizedAccounts, recommendationByLineId?: RecommendationByLineId) => TransactionReviewLocalData;
13
13
  export declare const checkIfAllLineItemsAreCategoryClassFilled: (transaction: SupportedTransaction, transactionDetailLocalData: TransactionReviewLocalData, uncategorizedAccounts: UncategorizedAccounts) => boolean;