@zeniai/client-epic-state 4.19.8-betaRR4 → 4.19.8-betaRR5
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.
|
@@ -3,6 +3,7 @@ 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 { FundingAccount } from '../../commonSetup/setupViewSelector';
|
|
6
7
|
import { PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
7
8
|
export interface ChargeCardRepaymentWithUser extends ChargeCardRepayment {
|
|
8
9
|
paidByUser?: User;
|
|
@@ -14,6 +15,7 @@ export interface ChargeCardPaymentHistorySelectorView extends SelectorView {
|
|
|
14
15
|
filters: PaymentHistoryFilters;
|
|
15
16
|
isAutoPayEnabled: boolean;
|
|
16
17
|
repaymentHistory: ChargeCardRepaymentWithUser[];
|
|
18
|
+
repaymentHistoryFundingAccounts: FundingAccount[];
|
|
17
19
|
repaymentHistoryIds: ID[];
|
|
18
20
|
repaymentHistoryUsers: User[];
|
|
19
21
|
searchText: string;
|
|
@@ -5,9 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getChargeCardPaymentHistoryView = void 0;
|
|
7
7
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
8
|
+
const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
|
|
8
9
|
const chargeCardRepaymentSelector_1 = require("../../../../entity/chargeCardRepayment/chargeCardRepaymentSelector");
|
|
9
10
|
const userSelector_1 = require("../../../../entity/user/userSelector");
|
|
11
|
+
const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
|
|
10
12
|
const spendManagementFilterHelpers_1 = require("../../spendManagementFilterHelpers");
|
|
13
|
+
const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
|
|
14
|
+
const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
|
|
11
15
|
const getPaymentHistorySortValue = (repayment, sortKey, accountInfoMap) => {
|
|
12
16
|
var _a;
|
|
13
17
|
switch (sortKey) {
|
|
@@ -32,7 +36,7 @@ const sortPaymentHistory = (repayments, sortKey, sortOrder, accountInfoMap) => {
|
|
|
32
36
|
return (0, orderBy_1.default)(repayments, (repayment) => getPaymentHistorySortValue(repayment, sortKey, accountInfoMap), [order]);
|
|
33
37
|
};
|
|
34
38
|
const getChargeCardPaymentHistoryView = (state, accountInfoMap) => {
|
|
35
|
-
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState } = state;
|
|
39
|
+
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState, depositAccountState, paymentAccountState, depositAccountListState, paymentAccountListState, } = state;
|
|
36
40
|
const { creditAccountId, currencyCode, currencySymbol, filters, isAutoPayEnabled, repaymentHistoryIds, repaymentHistoryUserIds, searchText, totalRepayments, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
|
|
37
41
|
// Get the full repayment details from the entity state
|
|
38
42
|
const repaymentHistory = (0, chargeCardRepaymentSelector_1.getChargeCardRepaymentByIds)(chargeCardRepaymentState, repaymentHistoryIds);
|
|
@@ -67,6 +71,31 @@ const getChargeCardPaymentHistoryView = (state, accountInfoMap) => {
|
|
|
67
71
|
}
|
|
68
72
|
// Apply sorting
|
|
69
73
|
repaymentHistoryWithUsers = sortPaymentHistory(repaymentHistoryWithUsers, uiState.sortKey, uiState.sortOrder, accountInfoMap);
|
|
74
|
+
// Extract unique funding account IDs from repayment history
|
|
75
|
+
const repaymentHistoryFundingAccountIds = Array.from(new Set(repaymentHistoryWithUsers
|
|
76
|
+
.map((repayment) => repayment.providerDepositAccountId)
|
|
77
|
+
.filter((id) => id !== undefined && id !== null)));
|
|
78
|
+
// Get deposit and payment accounts views for fetch state reduction
|
|
79
|
+
const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
|
|
80
|
+
const paymentAccountsView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
|
|
81
|
+
// Get funding accounts linked to payments
|
|
82
|
+
let repaymentHistoryFundingAccounts = [];
|
|
83
|
+
if (repaymentHistoryFundingAccountIds.length > 0 &&
|
|
84
|
+
depositAccountsView.fetchState === 'Completed' &&
|
|
85
|
+
paymentAccountsView.fetchState === 'Completed') {
|
|
86
|
+
// Filter deposit accounts that match providerDepositAccountIds (by id)
|
|
87
|
+
const matchingDepositAccounts = depositAccountsView.depositAccounts.filter((depositAccount) => repaymentHistoryFundingAccountIds.includes(depositAccount.id));
|
|
88
|
+
// Filter payment accounts that match providerDepositAccountIds (by providerAccountId)
|
|
89
|
+
const matchingPaymentAccounts = paymentAccountsView.paymentAccounts.filter((paymentAccount) => repaymentHistoryFundingAccountIds.includes(paymentAccount.providerAccountId));
|
|
90
|
+
// Convert to FundingAccount[] format
|
|
91
|
+
repaymentHistoryFundingAccounts = (0, setupViewSelector_1.getAllFundingAccounts)(matchingDepositAccounts, matchingPaymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus, false);
|
|
92
|
+
}
|
|
93
|
+
const reducedFetchState = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
94
|
+
{ fetchState, error },
|
|
95
|
+
depositAccountsView,
|
|
96
|
+
paymentAccountsView,
|
|
97
|
+
...Object.values(paymentAccountListState.paymentAccountBalanceFetchStatus),
|
|
98
|
+
]);
|
|
70
99
|
return {
|
|
71
100
|
creditAccountId,
|
|
72
101
|
currencyCode,
|
|
@@ -74,13 +103,14 @@ const getChargeCardPaymentHistoryView = (state, accountInfoMap) => {
|
|
|
74
103
|
filters,
|
|
75
104
|
isAutoPayEnabled,
|
|
76
105
|
repaymentHistory: repaymentHistoryWithUsers,
|
|
106
|
+
repaymentHistoryFundingAccounts,
|
|
77
107
|
repaymentHistoryIds,
|
|
78
108
|
repaymentHistoryUsers,
|
|
79
109
|
searchText,
|
|
80
110
|
totalRepayments,
|
|
81
111
|
uiState,
|
|
82
|
-
fetchState,
|
|
83
|
-
error,
|
|
112
|
+
fetchState: reducedFetchState.fetchState,
|
|
113
|
+
error: reducedFetchState.error,
|
|
84
114
|
version: 0,
|
|
85
115
|
};
|
|
86
116
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.8-
|
|
3
|
+
"version": "4.19.8-betaRR5",
|
|
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",
|