@zeniai/client-epic-state 5.2.11-beta0ND → 5.2.11-betaAM2

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/entity/invoicing/invoicingCommonPayload.d.ts +29 -27
  2. package/lib/entity/invoicing/invoicingCommonPayload.js +75 -37
  3. package/lib/entity/invoicing/product/productPayload.d.ts +0 -10
  4. package/lib/entity/invoicing/product/productPayload.js +2 -14
  5. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
  6. package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
  7. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +97 -1
  8. package/lib/entity/jeSchedules/jeSchedulesPayload.js +209 -0
  9. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
  10. package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  11. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
  12. package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
  13. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +140 -1
  14. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
  15. package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
  16. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  17. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  18. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
  19. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  20. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
  21. package/lib/epic.d.ts +15 -3
  22. package/lib/epic.js +31 -12
  23. package/lib/esm/entity/invoicing/invoicingCommonPayload.js +73 -33
  24. package/lib/esm/entity/invoicing/product/productPayload.js +2 -14
  25. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
  26. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +209 -1
  27. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  28. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
  29. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
  30. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  31. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  32. package/lib/esm/epic.js +27 -8
  33. package/lib/esm/index.js +23 -14
  34. package/lib/esm/reducer.js +3 -0
  35. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +46 -0
  36. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +7 -0
  37. package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +50 -0
  38. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +44 -0
  39. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +44 -0
  40. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +30 -10
  41. package/lib/esm/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +9 -1
  42. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  43. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
  44. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
  45. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  46. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +104 -0
  47. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
  48. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +136 -0
  49. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
  50. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +180 -0
  51. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +111 -0
  52. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +33 -0
  53. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +22 -7
  54. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
  55. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +35 -0
  56. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
  57. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +260 -0
  58. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +319 -29
  59. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
  60. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +162 -0
  61. package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  62. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
  63. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +297 -22
  64. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +22 -0
  65. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -5
  66. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +9 -25
  67. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +1 -6
  68. package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +0 -40
  69. package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +92 -0
  70. package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -25
  71. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +0 -41
  72. package/lib/esm/view/recommendation/recommendationReducer.js +1 -16
  73. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  74. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  75. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  76. package/lib/index.d.ts +29 -22
  77. package/lib/index.js +116 -56
  78. package/lib/reducer.d.ts +1 -0
  79. package/lib/reducer.js +3 -0
  80. package/lib/rootStateTypes.d.ts +2 -0
  81. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.d.ts +9 -0
  82. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +50 -0
  83. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.d.ts +5 -0
  84. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +11 -0
  85. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.d.ts +8 -0
  86. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +54 -0
  87. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.d.ts +8 -0
  88. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +48 -0
  89. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.d.ts +8 -0
  90. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +48 -0
  91. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +2 -1
  92. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +30 -10
  93. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +2 -1
  94. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +9 -1
  95. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  96. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
  97. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
  98. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +21 -0
  99. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
  100. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  101. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +9 -0
  102. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +108 -0
  103. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
  104. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
  105. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +9 -0
  106. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +140 -0
  107. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
  108. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
  109. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +13 -0
  110. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +187 -0
  111. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
  112. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +115 -0
  113. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +7 -0
  114. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +37 -0
  115. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +22 -7
  116. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
  117. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
  118. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  119. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +66 -0
  120. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +40 -0
  121. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +86 -3
  122. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
  123. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +53 -0
  124. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +264 -0
  125. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +93 -12
  126. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +321 -29
  127. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  128. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  129. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +58 -0
  130. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +2 -0
  131. package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +1 -0
  132. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
  133. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
  134. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +36 -7
  135. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +9 -0
  136. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +172 -0
  137. package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  138. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
  139. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
  140. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
  141. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +305 -21
  142. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +76 -0
  143. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +27 -0
  144. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  145. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +83 -8
  146. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +11 -7
  147. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +2 -2
  148. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +1 -12
  149. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +9 -25
  150. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +1 -6
  151. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +1 -10
  152. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +1 -43
  153. package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +12 -0
  154. package/lib/view/invoicing/settingsView/settingsViewEpics.js +99 -0
  155. package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +1 -4
  156. package/lib/view/invoicing/settingsView/settingsViewReducer.js +2 -26
  157. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +0 -35
  158. package/lib/view/invoicing/settingsView/settingsViewSelector.js +1 -43
  159. package/lib/view/invoicing/settingsView/settingsViewState.d.ts +0 -8
  160. package/lib/view/recommendation/recommendationPayload.d.ts +0 -34
  161. package/lib/view/recommendation/recommendationReducer.d.ts +1 -2
  162. package/lib/view/recommendation/recommendationReducer.js +2 -17
  163. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  164. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  165. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
  166. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  167. package/package.json +1 -1
  168. package/lib/esm/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +0 -27
  169. package/lib/esm/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +0 -19
  170. package/lib/esm/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +0 -19
  171. package/lib/esm/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +0 -39
  172. package/lib/esm/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +0 -25
  173. package/lib/esm/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +0 -48
  174. package/lib/esm/view/recommendation/submitRecommendationFeedbackEpic.js +0 -52
  175. package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.d.ts +0 -6
  176. package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +0 -31
  177. package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.d.ts +0 -6
  178. package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +0 -23
  179. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.d.ts +0 -6
  180. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +0 -23
  181. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.d.ts +0 -6
  182. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +0 -43
  183. package/lib/view/invoicing/settingsView/epics/settingsViewActionType.d.ts +0 -5
  184. package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.d.ts +0 -11
  185. package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +0 -29
  186. package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.d.ts +0 -34
  187. package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +0 -53
  188. package/lib/view/recommendation/submitRecommendationFeedbackEpic.d.ts +0 -7
  189. package/lib/view/recommendation/submitRecommendationFeedbackEpic.js +0 -56
  190. /package/lib/esm/view/{invoicing/settingsView/epics/settingsViewActionType.js → expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js} +0 -0
  191. /package/lib/view/{invoicing/settingsView/epics/settingsViewActionType.js → expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js} +0 -0
