@zeniai/client-epic-state 5.2.70 → 5.2.72-beta0ND

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 (161) hide show
  1. package/lib/entity/actualMatching/actualMatchingReducer.d.ts +3 -1
  2. package/lib/entity/actualMatching/actualMatchingReducer.js +11 -2
  3. package/lib/entity/aiCfo/aiCfoState.d.ts +2 -2
  4. package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +2 -2
  5. package/lib/entity/chargeCardTransaction/chargeCardTransaction.d.ts +1 -1
  6. package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -1
  7. package/lib/entity/invoicing/{product/productPayload.d.ts → invoicingCatalog/invoicingCatalogPayload.d.ts} +44 -6
  8. package/lib/entity/invoicing/{product/productPayload.js → invoicingCatalog/invoicingCatalogPayload.js} +50 -6
  9. package/lib/entity/invoicing/invoicingCatalog/invoicingCatalogReducer.d.ts +12 -0
  10. package/lib/entity/invoicing/{plan/planReducer.js → invoicingCatalog/invoicingCatalogReducer.js} +20 -21
  11. package/lib/entity/invoicing/{plan/planSelector.d.ts → invoicingCatalog/invoicingCatalogSelector.d.ts} +5 -6
  12. package/lib/entity/invoicing/{plan/planSelector.js → invoicingCatalog/invoicingCatalogSelector.js} +12 -12
  13. package/lib/entity/invoicing/{product/productState.d.ts → invoicingCatalog/invoicingCatalogState.d.ts} +42 -6
  14. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +2 -0
  15. package/lib/entity/jeSchedules/jeSchedulesPayload.js +2 -0
  16. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +2 -0
  17. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +4 -4
  18. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  19. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  20. package/lib/epic.d.ts +4 -2
  21. package/lib/epic.js +5 -1
  22. package/lib/esm/entity/actualMatching/actualMatchingReducer.js +9 -1
  23. package/lib/esm/entity/invoicing/{product/productPayload.js → invoicingCatalog/invoicingCatalogPayload.js} +46 -3
  24. package/lib/esm/entity/invoicing/{plan/planReducer.js → invoicingCatalog/invoicingCatalogReducer.js} +19 -20
  25. package/lib/esm/entity/invoicing/{plan/planSelector.js → invoicingCatalog/invoicingCatalogSelector.js} +8 -8
  26. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +2 -0
  27. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  28. package/lib/esm/epic.js +5 -1
  29. package/lib/esm/index.js +9 -12
  30. package/lib/esm/reducer.js +4 -7
  31. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.js +4 -2
  32. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.js +50 -0
  33. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +26 -13
  34. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +2 -23
  35. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +89 -38
  36. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +68 -62
  37. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +15 -0
  38. package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +9 -1
  39. package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +1 -1
  40. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +5 -3
  41. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/fetchInvoicingCatalogItemDetailEpic.js +2 -2
  42. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogPlanActionEpic.js +2 -2
  43. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogProductActionEpic.js +4 -4
  44. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -7
  45. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +2 -2
  46. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +5 -1
  47. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +27 -1
  48. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +5 -1
  49. package/lib/esm/view/invoicing/invoiceList/invoiceListReducer.js +8 -1
  50. package/lib/esm/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogPlanListEpic.js +2 -2
  51. package/lib/esm/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogProductListEpic.js +2 -2
  52. package/lib/esm/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.js +55 -22
  53. package/lib/esm/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewState.js +1 -20
  54. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +18 -9
  55. package/lib/esm/view/invoicing/settingsView/submitInvoicingBrandingFormEpic.js +11 -2
  56. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewEpic.js +33 -13
  57. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +2 -1
  58. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -30
  59. package/lib/esm/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.js +37 -0
  60. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +21 -1
  61. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +2 -1
  62. package/lib/index.d.ts +15 -19
  63. package/lib/index.js +65 -63
  64. package/lib/reducer.d.ts +1 -2
  65. package/lib/reducer.js +4 -7
  66. package/lib/rootStateTypes.d.ts +3 -5
  67. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.d.ts +2 -2
  68. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.js +3 -1
  69. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.d.ts +10 -0
  70. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.js +54 -0
  71. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +24 -11
  72. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +1 -22
  73. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  74. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +12 -1
  75. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +19 -8
  76. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +90 -39
  77. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -2
  78. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +24 -10
  79. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +7 -4
  80. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +71 -62
  81. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +19 -4
  82. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +18 -1
  83. package/lib/view/invoicing/createInvoice/createInvoiceEpic.d.ts +3 -2
  84. package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +8 -0
  85. package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +2 -2
  86. package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +2 -2
  87. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +8 -9
  88. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +2 -2
  89. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +5 -3
  90. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/fetchInvoicingCatalogItemDetailEpic.d.ts +2 -2
  91. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/fetchInvoicingCatalogItemDetailEpic.js +2 -2
  92. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormHelper.d.ts +3 -4
  93. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogPlanActionEpic.d.ts +2 -2
  94. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogPlanActionEpic.js +2 -2
  95. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogProductActionEpic.d.ts +2 -3
  96. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogProductActionEpic.js +4 -4
  97. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts +2 -3
  98. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -7
  99. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +2 -2
  100. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
  101. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +6 -2
  102. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +3 -2
  103. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +29 -2
  104. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +3 -1
  105. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +5 -1
  106. package/lib/view/invoicing/invoiceList/invoiceListReducer.d.ts +3 -1
  107. package/lib/view/invoicing/invoiceList/invoiceListReducer.js +9 -2
  108. package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogListPageEpic.d.ts +2 -2
  109. package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogPlanListEpic.d.ts +2 -2
  110. package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogPlanListEpic.js +2 -2
  111. package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogProductListEpic.d.ts +2 -2
  112. package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogProductListEpic.js +2 -2
  113. package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewPayload.d.ts +3 -3
  114. package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.d.ts +33 -15
  115. package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.js +57 -23
  116. package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewState.d.ts +0 -15
  117. package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewState.js +0 -22
  118. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.d.ts +1 -1
  119. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.d.ts +1 -1
  120. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +1 -1
  121. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +1 -1
  122. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +12 -3
  123. package/lib/view/invoicing/settingsView/settingsViewSelector.js +17 -8
  124. package/lib/view/invoicing/settingsView/submitInvoicingBrandingFormEpic.js +11 -2
  125. package/lib/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewEpic.js +33 -13
  126. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +3 -2
  127. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +2 -1
  128. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +4 -0
  129. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  130. package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +5 -5
  131. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  132. package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.d.ts +2 -2
  133. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -1
  134. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -30
  135. package/lib/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.d.ts +8 -0
  136. package/lib/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.js +41 -0
  137. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +1 -1
  138. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +22 -2
  139. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +1 -0
  140. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -1
  141. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +1 -0
  142. package/lib/view/spendManagement/commonSetup/types/businessVerification.d.ts +2 -1
  143. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewReducer.d.ts +2 -2
  144. package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +5 -5
  145. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +2 -2
  146. package/package.json +1 -26
  147. package/lib/entity/invoicing/plan/planPayload.d.ts +0 -40
  148. package/lib/entity/invoicing/plan/planPayload.js +0 -51
  149. package/lib/entity/invoicing/plan/planReducer.d.ts +0 -14
  150. package/lib/entity/invoicing/plan/planState.d.ts +0 -43
  151. package/lib/entity/invoicing/product/productReducer.d.ts +0 -9
  152. package/lib/entity/invoicing/product/productReducer.js +0 -50
  153. package/lib/entity/invoicing/product/productSelector.d.ts +0 -4
  154. package/lib/entity/invoicing/product/productSelector.js +0 -17
  155. package/lib/entity/invoicing/product/productState.js +0 -2
  156. package/lib/esm/entity/invoicing/plan/planPayload.js +0 -47
  157. package/lib/esm/entity/invoicing/product/productReducer.js +0 -43
  158. package/lib/esm/entity/invoicing/product/productSelector.js +0 -10
  159. package/lib/esm/entity/invoicing/product/productState.js +0 -1
  160. /package/lib/entity/invoicing/{plan/planState.js → invoicingCatalog/invoicingCatalogState.js} +0 -0
  161. /package/lib/esm/entity/invoicing/{plan/planState.js → invoicingCatalog/invoicingCatalogState.js} +0 -0
