@zeniai/client-epic-state 4.15.34 → 4.15.36

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 (191) hide show
  1. package/lib/commonPayloadTypes/recommendationPayload.d.ts +1 -0
  2. package/lib/commonStateTypes/timePeriod.d.ts +1 -1
  3. package/lib/commonStateTypes/timePeriod.js +2 -2
  4. package/lib/commonStateTypes/viewAndReport/agingReportStateTypes.js +1 -1
  5. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  6. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +1 -0
  7. package/lib/configureStore.js +2 -1
  8. package/lib/entity/account/accountState.d.ts +1 -1
  9. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  10. package/lib/entity/accountRecon/accountReconPayload.d.ts +70 -0
  11. package/lib/entity/accountRecon/accountReconPayload.js +125 -0
  12. package/lib/entity/accountRecon/accountReconReducer.d.ts +16 -0
  13. package/lib/entity/accountRecon/accountReconReducer.js +71 -0
  14. package/lib/entity/accountRecon/accountReconSelector.d.ts +28 -0
  15. package/lib/entity/accountRecon/accountReconSelector.js +44 -0
  16. package/lib/entity/accountRecon/accountReconState.d.ts +70 -0
  17. package/lib/entity/accountRecon/accountReconState.js +28 -0
  18. package/lib/entity/class/classReducer.d.ts +4 -4
  19. package/lib/entity/class/classState.d.ts +1 -1
  20. package/lib/entity/company/companyReducer.js +0 -1
  21. package/lib/entity/customer/customerPayload.d.ts +1 -1
  22. package/lib/entity/customer/customerPayload.js +16 -6
  23. package/lib/entity/forecast/forecastState.d.ts +1 -1
  24. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  25. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  26. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  27. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  28. package/lib/entity/snackbar/snackbarTypes.js +4 -0
  29. package/lib/entity/task/taskState.d.ts +1 -1
  30. package/lib/entity/tenant/clearAllEpic.d.ts +4 -2
  31. package/lib/entity/tenant/clearAllEpic.js +4 -0
  32. package/lib/entity/tenant/tenantReducer.js +0 -1
  33. package/lib/entity/transaction/payloadTypes/customerTransactionPayload.d.ts +1 -1
  34. package/lib/entity/transaction/payloadTypes/customerTransactionPayload.js +1 -2
  35. package/lib/entity/transaction/payloadTypes/reconciliationTransactionPayloads.d.ts +35 -0
  36. package/lib/entity/transaction/payloadTypes/reconciliationTransactionPayloads.js +53 -0
  37. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +2 -0
  38. package/lib/entity/transaction/payloadTypes/transactionPayload.js +9 -6
  39. package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.d.ts +9 -1
  40. package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.js +23 -2
  41. package/lib/entity/transaction/stateTypes/reconciliationTransaction.d.ts +32 -0
  42. package/lib/entity/transaction/stateTypes/reconciliationTransaction.js +10 -0
  43. package/lib/entity/transaction/stateTypes/transaction.d.ts +3 -1
  44. package/lib/entity/transaction/stateTypes/transactionType.d.ts +1 -1
  45. package/lib/entity/transaction/stateTypes/transactionType.js +1 -1
  46. package/lib/entity/transaction/stateTypes/vendorTransaction.d.ts +5 -0
  47. package/lib/entity/transaction/stateTypes/vendorTransaction.js +5 -1
  48. package/lib/entity/transaction/toSupportedTransaction.js +6 -1
  49. package/lib/entity/transaction/transactionReducer.d.ts +17 -0
  50. package/lib/entity/transaction/transactionReducer.js +47 -2
  51. package/lib/entity/transaction/transactionSelector.d.ts +2 -0
  52. package/lib/entity/transaction/transactionSelector.js +5 -0
  53. package/lib/entity/transaction/transactionState.d.ts +6 -4
  54. package/lib/entity/vendorExpense/vendorExpenseReducer.js +0 -1
  55. package/lib/entity/vendorExpense/vendorExpenseSelector.d.ts +2 -2
  56. package/lib/epic.d.ts +6 -1
  57. package/lib/epic.js +6 -1
  58. package/lib/index.d.ts +22 -13
  59. package/lib/index.js +56 -27
  60. package/lib/init.d.ts +2 -1
  61. package/lib/init.js +9 -2
  62. package/lib/reducer.d.ts +7 -1
  63. package/lib/reducer.js +6 -0
  64. package/lib/view/accountList/accountListReducer.js +1 -3
  65. package/lib/view/accountMappingView/accountMappingReducer.js +0 -1
  66. package/lib/view/apAgingView/apAgingDetail/apAgingDetailReducer.js +1 -2
  67. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  68. package/lib/view/balanceSheet/balanceSheetReducer.js +1 -6
  69. package/lib/view/bankAccountView/bankAccountViewReducer.js +0 -1
  70. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  71. package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
  72. package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
  73. package/lib/view/cashFlow/cashFlowReducer.js +1 -4
  74. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  75. package/lib/view/cashPosition/cashPositionReducer.js +0 -1
  76. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  77. package/lib/view/commonVendorView/vendorView/epics/fetchAndUpdateVendorRecommendationsEpic.js +1 -3
  78. package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewReducer.d.ts +2 -2
  79. package/lib/view/companyView/companyViewReducer.js +1 -10
  80. package/lib/view/dashboard/dashboardEpic.js +0 -2
  81. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  82. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.d.ts +15 -0
  83. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +118 -0
  84. package/lib/view/expenseAutomationView/epics/accountRecon/initialiseLocalDataForSelectedAccountIdEpic.d.ts +10 -0
  85. package/lib/view/expenseAutomationView/epics/accountRecon/initialiseLocalDataForSelectedAccountIdEpic.js +49 -0
  86. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationDetailEpic.d.ts +14 -0
  87. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationDetailEpic.js +169 -0
  88. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.d.ts +9 -0
  89. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +154 -0
  90. package/lib/view/expenseAutomationView/epics/accountRecon/updateReconcileTabLocalDataEpic.d.ts +6 -0
  91. package/lib/view/expenseAutomationView/epics/accountRecon/updateReconcileTabLocalDataEpic.js +110 -0
  92. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +2 -1
  93. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +24 -10
  94. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +2 -1
  95. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +14 -0
  96. package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +32 -5
  97. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.d.ts +2 -2
  98. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.js +1 -5
  99. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +17 -2
  100. package/lib/view/expenseAutomationView/expenseAutomationViewState.d.ts +2 -2
  101. package/lib/view/expenseAutomationView/expenseAutomationViewState.js +1 -1
  102. package/lib/view/expenseAutomationView/helpers/reconciliationHelpers.d.ts +7 -0
  103. package/lib/view/expenseAutomationView/helpers/reconciliationHelpers.js +18 -0
  104. package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +111 -35
  105. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  106. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +84 -10
  107. package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +28 -0
  108. package/lib/view/expenseAutomationView/payload/reconciliationPayload.js +51 -0
  109. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +66 -0
  110. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +384 -0
  111. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +12 -1
  112. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +66 -7
  113. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +2 -0
  114. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.js +1 -1
  115. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.d.ts +51 -0
  116. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.js +7 -0
  117. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.d.ts +5 -0
  118. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +250 -0
  119. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +103 -0
  120. package/lib/view/expenseAutomationView/types/reconciliationViewState.js +38 -0
  121. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +10 -0
  122. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  123. package/lib/view/financeStatement/financeStatementReducer.js +1 -4
  124. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  125. package/lib/view/netBurnOrIncome/netBurnOrIncomeReducer.js +3 -10
  126. package/lib/view/netBurnOrIncomeClassesView/netBurnOrIncomeClassesViewReducer.js +1 -6
  127. package/lib/view/netBurnOrIncomeStoryCard/netBurnOrIncomeStoryCardReducer.js +0 -1
  128. package/lib/view/onboardingView/cockpitView/onboardingCockpitViewReducer.js +0 -3
  129. package/lib/view/opEx/opExForTimeFrameEpic.js +1 -1
  130. package/lib/view/opEx/opExReducer.js +4 -14
  131. package/lib/view/opExByVendor/opExByVendorReducer.js +1 -3
  132. package/lib/view/opExClassesView/opExClassesViewReducer.js +1 -6
  133. package/lib/view/people/fetchPeopleEpic.js +1 -3
  134. package/lib/view/people/invitePeopleEpic.js +1 -3
  135. package/lib/view/people/inviteZeniPeopleEpic.js +1 -3
  136. package/lib/view/people/peopleReducer.js +0 -1
  137. package/lib/view/people/peopleSaveUpdatesEpic.js +1 -1
  138. package/lib/view/profitAndLoss/profitAndLossReducer.js +1 -6
  139. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +1 -6
  140. package/lib/view/recommendation/recommendationReducer.js +1 -4
  141. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  142. package/lib/view/reportUIOptions/updateReportUIOptionThisPeriodEpic.js +1 -3
  143. package/lib/view/revenue/revenueReducer.js +3 -10
  144. package/lib/view/revenueClassesView/revenueClassesViewReducer.js +1 -6
  145. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  146. package/lib/view/settingsView/settingsViewReducer.js +0 -1
  147. package/lib/view/spendManagement/billPay/billList/billListReducer.js +0 -1
  148. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigPayload.d.ts +5 -1
  149. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigState.js +0 -6
  150. package/lib/view/spendManagement/billPay/billsBulkActionView/epics/validateBillsBulkActionEpic.ts.js +4 -3
  151. package/lib/view/spendManagement/billPay/editBillView/epics/fetchBillAndInitializeLocalStoreEpic.js +1 -3
  152. package/lib/view/spendManagement/billPay/editBillView/epics/saveBillDetailEpic.d.ts +2 -1
  153. package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.js +11 -3
  154. package/lib/view/spendManagement/plaidAccount/plaidAccountViewReducer.d.ts +2 -1
  155. package/lib/view/spendManagement/plaidAccount/plaidAccountViewReducer.js +3 -1
  156. package/lib/view/spendManagement/plaidAccount/plaidAccountViewState.d.ts +1 -1
  157. package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchRecommendationsAndUpdateMerchantRecommendationsEpic.js +2 -6
  158. package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchRemiAndInitializeLocalStoreEpic.js +1 -3
  159. package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.js +0 -1
  160. package/lib/view/spendManagement/zeniAccounts/expressPay/epics/fetchExpressPayInitialDetailsEpic.d.ts +2 -2
  161. package/lib/view/spendManagement/zeniAccounts/expressPay/epics/fetchExpressPayInitialDetailsEpic.js +7 -7
  162. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPaySelector.d.ts +2 -2
  163. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPaySelector.js +5 -4
  164. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPayState.d.ts +2 -2
  165. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigPayload.d.ts +14 -0
  166. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigPayload.js +78 -1
  167. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigReducer.js +3 -1
  168. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigSelector.d.ts +2 -1
  169. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigSelector.js +2 -1
  170. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigState.d.ts +9 -0
  171. package/lib/view/subscriptionView/subscriptionViewReducer.js +0 -1
  172. package/lib/view/subscriptionView/types/subscriptionTypes.js +0 -1
  173. package/lib/view/taskManager/taskListView/epics/dragNDropTasksEpic.js +1 -3
  174. package/lib/view/tasksCard/fetchTasksCardEpic.js +1 -2
  175. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  176. package/lib/view/tasksCard/tasksCardSelector.js +1 -1
  177. package/lib/view/topEx/topExSelector.d.ts +1 -1
  178. package/lib/view/transactionDetail/epics/saveTransactionHelper.js +45 -15
  179. package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +22 -4
  180. package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +69 -13
  181. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +11 -2
  182. package/lib/view/transactionDetail/transactionDetailReducer.js +51 -21
  183. package/lib/view/transactionDetail/transactionDetailState.d.ts +1 -0
  184. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +8 -0
  185. package/lib/view/transactionList/transactionListByEntitySelector.js +0 -2
  186. package/lib/view/transactionList/transactionListReducer.js +4 -6
  187. package/lib/view/trendWithTransactions/trendWithTransactionsReducer.js +0 -1
  188. package/lib/view/userFinancialAccount/userFinancialAccountReducer.js +1 -3
  189. package/lib/view/vendorReviewView/vendorGlobalReviewView/vendorGlobalReviewViewState.d.ts +1 -1
  190. package/lib/zeniAPI.d.ts +1 -0
  191. package/package.json +9 -3
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveReconciliationDetailsEpic = void 0;
4
+ exports.createMessageForAction = createMessageForAction;
5
+ exports.getTransactionIdFromCheckedMatchedTransactionPayload = getTransactionIdFromCheckedMatchedTransactionPayload;
6
+ const rxjs_1 = require("rxjs");
7
+ const operators_1 = require("rxjs/operators");
8
+ const accountReconReducer_1 = require("../../../../entity/accountRecon/accountReconReducer");
9
+ const accountReconSelector_1 = require("../../../../entity/accountRecon/accountReconSelector");
10
+ const accountReconState_1 = require("../../../../entity/accountRecon/accountReconState");
11
+ const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
12
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
13
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
14
+ const responsePayload_1 = require("../../../../responsePayload");
15
+ const reconciliationHelpers_1 = require("../../helpers/reconciliationHelpers");
16
+ const reconciliationPayload_1 = require("../../payload/reconciliationPayload");
17
+ const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
18
+ const saveReconciliationDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(reconciliationViewReducer_1.saveReconciliationDetail.match), (0, operators_1.mergeMap)((action) => {
19
+ const state = state$.value;
20
+ const { reconcileAction } = action.payload;
21
+ const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationReconciliationViewState: { selectedAccountId, reconTabsState: { balances }, }, } = state;
22
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
23
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
24
+ let reconciliationData = undefined;
25
+ let reconciliationId = undefined;
26
+ if (selectedAccountId != null) {
27
+ reconciliationData = (0, accountReconSelector_1.getAccountReconByAccountIdAndSelectedPeriod)(state, selectedAccountId, selectedPeriod);
28
+ reconciliationId = reconciliationData === null || reconciliationData === void 0 ? void 0 : reconciliationData.reconciliationId;
29
+ }
30
+ let payload = {};
31
+ if (reconciliationData != null) {
32
+ payload = (0, reconciliationPayload_1.createSaveReconciliationPayloadBasedOnActionAndMethod)(state, selectedPeriod, balances, reconciliationData, action.payload, reconciliationId != null ? 'PUT' : 'POST');
33
+ }
34
+ const saveReconciliationDetailsApi = reconciliationId != null
35
+ ? zeniAPI.putAndGetJSON(`${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/${reconciliationId}`, payload)
36
+ : zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation`, payload);
37
+ return saveReconciliationDetailsApi.pipe((0, operators_1.mergeMap)((response) => {
38
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
39
+ const actions = [];
40
+ const selectedTransactionIds = getTransactionIdFromCheckedMatchedTransactionPayload(response.data.reconciliation[0].transactions.reconcile);
41
+ const allTransactionsPerRecon = (0, reconciliationHelpers_1.getAllReviewTransactionsFromReconcilePayload)(response.data.reconciliation);
42
+ actions.push((0, transactionReducer_1.updateMultipleReconcileTransactions)(allTransactionsPerRecon, 'merge'));
43
+ actions.push((0, accountReconReducer_1.updateAccountRecon)(selectedPeriod, response.data.reconciliation));
44
+ actions.push((0, reconciliationViewReducer_1.updateReconcileTabLocalData)({
45
+ selectedTransactionIds: selectedTransactionIds,
46
+ }));
47
+ if (action.payload.reconcileAction === 'exclude') {
48
+ if (selectedAccountId != null) {
49
+ const accountReconKey = (0, accountReconState_1.toAccountReconKey)(selectedAccountId, selectedPeriod);
50
+ actions.push((0, accountReconReducer_1.excludeReconReviewTransaction)(accountReconKey, action.payload.excludeTransactionId));
51
+ }
52
+ actions.push((0, reconciliationViewReducer_1.saveReconciliationDetailSuccess)({
53
+ reconcileAction,
54
+ excludeTransactionId: action.payload.excludeTransactionId,
55
+ }));
56
+ }
57
+ else if (action.payload.reconcileAction === 'reconcile' ||
58
+ action.payload.reconcileAction === 'save_reconcile_for_later') {
59
+ actions.push((0, reconciliationViewReducer_1.saveReconciliationDetailSuccess)({
60
+ reconcileAction: action.payload.reconcileAction,
61
+ }));
62
+ }
63
+ actions.push((0, snackbarReducer_1.openSnackbar)({
64
+ messageSection: action.payload.reconcileAction === 'reconcile'
65
+ ? 'reconcile'
66
+ : action.payload.reconcileAction ===
67
+ 'save_reconcile_for_later'
68
+ ? 'save_reconcile_for_later'
69
+ : 'exclude_transaction',
70
+ messageText: 'success',
71
+ type: 'success',
72
+ }));
73
+ return (0, rxjs_1.from)(actions);
74
+ }
75
+ else {
76
+ const actions = [];
77
+ if (action.payload.reconcileAction === 'exclude') {
78
+ actions.push((0, reconciliationViewReducer_1.saveReconciliationDetailFailure)({
79
+ fetchStateByAction: {
80
+ reconcileAction: action.payload.reconcileAction,
81
+ excludeTransactionId: action.payload.excludeTransactionId,
82
+ },
83
+ error: response.status,
84
+ }));
85
+ }
86
+ else if (action.payload.reconcileAction === 'reconcile' ||
87
+ action.payload.reconcileAction === 'save_reconcile_for_later') {
88
+ actions.push((0, reconciliationViewReducer_1.saveReconciliationDetailFailure)({
89
+ fetchStateByAction: {
90
+ reconcileAction: action.payload.reconcileAction,
91
+ },
92
+ error: response.status,
93
+ }));
94
+ }
95
+ actions.push((0, snackbarReducer_1.openSnackbar)({
96
+ messageSection: action.payload.reconcileAction === 'reconcile'
97
+ ? 'reconcile'
98
+ : action.payload.reconcileAction ===
99
+ 'save_reconcile_for_later'
100
+ ? 'save_reconcile_for_later'
101
+ : 'exclude_transaction',
102
+ messageText: 'failed',
103
+ type: 'error',
104
+ variables: [
105
+ {
106
+ variableName: '_api-error_',
107
+ variableValue: response.status.message,
108
+ },
109
+ ],
110
+ }));
111
+ return (0, rxjs_1.from)(actions);
112
+ }
113
+ }), (0, operators_1.catchError)((error) => {
114
+ const actions = [];
115
+ if (action.payload.reconcileAction === 'exclude') {
116
+ actions.push((0, reconciliationViewReducer_1.saveReconciliationDetailFailure)({
117
+ fetchStateByAction: {
118
+ reconcileAction: action.payload.reconcileAction,
119
+ excludeTransactionId: action.payload.excludeTransactionId,
120
+ },
121
+ error: (0, responsePayload_1.createZeniAPIStatus)(`Unexpected Error occured while ${createMessageForAction(action.payload.reconcileAction)}`, 'save REST API call errored out' + JSON.stringify(error)),
122
+ }));
123
+ }
124
+ else if (action.payload.reconcileAction === 'reconcile' ||
125
+ action.payload.reconcileAction === 'save_reconcile_for_later') {
126
+ actions.push((0, reconciliationViewReducer_1.saveReconciliationDetailFailure)({
127
+ fetchStateByAction: {
128
+ reconcileAction: action.payload.reconcileAction,
129
+ },
130
+ error: (0, responsePayload_1.createZeniAPIStatus)(`Unexpected Error occured while ${createMessageForAction(action.payload.reconcileAction)}`, 'save REST API call errored out' + JSON.stringify(error)),
131
+ }));
132
+ }
133
+ actions.push((0, snackbarReducer_1.openSnackbar)({
134
+ messageSection: action.payload.reconcileAction === 'reconcile'
135
+ ? 'reconcile'
136
+ : action.payload.reconcileAction ===
137
+ 'save_reconcile_for_later'
138
+ ? 'save_reconcile_for_later'
139
+ : 'exclude_transaction',
140
+ messageText: 'failed',
141
+ type: 'error',
142
+ variables: [
143
+ {
144
+ variableName: '_api-error_',
145
+ variableValue: `Unexpected Error occured while ${createMessageForAction(action.payload.reconcileAction)}` +
146
+ JSON.stringify(error),
147
+ },
148
+ ],
149
+ }));
150
+ return (0, rxjs_1.from)(actions);
151
+ }));
152
+ }));
153
+ exports.saveReconciliationDetailsEpic = saveReconciliationDetailsEpic;
154
+ function createMessageForAction(action) {
155
+ switch (action) {
156
+ case 'exclude':
157
+ return 'Excluding Transaction';
158
+ case 'reconcile':
159
+ return 'Reconciling';
160
+ case 'save_reconcile_for_later':
161
+ return 'Saving for Later';
162
+ }
163
+ }
164
+ function getTransactionIdFromCheckedMatchedTransactionPayload(transactions) {
165
+ const selectedTransactionDetailKeys = transactions
166
+ .filter((transaction) => transaction.is_checked_transaction === true)
167
+ .map((transaction) => transaction.transaction_id);
168
+ return selectedTransactionDetailKeys;
169
+ }
@@ -0,0 +1,9 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { addTransactionToReconcileList, excludeReconReviewTransaction } from '../../../../entity/accountRecon/accountReconReducer';
3
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
+ import { updateMultipleReconcileTransactions } from '../../../../entity/transaction/transactionReducer';
5
+ import { RootState } from '../../../../reducer';
6
+ import { ZeniAPI } from '../../../../zeniAPI';
7
+ import { saveReconciliationReview, updateReconcileTabLocalData, updateSaveReconciliationReviewFetchStatus } from '../../reducers/reconciliationViewReducer';
8
+ export type ActionType = ReturnType<typeof saveReconciliationReview> | ReturnType<typeof excludeReconReviewTransaction> | ReturnType<typeof updateMultipleReconcileTransactions> | ReturnType<typeof addTransactionToReconcileList> | ReturnType<typeof updateReconcileTabLocalData> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateSaveReconciliationReviewFetchStatus>;
9
+ export declare const saveReconciliationReviewEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveReconciliationReviewEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const formatZeniDateFY_1 = require("../../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
7
+ const accountReconReducer_1 = require("../../../../entity/accountRecon/accountReconReducer");
8
+ const accountReconSelector_1 = require("../../../../entity/accountRecon/accountReconSelector");
9
+ const accountReconState_1 = require("../../../../entity/accountRecon/accountReconState");
10
+ const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
11
+ const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
12
+ const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
13
+ const vendorState_1 = require("../../../../entity/vendor/vendorState");
14
+ const responsePayload_1 = require("../../../../responsePayload");
15
+ const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
16
+ const saveReconciliationReviewEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(reconciliationViewReducer_1.saveReconciliationReview.match), (0, operators_1.mergeMap)((action) => {
17
+ const state = state$.value;
18
+ const { transactionId } = action.payload;
19
+ const localData = state.expenseAutomationReconciliationViewState.reconTabsState.review
20
+ .localData[transactionId];
21
+ const reconcileTabLocalData = state.expenseAutomationReconciliationViewState.reconTabsState.reconcile
22
+ .localData;
23
+ const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationReconciliationViewState: { selectedAccountId }, } = state;
24
+ const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
25
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
26
+ let reconciliationData;
27
+ let reconciliationId = undefined;
28
+ let updatedTransaction;
29
+ if (selectedAccountId != null) {
30
+ reconciliationData = (0, accountReconSelector_1.getAccountReconByAccountIdAndSelectedPeriod)(state, selectedAccountId, selectedPeriod);
31
+ reconciliationId = reconciliationData === null || reconciliationData === void 0 ? void 0 : reconciliationData.reconciliationId;
32
+ updatedTransaction = reconciliationData === null || reconciliationData === void 0 ? void 0 : reconciliationData.transactionsToReview.find((transaction) => transaction.transactionId === transactionId);
33
+ }
34
+ const queryParam = {
35
+ review_action: updatedTransaction === null || updatedTransaction === void 0 ? void 0 : updatedTransaction.recommendedAction.action,
36
+ reconciliation_id: reconciliationId !== null && reconciliationId !== void 0 ? reconciliationId : '',
37
+ ref_account_id: selectedAccountId,
38
+ ref_account_name: reconciliationData === null || reconciliationData === void 0 ? void 0 : reconciliationData.account.accountName,
39
+ };
40
+ let payload = {};
41
+ if (reconciliationData != null &&
42
+ updatedTransaction != null &&
43
+ localData != null) {
44
+ if (updatedTransaction.recommendedAction.action === 'record_expense') {
45
+ payload = getPayloadForExpenseRecord(updatedTransaction, localData);
46
+ }
47
+ if (updatedTransaction.recommendedAction.action === 'record_bill_payment') {
48
+ const linkedTransaction = updatedTransaction.recommendedAction.recommendedTransactions.find((transaction) => transaction.transactionId === localData.matchedTransactionId);
49
+ payload = getPayloadForBillPayment(updatedTransaction, linkedTransaction, localData, reconciliationData === null || reconciliationData === void 0 ? void 0 : reconciliationData.account.accountType);
50
+ }
51
+ }
52
+ return zeniAPI
53
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/review?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
54
+ .pipe((0, operators_1.mergeMap)((response) => {
55
+ var _a, _b;
56
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
57
+ const actions = [];
58
+ actions.push((0, reconciliationViewReducer_1.updateSaveReconciliationReviewFetchStatus)({
59
+ transactionId,
60
+ fetchState: 'Completed',
61
+ }), (0, transactionReducer_1.updateMultipleReconcileTransactions)([
62
+ {
63
+ allReconciledTransactions: [response.data.reconciliation],
64
+ currencyPayload: {
65
+ currency_code: (_a = updatedTransaction === null || updatedTransaction === void 0 ? void 0 : updatedTransaction.amount.currencyCode) !== null && _a !== void 0 ? _a : vendorState_1.defaultVendorCurrency.currencyCode,
66
+ currency_symbol: (_b = updatedTransaction === null || updatedTransaction === void 0 ? void 0 : updatedTransaction.amount.currencySymbol) !== null && _b !== void 0 ? _b : vendorState_1.defaultVendorCurrency.currencySymbol,
67
+ },
68
+ },
69
+ ], 'merge'));
70
+ if (selectedAccountId != null) {
71
+ const accountReconKey = (0, accountReconState_1.toAccountReconKey)(selectedAccountId, selectedPeriod);
72
+ actions.push((0, accountReconReducer_1.excludeReconReviewTransaction)(accountReconKey, transactionId), (0, accountReconReducer_1.addTransactionToReconcileList)(accountReconKey, response.data.reconciliation.transaction_id), (0, reconciliationViewReducer_1.updateReconcileTabLocalData)({
73
+ selectedTransactionIds: [
74
+ ...reconcileTabLocalData.selectedTransactionIds,
75
+ response.data.reconciliation.transaction_id,
76
+ ],
77
+ }));
78
+ }
79
+ actions.push((0, snackbarReducer_1.openSnackbar)({
80
+ messageSection: 'recon_transaction_creation',
81
+ messageText: 'success',
82
+ type: 'success',
83
+ }));
84
+ return (0, rxjs_1.from)(actions);
85
+ }
86
+ else {
87
+ const actions = [];
88
+ actions.push((0, reconciliationViewReducer_1.updateSaveReconciliationReviewFetchStatus)({
89
+ transactionId,
90
+ fetchState: 'Error',
91
+ error: response.status,
92
+ }), (0, snackbarReducer_1.openSnackbar)({
93
+ messageSection: 'recon_transaction_creation',
94
+ messageText: 'failed',
95
+ type: 'error',
96
+ variables: [
97
+ {
98
+ variableName: '_api-error_',
99
+ variableValue: response.status.message,
100
+ },
101
+ ],
102
+ }));
103
+ return (0, rxjs_1.from)(actions);
104
+ }
105
+ }), (0, operators_1.catchError)((error) => {
106
+ const actions = [];
107
+ actions.push((0, reconciliationViewReducer_1.updateSaveReconciliationReviewFetchStatus)({
108
+ transactionId,
109
+ fetchState: 'Error',
110
+ error: (0, responsePayload_1.createZeniAPIStatus)(`Unexpected Error occurred while saving reconciliation review`, 'save reconciliation review REST API call errored out' +
111
+ JSON.stringify(error)),
112
+ }), (0, snackbarReducer_1.openSnackbar)({
113
+ messageSection: 'recon_transaction_creation',
114
+ messageText: 'failed',
115
+ type: 'error',
116
+ variables: [
117
+ {
118
+ variableName: '_api-error_',
119
+ variableValue: JSON.stringify('error'),
120
+ },
121
+ ],
122
+ }));
123
+ return (0, rxjs_1.from)(actions);
124
+ }));
125
+ }));
126
+ exports.saveReconciliationReviewEpic = saveReconciliationReviewEpic;
127
+ function getPayloadForExpenseRecord(updatedTransaction, localData) {
128
+ var _a, _b;
129
+ return {
130
+ amount: updatedTransaction.amount.amount,
131
+ transaction_memo: localData.memo,
132
+ transaction_date: updatedTransaction.transactionDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
133
+ transaction_direction: updatedTransaction.transactionDirection,
134
+ transaction_id: updatedTransaction.transactionId,
135
+ vendor_id: (_a = localData.vendor) === null || _a === void 0 ? void 0 : _a.id,
136
+ vendor_name: (_b = localData.vendor) === null || _b === void 0 ? void 0 : _b.name,
137
+ account_id: localData.categoryId,
138
+ accounting_class_id: localData.classId,
139
+ currency_code: updatedTransaction.amount.currencyCode,
140
+ };
141
+ }
142
+ const getPayloadForBillPayment = (updatedTransaction, linkedTransaction, localData, accountType) => {
143
+ return {
144
+ account_type: accountType,
145
+ amount: updatedTransaction.amount.amount,
146
+ transaction_memo: localData.memo,
147
+ transaction_date: updatedTransaction.transactionDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
148
+ transaction_direction: updatedTransaction.transactionDirection,
149
+ transaction_id: updatedTransaction.transactionId,
150
+ linked_transaction_id: linkedTransaction === null || linkedTransaction === void 0 ? void 0 : linkedTransaction.transactionId,
151
+ linked_transaction_type: linkedTransaction === null || linkedTransaction === void 0 ? void 0 : linkedTransaction.transactionType,
152
+ currency_code: updatedTransaction.amount.currencyCode,
153
+ };
154
+ };
@@ -0,0 +1,6 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../reducer';
4
+ import { updateBalancesLocalData, updateReconcileTabLocalData } from '../../reducers/reconciliationViewReducer';
5
+ export type ActionType = ReturnType<typeof updateReconcileTabLocalData> | ReturnType<typeof updateBalancesLocalData>;
6
+ export declare const updateReconcileTabLocalDataEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -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)([