@zeniai/client-epic-state 4.20.4 → 4.20.6

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 (168) hide show
  1. package/lib/commonStateTypes/coaBalance/additionalBalances/getSummationBalance.d.ts +1 -1
  2. package/lib/commonStateTypes/coaBalance/coaBalanceType.d.ts +0 -2
  3. package/lib/commonStateTypes/coaBalance/coaBalanceType.js +0 -6
  4. package/lib/commonStateTypes/currencyHelper.d.ts +0 -3
  5. package/lib/commonStateTypes/currencyHelper.js +1 -6
  6. package/lib/commonStateTypes/reduceFetchState.d.ts +0 -9
  7. package/lib/commonStateTypes/reduceFetchState.js +0 -26
  8. package/lib/entity/account/accountPayload.d.ts +0 -2
  9. package/lib/entity/account/accountPayload.js +0 -2
  10. package/lib/entity/account/accountState.d.ts +0 -2
  11. package/lib/entity/customer/customerState.d.ts +2 -0
  12. package/lib/entity/customer/customerState.js +5 -0
  13. package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
  14. package/lib/entity/depositAccount/depositAccount.js +1 -8
  15. package/lib/entity/reimbursement/reimbursementPayload.d.ts +0 -2
  16. package/lib/entity/reimbursement/reimbursementPayload.js +0 -7
  17. package/lib/entity/reimbursement/reimbursementState.d.ts +0 -2
  18. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  19. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  20. package/lib/entity/task/taskPayload.d.ts +0 -1
  21. package/lib/entity/task/taskPayload.js +0 -1
  22. package/lib/entity/task/taskState.d.ts +0 -1
  23. package/lib/epic.d.ts +1 -12
  24. package/lib/epic.js +1 -12
  25. package/lib/esm/commonStateTypes/coaBalance/coaBalanceType.js +0 -5
  26. package/lib/esm/commonStateTypes/currencyHelper.js +0 -5
  27. package/lib/esm/commonStateTypes/reduceFetchState.js +0 -25
  28. package/lib/esm/entity/account/accountPayload.js +0 -2
  29. package/lib/esm/entity/customer/customerState.js +4 -1
  30. package/lib/esm/entity/depositAccount/depositAccount.js +1 -8
  31. package/lib/esm/entity/reimbursement/reimbursementPayload.js +0 -7
  32. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  33. package/lib/esm/entity/task/taskPayload.js +0 -1
  34. package/lib/esm/epic.js +1 -12
  35. package/lib/esm/index.js +10 -19
  36. package/lib/esm/reducer.js +0 -6
  37. package/lib/esm/view/arAgingView/arAgingReport/arAgingReducer.js +1 -1
  38. package/lib/esm/view/arAgingView/arAgingReport/arAgingSelector.js +1 -1
  39. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +5 -7
  40. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +1 -189
  41. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -433
  42. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -23
  43. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +1 -244
  44. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -2
  45. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -44
  46. package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +1 -2
  47. package/lib/esm/view/financeStatement/financeStatementReducer.js +8 -11
  48. package/lib/esm/view/financeStatement/financeStatementSelector.js +9 -24
  49. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +1 -6
  50. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +29 -2
  51. package/lib/esm/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +5 -7
  52. package/lib/esm/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +7 -9
  53. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  54. package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +0 -1
  55. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +1 -3
  56. package/lib/esm/view/twoFactorAuthentication/resendOtpEpic.js +16 -2
  57. package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +0 -11
  58. package/lib/esm/zeniAPI.js +2 -0
  59. package/lib/index.d.ts +12 -20
  60. package/lib/index.js +34 -94
  61. package/lib/reducer.d.ts +0 -6
  62. package/lib/reducer.js +0 -6
  63. package/lib/view/arAgingView/arAgingReport/arAgingReducer.js +2 -2
  64. package/lib/view/arAgingView/arAgingReport/arAgingSelector.js +5 -5
  65. package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +5 -7
  66. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  67. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +0 -118
  68. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -201
  69. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +3 -76
  70. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -434
  71. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +3 -11
  72. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -24
  73. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -69
  74. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -1
  75. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  76. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -243
  77. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -2
  78. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +0 -142
  79. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -54
  80. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -2
  81. package/lib/view/expenseAutomationView/types/transactionsViewState.js +1 -2
  82. package/lib/view/financeStatement/financeStatementReducer.js +8 -11
  83. package/lib/view/financeStatement/financeStatementSelector.d.ts +0 -2
  84. package/lib/view/financeStatement/financeStatementSelector.js +9 -24
  85. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +2 -4
  86. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +2 -7
  87. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +29 -2
  88. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +0 -4
  89. package/lib/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +5 -7
  90. package/lib/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +6 -8
  91. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  92. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +0 -1
  93. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +0 -1
  94. package/lib/view/taskManager/taskListView/taskListSelector.d.ts +0 -2
  95. package/lib/view/taskManager/taskListView/taskListSelector.js +1 -3
  96. package/lib/view/twoFactorAuthentication/resendOtpEpic.d.ts +1 -1
  97. package/lib/view/twoFactorAuthentication/resendOtpEpic.js +15 -1
  98. package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +1 -3
  99. package/lib/view/userListView/fetchUserListByTypeEpic.js +0 -11
  100. package/lib/view/userListView/userListViewPayload.d.ts +0 -2
  101. package/lib/zeniAPI.js +2 -0
  102. package/package.json +3 -3
  103. package/lib/entity/userGroups/userGroupsPayload.d.ts +0 -7
  104. package/lib/entity/userGroups/userGroupsPayload.js +0 -10
  105. package/lib/entity/userGroups/userGroupsReducer.d.ts +0 -8
  106. package/lib/entity/userGroups/userGroupsReducer.js +0 -29
  107. package/lib/entity/userGroups/userGroupsSelector.d.ts +0 -4
  108. package/lib/entity/userGroups/userGroupsSelector.js +0 -12
  109. package/lib/entity/userGroups/userGroupsState.d.ts +0 -9
  110. package/lib/entity/userGroups/userGroupsState.js +0 -2
  111. package/lib/esm/entity/userGroups/userGroupsPayload.js +0 -7
  112. package/lib/esm/entity/userGroups/userGroupsReducer.js +0 -25
  113. package/lib/esm/entity/userGroups/userGroupsSelector.js +0 -8
  114. package/lib/esm/entity/userGroups/userGroupsState.js +0 -1
  115. package/lib/esm/view/expenseAutomationView/bulkUploadTiming.js +0 -10
  116. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -29
  117. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -49
  118. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -40
  119. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -47
  120. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -61
  121. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -33
  122. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -56
  123. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -77
  124. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -79
  125. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +0 -24
  126. package/lib/esm/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +0 -17
  127. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +0 -331
  128. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +0 -9
  129. package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +0 -262
  130. package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +0 -65
  131. package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +0 -16
  132. package/lib/esm/view/userGroupListView/userGroupListViewState.js +0 -1
  133. package/lib/view/expenseAutomationView/bulkUploadTiming.d.ts +0 -10
  134. package/lib/view/expenseAutomationView/bulkUploadTiming.js +0 -13
  135. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +0 -18
  136. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -33
  137. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +0 -7
  138. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -53
  139. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +0 -8
  140. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -44
  141. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +0 -7
  142. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -51
  143. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +0 -8
  144. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -65
  145. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +0 -8
  146. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -37
  147. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +0 -9
  148. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -61
  149. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +0 -14
  150. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -81
  151. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +0 -25
  152. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -85
  153. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +0 -7
  154. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +0 -28
  155. package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.d.ts +0 -9
  156. package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +0 -20
  157. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +0 -15
  158. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +0 -335
  159. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +0 -111
  160. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +0 -13
  161. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +0 -6
  162. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +0 -265
  163. package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +0 -23
  164. package/lib/view/userGroupListView/userGroupListViewReducer.js +0 -69
  165. package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +0 -7
  166. package/lib/view/userGroupListView/userGroupListViewSelector.js +0 -20
  167. package/lib/view/userGroupListView/userGroupListViewState.d.ts +0 -8
  168. package/lib/view/userGroupListView/userGroupListViewState.js +0 -2