@@ -1,7 +1,5 @@
1
1
  import { createSelector } from '@reduxjs/toolkit';
2
- import { getInvoicingPlansByIds } from '../../../entity/invoicing/plan/planSelector';
3
- import { runningInvoicingActionId } from '../runningInvoicingActionId';
4
- import { INVOICING_PRODUCT_COLUMNS, } from './invoicingCatalogListViewState';
2
+ import { getInvoicingCatalogItemsByIds, invoicingPricePointDisplayAmount, } from '../../../entity/invoicing/invoicingCatalog/invoicingCatalogSelector';
5
3
  /**
6
4
  * Flatten catalog items into the price rows the pickers render.
7
5
  *
@@ -22,28 +20,63 @@ export const getInvoicingCatalogPrices = (items) => items.flatMap((item) => (ite
22
20
  priceCode: subFamily.priceCode,
23
21
  productCode: item.productCode,
24
22
  })));
23
+ const lowestStartingTier = (tiers) => tiers.reduce((lowest, tier) => lowest == null || tier.startingUnit < lowest.startingUnit ? tier : lowest, undefined);
24
+ export const getInvoicingCatalogPlanRows = (items) => items.flatMap((item) => {
25
+ const pricePoints = item.subFamilies ?? [];
26
+ if (pricePoints.length === 0) {
27
+ return [
28
+ {
29
+ id: item.id,
30
+ item,
31
+ period: item.period,
32
+ periodUnit: item.periodUnit,
33
+ price: item.price,
34
+ productFamily: item.name,
35
+ status: item.status,
36
+ tierCount: item.tiers?.length ?? 0,
37
+ firstTier: lowestStartingTier(item.tiers ?? []),
38
+ },
39
+ ];
40
+ }
41
+ return pricePoints.map((pricePoint) => ({
42
+ id: pricePoint.id,
43
+ item,
44
+ period: pricePoint.period,
45
+ periodUnit: pricePoint.periodUnit,
46
+ planName: pricePoint.name,
47
+ price: invoicingPricePointDisplayAmount(pricePoint),
48
+ pricingModel: pricePoint.pricingModel,
49
+ productFamily: item.name,
50
+ status: pricePoint.status,
51
+ tierCount: pricePoint.tiers?.length ?? 0,
52
+ firstTier: lowestStartingTier(pricePoint.tiers ?? []),
53
+ }));
54
+ });
25
55
  /**
26
56
  * Bundled read view for the single catalog page (plans + products tabs).
27
57
  * Memoized over the plan + product entity slices and the list-view slice so the
28
58
  * denormalized arrays keep referential identity. The base `fetchState`/`error`
29
59
  * track the plan list; the product list has its own `productFetchState`.
30
60
  */
