@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.
- package/lib/commonStateTypes/coaBalance/additionalBalances/getSummationBalance.d.ts +1 -1
- package/lib/commonStateTypes/coaBalance/coaBalanceType.d.ts +0 -2
- package/lib/commonStateTypes/coaBalance/coaBalanceType.js +0 -6
- package/lib/commonStateTypes/currencyHelper.d.ts +0 -3
- package/lib/commonStateTypes/currencyHelper.js +1 -6
- package/lib/commonStateTypes/reduceFetchState.d.ts +0 -9
- package/lib/commonStateTypes/reduceFetchState.js +0 -26
- package/lib/entity/account/accountPayload.d.ts +0 -2
- package/lib/entity/account/accountPayload.js +0 -2
- package/lib/entity/account/accountState.d.ts +0 -2
- package/lib/entity/customer/customerState.d.ts +2 -0
- package/lib/entity/customer/customerState.js +5 -0
- package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
- package/lib/entity/depositAccount/depositAccount.js +1 -8
- package/lib/entity/reimbursement/reimbursementPayload.d.ts +0 -2
- package/lib/entity/reimbursement/reimbursementPayload.js +0 -7
- package/lib/entity/reimbursement/reimbursementState.d.ts +0 -2
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/entity/task/taskPayload.d.ts +0 -1
- package/lib/entity/task/taskPayload.js +0 -1
- package/lib/entity/task/taskState.d.ts +0 -1
- package/lib/epic.d.ts +1 -12
- package/lib/epic.js +1 -12
- package/lib/esm/commonStateTypes/coaBalance/coaBalanceType.js +0 -5
- package/lib/esm/commonStateTypes/currencyHelper.js +0 -5
- package/lib/esm/commonStateTypes/reduceFetchState.js +0 -25
- package/lib/esm/entity/account/accountPayload.js +0 -2
- package/lib/esm/entity/customer/customerState.js +4 -1
- package/lib/esm/entity/depositAccount/depositAccount.js +1 -8
- package/lib/esm/entity/reimbursement/reimbursementPayload.js +0 -7
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/esm/entity/task/taskPayload.js +0 -1
- package/lib/esm/epic.js +1 -12
- package/lib/esm/index.js +10 -19
- package/lib/esm/reducer.js +0 -6
- 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/uploadMissingReceiptSuccessEpic.js +5 -7
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +1 -189
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -433
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -23
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +1 -244
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -2
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -44
- package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +1 -2
- package/lib/esm/view/financeStatement/financeStatementReducer.js +8 -11
- package/lib/esm/view/financeStatement/financeStatementSelector.js +9 -24
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +1 -6
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +29 -2
- package/lib/esm/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +5 -7
- package/lib/esm/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +7 -9
- package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
- package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +0 -1
- package/lib/esm/view/taskManager/taskListView/taskListSelector.js +1 -3
- package/lib/esm/view/twoFactorAuthentication/resendOtpEpic.js +16 -2
- package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +0 -11
- package/lib/esm/zeniAPI.js +2 -0
- package/lib/index.d.ts +12 -20
- package/lib/index.js +34 -94
- package/lib/reducer.d.ts +0 -6
- package/lib/reducer.js +0 -6
- package/lib/view/arAgingView/arAgingReport/arAgingReducer.js +2 -2
- package/lib/view/arAgingView/arAgingReport/arAgingSelector.js +5 -5
- package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +5 -7
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +0 -118
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -201
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +3 -76
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -434
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +3 -11
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -24
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -69
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -1
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -243
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -2
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +0 -142
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -54
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -2
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +1 -2
- package/lib/view/financeStatement/financeStatementReducer.js +8 -11
- package/lib/view/financeStatement/financeStatementSelector.d.ts +0 -2
- package/lib/view/financeStatement/financeStatementSelector.js +9 -24
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +2 -4
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +2 -7
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +29 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +0 -4
- package/lib/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +5 -7
- package/lib/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +6 -8
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +0 -1
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +0 -1
- package/lib/view/taskManager/taskListView/taskListSelector.d.ts +0 -2
- package/lib/view/taskManager/taskListView/taskListSelector.js +1 -3
- package/lib/view/twoFactorAuthentication/resendOtpEpic.d.ts +1 -1
- package/lib/view/twoFactorAuthentication/resendOtpEpic.js +15 -1
- package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +1 -3
- package/lib/view/userListView/fetchUserListByTypeEpic.js +0 -11
- package/lib/view/userListView/userListViewPayload.d.ts +0 -2
- package/lib/zeniAPI.js +2 -0
- package/package.json +3 -3
- package/lib/entity/userGroups/userGroupsPayload.d.ts +0 -7
- package/lib/entity/userGroups/userGroupsPayload.js +0 -10
- package/lib/entity/userGroups/userGroupsReducer.d.ts +0 -8
- package/lib/entity/userGroups/userGroupsReducer.js +0 -29
- package/lib/entity/userGroups/userGroupsSelector.d.ts +0 -4
- package/lib/entity/userGroups/userGroupsSelector.js +0 -12
- package/lib/entity/userGroups/userGroupsState.d.ts +0 -9
- package/lib/entity/userGroups/userGroupsState.js +0 -2
- package/lib/esm/entity/userGroups/userGroupsPayload.js +0 -7
- package/lib/esm/entity/userGroups/userGroupsReducer.js +0 -25
- package/lib/esm/entity/userGroups/userGroupsSelector.js +0 -8
- package/lib/esm/entity/userGroups/userGroupsState.js +0 -1
- package/lib/esm/view/expenseAutomationView/bulkUploadTiming.js +0 -10
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -29
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -49
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -40
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -47
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -61
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -33
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -56
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -77
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -79
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +0 -24
- package/lib/esm/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +0 -17
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +0 -331
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +0 -9
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +0 -262
- package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +0 -65
- package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +0 -16
- package/lib/esm/view/userGroupListView/userGroupListViewState.js +0 -1
- package/lib/view/expenseAutomationView/bulkUploadTiming.d.ts +0 -10
- package/lib/view/expenseAutomationView/bulkUploadTiming.js +0 -13
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +0 -18
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -33
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +0 -7
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -53
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -44
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +0 -7
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -51
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -65
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +0 -37
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +0 -9
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -61
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +0 -14
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -81
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +0 -25
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -85
- package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +0 -7
- package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +0 -28
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.d.ts +0 -9
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +0 -20
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +0 -15
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +0 -335
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +0 -111
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +0 -13
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +0 -6
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +0 -265
- package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +0 -23
- package/lib/view/userGroupListView/userGroupListViewReducer.js +0 -69
- package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +0 -7
- package/lib/view/userGroupListView/userGroupListViewSelector.js +0 -20
- package/lib/view/userGroupListView/userGroupListViewState.d.ts +0 -8
- package/lib/view/userGroupListView/userGroupListViewState.js +0 -2
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import orderBy from 'lodash/orderBy';
|
|
2
2
|
import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
3
3
|
import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
|
|
4
|
-
import {
|
|
5
|
-
import { isBatchListStatusCompleted } from '../payload/missingReceiptsPayload';
|
|
6
|
-
import { getCompletedTransactionsCacheKey } from '../reducers/missingReceiptsViewReducer';
|
|
4
|
+
import { getSupportedTransactionsByIds } from '../../../entity/transaction/transactionSelector';
|
|
7
5
|
import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
|
|
8
|
-
import { isUnmatchedTabFileStatus, } from '../types/missingReceiptsViewState';
|
|
9
6
|
export function getExpenseAutomationMissingReceiptsView(state) {
|
|
10
7
|
const { expenseAutomationMissingReceiptsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
|
|
11
8
|
const currentTenant = getCurrentTenant(state);
|
|
@@ -50,131 +47,6 @@ export function getExpenseAutomationMissingReceiptsView(state) {
|
|
|
50
47
|
const completionStatus = missingReceiptsCompletionStatus != null
|
|
51
48
|
? missingReceiptsCompletionStatus
|
|
52
49
|
: 'incomplete';
|
|
53
|
-
const { bulkUpload, pendingMissingReceiptsTabNavigation } = expenseAutomationMissingReceiptsViewState;
|
|
54
|
-
const currentBatchStatus = bulkUpload.currentBatchId != null
|
|
55
|
-
? bulkUpload.batchStatusById[bulkUpload.currentBatchId]
|
|
56
|
-
: undefined;
|
|
57
|
-
const batchList = monthYearPeriodId != null
|
|
58
|
-
? (bulkUpload.batchListByPeriod[monthYearPeriodId] ?? [])
|
|
59
|
-
: [];
|
|
60
|
-
/**
|
|
61
|
-
* Primary "Unmatched" batch = first completed batch in platform list order, preferring the
|
|
62
|
-
* first batch that still has possible_matches/no_match work when any completed batch has such work.
|
|
63
|
-
* Batches without details yet: wait if the list row still reports unmatched work; otherwise skip
|
|
64
|
-
* so we do not block the whole tab while other rows are not fetched yet.
|
|
65
|
-
*/
|
|
66
|
-
const primaryBatchIdFromDetailsOrder = getPrimaryBatchIdFromBatchListOrder(batchList, bulkUpload.batchDetailsById, bulkUpload.failedBatchDetailIds);
|
|
67
|
-
/**
|
|
68
|
-
* During upload/matching, prefer `currentBatchId` only when its batch details are loaded,
|
|
69
|
-
* completed, and still have unmatched-tab work. Otherwise keep `primaryBatchIdFromDetailsOrder`.
|
|
70
|
-
*
|
|
71
|
-
* If we pinned to `currentBatchId` as soon as it was absent from the batch list (in-flight
|
|
72
|
-
* upload), details are often not loaded yet — `unmatchedFiles` would empty while older batches
|
|
73
|
-
* moved to "past", so the primary "Unmatched Receipts" section vanished during auto-matching.
|
|
74
|
-
*/
|
|
75
|
-
const unmatchedSectionBatchId = (() => {
|
|
76
|
-
const phase = bulkUpload.phase;
|
|
77
|
-
if (phase !== 'matching' && phase !== 'uploading') {
|
|
78
|
-
return primaryBatchIdFromDetailsOrder;
|
|
79
|
-
}
|
|
80
|
-
const currentId = bulkUpload.currentBatchId;
|
|
81
|
-
if (currentId == null) {
|
|
82
|
-
return primaryBatchIdFromDetailsOrder;
|
|
83
|
-
}
|
|
84
|
-
const currentDetails = bulkUpload.batchDetailsById[currentId];
|
|
85
|
-
if (currentDetails != null &&
|
|
86
|
-
currentDetails.status === 'completed' &&
|
|
87
|
-
batchDetailsHasUnmatchedWork(currentDetails)) {
|
|
88
|
-
return currentId;
|
|
89
|
-
}
|
|
90
|
-
return primaryBatchIdFromDetailsOrder;
|
|
91
|
-
})();
|
|
92
|
-
const completedBatchesInApiOrder = batchList.filter((batchListItem) => isBatchListStatusCompleted(batchListItem.status));
|
|
93
|
-
const currentBatchDetails = unmatchedSectionBatchId != null
|
|
94
|
-
? bulkUpload.batchDetailsById[unmatchedSectionBatchId]
|
|
95
|
-
: undefined;
|
|
96
|
-
const resolvedFiles = currentBatchDetails?.files.map((file) => resolveBatchFile(file, currentBatchDetails.batchId, transactionState));
|
|
97
|
-
const failedIds = new Set(bulkUpload.failedBatchDetailIds);
|
|
98
|
-
const hasMoreBatchDetails = completedBatchesInApiOrder.some((batchListItem) => bulkUpload.batchDetailsById[batchListItem.batchId] == null &&
|
|
99
|
-
!failedIds.has(batchListItem.batchId));
|
|
100
|
-
const getSortValue = (file) => {
|
|
101
|
-
const matchedTransaction = file.matchedTransaction;
|
|
102
|
-
if (matchedTransaction == null) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
switch (bulkUpload.sortKey) {
|
|
106
|
-
case 'vendor':
|
|
107
|
-
return ((matchedTransaction.vendorName ?? matchedTransaction.description)?.toLowerCase() ?? null);
|
|
108
|
-
case 'category': {
|
|
109
|
-
const line = matchedTransaction.lines?.[0];
|
|
110
|
-
return line?.account?.accountName?.toLowerCase() ?? null;
|
|
111
|
-
}
|
|
112
|
-
case 'class': {
|
|
113
|
-
const line = matchedTransaction.lines?.[0];
|
|
114
|
-
return line?.class?.className?.toLowerCase() ?? null;
|
|
115
|
-
}
|
|
116
|
-
case 'date':
|
|
117
|
-
return matchedTransaction.date.valueOf();
|
|
118
|
-
case 'amount':
|
|
119
|
-
return matchedTransaction.amount.amount;
|
|
120
|
-
default:
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
const bulkUploadSortDirection = bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc';
|
|
125
|
-
const matchedFiles = orderBy(resolvedFiles?.filter((resolvedFile) => resolvedFile.status === 'exact_match') ?? [], getSortValue, bulkUploadSortDirection);
|
|
126
|
-
const unmatchedFiles = orderBy(resolvedFiles?.filter((resolvedFile) => isUnmatchedTabFileStatus(resolvedFile.status)) ?? [], getSortValue, bulkUploadSortDirection);
|
|
127
|
-
const progress = currentBatchStatus != null
|
|
128
|
-
? {
|
|
129
|
-
...currentBatchStatus.progress,
|
|
130
|
-
percentage: currentBatchStatus.progress.total > 0
|
|
131
|
-
? Math.round((currentBatchStatus.progress.processed /
|
|
132
|
-
currentBatchStatus.progress.total) *
|
|
133
|
-
100)
|
|
134
|
-
: 0,
|
|
135
|
-
}
|
|
136
|
-
: { total: 0, processed: 0, percentage: 0 };
|
|
137
|
-
const batchListFetchState = bulkUpload.batchListFetchState;
|
|
138
|
-
/**
|
|
139
|
-
* When primary batch is not resolved yet, still aggregate unmatched files from every batch
|
|
140
|
-
* that has details loaded (otherwise past is empty and receipts vanish from the UI).
|
|
141
|
-
*/
|
|
142
|
-
const pastBatches = unmatchedSectionBatchId != null
|
|
143
|
-
? batchList.filter((batchListItem) => batchListItem.batchId !== unmatchedSectionBatchId)
|
|
144
|
-
: batchList;
|
|
145
|
-
const pastUnmatchedFiles = pastBatches.flatMap((pastBatch) => {
|
|
146
|
-
const details = bulkUpload.batchDetailsById[pastBatch.batchId];
|
|
147
|
-
if (details == null) {
|
|
148
|
-
return [];
|
|
149
|
-
}
|
|
150
|
-
return details.files
|
|
151
|
-
.filter((batchFile) => isUnmatchedTabFileStatus(batchFile.status))
|
|
152
|
-
.map((batchFile) => resolveBatchFile(batchFile, pastBatch.batchId, transactionState));
|
|
153
|
-
});
|
|
154
|
-
const completedTransactionsCacheKey = monthYearPeriodId != null
|
|
155
|
-
? getCompletedTransactionsCacheKey(monthYearPeriodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab)
|
|
156
|
-
: undefined;
|
|
157
|
-
const completedTransactionsForPeriod = completedTransactionsCacheKey != null
|
|
158
|
-
? bulkUpload.completedTransactionsByPeriod[completedTransactionsCacheKey]
|
|
159
|
-
: undefined;
|
|
160
|
-
const completedTransactionIds = completedTransactionsForPeriod?.transactionIds ?? [];
|
|
161
|
-
const resolvedCompletedTransactions = getSupportedTransactionsByIds(transactionState, completedTransactionIds);
|
|
162
|
-
const resolvedBatchDetails = currentBatchDetails != null && resolvedFiles != null
|
|
163
|
-
? {
|
|
164
|
-
batchId: currentBatchDetails.batchId,
|
|
165
|
-
createdAt: currentBatchDetails.createdAt,
|
|
166
|
-
files: resolvedFiles,
|
|
167
|
-
status: currentBatchDetails.status,
|
|
168
|
-
summary: currentBatchDetails.summary,
|
|
169
|
-
}
|
|
170
|
-
: undefined;
|
|
171
|
-
const manualSearchResults = bulkUpload.manualSearch.results.map((result) => {
|
|
172
|
-
const transaction = getSupportedTransactionById(transactionState, result.transactionId);
|
|
173
|
-
return {
|
|
174
|
-
...result,
|
|
175
|
-
vendorLogo: result.vendorLogo ?? transaction?.logo?.href,
|
|
176
|
-
};
|
|
177
|
-
});
|
|
178
50
|
return {
|
|
179
51
|
fetchState,
|
|
180
52
|
error,
|
|
@@ -183,120 +55,5 @@ export function getExpenseAutomationMissingReceiptsView(state) {
|
|
|
183
55
|
refreshStatus,
|
|
184
56
|
transactions: sortedTransactions,
|
|
185
57
|
completionStatus,
|
|
186
|
-
pendingMissingReceiptsTabNavigation: pendingMissingReceiptsTabNavigation ?? null,
|
|
187
|
-
bulkUpload: {
|
|
188
|
-
phase: bulkUpload.phase,
|
|
189
|
-
uploadStatus: bulkUpload.uploadStatus,
|
|
190
|
-
batchStatus: currentBatchStatus,
|
|
191
|
-
batchDetails: resolvedBatchDetails,
|
|
192
|
-
completedSubTab: bulkUpload.completedSubTab,
|
|
193
|
-
completedTransactions: {
|
|
194
|
-
fetchState: completedTransactionsForPeriod?.fetchState ?? {
|
|
195
|
-
fetchState: 'Not-Started',
|
|
196
|
-
error: undefined,
|
|
197
|
-
},
|
|
198
|
-
nextPageToken: completedTransactionsForPeriod?.nextPageToken ?? null,
|
|
199
|
-
totalCount: completedTransactionsForPeriod?.totalCount ?? 0,
|
|
200
|
-
transactions: resolvedCompletedTransactions,
|
|
201
|
-
},
|
|
202
|
-
matchedFiles,
|
|
203
|
-
unmatchedFiles,
|
|
204
|
-
progress,
|
|
205
|
-
currentResultsTab: bulkUpload.currentResultsTab,
|
|
206
|
-
sortKey: bulkUpload.sortKey,
|
|
207
|
-
sortOrder: bulkUpload.sortOrder,
|
|
208
|
-
batchList,
|
|
209
|
-
batchListFetchState,
|
|
210
|
-
pastBatches,
|
|
211
|
-
pastUnmatchedFiles,
|
|
212
|
-
confirmMatchStatus: bulkUpload.confirmMatchStatus,
|
|
213
|
-
manualSearchUiResetKey: bulkUpload.manualSearchUiResetKey,
|
|
214
|
-
hasMoreBatchDetails,
|
|
215
|
-
batchDetailsPaginationState: bulkUpload.batchDetailsPaginationState,
|
|
216
|
-
manualSearch: {
|
|
217
|
-
...bulkUpload.manualSearch,
|
|
218
|
-
results: manualSearchResults,
|
|
219
|
-
},
|
|
220
|
-
uploadProgress: bulkUpload.uploadProgress,
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
function batchDetailsHasUnmatchedWork(details) {
|
|
225
|
-
return details.files.some((file) => isUnmatchedTabFileStatus(file.status));
|
|
226
|
-
}
|
|
227
|
-
/** List row summary before batch details load — aligns with unmatched / possible-match work. */
|
|
228
|
-
function batchListItemHasUnmatchedWork(batch) {
|
|
229
|
-
return batch.noMatchCount > 0 || batch.possibleMatchesCount > 0;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* `batchList` must match platform order (same sequence as the bulk-upload batches API). Picks the
|
|
233
|
-
* primary batch for the top "Unmatched" section. Skips failed detail fetches.
|
|
234
|
-
*
|
|
235
|
-
* If details are not loaded for an earlier list row but that row reports no unmatched work, we
|
|
236
|
-
* skip it so later rows with loaded details can be primary (avoids an empty tab when the first
|
|
237
|
-
* fetch page only loaded later batches). If the list reports unmatched work but details are still
|
|
238
|
-
* loading, we wait (undefined) so primary order stays correct once details arrive.
|
|
239
|
-
*/
|
|
240
|
-
function getPrimaryBatchIdFromBatchListOrder(batchListInPlatformOrder, batchDetailsById, failedBatchDetailIds) {
|
|
241
|
-
const failedIds = new Set(failedBatchDetailIds);
|
|
242
|
-
const anyCompletedBatchHasUnmatchedWork = batchListInPlatformOrder.some((batch) => {
|
|
243
|
-
if (failedIds.has(batch.batchId)) {
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
const details = batchDetailsById[batch.batchId];
|
|
247
|
-
if (details != null &&
|
|
248
|
-
details.status === 'completed' &&
|
|
249
|
-
batchDetailsHasUnmatchedWork(details)) {
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
return details == null && batchListItemHasUnmatchedWork(batch);
|
|
253
|
-
});
|
|
254
|
-
for (const batch of batchListInPlatformOrder) {
|
|
255
|
-
if (failedIds.has(batch.batchId)) {
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
const details = batchDetailsById[batch.batchId];
|
|
259
|
-
if (details == null) {
|
|
260
|
-
if (batchListItemHasUnmatchedWork(batch)) {
|
|
261
|
-
return undefined;
|
|
262
|
-
}
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
if (details.status !== 'completed') {
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
if (anyCompletedBatchHasUnmatchedWork) {
|
|
269
|
-
if (batchDetailsHasUnmatchedWork(details)) {
|
|
270
|
-
return batch.batchId;
|
|
271
|
-
}
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
return batch.batchId;
|
|
275
|
-
}
|
|
276
|
-
return undefined;
|
|
277
|
-
}
|
|
278
|
-
function resolveBatchFile(file, batchId, transactionState) {
|
|
279
|
-
const matchedTransaction = file.matchedTransactionId != null
|
|
280
|
-
? getSupportedTransactionById(transactionState, file.matchedTransactionId)
|
|
281
|
-
: undefined;
|
|
282
|
-
const candidates = file.candidates
|
|
283
|
-
?.map((ref) => {
|
|
284
|
-
const transaction = getSupportedTransactionById(transactionState, ref.transactionId);
|
|
285
|
-
return transaction != null
|
|
286
|
-
? { transaction, matchScore: ref.matchScore }
|
|
287
|
-
: undefined;
|
|
288
|
-
})
|
|
289
|
-
.filter((candidate) => candidate != null);
|
|
290
|
-
return {
|
|
291
|
-
attachmentId: file.attachmentId,
|
|
292
|
-
batchId,
|
|
293
|
-
fileDownloadUrl: file.fileDownloadUrl,
|
|
294
|
-
fileId: file.fileId,
|
|
295
|
-
filename: file.filename,
|
|
296
|
-
filePreviewUrl: file.filePreviewUrl,
|
|
297
|
-
status: file.status,
|
|
298
|
-
matchedTransaction,
|
|
299
|
-
candidates: candidates != null && candidates.length > 0 ? candidates : undefined,
|
|
300
|
-
matchSource: file.matchSource,
|
|
301
58
|
};
|
|
302
59
|
}
|
|
@@ -10,7 +10,7 @@ import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes
|
|
|
10
10
|
export function getExpenseAutomationTransactionView(state) {
|
|
11
11
|
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
|
|
12
12
|
const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
|
|
13
|
-
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData,
|
|
13
|
+
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
14
14
|
const uncategorizedIncomeExpense = getUncategorizedAccounts(accountState, accountListState, 'accountList');
|
|
15
15
|
const accountList = getAccountList(accountState, accountListState, 'accountList');
|
|
16
16
|
const classList = getClassList(classState, classListState);
|
|
@@ -94,7 +94,6 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
94
94
|
completionStatus,
|
|
95
95
|
totalCountByTab,
|
|
96
96
|
fetchStateByTransactionTabs: fetchStateByTab,
|
|
97
|
-
uploadReceiptStatusById,
|
|
98
97
|
selectedTransactionId,
|
|
99
98
|
selectedTransactionLineId,
|
|
100
99
|
};
|
|
@@ -7,47 +7,3 @@ const MISSING_RECEIPTS_SORT_KEYS = [
|
|
|
7
7
|
'amount',
|
|
8
8
|
];
|
|
9
9
|
export const toMissingReceiptsSortKey = (v) => stringToUnion(v, MISSING_RECEIPTS_SORT_KEYS);
|
|
10
|
-
// -- Bulk Receipt Upload Types --
|
|
11
|
-
/**
|
|
12
|
-
* Minimum trimmed query length before manual-match search calls the expense-automation API.
|
|
13
|
-
* Kept in sync with `ManualSearchInput` in web-components (fires search only when length ≥ this).
|
|
14
|
-
*/
|
|
15
|
-
export const MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = 2;
|
|
16
|
-
const BATCH_STATUS_VALUES = ['pending', 'processing', 'completed'];
|
|
17
|
-
export const toBatchStatusValue = (v) => stringToUnion(v.trim().toLowerCase(), BATCH_STATUS_VALUES);
|
|
18
|
-
/** Canonical batch file statuses (API ingress may use aliases; see `parseBatchFileStatus`). */
|
|
19
|
-
export const BATCH_FILE_STATUSES = [
|
|
20
|
-
'exact_match',
|
|
21
|
-
'possible_matches',
|
|
22
|
-
'no_match',
|
|
23
|
-
'failed',
|
|
24
|
-
];
|
|
25
|
-
export const toBatchFileStatus = (v) => stringToUnion(v.trim().toLowerCase().replace(/-/g, '_'), BATCH_FILE_STATUSES);
|
|
26
|
-
const UNMATCHED_TAB_FILE_STATUSES = ['possible_matches', 'no_match'];
|
|
27
|
-
/** True for files that belong in the Unmatched tab (possible matches or no match). */
|
|
28
|
-
export function isUnmatchedTabFileStatus(status) {
|
|
29
|
-
return UNMATCHED_TAB_FILE_STATUSES.includes(status);
|
|
30
|
-
}
|
|
31
|
-
const BULK_UPLOAD_PHASES = [
|
|
32
|
-
'idle',
|
|
33
|
-
'uploading',
|
|
34
|
-
'matching',
|
|
35
|
-
'completed',
|
|
36
|
-
];
|
|
37
|
-
export const toBulkUploadPhase = (v) => stringToUnion(v.trim().toLowerCase(), BULK_UPLOAD_PHASES);
|
|
38
|
-
const BULK_UPLOAD_RESULTS_TABS = ['completed', 'unmatched'];
|
|
39
|
-
export const toBulkUploadResultsTab = (v) => stringToUnion(v.trim().toLowerCase(), BULK_UPLOAD_RESULTS_TABS);
|
|
40
|
-
const MISSING_RECEIPTS_TABS = ['missing', 'completed', 'unmatched'];
|
|
41
|
-
export const toMissingReceiptsTab = (v) => stringToUnion(v.trim().toLowerCase(), MISSING_RECEIPTS_TABS);
|
|
42
|
-
const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
|
|
43
|
-
export const toCompletedSubTab = (v) => stringToUnion(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
|
|
44
|
-
const MATCH_SOURCES = ['ai', 'manual'];
|
|
45
|
-
export const toMatchSource = (v) => stringToUnion(v.trim().toLowerCase(), MATCH_SOURCES);
|
|
46
|
-
const BULK_UPLOAD_SORT_KEYS = [
|
|
47
|
-
'amount',
|
|
48
|
-
'category',
|
|
49
|
-
'class',
|
|
50
|
-
'date',
|
|
51
|
-
'vendor',
|
|
52
|
-
];
|
|
53
|
-
export const toBulkUploadSortKey = (v) => stringToUnion(v.trim().toLowerCase(), BULK_UPLOAD_SORT_KEYS);
|
|
@@ -4,11 +4,10 @@ const TRANSACTIONS_SORT_KEYS = [
|
|
|
4
4
|
'vendor',
|
|
5
5
|
'amount',
|
|
6
6
|
'transaction_type',
|
|
7
|
-
'payment_account',
|
|
8
7
|
'date',
|
|
9
8
|
'category',
|
|
10
9
|
'class',
|
|
11
|
-
'
|
|
10
|
+
'memo',
|
|
12
11
|
];
|
|
13
12
|
export const toTransactionsSortKey = (v) => stringToUnion(v, TRANSACTIONS_SORT_KEYS);
|
|
14
13
|
export const TRANSACTIONS_TABS = ['review', 'autoCategorized'];
|
|
@@ -44,20 +44,19 @@ const financeStatement = createSlice({
|
|
|
44
44
|
updateFinanceStatementThisPeriod(draft, action) {
|
|
45
45
|
const { firstMonthOfFY, coaBalances, maxNumOfPeriodsToHighlight } = action.payload;
|
|
46
46
|
const { timeframe, selectedCOABalancesRange } = draft;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const prevThisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
|
|
47
|
+
if (coaBalances.length > 0) {
|
|
48
|
+
const prevThisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, coaBalances);
|
|
50
49
|
if (prevThisPeriod != null) {
|
|
51
50
|
const selectedCoaBalancesRangeWithThisPeriod = {
|
|
52
51
|
...selectedCOABalancesRange,
|
|
53
52
|
thisPeriod: prevThisPeriod,
|
|
54
53
|
};
|
|
55
|
-
const newThisPeriod = getMatchingThisPeriod(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod,
|
|
54
|
+
const newThisPeriod = getMatchingThisPeriod(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod, coaBalances);
|
|
56
55
|
if (newThisPeriod != null) {
|
|
57
56
|
const selectionRanges = getSelectedAndHighlightedRangesForThisPeriod({
|
|
58
57
|
firstMonthOfFY,
|
|
59
58
|
thisPeriod: newThisPeriod,
|
|
60
|
-
coaBalances
|
|
59
|
+
coaBalances,
|
|
61
60
|
timeframe,
|
|
62
61
|
maxNumOfPeriodsToSelect: maxNumOfPeriodsToHighlight,
|
|
63
62
|
currentSelection: {
|
|
@@ -76,9 +75,7 @@ const financeStatement = createSlice({
|
|
|
76
75
|
draft.selectedReportId = action.payload;
|
|
77
76
|
},
|
|
78
77
|
updateFinanceStatementAdditionalBalancesSelection(draft, action) {
|
|
79
|
-
const { firstMonthOfFY, additionalBalances
|
|
80
|
-
const safeCoaBalances = coaBalances != null ? coaBalances : [];
|
|
81
|
-
const additionalBalances = additionalBalancesPayload ?? [];
|
|
78
|
+
const { firstMonthOfFY, additionalBalances, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
|
|
82
79
|
let tempAdditionalBalances = [...additionalBalances];
|
|
83
80
|
if (additionalBalances.includes('this_period_vs_last_period') ||
|
|
84
81
|
additionalBalances.includes('this_period_vs_last_period_percent')) {
|
|
@@ -94,8 +91,8 @@ const financeStatement = createSlice({
|
|
|
94
91
|
draft.isAdditionalBalancesShown =
|
|
95
92
|
additionalBalances.length != 0 ? true : false;
|
|
96
93
|
const { timeframe, selectedCOABalancesRange } = draft;
|
|
97
|
-
if (
|
|
98
|
-
const thisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange,
|
|
94
|
+
if (coaBalances.length > 0) {
|
|
95
|
+
const thisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, coaBalances);
|
|
99
96
|
if (thisPeriod != null) {
|
|
100
97
|
const selectedCoaBalancesRangeWithThisPeriod = {
|
|
101
98
|
...selectedCOABalancesRange,
|
|
@@ -104,7 +101,7 @@ const financeStatement = createSlice({
|
|
|
104
101
|
const selectionRanges = getSelectedAndHighlightedRangesForThisPeriod({
|
|
105
102
|
firstMonthOfFY,
|
|
106
103
|
thisPeriod: thisPeriod,
|
|
107
|
-
coaBalances
|
|
104
|
+
coaBalances,
|
|
108
105
|
timeframe,
|
|
109
106
|
maxNumOfPeriodsToHighlight: maxNumOfPeriodsToHighlight,
|
|
110
107
|
currentSelection: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createSelector } from '@reduxjs/toolkit';
|
|
2
|
-
import { stripCompareAdditionalBalanceTypes } from '../../commonStateTypes/coaBalance/coaBalanceType';
|
|
3
2
|
import { newBalancesFilter, newBalancesFilterForDateRange, } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
|
|
4
3
|
import { newBalancesFilterClassesView } from '../../commonStateTypes/coaBalance/coaBalancesFilterClassesView';
|
|
5
4
|
import { getNumberOfPeriods, } from '../../commonStateTypes/dataAvailable';
|
|
@@ -9,7 +8,6 @@ import { extractThisPeriod } from '../../commonStateTypes/viewAndReport/thisPeri
|
|
|
9
8
|
import { getBalanceSheet } from '../balanceSheet/balanceSheetSelector';
|
|
10
9
|
import { getCashFlow } from '../cashFlow/cashFlowSelector';
|
|
11
10
|
import { getProfitAndLossReport, } from '../profitAndLoss/profitAndLossSelector';
|
|
12
|
-
import { getProfitAndLossClassesHorizontalView } from '../profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector';
|
|
13
11
|
import { getProfitAndLossClassesView } from '../profitAndLossClassesView/profitAndLossClassesViewSelector';
|
|
14
12
|
function getDateRangeForFinanceReports(profitAndLossState, balanceSheetState, cashFlowState) {
|
|
15
13
|
const datesSorted = [
|
|
@@ -44,11 +42,11 @@ export const getFinanceStatement = createSelector((state) => state.accountState,
|
|
|
44
42
|
if (dataAvailable != null) {
|
|
45
43
|
const noFilter = newBalancesFilterForDateRange(firstMonthOfFY, financeStatementState.timeframe, dataAvailable, 'ascending_date', []);
|
|
46
44
|
const profitAndLossForTimeframeTicks = getProfitAndLossReport(noFilter, undefined, accountState, accountGroupState, sectionAccountsViewState, profitAndLossState, forecastState);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
if (profitAndLossForTimeframeTicks.sections.expenses != null) {
|
|
46
|
+
balancesInTimeframe =
|
|
47
|
+
profitAndLossForTimeframeTicks.sections.expenses.balances.length > 0
|
|
48
|
+
? profitAndLossForTimeframeTicks.sections['expenses'].balances
|
|
49
|
+
: profitAndLossForTimeframeTicks.sections['income'].balances;
|
|
52
50
|
allTimeframeTicks = balancesInTimeframe.map((balance) => toTimeframeTick(balance));
|
|
53
51
|
}
|
|
54
52
|
}
|
|
@@ -56,22 +54,12 @@ export const getFinanceStatement = createSelector((state) => state.accountState,
|
|
|
56
54
|
if (thisPeriod == null && balancesInTimeframe.length > 0) {
|
|
57
55
|
thisPeriod = toTimeframeTick(balancesInTimeframe[balancesInTimeframe.length - 1]);
|
|
58
56
|
}
|
|
59
|
-
const
|
|
57
|
+
const filter = newBalancesFilter(firstMonthOfFY, financeStatementState.timeframe, Math.min(getNumberOfPeriods(firstMonthOfFY, financeStatementState.timeframe, dataAvailable) ?? financeStatementState.selectedCOABalancesRange.numberOfPeriods, financeStatementState.selectedCOABalancesRange.numberOfPeriods), thisPeriod, 'ascending_date', financeStatementState.isAdditionalBalancesShown === true
|
|
60
58
|
? financeStatementState.selectedAdditionalBalances
|
|
61
|
-
: [];
|
|
62
|
-
const useHorizontalClassesLayout = profitAndLossClassesViewState.uiState.classViewLayout ===
|
|
63
|
-
'horizontal' &&
|
|
64
|
-
financeStatementState.selectedReportId === 'profit_and_loss_by_classes';
|
|
65
|
-
const additionalBalancesForFilter = useHorizontalClassesLayout
|
|
66
|
-
? stripCompareAdditionalBalanceTypes(rawAdditionalBalances)
|
|
67
|
-
: rawAdditionalBalances;
|
|
68
|
-
const filter = newBalancesFilter(firstMonthOfFY, financeStatementState.timeframe, Math.min(getNumberOfPeriods(firstMonthOfFY, financeStatementState.timeframe, dataAvailable) ?? financeStatementState.selectedCOABalancesRange.numberOfPeriods, financeStatementState.selectedCOABalancesRange.numberOfPeriods), thisPeriod, 'ascending_date', additionalBalancesForFilter);
|
|
59
|
+
: []);
|
|
69
60
|
const profitAndLossReport = getProfitAndLossReport(filter, undefined, accountState, accountGroupState, sectionAccountsViewState, profitAndLossState, forecastState);
|
|
70
61
|
const classFilter = newBalancesFilterClassesView(filter.firstMonthOfFY, filter.timeframe, filter.balancesRange.numberOfPeriods, filter.balancesRange.thisPeriod, filter.balancesRange.orderBy, filter.additionalBalances, profitAndLossClassesViewState.uiState.classesToFilterOut);
|
|
71
62
|
const profitAndLossByClassReport = getProfitAndLossClassesView(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState);
|
|
72
|
-
const profitAndLossByClassHorizontalReport = getProfitAndLossClassesHorizontalView(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState, profitAndLossClassesViewState.uiState.classViewLayout === 'horizontal'
|
|
73
|
-
? thisPeriod
|
|
74
|
-
: undefined);
|
|
75
63
|
const balanceSheetReport = getBalanceSheet(filter, accountState, accountGroupState, sectionAccountsViewState, balanceSheetState);
|
|
76
64
|
const cashFlowReport = getCashFlow(filter, accountState, accountGroupState, sectionAccountsViewState, cashFlowState);
|
|
77
65
|
const allReports = [
|
|
@@ -119,15 +107,12 @@ export const getFinanceStatement = createSelector((state) => state.accountState,
|
|
|
119
107
|
dataAvailable,
|
|
120
108
|
profitAndLossReport,
|
|
121
109
|
profitAndLossByClassReport,
|
|
122
|
-
profitAndLossByClassHorizontalReport,
|
|
123
110
|
balanceSheetReport,
|
|
124
111
|
cashFlowReport,
|
|
125
112
|
filter,
|
|
126
113
|
selectedReportId: financeStatementState.selectedReportId,
|
|
127
114
|
downloadState: financeStatementState.downloadState,
|
|
128
|
-
isCompareModeOn:
|
|
129
|
-
|
|
130
|
-
: financeStatementState.selectedAdditionalBalances.includes('this_period_vs_last_period') ||
|
|
131
|
-
financeStatementState.selectedAdditionalBalances.includes('this_period_vs_last_period_percent'),
|
|
115
|
+
isCompareModeOn: financeStatementState.selectedAdditionalBalances.includes('this_period_vs_last_period') ||
|
|
116
|
+
financeStatementState.selectedAdditionalBalances.includes('this_period_vs_last_period_percent'),
|
|
132
117
|
};
|
|
133
118
|
});
|
|
@@ -23,7 +23,6 @@ export const initialState = {
|
|
|
23
23
|
nodeCollapseState: {},
|
|
24
24
|
scrollPosition: undefined,
|
|
25
25
|
accountViewMode: 'account_group',
|
|
26
|
-
classViewLayout: 'vertical',
|
|
27
26
|
classesToFilterOut: [],
|
|
28
27
|
},
|
|
29
28
|
firstMonthOfFY: 1,
|
|
@@ -95,9 +94,6 @@ const profitAndLossClassesView = createSlice({
|
|
|
95
94
|
updateAccountViewMode(draft, action) {
|
|
96
95
|
draft.uiState.accountViewMode = action.payload.viewMode;
|
|
97
96
|
},
|
|
98
|
-
updateClassViewLayout(draft, action) {
|
|
99
|
-
draft.uiState.classViewLayout = action.payload.classViewLayout;
|
|
100
|
-
},
|
|
101
97
|
resetProfitAndLossClassesNodeCollapseState(draft) {
|
|
102
98
|
draft.uiState.nodeCollapseState = {};
|
|
103
99
|
},
|
|
@@ -106,11 +102,10 @@ const profitAndLossClassesView = createSlice({
|
|
|
106
102
|
},
|
|
107
103
|
},
|
|
108
104
|
});
|
|
109
|
-
export const { fetchProfitAndLossClassesView, fetchProfitAndLossForTimeframeClassesView, updateProfitAndLossForTimeframeClassesView, updateProfitAndLossForTimeframeClassesViewFailure, updateClassesToFilterOut, updateProfitAndLossClassesViewUIState, updateAccountViewMode,
|
|
105
|
+
export const { fetchProfitAndLossClassesView, fetchProfitAndLossForTimeframeClassesView, updateProfitAndLossForTimeframeClassesView, updateProfitAndLossForTimeframeClassesViewFailure, updateClassesToFilterOut, updateProfitAndLossClassesViewUIState, updateAccountViewMode, resetProfitAndLossClassesNodeCollapseState, clearProfitAndLossClassesView, } = profitAndLossClassesView.actions;
|
|
110
106
|
export default profitAndLossClassesView.reducer;
|
|
111
107
|
const doUpdatedProfitAndLossClassesView = (draft, timeframe, pandLReport) => {
|
|
112
108
|
const report = mapReportPayloadV2ToReportV2(pandLReport.report);
|
|
113
|
-
draft.currency = report.currency;
|
|
114
109
|
draft.dataAvailable = report.dataAvailable;
|
|
115
110
|
draft.firstMonthOfFY = report.firstMonthOfFY;
|
|
116
111
|
draft.bookCloseDate = report.bookCloseDate;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getDifferenceOfBalancesGroupedByPeriod } from '../../commonStateTypes/coaBalance/classBalances/getDifferenceOfBalancesGroupedByPeriod';
|
|
2
2
|
import { getSumOfBalancesByGroupedByPeriod } from '../../commonStateTypes/coaBalance/classBalances/getSumOfBalancesGroupedByPeriod';
|
|
3
3
|
import { getCOABalances } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
4
|
-
import { reduceFetchStateParallelTimeframes } from '../../commonStateTypes/reduceFetchState';
|
|
5
4
|
import { getSectionClassesViewReport } from '../../entity/sectionClassesViewV2/sectionClassesViewSelector';
|
|
6
5
|
import { ALL_PANDL_REPORT_VIEW_SECTION_IDS, } from './profitAndLossClassesViewSelectorTypes';
|
|
7
6
|
export const profitAndLossIdsInOrder = [
|
|
@@ -16,7 +15,7 @@ export const profitAndLossIdsInOrder = [
|
|
|
16
15
|
'netIncome',
|
|
17
16
|
];
|
|
18
17
|
export const getProfitAndLossClassesView = (filter, accountState, classState, sectionsState, profitAndLossClassesViewState) => {
|
|
19
|
-
const fetchState =
|
|
18
|
+
const fetchState = reduceFetchState([
|
|
20
19
|
profitAndLossClassesViewState.fetchState.month,
|
|
21
20
|
profitAndLossClassesViewState.fetchState.quarter,
|
|
22
21
|
profitAndLossClassesViewState.fetchState.year,
|
|
@@ -65,3 +64,31 @@ export const getProfitAndLossClassesView = (filter, accountState, classState, se
|
|
|
65
64
|
idsInOrder: profitAndLossIdsInOrder,
|
|
66
65
|
};
|
|
67
66
|
};
|
|
67
|
+
function reduceFetchState(fetchStateList) {
|
|
68
|
+
const isAnyProgress = fetchStateList.reduce((prevValue, currentValue) => {
|
|
69
|
+
return prevValue === true || currentValue.fetchState === 'In-Progress';
|
|
70
|
+
}, false);
|
|
71
|
+
const isAllCompleted = fetchStateList.reduce((prevValue, currentValue) => {
|
|
72
|
+
return prevValue === true && currentValue.fetchState === 'Completed';
|
|
73
|
+
}, true);
|
|
74
|
+
const isAnyError = fetchStateList.reduce((prevValue, currentValue) => {
|
|
75
|
+
return prevValue === true || currentValue.fetchState === 'Error';
|
|
76
|
+
}, false);
|
|
77
|
+
const error = fetchStateList.reduce((prevValue, currentValue) => {
|
|
78
|
+
return prevValue ?? currentValue.error;
|
|
79
|
+
}, undefined);
|
|
80
|
+
let fetchState = 'Not-Started';
|
|
81
|
+
if (isAnyProgress) {
|
|
82
|
+
fetchState = 'In-Progress';
|
|
83
|
+
}
|
|
84
|
+
else if (isAllCompleted) {
|
|
85
|
+
fetchState = 'Completed';
|
|
86
|
+
}
|
|
87
|
+
else if (isAnyError) {
|
|
88
|
+
fetchState = 'Error';
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
fetchState,
|
|
92
|
+
error,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -24,13 +24,11 @@ export const fetchProfitAndLossForTimeframeClassesViewEpic = (actions$, _, zeniA
|
|
|
24
24
|
.pipe(mergeMap((response) => {
|
|
25
25
|
if (response.data != null && isSuccessResponse(response)) {
|
|
26
26
|
const actions = [];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
actions.push(updateSectionClassesView(action.payload.timeframe, '
|
|
30
|
-
actions.push(updateSectionClassesView(action.payload.timeframe, '
|
|
31
|
-
actions.push(updateSectionClassesView(action.payload.timeframe, '
|
|
32
|
-
actions.push(updateSectionClassesView(action.payload.timeframe, 'otherExpenses', 'profit_and_loss_by_classes', report.other_expenses, report.classes, report.accounts, currency));
|
|
33
|
-
actions.push(updateSectionClassesView(action.payload.timeframe, 'otherIncome', 'profit_and_loss_by_classes', report.other_income, report.classes, report.accounts, currency));
|
|
27
|
+
actions.push(updateSectionClassesView(action.payload.timeframe, 'cogs', 'profit_and_loss_by_classes', response.data.report.cogs, response.data.report.classes, response.data.report.accounts, response.data.report.currency));
|
|
28
|
+
actions.push(updateSectionClassesView(action.payload.timeframe, 'expenses', 'profit_and_loss_by_classes', response.data.report.expenses, response.data.report.classes, response.data.report.accounts, response.data.report.currency));
|
|
29
|
+
actions.push(updateSectionClassesView(action.payload.timeframe, 'income', 'profit_and_loss_by_classes', response.data.report.income, response.data.report.classes, response.data.report.accounts, response.data.report.currency));
|
|
30
|
+
actions.push(updateSectionClassesView(action.payload.timeframe, 'otherExpenses', 'profit_and_loss_by_classes', response.data.report.other_expenses, response.data.report.classes, response.data.report.accounts, response.data.report.currency));
|
|
31
|
+
actions.push(updateSectionClassesView(action.payload.timeframe, 'otherIncome', 'profit_and_loss_by_classes', response.data.report.other_income, response.data.report.classes, response.data.report.accounts, response.data.report.currency));
|
|
34
32
|
actions.push(updateProfitAndLossForTimeframeClassesView({
|
|
35
33
|
timeframe: action.payload.timeframe,
|
|
36
34
|
report: response.data,
|
|
@@ -2,19 +2,15 @@ import { of } from 'rxjs';
|
|
|
2
2
|
import { filter, switchMap } from 'rxjs/operators';
|
|
3
3
|
import { updateCashInCashOutCOABalancesRange } from '../cashInCashOut/cashInCashOutReducer';
|
|
4
4
|
import { updateCashPositionCOABalancesRange } from '../cashPosition/cashPositionReducer';
|
|
5
|
-
import { updateCOABalancesRange } from '../financeStatement/financeStatementReducer';
|
|
5
|
+
import { initialFinanceStatementState, updateCOABalancesRange, } from '../financeStatement/financeStatementReducer';
|
|
6
6
|
import { updateNetBurnOrIncomeCOABalancesRange } from '../netBurnOrIncome/netBurnOrIncomeReducer';
|
|
7
7
|
import { updateOpExCOABalancesRange } from '../opEx/opExReducer';
|
|
8
8
|
import { updateRevenueCOABalancesRange } from '../revenue/revenueReducer';
|
|
9
9
|
import { updateReportUIOptionCOABalancesRange } from './reportUIOptionsReducer';
|
|
10
10
|
export const updateReportUIOptionCOABalancesRangeEpic = (actions$, state$) => actions$.pipe(filter(updateReportUIOptionCOABalancesRange.match), switchMap((action) => {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const numberOfPeriodsFromSelection = selectedRange.numberOfPeriods;
|
|
15
|
-
const highlightedNoOfPeriods = state$.value.reportUIOptionsState.isCompareModeOn === true
|
|
16
|
-
? numberOfPeriodsFromSelection
|
|
17
|
-
: 1;
|
|
11
|
+
const thisPeriod = action.payload.selectedCOABalancesRange.thisPeriod;
|
|
12
|
+
const orderBy = action.payload.selectedCOABalancesRange.orderBy;
|
|
13
|
+
const highlightedNoOfPeriods = state$.value.reportUIOptionsState.isCompareModeOn === true ? 4 : 1;
|
|
18
14
|
const highlightedCOABalancesRange = action.payload.highlightedCOABalancesRange == null && thisPeriod != null
|
|
19
15
|
? {
|
|
20
16
|
numberOfPeriods: highlightedNoOfPeriods,
|
|
@@ -66,7 +62,9 @@ export const updateReportUIOptionCOABalancesRangeEpic = (actions$, state$) => ac
|
|
|
66
62
|
thisPeriod: action.payload.highlightedCOABalancesRange != null
|
|
67
63
|
? action.payload.highlightedCOABalancesRange.thisPeriod
|
|
68
64
|
: thisPeriod,
|
|
69
|
-
numberOfPeriods:
|
|
65
|
+
numberOfPeriods: state$.value.reportUIOptionsState.isCompareModeOn === true
|
|
66
|
+
? 4
|
|
67
|
+
: initialFinanceStatementState.maxNumOfPeriodsToHighlight,
|
|
70
68
|
orderBy,
|
|
71
69
|
}));
|
|
72
70
|
}));
|
|
@@ -70,7 +70,6 @@ const toTaskPayload = (state, task) => {
|
|
|
70
70
|
name: task.name,
|
|
71
71
|
assignees: task.assignees,
|
|
72
72
|
description: task.description,
|
|
73
|
-
group_assignees: task.groupAssignees,
|
|
74
73
|
due_date: task.dueDate != null ? task.dueDate.format(DEFAULT_DATE_FORMAT) : null,
|
|
75
74
|
priority: task.priority.code,
|
|
76
75
|
status: task.status.code,
|