@@ -58,7 +58,6 @@ import toastNotification, { initialState as initialToastNotificationState, } fro
58
58
  import transaction, { initialState as initialTransactionState, } from './entity/transaction/transactionReducer';
59
59
  import transactionActivityLog, { initialState as initialTransactionActivityLogState, } from './entity/transactionActivityLog/transactionActivityLogReducer';
60
60
  import user, { initialState as initialUserState, } from './entity/user/userReducer';
61
- import userGroups, { initialState as initialUserGroupsState, } from './entity/userGroups/userGroupsReducer';
62
61
  import userRole, { initialState as initialUserRoleState, } from './entity/userRole/userRoleReducer';
63
62
  import vendor, { initialState as initialVendorState, } from './entity/vendor/vendorReducer';
64
63
  import vendorExpense, { initialState as initialVendorExpenseState, } from './entity/vendorExpense/vendorExpenseReducer';
@@ -199,7 +198,6 @@ import trend, { initialTrendState } from './view/trend/trendReducer';
199
198
  import trendWithTransactions, { initialTrendWithTransactionsState, } from './view/trendWithTransactions/trendWithTransactionsReducer';
200
199
  import twoFactorAuthentication, { initialState as initialTwoFactorAuthenticationState, } from './view/twoFactorAuthentication/twoFactorAuthenticationReducer';