31
- export const getInvoicingCatalogListView = createSelector((state) => state.invoicingPlanState, (state) => state.invoicingCatalogListViewState, (state) => state.invoicingConfigViewState.catalogItemLifecycleActionOptions, (state) => state.editInvoicingCatalogItemDetailViewState.actionStateById, (planState, listViewState, catalogItemLifecycleActionOptions, actionStateById) => ({
32
- catalogItemLifecycleActionOptions,
33
- runningActionId: runningInvoicingActionId(actionStateById),
34
- plans: getInvoicingPlansByIds(planState, listViewState.planIds),
35
- planSort: listViewState.planSort,
36
- productColumns: INVOICING_PRODUCT_COLUMNS,
37
- products: getInvoicingPlansByIds(planState, listViewState.productIds),
38
- productSort: listViewState.productSort,
39
- count: listViewState.counts,
40
- countsFetchState: listViewState.countsFetchState,
41
- planFilters: listViewState.planFilters,
42
- planNextCursor: listViewState.planNextCursor,
43
- productFilters: listViewState.productFilters,
44
- productNextCursor: listViewState.productNextCursor,
45
- productFetchState: listViewState.productFetchState,
46
- fetchState: listViewState.fetchState,
47
- error: listViewState.error,
48
- version: 1.0,
49
- }));
61
+ export const getInvoicingCatalogListView = createSelector((state) => state.invoicingCatalogState, (state) => state.invoicingCatalogListViewState, (catalogState, listViewState) => {
62
+ const plans = getInvoicingCatalogItemsByIds(catalogState, listViewState.planIds);
63
+ const products = getInvoicingCatalogItemsByIds(catalogState, listViewState.productIds);
64
+ return {
65
+ planRows: getInvoicingCatalogPlanRows(plans),
66
+ plans,
67
+ planSort: listViewState.planSort,
68
+ productRows: getInvoicingCatalogPlanRows(products),
69
+ products,
70
+ productSort: listViewState.productSort,
71
+ count: listViewState.counts,
72
+ countsFetchState: listViewState.countsFetchState,
73
+ planFilters: listViewState.planFilters,
74
+ planNextCursor: listViewState.planNextCursor,
75
+ productFilters: listViewState.productFilters,
76
+ productNextCursor: listViewState.productNextCursor,
77
+ productFetchState: listViewState.productFetchState,
78
+ fetchState: listViewState.fetchState,
79
+ error: listViewState.error,
80
+ version: 1.0,
81
+ };
82
+ });
@@ -1,20 +1 @@
1
- import { stringToUnion } from '../../../commonStateTypes/stringToUnion';
2
- export const ALL_INVOICING_PRODUCT_SORT_KEYS = [
3
- 'product_name',
4
- 'product_code',
5
- 'type',
6
- 'pricing',
7
- 'usage',
8
- 'updated',
9
- 'status',
10
- ];
11
- export const toInvoicingProductSortKey = (v) => stringToUnion(v, ALL_INVOICING_PRODUCT_SORT_KEYS);
12
- export const INVOICING_PRODUCT_COLUMNS = [
13
- { key: 'product_name', sortable: true },
14
- { key: 'product_code', sortable: true },
15
- { key: 'type', sortable: true },
16
- { key: 'pricing', sortable: false },
17
- { key: 'usage', sortable: true },
18
- { key: 'updated', sortable: true },
19
- { key: 'status', sortable: true },
20
- ];
1
+ export {};
@@ -1,10 +1,11 @@
1
1
  import { getInvoicingQboAccountMappingId, } from '../../../entity/invoicing/invoicingCommonPayload';
