@zeniai/client-epic-state 4.19.83 → 4.19.84-betaVR1

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 (113) hide show
  1. package/lib/entity/account/accountPayload.d.ts +2 -0
  2. package/lib/entity/account/accountPayload.js +2 -0
  3. package/lib/entity/account/accountState.d.ts +2 -0
  4. package/lib/entity/company/companyPayload.d.ts +13 -0
  5. package/lib/entity/company/companyPayload.js +21 -0
  6. package/lib/entity/company/companyStateTypes.d.ts +13 -0
  7. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  8. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  9. package/lib/epic.d.ts +12 -1
  10. package/lib/epic.js +12 -1
  11. package/lib/esm/entity/account/accountPayload.js +2 -0
  12. package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionPayload.js +2 -2
  13. package/lib/esm/entity/company/companyPayload.js +21 -0
  14. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  15. package/lib/esm/epic.js +12 -1
  16. package/lib/esm/index.js +12 -8
  17. package/lib/esm/view/companyView/epic/companyPassport/updateCompanyDetailsEpic.js +6 -0
  18. package/lib/esm/view/companyView/types/companyPassport/companyPassportLocalData.js +13 -0
  19. package/lib/esm/view/companyView/types/companyPassportViewPayload.js +55 -12
  20. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +24 -0
  21. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
  22. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
  23. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +47 -0
  24. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
  25. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +34 -0
  26. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +57 -0
  27. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +68 -0
  28. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  29. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +42 -0
  30. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/triggerReviewTabRefetchEpic.js +2 -3
  31. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +24 -0
  32. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  33. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +147 -1
  34. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +401 -1
  35. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +20 -1
  36. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +224 -1
  37. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  38. package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  39. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +22 -4
  40. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +2 -2
  41. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +2 -2
  42. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +4 -1
  43. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -1
  44. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +1 -1
  45. package/lib/esm/view/spendManagement/commonSetup/epic/setup/updateBusinessVerificationDetailsEpic.js +67 -1
  46. package/lib/esm/view/spendManagement/commonSetup/epic/setup/updateSetupViewLocalStoreDataEpic.js +16 -2
  47. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +15 -1
  48. package/lib/esm/view/spendManagement/commonSetup/types/businessVerification.js +148 -1
  49. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  50. package/lib/esm/zeniAPI.js +0 -2
  51. package/lib/index.d.ts +14 -9
  52. package/lib/index.js +87 -44
  53. package/lib/view/companyView/epic/companyPassport/updateCompanyDetailsEpic.js +6 -0
  54. package/lib/view/companyView/types/companyPassport/companyDetailsLocalData.d.ts +13 -0
  55. package/lib/view/companyView/types/companyPassport/companyPassportLocalData.js +13 -0
  56. package/lib/view/companyView/types/companyPassportViewPayload.d.ts +1 -1
  57. package/lib/view/companyView/types/companyPassportViewPayload.js +55 -12
  58. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +15 -0
  59. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +28 -0
  60. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
  61. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
  62. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
  63. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
  64. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
  65. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +51 -0
  66. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
  67. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
  68. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
  69. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +38 -0
  70. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
  71. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +62 -0
  72. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
  73. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +72 -0
  74. package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  75. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +13 -0
  76. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +47 -0
  77. package/lib/view/expenseAutomationView/epics/transactionCategorization/triggerReviewTabRefetchEpic.js +2 -3
  78. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +7 -0
  79. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +28 -0
  80. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  81. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -2
  82. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +107 -0
  83. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +158 -0
  84. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +70 -3
  85. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +403 -2
  86. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -3
  87. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +21 -2
  88. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +69 -1
  89. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -0
  90. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  91. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +223 -0
  92. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  93. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +124 -0
  94. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -1
  95. package/lib/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  96. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +1 -0
  97. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +22 -3
  98. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +2 -2
  99. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +2 -2
  100. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +4 -1
  101. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -1
  102. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.d.ts +1 -1
  103. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +1 -1
  104. package/lib/view/spendManagement/commonSetup/epic/setup/updateBusinessVerificationDetailsEpic.js +67 -1
  105. package/lib/view/spendManagement/commonSetup/epic/setup/updateSetupViewLocalStoreDataEpic.js +16 -2
  106. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +14 -0
  107. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +15 -1
  108. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +14 -0
  109. package/lib/view/spendManagement/commonSetup/types/businessVerification.d.ts +43 -0
  110. package/lib/view/spendManagement/commonSetup/types/businessVerification.js +150 -0
  111. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  112. package/lib/zeniAPI.js +0 -2
  113. package/package.json +2 -2
@@ -9,6 +9,8 @@ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
9
9
  const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
10
10
  const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
11
11
  const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