201
200
  import userFinancialAccountState, { initialState as initialUserFinancialAccountState, } from './view/userFinancialAccount/userFinancialAccountReducer';
202
- import userGroupListView, { initialState as initialUserGroupListViewState, } from './view/userGroupListView/userGroupListViewReducer';
203
201
  import userListView, { initialState as initialUserListViewState, } from './view/userListView/userListViewReducer';
204
202
  import userRoleConfig, { initialState as initialUserRoleConfigState, } from './view/userRoleConfigView/userRoleConfigReducer';
205
203
  import vendor1099TypeList, { initialState as initialVendor1099TypeListState, } from './view/vendor1099TypeList/vendor1099TypeListReducer';
@@ -272,7 +270,6 @@ const initialEntitiesState = {
272
270
  toastNotificationState: initialToastNotificationState,
273
271
  transactionActivityLogState: initialTransactionActivityLogState,
274
272
  transactionState: initialTransactionState,
275
- userGroupsState: initialUserGroupsState,
276
273
  userRoleState: initialUserRoleState,
277
274
  userState: initialUserState,
278
275
  vendorExpenseState: initialVendorExpenseState,
@@ -411,7 +408,6 @@ const initialViewsState = {
411
408
  trendWithTransactionsState: initialTrendWithTransactionsState,
412
409
  twoFactorAuthenticationState: initialTwoFactorAuthenticationState,
413
410
  userFinancialAccountState: initialUserFinancialAccountState,
414
- userGroupListViewState: initialUserGroupListViewState,
415
411
  userListViewState: initialUserListViewState,
416
412
  userRoleConfigState: initialUserRoleConfigState,
417
413
  vendorFirstReviewViewState: initialVendorFirstReviewViewState,
@@ -496,7 +492,6 @@ const entityReducers = {
496
492
  toastNotificationState: toastNotification,
497
493
  transactionActivityLogState: transactionActivityLog,
498
494
  transactionState: transaction,
499
- userGroupsState: userGroups,
500
495
  userRoleState: userRole,
501
496
  userState: user,
502
497
  vendorExpenseState: vendorExpense,
@@ -635,7 +630,6 @@ const viewReducers = {
635
630
  trendWithTransactionsState: trendWithTransactions,
636
631
  twoFactorAuthenticationState: twoFactorAuthentication,
637
632
  userFinancialAccountState: userFinancialAccountState,
638
- userGroupListViewState: userGroupListView,
639
633
  userListViewState: userListView,
640
634
  userRoleConfigState: userRoleConfig,
641
635
  vendorFirstReviewViewState: vendorFirstReviewView,
@@ -1,9 +1,9 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { mapReportPayloadV2ToReportV2 } from '../../../commonPayloadTypes/v2/viewAndReportPayloadv2';
3
3
  import { getAgingBalancesKey, toAgingPeriod, } from '../../../commonStateTypes/agingBalance/agingBalance';
4
- import { defaultCustomerCurrency } from '../../../commonStateTypes/currencyHelper';
5
4
  import { getNestedCustomerHierarchy } from '../../../commonStateTypes/customerView/getNestedCustomerHierarchy';
6
5
  import { toCustomer } from '../../../entity/customer/customerPayload';
6
+ import { defaultCustomerCurrency } from '../../../entity/customer/customerState';
7
7
  import { dateNow } from '../../../zeniDayJS';
8
8
  import { toArAgingDataByCustomerId, toArAgingTotals, } from './arAgingPayload';
9
9
  export const inititalUIState = {
@@ -1,8 +1,8 @@
1
1
  import { createSelector } from '@reduxjs/toolkit';
2
2
  import orderBy from 'lodash/orderBy';
3
3
  import { getAgingBalancesKey, } from '../../../commonStateTypes/agingBalance/agingBalance';
4
- import { defaultCustomerCurrency } from '../../../commonStateTypes/currencyHelper';
5
4
  import { getCustomer } from '../../../entity/customer/customerSelector';
5
+ import { defaultCustomerCurrency, } from '../../../entity/customer/customerState';
6
6
  export const getArAgingReport = createSelector((state) => state.arAgingState, (state) => state.customerState, (arAgingState, customerState) => {
7
7
  const { reportId, reportTitle, fetchState, uiState, firstMonthOfFY, agingPeriods, } = arAgingState;
8
8
  const { searchString, sortOrder, sortKey, selectedDate } = uiState;
@@ -12,13 +12,11 @@ export const uploadMissingReceiptSuccessEpic = (actions$, state$) => actions$.pi
12
12
  updateActions.push(updateTransaction(transactionPayload.transaction_id, transactionPayload, updateType));
13
13
  if (currentTenant != null) {
14
14
  const monthEndChecksPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
15
- if (monthEndChecksPeriod != null) {
16
- updateActions.push(fetchMonthEndCloseChecks({
17
- tenantId: currentTenant.tenantId,
18
- period: monthEndChecksPeriod,
19
- refreshViewInBackground: true,
20
- }));
21
- }
15
+ updateActions.push(fetchMonthEndCloseChecks({
16
+ tenantId: currentTenant.tenantId,
17
+ period: monthEndChecksPeriod,
18
+ refreshViewInBackground: true,
19
+ }));
22
20
  }
23
21
  return from(updateActions);
24
22
  }));
@@ -1,189 +1 @@
1
- import { toURL } from '../../../commonPayloadTypes/urlPayload';
2
- import { toAmount } from '../../../commonStateTypes/amount';
3
- import { getTransactionPayloadAmount, } from '../../../entity/transaction/payloadTypes/transactionPayload';
4
- import { toBatchFileStatus, toBatchStatusValue, toMatchSource, } from '../types/missingReceiptsViewState';
5
- // -- Converter functions --
6
- /**
7
- * Maps batch-details API `files[].status` strings to canonical {@link BatchFileStatus}.
8
- * Legacy aliases are supported during rollout; unknown strings map to `failed` so Redux never
9
- * holds untyped status values.
10
- */
11
- export function parseBatchFileStatus(raw) {
12
- const normalizedStatus = raw.trim().toLowerCase().replace(/-/g, '_');
13
- switch (normalizedStatus) {
14
- case 'exact_match':
15
- case 'matched':
16
- return 'exact_match';
17
- case 'possible_matches':
18
- case 'possible_match':
19
- case 'possiblematch':
20
- case 'un_matched':
21
- case 'unmatched':
22
- return 'possible_matches';
23
- case 'no_match':
24
- case 'nomatch':
25
- return 'no_match';
26
- case 'failed':
27
- return 'failed';
28
- default:
29
- return 'failed';
30
- }
31
- }
32
- export function toBatchFile(payload, filesEndPoint) {
33
- return {
34
- attachmentId: payload.attachment_id,
35
- candidates: payload.candidates?.map((candidate) => ({
36
- transactionId: candidate.transaction_id,
37
- matchScore: candidate.match_score,
38
- })),
39
- fileDownloadUrl: payload.file_id != null && filesEndPoint != null
40
- ? `${filesEndPoint}/1.0/files/${payload.file_id}?query=${encodeURIComponent(JSON.stringify({ download_file: true }))}`
41
- : null,
42
- fileId: payload.file_id,
43
- filePreviewUrl: payload.file_preview_url,
44
- filename: payload.filename,
45
- matchSource: payload.match_source != null
46
- ? toMatchSource(payload.match_source)
47
- : undefined,
48
- matchedTransactionId: payload.matched_transaction?.transaction_id,
49
- status: toBatchFileStatus(payload.status),
50
- };
51
- }
52
- export function extractTransactionPayloadsFromBatchFiles(files) {
53
- const seen = new Set();
54
- const payloads = [];
55
- for (const file of files) {
56
- if (file.matched_transaction != null) {
57
- const id = file.matched_transaction.transaction_id;
58
- if (!seen.has(id)) {
59
- seen.add(id);
60
- payloads.push(matchedTransactionPayloadToSupportedTransactionPayload(file.matched_transaction));
61
- }
62
- }
63
- if (file.candidates != null) {
64
- for (const candidate of file.candidates) {
65
- const id = candidate.transaction_id;
66
- if (!seen.has(id)) {
67
- seen.add(id);
68
- payloads.push(matchedTransactionPayloadToSupportedTransactionPayload(candidate));
69
- }
70
- }
71
- }
72
- }
73
- return payloads;
74
- }
75
- function matchedTransactionPayloadToSupportedTransactionPayload(payload) {
76
- return {
77
- transaction_id: payload.transaction_id,
78
- transaction_type: payload.transaction_type ?? 'expense',
79
- transaction_date: payload.transaction_date ?? '',
80
- currency_code: payload.currency_code,
81
- total_amount: payload.amount,
82
- vendor_name: payload.vendor_name,
83
- logo: payload.vendor_logo == null ? undefined : toURL(payload.vendor_logo),
84
- };
85
- }
86
- export function toBatchSummary(payload) {
87
- return {
88
- failed: payload.failed,
89
- matched: payload.matched,
90
- noMatch: payload.no_match,
91
- possibleMatches: payload.possible_matches,
92
- total: payload.total,
93
- };
94
- }
95
- export function toBatchDetails(payload, filesEndPoint) {
96
- return {
97
- batchId: payload.batch_id,
98
- createdAt: payload.created_at,
99
- files: payload.files.map((file) => toBatchFile(file, filesEndPoint)),
100
- status: toBatchStatusValue(payload.status),
101
- summary: toBatchSummary(payload.summary),
102
- };
103
- }
104
- /** Batch list `status` is a string from the API — compare case-insensitively. */
105
- export function isBatchListStatusCompleted(status) {
106
- return status.toLowerCase() === 'completed';
107
- }
108
- /**
109
- * Subset of the get-all-batches (`/batches?query=...`) list that is eligible for
110
- * `GET /batches/:batchId` details fetches. The stored list may include pending, failed, or other
111
- * statuses for UI; only `completed` rows should trigger batch-details requests.
112
- */
113
- export function filterBatchListItemsForBatchDetailsFetch(batches) {
114
- return batches.filter((batch) => isBatchListStatusCompleted(batch.status));
115
- }
116
- /**
117
- * Batch details API response `status` field — only completed payloads should be stored from
118
- * multi-batch fetch paths (list can be briefly stale vs. live processing state).
119
- */
120
- export function isBatchDetailsApiStatusCompleted(status) {
121
- return status.toLowerCase() === 'completed';
122
- }
123
- export function findBatchListItemForBatchId(batchListByPeriod, batchId) {
124
- for (const list of Object.values(batchListByPeriod)) {
125
- const found = list.find((batch) => batch.batchId === batchId);
126
- if (found != null) {
127
- return found;
128
- }
129
- }
130
- return undefined;
131
- }
132
- /**
133
- * Whether it is appropriate to call `GET .../batches/:id` for details.
134
- * Skips when live batch status or batch list row indicates the batch is not completed yet.
135
- * When status is unknown in both sources, allows the request (e.g. dispatch before list refresh).
136
- */
137
- export function shouldFetchBatchDetailsForBatchId(batchStatusById, batchListByPeriod, batchId) {
138
- const live = batchStatusById[batchId]?.status;
139
- if (live === 'completed') {
140
- return true;
141
- }
142
- if (live === 'pending' || live === 'processing') {
143
- return false;
144
- }
145
- const listItem = findBatchListItemForBatchId(batchListByPeriod, batchId);
146
- if (listItem != null && !isBatchListStatusCompleted(listItem.status)) {
147
- return false;
148
- }
149
- return true;
150
- }
151
- export function toBatchListItem(payload) {
152
- return {
153
- batchId: payload.batch_id,
154
- createdAt: payload.created_at,
155
- failedCount: payload.failed_count,
156
- matchedCount: payload.matched_count,
157
- noMatchCount: payload.no_match_count,
158
- possibleMatchesCount: payload.possible_matches_count,
159
- status: payload.status,
160
- totalFiles: payload.total_files,
161
- };
162
- }
163
- /**
164
- * Amount shown in the Unmatched tab manual-search list: **first line only** when `lines` exist.
165
- * Falls back to transaction-level totals via {@link getTransactionPayloadAmount} when there is
166
- * no line or no line amount (same currency fields as the rest of the transaction payload).
167
- */
168
- function getManualSearchListAmountFromPayload(payload) {
169
- const lineAmount = payload.lines?.[0]?.amount;
170
- if (lineAmount != null) {
171
- return toAmount(lineAmount, payload.currency_code, payload.currency_symbol);
172
- }
173
- return getTransactionPayloadAmount(payload);
174
- }
175
- /** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */
176
- export function supportedTransactionPayloadToManualSearchResult(payload) {
177
- const amountPayload = getManualSearchListAmountFromPayload(payload);
178
- return {
179
- amount: amountPayload.amount,
180
- currencyCode: amountPayload.currencyCode,
181
- entityId: payload.vendor_id ?? payload.customer_id ?? '',
182
- memo: payload.transaction_memo ?? '',
183
- transactionDate: payload.transaction_date,
184
- transactionId: payload.transaction_id,
185
- transactionType: payload.transaction_type,
186
- vendorName: payload.vendor_name ?? '',
187
- vendorLogo: toURL(payload.logo)?.href,
188
- };
189
- }
1
+ export {};