@zeniai/client-epic-state 5.0.55-betaSS2 → 5.0.55-betaVR1
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/esm/index.js +5 -4
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -4
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +1 -9
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -80
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -20
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +2 -0
- package/lib/esm/view/transactionDetail/journalEntryLinesViewModel.js +113 -0
- package/lib/esm/view/transactionDetail/journalEntryLinesViewModel.vitest.js +243 -0
- package/lib/index.d.ts +6 -4
- package/lib/index.js +43 -37
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -4
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +0 -8
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +0 -15
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -8
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -81
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -2
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -14
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -20
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +4 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -35
- package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +73 -0
- package/lib/view/transactionDetail/journalEntryLinesViewModel.js +124 -0
- package/lib/view/transactionDetail/journalEntryLinesViewModel.vitest.d.ts +1 -0
- package/lib/view/transactionDetail/journalEntryLinesViewModel.vitest.js +245 -0
- package/package.json +2 -2
- package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +0 -9
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +0 -2
- package/lib/view/expenseAutomationView/types/completedSubTab.js +0 -13
|
@@ -65,9 +65,7 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
65
65
|
isUncategorizedExpenseCategoryEnabled: boolean | undefined;
|
|
66
66
|
}, "expenseAutomationTransactionsView/updateTransactionCategorization", never, never>, updateCurrentSelectedTransactionCategorizationTab: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[newSelectedTab: "review" | "autoCategorized"], {
|
|
67
67
|
newSelectedTab: "review" | "autoCategorized";
|
|
68
|
-
}, "expenseAutomationTransactionsView/updateCurrentSelectedTransactionCategorizationTab", never, never>,
|
|
69
|
-
newSubTab: "all" | "manual" | "ai_accountant";
|
|
70
|
-
}, "expenseAutomationTransactionsView/updateTransactionCategorizationCompletedSubTab", never, never>, updateTransactionCategorizationSaveStatus: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", fetchState: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
|
|
68
|
+
}, "expenseAutomationTransactionsView/updateCurrentSelectedTransactionCategorizationTab", never, never>, updateTransactionCategorizationSaveStatus: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", fetchState: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
|
|
71
69
|
selectedTab: "review" | "autoCategorized";
|
|
72
70
|
fetchState: FetchState;
|
|
73
71
|
error: ZeniAPIStatus<Record<string, unknown>> | undefined;
|
|
@@ -122,11 +120,7 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
122
120
|
selectedPeriod: MonthYearPeriod;
|
|
123
121
|
selectedTab: TransactionsTab;
|
|
124
122
|
totalCount: number;
|
|
125
|
-
}, "expenseAutomationTransactionsView/updateTotalCountForTransactionCategorization">,
|
|
126
|
-
parentTotalCount: number;
|
|
127
|
-
selectedPeriod: MonthYearPeriod;
|
|
128
|
-
selectedTab: TransactionsTab;
|
|
129
|
-
}, "expenseAutomationTransactionsView/updateParentTotalCountForTab">, fetchTransactionCategorizationSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
123
|
+
}, "expenseAutomationTransactionsView/updateTotalCountForTransactionCategorization">, fetchTransactionCategorizationSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
130
124
|
selectedTab: TransactionsTab;
|
|
131
125
|
status: ZeniAPIStatus;
|
|
132
126
|
refreshViewInBackground?: boolean;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.uploadTransactionCategorizationReceiptSuccess = exports.updateTransactionCategorizationUploadReceiptState = exports.backgroundRefetchReviewTab = exports.syncTransactionCategorizationFromDetailSave = exports.updateSelectedTransactionId = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.resetOtherTabsFetchState = exports.fetchTransactionCategorizationSuccess = exports.
|
|
7
|
+
exports.uploadTransactionCategorizationReceiptSuccess = exports.updateTransactionCategorizationUploadReceiptState = exports.backgroundRefetchReviewTab = exports.syncTransactionCategorizationFromDetailSave = exports.updateSelectedTransactionId = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.resetOtherTabsFetchState = exports.fetchTransactionCategorizationSuccess = exports.updateTotalCountForTransactionCategorization = exports.setAllItemsToCategoryClassInLocalDataForCategorization = exports.updateSelectedCustomerForTransaction = exports.updateSelectedVendorForTransaction = exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = exports.markTransactionAsNotMiscategorized = exports.updateTransactionCategorizationSaveStatus = exports.updateCurrentSelectedTransactionCategorizationTab = exports.updateTransactionCategorization = exports.saveTransactionCategorization = exports.fetchTransactionCategorizationFailure = exports.saveTransactionCategorizationLocalData = exports.initializeTransactionCategorizationViewLocalData = exports.updateTransactionCategorizationUIState = exports.fetchTransactionCategorization = exports.initialState = exports.initialTransactionTabViewState = void 0;
|
|
8
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
10
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
@@ -48,44 +48,12 @@ exports.initialTransactionTabViewState = {
|
|
|
48
48
|
selectedTransactionLineId: undefined,
|
|
49
49
|
};
|
|
50
50
|
exports.initialState = {
|
|
51
|
-
autoCategorizedSubTabCache: {},
|
|
52
|
-
parentTotalCountByTab: {
|
|
53
|
-
review: {},
|
|
54
|
-
autoCategorized: {},
|
|
55
|
-
},
|
|
56
51
|
selectedTransactionCategorizationTab: 'review',
|
|
57
|
-
selectedTransactionCategorizationCompletedSubTab: 'all',
|
|
58
52
|
transactionCategorizationView: {
|
|
59
53
|
review: { ...exports.initialTransactionTabViewState },
|
|
60
54
|
autoCategorized: { ...exports.initialTransactionTabViewState },
|
|
61
55
|
},
|
|
62
56
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Capture the autoCategorized tab's current paginated dataset for a sub-tab.
|
|
65
|
-
* The mid-flight `'In-Progress'` state is normalised to `'Completed'` because
|
|
66
|
-
* the in-flight request is cancelled by `switchMap` in the fetch epic when the
|
|
67
|
-
* sub-tab changes — restoring `'In-Progress'` later would leave the UI stuck
|
|
68
|
-
* showing a phantom loading state with no fetch actually running. Length-zero
|
|
69
|
-
* datasets degrade to `'Not-Started'` so the next visit triggers a fresh
|
|
70
|
-
* fetch from page 1 instead of short-circuiting on stale empty caches.
|
|
71
|
-
*/
|
|
72
|
-
function snapshotAutoCategorizedTab(autoCat) {
|
|
73
|
-
const transactionIdsBySelectedPeriod = {
|
|
74
|
-
...autoCat.transactionIdsBySelectedPeriod,
|
|
75
|
-
};
|
|
76
|
-
const hasAnyLoadedRows = Object.values(transactionIdsBySelectedPeriod).some((ids) => ids.length > 0);
|
|
77
|
-
let normalisedFetchState = autoCat.fetchState;
|
|
78
|
-
if (normalisedFetchState === 'In-Progress') {
|
|
79
|
-
normalisedFetchState = hasAnyLoadedRows ? 'Completed' : 'Not-Started';
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
error: autoCat.error,
|
|
83
|
-
fetchState: normalisedFetchState,
|
|
84
|
-
pageToken: autoCat.uiState.pageToken,
|
|
85
|
-
totalCount: { ...autoCat.uiState.totalCount },
|
|
86
|
-
transactionIdsBySelectedPeriod,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
57
|
const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
90
58
|
name: 'expenseAutomationTransactionsView',
|
|
91
59
|
initialState: exports.initialState,
|
|
@@ -299,48 +267,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
299
267
|
return { payload: { newSelectedTab } };
|
|
300
268
|
},
|
|
301
269
|
},
|
|
302
|
-
updateTransactionCategorizationCompletedSubTab: {
|
|
303
|
-
reducer(draft, action) {
|
|
304
|
-
const { newSubTab } = action.payload;
|
|
305
|
-
const previousSubTab = draft.selectedTransactionCategorizationCompletedSubTab;
|
|
306
|
-
if (previousSubTab === newSubTab) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
const autoCat = draft.transactionCategorizationView.autoCategorized;
|
|
310
|
-
// Snapshot the outgoing sub-tab so a future revisit can short-circuit
|
|
311
|
-
// the fetch epic (mirrors the parent-tab "don't refetch what's
|
|
312
|
-
// already cached" behaviour). Period-scoped data is preserved as-is
|
|
313
|
-
// because the snapshot itself is keyed only by sub-tab; the active
|
|
314
|
-
// tab's per-period maps remain the source of truth while live.
|
|
315
|
-
draft.autoCategorizedSubTabCache[previousSubTab] =
|
|
316
|
-
snapshotAutoCategorizedTab(autoCat);
|
|
317
|
-
const cached = draft.autoCategorizedSubTabCache[newSubTab];
|
|
318
|
-
if (cached != null) {
|
|
319
|
-
autoCat.uiState.pageToken = cached.pageToken;
|
|
320
|
-
autoCat.uiState.totalCount = { ...cached.totalCount };
|
|
321
|
-
autoCat.transactionIdsBySelectedPeriod = {
|
|
322
|
-
...cached.transactionIdsBySelectedPeriod,
|
|
323
|
-
};
|
|
324
|
-
autoCat.fetchState = cached.fetchState;
|
|
325
|
-
autoCat.error = cached.error;
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
// Sub-tab has never been visited — clear the active slot so the
|
|
329
|
-
// view-epic's `fetchState === 'Not-Started' || transactionIds.length
|
|
330
|
-
// === 0` cache check falls through and triggers a fresh page-1
|
|
331
|
-
// fetch for the new dataset.
|
|
332
|
-
autoCat.uiState.pageToken = null;
|
|
333
|
-
autoCat.uiState.totalCount = {};
|
|
334
|
-
autoCat.transactionIdsBySelectedPeriod = {};
|
|
335
|
-
autoCat.fetchState = 'Not-Started';
|
|
336
|
-
autoCat.error = undefined;
|
|
337
|
-
}
|
|
338
|
-
draft.selectedTransactionCategorizationCompletedSubTab = newSubTab;
|
|
339
|
-
},
|
|
340
|
-
prepare(newSubTab) {
|
|
341
|
-
return { payload: { newSubTab } };
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
270
|
updateTransactionCategorization: {
|
|
345
271
|
reducer(draft, action) {
|
|
346
272
|
const selectedTab = action.payload.selectedTab;
|
|
@@ -778,10 +704,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
778
704
|
const { selectedTab, selectedPeriod, totalCount } = action.payload;
|
|
779
705
|
draft.transactionCategorizationView[selectedTab].uiState.totalCount[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = totalCount;
|
|
780
706
|
},
|
|
781
|
-
updateParentTotalCountForTab(draft, action) {
|
|
782
|
-
const { selectedTab, selectedPeriod, parentTotalCount } = action.payload;
|
|
783
|
-
draft.parentTotalCountByTab[selectedTab][(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = parentTotalCount;
|
|
784
|
-
},
|
|
785
707
|
updateSelectedCheckboxTransactionIds(draft, action) {
|
|
786
708
|
const selectedTab = action.payload.selectedTab;
|
|
787
709
|
const transactionIds = action.payload.transactionIds;
|
|
@@ -792,7 +714,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
792
714
|
draft.transactionCategorizationView[selectedTab] = {
|
|
793
715
|
...exports.initialTransactionTabViewState,
|
|
794
716
|
};
|
|
795
|
-
draft.parentTotalCountByTab[selectedTab] = {};
|
|
796
717
|
},
|
|
797
718
|
clearExpenseAutomationTransactionsView(draft) {
|
|
798
719
|
Object.assign(draft, exports.initialState);
|
|
@@ -889,5 +810,5 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
889
810
|
},
|
|
890
811
|
},
|
|
891
812
|
});
|
|
892
|
-
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.initializeTransactionCategorizationViewLocalData = _a.initializeTransactionCategorizationViewLocalData, exports.saveTransactionCategorizationLocalData = _a.saveTransactionCategorizationLocalData, exports.fetchTransactionCategorizationFailure = _a.fetchTransactionCategorizationFailure, exports.saveTransactionCategorization = _a.saveTransactionCategorization, exports.updateTransactionCategorization = _a.updateTransactionCategorization, exports.updateCurrentSelectedTransactionCategorizationTab = _a.updateCurrentSelectedTransactionCategorizationTab, exports.
|
|
813
|
+
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.initializeTransactionCategorizationViewLocalData = _a.initializeTransactionCategorizationViewLocalData, exports.saveTransactionCategorizationLocalData = _a.saveTransactionCategorizationLocalData, exports.fetchTransactionCategorizationFailure = _a.fetchTransactionCategorizationFailure, exports.saveTransactionCategorization = _a.saveTransactionCategorization, exports.updateTransactionCategorization = _a.updateTransactionCategorization, exports.updateCurrentSelectedTransactionCategorizationTab = _a.updateCurrentSelectedTransactionCategorizationTab, exports.updateTransactionCategorizationSaveStatus = _a.updateTransactionCategorizationSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = _a.updateStatusForTransactionNotMiscategorizedUpdateForCategorization, exports.updateSelectedVendorForTransaction = _a.updateSelectedVendorForTransaction, exports.updateSelectedCustomerForTransaction = _a.updateSelectedCustomerForTransaction, exports.setAllItemsToCategoryClassInLocalDataForCategorization = _a.setAllItemsToCategoryClassInLocalDataForCategorization, exports.updateTotalCountForTransactionCategorization = _a.updateTotalCountForTransactionCategorization, exports.fetchTransactionCategorizationSuccess = _a.fetchTransactionCategorizationSuccess, exports.resetOtherTabsFetchState = _a.resetOtherTabsFetchState, exports.fetchTransactionCategorizationView = _a.fetchTransactionCategorizationView, exports.updateSelectedCheckboxTransactionIds = _a.updateSelectedCheckboxTransactionIds, exports.clearExpenseAutomationTransactionsViewPerTabView = _a.clearExpenseAutomationTransactionsViewPerTabView, exports.clearExpenseAutomationTransactionsView = _a.clearExpenseAutomationTransactionsView, exports.setEntityRecommendationForLineIdsForCategorization = _a.setEntityRecommendationForLineIdsForCategorization, exports.updateSelectedTransactionId = _a.updateSelectedTransactionId, exports.syncTransactionCategorizationFromDetailSave = _a.syncTransactionCategorizationFromDetailSave, exports.backgroundRefetchReviewTab = _a.backgroundRefetchReviewTab, exports.updateTransactionCategorizationUploadReceiptState = _a.updateTransactionCategorizationUploadReceiptState, exports.uploadTransactionCategorizationReceiptSuccess = _a.uploadTransactionCategorizationReceiptSuccess;
|
|
893
814
|
exports.default = expenseAutomationTransactionsView.reducer;
|
|
@@ -2,8 +2,7 @@ import { CompletionStatusType, FetchStateAndError, ID } from '../../../commonSta
|
|
|
2
2
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
3
3
|
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
4
4
|
import { SupportedTransaction } from '../../../entity/transaction/transactionState';
|
|
5
|
-
import type { CompletedSubTab } from '../types/
|
|
6
|
-
import type { BatchFileStatus, BatchListItem, BatchStatus, BulkUploadPhase, BulkUploadResultsTab, BulkUploadSortKey, ManualSearchState, MatchSource, MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
|
|
5
|
+
import type { BatchFileStatus, BatchListItem, BatchStatus, BulkUploadPhase, BulkUploadResultsTab, BulkUploadSortKey, CompletedSubTab, ManualSearchState, MatchSource, MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
|
|
7
6
|
export interface CompletedTransactionsSelectorData {
|
|
8
7
|
fetchState: FetchStateAndError;
|
|
9
8
|
nextPageToken: string | null;
|
|
@@ -7,7 +7,6 @@ import { ClassBase } from '../../../entity/class/classState';
|
|
|
7
7
|
import { SupportedTransactionWithCOT } from '../../../entity/transaction/transactionState';
|
|
8
8
|
import { UncategorizedAccounts } from '../../accountList/accountListSelector';
|
|
9
9
|
import { ProjectListSelectorView } from '../../projectList/projectListSelector';
|
|
10
|
-
import { CompletedSubTab } from '../types/completedSubTab';
|
|
11
10
|
import { TransactionReviewLocalData, TransactionsTab, TransactionsViewUIState } from '../types/transactionsViewState';
|
|
12
11
|
export interface TransactionReviewLocalDataSelectorView {
|
|
13
12
|
transactionId: ID;
|
|
@@ -22,23 +21,10 @@ export interface ExpenseAutomationTransactionViewSelector extends SelectorView {
|
|
|
22
21
|
fetchStateByTransactionTabs: Record<TransactionsTab, FetchStateAndError>;
|
|
23
22
|
isAccountingProjectsEnabled: boolean;
|
|
24
23
|
markAsNotMiscategorizedStatus: FetchStateAndError;
|
|
25
|
-
/**
|
|
26
|
-
* Parent tab badge counts, sourced from the listing response's
|
|
27
|
-
* `parent_tab_total_count`. Used exclusively to drive the navbar / tab
|
|
28
|
-
* strip badge labels — every other count consumer (pagination, in-list
|
|
29
|
-
* "showing X of Y", save flows) keeps reading {@link totalCountByTab}.
|
|
30
|
-
*/
|
|
31
|
-
parentTabTotalCountByTab: Record<TransactionsTab, number>;
|
|
32
24
|
projectList: ProjectListSelectorView;
|
|
33
25
|
refreshStatus: FetchStateAndError;
|
|
34
26
|
saveStatus: FetchStateAndError;
|
|
35
27
|
selectedCheckBoxTransactionIds: ID[];
|
|
36
|
-
selectedTransactionCategorizationCompletedSubTab: CompletedSubTab;
|
|
37
|
-
/**
|
|
38
|
-
* Per-(sub-)tab counts mirroring `total_count` from the listing response.
|
|
39
|
-
* Powers pagination via `InfiniteLoader.itemCount`, in-list count copy,
|
|
40
|
-
* and the `resetTransactionCategorizationLocalData` round-trip.
|
|
41
|
-
*/
|
|
42
28
|
totalCountByTab: Record<TransactionsTab, number>;
|
|
43
29
|
transactionIdsWithUnsavedData: ID[];
|
|
44
30
|
transactionLocalData: TransactionReviewLocalDataSelectorView[];
|
|
@@ -16,7 +16,7 @@ const projectListSelector_1 = require("../../projectList/projectListSelector");
|
|
|
16
16
|
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
17
17
|
function getExpenseAutomationTransactionView(state) {
|
|
18
18
|
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
19
|
-
const {
|
|
19
|
+
const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
|
|
20
20
|
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
21
21
|
const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(accountState, accountListState, 'accountList');
|
|
22
22
|
const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
|
|
@@ -69,27 +69,10 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
69
69
|
.uiState.totalCount;
|
|
70
70
|
const totalCountByAutoCat = expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
71
71
|
.autoCategorized.uiState.totalCount;
|
|
72
|
-
// Per-(sub-)tab counts powering pagination, in-list "showing X of Y", and
|
|
73
|
-
// any save/refresh round-trips. Sourced from `uiState.totalCount` which
|
|
74
|
-
// mirrors the response's `total_count` for whatever tab/sub-tab the user is
|
|
75
|
-
// viewing (e.g. only the Manual sub-tab rows for Completed → Manual).
|
|
76
72
|
const totalCountByTab = {
|
|
77
73
|
review: monthYearPeriodId != null ? totalCountByReview[monthYearPeriodId] : 0,
|
|
78
74
|
autoCategorized: monthYearPeriodId != null ? totalCountByAutoCat[monthYearPeriodId] : 0,
|
|
79
75
|
};
|
|
80
|
-
// Parent-tab badge counts. Sourced from `parent_tab_total_count` in the
|
|
81
|
-
// listing response and used exclusively by the navbar / tab strip badges.
|
|
82
|
-
// Independent of which Completed sub-tab is active so the badge stays
|
|
83
|
-
// stable across sub-tab switches.
|
|
84
|
-
const parentTotalCountByTab = expenseAutomationTransactionsViewState.parentTotalCountByTab;
|
|
85
|
-
const parentTabTotalCountByTab = {
|
|
86
|
-
review: monthYearPeriodId != null
|
|
87
|
-
? (parentTotalCountByTab.review[monthYearPeriodId] ?? 0)
|
|
88
|
-
: 0,
|
|
89
|
-
autoCategorized: monthYearPeriodId != null
|
|
90
|
-
? (parentTotalCountByTab.autoCategorized[monthYearPeriodId] ?? 0)
|
|
91
|
-
: 0,
|
|
92
|
-
};
|
|
93
76
|
const fetchStateByTab = {
|
|
94
77
|
review: {
|
|
95
78
|
fetchState: expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
@@ -131,11 +114,9 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
131
114
|
markAsNotMiscategorizedStatus,
|
|
132
115
|
completionStatus,
|
|
133
116
|
totalCountByTab,
|
|
134
|
-
parentTabTotalCountByTab,
|
|
135
117
|
fetchStateByTransactionTabs: fetchStateByTab,
|
|
136
118
|
uploadReceiptStatusById,
|
|
137
119
|
selectedTransactionId,
|
|
138
120
|
selectedTransactionLineId,
|
|
139
|
-
selectedTransactionCategorizationCompletedSubTab,
|
|
140
121
|
};
|
|
141
122
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
2
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
3
3
|
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
4
|
-
import { CompletedSubTab } from './completedSubTab';
|
|
5
4
|
export declare const toMissingReceiptsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class";
|
|
6
5
|
export type MissingReceiptsSortKey = ReturnType<typeof toMissingReceiptsSortKey>;
|
|
7
6
|
export interface MissingReceiptsViewUIState {
|
|
@@ -32,6 +31,8 @@ export declare const toBulkUploadResultsTab: (v: string) => "completed" | "unmat
|
|
|
32
31
|
export type BulkUploadResultsTab = ReturnType<typeof toBulkUploadResultsTab>;
|
|
33
32
|
export declare const toMissingReceiptsTab: (v: string) => "completed" | "unmatched" | "missing";
|
|
34
33
|
export type MissingReceiptsTab = ReturnType<typeof toMissingReceiptsTab>;
|
|
34
|
+
export declare const toCompletedSubTab: (v: string) => "all" | "manual" | "ai_accountant";
|
|
35
|
+
export type CompletedSubTab = ReturnType<typeof toCompletedSubTab>;
|
|
35
36
|
export declare const toMatchSource: (v: string) => "manual" | "ai";
|
|
36
37
|
export type MatchSource = ReturnType<typeof toMatchSource>;
|
|
37
38
|
export declare const toBulkUploadSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBulkUploadSortKey = exports.toMatchSource = exports.toMissingReceiptsTab = exports.toBulkUploadResultsTab = exports.toBulkUploadPhase = exports.toBatchFileStatus = exports.BATCH_FILE_STATUSES = exports.toBatchStatusValue = exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = exports.toMissingReceiptsSortKey = void 0;
|
|
3
|
+
exports.toBulkUploadSortKey = exports.toMatchSource = exports.toCompletedSubTab = exports.toMissingReceiptsTab = exports.toBulkUploadResultsTab = exports.toBulkUploadPhase = exports.toBatchFileStatus = exports.BATCH_FILE_STATUSES = exports.toBatchStatusValue = exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = exports.toMissingReceiptsSortKey = void 0;
|
|
4
4
|
exports.isUnmatchedTabFileStatus = isUnmatchedTabFileStatus;
|
|
5
5
|
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
6
6
|
const MISSING_RECEIPTS_SORT_KEYS = [
|
|
@@ -49,6 +49,9 @@ exports.toBulkUploadResultsTab = toBulkUploadResultsTab;
|
|
|
49
49
|
const MISSING_RECEIPTS_TABS = ['missing', 'completed', 'unmatched'];
|
|
50
50
|
const toMissingReceiptsTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), MISSING_RECEIPTS_TABS);
|
|
51
51
|
exports.toMissingReceiptsTab = toMissingReceiptsTab;
|
|
52
|
+
const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
|
|
53
|
+
const toCompletedSubTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
|
|
54
|
+
exports.toCompletedSubTab = toCompletedSubTab;
|
|
52
55
|
const MATCH_SOURCES = ['ai', 'manual'];
|
|
53
56
|
const toMatchSource = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), MATCH_SOURCES);
|
|
54
57
|
exports.toMatchSource = toMatchSource;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
|
-
import {
|
|
2
|
+
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
3
|
import { Recommendation, RecommendationWithCOT } from '../../../commonStateTypes/recommendationBase';
|
|
4
4
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
5
5
|
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
@@ -13,11 +13,9 @@ import { TransactionID } from '../../../entity/transaction/stateTypes/transactio
|
|
|
13
13
|
import { BillableStatus, CategorizationStatusType, PlatformLineDetailType, ProductOrService, TransactionLineBase } from '../../../entity/transaction/stateTypes/transactionLine';
|
|
14
14
|
import { TransactionCategory, TransactionType } from '../../../entity/transaction/stateTypes/transactionType';
|
|
15
15
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
16
|
-
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
17
16
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
18
17
|
import { EntityRecommendationKey } from '../../recommendation/recommendationState';
|
|
19
18
|
import { TransactionDetailKey } from '../../transactionDetail/transactionDetailState';
|
|
20
|
-
import { CompletedSubTab } from './completedSubTab';
|
|
21
19
|
export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "project" | "category" | "class" | "payment_account" | "transaction_type" | "memo_and_receipt";
|
|
22
20
|
export type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
|
|
23
21
|
export declare const TRANSACTIONS_TABS: readonly ["review", "autoCategorized"];
|
|
@@ -105,39 +103,7 @@ export interface TransactionsTabViewState extends FetchedState {
|
|
|
105
103
|
selectedTransactionId?: ID;
|
|
106
104
|
selectedTransactionLineId?: ID;
|
|
107
105
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Snapshot of the autoCategorized tab's paginated dataset for a single
|
|
110
|
-
* Completed sub-tab. Stored in {@link TransactionsViewState.autoCategorizedSubTabCache}
|
|
111
|
-
* so revisiting an already-loaded sub-tab can short-circuit the fetch epic
|
|
112
|
-
* (mirrors parent-tab caching). The snapshot is period-spanning — both the
|
|
113
|
-
* `totalCount` map and `transactionIdsBySelectedPeriod` map preserve every
|
|
114
|
-
* period the user has paged through under that sub-tab.
|
|
115
|
-
*/
|
|
116
|
-
export interface AutoCategorizedSubTabSnapshot {
|
|
117
|
-
error: ZeniAPIStatus | undefined;
|
|
118
|
-
fetchState: FetchState;
|
|
119
|
-
pageToken: PageToken;
|
|
120
|
-
totalCount: Record<MonthYearPeriodId, number>;
|
|
121
|
-
transactionIdsBySelectedPeriod: Record<MonthYearPeriodId, ID[]>;
|
|
122
|
-
}
|
|
123
106
|
export type TransactionsViewState = {
|
|
124
|
-
/**
|
|
125
|
-
* Per-sub-tab snapshot cache for the Completed (autoCategorized) tab. Keyed
|
|
126
|
-
* by {@link CompletedSubTab}. Populated as the user navigates between
|
|
127
|
-
* sub-tabs and consulted on every switch — the active autoCategorized slot
|
|
128
|
-
* is restored from here when a snapshot exists, otherwise it is reset and
|
|
129
|
-
* the fetch epic loads page 1 fresh.
|
|
130
|
-
*/
|
|
131
|
-
autoCategorizedSubTabCache: Partial<Record<CompletedSubTab, AutoCategorizedSubTabSnapshot>>;
|
|
132
|
-
/**
|
|
133
|
-
* Period-keyed parent tab counts, scoped per {@link TransactionsTab}.
|
|
134
|
-
* Sourced from the listing response's `parent_tab_total_count` and used
|
|
135
|
-
* exclusively to drive the parent tab badges on the UI — every other
|
|
136
|
-
* count consumer (pagination, sub-tab chips, in-tab "showing X of Y")
|
|
137
|
-
* keeps reading from {@link TransactionsViewUIState.totalCount}.
|
|
138
|
-
*/
|
|
139
|
-
parentTotalCountByTab: Record<TransactionsTab, Record<MonthYearPeriodId, number>>;
|
|
140
|
-
selectedTransactionCategorizationCompletedSubTab: CompletedSubTab;
|
|
141
107
|
selectedTransactionCategorizationTab: TransactionsTab;
|
|
142
108
|
transactionCategorizationView: Record<TransactionsTab, TransactionsTabViewState>;
|
|
143
109
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Amount } from '../../commonStateTypes/amount';
|
|
2
|
+
import { SortOrder } from '../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
3
|
+
import { JournalEntryTransactionLine, Line, TransactionLineBase } from '../../entity/transaction/stateTypes/transactionLine';
|
|
4
|
+
/**
|
|
5
|
+
* View-model helpers for the new Journal Entry table view (see
|
|
6
|
+
* web-components `journalEntryTable`). Keeps presentation-agnostic
|
|
7
|
+
* logic — totals, sort, line-filter — colocated in epic-state so it
|
|
8
|
+
* is testable and reusable.
|
|
9
|
+
*/
|
|
10
|
+
export declare const JOURNAL_ENTRY_SORT_KEYS: readonly ["description", "name", "category", "class", "debit", "credit"];
|
|
11
|
+
export declare const toJournalEntrySortKey: (v: string) => "name" | "description" | "category" | "class" | "credit" | "debit";
|
|
12
|
+
export type JournalEntrySortKey = ReturnType<typeof toJournalEntrySortKey>;
|
|
13
|
+
export interface JournalEntryRowSortConfig {
|
|
14
|
+
sortKey: JournalEntrySortKey;
|
|
15
|
+
sortOrder: SortOrder;
|
|
16
|
+
}
|
|
17
|
+
export declare const journalEntryDefaultSortConfig: JournalEntryRowSortConfig;
|
|
18
|
+
type AmountBearer = Pick<TransactionLineBase, 'amount'>;
|
|
19
|
+
/**
|
|
20
|
+
* Sums the `amount.amount` field of every line and returns an `Amount`
|
|
21
|
+
* whose currencyCode/currencySymbol are taken from the first line.
|
|
22
|
+
* Returns `undefined` for an empty list.
|
|
23
|
+
*
|
|
24
|
+
* Mirrors legacy `calculateTotal` in
|
|
25
|
+
* `web-components/src/components/transactionDetail/items/TransactionLinesJournalEntry.tsx`
|
|
26
|
+
* but without the `Object.assign` ceremony and with stable currency carry-over.
|
|
27
|
+
*/
|
|
28
|
+
export declare const sumJournalEntryAmounts: (lines: ReadonlyArray<AmountBearer>) => Amount | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Splits `lines` by `postingType` into debit/credit totals.
|
|
31
|
+
*
|
|
32
|
+
* Fixes the operator-precedence bug from legacy
|
|
33
|
+
* `calculateCombinedTotalAmount` where
|
|
34
|
+
* `totalAmount?.amount ?? 0 + (...) + (...)` parses as
|
|
35
|
+
* `totalAmount?.amount ?? (0 + ... + ...)` so the `(...)`'s only get
|
|
36
|
+
* added when `totalAmount` is nullish. The new implementation just sums
|
|
37
|
+
* every debit (or credit) line including the un/miscategorized ones in
|
|
38
|
+
* one pass, so the result is always the true sum.
|
|
39
|
+
*/
|
|
40
|
+
export declare const journalEntryTotalsByPostingSide: (lines: ReadonlyArray<Pick<JournalEntryTransactionLine, "amount" | "postingType">>) => {
|
|
41
|
+
creditTotal?: Amount;
|
|
42
|
+
debitTotal?: Amount;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Drops `linked_transaction_line` entries — equivalent to legacy
|
|
46
|
+
* `filterOutLinkedTransactionLine` in `transactionDetail.helpers.ts`.
|
|
47
|
+
*/
|
|
48
|
+
export declare const filterJournalEntryLinesExcludingLinked: <T extends Pick<Line, "type">>(lines?: ReadonlyArray<T>) => T[];
|
|
49
|
+
/**
|
|
50
|
+
* Accessor functions resolve the sort value for each column from a
|
|
51
|
+
* line. The new table reads display-formatted values from the form
|
|
52
|
+
* (selected option label, entity name, etc.), so callers pass in
|
|
53
|
+
* accessors that match their `LineInfo` shape rather than baking the
|
|
54
|
+
* column-to-form-field mapping into epic-state.
|
|
55
|
+
*/
|
|
56
|
+
export interface JournalEntrySortAccessors<T> {
|
|
57
|
+
category: (line: T) => string;
|
|
58
|
+
class: (line: T) => string;
|
|
59
|
+
credit: (line: T) => number;
|
|
60
|
+
debit: (line: T) => number;
|
|
61
|
+
description: (line: T) => string;
|
|
62
|
+
name: (line: T) => string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Stable, accessor-driven sort over arbitrary line shapes. Lines that
|
|
66
|
+
* resolve to the same key value preserve their original relative order
|
|
67
|
+
* thanks to lodash's stable `orderBy`.
|
|
68
|
+
*
|
|
69
|
+
* Strings are lower-cased before comparison so the order is predictable
|
|
70
|
+
* across mixed-case data. Numbers (debit/credit) compare directly.
|
|
71
|
+
*/
|
|
72
|
+
export declare const sortJournalEntryLines: <T>(lines: ReadonlyArray<T>, config: JournalEntryRowSortConfig, accessors: JournalEntrySortAccessors<T>) => T[];
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sortJournalEntryLines = exports.filterJournalEntryLinesExcludingLinked = exports.journalEntryTotalsByPostingSide = exports.sumJournalEntryAmounts = exports.journalEntryDefaultSortConfig = exports.toJournalEntrySortKey = exports.JOURNAL_ENTRY_SORT_KEYS = void 0;
|
|
7
|
+
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
8
|
+
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
9
|
+
/**
|
|
10
|
+
* View-model helpers for the new Journal Entry table view (see
|
|
11
|
+
* web-components `journalEntryTable`). Keeps presentation-agnostic
|
|
12
|
+
* logic — totals, sort, line-filter — colocated in epic-state so it
|
|
13
|
+
* is testable and reusable.
|
|
14
|
+
*/
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Sort keys
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
exports.JOURNAL_ENTRY_SORT_KEYS = [
|
|
19
|
+
'description',
|
|
20
|
+
'name',
|
|
21
|
+
'category',
|
|
22
|
+
'class',
|
|
23
|
+
'debit',
|
|
24
|
+
'credit',
|
|
25
|
+
];
|
|
26
|
+
const toJournalEntrySortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.JOURNAL_ENTRY_SORT_KEYS);
|
|
27
|
+
exports.toJournalEntrySortKey = toJournalEntrySortKey;
|
|
28
|
+
exports.journalEntryDefaultSortConfig = {
|
|
29
|
+
sortKey: 'description',
|
|
30
|
+
sortOrder: 'ascending',
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Sums the `amount.amount` field of every line and returns an `Amount`
|
|
34
|
+
* whose currencyCode/currencySymbol are taken from the first line.
|
|
35
|
+
* Returns `undefined` for an empty list.
|
|
36
|
+
*
|
|
37
|
+
* Mirrors legacy `calculateTotal` in
|
|
38
|
+
* `web-components/src/components/transactionDetail/items/TransactionLinesJournalEntry.tsx`
|
|
39
|
+
* but without the `Object.assign` ceremony and with stable currency carry-over.
|
|
40
|
+
*/
|
|
41
|
+
const sumJournalEntryAmounts = (lines) => {
|
|
42
|
+
if (lines.length === 0) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const first = lines[0].amount;
|
|
46
|
+
let total = 0;
|
|
47
|
+
for (const line of lines) {
|
|
48
|
+
total += line.amount?.amount ?? 0;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
amount: total,
|
|
52
|
+
currencyCode: first?.currencyCode ?? '',
|
|
53
|
+
currencySymbol: first?.currencySymbol ?? '',
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.sumJournalEntryAmounts = sumJournalEntryAmounts;
|
|
57
|
+
/**
|
|
58
|
+
* Splits `lines` by `postingType` into debit/credit totals.
|
|
59
|
+
*
|
|
60
|
+
* Fixes the operator-precedence bug from legacy
|
|
61
|
+
* `calculateCombinedTotalAmount` where
|
|
62
|
+
* `totalAmount?.amount ?? 0 + (...) + (...)` parses as
|
|
63
|
+
* `totalAmount?.amount ?? (0 + ... + ...)` so the `(...)`'s only get
|
|
64
|
+
* added when `totalAmount` is nullish. The new implementation just sums
|
|
65
|
+
* every debit (or credit) line including the un/miscategorized ones in
|
|
66
|
+
* one pass, so the result is always the true sum.
|
|
67
|
+
*/
|
|
68
|
+
const journalEntryTotalsByPostingSide = (lines) => {
|
|
69
|
+
const debitLines = [];
|
|
70
|
+
const creditLines = [];
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
if (line.postingType === 'debit') {
|
|
73
|
+
debitLines.push(line);
|
|
74
|
+
}
|
|
75
|
+
else if (line.postingType === 'credit') {
|
|
76
|
+
creditLines.push(line);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
debitTotal: (0, exports.sumJournalEntryAmounts)(debitLines),
|
|
81
|
+
creditTotal: (0, exports.sumJournalEntryAmounts)(creditLines),
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
exports.journalEntryTotalsByPostingSide = journalEntryTotalsByPostingSide;
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Filter
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
/**
|
|
89
|
+
* Drops `linked_transaction_line` entries — equivalent to legacy
|
|
90
|
+
* `filterOutLinkedTransactionLine` in `transactionDetail.helpers.ts`.
|
|
91
|
+
*/
|
|
92
|
+
const filterJournalEntryLinesExcludingLinked = (lines) => lines?.filter((line) => line.type !== 'linked_transaction_line') ?? [];
|
|
93
|
+
exports.filterJournalEntryLinesExcludingLinked = filterJournalEntryLinesExcludingLinked;
|
|
94
|
+
const sortOrderToLodash = (sortOrder) => sortOrder === 'descending' ? 'desc' : 'asc';
|
|
95
|
+
/**
|
|
96
|
+
* Stable, accessor-driven sort over arbitrary line shapes. Lines that
|
|
97
|
+
* resolve to the same key value preserve their original relative order
|
|
98
|
+
* thanks to lodash's stable `orderBy`.
|
|
99
|
+
*
|
|
100
|
+
* Strings are lower-cased before comparison so the order is predictable
|
|
101
|
+
* across mixed-case data. Numbers (debit/credit) compare directly.
|
|
102
|
+
*/
|
|
103
|
+
const sortJournalEntryLines = (lines, config, accessors) => {
|
|
104
|
+
const accessor = (line) => {
|
|
105
|
+
switch (config.sortKey) {
|
|
106
|
+
case 'description':
|
|
107
|
+
return accessors.description(line).toLowerCase();
|
|
108
|
+
case 'name':
|
|
109
|
+
return accessors.name(line).toLowerCase();
|
|
110
|
+
case 'category':
|
|
111
|
+
return accessors.category(line).toLowerCase();
|
|
112
|
+
case 'class':
|
|
113
|
+
return accessors.class(line).toLowerCase();
|
|
114
|
+
case 'debit':
|
|
115
|
+
return accessors.debit(line);
|
|
116
|
+
case 'credit':
|
|
117
|
+
return accessors.credit(line);
|
|
118
|
+
default:
|
|
119
|
+
return accessors.description(line).toLowerCase();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return (0, orderBy_1.default)([...lines], [accessor], [sortOrderToLodash(config.sortOrder)]);
|
|
123
|
+
};
|
|
124
|
+
exports.sortJournalEntryLines = sortJournalEntryLines;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|