@@ -37,46 +37,6 @@ export const INVOICING_INCOME_ACCOUNT_TYPES = [
37
37
  'income',
38
38
  'other_income',
39
39
  ];
40
- /**
41
- * The account behind a picker value. The pickers submit the QuickBooks id, so
42
- * that is what callers hold; the payload builders need the whole entity to send
43
- * `toAccountPayload`, which is why the lookup lives here next to the options.
44
- */
45
- export const invoicingQboAccountByQboId = (state, qboId) => {
46
- if (qboId == null || qboId === '') {
47
- return undefined;
48
- }
49
- // `getAccountList` throws when a listed id is missing from the entity slice.
50
- // That is survivable when looking one account up — the caller falls back to
51
- // the id it already had — but not when it happens inside an epic, where the
52
- // throw would take the whole request with it.
53
- try {
54
- const { accounts } = getAccountList(state.accountState, state.accountListState, INVOICING_ACCOUNT_LIST_KEY);
55
- // Matched on any id the account is known by. The pickers submit `qboId`,
56
- // but a mapping that arrived from the service can name the account by its
57
- // platform id instead, and an account we cannot resolve is a mapping that
58
- // cannot be sent as a record.
59
- return accounts.find((account) => account.qboId === qboId ||
60
- account.accountId === qboId ||
61
- account.coaId === qboId);
62
- }
63
- catch {
64
- return undefined;
65
- }
66
- };
67
- /** The class behind a picker value, for the same reason as the account above. */
68
- export const invoicingQboClassByQboId = (state, qboId) => {
69
- if (qboId == null || qboId === '') {
70
- return undefined;
71
- }
72
- try {
73
- const { classes } = getClassList(state.classState, state.classListState);
74
- return classes.find((accountingClass) => accountingClass.qboId === qboId);
75
- }
76
- catch {
77
- return undefined;
78
- }
79
- };
80
40
  /**
81
41
  * Accounts and classes as the invoicing pickers need them. Both come from the
82
42
  * shared accounting-service lists, so whatever another screen already loaded
@@ -0,0 +1,92 @@
1
+ import { from, of } from 'rxjs';
2
+ import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
5
+ import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
6
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
7
+ import { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, invoicingStripeConnectionFailure, saveInvoicingSettings, saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, updateInvoicingSettings, updateInvoicingSettingsFailure, updateInvoicingStripeConnection, } from './settingsViewReducer';
8
+ export const fetchInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchInvoicingSettings.match), switchMap(() => {
9
+ const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
10
+ return zeniAPI.getJSON(apiUrl).pipe(switchMap((response) => {
11
+ if (isSuccessResponse(response) && response.data != null) {
12
+ const address = response.data.address;
13
+ return [
14
+ ...(address != null ? [updateAddresses([address])] : []),
15
+ updateInvoicingSettings(response.data),
16
+ ];
17
+ }
18
+ return of(updateInvoicingSettingsFailure(response.status));
19
+ }), catchError((error) => of(updateInvoicingSettingsFailure(createZeniAPIStatus('Unexpected Error', 'Fetch settings REST API call errored out ' +
20
+ JSON.stringify(error))))));
21
+ }));
22
+ export const connectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(connectInvoicingStripe.match), mergeMap((action) => {
23
+ const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`;
24
+ const { api_key, publishable_key, webhook_secret } = action.payload;
25
+ const body = {
26
+ api_key,
27
+ publishable_key,
28
+ ...(webhook_secret != null && webhook_secret !== ''
29
+ ? { webhook_secret }
30
+ : {}),
31
+ };
32
+ return zeniAPI
33
+ .postAndGetJSON(apiUrl, body)
34
+ .pipe(switchMap((response) => {
35
+ if (isSuccessResponse(response) && response.data != null) {
36
+ return of(updateInvoicingStripeConnection({
37
+ stripe_connected: response.data.stripe_connected,
38
+ publishable_key: response.data.publishable_key,
39
+ }), fetchInvoicingSettings());
40
+ }
41
+ return of(invoicingStripeConnectionFailure(response.status));
42
+ }), catchError((error) => of(invoicingStripeConnectionFailure(createZeniAPIStatus('Unexpected Error', 'Stripe connect setup REST API call errored out ' +
43
+ JSON.stringify(error))))));
44
+ }));
45
+ export const disconnectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(disconnectInvoicingStripe.match), mergeMap(() => {
46
+ const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;
47
+ return zeniAPI
48
+ .deleteAndGetJSON(apiUrl)
49
+ .pipe(switchMap((response) => {
50
+ if (isSuccessResponse(response)) {
51
+ return of(updateInvoicingStripeConnection({
52
+ stripe_connected: false,
53
+ publishable_key: '',
54
+ }), fetchInvoicingSettings());
55
+ }
56
+ return of(invoicingStripeConnectionFailure(response.status));
57
+ }), catchError((error) => of(invoicingStripeConnectionFailure(createZeniAPIStatus('Unexpected Error', 'Stripe disconnect REST API call errored out ' +
58
+ JSON.stringify(error))))));
59
+ }));
60
+ export const saveInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveInvoicingSettings.match), mergeMap((action) => {
61
+ const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
62
+ const { settings, snackbarSection } = action.payload;
63
+ /** `status` surfaces the platform's error text; omit it to keep the generic copy. */
64
+ const snackbar = (messageText, status) => snackbarSection == null
65
+ ? []
66
+ : [
67
+ openSnackbar({
68
+ messageSection: snackbarSection,
69
+ messageText,
70
+ type: messageText === 'success' ? 'success' : 'error',
71
+ variables: apiErrorSnackbarVariables(status),
72
+ }),
73
+ ];
74
+ return zeniAPI
75
+ .putAndGetJSON(apiUrl, { ...settings })
76
+ .pipe(switchMap((response) => {
77
+ if (isSuccessResponse(response) && response.data != null) {
78
+ return from([
79
+ saveInvoicingSettingsSuccess(response.data),
80
+ ...snackbar('success'),
81
+ ]);
82
+ }
83
+ return from([
84
+ saveInvoicingSettingsFailure(response.status),
85
+ ...snackbar('failed', response.status),
86
+ ]);
87
+ }), catchError((error) => from([
88
+ saveInvoicingSettingsFailure(createZeniAPIStatus('Unexpected Error', 'Save settings REST API call errored out ' +
89
+ JSON.stringify(error))),
90
+ ...snackbar('failed'),
91
+ ])));
92
+ }));
@@ -1,16 +1,11 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { clearAll } from '../../../rootActions';
3
- import { entityToInvoicingQboSettingsLocalData, } from './invoicingQboSettingsFormConfig';
4
3
  export const initialState = {
5
4
  fetchState: 'Not-Started',
6
5
  error: undefined,
7
6
  saveFetchState: { fetchState: 'Not-Started', error: undefined },
8
7
  stripeFetchState: { fetchState: 'Not-Started', error: undefined },
9
8
  settings: undefined,
10
- // Listed so `clearAll` resets them: an in-progress draft left behind by a
11
- // tenant switch would be shown and saved against the tenant switched to.
12
- brandingDraft: undefined,
13
- qboDraft: undefined,
14
9
  hasValidState() {
15
10
  return this.fetchState === 'Completed' && this.settings != null;
16
11
  },
@@ -27,11 +22,6 @@ const settingsView = createSlice({
27
22
  draft.settings = action.payload;
28
23
  draft.fetchState = 'Completed';
29
24
  draft.error = undefined;
30
- // Seed the QBO page's local data from the response. An edit already in
31
- // progress wins: a refetch behind the user must not discard it.
32
- if (draft.qboDraft == null) {
33
- draft.qboDraft = entityToInvoicingQboSettingsLocalData(action.payload.qbo);
34
- }
35
25
  },
36
26
  updateInvoicingSettingsFailure(draft, action) {
37
27
  draft.fetchState = 'Error';
@@ -46,9 +36,6 @@ const settingsView = createSlice({
46
36
  saveInvoicingSettingsSuccess(draft, action) {
47
37
  draft.settings = action.payload;
48
38
  draft.saveFetchState = { fetchState: 'Completed', error: undefined };
49
- // Re-seeded from what was just persisted, so the page keeps working off
50
- // local data while showing the server's version of it.
51
- draft.qboDraft = entityToInvoicingQboSettingsLocalData(action.payload.qbo);
52
39
  },
53
40
  saveInvoicingSettingsFailure(draft, action) {
54
41
  draft.saveFetchState = { fetchState: 'Error', error: action.payload };
@@ -67,17 +54,6 @@ const settingsView = createSlice({
67
54
  resetInvoicingBrandingFormDraft(draft) {
68
55
  draft.brandingDraft = undefined;
69
56
  },
70
- updateInvoicingQboSettingsDraft(draft, action) {
71
- draft.qboDraft = action.payload.localData;
72
- },
73
- // Trigger only — handled by submitInvoicingQboSettingsEpic, which reads the
74
- // local data and converts it to the request body.
75
- submitInvoicingQboSettings(draft) {
76
- draft.saveFetchState = { fetchState: 'In-Progress', error: undefined };
77
- },
78
- resetInvoicingQboSettingsDraft(draft) {
79
- draft.qboDraft = undefined;
80
- },
81
57
  connectInvoicingStripe: {
82
58
  reducer(draft) {
83
59
  draft.stripeFetchState = { fetchState: 'In-Progress', error: undefined };
@@ -109,5 +85,5 @@ const settingsView = createSlice({
109
85
  });
110
86
  },
111
87
  });
112
- export const { fetchInvoicingSettings, updateInvoicingSettings, updateInvoicingSettingsFailure, saveInvoicingSettings, saveInvoicingSettingsSuccess, saveInvoicingSettingsFailure, resetSaveInvoicingSettings, updateInvoicingBrandingFormDraft, submitInvoicingBrandingForm, resetInvoicingBrandingFormDraft, updateInvoicingQboSettingsDraft, submitInvoicingQboSettings, resetInvoicingQboSettingsDraft, connectInvoicingStripe, disconnectInvoicingStripe, updateInvoicingStripeConnection, invoicingStripeConnectionFailure, } = settingsView.actions;
88
+ export const { fetchInvoicingSettings, updateInvoicingSettings, updateInvoicingSettingsFailure, saveInvoicingSettings, saveInvoicingSettingsSuccess, saveInvoicingSettingsFailure, resetSaveInvoicingSettings, updateInvoicingBrandingFormDraft, submitInvoicingBrandingForm, resetInvoicingBrandingFormDraft, connectInvoicingStripe, disconnectInvoicingStripe, updateInvoicingStripeConnection, invoicingStripeConnectionFailure, } = settingsView.actions;
113
89
  export default settingsView.reducer;
@@ -1,9 +1,7 @@
1
1
  import { getInvoicingQboAccountMappingId, } from '../../../entity/invoicing/invoicingCommonPayload';
2
2
  import { getFormattedAddress } from '../../addressView/addressViewSelector';
3
3
  import { getInvoicingConfigView } from '../invoicingConfigView/invoicingConfigViewSelector';
4
- import { getInvoicingQboView, isInvoicingAccountingPickerDataLoading, } from '../invoicingQboView/invoicingQboViewSelector';
5
4
  import { INVOICING_BUSINESS_ADDRESS_TYPE, entityToInvoicingBrandingFormLocalData, } from './invoicingBrandingFormConfig';
6
- import { initialInvoicingQboSettingsLocalData, } from './invoicingQboSettingsFormConfig';
7
5
  /**
8
6
  * Shared primitive: the raw invoicing settings. Consumed internally by other
9
7
  * CES selectors (create-invoice, customer-detail, overview) and by non-settings
@@ -94,45 +92,6 @@ export const getInvoicingSettingsHubView = (state) => {
94
92
  status,
95
93
  };
96
94
  };
97
- /**
98
- * Bundled view for the QBO configuration page: the draft it edits, the accounts
99
- * and option lists its dropdowns render, the connection and sync health it
100
- * reports, and the fetch states that decide between skeleton, form and error.
101
- *
102
- * `localData` is the draft once the user has edited, and the settings response
103
- * before that — so the page has one field to read and CES owns when it becomes
104
- * available, rather than the page copying settings into local state.
105
- */
106
- export const getInvoicingQboSettingsFormView = (state) => {
107
- const { error, fetchState, qboDraft, saveFetchState, settings } = state.invoicingSettingsViewState;
108
- const { fetchState: configFetchState, qboAccountMappingKindOptions, qboCustomerMatchingOptions, qboSyncStatusOptions, } = getInvoicingConfigView(state);
109
- const qboView = getInvoicingQboView(state);
110
- return {
111
- accountMappingKindOptions: qboAccountMappingKindOptions,
112
- accounts: qboView.accounts,
113
- backfillState: qboView.backfillState,
114
- connection: qboView.connection,
115
- configFetchState,
116
- customerMatchingOptions: qboCustomerMatchingOptions,
117
- // The dropdowns cannot be built before both the settings and the accounts
118
- // land, so the page waits on either rather than rendering empty pickers.
119
- isLoading: fetchState === 'Not-Started' ||
120
- fetchState === 'In-Progress' ||
121
- isInvoicingAccountingPickerDataLoading(state),
122
- isSyncEnabledSaved: settings?.qbo?.enabled === true,
123
- // Seeded in the reducer when the settings response lands, so this is a plain
124
- // read rather than a second place that decides what the page starts from.
125
- localData: qboDraft ?? initialInvoicingQboSettingsLocalData,
126
- nestedAccountHierarchy: qboView.nestedAccountHierarchy,
127
- retryFetchStateByTaskId: qboView.retryFetchStateByTaskId,
128
- saveState: saveFetchState.fetchState === 'Not-Started' && error != null
129
- ? { fetchState, error }
130
- : saveFetchState,
131
- settingsFetchState: fetchState,
132
- syncHealth: qboView.syncHealth,
133
- syncStatusOptions: qboSyncStatusOptions,
134
- };
135
- };
136
95
  /**
137
96
  * Bundled view for the branding settings form: the draft `localData` (seeded
138
97
  * from the existing settings until the user edits), the business-address label
@@ -131,21 +131,6 @@ const recommendation = createSlice({
131
131
  };
132
132
  },
133
133
  },
134
- clearRecommendation(draft) {
135
- Object.assign(draft, initialState);
136
- },
137
- // Fire-and-forget human feedback on a recommendation (accept, ranked
138
- // override or outside override). Handled by submitRecommendationFeedbackEpic
139
- // which POSTs to the accounting recommendation-feedback endpoint. No state
140
- // mutation: the categorization UX must not depend on the feedback round-trip.
141
- submitRecommendationFeedback: {
142
- reducer() {
143
- // Fire-and-forget: no state mutation; the epic performs the POST.
144
- },
145
- prepare(args) {
146
- return { payload: args };
147
- },
148
- },
149
134
  },
150
135
  extraReducers: (builder) => {
151
136
  builder.addCase(clearAll, (draft) => {
@@ -153,7 +138,7 @@ const recommendation = createSlice({
153
138
  });
154
139
  },
155
140
  });
156
- export const { fetchEntityRecommendationsByTransactionId, fetchEntityRecommendationsForLineUpdate, fetchRecommendationByEntityName, fetchRecommendationByEntityId, updateRecommendationForEntity, updateRecommendationForEntityFailure, indicateReadyToInitializeRecommendation, clearRecommendation, submitRecommendationFeedback, } = recommendation.actions;
141
+ export const { fetchEntityRecommendationsByTransactionId, fetchEntityRecommendationsForLineUpdate, fetchRecommendationByEntityName, fetchRecommendationByEntityId, updateRecommendationForEntity, updateRecommendationForEntityFailure, indicateReadyToInitializeRecommendation, } = recommendation.actions;
157
142
  export default recommendation.reducer;
158
143
  const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
159
144
  const key = getEntityRecommendationKey(entityType, entityId);
@@ -30,7 +30,7 @@ export const fetchAccruedScheduleListEpic = (actions$, state$, zeniAPI) => actio
30
30
  je_schedule_type: scheduleType,
31
31
  sort_by: 'transaction_date',
32
32
  sort_order: 'desc',
33
- filter: 'all',
33
+ filter: action.payload.statusFilter,
34
34
  };
35
35
  return zeniAPI
36
36
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
@@ -7,9 +7,14 @@ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePay
7
7
  import { fetchDownloadSchedules, getState, updateDownloadScheduleFailure, updateDownloadScheduleSuccess, } from '../scheduleListReducer';
8
8
  import { getScheduleListKey } from '../scheduleListTypes';
9
9
  export const fetchDownloadSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchDownloadSchedules.match), mergeMap((action) => {
10
- const { scheduleType, downloadCategories } = action.payload;
10
+ const { scheduleType, downloadCategories, statusFilter } = action.payload;
11
11
  const scheduleListState = state$.value.scheduleListState;
12
12
  // if parameters are provided, use those. else go to localdata
13
+ // Accrued is deliberately not served here. Its rows come back in a different shape, this
14
+ // epic writes them through updateJESchedules (the prepaid / fixed mapper), and
15
+ // doUpdateScheduleList never flips downloadState for accrued -- so a request would store the
16
+ // wrong data and then never report completion. Accrued downloads go through
17
+ // fetchAccruedScheduleList, which owns that shape end to end.
13
18
  let scheduleState;
14
19
  if (scheduleType !== 'accrued_expenses') {
15
20
  scheduleState = getState(scheduleListState, scheduleType);
@@ -34,7 +39,7 @@ export const fetchDownloadSchedulesEpic = (actions$, state$, zeniAPI) => actions
34
39
  base_txn_account_ids: downloadCategories,
35
40
  sort_by: 'transaction_date',
36
41
  sort_order: 'desc',
37
- filter: 'all',
42
+ filter: statusFilter,
38
43
  };
39
44
  return zeniAPI
40
45
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/download?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
@@ -84,8 +84,8 @@ const scheduleListView = createSlice({
84
84
  reducers: {
85
85
  fetchDownloadSchedules: {
86
86
  reducer(draft, action) {
87
+ // Accrued is not downloaded through this action -- see fetchDownloadSchedulesEpic for why.
87
88
  if (action.payload.scheduleType !== 'accrued_expenses') {
88
- //if condition added for type narrowing
89
89
  const state = getState(draft, action.payload.scheduleType);
90
90
  const selectedTimeframe = action.payload.timeframeAndCategory.selectedTimeframe;
91
91
  const selectedCategoryId = action.payload.timeframeAndCategory.selectedCategoryId;
@@ -109,13 +109,14 @@ const scheduleListView = createSlice({
109
109
  updateState(draft, action.payload.scheduleType, state);
110
110
  }
111
111
  },
112
- prepare(scheduleType, timeframeAndCategory, downloadCategories, cacheOverride = false) {
112
+ prepare(scheduleType, timeframeAndCategory, downloadCategories, statusFilter = 'all', cacheOverride = false) {
113
113
  return {
114
114
  payload: {
115
115
  timeframeAndCategory,
116
116
  scheduleType,
117
117
  cacheOverride,
118
118
  downloadCategories,
119
+ statusFilter,
119
120
  },
120
121
  };
121
122
  },
@@ -151,12 +152,13 @@ const scheduleListView = createSlice({
151
152
  updateState(draft, action.payload.scheduleType, state);
152
153
  }
153
154
  },
154
- prepare(scheduleType, timeframeAndCategory, cacheOverride = false) {
155
+ prepare(scheduleType, timeframeAndCategory, cacheOverride = false, statusFilter = 'all') {
155
156
  return {
156
157
  payload: {
157
158
  timeframeAndCategory,
158
159
  scheduleType,
159
160
  cacheOverride,
161
+ statusFilter,
160
162
  },
161
163
  };
162
164
  },