2
+ import { getAddressByAddressId } from '../../../entity/address/addressSelector';
2
3
  import { getFileByFileId } from '../../../entity/file/fileSelector';
3
4
  import { getFormattedAddress } from '../../addressView/addressViewSelector';
4
5
  import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
5
6
  import { getInvoicingQboView, isInvoicingAccountingPickerDataLoading, } from '../invoicingQboView/invoicingQboViewSelector';
6
7
  import { INVOICING_BUSINESS_ADDRESS_TYPE, entityToInvoicingBrandingFormLocalData, } from './invoicingBrandingFormConfig';
7
- import { initialInvoicingQboSettingsLocalData, } from './invoicingQboSettingsFormConfig';
8
+ import { entityToInvoicingQboSettingsLocalData, initialInvoicingQboSettingsLocalData, } from './invoicingQboSettingsFormConfig';
8
9
  /**
9
10
  * Shared primitive: the raw invoicing settings. Consumed internally by other
10
11
  * CES selectors (create-invoice, customer-detail, overview) and by non-settings
@@ -118,6 +119,7 @@ export const getInvoicingQboSettingsFormView = (state) => {
118
119
  fieldHelp: invoicingFieldHelpForGroup(state, 'settings'),
119
120
  accountMappingKindOptions: qboAccountMappingKindOptions,
120
121
  accounts: qboView.accounts,
122
+ savedLocalData: entityToInvoicingQboSettingsLocalData(settings?.qbo),
121
123
  backfillState: qboView.backfillState,
122
124
  connection: qboView.connection,
123
125
  configFetchState,
@@ -143,20 +145,27 @@ export const getInvoicingQboSettingsFormView = (state) => {
143
145
  };
144
146
  /**
145
147
  * Bundled view for the branding settings form: the draft `localData` (seeded
146
- * from the existing settings until the user edits), the business-address label
147
- * (from the shared Address screen, seeded on load from `address_id`), the raw
148
- * settings (for the logo/preview), the backend date-format choices and the
148
+ * from the existing settings until the user edits), the business address, the
149
+ * raw settings (for the logo/preview), the backend date-format choices and the
149
150
  * save fetch state.
151
+ *
152
+ * The address is resolved here rather than read from the Address screen's
153
+ * staging store alone: that store is only seeded when settings are fetched, and
154
+ * returning to this page does not refetch, so a saved address would otherwise
155
+ * have no way to reach the screen.
150
156
  */
