@zeniai/client-epic-state 4.19.42 → 4.19.43-betaAR2
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/account/accountState.d.ts +1 -0
- package/lib/entity/account/accountState.js +4 -4
- package/lib/epic.d.ts +2 -1
- package/lib/epic.js +2 -1
- package/lib/esm/entity/account/accountState.js +1 -1
- package/lib/esm/epic.js +2 -1
- package/lib/esm/index.js +7 -7
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/accountSettings/fetchAccountSettingsListForAccountTypesEpic.js +2 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/accountSettings/saveAccountSettingsViewEpic.js +2 -1
- package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -1
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +11 -1
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +57 -8
- package/lib/esm/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewDashboardLoadedEpic.js +28 -0
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +31 -1
- package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +137 -1
- package/lib/index.d.ts +9 -9
- package/lib/index.js +35 -30
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/accountSettings/fetchAccountSettingsListForAccountTypesEpic.js +2 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/accountSettings/saveAccountSettingsViewEpic.js +2 -1
- package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +5 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +12 -2
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +4 -1
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +59 -8
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewDashboardLoadedEpic.d.ts +8 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewDashboardLoadedEpic.js +32 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +3 -1
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +32 -2
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +1 -0
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +43 -4
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +138 -2
- package/package.json +2 -1
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.hideCreatedByFilter = exports.isRemiListDownloadable = exports.isBillListDownloadable = exports.applyAdvancedFiltersOnList = void 0;
|
|
6
|
+
exports.hideCreatedByFilter = exports.isRemiListDownloadable = exports.isBillListDownloadable = exports.applyAdvancedFiltersOnList = exports.TRANSACTION_FILTER_CATEGORIES = void 0;
|
|
7
7
|
const get_1 = __importDefault(require("lodash/get"));
|
|
8
8
|
const userSelector_1 = require("../../entity/user/userSelector");
|
|
9
9
|
const userRoleType_1 = require("../../entity/userRole/userRoleType");
|
|
@@ -13,6 +13,14 @@ const billListState_1 = require("./billPay/billList/billListState");
|
|
|
13
13
|
const helpers_1 = require("./helpers");
|
|
14
14
|
const remiListSelector_1 = require("./reimbursement/remiListView/remiListSelector");
|
|
15
15
|
const remiListState_1 = require("./reimbursement/remiListView/remiListState");
|
|
16
|
+
exports.TRANSACTION_FILTER_CATEGORIES = [
|
|
17
|
+
{ value: 'payment_account_name', type: 'searchAutocomplete' },
|
|
18
|
+
{ value: 'payment_account_type', type: 'dropdown' },
|
|
19
|
+
{ value: 'payee', type: 'searchAutocomplete' },
|
|
20
|
+
{ value: 'category', type: 'dropdown' },
|
|
21
|
+
{ value: 'class', type: 'dropdown' },
|
|
22
|
+
{ value: 'amount', type: 'numberRange' },
|
|
23
|
+
];
|
|
16
24
|
//filters items against filter values representing a range. ex: date (from-to), amount(1k<-->5k)
|
|
17
25
|
const filterItemOnRangeCategoryType = (valueForItem, currentFilter) => {
|
|
18
26
|
let doesItemFallInValueRange = false;
|
|
@@ -110,7 +118,11 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
110
118
|
? getCategoryValueForBill(key, item)
|
|
111
119
|
: entity === 'reimbursement'
|
|
112
120
|
? getCategoryValueForReimbursement(key, item)
|
|
113
|
-
:
|
|
121
|
+
: entity === 'task_management'
|
|
122
|
+
? getCategoryValueForTaskList(key, item)
|
|
123
|
+
: entity === 'transaction_categorization'
|
|
124
|
+
? getCategoryValueForTransaction(key, item)
|
|
125
|
+
: undefined;
|
|
114
126
|
if (categoryValue == null) {
|
|
115
127
|
if (currentFilter.matchingOperator === 'not-equal') {
|
|
116
128
|
return true;
|
|
@@ -231,6 +243,130 @@ const getCategoryValueForReimbursement = (key, reimbursement) => {
|
|
|
231
243
|
return undefined;
|
|
232
244
|
}
|
|
233
245
|
};
|
|
246
|
+
const getCategoryValueForTransaction = (key, transaction) => {
|
|
247
|
+
switch (key) {
|
|
248
|
+
case 'amount': {
|
|
249
|
+
// Get from transactionLocalData line items (preferred) - sum all line item amounts
|
|
250
|
+
const localDataForAmount = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
251
|
+
if (localDataForAmount?.lineItemById) {
|
|
252
|
+
const lineItems = Object.values(localDataForAmount.lineItemById);
|
|
253
|
+
if (lineItems.length > 0) {
|
|
254
|
+
// Sum all line item amounts
|
|
255
|
+
const totalAmount = lineItems.reduce((sum, lineItem) => sum + (lineItem.amount?.amount ?? 0), 0);
|
|
256
|
+
return totalAmount;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Fallback to transaction-level amount or sum from transaction lines
|
|
260
|
+
if (transaction.transaction.lines && transaction.transaction.lines.length > 0) {
|
|
261
|
+
const totalAmount = transaction.transaction.lines.reduce((sum, line) => sum + (line.amount?.amount ?? 0), 0);
|
|
262
|
+
return totalAmount;
|
|
263
|
+
}
|
|
264
|
+
// Final fallback to transaction amount
|
|
265
|
+
return transaction.amount.amount;
|
|
266
|
+
}
|
|
267
|
+
case 'payee': {
|
|
268
|
+
// Priority: vendorName > customerName > from transactionLocalData
|
|
269
|
+
if (transaction.vendorName) {
|
|
270
|
+
return transaction.vendorName;
|
|
271
|
+
}
|
|
272
|
+
if (transaction.customerName) {
|
|
273
|
+
return transaction.customerName;
|
|
274
|
+
}
|
|
275
|
+
// Check transactionLocalData for vendor/customer
|
|
276
|
+
const localData = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
277
|
+
if (localData?.vendor?.name) {
|
|
278
|
+
return localData.vendor.name;
|
|
279
|
+
}
|
|
280
|
+
if (localData?.customer?.name) {
|
|
281
|
+
return localData.customer.name;
|
|
282
|
+
}
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
case 'payment_account_name': {
|
|
286
|
+
// Get from transaction.account or from lines
|
|
287
|
+
if (transaction.transaction.account?.accountName) {
|
|
288
|
+
return transaction.transaction.account.accountName;
|
|
289
|
+
}
|
|
290
|
+
// Get from first line's account
|
|
291
|
+
const firstLine = transaction.transaction.lines?.[0];
|
|
292
|
+
if (firstLine?.type === 'transaction_with_account_and_class_line' ||
|
|
293
|
+
firstLine?.type === 'transaction_with_product_or_service_line' ||
|
|
294
|
+
firstLine?.type === 'journal_entry_transaction_line') {
|
|
295
|
+
const accountLine = firstLine;
|
|
296
|
+
return accountLine.account?.accountName;
|
|
297
|
+
}
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
case 'payment_account_type': {
|
|
301
|
+
// Similar to payment_account_name but for type
|
|
302
|
+
if (transaction.transaction.account?.accountType) {
|
|
303
|
+
return transaction.transaction.account.accountType;
|
|
304
|
+
}
|
|
305
|
+
const firstLineForType = transaction.transaction.lines?.[0];
|
|
306
|
+
if (firstLineForType?.type === 'transaction_with_account_and_class_line' ||
|
|
307
|
+
firstLineForType?.type === 'transaction_with_product_or_service_line' ||
|
|
308
|
+
firstLineForType?.type === 'journal_entry_transaction_line') {
|
|
309
|
+
const accountLineForType = firstLineForType;
|
|
310
|
+
return accountLineForType.account?.accountType;
|
|
311
|
+
}
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
case 'category': {
|
|
315
|
+
// Get from transactionLocalData (preferred) or from transaction lines
|
|
316
|
+
const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
317
|
+
if (localDataForCategory) {
|
|
318
|
+
// Get category from first line item or most common
|
|
319
|
+
const firstLineItem = Object.values(localDataForCategory.lineItemById)[0];
|
|
320
|
+
if (firstLineItem?.account?.accountId) {
|
|
321
|
+
return firstLineItem.account.accountId;
|
|
322
|
+
}
|
|
323
|
+
if (firstLineItem?.account?.qboId) {
|
|
324
|
+
return firstLineItem.account.qboId;
|
|
325
|
+
}
|
|
326
|
+
if (firstLineItem?.account?.accountName) {
|
|
327
|
+
return firstLineItem.account.accountName;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// Fallback to transaction lines
|
|
331
|
+
const firstLineForCategory = transaction.transaction.lines?.[0];
|
|
332
|
+
if (firstLineForCategory?.type === 'transaction_with_account_and_class_line' ||
|
|
333
|
+
firstLineForCategory?.type === 'transaction_with_product_or_service_line' ||
|
|
334
|
+
firstLineForCategory?.type === 'journal_entry_transaction_line') {
|
|
335
|
+
const account = firstLineForCategory
|
|
336
|
+
.account;
|
|
337
|
+
return account?.accountId ?? account?.qboId ?? account?.accountName;
|
|
338
|
+
}
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
case 'class': {
|
|
342
|
+
// Similar to category but for class
|
|
343
|
+
const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
344
|
+
if (localDataForClass) {
|
|
345
|
+
const firstLineItemForClass = Object.values(localDataForClass.lineItemById)[0];
|
|
346
|
+
if (firstLineItemForClass?.class?.classId) {
|
|
347
|
+
return firstLineItemForClass.class.classId;
|
|
348
|
+
}
|
|
349
|
+
if (firstLineItemForClass?.class?.qboId) {
|
|
350
|
+
return firstLineItemForClass.class.qboId;
|
|
351
|
+
}
|
|
352
|
+
if (firstLineItemForClass?.class?.className) {
|
|
353
|
+
return firstLineItemForClass.class.className;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const firstLineForClass = transaction.transaction.lines?.[0];
|
|
357
|
+
if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
|
|
358
|
+
firstLineForClass?.type === 'transaction_with_product_or_service_line' ||
|
|
359
|
+
firstLineForClass?.type === 'journal_entry_transaction_line') {
|
|
360
|
+
const classData = firstLineForClass
|
|
361
|
+
.class;
|
|
362
|
+
return classData?.classId ?? classData?.qboId ?? classData?.className;
|
|
363
|
+
}
|
|
364
|
+
return undefined;
|
|
365
|
+
}
|
|
366
|
+
default:
|
|
367
|
+
return undefined;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
234
370
|
const isBillListDownloadable = (state, currentTimePeriod) => {
|
|
235
371
|
const { billListState, billTransactionState, entityApprovalStatusState, userState, } = state;
|
|
236
372
|
const keys = billListState_1.ALL_BILL_TABS.filter((tab) => tab !== 'draft').map((tab) => (0, billListState_1.getBillListKey)(currentTimePeriod, tab));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.
|
|
3
|
+
"version": "4.19.43-betaAR2",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"circular-dependency": "npx madge --circular --extensions ts ./src",
|
|
114
114
|
"build": "concurrently --kill-others-on-fail --handle-input \"echo 'Running ESLint...' && eslint . --ext .js,.jsx,.ts,.tsx\" \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\" \"echo 'Running tests and typecheck...' && pnpm test\" && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
|
|
115
115
|
"only-build": "eslint . --ext .js,.jsx,.ts,.tsx && time tsc && tsc -p tsconfig.esm.json && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
|
|
116
|
+
"only-build-dev": "eslint . --ext .js,.jsx,.ts,.tsx && time tsc -p tsconfig.dev.json && tsc -p tsconfig.esm.dev.json && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
|
|
116
117
|
"format": "prettier --write --ignore-unknown \"src/**/*\" && pnpm lint",
|
|
117
118
|
"format-watch": "(git diff --name-only --diff-filter=ACM && git ls-files --others --exclude-standard) | grep -E '\\.(ts|tsx)$' | xargs prettier --write",
|
|
118
119
|
"check-version": "node ./scripts/check_version.js",
|