12
+ const missingReceiptsPayload_1 = require("../payload/missingReceiptsPayload");
13
+ const missingReceiptsViewReducer_1 = require("../reducers/missingReceiptsViewReducer");
12
14
  function getExpenseAutomationMissingReceiptsView(state) {
13
15
  const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
14
16
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
@@ -53,6 +55,110 @@ function getExpenseAutomationMissingReceiptsView(state) {
53
55
  const completionStatus = missingReceiptsCompletionStatus != null
54
56
  ? missingReceiptsCompletionStatus
55
57
  : 'incomplete';
58
+ const { bulkUpload, pendingMissingReceiptsTabNavigation, } = expenseAutomationMissingReceiptsViewState;
59
+ const currentBatchStatus = bulkUpload.currentBatchId != null
60
+ ? bulkUpload.batchStatusById[bulkUpload.currentBatchId]
61
+ : undefined;
62
+ const batchList = monthYearPeriodId != null
63
+ ? bulkUpload.batchListByPeriod[monthYearPeriodId] ?? []
64
+ : [];
65
+ /**
66
+ * Primary "Unmatched" batch = first completed batch in platform list order, preferring the
67
+ * first batch that still has un_matched/no_match work when any completed batch has such work.
68
+ * Batches without details yet: wait if the list row still reports unmatched work; otherwise skip
69
+ * so we do not block the whole tab while other rows are not fetched yet.
70
+ */
71
+ const primaryBatchIdFromDetailsOrder = getPrimaryBatchIdFromBatchListOrder(batchList, bulkUpload.batchDetailsById, bulkUpload.failedBatchDetailIds);
72
+ /** During upload/matching, the in-flight batch may not appear in batchList yet — prefer currentBatchId. */
73
+ const unmatchedSectionBatchId = bulkUpload.phase === 'matching' || bulkUpload.phase === 'uploading'
74
+ ? bulkUpload.currentBatchId ?? primaryBatchIdFromDetailsOrder
75
+ : primaryBatchIdFromDetailsOrder;
76
+ const completedBatchesInApiOrder = batchList.filter((b) => (0, missingReceiptsPayload_1.isBatchListStatusCompleted)(b.status));
77
+ const currentBatchDetails = unmatchedSectionBatchId != null
78
+ ? bulkUpload.batchDetailsById[unmatchedSectionBatchId]
79
+ : undefined;
80
+ const resolvedFiles = currentBatchDetails?.files.map((file) => resolveBatchFile(file, currentBatchDetails.batchId, transactionState));
81
+ const failedIds = new Set(bulkUpload.failedBatchDetailIds);
82
+ const hasMoreBatchDetails = completedBatchesInApiOrder.some((b) => bulkUpload.batchDetailsById[b.batchId] == null &&
83
+ !failedIds.has(b.batchId));
84
+ const getSortValue = (file) => {
85
+ const t = file.matchedTransaction;
86
+ if (t == null) {
87
+ return null;
88
+ }
89
+ switch (bulkUpload.sortKey) {
90
+ case 'vendor':
91
+ return (t.vendorName ?? t.description)?.toLowerCase() ?? null;
92
+ case 'category': {
93
+ const line = t.lines?.[0];
94
+ return line?.account?.accountName?.toLowerCase() ?? null;
95
+ }
96
+ case 'class': {
97
+ const line = t.lines?.[0];
98
+ return line?.class?.className?.toLowerCase() ?? null;
99
+ }
100
+ case 'date':
101
+ return t.date.valueOf();
102
+ case 'amount':
103
+ return t.amount.amount;
104
+ default:
105
+ return null;
106
+ }
107
+ };
108
+ const bulkUploadSortDirection = bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc';
109
+ const matchedFiles = (0, orderBy_1.default)(resolvedFiles?.filter((f) => f.status === 'matched') ?? [], getSortValue, bulkUploadSortDirection);
110
+ const unmatchedFiles = (0, orderBy_1.default)(resolvedFiles?.filter((f) => f.status === 'un_matched' || f.status === 'no_match') ?? [], getSortValue, bulkUploadSortDirection);
111
+ const progress = currentBatchStatus != null
112
+ ? {
113
+ ...currentBatchStatus.progress,
114
+ percentage: currentBatchStatus.progress.total > 0
115
+ ? Math.round((currentBatchStatus.progress.processed /
116
+ currentBatchStatus.progress.total) *
117
+ 100)
118
+ : 0,
119
+ }
120
+ : { total: 0, processed: 0, percentage: 0 };
121
+ const batchListFetchState = bulkUpload.batchListFetchState;
122
+ /**
123
+ * When primary batch is not resolved yet, still aggregate unmatched files from every batch
124
+ * that has details loaded (otherwise past is empty and receipts vanish from the UI).
125
+ */
126
+ const pastBatches = unmatchedSectionBatchId != null
127
+ ? batchList.filter((b) => b.batchId !== unmatchedSectionBatchId)
128
+ : batchList;
129
+ const pastUnmatchedFiles = pastBatches.flatMap((b) => {
130
+ const details = bulkUpload.batchDetailsById[b.batchId];
131
+ if (details == null) {
132
+ return [];
133
+ }
134
+ return details.files
135
+ .filter((f) => f.status === 'un_matched' || f.status === 'no_match')
136
+ .map((f) => resolveBatchFile(f, b.batchId, transactionState));
137
+ });
138
+ const completedTransactionsCacheKey = monthYearPeriodId != null
139
+ ? (0, missingReceiptsViewReducer_1.getCompletedTransactionsCacheKey)(monthYearPeriodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab)
140
+ : undefined;
141
+ const completedTransactionsForPeriod = completedTransactionsCacheKey != null
142
+ ? bulkUpload.completedTransactionsByPeriod[completedTransactionsCacheKey]
143
+ : undefined;
144
+ const completedTransactionIds = completedTransactionsForPeriod?.transactionIds ?? [];
145
+ const resolvedCompletedTransactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, completedTransactionIds);
146
+ const resolvedBatchDetails = currentBatchDetails != null && resolvedFiles != null
147
+ ? {
148
+ batchId: currentBatchDetails.batchId,
149
+ createdAt: currentBatchDetails.createdAt,
150
+ files: resolvedFiles,
151
+ status: currentBatchDetails.status,
152
+ summary: currentBatchDetails.summary,
153
+ }
154
+ : undefined;
155
+ const manualSearchResults = bulkUpload.manualSearch.results.map((r) => {
156
+ const t = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, r.transactionId);
157
+ return {
158
+ ...r,
159
+ vendorLogo: r.vendorLogo ?? t?.logo?.href,
160
+ };
161
+ });
56
162
  return {
57
163
  fetchState,
58
164
  error,
@@ -61,5 +167,122 @@ function getExpenseAutomationMissingReceiptsView(state) {
61
167
  refreshStatus,
62
168
  transactions: sortedTransactions,
63
169
  completionStatus,
170
+ pendingMissingReceiptsTabNavigation: pendingMissingReceiptsTabNavigation ?? null,
171
+ bulkUpload: {
172
+ phase: bulkUpload.phase,
173
+ uploadStatus: bulkUpload.uploadStatus,
174
+ batchStatus: currentBatchStatus,
175
+ batchDetails: resolvedBatchDetails,
176
+ completedSubTab: bulkUpload.completedSubTab,
177
+ completedTransactions: {
178
+ fetchState: completedTransactionsForPeriod?.fetchState ?? {
179
+ fetchState: 'Not-Started',
180
+ error: undefined,
181
+ },
182
+ nextPageToken: completedTransactionsForPeriod?.nextPageToken ?? null,
183
+ totalCount: completedTransactionsForPeriod?.totalCount ?? 0,
184
+ transactions: resolvedCompletedTransactions,
185
+ },
186
+ matchedFiles,
187
+ unmatchedFiles,
188
+ progress,
189
+ currentResultsTab: bulkUpload.currentResultsTab,
190
+ sortKey: bulkUpload.sortKey,
191
+ sortOrder: bulkUpload.sortOrder,
192
+ batchList,
193
+ batchListFetchState,
194
+ pastBatches,
195
+ pastUnmatchedFiles,
196
+ confirmMatchStatus: bulkUpload.confirmMatchStatus,
197
+ manualSearchUiResetKey: bulkUpload.manualSearchUiResetKey,
198
+ hasMoreBatchDetails,
199
+ batchDetailsPaginationState: bulkUpload.batchDetailsPaginationState,
200
+ manualSearch: {
201
+ ...bulkUpload.manualSearch,
202
+ results: manualSearchResults,
203
+ },
204
+ uploadProgress: bulkUpload.uploadProgress,
205
+ },
206
+ };
207
+ }
208
+ function batchDetailsHasUnmatchedWork(details) {
209
+ return details.files.some((f) => f.status === 'un_matched' || f.status === 'no_match');
210
+ }
211
+ /** List row summary before batch details load — aligns with unmatched / possible-match work. */
212
+ function batchListItemHasUnmatchedWork(batch) {
213
+ return batch.noMatchCount > 0 || batch.possibleMatchesCount > 0;
214
+ }
215
+ /**
216
+ * `batchList` must match platform order (same sequence as the bulk-upload batches API). Picks the
217
+ * primary batch for the top "Unmatched" section. Skips failed detail fetches.
218
+ *
219
+ * If details are not loaded for an earlier list row but that row reports no unmatched work, we
220
+ * skip it so later rows with loaded details can be primary (avoids an empty tab when the first
221
+ * fetch page only loaded later batches). If the list reports unmatched work but details are still
222
+ * loading, we wait (undefined) so primary order stays correct once details arrive.
223
+ */
224
+ function getPrimaryBatchIdFromBatchListOrder(batchListInPlatformOrder, batchDetailsById, failedBatchDetailIds) {
225
+ const failedIds = new Set(failedBatchDetailIds);
226
+ const anyCompletedBatchHasUnmatchedWork = batchListInPlatformOrder.some((b) => {
227
+ if (failedIds.has(b.batchId)) {
228
+ return false;
229
+ }
230
+ const d = batchDetailsById[b.batchId];
231
+ if (d != null &&
232
+ d.status === 'completed' &&
233
+ batchDetailsHasUnmatchedWork(d)) {
234
+ return true;
235
+ }
236
+ return d == null && batchListItemHasUnmatchedWork(b);
237
+ });
238
+ for (const batch of batchListInPlatformOrder) {
239
+ if (failedIds.has(batch.batchId)) {
240
+ continue;
241
+ }
242
+ const details = batchDetailsById[batch.batchId];
243
+ if (details == null) {
244
+ if (batchListItemHasUnmatchedWork(batch)) {
245
+ return undefined;
246
+ }
247
+ continue;
248
+ }
249
+ if (details.status !== 'completed') {
250
+ continue;
251
+ }
252
+ if (anyCompletedBatchHasUnmatchedWork) {
253
+ if (batchDetailsHasUnmatchedWork(details)) {
254
+ return batch.batchId;
255
+ }
256
+ continue;
257
+ }
258
+ return batch.batchId;
259
+ }
260
+ return undefined;
261
+ }
262
+ function resolveBatchFile(file, batchId, transactionState) {
263
+ const matchedTransaction = file.matchedTransactionId != null
264
+ ? (0, transactionSelector_1.getSupportedTransactionById)(transactionState, file.matchedTransactionId)
265
+ : undefined;
266
+ const candidates = file.candidates
267
+ ?.map((ref) => {
268
+ const transaction = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, ref.transactionId);
269
+ return transaction != null
270
+ ? { transaction, matchScore: ref.matchScore }
271
+ : undefined;
272
+ })
273
+ .filter((c) => c != null);
274
+ return {
275
+ attachmentId: file.attachmentId,
276
+ batchId,
277
+ fileDownloadUrl: file.fileDownloadUrl,
278
+ fileId: file.fileId,
279
+ filename: file.filename,
280
+ filePreviewUrl: file.filePreviewUrl,
281
+ status: file.status,
282
+ matchedTransaction,
283
+ candidates: candidates != null && candidates.length > 0
284
+ ? candidates
285
+ : undefined,
286
+ matchSource: file.matchSource,
64
287
  };