151
157
  export const getInvoicingBrandingFormView = (state) => {
152
158
  const { brandingDraft, saveFetchState, settings } = state.invoicingSettingsViewState;
153
- const newAddress = state.addressViewState.newAddressState?.[INVOICING_BUSINESS_ADDRESS_TYPE];
154
- const addressLabel = newAddress?.addressToCreate != null
155
- ? getFormattedAddress(newAddress.addressToCreate)
156
- : undefined;
159
+ const savedAddressId = settings?.address?.address_id;
160
+ const address = state.addressViewState.newAddressState?.[INVOICING_BUSINESS_ADDRESS_TYPE]
161
+ ?.addressToCreate ??
162
+ (savedAddressId != null
163
+ ? getAddressByAddressId(state.addressState, savedAddressId)
164
+ : undefined);
157
165
  return {
158
166
  fieldHelp: invoicingFieldHelpForGroup(state, 'settings'),
159
- addressLabel,
167
+ address,
168
+ addressLabel: address != null ? getFormattedAddress(address) : undefined,
160
169
  dateFormatOptions: getInvoicingConfigView(state).dateFormatOptions,
161
170
  localData: brandingDraft ?? entityToInvoicingBrandingFormLocalData(settings),
162
171
  saveState: saveFetchState,
@@ -1,6 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { getAddressByAddressId } from '../../../entity/address/addressSelector';
4
5
  import { updateFiles } from '../../../entity/file/fileReducer';
5
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
6
7
  import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
@@ -16,7 +17,11 @@ export const submitInvoicingBrandingFormEpic = (actions$, state$, zeniAPI) => ac
16
17
  const state = state$.value;
17
18
  const { brandingDraft, settings } = state.invoicingSettingsViewState;
18
19
  const localData = brandingDraft ?? entityToInvoicingBrandingFormLocalData(settings);
19
- const address = state.addressViewState.newAddressState?.[INVOICING_BUSINESS_ADDRESS_TYPE]?.addressToCreate;
20
+ const savedAddressId = settings?.address?.address_id;
21
+ const address = state.addressViewState.newAddressState?.[INVOICING_BUSINESS_ADDRESS_TYPE]?.addressToCreate ??
22
+ (savedAddressId != null
23
+ ? getAddressByAddressId(state.addressState, savedAddressId)
24
+ : undefined);
20
25
  const data = brandingLocalDataToSettingsPayload(localData, address);
21
26
  const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
22
27
  return zeniAPI
@@ -37,7 +42,11 @@ export const submitInvoicingBrandingFormEpic = (actions$, state$, zeniAPI) => ac
37
42
  ? [updateFiles({ files: [savedLogoFile] })]
38
43
  : []),
39
44
  saveInvoicingSettingsSuccess(response.data),
40
- resetNewAddressDataInLocalStore(INVOICING_BUSINESS_ADDRESS_TYPE),
45
+ ...(savedAddress == null
46
+ ? [
47
+ resetNewAddressDataInLocalStore(INVOICING_BUSINESS_ADDRESS_TYPE),
48
+ ]
49
+ : []),
41
50
  ];
42
51
  }
43
52
  return of(saveInvoicingSettingsFailure(response.status));
