@zeniai/client-epic-state 4.19.24-betaRR13 → 4.19.24-betaRR14
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/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.d.ts +3 -7
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.js +15 -12
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.d.ts +3 -6
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +25 -17
- package/package.json +1 -1
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { ID } from '../../../../commonStateTypes/common';
|
|
2
2
|
import { ChargeCardRepaymentStatusCodeType } from '../../../../entity/chargeCardRepayment/chargeCardRepayment';
|
|
3
|
+
import { PaymentHistoryAccountInfo, PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
3
4
|
import type { ChargeCardRepaymentWithUser } from './chargeCardPaymentHistorySelector';
|
|
4
|
-
|
|
5
|
-
export declare function getPaymentHistorySourceAccountName(repayment: ChargeCardRepaymentWithUser, accountInfoMap?: Map<ID, {
|
|
6
|
-
depositAccountName?: string;
|
|
7
|
-
}>): string;
|
|
5
|
+
export declare function getPaymentHistorySourceAccountName(repayment: ChargeCardRepaymentWithUser, accountInfoByAccountId?: Record<ID, PaymentHistoryAccountInfo>): string;
|
|
8
6
|
export declare function getPaymentStatusDisplayText(status: ChargeCardRepaymentStatusCodeType): string;
|
|
9
|
-
export declare function applyPaymentHistoryFiltersSearchAndSort(repayments: ChargeCardRepaymentWithUser[], filters: PaymentHistoryFilters, searchText: string, uiState: PaymentHistoryUIState,
|
|
10
|
-
depositAccountName?: string;
|
|
11
|
-
}>): ChargeCardRepaymentWithUser[];
|
|
7
|
+
export declare function applyPaymentHistoryFiltersSearchAndSort(repayments: ChargeCardRepaymentWithUser[], filters: PaymentHistoryFilters, searchText: string, uiState: PaymentHistoryUIState, accountInfoByAccountId?: Record<ID, PaymentHistoryAccountInfo>): ChargeCardRepaymentWithUser[];
|
|
@@ -9,9 +9,12 @@ exports.applyPaymentHistoryFiltersSearchAndSort = applyPaymentHistoryFiltersSear
|
|
|
9
9
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
10
10
|
const userSelector_1 = require("../../../../entity/user/userSelector");
|
|
11
11
|
const spendManagementFilterHelpers_1 = require("../../spendManagementFilterHelpers");
|
|
12
|
-
function getPaymentHistorySourceAccountName(repayment,
|
|
13
|
-
var _a, _b
|
|
14
|
-
|
|
12
|
+
function getPaymentHistorySourceAccountName(repayment, accountInfoByAccountId) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const fromMap = repayment.paymentAccountId != null
|
|
15
|
+
? (_a = accountInfoByAccountId === null || accountInfoByAccountId === void 0 ? void 0 : accountInfoByAccountId[repayment.paymentAccountId]) === null || _a === void 0 ? void 0 : _a.depositAccountName
|
|
16
|
+
: undefined;
|
|
17
|
+
return (_b = fromMap !== null && fromMap !== void 0 ? fromMap : repayment.paymentAccountName) !== null && _b !== void 0 ? _b : '';
|
|
15
18
|
}
|
|
16
19
|
function getPaymentStatusDisplayText(status) {
|
|
17
20
|
var _a;
|
|
@@ -25,7 +28,7 @@ function getPaymentStatusDisplayText(status) {
|
|
|
25
28
|
};
|
|
26
29
|
return (_a = statusMap[status]) !== null && _a !== void 0 ? _a : status;
|
|
27
30
|
}
|
|
28
|
-
function getPaymentHistorySortValue(repayment, sortKey,
|
|
31
|
+
function getPaymentHistorySortValue(repayment, sortKey, accountInfoByAccountId) {
|
|
29
32
|
switch (sortKey) {
|
|
30
33
|
case 'paymentDate':
|
|
31
34
|
return repayment.repaymentDate.valueOf();
|
|
@@ -38,12 +41,12 @@ function getPaymentHistorySortValue(repayment, sortKey, accountInfoMap) {
|
|
|
38
41
|
? 'autopay'
|
|
39
42
|
: (0, userSelector_1.getUserName)(repayment.paidByUser);
|
|
40
43
|
case 'sourceAccount':
|
|
41
|
-
return getPaymentHistorySourceAccountName(repayment,
|
|
44
|
+
return getPaymentHistorySourceAccountName(repayment, accountInfoByAccountId);
|
|
42
45
|
default:
|
|
43
46
|
return '';
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
function sortPaymentHistory(repayments, sortKey, sortOrder,
|
|
49
|
+
function sortPaymentHistory(repayments, sortKey, sortOrder, accountInfoByAccountId) {
|
|
47
50
|
const getColumnWiseSortOrder = (sortOrder) => {
|
|
48
51
|
switch (sortKey) {
|
|
49
52
|
case 'sourceAccount':
|
|
@@ -55,9 +58,9 @@ function sortPaymentHistory(repayments, sortKey, sortOrder, accountInfoMap) {
|
|
|
55
58
|
}
|
|
56
59
|
};
|
|
57
60
|
const order = getColumnWiseSortOrder(sortOrder);
|
|
58
|
-
return (0, orderBy_1.default)(repayments, (repayment) => getPaymentHistorySortValue(repayment, sortKey,
|
|
61
|
+
return (0, orderBy_1.default)(repayments, (repayment) => getPaymentHistorySortValue(repayment, sortKey, accountInfoByAccountId), [order]);
|
|
59
62
|
}
|
|
60
|
-
function filterPaymentHistoryBySearchText(repayments, searchText,
|
|
63
|
+
function filterPaymentHistoryBySearchText(repayments, searchText, accountInfoByAccountId) {
|
|
61
64
|
const loweredSearchText = searchText.trim().toLowerCase();
|
|
62
65
|
if (loweredSearchText.length === 0) {
|
|
63
66
|
return repayments;
|
|
@@ -68,16 +71,16 @@ function filterPaymentHistoryBySearchText(repayments, searchText, accountInfoMap
|
|
|
68
71
|
const initiatedByString = repayment.repaymentType === 'scheduled'
|
|
69
72
|
? 'autopay'
|
|
70
73
|
: (0, userSelector_1.getUserName)(repayment.paidByUser);
|
|
71
|
-
const accountNameString = getPaymentHistorySourceAccountName(repayment,
|
|
74
|
+
const accountNameString = getPaymentHistorySourceAccountName(repayment, accountInfoByAccountId).toLowerCase();
|
|
72
75
|
return (amountString.includes(loweredSearchText) ||
|
|
73
76
|
statusString.includes(loweredSearchText) ||
|
|
74
77
|
initiatedByString.toLowerCase().includes(loweredSearchText) ||
|
|
75
78
|
accountNameString.includes(loweredSearchText));
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
|
-
function applyPaymentHistoryFiltersSearchAndSort(repayments, filters, searchText, uiState,
|
|
81
|
+
function applyPaymentHistoryFiltersSearchAndSort(repayments, filters, searchText, uiState, accountInfoByAccountId) {
|
|
79
82
|
let result = (0, spendManagementFilterHelpers_1.applyAdvancedFiltersOnList)('charge_card_payment_history', repayments, filters);
|
|
80
|
-
result = filterPaymentHistoryBySearchText(result, searchText,
|
|
81
|
-
result = sortPaymentHistory(result, uiState.sortKey, uiState.sortOrder,
|
|
83
|
+
result = filterPaymentHistoryBySearchText(result, searchText, accountInfoByAccountId);
|
|
84
|
+
result = sortPaymentHistory(result, uiState.sortKey, uiState.sortOrder, accountInfoByAccountId);
|
|
82
85
|
return result;
|
|
83
86
|
}
|
|
@@ -3,25 +3,22 @@ import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAnd
|
|
|
3
3
|
import { ChargeCardRepayment } from '../../../../entity/chargeCardRepayment/chargeCardRepayment';
|
|
4
4
|
import { User } from '../../../../entity/user/userState';
|
|
5
5
|
import { RootState } from '../../../../reducer';
|
|
6
|
-
import {
|
|
7
|
-
import { PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
6
|
+
import { PaymentHistoryAccountInfo, PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
8
7
|
export interface ChargeCardRepaymentWithUser extends ChargeCardRepayment {
|
|
9
8
|
paidByUser?: User;
|
|
10
9
|
}
|
|
11
10
|
export interface ChargeCardPaymentHistorySelectorView extends SelectorView {
|
|
11
|
+
accountInfoByAccountId: Record<ID, PaymentHistoryAccountInfo>;
|
|
12
12
|
creditAccountId: ID;
|
|
13
13
|
currencyCode: string;
|
|
14
14
|
currencySymbol: string;
|
|
15
15
|
filters: PaymentHistoryFilters;
|
|
16
16
|
isAutoPayEnabled: boolean;
|
|
17
17
|
repaymentHistory: ChargeCardRepaymentWithUser[];
|
|
18
|
-
repaymentHistoryFundingAccounts: FundingAccount[];
|
|
19
18
|
repaymentHistoryIds: ID[];
|
|
20
19
|
repaymentHistoryUsers: User[];
|
|
21
20
|
searchText: string;
|
|
22
21
|
totalRepayments: number;
|
|
23
22
|
uiState: PaymentHistoryUIState;
|
|
24
23
|
}
|
|
25
|
-
export declare const getChargeCardPaymentHistoryView: (state: RootState
|
|
26
|
-
depositAccountName?: string;
|
|
27
|
-
}>) => ChargeCardPaymentHistorySelectorView;
|
|
24
|
+
export declare const getChargeCardPaymentHistoryView: (state: RootState) => ChargeCardPaymentHistorySelectorView;
|
|
@@ -8,7 +8,7 @@ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
|
|
|
8
8
|
const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
|
|
9
9
|
const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
|
|
10
10
|
const chargeCardPaymentHistoryHelpers_1 = require("./chargeCardPaymentHistoryHelpers");
|
|
11
|
-
const getChargeCardPaymentHistoryView = (state
|
|
11
|
+
const getChargeCardPaymentHistoryView = (state) => {
|
|
12
12
|
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState, depositAccountState, paymentAccountState, depositAccountListState, paymentAccountListState, } = state;
|
|
13
13
|
const { creditAccountId, currencyCode, currencySymbol, filters, isAutoPayEnabled, repaymentHistoryIds, searchText, totalRepayments, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
|
|
14
14
|
// Get the full repayment details from the entity state
|
|
@@ -23,26 +23,34 @@ const getChargeCardPaymentHistoryView = (state, accountInfoMap) => {
|
|
|
23
23
|
});
|
|
24
24
|
// Enrich repayments with paidByUser details
|
|
25
25
|
let repaymentHistoryWithUsers = repaymentHistory.map((repayment) => (Object.assign(Object.assign({}, repayment), { paidByUser: userMap.get(repayment.paidById) })));
|
|
26
|
-
|
|
27
|
-
// Extract unique funding account IDs from repayment history
|
|
28
|
-
const repaymentHistoryFundingAccountIds = Array.from(new Set(repaymentHistoryWithUsers
|
|
29
|
-
.map((repayment) => repayment.paymentAccountId)
|
|
30
|
-
.filter((id) => id !== undefined && id !== null)));
|
|
31
|
-
// Get deposit and payment accounts views for fetch state reduction
|
|
26
|
+
// Get deposit and payment accounts views (used for funding accounts and fetch state)
|
|
32
27
|
const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
|
|
33
28
|
const paymentAccountsView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
// Extract unique funding account IDs from unfiltered repayment history (for accountInfoMap used in filter/sort)
|
|
30
|
+
const repaymentHistoryFundingAccountIdsForMap = Array.from(new Set(repaymentHistory
|
|
31
|
+
.map((repayment) => repayment.paymentAccountId)
|
|
32
|
+
.filter((id) => id !== undefined && id !== null)));
|
|
33
|
+
let fundingAccountsForMap = [];
|
|
34
|
+
if (repaymentHistoryFundingAccountIdsForMap.length > 0 &&
|
|
37
35
|
depositAccountsView.fetchState === 'Completed' &&
|
|
38
36
|
paymentAccountsView.fetchState === 'Completed') {
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const matchingPaymentAccounts = paymentAccountsView.paymentAccounts.filter((paymentAccount) => repaymentHistoryFundingAccountIds.includes(paymentAccount.paymentAccountId));
|
|
43
|
-
// Convert to FundingAccount[] format
|
|
44
|
-
repaymentHistoryFundingAccounts = (0, setupViewSelector_1.getAllFundingAccounts)(matchingDepositAccounts, matchingPaymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus, false);
|
|
37
|
+
const matchingDepositAccountsForMap = depositAccountsView.depositAccounts.filter((depositAccount) => repaymentHistoryFundingAccountIdsForMap.includes(depositAccount.id));
|
|
38
|
+
const matchingPaymentAccountsForMap = paymentAccountsView.paymentAccounts.filter((paymentAccount) => repaymentHistoryFundingAccountIdsForMap.includes(paymentAccount.paymentAccountId));
|
|
39
|
+
fundingAccountsForMap = (0, setupViewSelector_1.getAllFundingAccounts)(matchingDepositAccountsForMap, matchingPaymentAccountsForMap, paymentAccountListState.paymentAccountBalanceFetchStatus, false);
|
|
45
40
|
}
|
|
41
|
+
const accountInfoByAccountId = {};
|
|
42
|
+
fundingAccountsForMap.forEach((fa) => {
|
|
43
|
+
if (fa.id != null) {
|
|
44
|
+
accountInfoByAccountId[fa.id] = {
|
|
45
|
+
accountId: fa.id,
|
|
46
|
+
accountLogo: fa.logo,
|
|
47
|
+
accountType: fa.accType === 'depositAccount' ? 'depositAccount' : 'paymentAccount',
|
|
48
|
+
depositAccountLast4: fa.accountLast4,
|
|
49
|
+
depositAccountName: fa.label,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
repaymentHistoryWithUsers = (0, chargeCardPaymentHistoryHelpers_1.applyPaymentHistoryFiltersSearchAndSort)(repaymentHistoryWithUsers, filters, searchText, uiState, accountInfoByAccountId);
|
|
46
54
|
const reducedFetchState = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
47
55
|
{ fetchState, error },
|
|
48
56
|
depositAccountsView,
|
|
@@ -50,13 +58,13 @@ const getChargeCardPaymentHistoryView = (state, accountInfoMap) => {
|
|
|
50
58
|
...Object.values(paymentAccountListState.paymentAccountBalanceFetchStatus),
|
|
51
59
|
]);
|
|
52
60
|
return {
|
|
61
|
+
accountInfoByAccountId,
|
|
53
62
|
creditAccountId,
|
|
54
63
|
currencyCode,
|
|
55
64
|
currencySymbol,
|
|
56
65
|
filters,
|
|
57
66
|
isAutoPayEnabled,
|
|
58
67
|
repaymentHistory: repaymentHistoryWithUsers,
|
|
59
|
-
repaymentHistoryFundingAccounts,
|
|
60
68
|
repaymentHistoryIds,
|
|
61
69
|
repaymentHistoryUsers,
|
|
62
70
|
searchText,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.24-
|
|
3
|
+
"version": "4.19.24-betaRR14",
|
|
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
|
"types": "lib/index.d.ts",
|