@zeniai/client-epic-state 5.0.81 → 5.0.82-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 (125) hide show
  1. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  2. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +2 -0
  3. package/lib/entity/account/accountSelector.d.ts +9 -0
  4. package/lib/entity/account/accountSelector.js +14 -1
  5. package/lib/entity/account/accountState.d.ts +1 -1
  6. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  7. package/lib/entity/class/classReducer.d.ts +4 -4
  8. package/lib/entity/class/classState.d.ts +1 -1
  9. package/lib/entity/company/companyPayload.d.ts +2 -0
  10. package/lib/entity/company/companyPayload.js +2 -0
  11. package/lib/entity/company/companyStateTypes.d.ts +2 -0
  12. package/lib/entity/forecast/forecastState.d.ts +1 -1
  13. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  14. package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
  15. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  16. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  17. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  18. package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
  19. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
  20. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  21. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  22. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  23. package/lib/entity/tenant/clearAllEpic.js +2 -0
  24. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  25. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  26. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  27. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  28. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  29. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  30. package/lib/entity/tenant/tenantPayload.d.ts +1 -0
  31. package/lib/entity/tenant/tenantReducer.d.ts +38 -25
  32. package/lib/entity/tenant/tenantReducer.js +65 -5
  33. package/lib/entity/tenant/tenantState.d.ts +1 -0
  34. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +4 -0
  35. package/lib/entity/transaction/payloadTypes/transactionPayload.js +18 -10
  36. package/lib/entity/transaction/stateTypes/transaction.d.ts +3 -0
  37. package/lib/epic.d.ts +6 -1
  38. package/lib/epic.js +7 -1
  39. package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +2 -0
  40. package/lib/esm/entity/account/accountSelector.js +11 -0
  41. package/lib/esm/entity/company/companyPayload.js +2 -0
  42. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
  43. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  44. package/lib/esm/entity/tenant/clearAllEpic.js +2 -0
  45. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  46. package/lib/esm/entity/tenant/tenantReducer.js +63 -3
  47. package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +18 -10
  48. package/lib/esm/epic.js +7 -1
  49. package/lib/esm/index.js +12 -8
  50. package/lib/esm/reducer.js +3 -0
  51. package/lib/esm/view/createTransferEntry/createTransferEntryReducer.js +82 -0
  52. package/lib/esm/view/createTransferEntry/createTransferEntrySelector.js +64 -0
  53. package/lib/esm/view/createTransferEntry/createTransferEntryState.js +17 -0
  54. package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +130 -0
  55. package/lib/esm/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +36 -0
  56. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +13 -1
  57. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +9 -1
  58. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
  59. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +93 -50
  60. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +49 -0
  61. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +58 -0
  62. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +12 -0
  63. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
  64. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +71 -52
  65. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
  66. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
  67. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +6 -1
  68. package/lib/index.d.ts +13 -8
  69. package/lib/index.js +56 -33
  70. package/lib/reducer.d.ts +3 -0
  71. package/lib/reducer.js +3 -0
  72. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  73. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  74. package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
  75. package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
  76. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  77. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  78. package/lib/view/createTransferEntry/createTransferEntryReducer.d.ts +32 -0
  79. package/lib/view/createTransferEntry/createTransferEntryReducer.js +86 -0
  80. package/lib/view/createTransferEntry/createTransferEntrySelector.d.ts +39 -0
  81. package/lib/view/createTransferEntry/createTransferEntrySelector.js +69 -0
  82. package/lib/view/createTransferEntry/createTransferEntryState.d.ts +30 -0
  83. package/lib/view/createTransferEntry/createTransferEntryState.js +20 -0
  84. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.d.ts +11 -0
  85. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +134 -0
  86. package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.d.ts +14 -0
  87. package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +40 -0
  88. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  89. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  90. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +3 -1
  91. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -2
  92. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +4 -1
  93. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -0
  94. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +11 -2
  95. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  96. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  97. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
  98. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
  99. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
  100. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +28 -3
  101. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +94 -51
  102. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +11 -0
  103. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  104. package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
  105. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +8 -0
  106. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +53 -0
  107. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +8 -0
  108. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +62 -0
  109. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +27 -0
  110. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +15 -0
  111. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
  112. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
  113. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +24 -2
  114. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +72 -53
  115. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +4 -0
  116. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
  117. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +12 -0
  118. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
  119. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
  120. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  121. package/lib/view/topEx/topExSelector.d.ts +1 -1
  122. package/lib/view/transactionDetail/transactionDetailPayload.d.ts +1 -1
  123. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +6 -1
  124. package/lib/view/transactionDetail/transactionDetailSelector.js +6 -1
  125. package/package.json +34 -62
