@zeniai/client-epic-state 4.13.17 → 4.13.19
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/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/entity/toastNotification/epic/pushToastNotificationEpic.d.ts +1 -1
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.d.ts +3 -1
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +6 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +3 -2
- package/lib/entity/transaction/stateTypes/transactionLine.d.ts +5 -0
- package/lib/entity/transaction/stateTypes/transactionLine.js +9 -1
- package/lib/entity/transaction/stateTypes/transactionType.d.ts +1 -1
- package/lib/entity/transaction/stateTypes/transactionType.js +2 -1
- package/lib/entity/transaction/transactionReducer.d.ts +3 -1
- package/lib/entity/transaction/transactionReducer.js +8 -2
- package/lib/epic.d.ts +7 -1
- package/lib/epic.js +7 -1
- package/lib/index.d.ts +7 -2
- package/lib/index.js +47 -25
- package/lib/view/accountList/fetchAccountListEpic.js +1 -1
- package/lib/view/cardPayment/epic/addCardPaymentSourceEpic.d.ts +1 -1
- package/lib/view/cardPayment/epic/confirmCardSetupIntentEpic.d.ts +1 -1
- package/lib/view/cardPayment/epic/createCardSetupIntentEpic.d.ts +1 -1
- package/lib/view/cardPayment/epic/fetchPaymentSourcesEpic.d.ts +1 -1
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +2 -1
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +8 -2
- package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +2 -1
- package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +5 -3
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +67 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +38 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/initializeTransactionCategorizationLocalDataEpic.d.ts +5 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/initializeTransactionCategorizationLocalDataEpic.js +31 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/markTransactionAsNotMiscatgorizedEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/markTransactionAsNotMiscatgorizedEpic.js +56 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/saveTransactionCategorizationEpic.d.ts +5 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/saveTransactionCategorizationEpic.js +32 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +164 -0
- package/lib/view/expenseAutomationView/expenseAutomationViewReducer.d.ts +3 -1
- package/lib/view/expenseAutomationView/expenseAutomationViewReducer.js +12 -2
- package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +14 -7
- package/lib/view/expenseAutomationView/expenseAutomationViewState.d.ts +2 -0
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.d.ts +8 -0
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +165 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +8 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +175 -0
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +48 -0
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.js +2 -0
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +100 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +368 -10
- package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +4 -0
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +29 -0
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +4 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +85 -0
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +97 -6
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +15 -2
- package/lib/view/people/changeZeniPersonRolesEpic.d.ts +1 -1
- package/lib/view/people/deletePersonEpic.d.ts +1 -1
- package/lib/view/people/invitePeopleEpic.d.ts +1 -1
- package/lib/view/people/inviteZeniPeopleEpic.d.ts +1 -1
- package/lib/view/people/resendInviteEpic.d.ts +1 -1
- package/lib/view/reviewCompanyView/reviewCompanyViewState.d.ts +1 -1
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
- package/lib/view/settingsView/epic/saveNotificationSettingsEpic.d.ts +1 -1
- package/lib/view/tagView/epics/createTagEpic.d.ts +1 -1
- package/lib/view/tagView/epics/deleteTagEpic.d.ts +1 -1
- package/lib/view/transactionDetail/epics/saveTransactionHelper.d.ts +8 -0
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +11 -6
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +2 -2
- package/lib/view/transactionDetail/transactionDetailLocalDataHelper.d.ts +10 -0
- package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +8 -7
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SupportedTransaction } from '../../../entity/transaction/transactionState';
|
|
2
|
+
import { UncategorizedAccounts } from '../../accountList/accountListSelector';
|
|
3
|
+
import { TransactionReviewLocalData, TransactionSaveUpdates } from '../types/transactionsViewState';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param transactionCategorizationLocalData
|
|
7
|
+
*/
|
|
8
|
+
export declare const toTransactionUpdatesFromTransactionCategorizationLocalData: (transactionCategorizationLocalData: TransactionReviewLocalData, transaction: SupportedTransaction, uncategorizedIncomeExpense: UncategorizedAccounts) => TransactionSaveUpdates;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toTransactionUpdatesFromTransactionCategorizationLocalData = void 0;
|
|
4
|
+
const entity_1 = require("../../../entity/genericEntity/entity");
|
|
5
|
+
const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
|
|
6
|
+
const recommendationState_1 = require("../../recommendation/recommendationState");
|
|
7
|
+
const saveTransactionHelper_1 = require("../../transactionDetail/epics/saveTransactionHelper");
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param transactionCategorizationLocalData
|
|
11
|
+
*/
|
|
12
|
+
const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionCategorizationLocalData, transaction, uncategorizedIncomeExpense) => {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
const updates = {
|
|
15
|
+
updatesByLineId: {},
|
|
16
|
+
};
|
|
17
|
+
const updatesByLineId = {};
|
|
18
|
+
const entityUpdates = {};
|
|
19
|
+
const isTransactionMisCategorized = (0, saveTransactionHelper_1.isTransactionMiscategorized)(transaction);
|
|
20
|
+
const isTransactionUnCategorized = (0, saveTransactionHelper_1.isTransactionUncategorized)(transaction, uncategorizedIncomeExpense);
|
|
21
|
+
updates.memo = transactionCategorizationLocalData.memo;
|
|
22
|
+
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) === true) {
|
|
23
|
+
updates.vendorId = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.id;
|
|
24
|
+
}
|
|
25
|
+
const entity = transaction.vendorId != null
|
|
26
|
+
? {
|
|
27
|
+
id: transaction.vendorId,
|
|
28
|
+
name: (_b = transaction.vendorName) !== null && _b !== void 0 ? _b : '',
|
|
29
|
+
type: (0, entity_1.toEntityType)('vendor'),
|
|
30
|
+
qboId: transaction.vendorId,
|
|
31
|
+
zeniId: transaction.vendorId,
|
|
32
|
+
}
|
|
33
|
+
: undefined;
|
|
34
|
+
let lastUpdatedCategory;
|
|
35
|
+
let lastUpdatedClass;
|
|
36
|
+
// single recommendation to just pick the last recommendation in the list of lines
|
|
37
|
+
(_c = transaction.lines) === null || _c === void 0 ? void 0 : _c.forEach((line) => {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
39
|
+
const updatedEntityId = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.qboId;
|
|
40
|
+
const entityDetails = getEntityDetails(entity, transactionCategorizationLocalData.lineItemById[line.id], transactionCategorizationLocalData.vendorUpdates);
|
|
41
|
+
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
42
|
+
line.type === 'transaction_with_product_or_service_line' ||
|
|
43
|
+
line.type === 'journal_entry_transaction_line') {
|
|
44
|
+
const lineItem = transactionCategorizationLocalData.lineItemById[line.id];
|
|
45
|
+
updatesByLineId[line.id] = {
|
|
46
|
+
lineDescription: lineItem.lineDescription,
|
|
47
|
+
class: lineItem.class,
|
|
48
|
+
account: lineItem.account,
|
|
49
|
+
recommendation: lineItem.recommendations,
|
|
50
|
+
};
|
|
51
|
+
if (line.type === 'journal_entry_transaction_line' ||
|
|
52
|
+
line.platformLineDetailType === 'deposit_line_detail') {
|
|
53
|
+
updatesByLineId[line.id] = Object.assign(Object.assign({}, updatesByLineId[line.id]), { vendor: lineItem.vendor });
|
|
54
|
+
}
|
|
55
|
+
let hasCategoryChanged = false;
|
|
56
|
+
let hasClassChanged = false;
|
|
57
|
+
const accountLine = line;
|
|
58
|
+
hasCategoryChanged =
|
|
59
|
+
((_b = lineItem.account) === null || _b === void 0 ? void 0 : _b.qboId) !== accountLine.account.qboId &&
|
|
60
|
+
Boolean((_c = lineItem.account) === null || _c === void 0 ? void 0 : _c.qboId);
|
|
61
|
+
hasClassChanged =
|
|
62
|
+
Boolean((_d = lineItem.class) === null || _d === void 0 ? void 0 : _d.qboId) &&
|
|
63
|
+
((_e = lineItem.class) === null || _e === void 0 ? void 0 : _e.qboId) !== accountLine.class.qboId;
|
|
64
|
+
const recommendedAccountBase = (0, saveTransactionHelper_1.toRecommendedAccountBase)(lineItem.amount.amount, lineItem.account);
|
|
65
|
+
const recommendedClassBase = (0, saveTransactionHelper_1.toRecommendedClassBase)(lineItem.amount.amount, lineItem.class);
|
|
66
|
+
const updatedLineEntityId = ((_f = accountLine.vendor) === null || _f === void 0 ? void 0 : _f.id) != null
|
|
67
|
+
? ((_g = accountLine.vendor) === null || _g === void 0 ? void 0 : _g.id) != ((_h = lineItem.vendor) === null || _h === void 0 ? void 0 : _h.id)
|
|
68
|
+
? (_j = lineItem.vendor) === null || _j === void 0 ? void 0 : _j.id
|
|
69
|
+
: (_k = accountLine.vendor) === null || _k === void 0 ? void 0 : _k.id
|
|
70
|
+
: undefined;
|
|
71
|
+
if (entityDetails != null &&
|
|
72
|
+
(updatedEntityId != null || updatedLineEntityId != null)) {
|
|
73
|
+
lastUpdatedCategory =
|
|
74
|
+
hasCategoryChanged === true ? recommendedAccountBase : undefined;
|
|
75
|
+
lastUpdatedClass =
|
|
76
|
+
hasClassChanged === true ? recommendedClassBase : undefined;
|
|
77
|
+
// Category might have been recommended one, and class may not have been updated and was undefined
|
|
78
|
+
// in this case check for each
|
|
79
|
+
const recommended = {
|
|
80
|
+
account: lastUpdatedCategory,
|
|
81
|
+
class: lastUpdatedClass,
|
|
82
|
+
};
|
|
83
|
+
if (recommended.class != null ||
|
|
84
|
+
recommended.account != null ||
|
|
85
|
+
updatedEntityId != null) {
|
|
86
|
+
const vendorIdToUpdate = (_l = transactionCategorizationLocalData.vendorUpdates) === null || _l === void 0 ? void 0 : _l.qboId;
|
|
87
|
+
let entityId = entityDetails.entityId;
|
|
88
|
+
if (line.type === 'journal_entry_transaction_line' ||
|
|
89
|
+
line.platformLineDetailType === 'deposit_line_detail') {
|
|
90
|
+
const entityId = (_m = accountLine.vendor) === null || _m === void 0 ? void 0 : _m.id;
|
|
91
|
+
if (entityId != null) {
|
|
92
|
+
doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, false, updatedLineEntityId);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (vendorIdToUpdate != null) {
|
|
97
|
+
entityId = vendorIdToUpdate;
|
|
98
|
+
}
|
|
99
|
+
doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, false, updatedEntityId);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
updatesByLineId[line.id] = line;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
updates.updatesByLineId = updatesByLineId;
|
|
109
|
+
return {
|
|
110
|
+
transactionId: transaction.id,
|
|
111
|
+
updates,
|
|
112
|
+
entityRelatedUpdates: entityUpdates,
|
|
113
|
+
/*Note: We need to call `mark-miscategorized-as-correct` api only when any of the line item is miscategorized
|
|
114
|
+
and all the line items are NOT uncategorized*/
|
|
115
|
+
markAsMiscatUpdates: isTransactionMisCategorized === true &&
|
|
116
|
+
isTransactionUnCategorized === false,
|
|
117
|
+
anyBulkUpdates: false,
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
exports.toTransactionUpdatesFromTransactionCategorizationLocalData = toTransactionUpdatesFromTransactionCategorizationLocalData;
|
|
121
|
+
const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendation, isBulkUpdate = false, updatedEntityId) => {
|
|
122
|
+
// see if this entity is already being updated
|
|
123
|
+
const entityKey = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
|
|
124
|
+
const entityUpdate = entityUpdates[entityKey];
|
|
125
|
+
if (entityUpdate == null) {
|
|
126
|
+
entityUpdates[entityKey] = {
|
|
127
|
+
entityId,
|
|
128
|
+
entityType,
|
|
129
|
+
recommendations: recommendation,
|
|
130
|
+
isBulkUpdate,
|
|
131
|
+
updatedEntityId,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), { recommendations: recommendation });
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
|
|
139
|
+
var _a, _b, _c;
|
|
140
|
+
if (entity != null) {
|
|
141
|
+
return {
|
|
142
|
+
entityId: (_a = entity.qboId) !== null && _a !== void 0 ? _a : entity.id,
|
|
143
|
+
entityType: entity.type,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (lineItemLocalData.lineEntity != null) {
|
|
147
|
+
return {
|
|
148
|
+
entityId: (_b = lineItemLocalData.lineEntity.qboId) !== null && _b !== void 0 ? _b : lineItemLocalData.lineEntity.id,
|
|
149
|
+
entityType: lineItemLocalData.vendor != null ? 'vendor' : 'customer',
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (vendorUpdates != null && vendorUpdates.id != null) {
|
|
153
|
+
return {
|
|
154
|
+
entityId: vendorUpdates.id,
|
|
155
|
+
entityType: 'vendor',
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (((_c = lineItemLocalData.vendor) === null || _c === void 0 ? void 0 : _c.id) != null) {
|
|
159
|
+
return {
|
|
160
|
+
entityId: lineItemLocalData.vendor.id,
|
|
161
|
+
entityType: 'vendor',
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
165
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ID } from '../../../commonStateTypes/common';
|
|
2
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
3
|
+
import { ClassBase } from '../../../entity/class/classState';
|
|
4
|
+
import { SupportedTransaction } from '../../../entity/transaction/transactionState';
|
|
5
|
+
import { TransactionReviewLocalData, TransactionsTabViewState } from '../types/transactionsViewState';
|
|
6
|
+
export declare const MAX_SELECTION_LIMIT = 5;
|
|
7
|
+
export declare const toTransactionDetailLocalData: (transaction: SupportedTransaction) => TransactionReviewLocalData;
|
|
8
|
+
export declare const toSetAllLineItemsToCategoryClass: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionId: ID, transactionLineId: ID, transactionDetailLocalData: TransactionReviewLocalData, vendorId?: string | undefined, selectedAccount?: AccountBase | undefined, selectedClassBase?: ClassBase | undefined) => TransactionReviewLocalData;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toSetAllLineItemsToCategoryClass = exports.toTransactionDetailLocalData = exports.MAX_SELECTION_LIMIT = void 0;
|
|
4
|
+
const transactionDetailLocalDataHelper_1 = require("../../transactionDetail/transactionDetailLocalDataHelper");
|
|
5
|
+
const transactionsViewState_1 = require("../types/transactionsViewState");
|
|
6
|
+
exports.MAX_SELECTION_LIMIT = 5;
|
|
7
|
+
const toTransactionDetailLocalData = (transaction) => {
|
|
8
|
+
const transactionLocal = Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData);
|
|
9
|
+
transactionLocal.memo = transaction.memo;
|
|
10
|
+
transactionLocal.transactionDate = transaction.date;
|
|
11
|
+
transactionLocal.transactionType = transaction.type;
|
|
12
|
+
transactionLocal.transactionTypeName = transaction.typeName;
|
|
13
|
+
transactionLocal.vendor =
|
|
14
|
+
transaction.vendorId != null && transaction.vendorName != null
|
|
15
|
+
? {
|
|
16
|
+
id: transaction.vendorId,
|
|
17
|
+
name: transaction.vendorName,
|
|
18
|
+
logo: transaction.logo,
|
|
19
|
+
}
|
|
20
|
+
: undefined;
|
|
21
|
+
transactionLocal.vendorUpdates = undefined;
|
|
22
|
+
transactionLocal.lineItemById =
|
|
23
|
+
transaction.lines != null && transaction.lines.length > 0
|
|
24
|
+
? buildLineItemById(transaction, transaction.recommendations)
|
|
25
|
+
: {};
|
|
26
|
+
return transactionLocal;
|
|
27
|
+
};
|
|
28
|
+
exports.toTransactionDetailLocalData = toTransactionDetailLocalData;
|
|
29
|
+
const buildLineItemById = (transaction, recommendations) => {
|
|
30
|
+
const lineItemData = {};
|
|
31
|
+
const { lines } = transaction;
|
|
32
|
+
lines === null || lines === void 0 ? void 0 : lines.forEach((line) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
35
|
+
line.type === 'transaction_with_product_or_service_line' ||
|
|
36
|
+
line.type === 'journal_entry_transaction_line') {
|
|
37
|
+
const record = Object.assign(Object.assign({}, line), { lineId: line.id, transactionId: transaction.id, transactionDate: transaction.date, billable: line.billable, isCategoryMiscategorized: (_a = line
|
|
38
|
+
.isCategoryMiscategorized) !== null && _a !== void 0 ? _a : false, isClassMiscategorized: (_b = line.isClassMiscategorized) !== null && _b !== void 0 ? _b : false });
|
|
39
|
+
const accountLine = line;
|
|
40
|
+
const lineId = line.id;
|
|
41
|
+
record.account = accountLine.account;
|
|
42
|
+
record.class = accountLine.class;
|
|
43
|
+
record.vendor =
|
|
44
|
+
accountLine.vendor != null
|
|
45
|
+
? {
|
|
46
|
+
id: accountLine.vendor.id,
|
|
47
|
+
name: accountLine.vendor.name,
|
|
48
|
+
logo: accountLine.vendor.logo,
|
|
49
|
+
}
|
|
50
|
+
: undefined;
|
|
51
|
+
record.customer = accountLine.customer;
|
|
52
|
+
record.billable = accountLine.billable;
|
|
53
|
+
record.categorizationStatus = accountLine.categorizationStatus;
|
|
54
|
+
record.reviewPendingReasons = accountLine.reviewPendingReasons;
|
|
55
|
+
if (recommendations != null) {
|
|
56
|
+
record.recommendations = recommendations[lineId];
|
|
57
|
+
}
|
|
58
|
+
lineItemData[line.id] = record;
|
|
59
|
+
if (line.platformLineDetailType === 'deposit_line_detail') {
|
|
60
|
+
record.lineEntity = (0, transactionDetailLocalDataHelper_1.toLineEntity)(line);
|
|
61
|
+
}
|
|
62
|
+
if (line.type === 'transaction_with_product_or_service_line') {
|
|
63
|
+
const lineRecord = line;
|
|
64
|
+
record.item = lineRecord.item;
|
|
65
|
+
record.lineDetailType = lineRecord.lineDetailType;
|
|
66
|
+
}
|
|
67
|
+
if (line.type === 'journal_entry_transaction_line') {
|
|
68
|
+
const lineRecord = line;
|
|
69
|
+
record.lineTransactionType = lineRecord.lineTransactionType;
|
|
70
|
+
record.postingType = lineRecord.postingType;
|
|
71
|
+
record.postingTypeName = lineRecord.postingTypeName;
|
|
72
|
+
record.lineEntity = (0, transactionDetailLocalDataHelper_1.toLineEntity)(lineRecord);
|
|
73
|
+
}
|
|
74
|
+
lineItemData[line.id] = record;
|
|
75
|
+
}
|
|
76
|
+
if (line.type === 'linked_transaction_line') {
|
|
77
|
+
const linkedRecord = line;
|
|
78
|
+
lineItemData[line.id] = Object.assign(Object.assign({}, linkedRecord), { lineId: linkedRecord.id, transactionId: transaction.id, transactionDate: transaction.date, billable: 'billable', isCategoryMiscategorized: false, isClassMiscategorized: false });
|
|
79
|
+
}
|
|
80
|
+
if (line.type === 'transaction_info_line') {
|
|
81
|
+
const infoRecord = line;
|
|
82
|
+
lineItemData[line.id] = Object.assign(Object.assign({}, infoRecord), { lineId: infoRecord.id, transactionId: transaction.id, transactionDate: transaction.date, billable: 'billable', isCategoryMiscategorized: false, isClassMiscategorized: false });
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return lineItemData;
|
|
86
|
+
};
|
|
87
|
+
const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, transactionLineId, transactionDetailLocalData, vendorId, selectedAccount, selectedClassBase) => {
|
|
88
|
+
const newLineItems = {};
|
|
89
|
+
let selectedCheckBoxTransactionIds = draft.selectedCheckBoxTransactionIds;
|
|
90
|
+
if (transaction.lines != null) {
|
|
91
|
+
// always preserving the order of the line items. hence iterating over this
|
|
92
|
+
transaction.lines.forEach((line) => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
95
|
+
line.type === 'transaction_with_product_or_service_line' ||
|
|
96
|
+
line.type === 'journal_entry_transaction_line') {
|
|
97
|
+
const lineId = line.id;
|
|
98
|
+
const record = Object.assign({}, transactionDetailLocalData.lineItemById[lineId]);
|
|
99
|
+
// if the line is the one that is being updated, then set the account and class
|
|
100
|
+
if (transactionId === record.transactionId &&
|
|
101
|
+
transactionLineId === lineId) {
|
|
102
|
+
record.account = selectedAccount;
|
|
103
|
+
record.class = selectedClassBase;
|
|
104
|
+
if (record.class != null && record.account != null) {
|
|
105
|
+
if (selectedCheckBoxTransactionIds.length <= exports.MAX_SELECTION_LIMIT &&
|
|
106
|
+
selectedCheckBoxTransactionIds.includes(transaction.id) === false) {
|
|
107
|
+
selectedCheckBoxTransactionIds.push(transaction.id);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
if (selectedCheckBoxTransactionIds.includes(transaction.id) === true) {
|
|
112
|
+
selectedCheckBoxTransactionIds =
|
|
113
|
+
selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
if ((transactionDetailLocalData.vendor != null &&
|
|
119
|
+
transactionDetailLocalData.vendor.id === vendorId) ||
|
|
120
|
+
(record.vendor != null && record.vendor.id === vendorId)) {
|
|
121
|
+
// if the vendor is same, then set the account and class with the selected ones and add the transaction to the selected list
|
|
122
|
+
if (((_a = record.account) === null || _a === void 0 ? void 0 : _a.qboId) == null) {
|
|
123
|
+
record.account = selectedAccount;
|
|
124
|
+
if (record.class != null &&
|
|
125
|
+
selectedCheckBoxTransactionIds.length <= exports.MAX_SELECTION_LIMIT &&
|
|
126
|
+
selectedCheckBoxTransactionIds.includes(transaction.id) ===
|
|
127
|
+
false) {
|
|
128
|
+
selectedCheckBoxTransactionIds.push(transaction.id);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (((_b = record.class) === null || _b === void 0 ? void 0 : _b.qboId) == null) {
|
|
132
|
+
record.class = selectedClassBase;
|
|
133
|
+
if (record.account != null &&
|
|
134
|
+
selectedCheckBoxTransactionIds.length <= exports.MAX_SELECTION_LIMIT &&
|
|
135
|
+
selectedCheckBoxTransactionIds.includes(transaction.id) ===
|
|
136
|
+
false) {
|
|
137
|
+
selectedCheckBoxTransactionIds.push(transaction.id);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (line.type === 'transaction_with_product_or_service_line') {
|
|
143
|
+
const lineRecord = transactionDetailLocalData.lineItemById[lineId];
|
|
144
|
+
record.item = lineRecord.item;
|
|
145
|
+
record.lineDetailType = lineRecord.lineDetailType;
|
|
146
|
+
}
|
|
147
|
+
if (line.type === 'journal_entry_transaction_line') {
|
|
148
|
+
const lineRecord = transactionDetailLocalData.lineItemById[lineId];
|
|
149
|
+
record.lineTransactionType = lineRecord.lineTransactionType;
|
|
150
|
+
record.postingType = lineRecord.postingType;
|
|
151
|
+
record.postingTypeName = lineRecord.postingTypeName;
|
|
152
|
+
record.lineEntity = (0, transactionDetailLocalDataHelper_1.toLineEntity)(lineRecord);
|
|
153
|
+
}
|
|
154
|
+
newLineItems[lineId] = record;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
newLineItems[line.id] = Object.assign({}, transactionDetailLocalData.lineItemById[line.id]);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendor: transactionDetailLocalData.vendor, vendorUpdates: transactionDetailLocalData.vendorUpdates, vendorDetails: transactionDetailLocalData.vendorDetails });
|
|
162
|
+
if (transactionDetailLocalData.vendor != null &&
|
|
163
|
+
transactionDetailLocalData.vendor.id === vendorId) {
|
|
164
|
+
if (!checkIfAllLineItemsAreCategoryClassFilled(newLocalData)) {
|
|
165
|
+
selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
166
|
+
}
|
|
167
|
+
draft.selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds;
|
|
168
|
+
}
|
|
169
|
+
return newLocalData;
|
|
170
|
+
};
|
|
171
|
+
exports.toSetAllLineItemsToCategoryClass = toSetAllLineItemsToCategoryClass;
|
|
172
|
+
const checkIfAllLineItemsAreCategoryClassFilled = (transactionDetailLocalData) => {
|
|
173
|
+
const lineItems = Object.values(transactionDetailLocalData.lineItemById);
|
|
174
|
+
return lineItems.every((lineItem) => lineItem.account != null && lineItem.class != null);
|
|
175
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { EntityRecommendationPayload } from '../../../commonPayloadTypes/recommendationPayload';
|
|
2
|
+
import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
|
|
3
|
+
import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState';
|
|
4
|
+
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
5
|
+
export interface TransactionCategorizationQueryPayload {
|
|
6
|
+
auto_categorized: boolean;
|
|
7
|
+
page_token: string | null;
|
|
8
|
+
page_size: number;
|
|
9
|
+
start_date: string | null;
|
|
10
|
+
end_date: string | null;
|
|
11
|
+
sort_by: string;
|
|
12
|
+
sort_order: string;
|
|
13
|
+
search_text: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface TransactionCategorizationPayload {
|
|
16
|
+
transactions: SupportedTransactionPayload[];
|
|
17
|
+
total_count: number;
|
|
18
|
+
query: TransactionCategorizationQueryPayload;
|
|
19
|
+
next_page_token: string | null;
|
|
20
|
+
}
|
|
21
|
+
export declare type TransactionCategorizationResponse = ZeniAPIResponse<TransactionCategorizationPayload>;
|
|
22
|
+
export interface EntityRelatedUpdatesPayload {
|
|
23
|
+
recommendations: EntityRecommendationPayload;
|
|
24
|
+
entity_id: string;
|
|
25
|
+
entity_type: string;
|
|
26
|
+
is_bulk_update: boolean;
|
|
27
|
+
updated_entity_id: string | undefined;
|
|
28
|
+
}
|
|
29
|
+
export interface UpdateTransactionCategorizationPayload {
|
|
30
|
+
transaction: Partial<TransactionPayload>;
|
|
31
|
+
entity_related_updates?: EntityRelatedUpdatesPayload[];
|
|
32
|
+
transaction_type: string;
|
|
33
|
+
transaction_id: string;
|
|
34
|
+
}
|
|
35
|
+
export interface UpdateTransactionCategorization {
|
|
36
|
+
transaction_id: string;
|
|
37
|
+
line_ids: string[];
|
|
38
|
+
}
|
|
39
|
+
interface UpdateTransactionCategorizationResponsePayload {
|
|
40
|
+
transactions_update_failed: UpdateTransactionCategorization[];
|
|
41
|
+
transactions_update_success: UpdateTransactionCategorization[];
|
|
42
|
+
}
|
|
43
|
+
export declare type TransactionCategorizationUpdateResponse = ZeniAPIResponse<UpdateTransactionCategorizationResponsePayload>;
|
|
44
|
+
export interface MarkAsReviewTransactionCategorizationPayload {
|
|
45
|
+
transactions_reviewed: UpdateTransactionCategorization[];
|
|
46
|
+
}
|
|
47
|
+
export declare type MarkAsReviewTransactionCategorizationPayloadResponse = ZeniAPIResponse<MarkAsReviewTransactionCategorizationPayload>;
|
|
48
|
+
export {};
|
|
@@ -1,5 +1,103 @@
|
|
|
1
|
-
import { TransactionsViewState } from '../types/transactionsViewState';
|
|
1
|
+
import { TransactionsViewState, TransactionsTabViewState, SupportedTransactionCategorization, TransactionSaveUpdates, TransactionsTab, TransactionsViewUIState } from '../types/transactionsViewState';
|
|
2
|
+
import { PageToken } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
3
|
+
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
4
|
+
import { FetchState, ID } from '../../../commonStateTypes/common';
|
|
5
|
+
import { MonthYearPeriod, TimePeriod } from '../../../commonStateTypes/timePeriod';
|
|
6
|
+
import { Recommendation } from '../../../commonStateTypes/recommendationBase';
|
|
7
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
8
|
+
import { ClassBase } from '../../../entity/class/classState';
|
|
9
|
+
import { Entity } from '../../../entity/genericEntity/entity';
|
|
10
|
+
import { SupportedTransaction } from '../../../entity/transaction/transactionState';
|
|
11
|
+
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
12
|
+
import { UpdateTransactionCategorization } from '../payload/transactionCategorizationPayload';
|
|
13
|
+
export declare const initialTransactionTabViewState: TransactionsTabViewState;
|
|
2
14
|
export declare const initialState: TransactionsViewState;
|
|
3
|
-
export declare const
|
|
15
|
+
export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", period: TimePeriod, cacheOverride?: any, keepExistingListItems?: any, searchString?: string | undefined, pageToken?: PageToken | undefined, refreshViewInBackground?: any], {
|
|
16
|
+
selectedTab: "review" | "autoCategorized";
|
|
17
|
+
period: TimePeriod;
|
|
18
|
+
searchString: string | undefined;
|
|
19
|
+
keepExistingListItems: any;
|
|
20
|
+
pageToken: PageToken | undefined;
|
|
21
|
+
cacheOverride: any;
|
|
22
|
+
refreshViewInBackground: any;
|
|
23
|
+
}, string, never, never>, updateTransactionCategorizationUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
24
|
+
selectedTab: TransactionsTab;
|
|
25
|
+
uiState: Partial<TransactionsViewUIState>;
|
|
26
|
+
}, string>, initializeTransactionCategorizationViewLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionIds: string[], selectedPeriod: MonthYearPeriod, keepExistingListItems: any, pageToken: PageToken, totalCount: number, refreshViewInBackground?: any], {
|
|
27
|
+
selectedTab: "review" | "autoCategorized";
|
|
28
|
+
transactionIds: string[];
|
|
29
|
+
selectedPeriod: MonthYearPeriod;
|
|
30
|
+
keepExistingListItems: any;
|
|
31
|
+
pageToken: PageToken;
|
|
32
|
+
totalCount: number;
|
|
33
|
+
refreshViewInBackground: any;
|
|
34
|
+
}, string, never, never>, saveTransactionCategorizationLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
35
|
+
selectedTab: TransactionsTab;
|
|
36
|
+
transactionIds: ID[];
|
|
37
|
+
selectedPeriod: MonthYearPeriod;
|
|
38
|
+
keepExistingListItems: boolean;
|
|
39
|
+
transactionLocalData: Record<ID, SupportedTransactionCategorization>;
|
|
40
|
+
pageToken: PageToken;
|
|
41
|
+
totalCount: number;
|
|
42
|
+
refreshViewInBackground?: boolean | undefined;
|
|
43
|
+
}, string>, fetchTransactionCategorizationFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
44
|
+
status: ZeniAPIStatus;
|
|
45
|
+
selectedPeriod: MonthYearPeriod;
|
|
46
|
+
selectedTab: TransactionsTab;
|
|
47
|
+
}, string>, saveTransactionCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionIds: string[]], {
|
|
48
|
+
selectedTab: "review" | "autoCategorized";
|
|
49
|
+
transactionIds: string[];
|
|
50
|
+
}, string, never, never>, updateTransactionCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionIds: string[], transactionSaveUpdates: TransactionSaveUpdates[]], {
|
|
51
|
+
selectedTab: "review" | "autoCategorized";
|
|
52
|
+
transactionIds: string[];
|
|
53
|
+
transactionSaveUpdates: TransactionSaveUpdates[];
|
|
54
|
+
}, string, never, never>, updateTransactionCategorizationSaveStatus: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", fetchState: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
|
|
55
|
+
selectedTab: "review" | "autoCategorized";
|
|
56
|
+
fetchState: FetchState;
|
|
57
|
+
error: ZeniAPIStatus<Record<string, unknown>> | undefined;
|
|
58
|
+
}, string, never, never>, markTransactionAsNotMiscategorized: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionsInReview: UpdateTransactionCategorization[]], {
|
|
59
|
+
selectedTab: "review" | "autoCategorized";
|
|
60
|
+
transactionsInReview: UpdateTransactionCategorization[];
|
|
61
|
+
}, string, never, never>, updateStatusForTransactionNotMiscategorizedUpdate: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionIds: string[], selectedPeriod: MonthYearPeriod, fetchState: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
|
|
62
|
+
selectedPeriod: MonthYearPeriod;
|
|
63
|
+
transactionIds: string[];
|
|
64
|
+
selectedTab: "review" | "autoCategorized";
|
|
65
|
+
fetchState: FetchState;
|
|
66
|
+
error: ZeniAPIStatus<Record<string, unknown>> | undefined;
|
|
67
|
+
}, string, never, never>, updateSelectedVendorForTransaction: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
68
|
+
selectedTab: TransactionsTab;
|
|
69
|
+
transactionId: ID;
|
|
70
|
+
lineId: ID;
|
|
71
|
+
selectedTransaction: SupportedTransaction;
|
|
72
|
+
updatedVendor?: VendorBase | undefined;
|
|
73
|
+
}, string>, setAllItemsToCategoryClassInLocalDataForCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionId: string, lineId: string, transactions: SupportedTransaction[], vendorId?: string | undefined, selectedAccount?: AccountBase | undefined, selectedClassBase?: ClassBase | undefined, lineEntity?: Entity | undefined, recommendations?: Recommendation[] | undefined], {
|
|
74
|
+
selectedTab: "review" | "autoCategorized";
|
|
75
|
+
transactionId: string;
|
|
76
|
+
lineId: string;
|
|
77
|
+
transactions: SupportedTransaction[];
|
|
78
|
+
vendorId: string | undefined;
|
|
79
|
+
lineEntity: Entity | undefined;
|
|
80
|
+
selectedAccount: AccountBase | undefined;
|
|
81
|
+
selectedClassBase: ClassBase | undefined;
|
|
82
|
+
recommendations: Recommendation[] | undefined;
|
|
83
|
+
}, string, never, never>, updateTotalCountForTransactionCategorization: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
84
|
+
selectedTab: TransactionsTab;
|
|
85
|
+
totalCount: number;
|
|
86
|
+
}, string>, fetchTransactionCategorizationSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
87
|
+
status: ZeniAPIStatus;
|
|
88
|
+
selectedTab: TransactionsTab;
|
|
89
|
+
refreshViewInBackground?: boolean | undefined;
|
|
90
|
+
}, string>, fetchTransactionCategorizationView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", period: TimePeriod, cacheOverride?: any, keepExistingListItems?: any, searchString?: string | undefined, pageToken?: PageToken | undefined, refreshViewInBackground?: any], {
|
|
91
|
+
selectedTab: "review" | "autoCategorized";
|
|
92
|
+
period: TimePeriod;
|
|
93
|
+
searchString: string | undefined;
|
|
94
|
+
keepExistingListItems: any;
|
|
95
|
+
pageToken: PageToken | undefined;
|
|
96
|
+
cacheOverride: any;
|
|
97
|
+
refreshViewInBackground: any;
|
|
98
|
+
}, string, never, never>, updateSelectedCheckboxTransactionIds: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
99
|
+
selectedTab: TransactionsTab;
|
|
100
|
+
transactionIds: ID[];
|
|
101
|
+
}, string>, clearExpenseAutomationTransactionsViewPerTabView: import("@reduxjs/toolkit").ActionCreatorWithPayload<"review" | "autoCategorized", string>, clearExpenseAutomationTransactionsView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
4
102
|
declare const _default: import("@reduxjs/toolkit").Reducer<TransactionsViewState, import("@reduxjs/toolkit").AnyAction>;
|
|
5
103
|
export default _default;
|