@zeniai/client-epic-state 4.20.7 → 4.20.8
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.
- package/lib/commonStateTypes/coaBalance/additionalBalances/getSummationBalance.d.ts +1 -1
- package/lib/commonStateTypes/coaBalance/coaBalanceType.d.ts +2 -0
- package/lib/commonStateTypes/coaBalance/coaBalanceType.js +6 -0
- package/lib/commonStateTypes/currencyHelper.d.ts +3 -0
- package/lib/commonStateTypes/currencyHelper.js +6 -1
- package/lib/commonStateTypes/reduceFetchState.d.ts +9 -0
- package/lib/commonStateTypes/reduceFetchState.js +26 -0
- package/lib/entity/account/accountPayload.d.ts +2 -0
- package/lib/entity/account/accountPayload.js +2 -0
- package/lib/entity/account/accountState.d.ts +2 -0
- package/lib/entity/customer/customerState.d.ts +0 -2
- package/lib/entity/customer/customerState.js +0 -5
- package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
- package/lib/entity/depositAccount/depositAccount.js +8 -1
- package/lib/entity/reimbursement/reimbursementPayload.d.ts +2 -0
- package/lib/entity/reimbursement/reimbursementPayload.js +7 -0
- package/lib/entity/reimbursement/reimbursementState.d.ts +2 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/entity/task/taskPayload.d.ts +1 -0
- package/lib/entity/task/taskPayload.js +1 -0
- package/lib/entity/task/taskState.d.ts +1 -0
- package/lib/entity/userGroups/userGroupsPayload.d.ts +7 -0
- package/lib/entity/userGroups/userGroupsPayload.js +10 -0
- package/lib/entity/userGroups/userGroupsReducer.d.ts +8 -0
- package/lib/entity/userGroups/userGroupsReducer.js +29 -0
- package/lib/entity/userGroups/userGroupsSelector.d.ts +4 -0
- package/lib/entity/userGroups/userGroupsSelector.js +12 -0
- package/lib/entity/userGroups/userGroupsState.d.ts +9 -0
- package/lib/entity/userGroups/userGroupsState.js +2 -0
- package/lib/epic.d.ts +15 -1
- package/lib/epic.js +15 -1
- package/lib/esm/commonStateTypes/coaBalance/coaBalanceType.js +5 -0
- package/lib/esm/commonStateTypes/currencyHelper.js +5 -0
- package/lib/esm/commonStateTypes/reduceFetchState.js +25 -0
- package/lib/esm/entity/account/accountPayload.js +2 -0
- package/lib/esm/entity/customer/customerState.js +1 -4
- package/lib/esm/entity/depositAccount/depositAccount.js +8 -1
- package/lib/esm/entity/reimbursement/reimbursementPayload.js +7 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/esm/entity/task/taskPayload.js +1 -0
- package/lib/esm/entity/userGroups/userGroupsPayload.js +7 -0
- package/lib/esm/entity/userGroups/userGroupsReducer.js +25 -0
- package/lib/esm/entity/userGroups/userGroupsSelector.js +8 -0
- package/lib/esm/entity/userGroups/userGroupsState.js +1 -0
- package/lib/esm/epic.js +15 -1
- package/lib/esm/index.js +19 -10
- package/lib/esm/reducer.js +6 -0
- package/lib/esm/view/arAgingView/arAgingReport/arAgingReducer.js +1 -1
- package/lib/esm/view/arAgingView/arAgingReport/arAgingSelector.js +1 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js +33 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +29 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +49 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +33 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +56 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +12 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +98 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +71 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +86 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +24 -0
- package/lib/esm/view/expenseAutomationView/helpers/bulkUploadTiming.js +16 -0
- package/lib/esm/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +13 -0
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +198 -1
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +456 -2
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +23 -1
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +245 -1
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +44 -0
- package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +2 -1
- package/lib/esm/view/financeStatement/financeStatementReducer.js +11 -8
- package/lib/esm/view/financeStatement/financeStatementSelector.js +24 -9
- package/lib/esm/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +17 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +331 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +9 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +6 -1
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
- package/lib/esm/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +262 -0
- package/lib/esm/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +9 -7
- package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
- package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
- package/lib/esm/view/taskManager/taskListView/taskListSelector.js +3 -1
- package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +65 -0
- package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +16 -0
- package/lib/esm/view/userGroupListView/userGroupListViewState.js +1 -0
- package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +11 -0
- package/lib/esm/zeniAPI.js +0 -2
- package/lib/index.d.ts +20 -12
- package/lib/index.js +97 -34
- package/lib/reducer.d.ts +6 -0
- package/lib/reducer.js +6 -0
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/arAgingView/arAgingReport/arAgingReducer.js +2 -2
- package/lib/view/arAgingView/arAgingReport/arAgingSelector.js +5 -5
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.d.ts +13 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js +37 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +18 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +33 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +53 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +37 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +61 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.d.ts +10 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +16 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.d.ts +18 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +102 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +75 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +25 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +92 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +28 -0
- package/lib/view/expenseAutomationView/helpers/bulkUploadTiming.d.ts +16 -0
- package/lib/view/expenseAutomationView/helpers/bulkUploadTiming.js +19 -0
- package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.d.ts +7 -0
- package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +16 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +123 -0
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +211 -0
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +86 -3
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +457 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -3
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +24 -2
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +70 -1
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -0
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +244 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +146 -0
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +54 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +2 -1
- package/lib/view/financeStatement/financeStatementReducer.js +11 -8
- package/lib/view/financeStatement/financeStatementSelector.d.ts +2 -0
- package/lib/view/financeStatement/financeStatementSelector.js +24 -9
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.d.ts +9 -0
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +20 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +15 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +335 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +111 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +13 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +4 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +7 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +4 -0
- package/lib/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +6 -0
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +265 -0
- package/lib/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +8 -6
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +1 -0
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
- package/lib/view/taskManager/taskListView/taskListSelector.d.ts +2 -0
- package/lib/view/taskManager/taskListView/taskListSelector.js +3 -1
- package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +23 -0
- package/lib/view/userGroupListView/userGroupListViewReducer.js +69 -0
- package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +7 -0
- package/lib/view/userGroupListView/userGroupListViewSelector.js +20 -0
- package/lib/view/userGroupListView/userGroupListViewState.d.ts +8 -0
- package/lib/view/userGroupListView/userGroupListViewState.js +2 -0
- package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +3 -1
- package/lib/view/userListView/fetchUserListByTypeEpic.js +11 -0
- package/lib/view/userListView/userListViewPayload.d.ts +2 -0
- package/lib/zeniAPI.js +0 -2
- package/package.json +3 -3
|
@@ -28,6 +28,7 @@ export interface ExpenseAutomationTransactionViewSelector extends SelectorView {
|
|
|
28
28
|
transactions: SupportedTransactionWithCOT[];
|
|
29
29
|
uiState: TransactionsViewUIState;
|
|
30
30
|
uncategorizedAccounts: UncategorizedAccounts;
|
|
31
|
+
uploadReceiptStatusById: Record<ID, FetchStateAndError>;
|
|
31
32
|
selectedTransactionId?: ID;
|
|
32
33
|
selectedTransactionLineId?: ID;
|
|
33
34
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { RootState } from '../../../reducer';
|
|
2
|
-
import { ExpenseAutomationMissingReceiptsViewSelector } from '../selectorTypes/missingReceiptsSelectorTypes';
|
|
2
|
+
import type { ExpenseAutomationMissingReceiptsViewSelector } from '../selectorTypes/missingReceiptsSelectorTypes';
|
|
3
3
|
export declare function getExpenseAutomationMissingReceiptsView(state: RootState): ExpenseAutomationMissingReceiptsViewSelector;
|
|
@@ -8,7 +8,10 @@ const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
|
8
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
|
+
const missingReceiptsPayload_1 = require("../payload/missingReceiptsPayload");
|
|
12
|
+
const missingReceiptsViewReducer_1 = require("../reducers/missingReceiptsViewReducer");
|
|
11
13
|
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
14
|
+
const missingReceiptsViewState_1 = require("../types/missingReceiptsViewState");
|
|
12
15
|
function getExpenseAutomationMissingReceiptsView(state) {
|
|
13
16
|
const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
|
|
14
17
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
@@ -53,6 +56,131 @@ function getExpenseAutomationMissingReceiptsView(state) {
|
|
|
53
56
|
const completionStatus = missingReceiptsCompletionStatus != null
|
|
54
57
|
? missingReceiptsCompletionStatus
|
|
55
58
|
: 'incomplete';
|
|
59
|
+
const { bulkUpload, pendingMissingReceiptsTabNavigation } = expenseAutomationMissingReceiptsViewState;
|
|
60
|
+
const currentBatchStatus = bulkUpload.currentBatchId != null
|
|
61
|
+
? bulkUpload.batchStatusById[bulkUpload.currentBatchId]
|
|
62
|
+
: undefined;
|
|
63
|
+
const batchList = monthYearPeriodId != null
|
|
64
|
+
? (bulkUpload.batchListByPeriod[monthYearPeriodId] ?? [])
|
|
65
|
+
: [];
|
|
66
|
+
/**
|
|
67
|
+
* Primary "Unmatched" batch = first completed batch in platform list order, preferring the
|
|
68
|
+
* first batch that still has possible_matches/no_match work when any completed batch has such work.
|
|
69
|
+
* Batches without details yet: wait if the list row still reports unmatched work; otherwise skip
|
|
70
|
+
* so we do not block the whole tab while other rows are not fetched yet.
|
|
71
|
+
*/
|
|
72
|
+
const primaryBatchIdFromDetailsOrder = getPrimaryBatchIdFromBatchListOrder(batchList, bulkUpload.batchDetailsById, bulkUpload.failedBatchDetailIds);
|
|
73
|
+
/**
|
|
74
|
+
* During upload/matching, prefer `currentBatchId` only when its batch details are loaded,
|
|
75
|
+
* completed, and still have unmatched-tab work. Otherwise keep `primaryBatchIdFromDetailsOrder`.
|
|
76
|
+
*
|
|
77
|
+
* If we pinned to `currentBatchId` as soon as it was absent from the batch list (in-flight
|
|
78
|
+
* upload), details are often not loaded yet — `unmatchedFiles` would empty while older batches
|
|
79
|
+
* moved to "past", so the primary "Unmatched Receipts" section vanished during auto-matching.
|
|
80
|
+
*/
|
|
81
|
+
const unmatchedSectionBatchId = (() => {
|
|
82
|
+
const phase = bulkUpload.phase;
|
|
83
|
+
if (phase !== 'matching' && phase !== 'uploading') {
|
|
84
|
+
return primaryBatchIdFromDetailsOrder;
|
|
85
|
+
}
|
|
86
|
+
const currentId = bulkUpload.currentBatchId;
|
|
87
|
+
if (currentId == null) {
|
|
88
|
+
return primaryBatchIdFromDetailsOrder;
|
|
89
|
+
}
|
|
90
|
+
const currentDetails = bulkUpload.batchDetailsById[currentId];
|
|
91
|
+
if (currentDetails != null &&
|
|
92
|
+
currentDetails.status === 'completed' &&
|
|
93
|
+
batchDetailsHasUnmatchedWork(currentDetails)) {
|
|
94
|
+
return currentId;
|
|
95
|
+
}
|
|
96
|
+
return primaryBatchIdFromDetailsOrder;
|
|
97
|
+
})();
|
|
98
|
+
const completedBatchesInApiOrder = batchList.filter((batchListItem) => (0, missingReceiptsPayload_1.isBatchListStatusCompleted)(batchListItem.status));
|
|
99
|
+
const currentBatchDetails = unmatchedSectionBatchId != null
|
|
100
|
+
? bulkUpload.batchDetailsById[unmatchedSectionBatchId]
|
|
101
|
+
: undefined;
|
|
102
|
+
const resolvedFiles = currentBatchDetails?.files.map((file) => resolveBatchFile(file, currentBatchDetails.batchId, transactionState));
|
|
103
|
+
const failedIds = new Set(bulkUpload.failedBatchDetailIds);
|
|
104
|
+
const hasMoreBatchDetails = completedBatchesInApiOrder.some((batchListItem) => bulkUpload.batchDetailsById[batchListItem.batchId] == null &&
|
|
105
|
+
!failedIds.has(batchListItem.batchId));
|
|
106
|
+
const getSortValue = (file) => {
|
|
107
|
+
const matchedTransaction = file.matchedTransaction;
|
|
108
|
+
if (matchedTransaction == null) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
switch (bulkUpload.sortKey) {
|
|
112
|
+
case 'vendor':
|
|
113
|
+
return ((matchedTransaction.vendorName ?? matchedTransaction.description)?.toLowerCase() ?? null);
|
|
114
|
+
case 'category': {
|
|
115
|
+
const line = matchedTransaction.lines?.[0];
|
|
116
|
+
return line?.account?.accountName?.toLowerCase() ?? null;
|
|
117
|
+
}
|
|
118
|
+
case 'class': {
|
|
119
|
+
const line = matchedTransaction.lines?.[0];
|
|
120
|
+
return line?.class?.className?.toLowerCase() ?? null;
|
|
121
|
+
}
|
|
122
|
+
case 'date':
|
|
123
|
+
return matchedTransaction.date.valueOf();
|
|
124
|
+
case 'amount':
|
|
125
|
+
return matchedTransaction.amount.amount;
|
|
126
|
+
default:
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const bulkUploadSortDirection = bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc';
|
|
131
|
+
const matchedFiles = (0, orderBy_1.default)(resolvedFiles?.filter((resolvedFile) => resolvedFile.status === 'exact_match') ?? [], getSortValue, bulkUploadSortDirection);
|
|
132
|
+
const unmatchedFiles = (0, orderBy_1.default)(resolvedFiles?.filter((resolvedFile) => (0, missingReceiptsViewState_1.isUnmatchedTabFileStatus)(resolvedFile.status)) ?? [], getSortValue, bulkUploadSortDirection);
|
|
133
|
+
const progress = currentBatchStatus != null
|
|
134
|
+
? {
|
|
135
|
+
...currentBatchStatus.progress,
|
|
136
|
+
percentage: currentBatchStatus.progress.total > 0
|
|
137
|
+
? Math.round((currentBatchStatus.progress.processed /
|
|
138
|
+
currentBatchStatus.progress.total) *
|
|
139
|
+
100)
|
|
140
|
+
: 0,
|
|
141
|
+
}
|
|
142
|
+
: { total: 0, processed: 0, percentage: 0 };
|
|
143
|
+
const batchListFetchState = bulkUpload.batchListFetchState;
|
|
144
|
+
/**
|
|
145
|
+
* When primary batch is not resolved yet, still aggregate unmatched files from every batch
|
|
146
|
+
* that has details loaded (otherwise past is empty and receipts vanish from the UI).
|
|
147
|
+
*/
|
|
148
|
+
const pastBatches = unmatchedSectionBatchId != null
|
|
149
|
+
? batchList.filter((batchListItem) => batchListItem.batchId !== unmatchedSectionBatchId)
|
|
150
|
+
: batchList;
|
|
151
|
+
const pastUnmatchedFiles = pastBatches.flatMap((pastBatch) => {
|
|
152
|
+
const details = bulkUpload.batchDetailsById[pastBatch.batchId];
|
|
153
|
+
if (details == null) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
return details.files
|
|
157
|
+
.filter((batchFile) => (0, missingReceiptsViewState_1.isUnmatchedTabFileStatus)(batchFile.status))
|
|
158
|
+
.map((batchFile) => resolveBatchFile(batchFile, pastBatch.batchId, transactionState));
|
|
159
|
+
});
|
|
160
|
+
const completedTransactionsCacheKey = monthYearPeriodId != null
|
|
161
|
+
? (0, missingReceiptsViewReducer_1.getCompletedTransactionsCacheKey)(monthYearPeriodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab)
|
|
162
|
+
: undefined;
|
|
163
|
+
const completedTransactionsForPeriod = completedTransactionsCacheKey != null
|
|
164
|
+
? bulkUpload.completedTransactionsByPeriod[completedTransactionsCacheKey]
|
|
165
|
+
: undefined;
|
|
166
|
+
const completedTransactionIds = completedTransactionsForPeriod?.transactionIds ?? [];
|
|
167
|
+
const resolvedCompletedTransactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, completedTransactionIds);
|
|
168
|
+
const resolvedBatchDetails = currentBatchDetails != null && resolvedFiles != null
|
|
169
|
+
? {
|
|
170
|
+
batchId: currentBatchDetails.batchId,
|
|
171
|
+
createdAt: currentBatchDetails.createdAt,
|
|
172
|
+
files: resolvedFiles,
|
|
173
|
+
status: currentBatchDetails.status,
|
|
174
|
+
summary: currentBatchDetails.summary,
|
|
175
|
+
}
|
|
176
|
+
: undefined;
|
|
177
|
+
const manualSearchResults = bulkUpload.manualSearch.results.map((result) => {
|
|
178
|
+
const transaction = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, result.transactionId);
|
|
179
|
+
return {
|
|
180
|
+
...result,
|
|
181
|
+
vendorLogo: result.vendorLogo ?? transaction?.logo?.href,
|
|
182
|
+
};
|
|
183
|
+
});
|
|
56
184
|
return {
|
|
57
185
|
fetchState,
|
|
58
186
|
error,
|
|
@@ -61,5 +189,121 @@ function getExpenseAutomationMissingReceiptsView(state) {
|
|
|
61
189
|
refreshStatus,
|
|
62
190
|
transactions: sortedTransactions,
|
|
63
191
|
completionStatus,
|
|
192
|
+
pendingMissingReceiptsTabNavigation: pendingMissingReceiptsTabNavigation ?? null,
|
|
193
|
+
bulkUpload: {
|
|
194
|
+
phase: bulkUpload.phase,
|
|
195
|
+
uploadStatus: bulkUpload.uploadStatus,
|
|
196
|
+
batchStatus: currentBatchStatus,
|
|
197
|
+
batchDetails: resolvedBatchDetails,
|
|
198
|
+
completedSubTab: bulkUpload.completedSubTab,
|
|
199
|
+
completedTransactions: {
|
|
200
|
+
fetchState: completedTransactionsForPeriod?.fetchState ?? {
|
|
201
|
+
fetchState: 'Not-Started',
|
|
202
|
+
error: undefined,
|
|
203
|
+
},
|
|
204
|
+
nextPageToken: completedTransactionsForPeriod?.nextPageToken ?? null,
|
|
205
|
+
totalCount: completedTransactionsForPeriod?.totalCount ?? 0,
|
|
206
|
+
transactions: resolvedCompletedTransactions,
|
|
207
|
+
},
|
|
208
|
+
matchedFiles,
|
|
209
|
+
unmatchedFiles,
|
|
210
|
+
progress,
|
|
211
|
+
currentResultsTab: bulkUpload.currentResultsTab,
|
|
212
|
+
sortKey: bulkUpload.sortKey,
|
|
213
|
+
sortOrder: bulkUpload.sortOrder,
|
|
214
|
+
batchList,
|
|
215
|
+
batchListFetchState,
|
|
216
|
+
pastBatches,
|
|
217
|
+
pastUnmatchedFiles,
|
|
218
|
+
confirmMatchStatus: bulkUpload.confirmMatchStatus,
|
|
219
|
+
manualSearchUiResetKey: bulkUpload.manualSearchUiResetKey,
|
|
220
|
+
hasMoreBatchDetails,
|
|
221
|
+
batchDetailsPaginationState: bulkUpload.batchDetailsPaginationState,
|
|
222
|
+
manualSearch: {
|
|
223
|
+
...bulkUpload.manualSearch,
|
|
224
|
+
results: manualSearchResults,
|
|
225
|
+
},
|
|
226
|
+
uploadedFileCount: bulkUpload.uploadedFileCount,
|
|
227
|
+
uploadProgress: bulkUpload.uploadProgress,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function batchDetailsHasUnmatchedWork(details) {
|
|
232
|
+
return details.files.some((file) => (0, missingReceiptsViewState_1.isUnmatchedTabFileStatus)(file.status));
|
|
233
|
+
}
|
|
234
|
+
/** List row summary before batch details load — aligns with unmatched / possible-match work. */
|
|
235
|
+
function batchListItemHasUnmatchedWork(batch) {
|
|
236
|
+
return batch.noMatchCount > 0 || batch.possibleMatchesCount > 0;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* `batchList` must match platform order (same sequence as the bulk-upload batches API). Picks the
|
|
240
|
+
* primary batch for the top "Unmatched" section. Skips failed detail fetches.
|
|
241
|
+
*
|
|
242
|
+
* If details are not loaded for an earlier list row but that row reports no unmatched work, we
|
|
243
|
+
* skip it so later rows with loaded details can be primary (avoids an empty tab when the first
|
|
244
|
+
* fetch page only loaded later batches). If the list reports unmatched work but details are still
|
|
245
|
+
* loading, we wait (undefined) so primary order stays correct once details arrive.
|
|
246
|
+
*/
|
|
247
|
+
function getPrimaryBatchIdFromBatchListOrder(batchListInPlatformOrder, batchDetailsById, failedBatchDetailIds) {
|
|
248
|
+
const failedIds = new Set(failedBatchDetailIds);
|
|
249
|
+
const anyCompletedBatchHasUnmatchedWork = batchListInPlatformOrder.some((batch) => {
|
|
250
|
+
if (failedIds.has(batch.batchId)) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
const details = batchDetailsById[batch.batchId];
|
|
254
|
+
if (details != null &&
|
|
255
|
+
details.status === 'completed' &&
|
|
256
|
+
batchDetailsHasUnmatchedWork(details)) {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
return details == null && batchListItemHasUnmatchedWork(batch);
|
|
260
|
+
});
|
|
261
|
+
for (const batch of batchListInPlatformOrder) {
|
|
262
|
+
if (failedIds.has(batch.batchId)) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
const details = batchDetailsById[batch.batchId];
|
|
266
|
+
if (details == null) {
|
|
267
|
+
if (batchListItemHasUnmatchedWork(batch)) {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (details.status !== 'completed') {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (anyCompletedBatchHasUnmatchedWork) {
|
|
276
|
+
if (batchDetailsHasUnmatchedWork(details)) {
|
|
277
|
+
return batch.batchId;
|
|
278
|
+
}
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
return batch.batchId;
|
|
282
|
+
}
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
function resolveBatchFile(file, batchId, transactionState) {
|
|
286
|
+
const matchedTransaction = file.matchedTransactionId != null
|
|
287
|
+
? (0, transactionSelector_1.getSupportedTransactionById)(transactionState, file.matchedTransactionId)
|
|
288
|
+
: undefined;
|
|
289
|
+
const candidates = file.candidates
|
|
290
|
+
?.map((ref) => {
|
|
291
|
+
const transaction = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, ref.transactionId);
|
|
292
|
+
return transaction != null
|
|
293
|
+
? { transaction, matchScore: ref.matchScore }
|
|
294
|
+
: undefined;
|
|
295
|
+
})
|
|
296
|
+
.filter((candidate) => candidate != null);
|
|
297
|
+
return {
|
|
298
|
+
attachmentId: file.attachmentId,
|
|
299
|
+
batchId,
|
|
300
|
+
fileDownloadUrl: file.fileDownloadUrl,
|
|
301
|
+
fileId: file.fileId,
|
|
302
|
+
filename: file.filename,
|
|
303
|
+
filePreviewUrl: file.filePreviewUrl,
|
|
304
|
+
status: file.status,
|
|
305
|
+
matchedTransaction,
|
|
306
|
+
candidates: candidates != null && candidates.length > 0 ? candidates : undefined,
|
|
307
|
+
matchSource: file.matchSource,
|
|
64
308
|
};
|
|
65
309
|
}
|
|
@@ -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
|
};
|
|
@@ -12,7 +12,153 @@ export interface MissingReceiptsViewUIState {
|
|
|
12
12
|
sortKey: MissingReceiptsSortKey;
|
|
13
13
|
sortOrder: SortOrder;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Minimum trimmed query length before manual-match search calls the expense-automation API.
|
|
17
|
+
* Kept in sync with `ManualSearchInput` in web-components (fires search only when length ≥ this).
|
|
18
|
+
*/
|
|
19
|
+
export declare const MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = 2;
|
|
20
|
+
export declare const toBatchStatusValue: (v: string) => "pending" | "processing" | "completed";
|
|
21
|
+
export type BatchStatusValue = ReturnType<typeof toBatchStatusValue>;
|
|
22
|
+
/** Canonical batch file statuses (API ingress may use aliases; see `parseBatchFileStatus`). */
|
|
23
|
+
export declare const BATCH_FILE_STATUSES: readonly ["exact_match", "possible_matches", "no_match", "failed"];
|
|
24
|
+
export declare const toBatchFileStatus: (v: string) => "failed" | "exact_match" | "possible_matches" | "no_match";
|
|
25
|
+
export type BatchFileStatus = ReturnType<typeof toBatchFileStatus>;
|
|
26
|
+
/** True for files that belong in the Unmatched tab (possible matches or no match). */
|
|
27
|
+
export declare function isUnmatchedTabFileStatus(status: BatchFileStatus): boolean;
|
|
28
|
+
export declare const toBulkUploadPhase: (v: string) => "completed" | "idle" | "uploading" | "matching";
|
|
29
|
+
export type BulkUploadPhase = ReturnType<typeof toBulkUploadPhase>;
|
|
30
|
+
export declare const toBulkUploadResultsTab: (v: string) => "completed" | "unmatched";
|
|
31
|
+
export type BulkUploadResultsTab = ReturnType<typeof toBulkUploadResultsTab>;
|
|
32
|
+
export declare const toMissingReceiptsTab: (v: string) => "completed" | "unmatched" | "missing";
|
|
33
|
+
export type MissingReceiptsTab = ReturnType<typeof toMissingReceiptsTab>;
|
|
34
|
+
export declare const toCompletedSubTab: (v: string) => "all" | "manual" | "ai_accountant";
|
|
35
|
+
export type CompletedSubTab = ReturnType<typeof toCompletedSubTab>;
|
|
36
|
+
export declare const toMatchSource: (v: string) => "manual" | "ai";
|
|
37
|
+
export type MatchSource = ReturnType<typeof toMatchSource>;
|
|
38
|
+
export declare const toBulkUploadSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class";
|
|
39
|
+
export type BulkUploadSortKey = ReturnType<typeof toBulkUploadSortKey>;
|
|
40
|
+
export interface CandidateRef {
|
|
41
|
+
matchScore: number;
|
|
42
|
+
transactionId: ID;
|
|
43
|
+
}
|
|
44
|
+
export interface MatchCandidate {
|
|
45
|
+
amount: number;
|
|
46
|
+
currencyCode: string;
|
|
47
|
+
matchScore: number;
|
|
48
|
+
transactionDate: string;
|
|
49
|
+
transactionId: ID;
|
|
50
|
+
transactionType: string;
|
|
51
|
+
vendorName: string;
|
|
52
|
+
vendorLogo?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface BatchFile {
|
|
55
|
+
attachmentId: ID;
|
|
56
|
+
fileDownloadUrl: string | null;
|
|
57
|
+
fileId: ID;
|
|
58
|
+
filename: string;
|
|
59
|
+
filePreviewUrl: string | null;
|
|
60
|
+
status: BatchFileStatus;
|
|
61
|
+
candidates?: CandidateRef[];
|
|
62
|
+
matchedTransactionId?: ID;
|
|
63
|
+
matchSource?: MatchSource;
|
|
64
|
+
}
|
|
65
|
+
export interface BatchSummary {
|
|
66
|
+
failed: number;
|
|
67
|
+
matched: number;
|
|
68
|
+
noMatch: number;
|
|
69
|
+
possibleMatches: number;
|
|
70
|
+
total: number;
|
|
71
|
+
}
|
|
72
|
+
export interface BatchStatus {
|
|
73
|
+
batchId: ID;
|
|
74
|
+
progress: {
|
|
75
|
+
processed: number;
|
|
76
|
+
total: number;
|
|
77
|
+
};
|
|
78
|
+
status: BatchStatusValue;
|
|
79
|
+
}
|
|
80
|
+
export interface BatchDetails {
|
|
81
|
+
batchId: ID;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
files: BatchFile[];
|
|
84
|
+
status: BatchStatusValue;
|
|
85
|
+
summary: BatchSummary;
|
|
86
|
+
/** Present when batch-details API includes `user_id` (uploader). */
|
|
87
|
+
userId?: ID;
|
|
88
|
+
}
|
|
89
|
+
export interface BatchListItem {
|
|
90
|
+
batchId: ID;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
failedCount: number;
|
|
93
|
+
matchedCount: number;
|
|
94
|
+
noMatchCount: number;
|
|
95
|
+
possibleMatchesCount: number;
|
|
96
|
+
status: string;
|
|
97
|
+
totalFiles: number;
|
|
98
|
+
userId: ID;
|
|
99
|
+
}
|
|
100
|
+
export interface ManualSearchResult {
|
|
101
|
+
amount: number;
|
|
102
|
+
currencyCode: string;
|
|
103
|
+
entityId: string;
|
|
104
|
+
memo: string;
|
|
105
|
+
transactionDate: string;
|
|
106
|
+
transactionId: ID;
|
|
107
|
+
transactionType: string;
|
|
108
|
+
vendorName: string;
|
|
109
|
+
/** Present when API/merged transaction state supplies a logo URL. */
|
|
110
|
+
vendorLogo?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface ManualSearchState {
|
|
113
|
+
fetchState: FetchStateAndError;
|
|
114
|
+
/** True while appending the next page (initial search uses fetchState only). */
|
|
115
|
+
isLoadingMore: boolean;
|
|
116
|
+
nextPageToken: string | null;
|
|
117
|
+
pageSize: number;
|
|
118
|
+
results: ManualSearchResult[];
|
|
119
|
+
searchQuery: string;
|
|
120
|
+
totalCount: number;
|
|
121
|
+
}
|
|
122
|
+
/** Same union as {@link CompletedSubTab} — used for completed-transactions API `match_type`. */
|
|
123
|
+
export type CompletedTransactionsMatchType = CompletedSubTab;
|
|
124
|
+
export interface CompletedTransactionsState {
|
|
125
|
+
fetchState: FetchStateAndError;
|
|
126
|
+
nextPageToken: string | null;
|
|
127
|
+
totalCount: number;
|
|
128
|
+
transactionIds: ID[];
|
|
129
|
+
}
|
|
130
|
+
export interface BulkUploadState {
|
|
131
|
+
batchDetailsById: Record<ID, BatchDetails>;
|
|
132
|
+
batchDetailsPaginationState: FetchStateAndError;
|
|
133
|
+
batchListByPeriod: Record<MonthYearPeriodId, BatchListItem[]>;
|
|
134
|
+
batchListFetchState: FetchStateAndError;
|
|
135
|
+
batchStatusById: Record<ID, BatchStatus>;
|
|
136
|
+
completedSubTab: CompletedSubTab;
|
|
137
|
+
completedTransactionsByPeriod: Record<string, CompletedTransactionsState>;
|
|
138
|
+
confirmMatchStatus: FetchStateAndError;
|
|
139
|
+
currentResultsTab: BulkUploadResultsTab;
|
|
140
|
+
failedBatchDetailIds: ID[];
|
|
141
|
+
/**
|
|
142
|
+
* Incremented when manual search Redux state is cleared so Unmatched `ManualSearchInput`
|
|
143
|
+
* instances remount and drop local query text.
|
|
144
|
+
*/
|
|
145
|
+
manualSearch: ManualSearchState;
|
|
146
|
+
manualSearchUiResetKey: number;
|
|
147
|
+
phase: BulkUploadPhase;
|
|
148
|
+
sortKey: BulkUploadSortKey;
|
|
149
|
+
sortOrder: SortOrder;
|
|
150
|
+
uploadedFileCount: number;
|
|
151
|
+
uploadProgress: number;
|
|
152
|
+
uploadStatus: FetchStateAndError;
|
|
153
|
+
currentBatchId?: ID;
|
|
154
|
+
}
|
|
15
155
|
export interface MissingReceiptsViewState extends FetchedState {
|
|
156
|
+
bulkUpload: BulkUploadState;
|
|
157
|
+
/**
|
|
158
|
+
* When set, the app shell should switch the Missing Receipts sub-tab (e.g. to Unmatched)
|
|
159
|
+
* once, then clear via `clearMissingReceiptsTabNavigation`.
|
|
160
|
+
*/
|
|
161
|
+
pendingMissingReceiptsTabNavigation: BulkUploadResultsTab | null;
|
|
16
162
|
refreshStatus: FetchStateAndError;
|
|
17
163
|
transactionIdsBySelectedPeriod: Record<MonthYearPeriodId, ID[]>;
|
|
18
164
|
uiState: MissingReceiptsViewUIState;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toMissingReceiptsSortKey = void 0;
|
|
3
|
+
exports.toBulkUploadSortKey = exports.toMatchSource = exports.toCompletedSubTab = exports.toMissingReceiptsTab = exports.toBulkUploadResultsTab = exports.toBulkUploadPhase = exports.toBatchFileStatus = exports.BATCH_FILE_STATUSES = exports.toBatchStatusValue = exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = exports.toMissingReceiptsSortKey = void 0;
|
|
4
|
+
exports.isUnmatchedTabFileStatus = isUnmatchedTabFileStatus;
|
|
4
5
|
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
5
6
|
const MISSING_RECEIPTS_SORT_KEYS = [
|
|
6
7
|
'vendor',
|
|
@@ -11,3 +12,55 @@ const MISSING_RECEIPTS_SORT_KEYS = [
|
|
|
11
12
|
];
|
|
12
13
|
const toMissingReceiptsSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, MISSING_RECEIPTS_SORT_KEYS);
|
|
13
14
|
exports.toMissingReceiptsSortKey = toMissingReceiptsSortKey;
|
|
15
|
+
// -- Bulk Receipt Upload Types --
|
|
16
|
+
/**
|
|
17
|
+
* Minimum trimmed query length before manual-match search calls the expense-automation API.
|
|
18
|
+
* Kept in sync with `ManualSearchInput` in web-components (fires search only when length ≥ this).
|
|
19
|
+
*/
|
|
20
|
+
exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = 2;
|
|
21
|
+
const BATCH_STATUS_VALUES = ['pending', 'processing', 'completed'];
|
|
22
|
+
const toBatchStatusValue = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), BATCH_STATUS_VALUES);
|
|
23
|
+
exports.toBatchStatusValue = toBatchStatusValue;
|
|
24
|
+
/** Canonical batch file statuses (API ingress may use aliases; see `parseBatchFileStatus`). */
|
|
25
|
+
exports.BATCH_FILE_STATUSES = [
|
|
26
|
+
'exact_match',
|
|
27
|
+
'possible_matches',
|
|
28
|
+
'no_match',
|
|
29
|
+
'failed',
|
|
30
|
+
];
|
|
31
|
+
const toBatchFileStatus = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase().replace(/-/g, '_'), exports.BATCH_FILE_STATUSES);
|
|
32
|
+
exports.toBatchFileStatus = toBatchFileStatus;
|
|
33
|
+
const UNMATCHED_TAB_FILE_STATUSES = ['possible_matches', 'no_match'];
|
|
34
|
+
/** True for files that belong in the Unmatched tab (possible matches or no match). */
|
|
35
|
+
function isUnmatchedTabFileStatus(status) {
|
|
36
|
+
return UNMATCHED_TAB_FILE_STATUSES.includes(status);
|
|
37
|
+
}
|
|
38
|
+
const BULK_UPLOAD_PHASES = [
|
|
39
|
+
'idle',
|
|
40
|
+
'uploading',
|
|
41
|
+
'matching',
|
|
42
|
+
'completed',
|
|
43
|
+
];
|
|
44
|
+
const toBulkUploadPhase = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), BULK_UPLOAD_PHASES);
|
|
45
|
+
exports.toBulkUploadPhase = toBulkUploadPhase;
|
|
46
|
+
const BULK_UPLOAD_RESULTS_TABS = ['completed', 'unmatched'];
|
|
47
|
+
const toBulkUploadResultsTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), BULK_UPLOAD_RESULTS_TABS);
|
|
48
|
+
exports.toBulkUploadResultsTab = toBulkUploadResultsTab;
|
|
49
|
+
const MISSING_RECEIPTS_TABS = ['missing', 'completed', 'unmatched'];
|
|
50
|
+
const toMissingReceiptsTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), MISSING_RECEIPTS_TABS);
|
|
51
|
+
exports.toMissingReceiptsTab = toMissingReceiptsTab;
|
|
52
|
+
const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
|
|
53
|
+
const toCompletedSubTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
|
|
54
|
+
exports.toCompletedSubTab = toCompletedSubTab;
|
|
55
|
+
const MATCH_SOURCES = ['ai', 'manual'];
|
|
56
|
+
const toMatchSource = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), MATCH_SOURCES);
|
|
57
|
+
exports.toMatchSource = toMatchSource;
|
|
58
|
+
const BULK_UPLOAD_SORT_KEYS = [
|
|
59
|
+
'amount',
|
|
60
|
+
'category',
|
|
61
|
+
'class',
|
|
62
|
+
'date',
|
|
63
|
+
'vendor',
|
|
64
|
+
];
|
|
65
|
+
const toBulkUploadSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), BULK_UPLOAD_SORT_KEYS);
|
|
66
|
+
exports.toBulkUploadSortKey = toBulkUploadSortKey;
|
|
@@ -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" | "
|
|
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
|
-
'
|
|
14
|
+
'memo_and_receipt',
|
|
14
15
|
];
|
|
15
16
|
const toTransactionsSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, TRANSACTIONS_SORT_KEYS);
|
|
16
17
|
exports.toTransactionsSortKey = toTransactionsSortKey;
|
|
@@ -48,19 +48,20 @@ const financeStatement = (0, toolkit_1.createSlice)({
|
|
|
48
48
|
updateFinanceStatementThisPeriod(draft, action) {
|
|
49
49
|
const { firstMonthOfFY, coaBalances, maxNumOfPeriodsToHighlight } = action.payload;
|
|
50
50
|
const { timeframe, selectedCOABalancesRange } = draft;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const safeCoaBalances = coaBalances != null ? coaBalances : [];
|
|
52
|
+
if (safeCoaBalances.length > 0) {
|
|
53
|
+
const prevThisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
|
|
53
54
|
if (prevThisPeriod != null) {
|
|
54
55
|
const selectedCoaBalancesRangeWithThisPeriod = {
|
|
55
56
|
...selectedCOABalancesRange,
|
|
56
57
|
thisPeriod: prevThisPeriod,
|
|
57
58
|
};
|
|
58
|
-
const newThisPeriod = (0, thisPeriodHelpers_1.getMatchingThisPeriod)(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod,
|
|
59
|
+
const newThisPeriod = (0, thisPeriodHelpers_1.getMatchingThisPeriod)(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod, safeCoaBalances);
|
|
59
60
|
if (newThisPeriod != null) {
|
|
60
61
|
const selectionRanges = (0, getSelectedAndHighlightedRanges_1.getSelectedAndHighlightedRangesForThisPeriod)({
|
|
61
62
|
firstMonthOfFY,
|
|
62
63
|
thisPeriod: newThisPeriod,
|
|
63
|
-
coaBalances,
|
|
64
|
+
coaBalances: safeCoaBalances,
|
|
64
65
|
timeframe,
|
|
65
66
|
maxNumOfPeriodsToSelect: maxNumOfPeriodsToHighlight,
|
|
66
67
|
currentSelection: {
|
|
@@ -79,7 +80,9 @@ const financeStatement = (0, toolkit_1.createSlice)({
|
|
|
79
80
|
draft.selectedReportId = action.payload;
|
|
80
81
|
},
|
|
81
82
|
updateFinanceStatementAdditionalBalancesSelection(draft, action) {
|
|
82
|
-
const { firstMonthOfFY, additionalBalances, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
|
|
83
|
+
const { firstMonthOfFY, additionalBalances: additionalBalancesPayload, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
|
|
84
|
+
const safeCoaBalances = coaBalances != null ? coaBalances : [];
|
|
85
|
+
const additionalBalances = additionalBalancesPayload ?? [];
|
|
83
86
|
let tempAdditionalBalances = [...additionalBalances];
|
|
84
87
|
if (additionalBalances.includes('this_period_vs_last_period') ||
|
|
85
88
|
additionalBalances.includes('this_period_vs_last_period_percent')) {
|
|
@@ -95,8 +98,8 @@ const financeStatement = (0, toolkit_1.createSlice)({
|
|
|
95
98
|
draft.isAdditionalBalancesShown =
|
|
96
99
|
additionalBalances.length != 0 ? true : false;
|
|
97
100
|
const { timeframe, selectedCOABalancesRange } = draft;
|
|
98
|
-
if (
|
|
99
|
-
const thisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange,
|
|
101
|
+
if (safeCoaBalances.length > 0) {
|
|
102
|
+
const thisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
|
|
100
103
|
if (thisPeriod != null) {
|
|
101
104
|
const selectedCoaBalancesRangeWithThisPeriod = {
|
|
102
105
|
...selectedCOABalancesRange,
|
|
@@ -105,7 +108,7 @@ const financeStatement = (0, toolkit_1.createSlice)({
|
|
|
105
108
|
const selectionRanges = (0, getSelectedAndHighlightedRanges_1.getSelectedAndHighlightedRangesForThisPeriod)({
|
|
106
109
|
firstMonthOfFY,
|
|
107
110
|
thisPeriod: thisPeriod,
|
|
108
|
-
coaBalances,
|
|
111
|
+
coaBalances: safeCoaBalances,
|
|
109
112
|
timeframe,
|
|
110
113
|
maxNumOfPeriodsToHighlight: maxNumOfPeriodsToHighlight,
|
|
111
114
|
currentSelection: {
|
|
@@ -8,6 +8,7 @@ import { RootState } from '../../reducer';
|
|
|
8
8
|
import { BalanceSheetReport } from '../balanceSheet/balanceSheetSelectorTypes';
|
|
9
9
|
import { CashFlowReport } from '../cashFlow/cashFlowSelectorTypes';
|
|
10
10
|
import { ProfitAndLossReport } from '../profitAndLoss/profitAndLossSelector';
|
|
11
|
+
import { ProfitAndLossByClassHorizontalReport } from '../profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes';
|
|
11
12
|
import { ProfitAndLossClassesViewReport } from '../profitAndLossClassesView/profitAndLossClassesViewSelectorTypes';
|
|
12
13
|
export interface FinanceStatementReport extends SelectorReport {
|
|
13
14
|
allTimeframeTicks: TimeframeTickWithMetaData[];
|
|
@@ -18,6 +19,7 @@ export interface FinanceStatementReport extends SelectorReport {
|
|
|
18
19
|
downloadState: FetchState;
|
|
19
20
|
filter: COABalancesFilter;
|
|
20
21
|
isCompareModeOn: boolean;
|
|
22
|
+
profitAndLossByClassHorizontalReport: ProfitAndLossByClassHorizontalReport;
|
|
21
23
|
profitAndLossByClassReport: ProfitAndLossClassesViewReport;
|
|
22
24
|
profitAndLossReport: ProfitAndLossReport;
|
|
23
25
|
reportFormat: ReportFormat;
|