@@ -5,6 +5,7 @@ import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
5
5
  import { isVendorTransaction } from '../../../entity/transaction/stateTypes/vendorTransaction';
6
6
  import { filterAutoTabLineItems, mergeTabSpecificLineItems, removeTransactionFromTabView, setEntityRecommendationForLineIdInLocalData, shouldAutoSelectAndAdd, toSetAllLineItemsToCategoryClass, toTransactionDetailLocalData, } from '../helpers/transactionCategorizationLocalDataHelper';
7
7
  import { DEFAULT_COMPLETED_SUB_TAB, } from '../types/completedSubTab';
8
+ import { TRANSACTIONS_TABS, } from '../types/transactionsViewState';
8
9
  export const initialTransactionTabViewState = {
9
10
  saveStatus: {
10
11
  fetchState: 'Not-Started',
@@ -1040,7 +1041,18 @@ const expenseAutomationTransactionsView = createSlice({
1040
1041
  };
1041
1042
  },
1042
1043
  },
1044
+ removeTransactionFromAllTabs: {
1045
+ prepare(transactionId) {
1046
+ return { payload: { transactionId } };
1047
+ },
1048
+ reducer(draft, action) {
1049
+ const { transactionId } = action.payload;
1050
+ for (const tab of TRANSACTIONS_TABS) {
1051
+ removeTransactionFromTabView(draft.transactionCategorizationView[tab], transactionId);
1052
+ }
1053
+ },
1054
+ },
1043
1055
  },
1044
1056
  });
1045
- export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, updateTransactionFilters, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, updateParentTotalCountForTab, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, markCategoryClassRecommendationsInProgressForCategorization, markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
1057
+ export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, updateTransactionFilters, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, updateParentTotalCountForTab, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, markCategoryClassRecommendationsInProgressForCategorization, markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, removeTransactionFromAllTabs, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
1046
1058
  export default expenseAutomationTransactionsView.reducer;
@@ -8,6 +8,7 @@ import { getSupportedTransactionsByIds } from '../../../entity/transaction/trans
8
8
  import { applyTransactionFilters, } from '../transactionFilterHelpers';
9
9
  import { getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
10
10
  import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
11
+ import { getResolvedTransferAccounts } from '../../createTransferEntry/createTransferEntrySelector';
11
12
  import { getProjectList } from '../../projectList/projectListSelector';
12
13
  import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
13
14
  // Walks the tab's transactionReviewLocalDataById map and returns
@@ -81,8 +82,11 @@ export const toTransactionView = (transaction, transactionLocalData) => {
81
82
  transactionLocalData,
82
83
  };
83
84
  };
