@zeniai/client-epic-state 5.0.61-betaJK1 → 5.0.61-betaML1
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 +2 -0
- package/lib/entity/account/accountSelector.d.ts +9 -0
- package/lib/entity/account/accountSelector.js +14 -1
- 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/project/projectPayload.d.ts +1 -1
- package/lib/entity/project/projectPayload.js +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 +2 -1
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +4 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +10 -0
- package/lib/entity/transaction/stateTypes/transaction.d.ts +3 -0
- package/lib/epic.d.ts +3 -2
- package/lib/epic.js +3 -2
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +2 -0
- package/lib/esm/entity/account/accountSelector.js +11 -0
- package/lib/esm/entity/project/projectPayload.js +1 -1
- package/lib/esm/entity/snackbar/snackbarTypes.js +2 -1
- package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +10 -0
- package/lib/esm/epic.js +3 -2
- package/lib/esm/index.js +14 -14
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/createTransferEntryEpic.js +81 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +8 -1
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransferAccountsEpic.js +30 -0
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +79 -1
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +30 -0
- package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +5 -0
- package/lib/esm/view/taskManager/taskDetailView/taskDetailReducer.js +1 -23
- package/lib/esm/view/transactionDetail/epics/transactionDetailEpic.js +10 -0
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +24 -2
- package/lib/index.d.ts +16 -16
- package/lib/index.js +64 -56
- 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/createTransferEntryEpic.d.ts +9 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/createTransferEntryEpic.js +85 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +7 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransferAccountsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransferAccountsEpic.js +34 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +21 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +80 -2
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +4 -1
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +2 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +31 -0
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +18 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +6 -1
- package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
- package/lib/view/taskManager/taskDetailView/taskDetail.d.ts +0 -12
- package/lib/view/taskManager/taskDetailView/taskDetailReducer.d.ts +2 -6
- package/lib/view/taskManager/taskDetailView/taskDetailReducer.js +2 -24
- 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 +2 -1
- package/lib/view/transactionDetail/epics/transactionDetailEpic.js +10 -0
- package/lib/view/transactionDetail/transactionDetailPayload.d.ts +1 -1
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +6 -1
- package/lib/view/transactionDetail/transactionDetailSelector.js +23 -1
- package/package.json +1 -1
- package/lib/esm/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +0 -62
- package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.d.ts +0 -29
- package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +0 -66
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { concat, from, timer } from 'rxjs';
|
|
2
|
+
import { catchError, filter, map, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { toTransactionID } from '../../../../entity/transaction/payloadTypes/transactionIDPayload';
|
|
5
|
+
import { toTransactionType } from '../../../../entity/transaction/stateTypes/transactionType';
|
|
6
|
+
import { removeTransaction, updateTransaction, } from '../../../../entity/transaction/transactionReducer';
|
|
7
|
+
import { isSuccessResponse } from '../../../../responsePayload';
|
|
8
|
+
import { initializeTransactionDetailLocalData, removeTransactionDetail, } from '../../../transactionDetail/transactionDetailReducer';
|
|
9
|
+
import { getTransactionDetailKey } from '../../../transactionDetail/transactionDetailState';
|
|
10
|
+
import { acknowledgeTransferEntryRouteReplacement, createTransferEntry, createTransferEntryFailure, createTransferEntryReplacedTransaction, createTransferEntrySuccess, removeTransactionFromAllTabs, resetCreateTransferEntryStatus, } from '../../reducers/transactionsViewReducer';
|
|
11
|
+
function transactionIdsAreEqual(a, b) {
|
|
12
|
+
return a.id === b.id && a.type === b.type;
|
|
13
|
+
}
|
|
14
|
+
export const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(createTransferEntry.match), mergeMap((action) => {
|
|
15
|
+
const { transactionId, creditAccountIntegrationId, debitAccountIntegrationId, memo, transactionType, sourceTransactionType, } = action.payload;
|
|
16
|
+
const url = `https://dev.api.zeni.ai/version/accounting/komal/1.0/transactions/transaction-type-update`;
|
|
17
|
+
return zeniAPI
|
|
18
|
+
.postAndGetJSON(url, {
|
|
19
|
+
transaction_type: transactionType,
|
|
20
|
+
transaction_id: transactionId,
|
|
21
|
+
to_account_integration_id: creditAccountIntegrationId,
|
|
22
|
+
from_account_integration_id: debitAccountIntegrationId,
|
|
23
|
+
memo,
|
|
24
|
+
})
|
|
25
|
+
.pipe(mergeMap((response) => {
|
|
26
|
+
if (isSuccessResponse(response)) {
|
|
27
|
+
const immediate = [];
|
|
28
|
+
const previousTransactionId = {
|
|
29
|
+
id: transactionId,
|
|
30
|
+
type: toTransactionType(sourceTransactionType),
|
|
31
|
+
};
|
|
32
|
+
if (response.data?.transaction != null) {
|
|
33
|
+
const newTransactionId = toTransactionID(response.data.transaction);
|
|
34
|
+
const replaced = !transactionIdsAreEqual(previousTransactionId, newTransactionId);
|
|
35
|
+
const newDetailKey = getTransactionDetailKey(newTransactionId);
|
|
36
|
+
immediate.push(updateTransaction(newDetailKey, response.data.transaction));
|
|
37
|
+
immediate.push(initializeTransactionDetailLocalData({
|
|
38
|
+
transactionId: newTransactionId,
|
|
39
|
+
vendorId: response.data.vendors?.[0]?.vendor_id,
|
|
40
|
+
}));
|
|
41
|
+
immediate.push(createTransferEntrySuccess(), removeTransactionFromAllTabs(transactionId), openSnackbar({
|
|
42
|
+
messageSection: 'create_transfer_entry',
|
|
43
|
+
messageText: 'success',
|
|
44
|
+
type: 'success',
|
|
45
|
+
}));
|
|
46
|
+
if (replaced) {
|
|
47
|
+
immediate.push(createTransferEntryReplacedTransaction(previousTransactionId, newTransactionId));
|
|
48
|
+
}
|
|
49
|
+
return concat(from(immediate), timer(0).pipe(map(() => resetCreateTransferEntryStatus()), mergeMap((resetAction) => replaced
|
|
50
|
+
? from([
|
|
51
|
+
resetAction,
|
|
52
|
+
removeTransaction(getTransactionDetailKey(previousTransactionId)),
|
|
53
|
+
removeTransactionDetail(previousTransactionId),
|
|
54
|
+
acknowledgeTransferEntryRouteReplacement(),
|
|
55
|
+
])
|
|
56
|
+
: from([resetAction]))));
|
|
57
|
+
}
|
|
58
|
+
immediate.push(createTransferEntrySuccess(), removeTransactionFromAllTabs(transactionId), openSnackbar({
|
|
59
|
+
messageSection: 'create_transfer_entry',
|
|
60
|
+
messageText: 'success',
|
|
61
|
+
type: 'success',
|
|
62
|
+
}));
|
|
63
|
+
return concat(from(immediate), timer(0).pipe(map(() => resetCreateTransferEntryStatus())));
|
|
64
|
+
}
|
|
65
|
+
return from([
|
|
66
|
+
createTransferEntryFailure(),
|
|
67
|
+
openSnackbar({
|
|
68
|
+
messageSection: 'create_transfer_entry',
|
|
69
|
+
messageText: 'failed',
|
|
70
|
+
type: 'error',
|
|
71
|
+
}),
|
|
72
|
+
]);
|
|
73
|
+
}), catchError(() => from([
|
|
74
|
+
createTransferEntryFailure(),
|
|
75
|
+
openSnackbar({
|
|
76
|
+
messageSection: 'create_transfer_entry',
|
|
77
|
+
messageText: 'failed',
|
|
78
|
+
type: 'error',
|
|
79
|
+
}),
|
|
80
|
+
])));
|
|
81
|
+
}));
|
|
@@ -6,7 +6,7 @@ import { fetchAccountList } from '../../../accountList/accountListReducer';
|
|
|
6
6
|
import { fetchClassList } from '../../../classList/classListReducer';
|
|
7
7
|
import { fetchOwnerList } from '../../../ownerList/ownerListReducer';
|
|
8
8
|
import { fetchProjectList } from '../../../projectList/projectListReducer';
|
|
9
|
-
import { fetchTransactionCategorization, fetchTransactionCategorizationView, } from '../../reducers/transactionsViewReducer';
|
|
9
|
+
import { fetchTransactionCategorization, fetchTransactionCategorizationView, fetchAccountsForTransferFlow, } from '../../reducers/transactionsViewReducer';
|
|
10
10
|
export const fetchTransactionCategorizationViewEpic = (actions$, state$) => actions$.pipe(filter(fetchTransactionCategorizationView.match), mergeMap((action) => {
|
|
11
11
|
const { selectedTab, cacheOverride, keepExistingListItems, pageToken, period, refreshViewInBackground, searchString, resetListItems, isUncategorizedExpenseCategoryEnabled, } = action.payload;
|
|
12
12
|
const updateActions = [];
|
|
@@ -23,6 +23,13 @@ export const fetchTransactionCategorizationViewEpic = (actions$, state$) => acti
|
|
|
23
23
|
accountList.fetchState === 'Not-Started') {
|
|
24
24
|
updateActions.push(fetchAccountList('accountList', true));
|
|
25
25
|
}
|
|
26
|
+
const { transferAccounts, creditCardAccountsForTransfer, } = state$.value.expenseAutomationTransactionsViewState;
|
|
27
|
+
if (transferAccounts.fetchState === 'Not-Started') {
|
|
28
|
+
updateActions.push(fetchAccountsForTransferFlow({ kind: 'transfer_eligible' }));
|
|
29
|
+
}
|
|
30
|
+
if (creditCardAccountsForTransfer.fetchState === 'Not-Started') {
|
|
31
|
+
updateActions.push(fetchAccountsForTransferFlow({ kind: 'credit_card_only' }));
|
|
32
|
+
}
|
|
26
33
|
const classList = state$.value.classListState;
|
|
27
34
|
if (classList.hasValidState() === false &&
|
|
28
35
|
classList.fetchState === 'Not-Started') {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { updateAccounts } from '../../../../entity/account/accountReducer';
|
|
4
|
+
import { isSuccessResponse } from '../../../../responsePayload';
|
|
5
|
+
import { fetchAccountsForTransferFlow, updateAccountsForTransferFlow, updateAccountsForTransferFlowFailure, } from '../../reducers/transactionsViewReducer';
|
|
6
|
+
const REPORT_ID_BY_KIND = {
|
|
7
|
+
transfer_eligible: 'transfer_accounts',
|
|
8
|
+
credit_card_only: 'credit_card_transfer_accounts',
|
|
9
|
+
};
|
|
10
|
+
const QUERY_BY_KIND = {
|
|
11
|
+
transfer_eligible: { is_only_include_transfer_accounts: true },
|
|
12
|
+
credit_card_only: { is_include_only_credit_card_accounts: true },
|
|
13
|
+
};
|
|
14
|
+
export const fetchTransferAccountsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchAccountsForTransferFlow.match), switchMap((action) => {
|
|
15
|
+
const { kind } = action.payload;
|
|
16
|
+
const queryValue = QUERY_BY_KIND[kind];
|
|
17
|
+
const reportId = REPORT_ID_BY_KIND[kind];
|
|
18
|
+
const url = `https://dev.api.zeni.ai/version/accounting/komal/1.0/accounts?query=${encodeURIComponent(JSON.stringify(queryValue))}`;
|
|
19
|
+
return zeniAPI.getJSON(url).pipe(mergeMap((response) => {
|
|
20
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
21
|
+
const accountIds = response.data.accounts.map((account) => account.account_id);
|
|
22
|
+
const actions = [
|
|
23
|
+
updateAccounts(response.data.accounts, reportId),
|
|
24
|
+
updateAccountsForTransferFlow({ accountIds, kind }),
|
|
25
|
+
];
|
|
26
|
+
return of(...actions);
|
|
27
|
+
}
|
|
28
|
+
return of(updateAccountsForTransferFlowFailure({ kind }));
|
|
29
|
+
}), catchError(() => of(updateAccountsForTransferFlowFailure({ kind }))));
|
|
30
|
+
}));
|
|
@@ -4,6 +4,7 @@ import uniq from 'lodash/uniq';
|
|
|
4
4
|
import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
5
5
|
import { isVendorTransaction } from '../../../entity/transaction/stateTypes/vendorTransaction';
|
|
6
6
|
import { MAX_SELECTION_LIMIT, checkIfAllLineItemsAreCategoryClassFilled, filterAutoTabLineItems, mergeTabSpecificLineItems, removeTransactionFromTabView, setEntityRecommendationForLineIdInLocalData, toSetAllLineItemsToCategoryClass, toTransactionDetailLocalData, } from '../helpers/transactionCategorizationLocalDataHelper';
|
|
7
|
+
import { TRANSACTIONS_TABS, } from '../types/transactionsViewState';
|
|
7
8
|
export const initialTransactionTabViewState = {
|
|
8
9
|
saveStatus: {
|
|
9
10
|
fetchState: 'Not-Started',
|
|
@@ -41,11 +42,21 @@ export const initialTransactionTabViewState = {
|
|
|
41
42
|
selectedTransactionLineId: undefined,
|
|
42
43
|
};
|
|
43
44
|
export const initialState = {
|
|
45
|
+
createTransferEntryStatus: 'Not-Started',
|
|
46
|
+
creditCardAccountsForTransfer: {
|
|
47
|
+
accountIds: [],
|
|
48
|
+
fetchState: 'Not-Started',
|
|
49
|
+
},
|
|
50
|
+
lastTransferEntryReplacement: undefined,
|
|
44
51
|
selectedTransactionCategorizationTab: 'review',
|
|
45
52
|
transactionCategorizationView: {
|
|
46
53
|
review: { ...initialTransactionTabViewState },
|
|
47
54
|
autoCategorized: { ...initialTransactionTabViewState },
|
|
48
55
|
},
|
|
56
|
+
transferAccounts: {
|
|
57
|
+
accountIds: [],
|
|
58
|
+
fetchState: 'Not-Started',
|
|
59
|
+
},
|
|
49
60
|
};
|
|
50
61
|
const expenseAutomationTransactionsView = createSlice({
|
|
51
62
|
name: 'expenseAutomationTransactionsView',
|
|
@@ -801,7 +812,74 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
801
812
|
};
|
|
802
813
|
},
|
|
803
814
|
},
|
|
815
|
+
fetchAccountsForTransferFlow(draft, action) {
|
|
816
|
+
const slice = action.payload.kind === 'credit_card_only'
|
|
817
|
+
? draft.creditCardAccountsForTransfer
|
|
818
|
+
: draft.transferAccounts;
|
|
819
|
+
slice.fetchState = 'In-Progress';
|
|
820
|
+
},
|
|
821
|
+
updateAccountsForTransferFlow(draft, action) {
|
|
822
|
+
const slice = action.payload.kind === 'credit_card_only'
|
|
823
|
+
? draft.creditCardAccountsForTransfer
|
|
824
|
+
: draft.transferAccounts;
|
|
825
|
+
slice.fetchState = 'Completed';
|
|
826
|
+
slice.accountIds = action.payload.accountIds;
|
|
827
|
+
},
|
|
828
|
+
updateAccountsForTransferFlowFailure(draft, action) {
|
|
829
|
+
const slice = action.payload.kind === 'credit_card_only'
|
|
830
|
+
? draft.creditCardAccountsForTransfer
|
|
831
|
+
: draft.transferAccounts;
|
|
832
|
+
slice.fetchState = 'Error';
|
|
833
|
+
},
|
|
834
|
+
createTransferEntry: {
|
|
835
|
+
prepare(transactionId, creditAccountIntegrationId, debitAccountIntegrationId, memo, transactionType, sourceTransactionType) {
|
|
836
|
+
return {
|
|
837
|
+
payload: {
|
|
838
|
+
transactionId,
|
|
839
|
+
creditAccountIntegrationId,
|
|
840
|
+
debitAccountIntegrationId,
|
|
841
|
+
memo,
|
|
842
|
+
transactionType,
|
|
843
|
+
sourceTransactionType,
|
|
844
|
+
},
|
|
845
|
+
};
|
|
846
|
+
},
|
|
847
|
+
reducer(draft) {
|
|
848
|
+
draft.createTransferEntryStatus = 'In-Progress';
|
|
849
|
+
},
|
|
850
|
+
},
|
|
851
|
+
createTransferEntrySuccess(draft) {
|
|
852
|
+
draft.createTransferEntryStatus = 'Completed';
|
|
853
|
+
},
|
|
854
|
+
createTransferEntryFailure(draft) {
|
|
855
|
+
draft.createTransferEntryStatus = 'Error';
|
|
856
|
+
},
|
|
857
|
+
resetCreateTransferEntryStatus(draft) {
|
|
858
|
+
draft.createTransferEntryStatus = 'Not-Started';
|
|
859
|
+
},
|
|
860
|
+
createTransferEntryReplacedTransaction: {
|
|
861
|
+
prepare(previousTransactionId, newTransactionId) {
|
|
862
|
+
return { payload: { newTransactionId, previousTransactionId } };
|
|
863
|
+
},
|
|
864
|
+
reducer(draft, action) {
|
|
865
|
+
draft.lastTransferEntryReplacement = action.payload;
|
|
866
|
+
},
|
|
867
|
+
},
|
|
868
|
+
acknowledgeTransferEntryRouteReplacement(draft) {
|
|
869
|
+
draft.lastTransferEntryReplacement = undefined;
|
|
870
|
+
},
|
|
871
|
+
removeTransactionFromAllTabs: {
|
|
872
|
+
prepare(transactionId) {
|
|
873
|
+
return { payload: { transactionId } };
|
|
874
|
+
},
|
|
875
|
+
reducer(draft, action) {
|
|
876
|
+
const { transactionId } = action.payload;
|
|
877
|
+
for (const tab of TRANSACTIONS_TABS) {
|
|
878
|
+
removeTransactionFromTabView(draft.transactionCategorizationView[tab], transactionId);
|
|
879
|
+
}
|
|
880
|
+
},
|
|
881
|
+
},
|
|
804
882
|
},
|
|
805
883
|
});
|
|
806
|
-
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
|
|
884
|
+
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, fetchAccountsForTransferFlow, updateAccountsForTransferFlow, updateAccountsForTransferFlowFailure, createTransferEntry, createTransferEntrySuccess, createTransferEntryFailure, resetCreateTransferEntryStatus, createTransferEntryReplacedTransaction, acknowledgeTransferEntryRouteReplacement, removeTransactionFromAllTabs, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
|
|
807
885
|
export default expenseAutomationTransactionsView.reducer;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import omit from 'lodash/omit';
|
|
2
2
|
import { reduceAllFetchState, reduceAnyFetchState, } from '../../../commonStateTypes/reduceFetchState';
|
|
3
3
|
import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { getAccountBase, getAccountBaseForCreditCardTransferAccounts, getAccountBaseForTransferAccounts, } from '../../../entity/account/accountSelector';
|
|
4
5
|
import { getCurrentTenant, getIsAccountingClassesEnabled, getIsAccountingProjectsEnabled, } from '../../../entity/tenant/tenantSelector';
|
|
5
6
|
import { getTransactionWithCOT } from '../../../entity/transaction/transactionHelper';
|
|
6
7
|
import { getSupportedTransactionsByIds } from '../../../entity/transaction/transactionSelector';
|
|
@@ -8,6 +9,9 @@ import { getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts
|
|
|
8
9
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
9
10
|
import { getProjectList } from '../../projectList/projectListSelector';
|
|
10
11
|
import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
|
|
12
|
+
export function getLastTransferEntryReplacement(state) {
|
|
13
|
+
return state.expenseAutomationTransactionsViewState.lastTransferEntryReplacement;
|
|
14
|
+
}
|
|
11
15
|
export function getExpenseAutomationTransactionView(state) {
|
|
12
16
|
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
13
17
|
const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
|
|
@@ -86,6 +90,29 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
86
90
|
: [];
|
|
87
91
|
const transactionCompletionStatus = allSteps.find((step) => step.step === 'transaction_categorization')?.completionStatus;
|
|
88
92
|
const completionStatus = transactionCompletionStatus ?? 'incomplete';
|
|
93
|
+
const transferAccountsFromApi = expenseAutomationTransactionsViewState.transferAccounts.accountIds
|
|
94
|
+
.map((id) => getAccountBaseForTransferAccounts(accountState, id))
|
|
95
|
+
.filter((account) => account != null);
|
|
96
|
+
/**
|
|
97
|
+
* Credit transfer picker uses transfer-account ids from a dedicated fetch. If that list
|
|
98
|
+
* resolves to nothing while the COA list is loaded, fall back to the full COA list so the
|
|
99
|
+
* credit dropdown is not empty.
|
|
100
|
+
*/
|
|
101
|
+
const transferAccountsList = transferAccountsFromApi.length > 0
|
|
102
|
+
? transferAccountsFromApi
|
|
103
|
+
: accountList.accounts
|
|
104
|
+
.map((a) => getAccountBase(accountState, a.accountId, 'account_list'))
|
|
105
|
+
.filter((account) => account != null);
|
|
106
|
+
const creditCardAccountsFromApi = expenseAutomationTransactionsViewState.creditCardAccountsForTransfer.accountIds
|
|
107
|
+
.map((id) => getAccountBaseForCreditCardTransferAccounts(accountState, id))
|
|
108
|
+
.filter((account) => account != null);
|
|
109
|
+
const coaCreditCardsFallback = accountList.accounts
|
|
110
|
+
.map((a) => getAccountBase(accountState, a.accountId, 'account_list'))
|
|
111
|
+
.filter((account) => account != null)
|
|
112
|
+
.filter((a) => a.accountType === 'credit_card');
|
|
113
|
+
const creditCardAccountsForTransferList = creditCardAccountsFromApi.length > 0
|
|
114
|
+
? creditCardAccountsFromApi
|
|
115
|
+
: coaCreditCardsFallback;
|
|
89
116
|
return {
|
|
90
117
|
version: 0,
|
|
91
118
|
fetchState: fetchStatus.fetchState,
|
|
@@ -106,11 +133,14 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
106
133
|
refreshStatus,
|
|
107
134
|
saveStatus,
|
|
108
135
|
markAsNotMiscategorizedStatus,
|
|
136
|
+
createTransferEntryStatus: expenseAutomationTransactionsViewState.createTransferEntryStatus,
|
|
109
137
|
completionStatus,
|
|
110
138
|
totalCountByTab,
|
|
111
139
|
fetchStateByTransactionTabs: fetchStateByTab,
|
|
112
140
|
uploadReceiptStatusById,
|
|
113
141
|
selectedTransactionId,
|
|
114
142
|
selectedTransactionLineId,
|
|
143
|
+
creditCardAccountsForTransferList,
|
|
144
|
+
transferAccounts: transferAccountsList,
|
|
115
145
|
};
|
|
116
146
|
}
|
|
@@ -25,3 +25,8 @@ export const initialSupportedTransactionCategorization = {
|
|
|
25
25
|
tabSpecificLineItems: {},
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
|
+
/** Which pool `fetchAccountsForTransferFlow` / transfer-flow epic should load. */
|
|
29
|
+
export const TRANSFER_ACCOUNTS_FETCH_KIND = [
|
|
30
|
+
'transfer_eligible',
|
|
31
|
+
'credit_card_only',
|
|
32
|
+
];
|
|
@@ -6,10 +6,6 @@ import { initialTaskDetail, } from './taskDetail';
|
|
|
6
6
|
export const initialState = {
|
|
7
7
|
newTaskState: initialTaskDetail,
|
|
8
8
|
editTaskStateById: {},
|
|
9
|
-
subTaskCreateStatus: {
|
|
10
|
-
fetchState: 'Not-Started',
|
|
11
|
-
error: undefined,
|
|
12
|
-
},
|
|
13
9
|
taskHistoryById: {},
|
|
14
10
|
};
|
|
15
11
|
const taskDetailView = createSlice({
|
|
@@ -322,28 +318,10 @@ const taskDetailView = createSlice({
|
|
|
322
318
|
error,
|
|
323
319
|
};
|
|
324
320
|
},
|
|
325
|
-
createSubTask: {
|
|
326
|
-
reducer(draft) {
|
|
327
|
-
draft.subTaskCreateStatus = {
|
|
328
|
-
fetchState: 'In-Progress',
|
|
329
|
-
error: undefined,
|
|
330
|
-
};
|
|
331
|
-
},
|
|
332
|
-
prepare(payload) {
|
|
333
|
-
return { payload };
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
createSubTaskSuccessOrFailure(draft, action) {
|
|
337
|
-
const { fetchState, error } = action.payload;
|
|
338
|
-
draft.subTaskCreateStatus = {
|
|
339
|
-
fetchState,
|
|
340
|
-
error,
|
|
341
|
-
};
|
|
342
|
-
},
|
|
343
321
|
clearTaskDetail(draft) {
|
|
344
322
|
Object.assign(draft, initialState);
|
|
345
323
|
},
|
|
346
324
|
},
|
|
347
325
|
});
|
|
348
|
-
export const { fetchTaskDetailPage, fetchTaskDetail, initializeTaskToLocalStore, updateEditTaskFetchStatus, saveTaskUpdatesToLocalStore, discardTaskUpdatesInLocalStore, saveTaskDetail, archiveTask, archiveTaskSuccessOrFailure, saveTaskSuccessOrFailure,
|
|
326
|
+
export const { fetchTaskDetailPage, fetchTaskDetail, initializeTaskToLocalStore, updateEditTaskFetchStatus, saveTaskUpdatesToLocalStore, discardTaskUpdatesInLocalStore, saveTaskDetail, archiveTask, archiveTaskSuccessOrFailure, saveTaskSuccessOrFailure, deleteTask, removeTaskDetail, deleteTaskSuccessOrFailure, snoozeTask, snoozeTaskSuccessOrFailure, unsnoozeTask, fetchTaskHistory, updateTaskHistory, updateTaskHistoryFetchStatus, clearTaskDetail, updateCreatedTagToLocalStore, updateDeletedTagToLocalStore, } = taskDetailView.actions;
|
|
349
327
|
export default taskDetailView.reducer;
|
|
@@ -13,6 +13,7 @@ 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 '../../expenseAutomationView/reducers/transactionsViewReducer';
|
|
16
17
|
import { fetchOwnerList } from '../../ownerList/ownerListReducer';
|
|
17
18
|
import { fetchProjectList } from '../../projectList/projectListReducer';
|
|
18
19
|
import { fetchTransactionDetail, initializeTransactionDetailLocalData, removeTransactionDetail, updateTransactionDetailFetchState, } from '../transactionDetailReducer';
|
|
@@ -35,6 +36,15 @@ export const fetchTransactionDetailEpic = (actions$, state$, zeniAPI) => actions
|
|
|
35
36
|
accountList.fetchState !== 'In-Progress') {
|
|
36
37
|
transactionActions.push(fetchAccountList('accountList'));
|
|
37
38
|
}
|
|
39
|
+
const { transferAccounts, creditCardAccountsForTransfer, } = state$.value.expenseAutomationTransactionsViewState;
|
|
40
|
+
if (transferAccounts.fetchState !== 'In-Progress' &&
|
|
41
|
+
transferAccounts.fetchState !== 'Completed') {
|
|
42
|
+
transactionActions.push(fetchAccountsForTransferFlow({ kind: 'transfer_eligible' }));
|
|
43
|
+
}
|
|
44
|
+
if (creditCardAccountsForTransfer.fetchState !== 'In-Progress' &&
|
|
45
|
+
creditCardAccountsForTransfer.fetchState !== 'Completed') {
|
|
46
|
+
transactionActions.push(fetchAccountsForTransferFlow({ kind: 'credit_card_only' }));
|
|
47
|
+
}
|
|
38
48
|
const classList = state$.value.classListState;
|
|
39
49
|
if (classList.hasValidState() === false &&
|
|
40
50
|
classList.fetchState !== 'In-Progress') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import recordGet from 'lodash/get';
|
|
2
2
|
import { reduceFetchState } from '../../commonStateTypes/reduceFetchState';
|
|
3
|
-
import {
|
|
3
|
+
import { getAccountBase, getAccountBaseForCreditCardTransferAccounts, getAccountBaseForTransferAccounts, } from '../../entity/account/accountSelector';
|
|
4
|
+
import { getIsAccountingClassesEnabled, getIsAccountingProjectsEnabled } from '../../entity/tenant/tenantSelector';
|
|
4
5
|
import { toTransactionTypeStrict } from '../../entity/transaction/stateTypes/transactionType';
|
|
5
6
|
import { getTransactionWithCOT } from '../../entity/transaction/transactionHelper';
|
|
6
7
|
import { getSupportedTransactionById } from '../../entity/transaction/transactionSelector';
|
|
@@ -11,7 +12,7 @@ import { getClassList, getNestedClassListHierarchy, } from '../classList/classLi
|
|
|
11
12
|
import { getProjectList, } from '../projectList/projectListSelector';
|
|
12
13
|
import { getAllLinkedTransactions, getTransactionDetailKey, initialSupportedTransactionDetail, } from './transactionDetailState';
|
|
13
14
|
export const getTransactionDetail = (state, transactionId, fetchLinkedTransactions = true) => {
|
|
14
|
-
const { transactionDetailState, transactionState, vendorState, vendorListState, accountState, classState, classListState, accountListState, projectState, projectListState, } = state;
|
|
15
|
+
const { transactionDetailState, transactionState, vendorState, vendorListState, accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, projectState, projectListState, } = state;
|
|
15
16
|
const detailKey = getTransactionDetailKey(transactionId);
|
|
16
17
|
const transactionDetail = recordGet(transactionDetailState.transactionDetailById, detailKey);
|
|
17
18
|
let fetchState = {
|
|
@@ -72,6 +73,24 @@ export const getTransactionDetail = (state, transactionId, fetchLinkedTransactio
|
|
|
72
73
|
: [];
|
|
73
74
|
const transactionDetailAnyUpdateStatus = reduceUpdateFetchStates(transactionDetail);
|
|
74
75
|
const vendors = getVendorsByVendorIds(vendorState, vendorListState.vendorIds);
|
|
76
|
+
const transferAccountsFromApi = expenseAutomationTransactionsViewState.transferAccounts.accountIds
|
|
77
|
+
.map((id) => getAccountBaseForTransferAccounts(accountState, id))
|
|
78
|
+
.filter((account) => account != null);
|
|
79
|
+
const transferAccountsList = transferAccountsFromApi.length > 0
|
|
80
|
+
? transferAccountsFromApi
|
|
81
|
+
: accountsList.accounts
|
|
82
|
+
.map((a) => getAccountBase(accountState, a.accountId, 'account_list'))
|
|
83
|
+
.filter((account) => account != null);
|
|
84
|
+
const creditCardAccountsFromApi = expenseAutomationTransactionsViewState.creditCardAccountsForTransfer.accountIds
|
|
85
|
+
.map((id) => getAccountBaseForCreditCardTransferAccounts(accountState, id))
|
|
86
|
+
.filter((account) => account != null);
|
|
87
|
+
const coaCreditCardsFallback = accountsList.accounts
|
|
88
|
+
.map((a) => getAccountBase(accountState, a.accountId, 'account_list'))
|
|
89
|
+
.filter((account) => account != null)
|
|
90
|
+
.filter((a) => a.accountType === 'credit_card');
|
|
91
|
+
const creditCardAccountsForTransferList = creditCardAccountsFromApi.length > 0
|
|
92
|
+
? creditCardAccountsFromApi
|
|
93
|
+
: coaCreditCardsFallback;
|
|
75
94
|
return {
|
|
76
95
|
reportId: 'transaction_detail',
|
|
77
96
|
reportTitle: 'Transaction Detail',
|
|
@@ -88,6 +107,9 @@ export const getTransactionDetail = (state, transactionId, fetchLinkedTransactio
|
|
|
88
107
|
accountsHierarchyList,
|
|
89
108
|
classList: classList,
|
|
90
109
|
isAccountingClassesEnabled,
|
|
110
|
+
createTransferEntryStatus: expenseAutomationTransactionsViewState.createTransferEntryStatus,
|
|
111
|
+
creditCardAccountsForTransferList,
|
|
112
|
+
transferAccounts: transferAccountsList,
|
|
91
113
|
isAccountingProjectsEnabled,
|
|
92
114
|
projectList,
|
|
93
115
|
isUpdateNotAllowed: transactionDetail?.isUpdateNotAllowed,
|