@zeniai/client-epic-state 4.19.39-betaRR0 → 4.19.39
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 +1 -6
- package/lib/entity/chargeCardRepayment/chargeCardRepayment.js +1 -4
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.d.ts +3 -8
- package/lib/entity/chargeCardRepayment/chargeCardRepaymentPayload.js +2 -5
- package/lib/epic.d.ts +1 -3
- package/lib/epic.js +1 -3
- package/lib/esm/entity/chargeCardRepayment/chargeCardRepayment.js +0 -2
- package/lib/esm/entity/chargeCardRepayment/chargeCardRepaymentPayload.js +3 -6
- package/lib/esm/epic.js +1 -3
- package/lib/esm/index.js +1 -6
- package/lib/esm/reducer.js +0 -3
- package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +6 -12
- package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +0 -5
- package/lib/esm/view/spendManagement/chargeCards/chargeCardSetUp/epic/fetchChargeCardSetupViewEpic.js +1 -1
- package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +0 -15
- package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +2 -29
- package/lib/esm/view/spendManagement/zeniAccounts/depositAccountList/fetchDepositAccountListEpic.js +3 -5
- package/lib/index.d.ts +1 -7
- package/lib/index.js +8 -25
- package/lib/reducer.d.ts +0 -3
- package/lib/reducer.js +0 -3
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailSelector.js +4 -10
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/fetchChargeCardRepaymentDetailEpic.js +2 -2
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.d.ts +1 -2
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/initiateChargeCardRepaymentEpic.js +0 -5
- package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/fetchChargeCardSetupViewEpic.js +1 -1
- package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +1 -2
- package/lib/view/spendManagement/commonSetup/setupViewSelector.js +1 -17
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +4 -6
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +2 -29
- package/lib/view/spendManagement/zeniAccounts/depositAccountList/fetchDepositAccountListEpic.js +3 -5
- package/package.json +1 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.js +0 -32
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +0 -22
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.js +0 -76
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryPayload.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +0 -83
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +0 -104
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentHistoryEpic.js +0 -31
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +0 -31
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +0 -50
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.js +0 -35
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.d.ts +0 -8
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryDownloadSelector.js +0 -26
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.d.ts +0 -7
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryHelpers.js +0 -84
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryPayload.d.ts +0 -13
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryPayload.js +0 -2
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +0 -19
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +0 -87
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.d.ts +0 -24
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector.js +0 -108
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentHistoryEpic.d.ts +0 -9
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentHistoryEpic.js +0 -35
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.d.ts +0 -7
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +0 -35
|
@@ -11,17 +11,11 @@ const getChargeCardRepaymentDetail = (state) => {
|
|
|
11
11
|
const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
|
|
12
12
|
const paymentAccountsView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
|
|
13
13
|
let transferFromAccounts = [];
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
const depositFundingFromLimit = Object.values(depositAccountState.depositAccountLimitForChargeCardByID ?? {}).map(setupViewSelector_1.mapDepositAccountWithLimitToFundingAccount);
|
|
20
|
-
const paymentFundingAccounts = (0, setupViewSelector_1.getAllFundingAccounts)([], paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
|
|
21
|
-
transferFromAccounts = [...depositFundingFromLimit, ...paymentFundingAccounts];
|
|
22
|
-
}
|
|
14
|
+
if (depositAccountsView.fetchState === 'Completed' &&
|
|
15
|
+
paymentAccountsView.fetchState === 'Completed') {
|
|
16
|
+
transferFromAccounts = (0, setupViewSelector_1.getAllFundingAccounts)(depositAccountsView.depositAccounts, paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
|
|
23
17
|
}
|
|
24
|
-
const reducedFetchState = (0, reduceFetchState_1.
|
|
18
|
+
const reducedFetchState = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
25
19
|
depositAccountsView,
|
|
26
20
|
paymentAccountsView,
|
|
27
21
|
...Object.values(paymentAccountListState.paymentAccountBalanceFetchStatus),
|
|
@@ -10,8 +10,8 @@ const fetchChargeCardRepaymentDetailEpic = (actions$, state$) => actions$.pipe((
|
|
|
10
10
|
const fetchChargeCardRepaymentDetailActions = [];
|
|
11
11
|
const state = state$.value;
|
|
12
12
|
const depositAccounts = state.depositAccountListState;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (depositAccounts.fetchState !== 'In-Progress' &&
|
|
14
|
+
depositAccounts.fetchState !== 'Completed') {
|
|
15
15
|
fetchChargeCardRepaymentDetailActions.push((0, depositAccountListReducer_1.fetchDepositAccountList)());
|
|
16
16
|
}
|
|
17
17
|
const paymentAccounts = state.paymentAccountListState;
|
|
@@ -4,8 +4,7 @@ import { updateChargeCardRepayment } from '../../../../entity/chargeCardRepaymen
|
|
|
4
4
|
import { updateCompanyPrimaryAccount, updateEnableAutoPayForChargeCard } from '../../../../entity/company/companyReducer';
|
|
5
5
|
import { RootState } from '../../../../reducer';
|
|
6
6
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
7
|
-
import { addRepaymentToChargeCardPaymentHistory } from '../chargeCardPaymentHistory/chargeCardPaymentHistoryReducer';
|
|
8
7
|
import { updateCreditAccountRepaymentAmountAndDate } from '../chargeCardList/chargeCardListReducer';
|
|
9
8
|
import { initiateChargeCardRepayment, updateChargeCardRepaymentStatus } from './chargeCardRepaymentDetailReducer';
|
|
10
|
-
export type ActionType = ReturnType<typeof
|
|
9
|
+
export type ActionType = ReturnType<typeof initiateChargeCardRepayment> | ReturnType<typeof updateChargeCardRepayment> | ReturnType<typeof updateCreditAccountRepaymentAmountAndDate> | ReturnType<typeof updateChargeCardRepaymentStatus> | ReturnType<typeof updateCompanyPrimaryAccount> | ReturnType<typeof updateEnableAutoPayForChargeCard>;
|
|
11
10
|
export declare const initiateChargeCardRepaymentEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -12,7 +12,6 @@ const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
|
|
|
12
12
|
const helpers_1 = require("../../helpers");
|
|
13
13
|
const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
|
|
14
14
|
const paymentAccountListSelector_1 = require("../../zeniAccounts/paymentAccountList/paymentAccountListSelector");
|
|
15
|
-
const chargeCardPaymentHistoryReducer_1 = require("../chargeCardPaymentHistory/chargeCardPaymentHistoryReducer");
|
|
16
15
|
const chargeCardListReducer_1 = require("../chargeCardList/chargeCardListReducer");
|
|
17
16
|
const chargeCardRepaymentDetailReducer_1 = require("./chargeCardRepaymentDetailReducer");
|
|
18
17
|
const initiateChargeCardRepaymentEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(chargeCardRepaymentDetailReducer_1.initiateChargeCardRepayment.match), (0, operators_1.switchMap)((action) => {
|
|
@@ -40,10 +39,6 @@ const initiateChargeCardRepaymentEpic = (actions$, state$, zeniAPI) => actions$.
|
|
|
40
39
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
41
40
|
const actions = [
|
|
42
41
|
(0, chargeCardRepaymentReducer_1.updateChargeCardRepayment)(response.data.card_repayment),
|
|
43
|
-
(0, chargeCardPaymentHistoryReducer_1.addRepaymentToChargeCardPaymentHistory)({
|
|
44
|
-
cardRepaymentId: response.data.card_repayment.card_repayment_id,
|
|
45
|
-
zeniCreditAccountId: response.data.card_repayment.zeni_credit_account_id,
|
|
46
|
-
}),
|
|
47
42
|
(0, chargeCardListReducer_1.updateCreditAccountRepaymentAmountAndDate)({
|
|
48
43
|
amount: (0, amount_1.toAmount)(response.data.card_repayment.amount, response.data.card_repayment.currency_code, response.data.card_repayment.currency_symbol),
|
|
49
44
|
date: (0, zeniDayJS_1.date)(response.data.card_repayment.repayment_date),
|
package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/fetchChargeCardSetupViewEpic.js
CHANGED
|
@@ -51,7 +51,7 @@ const fetchChargeCardSetupViewEpic = (actions$, state$, zeniAPI) => actions$.pip
|
|
|
51
51
|
(0, depositAccountReducer_1.updateDepositAccounts)(response.data.deposit_accounts ?? []),
|
|
52
52
|
(0, depositAccountListReducer_1.updateDepositAccountList)({
|
|
53
53
|
data: response.data?.deposit_accounts ?? [],
|
|
54
|
-
updateType: '
|
|
54
|
+
updateType: 'replace',
|
|
55
55
|
}),
|
|
56
56
|
(0, setupViewReducer_1.updateSetupViewLocalStoreData)({
|
|
57
57
|
companyId: response.data.companies[0].company_id,
|
|
@@ -5,7 +5,7 @@ import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
|
|
|
5
5
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
6
6
|
import { CompanyBillPayInfo } from '../../../entity/company/companyStateTypes';
|
|
7
7
|
import { Country } from '../../../entity/countryList/countryListState';
|
|
8
|
-
import { DepositAccount
|
|
8
|
+
import { DepositAccount } from '../../../entity/depositAccount/depositAccount';
|
|
9
9
|
import { File } from '../../../entity/file/fileState';
|
|
10
10
|
import { InstitutionDetails, Logo, PaymentAccount } from '../../../entity/paymentAccount/paymentAccountState';
|
|
11
11
|
import { RootState } from '../../../reducer';
|
|
@@ -94,6 +94,5 @@ export declare function getBusinessVerificationDetails(state: RootState, company
|
|
|
94
94
|
export declare const getCompanyAndIdentityDetails: (state: RootState, companyId: ID, companyAndIdentityDetails: CompanyAndIdentityDetails) => CompanyAndOfficerLocalData;
|
|
95
95
|
export declare const getAllFundingAccounts: (depositAccounts: DepositAccount[], paymentAccounts: PaymentAccount[], paymentAccountBalanceFetchStatus: Record<ID, FetchStateAndError>, includeOnlyVerifiedAccounts?: boolean) => FundingAccount[];
|
|
96
96
|
export declare const mapDepositAccToFundingAccount: (depositAcc: DepositAccount) => FundingAccount;
|
|
97
|
-
export declare const mapDepositAccountWithLimitToFundingAccount: (depositAcc: DepositAccountWithLimit) => FundingAccount;
|
|
98
97
|
export declare const mapPaymentAccToFundingAccount: (paymentAcc: PaymentAccount, paymentAccountBalanceFetchStatus: Record<ID, FetchStateAndError>) => FundingAccount;
|
|
99
98
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapPaymentAccToFundingAccount = exports.
|
|
3
|
+
exports.mapPaymentAccToFundingAccount = exports.mapDepositAccToFundingAccount = exports.getAllFundingAccounts = exports.getCompanyAndIdentityDetails = void 0;
|
|
4
4
|
exports.getCommonSetupViewDetails = getCommonSetupViewDetails;
|
|
5
5
|
exports.getBusinessVerificationDetails = getBusinessVerificationDetails;
|
|
6
6
|
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
@@ -227,22 +227,6 @@ const mapDepositAccToFundingAccount = (depositAcc) => ({
|
|
|
227
227
|
accountLast4: depositAcc.accountLast4,
|
|
228
228
|
});
|
|
229
229
|
exports.mapDepositAccToFundingAccount = mapDepositAccToFundingAccount;
|
|
230
|
-
const mapDepositAccountWithLimitToFundingAccount = (depositAcc) => ({
|
|
231
|
-
id: depositAcc.id,
|
|
232
|
-
accType: 'depositAccount',
|
|
233
|
-
label: depositAcc.accountName,
|
|
234
|
-
maskedAccountNumber: depositAcc.maskedAccountNumber,
|
|
235
|
-
accountBalance: depositAcc.accountBalance,
|
|
236
|
-
logo: undefined,
|
|
237
|
-
zeniAccountId: depositAcc.zeniAccountId,
|
|
238
|
-
balanceFetchStatus: {
|
|
239
|
-
fetchState: 'Completed',
|
|
240
|
-
error: undefined,
|
|
241
|
-
},
|
|
242
|
-
createTime: depositAcc.createTime,
|
|
243
|
-
accountLast4: depositAcc.maskedAccountNumber.match(/(\d{4})$/)?.[1] ?? undefined,
|
|
244
|
-
});
|
|
245
|
-
exports.mapDepositAccountWithLimitToFundingAccount = mapDepositAccountWithLimitToFundingAccount;
|
|
246
230
|
const mapPaymentAccToFundingAccount = (paymentAcc, paymentAccountBalanceFetchStatus) => ({
|
|
247
231
|
id: paymentAcc.paymentAccountId,
|
|
248
232
|
accType: 'paymentAccount',
|
|
@@ -6,12 +6,10 @@ import { TaskListFilterCategoryField, TaskListFilters } from '../taskManager/tas
|
|
|
6
6
|
import { TaskWithUserDetails } from '../taskManager/taskListView/taskListSelector';
|
|
7
7
|
import { BillTransactionView } from './billPay/billList/billListSelector';
|
|
8
8
|
import { BillListViewFilterCategoryField, BillPayFilters } from './billPay/billList/billListState';
|
|
9
|
-
import { PaymentHistoryFilterCategoryDropdownOption, PaymentHistoryFilters } from './chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory';
|
|
10
|
-
import { ChargeCardRepaymentWithUser } from './chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector';
|
|
11
9
|
import { ReimbursementView } from './reimbursement/remiListView/remiListSelector';
|
|
12
10
|
import { ReimbursementFilters, RemiListViewFilterCategoryField } from './reimbursement/remiListView/remiListState';
|
|
13
|
-
export type SpendManagementFiltersType = BillPayFilters | ReimbursementFilters | TaskListFilters
|
|
14
|
-
export type SpendManagementFilterEntityType = 'bill_pay' | 'reimbursement' | 'task_management'
|
|
11
|
+
export type SpendManagementFiltersType = BillPayFilters | ReimbursementFilters | TaskListFilters;
|
|
12
|
+
export type SpendManagementFilterEntityType = 'bill_pay' | 'reimbursement' | 'task_management';
|
|
15
13
|
export type FilterCategoryType = 'searchAutocomplete' | 'user' | 'dateRange' | 'numberRange' | 'dropdown';
|
|
16
14
|
export interface MatchingOperatorDropdownOption {
|
|
17
15
|
label: 'is' | 'is not';
|
|
@@ -33,9 +31,9 @@ export interface TaskFilterCategoryDropdownOption {
|
|
|
33
31
|
multiple?: boolean;
|
|
34
32
|
type?: FilterCategoryType;
|
|
35
33
|
}
|
|
36
|
-
export type SpendManagementFilterCategoryDropdownOption = BillPayFilterCategoryDropdownOption | ReimbursementFilterCategoryDropdownOption | TaskFilterCategoryDropdownOption
|
|
34
|
+
export type SpendManagementFilterCategoryDropdownOption = BillPayFilterCategoryDropdownOption | ReimbursementFilterCategoryDropdownOption | TaskFilterCategoryDropdownOption;
|
|
37
35
|
export type FilterCategoryValueType = string | number | ZeniDate;
|
|
38
|
-
export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[]
|
|
36
|
+
export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[], filters?: BillPayFilters | ReimbursementFilters | TaskListFilters, filteredItems?: (BillTransactionView | ReimbursementView | TaskWithUserDetails)[], index?: number) => (BillTransactionView | ReimbursementView | TaskWithUserDetails)[];
|
|
39
37
|
export declare const isBillListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
|
|
40
38
|
export declare const isRemiListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
|
|
41
39
|
export declare const hideCreatedByFilter: (userRole: UserRoleType[]) => boolean;
|
|
@@ -72,17 +72,10 @@ const filterItemOnCategoriesWithMultipleValues = (categoryValue, currentFilter)
|
|
|
72
72
|
return true;
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
const getItemId = (item) => {
|
|
76
|
-
if ('cardRepaymentId' in item) {
|
|
77
|
-
return item.cardRepaymentId;
|
|
78
|
-
}
|
|
79
|
-
return item
|
|
80
|
-
.id;
|
|
81
|
-
};
|
|
82
75
|
const removeDuplicatesFromList = (list) => {
|
|
83
76
|
const foundIds = [];
|
|
84
77
|
return list.filter((item) => {
|
|
85
|
-
const itemId =
|
|
78
|
+
const itemId = item.id;
|
|
86
79
|
if (foundIds.indexOf(itemId) === -1) {
|
|
87
80
|
foundIds.push(itemId);
|
|
88
81
|
return true;
|
|
@@ -117,9 +110,7 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
117
110
|
? getCategoryValueForBill(key, item)
|
|
118
111
|
: entity === 'reimbursement'
|
|
119
112
|
? getCategoryValueForReimbursement(key, item)
|
|
120
|
-
:
|
|
121
|
-
? getCategoryValueForTaskList(key, item)
|
|
122
|
-
: getCategoryValueForPaymentHistory(key, item);
|
|
113
|
+
: getCategoryValueForTaskList(key, item);
|
|
123
114
|
if (categoryValue == null) {
|
|
124
115
|
if (currentFilter.matchingOperator === 'not-equal') {
|
|
125
116
|
return true;
|
|
@@ -139,7 +130,6 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
139
130
|
'dueDate',
|
|
140
131
|
'creationDate',
|
|
141
132
|
'receiptDate',
|
|
142
|
-
'repaymentDate',
|
|
143
133
|
]);
|
|
144
134
|
}
|
|
145
135
|
});
|
|
@@ -241,23 +231,6 @@ const getCategoryValueForReimbursement = (key, reimbursement) => {
|
|
|
241
231
|
return undefined;
|
|
242
232
|
}
|
|
243
233
|
};
|
|
244
|
-
const getCategoryValueForPaymentHistory = (key, repayment) => {
|
|
245
|
-
switch (key) {
|
|
246
|
-
case 'repaymentDate':
|
|
247
|
-
return repayment.repaymentDate;
|
|
248
|
-
case 'sourceAccount': {
|
|
249
|
-
return repayment.paymentAccountId;
|
|
250
|
-
}
|
|
251
|
-
case 'status':
|
|
252
|
-
return repayment.status;
|
|
253
|
-
case 'initiatedBy':
|
|
254
|
-
return repayment.repaymentType === 'scheduled'
|
|
255
|
-
? 'autopay'
|
|
256
|
-
: repayment.paidById;
|
|
257
|
-
default:
|
|
258
|
-
return undefined;
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
234
|
const isBillListDownloadable = (state, currentTimePeriod) => {
|
|
262
235
|
const { billListState, billTransactionState, entityApprovalStatusState, userState, } = state;
|
|
263
236
|
const keys = billListState_1.ALL_BILL_TABS.filter((tab) => tab !== 'draft').map((tab) => (0, billListState_1.getBillListKey)(currentTimePeriod, tab));
|
package/lib/view/spendManagement/zeniAccounts/depositAccountList/fetchDepositAccountListEpic.js
CHANGED
|
@@ -11,13 +11,11 @@ const fetchDepositAccountListEpic = (actions$, _state$, zeniAPI) => actions$.pip
|
|
|
11
11
|
return zeniAPI
|
|
12
12
|
.getJSON(`${zeniAPI.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts?query=${encodeURIComponent(`{"is_include_deposit_accounts_summary":true}`)}`)
|
|
13
13
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const depositAccounts = response.data?.deposit_accounts ?? [];
|
|
17
|
-
return (0, rxjs_1.of)((0, depositAccountReducer_1.updateDepositAccounts)(depositAccounts), (0, zeniAccountListReducer_1.updateZeniAccountsSummary)({
|
|
14
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
15
|
+
return (0, rxjs_1.of)((0, depositAccountReducer_1.updateDepositAccounts)(response.data?.deposit_accounts ?? []), (0, zeniAccountListReducer_1.updateZeniAccountsSummary)({
|
|
18
16
|
summaryPayload: response.data?.all_deposit_accounts_summary,
|
|
19
17
|
}), (0, depositAccountListReducer_1.updateDepositAccountList)({
|
|
20
|
-
data:
|
|
18
|
+
data: response.data?.deposit_accounts ?? [],
|
|
21
19
|
updateType: 'replace',
|
|
22
20
|
}));
|
|
23
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.39
|
|
3
|
+
"version": "4.19.39",
|
|
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",
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export const PAYMENT_HISTORY_FILTER_CATEGORIES = [
|
|
2
|
-
{ value: 'repaymentDate', type: 'dateRange', multiple: true },
|
|
3
|
-
{ value: 'sourceAccount', multiple: true, type: 'dropdown' },
|
|
4
|
-
{ value: 'status', multiple: true, type: 'dropdown' },
|
|
5
|
-
{ value: 'initiatedBy', multiple: true, type: 'dropdown' },
|
|
6
|
-
];
|
|
7
|
-
export const initialChargeCardPaymentHistoryState = {
|
|
8
|
-
fetchState: 'Not-Started',
|
|
9
|
-
error: undefined,
|
|
10
|
-
creditAccountId: '',
|
|
11
|
-
currencyCode: 'USD',
|
|
12
|
-
currencySymbol: '$',
|
|
13
|
-
downloadUIState: {
|
|
14
|
-
downloadState: 'Not-Started',
|
|
15
|
-
},
|
|
16
|
-
filters: {
|
|
17
|
-
categories: [],
|
|
18
|
-
categoryCombinationOperator: 'AND',
|
|
19
|
-
},
|
|
20
|
-
isAutoPayEnabled: false,
|
|
21
|
-
repaymentHistoryIds: [],
|
|
22
|
-
searchText: '',
|
|
23
|
-
totalRepayments: 0,
|
|
24
|
-
repaymentHistoryXlsDownloadUrl: '',
|
|
25
|
-
uiState: {
|
|
26
|
-
sortKey: 'paymentDate',
|
|
27
|
-
sortOrder: 'ascending',
|
|
28
|
-
},
|
|
29
|
-
hasValidState() {
|
|
30
|
-
return this.fetchState === 'Completed';
|
|
31
|
-
},
|
|
32
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getChargeCardRepaymentByIds } from '../../../../entity/chargeCardRepayment/chargeCardRepaymentSelector';
|
|
2
|
-
import { getUsersByUserIds } from '../../../../entity/user/userSelector';
|
|
3
|
-
import { applyPaymentHistoryFiltersSearchAndSort } from './chargeCardPaymentHistoryHelpers';
|
|
4
|
-
export const getChargeCardPaymentHistoryDownloadReport = (state) => {
|
|
5
|
-
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState, } = state;
|
|
6
|
-
const { filters, repaymentHistoryIds, searchText, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
|
|
7
|
-
const repaymentHistory = getChargeCardRepaymentByIds(chargeCardRepaymentState, repaymentHistoryIds);
|
|
8
|
-
const repaymentHistoryUserIds = Array.from(new Set(repaymentHistory.map((r) => r.paidById)));
|
|
9
|
-
const repaymentHistoryUsers = getUsersByUserIds(userState, repaymentHistoryUserIds);
|
|
10
|
-
const userMap = new Map(repaymentHistoryUsers.map((user) => [user.userId, user]));
|
|
11
|
-
const repaymentHistoryWithUsers = repaymentHistory.map((repayment) => ({
|
|
12
|
-
...repayment,
|
|
13
|
-
paidByUser: userMap.get(repayment.paidById),
|
|
14
|
-
}));
|
|
15
|
-
const transactions = applyPaymentHistoryFiltersSearchAndSort(repaymentHistoryWithUsers, filters, searchText, uiState);
|
|
16
|
-
return {
|
|
17
|
-
reportTitle: 'Card Payment History',
|
|
18
|
-
fetchState,
|
|
19
|
-
error,
|
|
20
|
-
transactions,
|
|
21
|
-
};
|
|
22
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import orderBy from 'lodash/orderBy';
|
|
2
|
-
import { getUserName } from '../../../../entity/user/userSelector';
|
|
3
|
-
import { applyAdvancedFiltersOnList } from '../../spendManagementFilterHelpers';
|
|
4
|
-
export function getPaymentHistorySourceAccountName(repayment, accountInfoByAccountId) {
|
|
5
|
-
const fromMap = repayment.paymentAccountId != null
|
|
6
|
-
? accountInfoByAccountId?.[repayment.paymentAccountId]?.depositAccountName
|
|
7
|
-
: undefined;
|
|
8
|
-
return fromMap ?? repayment.paymentAccountName ?? '';
|
|
9
|
-
}
|
|
10
|
-
export function getPaymentStatusDisplayText(status) {
|
|
11
|
-
const statusMap = {
|
|
12
|
-
PendingReview: 'In Progress',
|
|
13
|
-
Pending: 'In Progress',
|
|
14
|
-
Sent: 'Complete',
|
|
15
|
-
Clear: 'Complete',
|
|
16
|
-
Rejected: 'Failed',
|
|
17
|
-
Returned: 'Failed',
|
|
18
|
-
};
|
|
19
|
-
return statusMap[status] ?? status;
|
|
20
|
-
}
|
|
21
|
-
function getPaymentHistorySortValue(repayment, sortKey, accountInfoByAccountId) {
|
|
22
|
-
switch (sortKey) {
|
|
23
|
-
case 'paymentDate':
|
|
24
|
-
return repayment.repaymentDate.valueOf();
|
|
25
|
-
case 'amount':
|
|
26
|
-
return repayment.amount.amount;
|
|
27
|
-
case 'paymentStatus':
|
|
28
|
-
return getPaymentStatusDisplayText(repayment.status);
|
|
29
|
-
case 'initiatedBy':
|
|
30
|
-
return repayment.repaymentType === 'scheduled'
|
|
31
|
-
? 'autopay'
|
|
32
|
-
: getUserName(repayment.paidByUser);
|
|
33
|
-
case 'sourceAccount':
|
|
34
|
-
return getPaymentHistorySourceAccountName(repayment, accountInfoByAccountId);
|
|
35
|
-
default:
|
|
36
|
-
return '';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function sortPaymentHistory(repayments, sortKey, sortOrder, accountInfoByAccountId) {
|
|
40
|
-
const getColumnWiseSortOrder = (sortOrder) => {
|
|
41
|
-
switch (sortKey) {
|
|
42
|
-
case 'sourceAccount':
|
|
43
|
-
case 'paymentStatus':
|
|
44
|
-
case 'initiatedBy':
|
|
45
|
-
return sortOrder === 'ascending' ? 'asc' : 'desc';
|
|
46
|
-
default:
|
|
47
|
-
return sortOrder === 'ascending' ? 'desc' : 'asc';
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const order = getColumnWiseSortOrder(sortOrder);
|
|
51
|
-
return orderBy(repayments, (repayment) => getPaymentHistorySortValue(repayment, sortKey, accountInfoByAccountId), [order]);
|
|
52
|
-
}
|
|
53
|
-
function filterPaymentHistoryBySearchText(repayments, searchText, accountInfoByAccountId) {
|
|
54
|
-
const loweredSearchText = searchText.trim().toLowerCase();
|
|
55
|
-
if (loweredSearchText.length === 0) {
|
|
56
|
-
return repayments;
|
|
57
|
-
}
|
|
58
|
-
return repayments.filter((repayment) => {
|
|
59
|
-
const amountString = repayment.amount.amount.toString();
|
|
60
|
-
const statusString = getPaymentStatusDisplayText(repayment.status).toLowerCase();
|
|
61
|
-
const initiatedByString = repayment.repaymentType === 'scheduled'
|
|
62
|
-
? 'autopay'
|
|
63
|
-
: getUserName(repayment.paidByUser);
|
|
64
|
-
const accountNameString = getPaymentHistorySourceAccountName(repayment, accountInfoByAccountId).toLowerCase();
|
|
65
|
-
return (amountString.includes(loweredSearchText) ||
|
|
66
|
-
statusString.includes(loweredSearchText) ||
|
|
67
|
-
initiatedByString.toLowerCase().includes(loweredSearchText) ||
|
|
68
|
-
accountNameString.includes(loweredSearchText));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
export function applyPaymentHistoryFiltersSearchAndSort(repayments, filters, searchText, uiState, accountInfoByAccountId) {
|
|
72
|
-
let result = applyAdvancedFiltersOnList('charge_card_payment_history', repayments, filters);
|
|
73
|
-
result = filterPaymentHistoryBySearchText(result, searchText, accountInfoByAccountId);
|
|
74
|
-
result = sortPaymentHistory(result, uiState.sortKey, uiState.sortOrder, accountInfoByAccountId);
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { initialChargeCardPaymentHistoryState, } from './chargeCardPaymentHistory';
|
|
3
|
-
export const initialState = initialChargeCardPaymentHistoryState;
|
|
4
|
-
const chargeCardPaymentHistory = createSlice({
|
|
5
|
-
name: 'chargeCardPaymentHistory',
|
|
6
|
-
initialState,
|
|
7
|
-
reducers: {
|
|
8
|
-
fetchChargeCardPaymentPage: {
|
|
9
|
-
reducer() {
|
|
10
|
-
// do nothing
|
|
11
|
-
},
|
|
12
|
-
prepare(cacheOverride = false) {
|
|
13
|
-
return {
|
|
14
|
-
payload: {
|
|
15
|
-
cacheOverride,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
fetchChargeCardPaymentHistory(draft) {
|
|
21
|
-
draft.fetchState = 'In-Progress';
|
|
22
|
-
draft.error = undefined;
|
|
23
|
-
},
|
|
24
|
-
updateChargeCardPaymentHistory(draft, action) {
|
|
25
|
-
const payload = action.payload;
|
|
26
|
-
draft.creditAccountId = payload.credit_account_id;
|
|
27
|
-
draft.currencyCode = payload.currency_code;
|
|
28
|
-
draft.currencySymbol = payload.currency_symbol;
|
|
29
|
-
draft.isAutoPayEnabled = payload.is_auto_pay_enabled;
|
|
30
|
-
draft.repaymentHistoryIds = payload.repayment_history.map((repayment) => repayment.card_repayment_id);
|
|
31
|
-
draft.totalRepayments = payload.total_repayments;
|
|
32
|
-
draft.fetchState = 'Completed';
|
|
33
|
-
draft.error = undefined;
|
|
34
|
-
},
|
|
35
|
-
updateChargeCardPaymentHistoryFailure(draft, action) {
|
|
36
|
-
draft.fetchState = 'Error';
|
|
37
|
-
draft.error = action.payload;
|
|
38
|
-
},
|
|
39
|
-
addRepaymentToChargeCardPaymentHistory(draft, action) {
|
|
40
|
-
const { cardRepaymentId, zeniCreditAccountId } = action.payload;
|
|
41
|
-
if (draft.creditAccountId !== zeniCreditAccountId) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (draft.repaymentHistoryIds.includes(cardRepaymentId)) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
draft.repaymentHistoryIds.unshift(cardRepaymentId);
|
|
48
|
-
draft.totalRepayments += 1;
|
|
49
|
-
},
|
|
50
|
-
clearChargeCardPaymentHistory(draft) {
|
|
51
|
-
Object.assign(draft, initialState);
|
|
52
|
-
},
|
|
53
|
-
updatePaymentHistoryFilters(draft, action) {
|
|
54
|
-
if (action.payload.filters != null) {
|
|
55
|
-
draft.filters = action.payload.filters;
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
updatePaymentHistorySearchText(draft, action) {
|
|
59
|
-
if (action.payload != null) {
|
|
60
|
-
draft.searchText = action.payload;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
updatePaymentHistoryUIState(draft, action) {
|
|
64
|
-
if (action.payload.uiState.sortKey != null) {
|
|
65
|
-
draft.uiState.sortKey = action.payload.uiState.sortKey;
|
|
66
|
-
}
|
|
67
|
-
if (action.payload.uiState.sortOrder != null) {
|
|
68
|
-
draft.uiState.sortOrder = action.payload.uiState.sortOrder;
|
|
69
|
-
}
|
|
70
|
-
if (action.payload.uiState.scrollYOffset != null) {
|
|
71
|
-
draft.uiState.scrollYOffset = action.payload.uiState.scrollYOffset;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
updatePaymentHistoryDownloadUIState(draft, action) {
|
|
75
|
-
if (action.payload.uiState.downloadState != null) {
|
|
76
|
-
draft.downloadUIState.downloadState =
|
|
77
|
-
action.payload.uiState.downloadState;
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
export const { addRepaymentToChargeCardPaymentHistory, fetchChargeCardPaymentPage, fetchChargeCardPaymentHistory, updateChargeCardPaymentHistory, updateChargeCardPaymentHistoryFailure, clearChargeCardPaymentHistory, updatePaymentHistoryFilters, updatePaymentHistorySearchText, updatePaymentHistoryDownloadUIState, updatePaymentHistoryUIState, } = chargeCardPaymentHistory.actions;
|
|
83
|
-
export default chargeCardPaymentHistory.reducer;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { reduceAllFetchState } from '../../../../commonStateTypes/reduceFetchState';
|
|
2
|
-
import { getChargeCardRepaymentByIds } from '../../../../entity/chargeCardRepayment/chargeCardRepaymentSelector';
|
|
3
|
-
import { getUsersByUserIds } from '../../../../entity/user/userSelector';
|
|
4
|
-
import { getAllFundingAccounts, mapDepositAccToFundingAccount, mapPaymentAccToFundingAccount, } from '../../commonSetup/setupViewSelector';
|
|
5
|
-
import { getDepositAccountByDepositAccountId } from '../../../../entity/depositAccount/depositAccountSelector';
|
|
6
|
-
import { getPaymentAccountByPaymentAccountId } from '../../../../entity/paymentAccount/paymentAccountSelector';
|
|
7
|
-
import { getAllDepositAccounts } from '../../zeniAccounts/depositAccountList/depositAccountListSelector';
|
|
8
|
-
import { getAllPaymentAccounts } from '../../zeniAccounts/paymentAccountList/paymentAccountListSelector';
|
|
9
|
-
import { applyPaymentHistoryFiltersSearchAndSort } from './chargeCardPaymentHistoryHelpers';
|
|
10
|
-
export const getChargeCardPaymentHistoryView = (state) => {
|
|
11
|
-
const { chargeCardPaymentHistoryState, chargeCardRepaymentState, userState, depositAccountState, paymentAccountState, depositAccountListState, paymentAccountListState, } = state;
|
|
12
|
-
const { creditAccountId, currencyCode, currencySymbol, filters, isAutoPayEnabled, repaymentHistoryIds, searchText, totalRepayments, uiState, fetchState, error, } = chargeCardPaymentHistoryState;
|
|
13
|
-
// Get the full repayment details from the entity state
|
|
14
|
-
const repaymentHistory = getChargeCardRepaymentByIds(chargeCardRepaymentState, repaymentHistoryIds);
|
|
15
|
-
const repaymentHistoryUserIds = Array.from(new Set(repaymentHistory.map((r) => r.paidById)));
|
|
16
|
-
// Get users first to enrich repayments
|
|
17
|
-
const repaymentHistoryUsers = getUsersByUserIds(userState, repaymentHistoryUserIds);
|
|
18
|
-
// Create a map of userId -> User for quick lookup
|
|
19
|
-
const userMap = new Map();
|
|
20
|
-
repaymentHistoryUsers.forEach((user) => {
|
|
21
|
-
userMap.set(user.userId, user);
|
|
22
|
-
});
|
|
23
|
-
// Enrich repayments with paidByUser details
|
|
24
|
-
let repaymentHistoryWithUsers = repaymentHistory.map((repayment) => ({
|
|
25
|
-
...repayment,
|
|
26
|
-
paidByUser: userMap.get(repayment.paidById),
|
|
27
|
-
}));
|
|
28
|
-
// Get deposit and payment accounts views (used for funding accounts and fetch state)
|
|
29
|
-
const depositAccountsView = getAllDepositAccounts(depositAccountState, depositAccountListState);
|
|
30
|
-
const paymentAccountsView = getAllPaymentAccounts(paymentAccountState, paymentAccountListState);
|
|
31
|
-
// Extract unique funding account IDs from unfiltered repayment history (for accountInfoMap used in filter/sort)
|
|
32
|
-
const repaymentHistoryFundingAccountIdsForMap = Array.from(new Set(repaymentHistory
|
|
33
|
-
.map((repayment) => repayment.paymentAccountId)
|
|
34
|
-
.filter((id) => id !== undefined && id !== null)));
|
|
35
|
-
let fundingAccountsForMap = [];
|
|
36
|
-
if (repaymentHistoryFundingAccountIdsForMap.length > 0) {
|
|
37
|
-
const hasDepositData = depositAccountsView.fetchState === 'Completed';
|
|
38
|
-
const hasPaymentData = paymentAccountsView.fetchState === 'Completed';
|
|
39
|
-
if (hasDepositData || hasPaymentData) {
|
|
40
|
-
const matchingDepositAccountsForMap = hasDepositData
|
|
41
|
-
? depositAccountsView.depositAccounts.filter((depositAccount) => repaymentHistoryFundingAccountIdsForMap.includes(depositAccount.id))
|
|
42
|
-
: [];
|
|
43
|
-
const matchingPaymentAccountsForMap = hasPaymentData
|
|
44
|
-
? paymentAccountsView.paymentAccounts.filter((paymentAccount) => repaymentHistoryFundingAccountIdsForMap.includes(paymentAccount.paymentAccountId))
|
|
45
|
-
: [];
|
|
46
|
-
fundingAccountsForMap = getAllFundingAccounts(matchingDepositAccountsForMap, matchingPaymentAccountsForMap, paymentAccountListState.paymentAccountBalanceFetchStatus, false);
|
|
47
|
-
// Fallback: look up repayment-referenced accounts directly from entity stores
|
|
48
|
-
// in case they're not in the list state (e.g. race condition, stale list)
|
|
49
|
-
const existingIds = new Set(fundingAccountsForMap.map((fa) => fa.id).filter(Boolean));
|
|
50
|
-
for (const accountId of repaymentHistoryFundingAccountIdsForMap) {
|
|
51
|
-
if (existingIds.has(accountId)) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
const depositAccount = getDepositAccountByDepositAccountId(depositAccountState, accountId);
|
|
55
|
-
if (depositAccount != null) {
|
|
56
|
-
fundingAccountsForMap.push(mapDepositAccToFundingAccount(depositAccount));
|
|
57
|
-
existingIds.add(accountId);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const paymentAccount = getPaymentAccountByPaymentAccountId(paymentAccountState, accountId);
|
|
61
|
-
if (paymentAccount != null) {
|
|
62
|
-
fundingAccountsForMap.push(mapPaymentAccToFundingAccount(paymentAccount, paymentAccountListState.paymentAccountBalanceFetchStatus));
|
|
63
|
-
existingIds.add(accountId);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const accountInfoByAccountId = {};
|
|
69
|
-
fundingAccountsForMap.forEach((fa) => {
|
|
70
|
-
if (fa.id != null) {
|
|
71
|
-
accountInfoByAccountId[fa.id] = {
|
|
72
|
-
accountId: fa.id,
|
|
73
|
-
accountLogo: fa.logo,
|
|
74
|
-
accountType: fa.accType === 'depositAccount' ? 'depositAccount' : 'paymentAccount',
|
|
75
|
-
depositAccountLast4: fa.accountLast4,
|
|
76
|
-
depositAccountName: fa.label,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
repaymentHistoryWithUsers = applyPaymentHistoryFiltersSearchAndSort(repaymentHistoryWithUsers, filters, searchText, uiState, accountInfoByAccountId);
|
|
81
|
-
const reducedFetchState = reduceAllFetchState([
|
|
82
|
-
{ fetchState, error },
|
|
83
|
-
depositAccountsView,
|
|
84
|
-
paymentAccountsView,
|
|
85
|
-
...Object.values(paymentAccountListState.paymentAccountBalanceFetchStatus),
|
|
86
|
-
]);
|
|
87
|
-
return {
|
|
88
|
-
accountInfoByAccountId,
|
|
89
|
-
creditAccountId,
|
|
90
|
-
currencyCode,
|
|
91
|
-
currencySymbol,
|
|
92
|
-
filters,
|
|
93
|
-
isAutoPayEnabled,
|
|
94
|
-
repaymentHistory: repaymentHistoryWithUsers,
|
|
95
|
-
repaymentHistoryIds,
|
|
96
|
-
repaymentHistoryUsers,
|
|
97
|
-
searchText,
|
|
98
|
-
totalRepayments,
|
|
99
|
-
uiState,
|
|
100
|
-
fetchState: reducedFetchState.fetchState,
|
|
101
|
-
error: reducedFetchState.error,
|
|
102
|
-
version: 0,
|
|
103
|
-
};
|
|
104
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { updateChargeCardRepayments } from '../../../../entity/chargeCardRepayment/chargeCardRepaymentReducer';
|
|
4
|
-
import { updateAllUsers } from '../../../../entity/user/userReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessStatus, } from '../../../../responsePayload';
|
|
6
|
-
import { fetchChargeCardPaymentHistory, updateChargeCardPaymentHistory, updateChargeCardPaymentHistoryFailure, } from './chargeCardPaymentHistoryReducer';
|
|
7
|
-
export const fetchChargeCardPaymentHistoryEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchChargeCardPaymentHistory.match), switchMap(() => {
|
|
8
|
-
const queryParams = { include_history: true };
|
|
9
|
-
const queryString = encodeURIComponent(JSON.stringify(queryParams));
|
|
10
|
-
return zeniAPI
|
|
11
|
-
.getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments?query=${queryString}`)
|
|
12
|
-
.pipe(mergeMap((response) => {
|
|
13
|
-
if (isSuccessStatus(response) && response.data != null) {
|
|
14
|
-
return of(
|
|
15
|
-
// Store repayments FIRST before marking as completed
|
|
16
|
-
updateChargeCardRepayments(response.data.repayment_history), updateAllUsers({
|
|
17
|
-
users: response.data.repayment_history
|
|
18
|
-
.map((repayment) => repayment.paid_by_user)
|
|
19
|
-
.filter((user) => user != null),
|
|
20
|
-
}),
|
|
21
|
-
// Mark as completed LAST, after all data is stored
|
|
22
|
-
updateChargeCardPaymentHistory(response.data));
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return of(updateChargeCardPaymentHistoryFailure(response.status));
|
|
26
|
-
}
|
|
27
|
-
}), catchError((error) => {
|
|
28
|
-
return of(updateChargeCardPaymentHistoryFailure(createZeniAPIStatus('Unexpected Error', 'Fetch charge card payment history REST API call errored out' +
|
|
29
|
-
JSON.stringify(error))));
|
|
30
|
-
}));
|
|
31
|
-
}));
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { concat, from } from 'rxjs';
|
|
2
|
-
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { fetchChargeCardRepaymentDetail } from '../chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer';
|
|
4
|
-
import { fetchChargeCardPaymentHistory, fetchChargeCardPaymentPage, } from './chargeCardPaymentHistoryReducer';
|
|
5
|
-
export const fetchChargeCardPaymentPageEpic = (actions$, state$) => actions$.pipe(filter(fetchChargeCardPaymentPage.match), mergeMap((action) => {
|
|
6
|
-
const { cacheOverride } = action.payload;
|
|
7
|
-
const chargeCardPaymentPageActions = [];
|
|
8
|
-
const state = state$.value;
|
|
9
|
-
const chargeCardPaymentHistoryState = state.chargeCardPaymentHistoryState;
|
|
10
|
-
if (cacheOverride === true) {
|
|
11
|
-
chargeCardPaymentPageActions.push(fetchChargeCardPaymentHistory());
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
if (chargeCardPaymentHistoryState.fetchState !== 'Completed' &&
|
|
15
|
-
chargeCardPaymentHistoryState.fetchState !== 'In-Progress') {
|
|
16
|
-
chargeCardPaymentPageActions.push(fetchChargeCardPaymentHistory());
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
// Fetch repayment detail if deposit or payment accounts are not fetched
|
|
20
|
-
//These are needed to get the transfer from accounts for the repayment history
|
|
21
|
-
const depositAccountListState = state.depositAccountListState;
|
|
22
|
-
const paymentAccountListState = state.paymentAccountListState;
|
|
23
|
-
const needsRepaymentDetailFetch = (depositAccountListState.fetchState !== 'Completed' &&
|
|
24
|
-
depositAccountListState.fetchState !== 'In-Progress') ||
|
|
25
|
-
(paymentAccountListState.fetchState !== 'Completed' &&
|
|
26
|
-
paymentAccountListState.fetchState !== 'In-Progress');
|
|
27
|
-
if (needsRepaymentDetailFetch) {
|
|
28
|
-
chargeCardPaymentPageActions.push(fetchChargeCardRepaymentDetail());
|
|
29
|
-
}
|
|
30
|
-
return concat(from(chargeCardPaymentPageActions));
|
|
31
|
-
}));
|