65
288
  }
@@ -16,7 +16,7 @@ const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAu
16
16
  function getExpenseAutomationTransactionView(state) {
17
17
  const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
18
18
  const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
19
- const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
19
+ const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
20
20
  const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(accountState, accountListState, 'accountList');
21
21
  const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
22
22
  const classList = (0, classListSelector_1.getClassList)(classState, classListState);
@@ -100,6 +100,7 @@ function getExpenseAutomationTransactionView(state) {
100
100
  completionStatus,
101
101
  totalCountByTab,
102
102
  fetchStateByTransactionTabs: fetchStateByTab,
103
+ uploadReceiptStatusById,
103
104
  selectedTransactionId,
104
105
  selectedTransactionLineId,
105
106
  };
@@ -3,6 +3,7 @@ import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderType
3
3
  import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
4
4
  export declare const toMissingReceiptsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class";
5
5
  export type MissingReceiptsSortKey = ReturnType<typeof toMissingReceiptsSortKey>;
6
+ export type BulkUploadSortKey = 'amount' | 'category' | 'class' | 'date' | 'vendor';
6
7
  export interface MissingReceiptsViewUIState {
7
8
  scrollPosition: {
8
9
  scrollTop: number;
@@ -12,7 +13,130 @@ export interface MissingReceiptsViewUIState {
12
13
  sortKey: MissingReceiptsSortKey;
13
14
  sortOrder: SortOrder;
14
15
  }
16
+ export type BatchStatusValue = 'pending' | 'processing' | 'completed';
17
+ export type BatchFileStatus = 'matched' | 'un_matched' | 'no_match' | 'failed';
18
+ export type BulkUploadPhase = 'idle' | 'uploading' | 'matching' | 'completed';
19
+ export type BulkUploadResultsTab = 'completed' | 'unmatched';
20
+ export type MissingReceiptsTab = 'missing' | BulkUploadResultsTab;
21
+ export type CompletedSubTab = 'all' | 'ai_accountant' | 'manual';
22
+ export type MatchSource = 'ai' | 'manual';
23
+ export interface CandidateRef {
24
+ matchScore: number;
25
+ transactionId: ID;
26
+ }
27
+ export interface MatchCandidate {
28
+ amount: number;
29
+ currencyCode: string;
30
+ matchScore: number;
31
+ transactionDate: string;
32
+ transactionId: ID;
33
+ transactionType: string;
34
+ vendorName: string;
35
+ vendorLogo?: string;
36
+ }
37
+ export interface BatchFile {
38
+ attachmentId: ID;
39
+ fileDownloadUrl: string | null;
40
+ fileId: ID;
41
+ filename: string;
42
+ filePreviewUrl: string | null;
43
+ status: BatchFileStatus;
44
+ candidates?: CandidateRef[];
45
+ matchedTransactionId?: ID;
46
+ matchSource?: MatchSource;
47
+ }
48
+ export interface BatchSummary {
49
+ failed: number;
50
+ matched: number;
51
+ noMatch: number;
52
+ possibleMatches: number;
53
+ total: number;
54
+ }
55
+ export interface BatchStatus {
56
+ batchId: ID;
57
+ progress: {
58
+ processed: number;
59
+ total: number;
60
+ };
61
+ status: BatchStatusValue;
62
+ }
63
+ export interface BatchDetails {
64
+ batchId: ID;
65
+ createdAt: string;
66
+ files: BatchFile[];
67
+ status: BatchStatusValue;
68
+ summary: BatchSummary;
69
+ }
70
+ export interface BatchListItem {
71
+ batchId: ID;
72
+ createdAt: string;
73
+ failedCount: number;
74
+ matchedCount: number;
75
+ noMatchCount: number;
76
+ possibleMatchesCount: number;
77
+ status: string;
78
+ totalFiles: number;
79
+ }
80
+ export interface ManualSearchResult {
81
+ amount: number;
82
+ currencyCode: string;
83
+ entityId: string;
84
+ memo: string;
85
+ transactionDate: string;
86
+ transactionId: ID;
87
+ transactionType: string;
88
+ vendorName: string;
89
+ /** Present when API/merged transaction state supplies a logo URL. */
90
+ vendorLogo?: string;
91
+ }
92
+ export interface ManualSearchState {
93
+ fetchState: FetchStateAndError;
94
+ /** True while appending the next page (initial search uses fetchState only). */
95
+ isLoadingMore: boolean;
96
+ nextPageToken: string | null;
97
+ pageSize: number;
98
+ results: ManualSearchResult[];
99
+ searchQuery: string;
100
+ totalCount: number;
101
+ }
102
+ export type CompletedTransactionsMatchType = 'all' | 'ai_accountant' | 'manual';
103
+ export interface CompletedTransactionsState {
104
+ fetchState: FetchStateAndError;
105
+ nextPageToken: string | null;
106
+ totalCount: number;
107
+ transactionIds: ID[];
108
+ }
109
+ export interface BulkUploadState {
110
+ batchDetailsById: Record<ID, BatchDetails>;
111
+ batchDetailsPaginationState: FetchStateAndError;
112
+ batchListByPeriod: Record<MonthYearPeriodId, BatchListItem[]>;
113
+ batchListFetchState: FetchStateAndError;
114
+ batchStatusById: Record<ID, BatchStatus>;
115
+ completedSubTab: CompletedSubTab;
116
+ completedTransactionsByPeriod: Record<string, CompletedTransactionsState>;
117
+ confirmMatchStatus: FetchStateAndError;
118
+ currentResultsTab: BulkUploadResultsTab;
119
+ failedBatchDetailIds: ID[];
120
+ /**
121
+ * Incremented when manual search Redux state is cleared so Unmatched `ManualSearchInput`
122
+ * instances remount and drop local query text.
123
+ */
124
+ manualSearch: ManualSearchState;
125
+ manualSearchUiResetKey: number;
126
+ phase: BulkUploadPhase;
127
+ sortKey: BulkUploadSortKey;
128
+ sortOrder: SortOrder;
129
+ uploadProgress: number;
130
+ uploadStatus: FetchStateAndError;
131
+ currentBatchId?: ID;
132
+ }
15
133
  export interface MissingReceiptsViewState extends FetchedState {
134
+ bulkUpload: BulkUploadState;
135
+ /**
136
+ * When set, the app shell should switch the Missing Receipts sub-tab (e.g. to Unmatched)
137
+ * once, then clear via `clearMissingReceiptsTabNavigation`.
138
+ */
139
+ pendingMissingReceiptsTabNavigation: BulkUploadResultsTab | null;
16
140
  refreshStatus: FetchStateAndError;
17
141
  transactionIdsBySelectedPeriod: Record<MonthYearPeriodId, ID[]>;
18
142
  uiState: MissingReceiptsViewUIState;
@@ -15,7 +15,7 @@ import { VendorBase } from '../../../entity/vendor/vendorState';
15
15
  import { ZeniDate } from '../../../zeniDayJS';
16
16
  import { EntityRecommendationKey } from '../../recommendation/recommendationState';
17
17
  import { TransactionDetailKey } from '../../transactionDetail/transactionDetailState';
18
- export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class" | "memo" | "transaction_type";
18
+ export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class" | "payment_account" | "transaction_type" | "memo_and_receipt";
19
19
  export type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
20
20
  export declare const TRANSACTIONS_TABS: readonly ["review", "autoCategorized"];
21
21
  export declare const toTransactionsTabKey: (v: string) => "review" | "autoCategorized";
@@ -97,6 +97,7 @@ export interface TransactionsTabViewState extends FetchedState {
97
97
  transactionIdsWithUnsavedData: ID[];
98
98
  transactionReviewLocalDataById: Record<ID | TransactionDetailKey, SupportedTransactionCategorization>;
99
99
  uiState: TransactionsViewUIState;
100
+ uploadReceiptStatusById: Record<ID, FetchStateAndError>;
100
101
  selectedTransactionId?: ID;
101
102
  selectedTransactionLineId?: ID;
102
103
  }
@@ -7,10 +7,11 @@ const TRANSACTIONS_SORT_KEYS = [
7
7
  'vendor',
8
8
  'amount',
9
9
  'transaction_type',
10
+ 'payment_account',
10
11
  'date',
11
12
  'category',
12
13
  'class',
13
- 'memo',
14
+ 'memo_and_receipt',
14
15
  ];
15
16
  const toTransactionsSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, TRANSACTIONS_SORT_KEYS);
16
17
  exports.toTransactionsSortKey = toTransactionsSortKey;
@@ -53,4 +53,5 @@ export declare const onboardingStepsData: (isValidConnection: boolean, productSe
53
53
  allStepsData: OnboardingStep[];
54
54
  requiredStepsData: OnboardingStep[];
55
55
  };
56
+ export declare function isCompanyDetailsSavePending(fileState: FileState, company?: CompanyView, primaryContact?: User, companyDetailsLocalData?: CompanyDetails): boolean;
56
57
  export declare const getProductSettingsString: (productSettings: TenantProductSettings | undefined) => string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProductSettingsString = exports.onboardingStepsData = void 0;
4
4
  exports.getOnboardingCustomerView = getOnboardingCustomerView;
5
5
  exports.isOfficerDetailsCompleted = isOfficerDetailsCompleted;
6
+ exports.isCompanyDetailsSavePending = isCompanyDetailsSavePending;
6
7
  const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
7
8
  const fileSelector_1 = require("../../../entity/file/fileSelector");
8
9
  const paymentAccountSelector_1 = require("../../../entity/paymentAccount/paymentAccountSelector");
@@ -229,12 +230,12 @@ function isCompanyDetailsSavePending(fileState, company, primaryContact, company
229
230
  return false;
230
231
  }
231
232
  const { companyInfo, incInfo, taxInfo, questionaire } = company.company.company;
232
- const { companyDescription, companyLegalName, companyUrl, phone } = companyInfo;
233
- const { fileIds, companyIncDate: incDate, companyIncType } = incInfo;
233
+ const { companyDescription, companyLegalName, companyUrl, phone, companySourceOfFunds, companySourceOfFundsDescription, countriesOfOperations, transactionVolume, transactionVolumeDescription, purposeOfAccount, purposeOfAccountDescription, regulatedStatus, regulatedStatusDescription, usNexus, usNexusTypes, } = companyInfo;
234
+ const { fileIds, companyIncDate: incDate, companyIncState, companyIncType, companySubIndustry, } = incInfo;
234
235
  const { companyIndustry } = questionaire;
235
236
  const { taxId } = taxInfo;
236
237
  const companyFileIds = (0, fileSelector_1.getFilesByFileIds)(fileState, fileIds).map((file) => file.fileId);
237
- const { companyDescription: companyDescriptionLocalData, companyIndustry: companyIndustryLocalData, companyLegalName: companyLegalNameLocalData, taxIdOrEIN: taxIdLocalData, incDate: incDateLocalData, phone: companyPhoneLocalData, website: companyUrlLocalData, companyFiles: companyFilesLocalData, typeOfIncorporation: companyIncTypeLocalData, primaryContactLocalData, } = companyDetailsLocalData;
238
+ const { companyDescription: companyDescriptionLocalData, companyIndustry: companyIndustryLocalData, companyLegalName: companyLegalNameLocalData, taxIdOrEIN: taxIdLocalData, incDate: incDateLocalData, phone: companyPhoneLocalData, website: companyUrlLocalData, companyFiles: companyFilesLocalData, stateOfIncorporation: stateOfIncorporationLocalData, typeOfIncorporation: companyIncTypeLocalData, companySourceOfFunds: companySourceOfFundsLocalData, companySourceOfFundsDescription: companySourceOfFundsDescriptionLocalData, countriesOfOperations: countriesOfOperationsLocalData, companySubIndustry: companySubIndustryLocalData, transactionVolume: transactionVolumeLocalData, transactionVolumeDescription: transactionVolumeDescriptionLocalData, purposeOfAccount: purposeOfAccountLocalData, purposeOfAccountDescription: purposeOfAccountDescriptionLocalData, regulatedStatus: regulatedStatusLocalData, regulatedStatusDescription: regulatedStatusDescriptionLocalData, usNexus: usNexusLocalData, usNexusTypes: usNexusTypesLocalData, primaryContactLocalData, } = companyDetailsLocalData;
238
239
  const fileIdsLocalData = companyFilesLocalData.map((file) => file.fileId);
239
240
  if (primaryContact != null) {
240
241
  const { firstName, lastName, email } = primaryContact;
@@ -244,6 +245,10 @@ function isCompanyDetailsSavePending(fileState, company, primaryContact, company
244
245
  return true;
245
246
  }
246
247
  }
248
+ const countriesOfOperationsMatch = JSON.stringify(countriesOfOperations ?? []) ===
249
+ JSON.stringify(countriesOfOperationsLocalData ?? []);
250
+ const usNexusTypesMatch = JSON.stringify(usNexusTypes ?? []) ===
251
+ JSON.stringify(usNexusTypesLocalData ?? []);
247
252
  return (companyDescription != companyDescriptionLocalData ||
248
253
  companyIndustry != companyIndustryLocalData ||
249
254
  companyLegalName != companyLegalNameLocalData ||
@@ -251,7 +256,21 @@ function isCompanyDetailsSavePending(fileState, company, primaryContact, company
251
256
  incDate?.toString() != incDateLocalData?.toString() ||
252
257
  phone != companyPhoneLocalData ||
253
258
  companyUrl?.toString() != companyUrlLocalData?.toString() ||
259
+ companyIncState != stateOfIncorporationLocalData ||
260
+ companySourceOfFunds != companySourceOfFundsLocalData ||
261
+ companySourceOfFundsDescription !=
262
+ companySourceOfFundsDescriptionLocalData ||
263
+ !countriesOfOperationsMatch ||
254
264
  companyIncType != companyIncTypeLocalData ||
265
+ transactionVolume != transactionVolumeLocalData ||
266
+ transactionVolumeDescription != transactionVolumeDescriptionLocalData ||
267
+ purposeOfAccount != purposeOfAccountLocalData ||
268
+ purposeOfAccountDescription != purposeOfAccountDescriptionLocalData ||
269
+ regulatedStatus != regulatedStatusLocalData ||
270
+ regulatedStatusDescription != regulatedStatusDescriptionLocalData ||
271
+ usNexus != usNexusLocalData ||
272
+ !usNexusTypesMatch ||
273
+ companySubIndustry != companySubIndustryLocalData ||
255
274
  !(fileIdsLocalData.length === companyFileIds.length &&
256
275
  companyFileIds.every((fileId) => fileIdsLocalData.includes(fileId))));
257
276
  }
@@ -5,8 +5,8 @@ const chargeCardRepaymentSelector_1 = require("../../../../entity/chargeCardRepa
5
5
  const userSelector_1 = require("../../../../entity/user/userSelector");
6
6
  const chargeCardPaymentHistoryHelpers_1 = require("./chargeCardPaymentHistoryHelpers");
7
7
  const getChargeCardPaymentHistoryDownloadReport = (state) => {
8
- const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState, } = state;
9
- const { filters, repaymentHistoryIds, searchText, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
8
+ const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState } = state;
9
+ const { filters, repaymentHistoryIds, searchText, uiState, fetchState, error } = chargeCardPaymentHistoryState;
10
10
  const repaymentHistory = (0, chargeCardRepaymentSelector_1.getChargeCardRepaymentByIds)(chargeCardRepaymentState, repaymentHistoryIds);
11
11
  const repaymentHistoryUserIds = Array.from(new Set(repaymentHistory.map((r) => r.paidById)));
12
12
  const repaymentHistoryUsers = (0, userSelector_1.getUsersByUserIds)(userState, repaymentHistoryUserIds);
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getChargeCardPaymentHistoryView = void 0;
4
4
  const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
5
5
  const chargeCardRepaymentSelector_1 = require("../../../../entity/chargeCardRepayment/chargeCardRepaymentSelector");
6
- const userSelector_1 = require("../../../../entity/user/userSelector");
7
- const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
8
6
  const depositAccountSelector_1 = require("../../../../entity/depositAccount/depositAccountSelector");
9
7
  const paymentAccountSelector_1 = require("../../../../entity/paymentAccount/paymentAccountSelector");
8
+ const userSelector_1 = require("../../../../entity/user/userSelector");
9
+ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
10
10
  const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
11
11
  const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
12
12
  const chargeCardPaymentHistoryHelpers_1 = require("./chargeCardPaymentHistoryHelpers");
@@ -18,7 +18,10 @@ const getChargeCardRepaymentDetail = (state) => {
18
18
  else {
19
19
  const depositFundingFromLimit = Object.values(depositAccountState.depositAccountLimitForChargeCardByID ?? {}).map(setupViewSelector_1.mapDepositAccountWithLimitToFundingAccount);
20
20
  const paymentFundingAccounts = (0, setupViewSelector_1.getAllFundingAccounts)([], paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
21
- transferFromAccounts = [...depositFundingFromLimit, ...paymentFundingAccounts];
21
+ transferFromAccounts = [
22
+ ...depositFundingFromLimit,
23
+ ...paymentFundingAccounts,
24
+ ];
22
25
  }
23
26
  }
24
27
  const reducedFetchState = (0, reduceFetchState_1.reduceAnyCompletedFetchState)([
@@ -10,7 +10,8 @@ const fetchChargeCardRepaymentDetailEpic = (actions$, state$) => actions$.pipe((
10
10
  const fetchChargeCardRepaymentDetailActions = [];
11
11
  const state = state$.value;
12
12
  const depositAccounts = state.depositAccountListState;
13
- const willFetchDeposit = depositAccounts.fetchState !== 'In-Progress' && depositAccounts.fetchState !== 'Completed';
13
+ const willFetchDeposit = depositAccounts.fetchState !== 'In-Progress' &&
14
+ depositAccounts.fetchState !== 'Completed';
14
15
  if (willFetchDeposit) {
15
16
  fetchChargeCardRepaymentDetailActions.push((0, depositAccountListReducer_1.fetchDepositAccountList)());
16
17
  }
@@ -4,8 +4,8 @@ import { updateChargeCardRepayment } from '../../../../entity/chargeCardRepaymen
4
4
  import { updateCompanyPrimaryAccount, updateEnableAutoPayForChargeCard } from '../../../../entity/company/companyReducer';
5
5
  import { RootState } from '../../../../reducer';
6
6
  import { ZeniAPI } from '../../../../zeniAPI';
7
- import { addRepaymentToChargeCardPaymentHistory } from '../chargeCardPaymentHistory/chargeCardPaymentHistoryReducer';
8
7
  import { updateCreditAccountRepaymentAmountAndDate } from '../chargeCardList/chargeCardListReducer';
8
+ import { addRepaymentToChargeCardPaymentHistory } from '../chargeCardPaymentHistory/chargeCardPaymentHistoryReducer';
9
9
  import { initiateChargeCardRepayment, updateChargeCardRepaymentStatus } from './chargeCardRepaymentDetailReducer';
10
10
  export type ActionType = ReturnType<typeof addRepaymentToChargeCardPaymentHistory> | ReturnType<typeof initiateChargeCardRepayment> | ReturnType<typeof updateChargeCardRepayment> | ReturnType<typeof updateCreditAccountRepaymentAmountAndDate> | ReturnType<typeof updateChargeCardRepaymentStatus> | ReturnType<typeof updateCompanyPrimaryAccount> | ReturnType<typeof updateEnableAutoPayForChargeCard>;
11
11
  export declare const initiateChargeCardRepaymentEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -12,8 +12,8 @@ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
12
12
  const helpers_1 = require("../../helpers");
13
13
  const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
14
14
  const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
15
- const chargeCardPaymentHistoryReducer_1 = require("../chargeCardPaymentHistory/chargeCardPaymentHistoryReducer");
16
15
  const chargeCardListReducer_1 = require("../chargeCardList/chargeCardListReducer");
16
+ const chargeCardPaymentHistoryReducer_1 = require("../chargeCardPaymentHistory/chargeCardPaymentHistoryReducer");
17
17
  const chargeCardRepaymentDetailReducer_1 = require("./chargeCardRepaymentDetailReducer");
18
18
  const initiateChargeCardRepaymentEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(chargeCardRepaymentDetailReducer_1.initiateChargeCardRepayment.match), (0, operators_1.switchMap)((action) => {
19
19
  const state = state$.value;
@@ -122,8 +122,28 @@ const updateBusinessVerificationDetailsEpic = (actions$, state$, zeniAPI) => act
122
122
  }
123
123
  }));
124
124
  exports.updateBusinessVerificationDetailsEpic = updateBusinessVerificationDetailsEpic;
125
+ /** US Nexus API keys. Form may submit these or display labels; we send keys to API. */
126
+ const US_NEXUS_KEYS = new Set([
127
+ 'employees',
128
+ 'customers',
129
+ 'physical_office',
130
+ 'banking_relationships',
131
+ ]);
132
+ /** Maps display label → API key for US nexus types (English labels from strings). */
133
+ const US_NEXUS_LABEL_TO_KEY = {
134
+ Employees: 'employees',
135
+ Customers: 'customers',
136
+ 'Physical office or facility': 'physical_office',
137
+ 'Banking relationships': 'banking_relationships',
138
+ };
139
+ function toUsNexusTypeKey(value) {
140
+ if (US_NEXUS_KEYS.has(value)) {
141
+ return value;
142
+ }
143
+ return US_NEXUS_LABEL_TO_KEY[value] ?? value;
144
+ }
125
145
  const toBusinessVerificationCompanyDataPayload = (companyLocalData, sendForVerification, companyAddressData, registeredAddressData, setupViewType) => {
126
- const { companyDescription, companyLegalName, companyIndustry, website, incDate, taxIdOrEIN, phone, syncToken, fileIds, typeOfIncorporation, sourceOfFunds, } = companyLocalData;
146
+ const { companyDescription, companyLegalName, companyIndustry, companyIndustryType, companySubIndustry, countriesOfOperations, companySourceOfFunds, companySourceOfFundsDescription, transactionVolume, transactionVolumeDescription, purposeOfAccount, purposeOfAccountDescription, regulatedStatus, regulatedStatusDescription, usNexus, usNexusTypes, website, incDate, taxIdOrEIN, phone, syncToken, fileIds, typeOfIncorporation, stateOfIncorporation, sourceOfFunds, } = companyLocalData;
127
147
  const company = {
128
148
  is_ready_for_verification: sendForVerification,
129
149
  file_ids: fileIds,
@@ -174,9 +194,55 @@ const toBusinessVerificationCompanyDataPayload = (companyLocalData, sendForVerif
174
194
  if (typeOfIncorporation != null) {
175
195
  company['company_inc_type'] = typeOfIncorporation;
176
196
  }
197
+ if (stateOfIncorporation != null) {
198
+ company['company_inc_state'] = stateOfIncorporation;
199
+ }
177
200
  if (companyIndustry != null) {
178
201
  company['company_industry'] = companyIndustry;
179
202
  }
203
+ Object.assign(company, {
204
+ ...(companyIndustryType != null && {
205
+ company_industry_type: companyIndustryType,
206
+ }),
207
+ ...(companySubIndustry != null && {
208
+ company_industry_sub_type: companySubIndustry,
209
+ }),
210
+ ...(countriesOfOperations != null &&
211
+ countriesOfOperations.length > 0 && {
212
+ company_countries_of_operations: countriesOfOperations,
213
+ }),
214
+ ...(companySourceOfFunds != null && {
215
+ company_source_of_funds: companySourceOfFunds,
216
+ }),
217
+ ...(companySourceOfFundsDescription != null && {
218
+ company_source_of_funds_desc: companySourceOfFundsDescription,
219
+ }),
220
+ ...(transactionVolume != null && {
221
+ company_transaction_vol_expectations: transactionVolume,
222
+ }),
223
+ ...(transactionVolumeDescription != null && {
224
+ company_transaction_vol_expectations_desc: transactionVolumeDescription,
225
+ }),
226
+ ...(purposeOfAccount != null && {
227
+ company_purpose_of_account: purposeOfAccount,
228
+ }),
229
+ ...(purposeOfAccountDescription != null && {
230
+ company_purpose_of_account_desc: purposeOfAccountDescription,
231
+ }),
232
+ ...(regulatedStatus != null && {
233
+ company_regulated_states: regulatedStatus === 'yes',
234
+ }),
235
+ ...(regulatedStatusDescription != null && {
236
+ company_regulated_states_desc: regulatedStatusDescription,
237
+ }),
238
+ ...(usNexus != null && {
239
+ company_us_nexus: usNexus === 'yes',
240
+ }),
241
+ ...(usNexusTypes != null &&
242
+ usNexusTypes.length > 0 && {
243
+ company_us_nexus_desc: usNexusTypes.map(toUsNexusTypeKey),
244
+ }),
245
+ });
180
246
  if (setupViewType === 'zeni_treasury' && sourceOfFunds != null) {
181
247
  company['source_of_funds'] = sourceOfFunds;
182
248
  }