85
+ // Re-exported here for back-compat. New code should import from
86
+ // `view/createTransferEntry/createTransferEntrySelector`.
87
+ export { getLastTransferEntryReplacement } from '../../createTransferEntry/createTransferEntrySelector';
84
88
  export function getExpenseAutomationTransactionView(state) {
85
- const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
89
+ const { accountState, classState, classListState, accountListState, createTransferEntryState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
86
90
  const { selectedTransactionCategorizationCompletedSubTab, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
87
91
  const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, filters, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
88
92
  const uncategorizedIncomeExpense = getUncategorizedAccounts(accountState, accountListState, 'accountList');
@@ -214,6 +218,7 @@ export function getExpenseAutomationTransactionView(state) {
214
218
  : [];
215
219
  const transactionCompletionStatus = allSteps.find((step) => step.step === 'transaction_categorization')?.completionStatus;
216
220
  const completionStatus = transactionCompletionStatus ?? 'incomplete';
221
+ const { transferAccountsList, creditCardTransferAccountsList } = getResolvedTransferAccounts(state);
217
222
  const inFlightCategoryClassRecommendationsByTransactionId = getCategorizationInFlightRecommendationsByTransactionId(state);
218
223
  const hasInFlightCategoryClassRecommendations = getCategorizationHasInFlightRecommendations(state);
219
224
  return {
@@ -238,6 +243,7 @@ export function getExpenseAutomationTransactionView(state) {
238
243
  refreshStatus,
239
244
  saveStatus,
240
245
  markAsNotMiscategorizedStatus,
246
+ createTransferEntryStatus: createTransferEntryState.createTransferEntryStatus,
241
247
  completionStatus,
242
248
  totalCountByTab,
243
249
  parentTabTotalCountByTab,
@@ -245,6 +251,8 @@ export function getExpenseAutomationTransactionView(state) {
245
251
  uploadReceiptStatusById,
246
252
  selectedTransactionId,
247
253
  selectedTransactionLineId,
254
+ creditCardTransferAccountsList,
255
+ transferAccounts: transferAccountsList,
248
256
  selectedTransactionCategorizationCompletedSubTab,
249
257
  };
250
258
  }
@@ -0,0 +1,40 @@
1
+ import { from, of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateCompanies } from '../../../../../entity/company/companyReducer';
4
+ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
6
+ import { acknowledgeOnboardingAiFinanceTeam, acknowledgeOnboardingAiFinanceTeamFailure, acknowledgeOnboardingAiFinanceTeamSuccess, } from '../../onboardingCustomerViewReducer';
7
+ export const acknowledgeOnboardingAiFinanceTeamEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(acknowledgeOnboardingAiFinanceTeam.match), mergeMap((action) => {
8
+ const { companyId } = action.payload;
9
+ const payload = {
10
+ is_onboarding_ai_finance_team_acknowledged: true,
11
+ };
12
+ return zeniAPI
13
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, payload)
14
+ .pipe(mergeMap((response) => {
15
+ if (isSuccessResponse(response) && response.data != null) {
16
+ const actions = [
17
+ updateCompanies({
18
+ payload: response.data.companies,
19
+ schema: {},
20
+ }),
21
+ acknowledgeOnboardingAiFinanceTeamSuccess(),
22
+ ];
23
+ return from(actions);
24
+ }
25
+ else {
26
+ return of(openSnackbar({
27
+ messageSection: 'onboarding_customer_view_complete',
28
+ messageText: 'failed',
29
+ type: 'error',
30
+ variables: [
31
+ {
32
+ variableName: '_api-error_',
33
+ variableValue: response.status.message,
34
+ },
35
+ ],
36
+ }), acknowledgeOnboardingAiFinanceTeamFailure(response.status));
37
+ }
38
+ }), catchError((error) => of(acknowledgeOnboardingAiFinanceTeamFailure(createZeniAPIStatus('Unexpected Error', 'Acknowledge - Onboarding AI Finance Team errored out' +
39
+ JSON.stringify(error))))));
40
+ }));
@@ -10,60 +10,29 @@ export const initialState = {
10
10
  dashboardLoadedStatus: initialStatus,
11
11
  currentStep: 'link_payment_account',
12
12
  companyDetails: {
13
+ autoFilledFields: [],
13
14
  localData: undefined,
14
15
  },
15
- companyOfficerUpdateStatus: {
16
- Officer_1: {
16
+ companyOfficerUpdateStatus: (() => {
17
+ const emptyOfficerSlot = {
18
+ autoFilledFields: [],
17
19
  localData: undefined,
18
20
  sendOtpStatus: initialStatus,
19
21
  otpverificationStatus: initialStatus,
20
- },
21
- Officer_2: {
22
- localData: undefined,
23
- sendOtpStatus: initialStatus,
24
- otpverificationStatus: initialStatus,
25
- },
26
- Officer_3: {
27
- localData: undefined,
28
- sendOtpStatus: initialStatus,
29
- otpverificationStatus: initialStatus,
30
- },
31
- Officer_4: {
32
- localData: undefined,
33
- sendOtpStatus: initialStatus,
34
- otpverificationStatus: initialStatus,
35
- },
36
- Officer_5: {
37
- localData: undefined,
38
- sendOtpStatus: initialStatus,
39
- otpverificationStatus: initialStatus,
40
- },
41
- Officer_6: {
42
- localData: undefined,
43
- sendOtpStatus: initialStatus,
44
- otpverificationStatus: initialStatus,
45
- },
46
- Officer_7: {
47
- localData: undefined,
48
- sendOtpStatus: initialStatus,
49
- otpverificationStatus: initialStatus,
50
- },
51
- Officer_8: {
52
- localData: undefined,
53
- sendOtpStatus: initialStatus,
54
- otpverificationStatus: initialStatus,
55
- },
56
- Officer_9: {
57
- localData: undefined,
58
- sendOtpStatus: initialStatus,
59
- otpverificationStatus: initialStatus,
60
- },
61
- Officer_10: {
62
- localData: undefined,
63
- sendOtpStatus: initialStatus,
64
- otpverificationStatus: initialStatus,
65
- },
66
- },
22
+ };
23
+ return {
24
+ Officer_1: { ...emptyOfficerSlot },
25
+ Officer_2: { ...emptyOfficerSlot },
26
+ Officer_3: { ...emptyOfficerSlot },
27
+ Officer_4: { ...emptyOfficerSlot },
28
+ Officer_5: { ...emptyOfficerSlot },
29
+ Officer_6: { ...emptyOfficerSlot },
30
+ Officer_7: { ...emptyOfficerSlot },
31
+ Officer_8: { ...emptyOfficerSlot },
32
+ Officer_9: { ...emptyOfficerSlot },
33
+ Officer_10: { ...emptyOfficerSlot },
34
+ };
35
+ })(),
67
36
  primaryContactDetails: {},
68
37
  paymentAccountDetails: {
69
38
  fetchStatus: initialStatus,
@@ -180,6 +149,38 @@ const onboardingCustomerView = createSlice({
180
149
  };
181
150
  },
182
151
  },
152
+ acknowledgeOnboardingAiFinanceTeam: {
153
+ reducer(draft) {
154
+ draft.aiFinanceTeamAcknowledgementStatus = {
155
+ fetchState: 'In-Progress',
156
+ error: undefined,
157
+ };
158
+ },
159
+ prepare(companyId) {
160
+ return {
161
+ payload: { companyId },
162
+ };
163
+ },
164
+ },
165
+ acknowledgeOnboardingAiFinanceTeamSuccess(draft) {
166
+ draft.aiFinanceTeamAcknowledgementStatus = {
167
+ fetchState: 'Completed',
168
+ error: undefined,
169
+ };
170
+ },
171
+ acknowledgeOnboardingAiFinanceTeamFailure: {
172
+ reducer(draft, action) {
173
+ draft.aiFinanceTeamAcknowledgementStatus = {
174
+ fetchState: 'Error',
175
+ error: action.payload,
176
+ };
177
+ },
178
+ prepare(error) {
179
+ return {
180
+ payload: error,
181
+ };
182
+ },
183
+ },
183
184
  updateOnboardingCustomerViewDashboardLoaded: {
184
185
  reducer(draft) {
185
186
  draft.dashboardLoadedStatus = {
@@ -592,7 +593,49 @@ const onboardingCustomerView = createSlice({
592
593
  clearOnboardingCustomerView(draft) {
593
594
  Object.assign(draft, initialState);
594
595
  },
596
+ /** Merge AI-parsed officer fields into the officer's onboarding localData. */
597
+ applyKycDocumentAutofillForOnboarding: {
598
+ reducer(draft, action) {
599
+ const { officerType, values, autoFilledFieldNames } = action.payload;
600
+ const slot = draft.companyOfficerUpdateStatus[officerType];
601
+ slot.localData = Object.assign({}, slot.localData, values);
602
+ slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
603
+ },
604
+ prepare(payload) {
605
+ return { payload };
606
+ },
607
+ },
608
+ /** Merge AI-parsed company fields into companyDetails onboarding localData. */
609
+ applyKybDocumentAutofillForOnboarding: {
610
+ reducer(draft, action) {
611
+ const { values, autoFilledFieldNames } = action.payload;
612
+ draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
613
+ const prev = draft.companyDetails.autoFilledFields ?? [];
614
+ draft.companyDetails.autoFilledFields = Array.from(new Set([...prev, ...autoFilledFieldNames]));
615
+ },
616
+ prepare(payload) {
617
+ return { payload };
618
+ },
619
+ },
620
+ /** Wipe AI-autofill badges during onboarding. */
621
+ clearKycKybAutofillForOnboarding: {
622
+ reducer(draft, action) {
623
+ const { officerType } = action.payload;
624
+ if (officerType != null) {
625
+ draft.companyOfficerUpdateStatus[officerType].autoFilledFields = [];
626
+ }
627
+ else {
628
+ draft.companyDetails.autoFilledFields = [];
629
+ Object.keys(draft.companyOfficerUpdateStatus).forEach((key) => {
630
+ draft.companyOfficerUpdateStatus[key].autoFilledFields = [];
631
+ });
632
+ }
633
+ },
634
+ prepare(payload = {}) {
635
+ return { payload };
636
+ },
637
+ },
595
638
  },
596
639
  });
597
- export const { fetchOnboardingCustomerView, fetchOnboardingCustomerSetupView, fetchOnboardingCustomerSetupViewSuccess, fetchOnboardingCustomerSetupViewFailure, updateOnboardingCustomerViewCompleteStatus, updateOnboardingCustomerViewCompleteStatusSuccess, updateOnboardingCustomerViewCompleteStatusFailure, updateOnboardingCustomerViewDashboardLoaded, updateOnboardingCustomerViewDashboardLoadedSuccess, updateOnboardingCustomerViewDashboardLoadedFailure, updateOnboardingCustomerView, updateOnboardingCustomerViewSuccess, updateOnboardingCustomerViewFailure, updateOnboardingPaymentAccountStatus, updateOnboardingPaymentAccountStatusSuccess, updateOnboardingPaymentAccountStatusFailure, updateOnboardingPaymentAccountLoginStatus, updateOnboardingPaymentAccountLoginStatusSuccess, updateOnboardingPaymentAccountLoginStatusFailure, establishOnboardingPlaidConnection, establishOnboardingPlaidConnectionSuccess, establishOnboardingPlaidConnectionFailure, getOnboardingPlaidLinkToken, getOnboardingPlaidLinkTokenSuccess, getOnboardingPlaidLinkTokenFailure, updateCurrentStep, updateOnboardingCustomerViewAccountDetails, updateOnboardingCustomerViewLocalStoreData, saveOnboardingCustomerViewDataInLocalStore, saveOnboardingCompnayOfficerPhoneInLocalStore, updateOnboardingCustomerViewUIState, sendOnboardingOfficerOtp, sendOnboardingOfficerOtpSuccess, sendOnboardingOfficerOtpFailure, resendOnboardingOfficerOtp, verifyOnboardingOfficerOtp, verifyOnboardingOfficerOtpSuccess, verifyOnboardingOfficerOtpFailure, clearOnboardingCustomerViewDataInLocalStore, clearOnboardingCustomerView, } = onboardingCustomerView.actions;
640
+ export const { fetchOnboardingCustomerView, fetchOnboardingCustomerSetupView, fetchOnboardingCustomerSetupViewSuccess, fetchOnboardingCustomerSetupViewFailure, updateOnboardingCustomerViewCompleteStatus, updateOnboardingCustomerViewCompleteStatusSuccess, updateOnboardingCustomerViewCompleteStatusFailure, acknowledgeOnboardingAiFinanceTeam, acknowledgeOnboardingAiFinanceTeamSuccess, acknowledgeOnboardingAiFinanceTeamFailure, updateOnboardingCustomerViewDashboardLoaded, updateOnboardingCustomerViewDashboardLoadedSuccess, updateOnboardingCustomerViewDashboardLoadedFailure, updateOnboardingCustomerView, updateOnboardingCustomerViewSuccess, updateOnboardingCustomerViewFailure, updateOnboardingPaymentAccountStatus, updateOnboardingPaymentAccountStatusSuccess, updateOnboardingPaymentAccountStatusFailure, updateOnboardingPaymentAccountLoginStatus, updateOnboardingPaymentAccountLoginStatusSuccess, updateOnboardingPaymentAccountLoginStatusFailure, establishOnboardingPlaidConnection, establishOnboardingPlaidConnectionSuccess, establishOnboardingPlaidConnectionFailure, getOnboardingPlaidLinkToken, getOnboardingPlaidLinkTokenSuccess, getOnboardingPlaidLinkTokenFailure, updateCurrentStep, updateOnboardingCustomerViewAccountDetails, updateOnboardingCustomerViewLocalStoreData, saveOnboardingCustomerViewDataInLocalStore, saveOnboardingCompnayOfficerPhoneInLocalStore, updateOnboardingCustomerViewUIState, sendOnboardingOfficerOtp, sendOnboardingOfficerOtpSuccess, sendOnboardingOfficerOtpFailure, resendOnboardingOfficerOtp, verifyOnboardingOfficerOtp, verifyOnboardingOfficerOtpSuccess, verifyOnboardingOfficerOtpFailure, clearOnboardingCustomerViewDataInLocalStore, clearOnboardingCustomerView, applyKycDocumentAutofillForOnboarding, applyKybDocumentAutofillForOnboarding, clearKycKybAutofillForOnboarding, } = onboardingCustomerView.actions;
598
641
  export default onboardingCustomerView.reducer;
@@ -0,0 +1,49 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { isSuccessResponse } from '../../../../../responsePayload';
4
+ import { applyKybDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
+ import { parseUploadedKybDocument } from '../../kycKybAutofillActions';
6
+ import { mapCoiToCompanyDetails, mapTaxEinToCompanyDetails, } from '../../kycKybParseMapper';
7
+ import { applyKybDocumentAutofillForSetup } from '../../setupViewReducer';
8
+ const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
9
+ export const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(parseUploadedKybDocument.match), mergeMap((action) => {
10
+ const { target, companyId, fileId, documentType } = action.payload;
11
+ const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
12
+ const requestPayload = {
13
+ provided_document_type: documentType,
14
+ files: [{ file_id: fileId }],
15
+ processing_priority: 10,
16
+ metadata: { source: 'kyc_kyb_autofill' },
17
+ };
18
+ return zeniAPI
19
+ .postAndGetJSON(url, requestPayload)
20
+ .pipe(mergeMap((response) => {
21
+ if (!isSuccessResponse(response) || response.data == null) {
22
+ return of();
23
+ }
24
+ let result;
25
+ switch (documentType) {
26
+ case 'certificate_of_incorporation':
27
+ result = mapCoiToCompanyDetails(response.data);
28
+ break;
29
+ case 'tax_ein':
30
+ result = mapTaxEinToCompanyDetails(response.data);
31
+ break;
32
+ }
33
+ if (result.autoFilledFieldNames.length === 0) {
34
+ return of();
35
+ }
36
+ const applyAction = target === 'setup'
37
+ ? applyKybDocumentAutofillForSetup({
38
+ companyId,
39
+ values: result.values,
40
+ autoFilledFieldNames: result.autoFilledFieldNames,
41
+ })
42
+ : applyKybDocumentAutofillForOnboarding({
43
+ companyId,
44
+ values: result.values,
45
+ autoFilledFieldNames: result.autoFilledFieldNames,
46
+ });
47
+ return of(applyAction);
48
+ }), catchError(() => of()));
49
+ }));
@@ -0,0 +1,58 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { getCountryList } from '../../../../../entity/countryList/countryListSelector';
4
+ import { isSuccessResponse } from '../../../../../responsePayload';
5
+ import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
6
+ import { parseUploadedKycDocument } from '../../kycKybAutofillActions';
7
+ import { mapDrivingLicenseToOfficer, mapPassportToOfficer, mapSsnCardToOfficer, } from '../../kycKybParseMapper';
8
+ import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
9
+ const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
10
+ export const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(parseUploadedKycDocument.match), mergeMap((action) => {
11
+ const { target, companyId, officerType, fileId, documentType } = action.payload;
12
+ const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
13
+ const requestPayload = {
14
+ provided_document_type: documentType,
15
+ files: [{ file_id: fileId }],
16
+ processing_priority: 10,
17
+ metadata: { source: 'kyc_kyb_autofill' },
18
+ };
19
+ return zeniAPI
20
+ .postAndGetJSON(url, requestPayload)
21
+ .pipe(mergeMap((response) => {
22
+ if (!isSuccessResponse(response) || response.data == null) {
23
+ return of();
24
+ }
25
+ const allCountries = getCountryList(state$.value.countryListState, 'nationalityCountryList').countries;
26
+ let result;
27
+ switch (documentType) {
28
+ case 'passport':
29
+ result = mapPassportToOfficer(response.data, allCountries);
30
+ break;
31
+ case 'driving_license':
32
+ result = mapDrivingLicenseToOfficer(response.data);
33
+ break;
34
+ case 'social_security_card':
35
+ result = mapSsnCardToOfficer(response.data);
36
+ break;
37
+ }
38
+ if (result.autoFilledFieldNames.length === 0) {
39
+ return of();
40
+ }
41
+ const applyAction = target === 'setup'
42
+ ? applyKycDocumentAutofillForSetup({
43
+ companyId,
44
+ officerType,
45
+ values: result.values,
46
+ autoFilledFieldNames: result.autoFilledFieldNames,
47
+ })
48
+ : applyKycDocumentAutofillForOnboarding({
49
+ companyId,
50
+ officerType,
51
+ values: result.values,
52
+ autoFilledFieldNames: result.autoFilledFieldNames,
53
+ });
54
+ return of(applyAction);
55
+ }), catchError(() =>
56
+ // Autofill is best-effort; swallow errors silently so the user can keep typing.
57
+ of()));
58
+ }));
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Trigger actions for the KYC / KYB autofill epics.
3
+ *
4
+ * These actions don't mutate state — the epic listens for them, calls
5
+ * document-communication-agent's sync endpoint, and dispatches the appropriate
6
+ * `applyKyc/KybDocumentAutofillFor{Setup,Onboarding}` against the matching
7
+ * slice. Co-located with the rest of the commonSetup module because the entire
8
+ * autofill flow is auxiliary to the setup view; there is no separate state.
9
+ */
10
+ import { createAction } from '@reduxjs/toolkit';
11
+ export const parseUploadedKycDocument = createAction('commonSetup/parseUploadedKycDocument');
12
+ export const parseUploadedKybDocument = createAction('commonSetup/parseUploadedKybDocument');
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Pure mappers from ExtendAI parser payloads to our form-side local-data shapes.
3
+ *
4
+ * Each mapper filters out fields below KYC_KYB_AUTOFILL_MIN_CONFIDENCE and returns
5
+ * both the merged values and the list of field names that were autofilled so the
6
+ * UI can show the ✦ AI badge next to each.
7
+ */
8
+ import { date } from '../../../zeniDayJS';
9
+ import { toZeniUrl } from '../../../zeniUrl';
10
+ import { KYC_KYB_AUTOFILL_MIN_CONFIDENCE, } from './types/kycKybAutofill';
11
+ const emptyResult = () => ({
12
+ values: {},
13
+ autoFilledFieldNames: [],
14
+ });
15
+ const isConfident = (field) => {
16
+ if (field == null) {
17
+ return false;
18
+ }
19
+ if (field.value == null) {
20
+ return false;
21
+ }
22
+ return field.confidence >= KYC_KYB_AUTOFILL_MIN_CONFIDENCE;
23
+ };
24
+ const assignAutofilledValue = (result, key, value) => {
25
+ if (value == null) {
26
+ return;
27
+ }
28
+ if (typeof value === 'string' && value.trim() === '') {
29
+ return;
30
+ }
31
+ result.values[key] = value;
32
+ result.autoFilledFieldNames.push(key);
33
+ };
34
+ const tryParseDate = (rawDate) => {
35
+ const parsedDate = date(rawDate);
36
+ if (parsedDate.isValid()) {
37
+ return parsedDate;
38
+ }
39
+ return undefined;
40
+ };
41
+ const normalizeNationality = (rawNationality, countries) => {
42
+ const needle = rawNationality.trim().toLowerCase();
43
+ if (needle === '') {
44
+ return undefined;
45
+ }
46
+ // Exact ISO-2 / ISO-3 match.
47
+ const isoMatch = countries.find((country) => country.countryCode.toLowerCase() === needle);
48
+ if (isoMatch != null) {
49
+ return isoMatch.countryCode;
50
+ }
51
+ // Common nationality adjectives map to country names (e.g. "American" → "United States").
52
+ const adjectiveToCountry = {
53
+ american: 'united states',
54
+ british: 'united kingdom',
55
+ indian: 'india',
56
+ canadian: 'canada',
57
+ australian: 'australia',
58
+ german: 'germany',
59
+ french: 'france',
60
+ chinese: 'china',
61
+ japanese: 'japan',
62
+ mexican: 'mexico',
63
+ brazilian: 'brazil',
64
+ };
65
+ const resolvedName = adjectiveToCountry[needle] ?? needle;
66
+ const nameMatch = countries.find((country) => country.countryName.toLowerCase() === resolvedName);
67
+ return nameMatch?.countryCode;
68
+ };
69
+ const splitFullName = (fullName) => {
70
+ const parts = fullName.trim().split(/\s+/);
71
+ if (parts.length === 1) {
72
+ return { firstName: parts[0], lastName: '' };
73
+ }
74
+ const lastName = parts[parts.length - 1];
75
+ const firstName = parts.slice(0, -1).join(' ');
76
+ return { firstName, lastName };
77
+ };
78
+ /** Passport → Company Officer. */
79
+ export const mapPassportToOfficer = (parsed, allNationalityCountries) => {
80
+ const result = emptyResult();
81
+ if (isConfident(parsed.first_name)) {
82
+ assignAutofilledValue(result, 'firstName', parsed.first_name.value);
83
+ }
84
+ if (isConfident(parsed.last_name)) {
85
+ assignAutofilledValue(result, 'lastName', parsed.last_name.value);
86
+ }
87
+ if (isConfident(parsed.date_of_birth)) {
88
+ const parsedDate = tryParseDate(parsed.date_of_birth.value);
89
+ if (parsedDate != null) {
90
+ assignAutofilledValue(result, 'birthday', parsedDate);
91
+ }
92
+ }
93
+ if (isConfident(parsed.nationality)) {
94
+ const isoCode = normalizeNationality(parsed.nationality.value, allNationalityCountries);
95
+ if (isoCode != null) {
96
+ assignAutofilledValue(result, 'nationalityCountryCode', isoCode);
97
+ }
98
+ }
99
+ return result;
100
+ };
101
+ /** Driving License → Company Officer. */
102
+ export const mapDrivingLicenseToOfficer = (parsed) => {
103
+ const result = emptyResult();
104
+ if (isConfident(parsed.first_name)) {
105
+ assignAutofilledValue(result, 'firstName', parsed.first_name.value);
106
+ }
107
+ if (isConfident(parsed.last_name)) {
108
+ assignAutofilledValue(result, 'lastName', parsed.last_name.value);
109
+ }
110
+ if (isConfident(parsed.date_of_birth)) {
111
+ const parsedDate = tryParseDate(parsed.date_of_birth.value);
112
+ if (parsedDate != null) {
113
+ assignAutofilledValue(result, 'birthday', parsedDate);
114
+ }
115
+ }
116
+ // address_* fields are mapped at a higher layer (addressView reducer) — kept here as values
117
+ // only, the consuming epic dispatches the address payload separately.
118
+ return result;
119
+ };
120
+ /** SSN Card → Company Officer (name only — SSN value not yet returned by parser). */
121
+ export const mapSsnCardToOfficer = (parsed) => {
122
+ const result = emptyResult();
123
+ if (isConfident(parsed.full_name)) {
124
+ const { firstName, lastName } = splitFullName(parsed.full_name.value);
125
+ if (firstName !== '') {
126
+ assignAutofilledValue(result, 'firstName', firstName);
127
+ }
128
+ if (lastName !== '') {
129
+ assignAutofilledValue(result, 'lastName', lastName);
130
+ }
131
+ }
132
+ return result;
133
+ };
134
+ /** Certificate of Incorporation → Company Details. */
135
+ export const mapCoiToCompanyDetails = (parsed) => {
136
+ const result = emptyResult();
137
+ if (isConfident(parsed.company_legal_name)) {
138
+ assignAutofilledValue(result, 'companyLegalName', parsed.company_legal_name.value);
139
+ }
140
+ if (isConfident(parsed.ein)) {
141
+ assignAutofilledValue(result, 'taxIdOrEIN', parsed.ein.value);
142
+ }
143
+ if (isConfident(parsed.phone_number)) {
144
+ assignAutofilledValue(result, 'phone', parsed.phone_number.value);
145
+ }
146
+ if (isConfident(parsed.product_description)) {
147
+ assignAutofilledValue(result, 'companyDescription', parsed.product_description.value);
148
+ }
149
+ if (isConfident(parsed.website)) {
150
+ try {
151
+ assignAutofilledValue(result, 'website', toZeniUrl(parsed.website.value));
152
+ }
153
+ catch {
154
+ // ignore — malformed URL string from OCR
155
+ }
156
+ }
157
+ if (isConfident(parsed.industry)) {
158
+ assignAutofilledValue(result, 'companyIndustryType', parsed.industry.value);
159
+ }
160
+ if (isConfident(parsed.sub_industry)) {
161
+ assignAutofilledValue(result, 'companySubIndustry', parsed.sub_industry.value);
162
+ }
163
+ if (isConfident(parsed.type_of_incorporation)) {
164
+ assignAutofilledValue(result, 'typeOfIncorporation', parsed.type_of_incorporation.value);
165
+ }
166
+ if (isConfident(parsed.date_of_incorporation)) {
167
+ const parsedDate = tryParseDate(parsed.date_of_incorporation.value);
168
+ if (parsedDate != null) {
169
+ assignAutofilledValue(result, 'incDate', parsedDate);
170
+ }
171
+ }
172
+ if (isConfident(parsed.state_of_incorporation)) {
173
+ assignAutofilledValue(result, 'stateOfIncorporation', parsed.state_of_incorporation.value);
174
+ }
175
+ if (isConfident(parsed.countries_of_operations)) {
176
+ assignAutofilledValue(result, 'countriesOfOperations', parsed.countries_of_operations.value);
177
+ }
178
+ if (isConfident(parsed.source_of_funds)) {
179
+ assignAutofilledValue(result, 'sourceOfFunds', parsed.source_of_funds.value);
180
+ }
181
+ if (isConfident(parsed.transaction_volume_expectations)) {
182
+ assignAutofilledValue(result, 'transactionVolume', parsed.transaction_volume_expectations.value);
183
+ }
184
+ if (isConfident(parsed.purpose_of_account)) {
185
+ assignAutofilledValue(result, 'purposeOfAccount', parsed.purpose_of_account.value);
186
+ }
187
+ if (isConfident(parsed.regulated_status)) {
188
+ assignAutofilledValue(result, 'regulatedStatus', parsed.regulated_status.value);
189
+ }
190
+ if (isConfident(parsed.us_nexus)) {
191
+ assignAutofilledValue(result, 'usNexus', parsed.us_nexus.value);
192
+ }
193
+ return result;
194
+ };
195
+ /** Tax EIN letter → Company Details. */
196
+ export const mapTaxEinToCompanyDetails = (parsed) => {
197
+ const result = emptyResult();
198
+ if (isConfident(parsed.legal_business_name)) {
199
+ assignAutofilledValue(result, 'companyLegalName', parsed.legal_business_name.value);
200
+ }
201
+ if (isConfident(parsed.ein)) {
202
+ assignAutofilledValue(result, 'taxIdOrEIN', parsed.ein.value);
203
+ }
204
+ return result;
205
+ };