@zeniai/client-epic-state 5.0.69-betaML21 → 5.0.69-betaML31
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/viewAndReport/viewAndReport.d.ts +2 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +0 -2
- package/lib/entity/account/accountSelector.d.ts +0 -9
- package/lib/entity/account/accountSelector.js +1 -14
- package/lib/entity/account/accountState.d.ts +1 -1
- package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
- package/lib/entity/class/classReducer.d.ts +4 -4
- package/lib/entity/class/classState.d.ts +1 -1
- package/lib/entity/forecast/forecastState.d.ts +1 -1
- package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
- package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/entity/tenant/clearAllEpic.d.ts +1 -2
- package/lib/entity/tenant/clearAllEpic.js +0 -2
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +0 -4
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +10 -18
- package/lib/entity/transaction/stateTypes/transaction.d.ts +0 -3
- package/lib/epic.d.ts +2 -3
- package/lib/epic.js +2 -3
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +0 -2
- package/lib/esm/entity/account/accountSelector.js +0 -11
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -2
- package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +10 -18
- package/lib/esm/epic.js +2 -3
- package/lib/esm/index.js +8 -9
- package/lib/esm/reducer.js +0 -3
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +0 -8
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +21 -1
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +117 -26
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +59 -9
- package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +83 -0
- package/lib/esm/view/recommendation/recommendationHelper.js +29 -0
- package/lib/esm/view/recommendation/recommendationReducer.js +36 -1
- package/lib/esm/view/transactionDetail/epics/transactionDetailEpic.js +2 -14
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +122 -8
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +23 -6
- package/lib/index.d.ts +9 -9
- package/lib/index.js +36 -43
- package/lib/reducer.d.ts +0 -3
- package/lib/reducer.js +0 -3
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
- package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
- package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
- package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
- package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
- package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
- package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +1 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +0 -8
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +2 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +23 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +15 -4
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +117 -26
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +3 -4
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +3 -1
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +61 -11
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -0
- package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +9 -0
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +87 -0
- package/lib/view/recommendation/recommendationHelper.d.ts +9 -0
- package/lib/view/recommendation/recommendationHelper.js +31 -1
- package/lib/view/recommendation/recommendationReducer.d.ts +18 -1
- package/lib/view/recommendation/recommendationReducer.js +37 -2
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
- package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
- package/lib/view/topEx/topExSelector.d.ts +1 -1
- package/lib/view/transactionDetail/epics/transactionDetailEpic.d.ts +1 -2
- package/lib/view/transactionDetail/epics/transactionDetailEpic.js +2 -14
- package/lib/view/transactionDetail/transactionDetailPayload.d.ts +1 -1
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +12 -3
- package/lib/view/transactionDetail/transactionDetailReducer.js +123 -9
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +3 -6
- package/lib/view/transactionDetail/transactionDetailSelector.js +25 -7
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +1 -0
- package/package.json +1 -1
- package/lib/esm/view/createTransferEntry/createTransferEntryReducer.js +0 -72
- package/lib/esm/view/createTransferEntry/createTransferEntrySelector.js +0 -64
- package/lib/esm/view/createTransferEntry/createTransferEntryState.js +0 -17
- package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +0 -130
- package/lib/esm/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +0 -36
- package/lib/view/createTransferEntry/createTransferEntryReducer.d.ts +0 -32
- package/lib/view/createTransferEntry/createTransferEntryReducer.js +0 -76
- package/lib/view/createTransferEntry/createTransferEntrySelector.d.ts +0 -39
- package/lib/view/createTransferEntry/createTransferEntrySelector.js +0 -69
- package/lib/view/createTransferEntry/createTransferEntryState.d.ts +0 -30
- package/lib/view/createTransferEntry/createTransferEntryState.js +0 -20
- package/lib/view/createTransferEntry/epics/createTransferEntryEpic.d.ts +0 -11
- package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +0 -134
- package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.d.ts +0 -14
- package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +0 -40
package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js
CHANGED
|
@@ -59,6 +59,22 @@ export const filterAutoTabLineItems = (tabView, transactionId, updatedTransactio
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
export const MAX_SELECTION_LIMIT = 5;
|
|
62
|
+
// Returns true when the transaction should be auto-added to the
|
|
63
|
+
// selectedCheckBoxTransactionIds list after a categorization-related
|
|
64
|
+
// state mutation: all line items are filled, the selection limit has
|
|
65
|
+
// not been hit, and the id isn't already in the list. Consolidates the
|
|
66
|
+
// triplet that was inlined at four sites (updateSelectedCustomer/Vendor,
|
|
67
|
+
// setAllItemsToCategoryClassInLocalDataForCategorization, and
|
|
68
|
+
// setEntityRecommendationForLineIdInLocalData below).
|
|
69
|
+
export const shouldAutoSelectAndAdd = (transaction, localData, selectedCheckBoxTransactionIds, uncategorizedAccounts, isUncategorizedExpenseCategoryEnabled, isAccountingClassesEnabled) => {
|
|
70
|
+
if (selectedCheckBoxTransactionIds.includes(transaction.id)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (selectedCheckBoxTransactionIds.length >= MAX_SELECTION_LIMIT) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return checkIfAllLineItemsAreCategoryClassFilled(transaction, localData, uncategorizedAccounts, isUncategorizedExpenseCategoryEnabled, isAccountingClassesEnabled);
|
|
77
|
+
};
|
|
62
78
|
export const toTransactionDetailLocalData = (transaction, selectedTab, lineItemsByTransactionIds, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled) => {
|
|
63
79
|
const transactionLocal = {
|
|
64
80
|
...initialSupportedTransactionCategorization.transactionReviewLocalData,
|
|
@@ -544,10 +560,14 @@ export const setEntityRecommendationForLineIdInLocalData = (draft, transaction,
|
|
|
544
560
|
selectedEntity: transactionDetailLocalData.selectedEntity,
|
|
545
561
|
tabSpecificLineItems: transactionDetailLocalData.tabSpecificLineItems,
|
|
546
562
|
};
|
|
563
|
+
// Auto-uncheck if not all line items are filled (the row's
|
|
564
|
+
// category/class became stale after the entity update). Otherwise
|
|
565
|
+
// route through shouldAutoSelectAndAdd so the MAX_SELECTION_LIMIT
|
|
566
|
+
// gate is consistently applied across all auto-add sites.
|
|
547
567
|
if (!checkIfAllLineItemsAreCategoryClassFilled(transaction, newLocalData, uncategorizedAccounts, isUncategorizedExpenseCategoryEnabled, isAccountingClassesEnabled)) {
|
|
548
568
|
selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
549
569
|
}
|
|
550
|
-
else if (
|
|
570
|
+
else if (shouldAutoSelectAndAdd(transaction, newLocalData, selectedCheckBoxTransactionIds, uncategorizedAccounts, isUncategorizedExpenseCategoryEnabled, isAccountingClassesEnabled)) {
|
|
551
571
|
selectedCheckBoxTransactionIds.push(transaction.id);
|
|
552
572
|
}
|
|
553
573
|
draft.selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds;
|
|
@@ -3,9 +3,8 @@ import recordGet from 'lodash/get';
|
|
|
3
3
|
import uniq from 'lodash/uniq';
|
|
4
4
|
import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
5
5
|
import { isVendorTransaction } from '../../../entity/transaction/stateTypes/vendorTransaction';
|
|
6
|
-
import {
|
|
6
|
+
import { filterAutoTabLineItems, mergeTabSpecificLineItems, removeTransactionFromTabView, setEntityRecommendationForLineIdInLocalData, shouldAutoSelectAndAdd, toSetAllLineItemsToCategoryClass, toTransactionDetailLocalData, } from '../helpers/transactionCategorizationLocalDataHelper';
|
|
7
7
|
import { DEFAULT_COMPLETED_SUB_TAB, } from '../types/completedSubTab';
|
|
8
|
-
import { TRANSACTIONS_TABS, } from '../types/transactionsViewState';
|
|
9
8
|
export const initialTransactionTabViewState = {
|
|
10
9
|
saveStatus: {
|
|
11
10
|
fetchState: 'Not-Started',
|
|
@@ -421,12 +420,9 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
421
420
|
const selectedCheckBoxTransactionIds = draft.transactionCategorizationView[selectedTab]
|
|
422
421
|
.selectedCheckBoxTransactionIds;
|
|
423
422
|
if (selectedTransaction != null &&
|
|
424
|
-
|
|
425
|
-
selectedCheckBoxTransactionIds.length < MAX_SELECTION_LIMIT &&
|
|
426
|
-
selectedCheckBoxTransactionIds.includes(transactionId) === false) {
|
|
423
|
+
shouldAutoSelectAndAdd(selectedTransaction, newTransactionLocalData, selectedCheckBoxTransactionIds, uncategorizedAccounts, isUncategorizedExpenseCategoryEnabled, isAccountingClassesEnabled)) {
|
|
427
424
|
draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds = [
|
|
428
|
-
...
|
|
429
|
-
.selectedCheckBoxTransactionIds,
|
|
425
|
+
...selectedCheckBoxTransactionIds,
|
|
430
426
|
transactionId,
|
|
431
427
|
];
|
|
432
428
|
}
|
|
@@ -509,9 +505,26 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
509
505
|
const transactionLocalData = recordGet(draft.transactionCategorizationView[selectedTab]
|
|
510
506
|
.transactionReviewLocalDataById, transactionId.id, undefined);
|
|
511
507
|
if (transactionLocalData != null) {
|
|
508
|
+
const newLocalData = setEntityRecommendationForLineIdInLocalData(draft.transactionCategorizationView[selectedTab], transaction, transactionLocalData.transactionReviewLocalData, entity, lineIds, uncategorizedAccounts, action.payload.recommendationWithCOTByLineId, isUncategorizedExpenseCategoryEnabled, isAccountingClassesEnabled);
|
|
509
|
+
// Release the per-line fetch flag for every line this fetch
|
|
510
|
+
// covered. Done in-place on the freshly returned local data
|
|
511
|
+
// (the helper produces a new mutable object), before we write
|
|
512
|
+
// it back to the draft.
|
|
513
|
+
lineIds.forEach((lineId) => {
|
|
514
|
+
const lineItem = newLocalData.lineItemById[lineId];
|
|
515
|
+
if (lineItem != null) {
|
|
516
|
+
newLocalData.lineItemById[lineId] = {
|
|
517
|
+
...lineItem,
|
|
518
|
+
categoryClassRecommendationsFetchState: {
|
|
519
|
+
fetchState: 'Completed',
|
|
520
|
+
error: undefined,
|
|
521
|
+
},
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
});
|
|
512
525
|
draft.transactionCategorizationView[selectedTab].transactionReviewLocalDataById[transaction.id] = {
|
|
513
526
|
transactionId: transaction.id,
|
|
514
|
-
transactionReviewLocalData:
|
|
527
|
+
transactionReviewLocalData: newLocalData,
|
|
515
528
|
};
|
|
516
529
|
// Mark transaction as dirty (autofill happened)
|
|
517
530
|
if (!draft.transactionCategorizationView[selectedTab].transactionIdsWithUnsavedData.includes(transaction.id)) {
|
|
@@ -524,6 +537,99 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
524
537
|
}
|
|
525
538
|
},
|
|
526
539
|
},
|
|
540
|
+
// Start arm of the line-update recommendations fetch. Flips covered
|
|
541
|
+
// lines to In-Progress AND removes the transaction from
|
|
542
|
+
// selectedCheckBoxTransactionIds — the row is unchecked + disabled
|
|
543
|
+
// until either the success arm (recheck if limit allows) or the
|
|
544
|
+
// failure arm releases the per-line flag.
|
|
545
|
+
markCategoryClassRecommendationsInProgressForCategorization: {
|
|
546
|
+
reducer(draft, action) {
|
|
547
|
+
const { selectedTab, transactionId, lineIds } = action.payload;
|
|
548
|
+
const tab = draft.transactionCategorizationView[selectedTab];
|
|
549
|
+
const transactionLocalData = recordGet(tab.transactionReviewLocalDataById, transactionId.id, undefined);
|
|
550
|
+
if (transactionLocalData != null) {
|
|
551
|
+
lineIds.forEach((lineId) => {
|
|
552
|
+
const lineItem = transactionLocalData.transactionReviewLocalData.lineItemById[lineId];
|
|
553
|
+
if (lineItem != null) {
|
|
554
|
+
transactionLocalData.transactionReviewLocalData.lineItemById[lineId] = {
|
|
555
|
+
...lineItem,
|
|
556
|
+
categoryClassRecommendationsFetchState: {
|
|
557
|
+
fetchState: 'In-Progress',
|
|
558
|
+
error: undefined,
|
|
559
|
+
},
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
// Uncheck on fetch start: the row's existing category/class are
|
|
565
|
+
// stale after a payee change, so we drop the auto-selection until
|
|
566
|
+
// fresh recommendations land.
|
|
567
|
+
if (tab.selectedCheckBoxTransactionIds.includes(transactionId.id)) {
|
|
568
|
+
tab.selectedCheckBoxTransactionIds =
|
|
569
|
+
tab.selectedCheckBoxTransactionIds.filter((id) => id !== transactionId.id);
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
prepare(selectedTab, transactionId, lineIds) {
|
|
573
|
+
return { payload: { selectedTab, transactionId, lineIds } };
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
// Completed arm. Used by the epic when the HTTP call succeeds but the
|
|
577
|
+
// server returned no per-line recommendations — we still need to
|
|
578
|
+
// release the In-Progress flag so the skeleton resolves. Successful
|
|
579
|
+
// responses with recommendations go through
|
|
580
|
+
// setEntityRecommendationForLineIdsForCategorization instead (which
|
|
581
|
+
// also flips the lines to Completed).
|
|
582
|
+
markCategoryClassRecommendationsCompletedForCategorization: {
|
|
583
|
+
reducer(draft, action) {
|
|
584
|
+
const { selectedTab, transactionId, lineIds } = action.payload;
|
|
585
|
+
const transactionLocalData = recordGet(draft.transactionCategorizationView[selectedTab]
|
|
586
|
+
.transactionReviewLocalDataById, transactionId.id, undefined);
|
|
587
|
+
if (transactionLocalData != null) {
|
|
588
|
+
lineIds.forEach((lineId) => {
|
|
589
|
+
const lineItem = transactionLocalData.transactionReviewLocalData.lineItemById[lineId];
|
|
590
|
+
if (lineItem != null) {
|
|
591
|
+
transactionLocalData.transactionReviewLocalData.lineItemById[lineId] = {
|
|
592
|
+
...lineItem,
|
|
593
|
+
categoryClassRecommendationsFetchState: {
|
|
594
|
+
fetchState: 'Completed',
|
|
595
|
+
error: undefined,
|
|
596
|
+
},
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
prepare(selectedTab, transactionId, lineIds) {
|
|
603
|
+
return { payload: { selectedTab, transactionId, lineIds } };
|
|
604
|
+
},
|
|
605
|
+
},
|
|
606
|
+
// Failure arm. Flips covered lines to Error so the skeleton resolves
|
|
607
|
+
// and downstream UI can react to the failure. The transaction stays
|
|
608
|
+
// unchecked from the start-arm action.
|
|
609
|
+
markCategoryClassRecommendationsFailureForCategorization: {
|
|
610
|
+
reducer(draft, action) {
|
|
611
|
+
const { selectedTab, transactionId, lineIds, error } = action.payload;
|
|
612
|
+
const transactionLocalData = recordGet(draft.transactionCategorizationView[selectedTab]
|
|
613
|
+
.transactionReviewLocalDataById, transactionId.id, undefined);
|
|
614
|
+
if (transactionLocalData != null) {
|
|
615
|
+
lineIds.forEach((lineId) => {
|
|
616
|
+
const lineItem = transactionLocalData.transactionReviewLocalData.lineItemById[lineId];
|
|
617
|
+
if (lineItem != null) {
|
|
618
|
+
transactionLocalData.transactionReviewLocalData.lineItemById[lineId] = {
|
|
619
|
+
...lineItem,
|
|
620
|
+
categoryClassRecommendationsFetchState: {
|
|
621
|
+
fetchState: 'Error',
|
|
622
|
+
error,
|
|
623
|
+
},
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
prepare(selectedTab, transactionId, lineIds, error) {
|
|
630
|
+
return { payload: { selectedTab, transactionId, lineIds, error } };
|
|
631
|
+
},
|
|
632
|
+
},
|
|
527
633
|
fetchTransactionCategorizationSuccess(draft, action) {
|
|
528
634
|
const { selectedTab, refreshViewInBackground } = action.payload;
|
|
529
635
|
if (draft.transactionCategorizationView[selectedTab].fetchState ===
|
|
@@ -619,9 +725,7 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
619
725
|
.selectedCheckBoxTransactionIds;
|
|
620
726
|
if (newTransactionLocalData.customer != null &&
|
|
621
727
|
newTransactionLocalData.customer.id != null &&
|
|
622
|
-
|
|
623
|
-
selectedCheckBoxTransactionIds.length < MAX_SELECTION_LIMIT &&
|
|
624
|
-
selectedCheckBoxTransactionIds.includes(transactionId) === false) {
|
|
728
|
+
shouldAutoSelectAndAdd(selectedTransaction, newTransactionLocalData, selectedCheckBoxTransactionIds, uncategorizedAccounts, isUncategorizedExpenseCategoryEnabled, isAccountingClassesEnabled)) {
|
|
625
729
|
draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds = [
|
|
626
730
|
...selectedCheckBoxTransactionIds,
|
|
627
731
|
transactionId,
|
|
@@ -695,9 +799,7 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
695
799
|
.selectedCheckBoxTransactionIds;
|
|
696
800
|
if (newTransactionLocalData.vendor != null &&
|
|
697
801
|
newTransactionLocalData.vendor.id != null &&
|
|
698
|
-
|
|
699
|
-
selectedCheckBoxTransactionIds.length < MAX_SELECTION_LIMIT &&
|
|
700
|
-
selectedCheckBoxTransactionIds.includes(transactionId) === false) {
|
|
802
|
+
shouldAutoSelectAndAdd(selectedTransaction, newTransactionLocalData, selectedCheckBoxTransactionIds, uncategorizedAccounts, isUncategorizedExpenseCategoryEnabled, isAccountingClassesEnabled)) {
|
|
701
803
|
draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds = [
|
|
702
804
|
...selectedCheckBoxTransactionIds,
|
|
703
805
|
transactionId,
|
|
@@ -928,18 +1030,7 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
928
1030
|
};
|
|
929
1031
|
},
|
|
930
1032
|
},
|
|
931
|
-
removeTransactionFromAllTabs: {
|
|
932
|
-
prepare(transactionId) {
|
|
933
|
-
return { payload: { transactionId } };
|
|
934
|
-
},
|
|
935
|
-
reducer(draft, action) {
|
|
936
|
-
const { transactionId } = action.payload;
|
|
937
|
-
for (const tab of TRANSACTIONS_TABS) {
|
|
938
|
-
removeTransactionFromTabView(draft.transactionCategorizationView[tab], transactionId);
|
|
939
|
-
}
|
|
940
|
-
},
|
|
941
|
-
},
|
|
942
1033
|
},
|
|
943
1034
|
});
|
|
944
|
-
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, updateParentTotalCountForTab, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab,
|
|
1035
|
+
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, updateParentTotalCountForTab, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, markCategoryClassRecommendationsInProgressForCategorization, markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
|
|
945
1036
|
export default expenseAutomationTransactionsView.reducer;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createSelector } from '@reduxjs/toolkit';
|
|
1
2
|
import omit from 'lodash/omit';
|
|
2
3
|
import { reduceAllFetchState, reduceAnyFetchState, } from '../../../commonStateTypes/reduceFetchState';
|
|
3
4
|
import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
@@ -6,14 +7,63 @@ import { getTransactionWithCOT } from '../../../entity/transaction/transactionHe
|
|
|
6
7
|
import { getSupportedTransactionsByIds } from '../../../entity/transaction/transactionSelector';
|
|
7
8
|
import { getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
|
|
8
9
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
9
|
-
import { getResolvedTransferAccounts } from '../../createTransferEntry/createTransferEntrySelector';
|
|
10
10
|
import { getProjectList } from '../../projectList/projectListSelector';
|
|
11
11
|
import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
|
|
12
|
-
//
|
|
13
|
-
// `
|
|
14
|
-
|
|
12
|
+
// Walks the tab's transactionReviewLocalDataById map and returns
|
|
13
|
+
// `{ [transactionId]: true }` for every transaction that has at least
|
|
14
|
+
// one line whose targeted-fetch is In-Progress. Pulled out as a plain
|
|
15
|
+
// function so each tab's createSelector can share it.
|
|
16
|
+
const computeCategorizationInFlightRecommendations = (transactionReviewLocalDataById) => {
|
|
17
|
+
const result = {};
|
|
18
|
+
if (transactionReviewLocalDataById == null) {
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
for (const [transactionId, data] of Object.entries(transactionReviewLocalDataById)) {
|
|
22
|
+
const lineItems = Object.values(data.transactionReviewLocalData.lineItemById);
|
|
23
|
+
if (lineItems.some((lineItem) => lineItem.categoryClassRecommendationsFetchState?.fetchState ===
|
|
24
|
+
'In-Progress')) {
|
|
25
|
+
result[transactionId] = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
// Per-tab createSelector instances. Each one is memoized on its OWN tab's
|
|
31
|
+
// transactionReviewLocalDataById reference. Switching tabs A->B->A no
|
|
32
|
+
// longer busts the memo for tab A — the dispatcher below just returns
|
|
33
|
+
// whichever per-tab selector matches the active tab, and reselect keeps
|
|
34
|
+
// the prior result alive as long as the underlying slice ref is stable.
|
|
35
|
+
const getReviewInFlightRecommendationsByTransactionId = createSelector((state) => state.expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
36
|
+
.review.transactionReviewLocalDataById, computeCategorizationInFlightRecommendations);
|
|
37
|
+
const getAutoCategorizedInFlightRecommendationsByTransactionId = createSelector((state) => state.expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
38
|
+
.autoCategorized.transactionReviewLocalDataById, computeCategorizationInFlightRecommendations);
|
|
39
|
+
// Per-transaction "any line is fetching category/class recommendations?"
|
|
40
|
+
// map for the active categorization tab. Dispatches to the per-tab
|
|
41
|
+
// memoized selector above so steady state (no fetches in flight)
|
|
42
|
+
// recomputes only when the active tab's local data changes; tab switches
|
|
43
|
+
// are O(1) cache lookups.
|
|
44
|
+
//
|
|
45
|
+
// `default` guards against the union "lying" at runtime: `TransactionsTab`
|
|
46
|
+
// is produced via `stringToUnion`, which falls back to `s as StringUnion`
|
|
47
|
+
// for unrecognized strings, so an unexpected value can land in state. The
|
|
48
|
+
// downstream `getCategorizationHasInFlightRecommendations` calls
|
|
49
|
+
// `Object.keys` on this result, so we must always return an object.
|
|
50
|
+
export const getCategorizationInFlightRecommendationsByTransactionId = (state) => {
|
|
51
|
+
const tab = state.expenseAutomationTransactionsViewState
|
|
52
|
+
.selectedTransactionCategorizationTab;
|
|
53
|
+
switch (tab) {
|
|
54
|
+
case 'review':
|
|
55
|
+
return getReviewInFlightRecommendationsByTransactionId(state);
|
|
56
|
+
case 'autoCategorized':
|
|
57
|
+
return getAutoCategorizedInFlightRecommendationsByTransactionId(state);
|
|
58
|
+
default:
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// Page-level "any line on the active tab is in flight?" flag. Drives the
|
|
63
|
+
// list-page Save disable.
|
|
64
|
+
export const getCategorizationHasInFlightRecommendations = createSelector(getCategorizationInFlightRecommendationsByTransactionId, (inFlightByTransactionId) => Object.keys(inFlightByTransactionId).length > 0);
|
|
15
65
|
export function getExpenseAutomationTransactionView(state) {
|
|
16
|
-
const { accountState, classState, classListState, accountListState,
|
|
66
|
+
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
17
67
|
const { selectedTransactionCategorizationCompletedSubTab, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
|
|
18
68
|
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
19
69
|
const uncategorizedIncomeExpense = getUncategorizedAccounts(accountState, accountListState, 'accountList');
|
|
@@ -107,7 +157,8 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
107
157
|
: [];
|
|
108
158
|
const transactionCompletionStatus = allSteps.find((step) => step.step === 'transaction_categorization')?.completionStatus;
|
|
109
159
|
const completionStatus = transactionCompletionStatus ?? 'incomplete';
|
|
110
|
-
const
|
|
160
|
+
const inFlightCategoryClassRecommendationsByTransactionId = getCategorizationInFlightRecommendationsByTransactionId(state);
|
|
161
|
+
const hasInFlightCategoryClassRecommendations = getCategorizationHasInFlightRecommendations(state);
|
|
111
162
|
return {
|
|
112
163
|
version: 0,
|
|
113
164
|
fetchState: fetchStatus.fetchState,
|
|
@@ -121,6 +172,8 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
121
172
|
classList: allClasses,
|
|
122
173
|
accountsHierarchyList,
|
|
123
174
|
classHierarchyList,
|
|
175
|
+
hasInFlightCategoryClassRecommendations,
|
|
176
|
+
inFlightCategoryClassRecommendationsByTransactionId,
|
|
124
177
|
isAccountingProjectsEnabled,
|
|
125
178
|
projectList,
|
|
126
179
|
transactionLocalData,
|
|
@@ -128,7 +181,6 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
128
181
|
refreshStatus,
|
|
129
182
|
saveStatus,
|
|
130
183
|
markAsNotMiscategorizedStatus,
|
|
131
|
-
createTransferEntryStatus: createTransferEntryState.createTransferEntryStatus,
|
|
132
184
|
completionStatus,
|
|
133
185
|
totalCountByTab,
|
|
134
186
|
parentTabTotalCountByTab,
|
|
@@ -136,8 +188,6 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
136
188
|
uploadReceiptStatusById,
|
|
137
189
|
selectedTransactionId,
|
|
138
190
|
selectedTransactionLineId,
|
|
139
|
-
creditCardTransferAccountsList,
|
|
140
|
-
transferAccounts: transferAccountsList,
|
|
141
191
|
selectedTransactionCategorizationCompletedSubTab,
|
|
142
192
|
};
|
|
143
193
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { concat, of, timer } from 'rxjs';
|
|
2
|
+
import { catchError, debounce, filter, groupBy, mergeMap, switchMap, } from 'rxjs/operators';
|
|
3
|
+
import { getIsAccountingClassesEnabled } from '../../entity/tenant/tenantSelector';
|
|
4
|
+
import { getTransactionWithCOT, getTransactionWithCOTFromRecommendations, } from '../../entity/transaction/transactionHelper';
|
|
5
|
+
import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
|
|
6
|
+
import { getUncategorizedAccounts } from '../accountList/accountListSelector';
|
|
7
|
+
import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization, } from '../expenseAutomationView/reducers/transactionsViewReducer';
|
|
8
|
+
import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail, } from '../transactionDetail/transactionDetailReducer';
|
|
9
|
+
import { buildRecommendationUrl, getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT, } from './recommendationHelper';
|
|
10
|
+
import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
|
|
11
|
+
// Close the per-target groupBy bucket after this much idle time so inactive
|
|
12
|
+
// groups don't accumulate forever (each group holds a Subject + a chain of
|
|
13
|
+
// active subscribers; without a duration selector groupBy retains them for
|
|
14
|
+
// the lifetime of the source observable, which is the lifetime of the app).
|
|
15
|
+
// Picked at 60s to leave a generous window for re-fetches on the same
|
|
16
|
+
// payee/transaction/line target while still bounding memory.
|
|
17
|
+
const GROUP_INACTIVITY_TIMEOUT_MS = 60000;
|
|
18
|
+
// Build the groupBy key. Same flow + same transaction + same line set
|
|
19
|
+
// share a target so switchMap can cancel an in-flight prior fetch. Use
|
|
20
|
+
// NUL (\u0000) as separator because it can never appear in transaction
|
|
21
|
+
// or line ids (vs the `|` used in an earlier WIP which collides with
|
|
22
|
+
// pipe-delimited synthetic ids).
|
|
23
|
+
const SEPARATOR = '\u0000';
|
|
24
|
+
const toGroupKey = (flowType, transactionId, lineIds) => `${flowType}${SEPARATOR}${transactionId}${SEPARATOR}${[...lineIds]
|
|
25
|
+
.sort((a, b) => a.localeCompare(b))
|
|
26
|
+
.join(SEPARATOR)}`;
|
|
27
|
+
// Targeted recommendations fetch that drives the per-line skeleton, the
|
|
28
|
+
// list-page row-checkbox uncheck/recheck, and the page-level Save
|
|
29
|
+
// disable.
|
|
30
|
+
//
|
|
31
|
+
// Concurrency model:
|
|
32
|
+
// - groupBy by (flowType, transactionId, sorted lineIds) so distinct
|
|
33
|
+
// targets run in parallel.
|
|
34
|
+
// - inside each group, switchMap so a re-fetch on the SAME target
|
|
35
|
+
// cancels any prior in-flight request for that target.
|
|
36
|
+
// - groupBy duration selector closes idle groups to bound memory.
|
|
37
|
+
export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchEntityRecommendationsForLineUpdate.match), groupBy((action) => toGroupKey(action.payload.flowType, action.payload.transactionDetails.transactionId.id, action.payload.transactionDetails.lineIds), undefined, (group$) => group$.pipe(debounce(() => timer(GROUP_INACTIVITY_TIMEOUT_MS)))), mergeMap((group$) => group$.pipe(switchMap((action) => {
|
|
38
|
+
const { entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = action.payload;
|
|
39
|
+
const { transactionId, transaction, lineIds } = transactionDetails;
|
|
40
|
+
// Synchronously emit the start arm so the per-line skeleton +
|
|
41
|
+
// row uncheck happen before the HTTP request begins.
|
|
42
|
+
const startAction = flowType === 'categorization' && selectedTab != null
|
|
43
|
+
? markCategoryClassRecommendationsInProgressForCategorization(selectedTab, transactionId, lineIds)
|
|
44
|
+
: markCategoryClassRecommendationsInProgressForTransactionDetail(transactionId, lineIds);
|
|
45
|
+
const url = buildRecommendationUrl(zeniAPI.apiEndPoints.accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT === true);
|
|
46
|
+
const httpStream$ = zeniAPI
|
|
47
|
+
.getJSON(url)
|
|
48
|
+
.pipe(mergeMap((response) => {
|
|
49
|
+
if (!isSuccessResponse(response) || response.data == null) {
|
|
50
|
+
return of(flowType === 'categorization' && selectedTab != null
|
|
51
|
+
? markCategoryClassRecommendationsFailureForCategorization(selectedTab, transactionId, lineIds, response.status)
|
|
52
|
+
: markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, response.status));
|
|
53
|
+
}
|
|
54
|
+
const recommendationWithCOTByLineId = getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT(response.data.recommendations, lineIds);
|
|
55
|
+
// HTTP 200 with no per-line recommendations: NOT an error.
|
|
56
|
+
// Flip lines to Completed so the skeleton resolves and
|
|
57
|
+
// downstream UI can treat this as "we tried, nothing to
|
|
58
|
+
// apply".
|
|
59
|
+
if (recommendationWithCOTByLineId == null) {
|
|
60
|
+
return of(flowType === 'categorization' && selectedTab != null
|
|
61
|
+
? markCategoryClassRecommendationsCompletedForCategorization(selectedTab, transactionId, lineIds)
|
|
62
|
+
: markCategoryClassRecommendationsCompletedForTransactionDetail(transactionId, lineIds));
|
|
63
|
+
}
|
|
64
|
+
const transactionWithCOT = isFetchCOT === true
|
|
65
|
+
? getTransactionWithCOTFromRecommendations(transaction, recommendationWithCOTByLineId)
|
|
66
|
+
: getTransactionWithCOT(transaction);
|
|
67
|
+
const uncategorizedIncomeExpense = getUncategorizedAccounts(state$.value.accountState, state$.value.accountListState, 'accountList');
|
|
68
|
+
if (flowType === 'categorization' && selectedTab != null) {
|
|
69
|
+
return of(setEntityRecommendationForLineIdsForCategorization(selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, getIsAccountingClassesEnabled(state$.value)));
|
|
70
|
+
}
|
|
71
|
+
return of(setEntityRecommendationForLineIdsForTransactionDetail(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
|
|
72
|
+
}), catchError((error) => {
|
|
73
|
+
const errorMessage = 'fetchEntityRecommendationsForLineUpdate failed: ' +
|
|
74
|
+
(error instanceof Error
|
|
75
|
+
? error.message
|
|
76
|
+
: JSON.stringify(error));
|
|
77
|
+
const status = createZeniAPIStatus('Unexpected Error', errorMessage);
|
|
78
|
+
return of(flowType === 'categorization' && selectedTab != null
|
|
79
|
+
? markCategoryClassRecommendationsFailureForCategorization(selectedTab, transactionId, lineIds, status)
|
|
80
|
+
: markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, status));
|
|
81
|
+
}));
|
|
82
|
+
return concat(of(startAction), httpStream$);
|
|
83
|
+
}))));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { transformRecommendation, transformRecommendationWithCOT, } from '../../entity/transaction/payloadTypes/transactionPayload';
|
|
2
|
+
import { getActualTransactionID } from '../transactionDetail/transactionDetailState';
|
|
2
3
|
export const getRecommendationFromRecommendationPayload = (payload) => {
|
|
3
4
|
if (payload == null || payload.length === 0) {
|
|
4
5
|
return undefined;
|
|
@@ -37,6 +38,34 @@ export const getRecommendationWithCOTFromRecommendationPayloadWithCOT = (payload
|
|
|
37
38
|
});
|
|
38
39
|
return recommendations;
|
|
39
40
|
};
|
|
41
|
+
// Pluralized URL segment for entity types. Mirrors the legacy
|
|
42
|
+
// fetchEntityRecommendationsByTransactionIdEpic.toEntityTypeURL.
|
|
43
|
+
const toEntityTypeUrlSegment = (entityType) => `${entityType}s`;
|
|
44
|
+
// Build the recommendations URL for a single entity + transaction target.
|
|
45
|
+
// Centralizes the URL shape so the legacy
|
|
46
|
+
// fetchEntityRecommendationsByTransactionIdEpic and the new
|
|
47
|
+
// fetchEntityRecommendationsForLineUpdateEpic stay in lockstep.
|
|
48
|
+
export const buildRecommendationUrl = (accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT) => {
|
|
49
|
+
const entityQuery = {
|
|
50
|
+
entity_name: entity.name,
|
|
51
|
+
entity_type: entity.type,
|
|
52
|
+
};
|
|
53
|
+
// Entity-id-null case: server expects entity_name / entity_type query
|
|
54
|
+
// instead of the {entityType}/{qboId}/recommendations path.
|
|
55
|
+
if (entity.qboId === entity.name) {
|
|
56
|
+
return `${accountMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(entityQuery))}`;
|
|
57
|
+
}
|
|
58
|
+
const query = {
|
|
59
|
+
amount,
|
|
60
|
+
transaction_id: getActualTransactionID(transactionDetails.transactionId.id),
|
|
61
|
+
transaction_type: transactionDetails.transaction.type,
|
|
62
|
+
line_ids: transactionDetails.lineIds,
|
|
63
|
+
};
|
|
64
|
+
if (isFetchCOT === true) {
|
|
65
|
+
query.include_cot = true;
|
|
66
|
+
}
|
|
67
|
+
return `${accountMicroServiceBaseUrl}/1.0/${toEntityTypeUrlSegment(entity.type)}/${entity.qboId}/recommendations?query=${encodeURIComponent(JSON.stringify(query))}`;
|
|
68
|
+
};
|
|
40
69
|
export const getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT = (recommendationPayload, lineIds) => {
|
|
41
70
|
if (recommendationPayload.length === 0) {
|
|
42
71
|
return undefined;
|
|
@@ -33,6 +33,41 @@ const recommendation = createSlice({
|
|
|
33
33
|
};
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
|
+
// Targeted recommendations fetch fired when the user changes the
|
|
37
|
+
// payee/customer on a single transaction line (or the JE sibling set
|
|
38
|
+
// for that change). Routed by `fetchEntityRecommendationsForLineUpdateEpic`
|
|
39
|
+
// which uses groupBy + switchMap to keep fetches for distinct targets
|
|
40
|
+
// running in parallel while same-target re-fetches still cancel each
|
|
41
|
+
// other. The flowType discriminator selects the categorization vs
|
|
42
|
+
// detail slice for the per-line In-Progress / Completed / Error state.
|
|
43
|
+
fetchEntityRecommendationsForLineUpdate: {
|
|
44
|
+
reducer(draft, action) {
|
|
45
|
+
const { entity } = action.payload;
|
|
46
|
+
const key = getEntityRecommendationKey(entity.type, entity.id);
|
|
47
|
+
// Unconditional flip to In-Progress; the previous variant only
|
|
48
|
+
// seeded when missing, which left stale fetchStates when a prior
|
|
49
|
+
// fetch had already populated the entity entry.
|
|
50
|
+
draft.recommendationByEntity[key] = {
|
|
51
|
+
...(draft.recommendationByEntity[key] ??
|
|
52
|
+
initialEntityRecommendationState),
|
|
53
|
+
fetchState: 'In-Progress',
|
|
54
|
+
error: undefined,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
prepare(entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT = false, isUncategorizedExpenseCategoryEnabled) {
|
|
58
|
+
return {
|
|
59
|
+
payload: {
|
|
60
|
+
entity,
|
|
61
|
+
amount,
|
|
62
|
+
transactionDetails,
|
|
63
|
+
flowType,
|
|
64
|
+
selectedTab,
|
|
65
|
+
isFetchCOT,
|
|
66
|
+
isUncategorizedExpenseCategoryEnabled,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
},
|
|
36
71
|
fetchRecommendationByEntityName: {
|
|
37
72
|
reducer(draft, action) {
|
|
38
73
|
const { entityName, entityType } = action.payload;
|
|
@@ -111,7 +146,7 @@ const recommendation = createSlice({
|
|
|
111
146
|
},
|
|
112
147
|
},
|
|
113
148
|
});
|
|
114
|
-
export const { fetchEntityRecommendationsByTransactionId, fetchRecommendationByEntityName, fetchRecommendationByEntityId, updateRecommendationForEntity, updateRecommendationForEntityFailure, indicateReadyToInitializeRecommendation, clearRecommendation, } = recommendation.actions;
|
|
149
|
+
export const { fetchEntityRecommendationsByTransactionId, fetchEntityRecommendationsForLineUpdate, fetchRecommendationByEntityName, fetchRecommendationByEntityId, updateRecommendationForEntity, updateRecommendationForEntityFailure, indicateReadyToInitializeRecommendation, clearRecommendation, } = recommendation.actions;
|
|
115
150
|
export default recommendation.reducer;
|
|
116
151
|
const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
|
|
117
152
|
const key = getEntityRecommendationKey(entityType, entityId);
|
|
@@ -13,13 +13,12 @@ import { fetchAccountList } from '../../accountList/accountListReducer';
|
|
|
13
13
|
import { fetchClassList } from '../../classList/classListReducer';
|
|
14
14
|
import { getInitializedTransactionVendorLocalData } from '../../commonVendorView/transactionVendorView/transactionVendorLocalDataHelper';
|
|
15
15
|
import { updateTransactionVendorLocalData } from '../../commonVendorView/transactionVendorView/transactionVendorViewReducer';
|
|
16
|
-
import { fetchAccountsForTransferFlow } from '../../createTransferEntry/createTransferEntryReducer';
|
|
17
16
|
import { fetchOwnerList } from '../../ownerList/ownerListReducer';
|
|
18
17
|
import { fetchProjectList } from '../../projectList/projectListReducer';
|
|
19
18
|
import { fetchTransactionDetail, initializeTransactionDetailLocalData, removeTransactionDetail, updateTransactionDetailFetchState, } from '../transactionDetailReducer';
|
|
20
19
|
import { getAllLinkedTransactions, getTransactionDetailKey, } from '../transactionDetailState';
|
|
21
20
|
export const fetchTransactionDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchTransactionDetail.match), mergeMap((action) => {
|
|
22
|
-
const { transactionId, cacheOverride
|
|
21
|
+
const { transactionId, cacheOverride } = action.payload;
|
|
23
22
|
const detailKey = getTransactionDetailKey(transactionId);
|
|
24
23
|
const transactionActions = [];
|
|
25
24
|
if (cacheOverride === true) {
|
|
@@ -36,17 +35,6 @@ export const fetchTransactionDetailEpic = (actions$, state$, zeniAPI) => actions
|
|
|
36
35
|
accountList.fetchState !== 'In-Progress') {
|
|
37
36
|
transactionActions.push(fetchAccountList('accountList'));
|
|
38
37
|
}
|
|
39
|
-
if (isCreateTransferEntryFromExpenseEnabled === true) {
|
|
40
|
-
const { transferEntryEligible, creditCardOnlyEligible } = state$.value.createTransferEntryState.transferAccountsByType;
|
|
41
|
-
if (transferEntryEligible.fetchState !== 'In-Progress' &&
|
|
42
|
-
transferEntryEligible.fetchState !== 'Completed') {
|
|
43
|
-
transactionActions.push(fetchAccountsForTransferFlow({ kind: 'transferEntryEligible' }));
|
|
44
|
-
}
|
|
45
|
-
if (creditCardOnlyEligible.fetchState !== 'In-Progress' &&
|
|
46
|
-
creditCardOnlyEligible.fetchState !== 'Completed') {
|
|
47
|
-
transactionActions.push(fetchAccountsForTransferFlow({ kind: 'creditCardOnlyEligible' }));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
38
|
const classList = state$.value.classListState;
|
|
51
39
|
if (classList.hasValidState() === false &&
|
|
52
40
|
classList.fetchState !== 'In-Progress') {
|
|
@@ -60,7 +48,7 @@ export const fetchTransactionDetailEpic = (actions$, state$, zeniAPI) => actions
|
|
|
60
48
|
transactionActions.push(updateTransactionDetailFetchState(transactionId, 'In-Progress'));
|
|
61
49
|
const query = { transaction_type: transactionId.type };
|
|
62
50
|
const getTransactionDetail$ = zeniAPI
|
|
63
|
-
.getJSON(
|
|
51
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${transactionId.id}?query=${encodeURIComponent(JSON.stringify(query))}`)
|
|
64
52
|
.pipe(mergeMap((response) => {
|
|
65
53
|
if (isSuccessResponse(response) &&
|
|
66
54
|
response.data?.transaction?.transaction_id != null) {
|