@zeniai/client-epic-state 4.19.8-betaRR2 → 4.19.8-betaRR4
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/chargeCardRepayment/chargeCardRepayment.d.ts +3 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepayment.js +4 -1
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.d.ts +1 -0
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.js +1 -0
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.d.ts +4 -1
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +18 -8
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ export interface ChargeCardRepayment {
|
|
|
16
16
|
providerPaymentId: ID;
|
|
17
17
|
providerRepaymentId: ID;
|
|
18
18
|
repaymentDate: ZeniDate;
|
|
19
|
+
repaymentType: ChargeCardRepaymentType;
|
|
19
20
|
status: ChargeCardRepaymentStatusCodeType;
|
|
20
21
|
statusDescription: string;
|
|
21
22
|
updateTime: ZeniDate;
|
|
@@ -30,3 +31,5 @@ export interface ChargeCardRepaymentState {
|
|
|
30
31
|
}
|
|
31
32
|
export declare const toChargeCardRepaymentStatusCodeType: (v: string) => "PendingReview" | "Pending" | "Sent" | "Clear" | "Rejected" | "Returned";
|
|
32
33
|
export type ChargeCardRepaymentStatusCodeType = ReturnType<typeof toChargeCardRepaymentStatusCodeType>;
|
|
34
|
+
export declare const toChargeCardRepaymentType: (v: string) => "scheduled" | "onDemand";
|
|
35
|
+
export type ChargeCardRepaymentType = ReturnType<typeof toChargeCardRepaymentType>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toChargeCardRepaymentStatusCodeType = void 0;
|
|
3
|
+
exports.toChargeCardRepaymentType = exports.toChargeCardRepaymentStatusCodeType = void 0;
|
|
4
4
|
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
5
5
|
const ALL_CHARGE_CARD_REPAYMENT_STATUS_CODE = [
|
|
6
6
|
'PendingReview',
|
|
@@ -12,3 +12,6 @@ const ALL_CHARGE_CARD_REPAYMENT_STATUS_CODE = [
|
|
|
12
12
|
];
|
|
13
13
|
const toChargeCardRepaymentStatusCodeType = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_CHARGE_CARD_REPAYMENT_STATUS_CODE);
|
|
14
14
|
exports.toChargeCardRepaymentStatusCodeType = toChargeCardRepaymentStatusCodeType;
|
|
15
|
+
const ALL_CHARGE_CARD_REPAYMENT_TYPE = ['scheduled', 'onDemand'];
|
|
16
|
+
const toChargeCardRepaymentType = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_CHARGE_CARD_REPAYMENT_TYPE);
|
|
17
|
+
exports.toChargeCardRepaymentType = toChargeCardRepaymentType;
|
|
@@ -27,6 +27,7 @@ const mapChargeCardRepaymentPayloadToChargeCardRepayment = (payload) => {
|
|
|
27
27
|
statusDescription: payload.status_description,
|
|
28
28
|
updateTime: (0, zeniDayJS_1.date)(payload.update_time),
|
|
29
29
|
zeniCreditAccountId: payload.zeni_credit_account_id,
|
|
30
|
+
repaymentType: (0, chargeCardRepayment_1.toChargeCardRepaymentType)(payload.repayment_type),
|
|
30
31
|
providerCounterpartyAccountId: (_c = payload.provider_counterparty_account_id) !== null && _c !== void 0 ? _c : undefined,
|
|
31
32
|
thirdPartyTransactionId: (_d = payload.third_party_transaction_id) !== null && _d !== void 0 ? _d : undefined,
|
|
32
33
|
});
|
|
@@ -4,13 +4,16 @@ import { ChargeCardRepayment } from '../../../../entity/chargeCardRepayment/char
|
|
|
4
4
|
import { User } from '../../../../entity/user/userState';
|
|
5
5
|
import { RootState } from '../../../../reducer';
|
|
6
6
|
import { PaymentHistoryFilters, PaymentHistoryUIState } from './chargeCardPaymentHistory';
|
|
7
|
+
export interface ChargeCardRepaymentWithUser extends ChargeCardRepayment {
|
|
8
|
+
paidByUser?: User;
|
|
9
|
+
}
|
|
7
10
|
export interface ChargeCardPaymentHistorySelectorView extends SelectorView {
|
|
8
11
|
creditAccountId: ID;
|
|
9
12
|
currencyCode: string;
|
|
10
13
|
currencySymbol: string;
|
|
11
14
|
filters: PaymentHistoryFilters;
|
|
12
15
|
isAutoPayEnabled: boolean;
|
|
13
|
-
repaymentHistory:
|
|
16
|
+
repaymentHistory: ChargeCardRepaymentWithUser[];
|
|
14
17
|
repaymentHistoryIds: ID[];
|
|
15
18
|
repaymentHistoryUsers: User[];
|
|
16
19
|
searchText: string;
|
|
@@ -35,35 +35,45 @@ const getChargeCardPaymentHistoryView = (state, accountInfoMap) => {
|
|
|
35
35
|
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState } = state;
|
|
36
36
|
const { creditAccountId, currencyCode, currencySymbol, filters, isAutoPayEnabled, repaymentHistoryIds, repaymentHistoryUserIds, searchText, totalRepayments, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
|
|
37
37
|
// Get the full repayment details from the entity state
|
|
38
|
-
|
|
38
|
+
const repaymentHistory = (0, chargeCardRepaymentSelector_1.getChargeCardRepaymentByIds)(chargeCardRepaymentState, repaymentHistoryIds);
|
|
39
|
+
// Get users first to enrich repayments
|
|
40
|
+
const repaymentHistoryUsers = (0, userSelector_1.getUsersByUserIds)(userState, repaymentHistoryUserIds);
|
|
41
|
+
// Create a map of userId -> User for quick lookup
|
|
42
|
+
const userMap = new Map();
|
|
43
|
+
repaymentHistoryUsers.forEach((user) => {
|
|
44
|
+
userMap.set(user.userId, user);
|
|
45
|
+
});
|
|
46
|
+
// Enrich repayments with paidByUser details
|
|
47
|
+
let repaymentHistoryWithUsers = repaymentHistory.map((repayment) => (Object.assign(Object.assign({}, repayment), { paidByUser: userMap.get(repayment.paidById) })));
|
|
39
48
|
// Apply filters
|
|
40
|
-
|
|
49
|
+
repaymentHistoryWithUsers = (0, spendManagementFilterHelpers_1.applyAdvancedFiltersOnList)('charge_card_payment_history', repaymentHistoryWithUsers, filters);
|
|
41
50
|
// Apply search text filtering
|
|
42
51
|
const loweredSearchText = searchText.trim().toLowerCase();
|
|
43
52
|
if (loweredSearchText.length > 0) {
|
|
44
|
-
|
|
53
|
+
repaymentHistoryWithUsers = repaymentHistoryWithUsers.filter((repayment) => {
|
|
45
54
|
var _a, _b;
|
|
46
55
|
const amountString = repayment.amount.amount.toString();
|
|
47
56
|
const statusString = repayment.status.toLowerCase();
|
|
48
|
-
const initiatedByString = repayment.
|
|
57
|
+
const initiatedByString = repayment.repaymentType === 'scheduled'
|
|
58
|
+
? 'autopay'
|
|
59
|
+
: (0, userSelector_1.getUserName)(repayment.paidByUser);
|
|
49
60
|
const accountInfo = accountInfoMap === null || accountInfoMap === void 0 ? void 0 : accountInfoMap.get(repayment.providerDepositAccountId);
|
|
50
61
|
const accountNameString = (_b = (_a = accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.depositAccountName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
51
62
|
return (amountString.includes(loweredSearchText) ||
|
|
52
63
|
statusString.includes(loweredSearchText) ||
|
|
53
|
-
initiatedByString.includes(loweredSearchText) ||
|
|
64
|
+
initiatedByString.toLowerCase().includes(loweredSearchText) ||
|
|
54
65
|
accountNameString.includes(loweredSearchText));
|
|
55
66
|
});
|
|
56
67
|
}
|
|
57
68
|
// Apply sorting
|
|
58
|
-
|
|
59
|
-
const repaymentHistoryUsers = (0, userSelector_1.getUsersByUserIds)(userState, repaymentHistoryUserIds);
|
|
69
|
+
repaymentHistoryWithUsers = sortPaymentHistory(repaymentHistoryWithUsers, uiState.sortKey, uiState.sortOrder, accountInfoMap);
|
|
60
70
|
return {
|
|
61
71
|
creditAccountId,
|
|
62
72
|
currencyCode,
|
|
63
73
|
currencySymbol,
|
|
64
74
|
filters,
|
|
65
75
|
isAutoPayEnabled,
|
|
66
|
-
repaymentHistory,
|
|
76
|
+
repaymentHistory: repaymentHistoryWithUsers,
|
|
67
77
|
repaymentHistoryIds,
|
|
68
78
|
repaymentHistoryUsers,
|
|
69
79
|
searchText,
|
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-betaRR4",
|
|
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",
|