@@ -16,7 +16,7 @@ import { toBusinessVerificationCompanyDataPayload, toBusinessVerificationOfficer
16
16
  import { updateCurrentStep, updateOnboardingCustomerView, updateOnboardingCustomerViewFailure, updateOnboardingCustomerViewLocalStoreData, updateOnboardingCustomerViewSuccess, } from '../../onboardingCustomerViewReducer';
17
17
  import { getOnboardingCustomerView } from '../../onboardingCustomerViewSelector';
18
18
  export const updateOnboardingCustomerViewEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(updateOnboardingCustomerView.match), mergeMap((action) => {
19
- const { companyId, officerType, sendForVerification, reCalculateCurrentStep = false, isBillingAddressUpdate, } = action.payload;
19
+ const { companyId, officerType, sendForVerification, reCalculateCurrentStep = false, isBillingAddressUpdate, businessProfile, } = action.payload;
20
20
  const { onboardingCustomerViewState } = state$.value;
21
21
  const { companyDetails, primaryContactDetails, companyOfficerUpdateStatus, currentStep, currentSubStep, } = onboardingCustomerViewState;
22
22
  const companyLocalData = companyDetails.localData;
@@ -28,12 +28,17 @@ export const updateOnboardingCustomerViewEpic = (actions$, state$, zeniAPI) => a
28
28
  }
29
29
  const { newAddressState } = state$.value.addressViewState;
30
30
  let payload = {};
31
+ const isSetupBillingSave = isBillingAddressUpdate === true || businessProfile != null;
31
32
  if (companyLocalData != null) {
32
- if (isBillingAddressUpdate === true &&
33
- newAddressState?.subscription_billing_address.addressToCreate != null) {
34
- payload = prepareEditBillingAddressPayload(companyLocalData, newAddressState.subscription_billing_address.addressToCreate);
35
- }
36
33
  const companyView = getCompanyView(state$.value, companyId, []);
34
+ const billingAddressToCreate = isBillingAddressUpdate === true
35
+ ? newAddressState?.subscription_billing_address.addressToCreate
36
+ : undefined;
37
+ if (billingAddressToCreate != null || businessProfile != null) {
38
+ payload = prepareEditBillingAddressPayload(companyLocalData, billingAddressToCreate, businessProfile != null
39
+ ? toBusinessProfilePayload(businessProfile, companyView?.company.company.incInfo)
40
+ : {});
41
+ }
37
42
  const companyAddressToCreate = newAddressState?.company_address?.addressToCreate;
38
43
  const registeredAddressToCreate = newAddressState?.company_registered_address?.addressToCreate;
39
44
  const addressType = officerType
@@ -56,7 +61,7 @@ export const updateOnboardingCustomerViewEpic = (actions$, state$, zeniAPI) => a
56
61
  // different payloads — currentSubStep is the source of truth here.
57
62
  const isOfficerSave = currentStep === 'verification' &&
58
63
  currentSubStep === 'company_officer';
59
- if (isBillingAddressUpdate === false) {
64
+ if (isBillingAddressUpdate === false && businessProfile == null) {
60
65
  if (isOfficerSave) {
61
66
  payload = {
62
67
  company: toBusinessVerificationMinimalCompanyDataPayload(companyLocalData),
@@ -70,7 +75,7 @@ export const updateOnboardingCustomerViewEpic = (actions$, state$, zeniAPI) => a
70
75
  };
71
76
  }
72
77
  }
73
- const section = isBillingAddressUpdate === true
78
+ const section = isSetupBillingSave
74
79
  ? 'setup_billing'
75
80
  : isOfficerSave
76
81
  ? 'company_officer'
@@ -85,12 +90,12 @@ export const updateOnboardingCustomerViewEpic = (actions$, state$, zeniAPI) => a
85
90
  save: 'onboarding_customer_business_verification_save',
86
91
  },
87
92
  setup_billing: {
88
- save: 'billing_address_view',
89
- sendForVerification: 'billing_address_view',
93
+ save: 'common',
94
+ sendForVerification: 'common',
90
95
  },
91
96
  };
92
97
  let messageSection;
93
- if (isBillingAddressUpdate === true) {
98
+ if (isSetupBillingSave) {
94
99
  messageSection = messageSectionMapper[section].save;
95
100
  }
96
101
  else if (sendForVerification === true) {
@@ -173,13 +178,28 @@ const toBusinessVerificationMinimalCompanyDataPayload = (companyLocalData) => {
173
178
  }
174
179
  return company;
175
180
  };
176
- const prepareEditBillingAddressPayload = (companyDetailsLocalData, address) => {
181
+ const toBusinessProfilePayload = (businessProfile, persistedIncInfo) => {
182
+ const isIndustryTypeChanged = businessProfile.companyIndustryType !==
183
+ persistedIncInfo?.companyIndustryType;
184
+ return {
185
+ company_business_model: businessProfile.companyBusinessModel,
186
+ company_industry_type: businessProfile.companyIndustryType,
187
+ // A sub-industry kept from the old industry would fail the backend subtype check on the next KYB save.
188
+ ...(isIndustryTypeChanged &&
189
+ persistedIncInfo?.companySubIndustry != null && {
190
+ company_industry_sub_type: null,
191
+ }),
192
+ };
193
+ };
194
+ const prepareEditBillingAddressPayload = (companyDetailsLocalData, address, businessProfilePayload) => {
177
195
  const { syncToken } = companyDetailsLocalData;
178
- const addressPayload = toAddressUpdatableInfoPayload(address);
179
196
  return {
180
197
  company: {
181
198
  sync_token: syncToken,
182
- subscription_billing_address: addressPayload,
199
+ ...(address != null && {
200
+ subscription_billing_address: toAddressUpdatableInfoPayload(address),
201
+ }),
202
+ ...businessProfilePayload,
183
203
  },
184
204
  };
185
205
  };
@@ -523,7 +523,7 @@ const onboardingCustomerView = createSlice({
523
523
  reducer(draft) {
524
524
  draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
525
525
  },
526
- prepare(companyId, sendForVerification, reCalculateCurrentStep, isBillingAddressUpdate, officerType) {
526
+ prepare(companyId, sendForVerification, reCalculateCurrentStep, isBillingAddressUpdate, officerType, businessProfile) {
527
527
  return {
528
528
  payload: {
529
529
  companyId,
@@ -531,6 +531,7 @@ const onboardingCustomerView = createSlice({
531
531
  reCalculateCurrentStep,
532
532
  isBillingAddressUpdate,
533
533
  officerType,
534
+ businessProfile,
534
535
  },
535
536
  };
536
537
  },
@@ -625,7 +625,7 @@ export const getDueDate = (billStageCode, dueDate, invoiceDate, bookCloseDate) =
625
625
  }
626
626
  };
627
627
  export const getWithdrawFrom = (state, fromAccountId, fromAccountType, companyId, lastSelectedFromAccount) => {
628
- const { paymentAccountState, depositAccountState, depositAccountListState, paymentAccountListState, } = state;
628
+ const { paymentAccountState, depositAccountState, paymentAccountListState } = state;
629
629
  if (fromAccountId != null) {
630
630
  const withdrawFromAsDepositAcc = getDepositAccountByDepositAccountId(depositAccountState, fromAccountId);
631
631
  const withdrawFromAsPaymentAcc = getPaymentAccountByPaymentAccountId(paymentAccountState, fromAccountId);
@@ -639,41 +639,15 @@ export const getWithdrawFrom = (state, fromAccountId, fromAccountType, companyId
639
639
  }
640
640
  }
641
641
  else {
642
- return getDefaultWithdrawFromAccount(state, depositAccountListState.accountIds, companyId ?? '', lastSelectedFromAccount);
642
+ return getDefaultWithdrawFromAccount(state, companyId ?? '', lastSelectedFromAccount);
643
643
  }
644
644
  return undefined;
645
645
  };
646
- export const getDefaultWithdrawFromAccount = (state, depositAccounts, companyId, lastSelectedFromAccount) => {
646
+ export const getDefaultWithdrawFromAccount = (state, companyId, lastSelectedFromAccount) => {
647
647
  const { depositAccountState, paymentAccountState, paymentAccountListState } = state;
648
648
  const companyView = getCompanyView(state, companyId, []);
649
649
  const primaryAccount = companyView?.company.company.companyBillPayInfo.primaryFundingAccount;
650
- let defaultAccount = undefined;
651
- // User paying bill for first time or previously paid with external account
652
- if (lastSelectedFromAccount == null ||
653
- lastSelectedFromAccount?.accountType === 'paymentAccount') {
654
- if (depositAccounts.length === 0) {
655
- defaultAccount = primaryAccount;
656
- }
657
- else {
658
- if (primaryAccount?.accountType === 'depositAccount') {
659
- defaultAccount = primaryAccount;
660
- }
661
- }
662
- }
663
- else {
664
- // User paid with Zeni account previously
665
- if (depositAccounts.length === 1) {
666
- defaultAccount = lastSelectedFromAccount;
667
- }
668
- else {
669
- if (primaryAccount?.accountType === 'depositAccount') {
670
- defaultAccount = primaryAccount;
671
- }
672
- else {
673
- defaultAccount = lastSelectedFromAccount;
674
- }
675
- }
676
- }
650
+ const defaultAccount = primaryAccount ?? lastSelectedFromAccount;
677
651
  if (defaultAccount != null) {
678
652
  const defaultAccAsDepositAcc = getDepositAccountByDepositAccountId(depositAccountState, defaultAccount?.accountId);
679
653
  const defaultAccAsPaymentAcc = getPaymentAccountByPaymentAccountId(paymentAccountState, defaultAccount?.accountId);
@@ -0,0 +1,37 @@
1
+ import { from } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
4
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
5
+ import { resetKycKyb, resetKycKybFailure, resetKycKybSuccess, } from '../../setupViewReducer';
6
+ export const resetKycKybEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(resetKycKyb.match), mergeMap(() => zeniAPI
7
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/kyc-kyb-reset`, { is_reset_company_officers: false })
8
+ .pipe(mergeMap((response) => {
9
+ if (isSuccessResponse(response)) {
10
+ return from([
11
+ resetKycKybSuccess(),
12
+ openSnackbar({
13
+ messageSection: 'kyc_kyb_reset',
14
+ messageText: 'success',
15
+ type: 'success',
16
+ }),
17
+ ]);
18
+ }
19
+ return from([
20
+ resetKycKybFailure(response.status),
21
+ openSnackbar({
22
+ messageSection: 'kyc_kyb_reset',
23
+ messageText: 'failed',
24
+ type: 'error',
25
+ }),
26
+ ]);
27
+ }), catchError((error) => from([
28
+ resetKycKybFailure(createZeniAPIStatus('Unexpected error', 'Reset KYC/KYB errored out: ' +
29
+ (error instanceof Error
30
+ ? error.message
31
+ : JSON.stringify(error)))),
32
+ openSnackbar({
33
+ messageSection: 'kyc_kyb_reset',
34
+ messageText: 'failed',
35
+ type: 'error',
36
+ }),
37
+ ])))));
@@ -13,6 +13,7 @@ const emptyOfficerSlot = {
13
13
  };
14
14
  export const initialState = {
15
15
  updateStatus: { fetchState: 'Not-Started', error: undefined },
16
+ kycKybResetStatus: { fetchState: 'Not-Started', error: undefined },
16
17
  parsingDocumentFileIds: [],
17
18
  companyDetails: { autoFilledFields: [] },
18
19
  companyOfficerUpdateStatus: {
@@ -84,6 +85,25 @@ const setupView = createSlice({
84
85
  };
85
86
  },
86
87
  },
88
+ resetKycKyb(draft) {
89
+ draft.kycKybResetStatus = { fetchState: 'In-Progress', error: undefined };
90
+ },
91
+ resetKycKybSuccess(draft) {
92
+ draft.kycKybResetStatus = { fetchState: 'Completed', error: undefined };
93
+ },
94
+ resetKycKybFailure: {
95
+ reducer(draft, action) {
96
+ draft.kycKybResetStatus = { fetchState: 'Error', error: action.payload };
97
+ },
98
+ prepare(error) {
99
+ return {
100
+ payload: error,
101
+ };
102
+ },
103
+ },
104
+ clearKycKybResetStatus(draft) {
105
+ draft.kycKybResetStatus = { fetchState: 'Not-Started', error: undefined };
106
+ },
87
107
  updateSelectedCompanyOfficer: {
88
108
  reducer(draft, action) {
89
109
  const { selectedOfficerType } = action.payload;
@@ -359,5 +379,5 @@ const setupView = createSlice({
359
379
  });
360
380
  },
361
381
  });
362
- export const { enableSetup, enableSetupSuccess, enableSetupFailure, updateBusinessVerificationDetails, updateBusinessVerificationDetailsSuccess, updateBusinessVerificationDetailsFailure, updateSelectedCompanyOfficer, updateSetupViewLocalStoreData, saveSetupViewDataInLocalStore, saveCompnayOfficerPhoneInLocalStore, saveCompnayOfficerAdditionalDocumentsInLocalStore, saveTreasuryAdditionalDocumentsInLocalStore, sendOtp: sendOtpSpendManagementSetUp, resendOtp: resendOtpSpendManagementSetUp, sendOtpSuccess: sendOtpSuccessSpendManagementSetUp, sendOtpFailure: sendOtpFailureSpendManagementSetUp, verifyOtp: verifyOtpSpendManagementSetUp, verifyOtpSuccess: verifyOtpSuccessSpendManagementSetUp, verifyOtpFailure: verifyOtpFailureSpendManagementSetUp, saveIndustryAndIncDateInLocalStore, clearSetupViewDataInLocalStore, applyKycDocumentAutofillForSetup, applyKybDocumentAutofillForSetup, clearKycKybAutofillForSetup, } = setupView.actions;
382
+ export const { enableSetup, enableSetupSuccess, enableSetupFailure, updateBusinessVerificationDetails, updateBusinessVerificationDetailsSuccess, updateBusinessVerificationDetailsFailure, resetKycKyb, resetKycKybSuccess, resetKycKybFailure, clearKycKybResetStatus, updateSelectedCompanyOfficer, updateSetupViewLocalStoreData, saveSetupViewDataInLocalStore, saveCompnayOfficerPhoneInLocalStore, saveCompnayOfficerAdditionalDocumentsInLocalStore, saveTreasuryAdditionalDocumentsInLocalStore, sendOtp: sendOtpSpendManagementSetUp, resendOtp: resendOtpSpendManagementSetUp, sendOtpSuccess: sendOtpSuccessSpendManagementSetUp, sendOtpFailure: sendOtpFailureSpendManagementSetUp, verifyOtp: verifyOtpSpendManagementSetUp, verifyOtpSuccess: verifyOtpSuccessSpendManagementSetUp, verifyOtpFailure: verifyOtpFailureSpendManagementSetUp, saveIndustryAndIncDateInLocalStore, clearSetupViewDataInLocalStore, applyKycDocumentAutofillForSetup, applyKybDocumentAutofillForSetup, clearKycKybAutofillForSetup, } = setupView.actions;
363
383
  export default setupView.reducer;
@@ -85,7 +85,7 @@ function getPrimaryAccountForTheProduct(state, companyId, setupViewType) {
85
85
  }
86
86
  export function getBusinessVerificationDetails(state, companyId) {
87
87
  const { setupViewState, countryListState } = state;
88
- const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, updateStatus, } = setupViewState;
88
+ const { companyDetails, companyOfficerUpdateStatus, kycKybResetStatus, primaryContactDetails, updateStatus, } = setupViewState;
89
89
  const companyView = getCompanyView(state, companyId, []);
90
90
  const { companyDetailsLocalData, companyOfficerLocalData, parsingDocumentFileIds, } = getCompanyAndIdentityDetails(state, companyId, {
91
91
  companyDetails,
@@ -100,6 +100,7 @@ export function getBusinessVerificationDetails(state, companyId) {
100
100
  parsingDocumentFileIds,
101
101
  companyView,
102
102
  updateStatus,
103
+ kycKybResetStatus,
103
104
  allNationalityCountries,
104
105
  };
105
106
  }