@zeniai/client-epic-state 5.0.84-betaAK3 → 5.0.84-betaAS1
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/commonStateTypes/amount.d.ts +0 -1
- package/lib/commonStateTypes/amount.js +1 -3
- package/lib/commonStateTypes/workingDayHelper.d.ts +0 -9
- package/lib/commonStateTypes/workingDayHelper.js +1 -28
- package/lib/entity/tenant/clearAllEpic.d.ts +1 -3
- package/lib/entity/tenant/clearAllEpic.js +0 -4
- package/lib/epic.d.ts +1 -5
- package/lib/epic.js +1 -5
- package/lib/esm/commonStateTypes/amount.js +0 -1
- package/lib/esm/commonStateTypes/workingDayHelper.js +0 -26
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -4
- package/lib/esm/epic.js +1 -5
- package/lib/esm/index.js +3 -8
- package/lib/esm/reducer.js +0 -6
- package/lib/esm/view/spendManagement/autotransferRules/autoTransferRulesSelector.js +2 -22
- package/lib/index.d.ts +6 -15
- package/lib/index.js +17 -37
- package/lib/reducer.d.ts +0 -6
- package/lib/reducer.js +0 -6
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesSelector.d.ts +1 -8
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesSelector.js +1 -21
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesState.d.ts +0 -22
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +16 -0
- package/lib/zeniAPI.d.ts +0 -1
- package/package.json +1 -1
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +0 -31
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.js +0 -69
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +0 -29
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.js +0 -47
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.js +0 -34
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js +0 -32
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +0 -41
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +0 -44
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +0 -193
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +0 -5
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +0 -27
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +0 -42
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.d.ts +0 -48
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +0 -36
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.d.ts +0 -21
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.js +0 -73
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.d.ts +0 -40
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +0 -33
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.d.ts +0 -37
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.js +0 -53
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.d.ts +0 -14
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.js +0 -38
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.d.ts +0 -7
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js +0 -36
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.d.ts +0 -32
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +0 -46
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.d.ts +0 -15
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +0 -48
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.d.ts +0 -35
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +0 -198
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.d.ts +0 -75
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +0 -8
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.d.ts +0 -7
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +0 -31
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.d.ts +0 -10
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +0 -46
package/lib/reducer.js
CHANGED
|
@@ -197,8 +197,6 @@ const internationalWireVerificationReducer_1 = __importStar(require("./view/spen
|
|
|
197
197
|
const magicLinkViewReducer_1 = __importStar(require("./view/spendManagement/billPay/magicLinkView/magicLinkViewReducer"));
|
|
198
198
|
const previousBillsReducer_1 = __importStar(require("./view/spendManagement/billPay/previousBills/previousBillsReducer"));
|
|
199
199
|
const wiseRedirectReducer_1 = __importStar(require("./view/spendManagement/billPay/wiseRedirectView/wiseRedirectReducer"));
|
|
200
|
-
const autoSweepFlowReducer_1 = __importStar(require("./view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer"));
|
|
201
|
-
const cashManagementOverviewReducer_1 = __importStar(require("./view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer"));
|
|
202
200
|
const cardUserOnboardingReducer_1 = __importStar(require("./view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingReducer"));
|
|
203
201
|
const cashbackDetailReducer_1 = __importStar(require("./view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer"));
|
|
204
202
|
const chargeCardConfigReducer_1 = __importStar(require("./view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer"));
|
|
@@ -350,7 +348,6 @@ const initialViewsState = {
|
|
|
350
348
|
arAgingState: arAgingReducer_1.initialState,
|
|
351
349
|
auditReportViewState: auditReportViewReducer_1.initialState,
|
|
352
350
|
authenticationViewState: authenticationViewReducer_1.initialState,
|
|
353
|
-
autoSweepFlowState: autoSweepFlowReducer_1.initialState,
|
|
354
351
|
autotransferRulesState: autoTransferRulesReducer_1.initialState,
|
|
355
352
|
balanceSheetState: balanceSheetReducer_1.initialState,
|
|
356
353
|
bankAccountViewState: bankAccountViewReducer_1.initialState,
|
|
@@ -369,7 +366,6 @@ const initialViewsState = {
|
|
|
369
366
|
cashBalanceState: cashBalanceReducer_1.initialState,
|
|
370
367
|
cashFlowState: cashFlowReducer_1.initialState,
|
|
371
368
|
cashInCashOutState: cashInCashOutReducer_1.initialState,
|
|
372
|
-
cashManagementOverviewState: cashManagementOverviewReducer_1.initialState,
|
|
373
369
|
cashPositionState: cashPositionReducer_1.initialState,
|
|
374
370
|
chargeCardConfigState: chargeCardConfigReducer_1.initialState,
|
|
375
371
|
chargeCardDetailState: chargeCardDetailReducer_1.initialState,
|
|
@@ -589,7 +585,6 @@ const viewReducers = {
|
|
|
589
585
|
arAgingState: arAgingReducer_1.default,
|
|
590
586
|
auditReportViewState: auditReportViewReducer_1.default,
|
|
591
587
|
authenticationViewState: authenticationViewReducer_1.default,
|
|
592
|
-
autoSweepFlowState: autoSweepFlowReducer_1.default,
|
|
593
588
|
autotransferRulesState: autoTransferRulesReducer_1.default,
|
|
594
589
|
balanceSheetState: balanceSheetReducer_1.default,
|
|
595
590
|
bankAccountViewState: bankAccountViewReducer_1.default,
|
|
@@ -607,7 +602,6 @@ const viewReducers = {
|
|
|
607
602
|
cashBalanceState: cashBalanceReducer_1.default,
|
|
608
603
|
cashFlowState: cashFlowReducer_1.default,
|
|
609
604
|
cashInCashOutState: cashInCashOutReducer_1.default,
|
|
610
|
-
cashManagementOverviewState: cashManagementOverviewReducer_1.default,
|
|
611
605
|
cashPositionState: cashPositionReducer_1.default,
|
|
612
606
|
chargeCardConfigState: chargeCardConfigReducer_1.default,
|
|
613
607
|
chargeCardDetailState: chargeCardDetailReducer_1.default,
|
|
@@ -6,7 +6,7 @@ import { FundingAccount } from '../commonSetup/setupViewSelector';
|
|
|
6
6
|
import { TreasuryAccount } from '../treasury/treasuryTransferMoney/treasuryTransferMoneyState';
|
|
7
7
|
import { ReviewTransferDetail } from '../zeniAccounts/transferDetail/transferDetailState';
|
|
8
8
|
import { AutoTransferRuleLocalData } from './autoTransferRulesPayload';
|
|
9
|
-
import { AutoTransferRule
|
|
9
|
+
import { AutoTransferRule } from './autoTransferRulesState';
|
|
10
10
|
export interface AutoTransferRulesSelectorView extends SelectorView {
|
|
11
11
|
autoTransferReviewDetail: ReviewTransferDetail;
|
|
12
12
|
createRuleFetchState: FetchStateAndError;
|
|
@@ -17,13 +17,6 @@ export interface AutoTransferRulesSelectorView extends SelectorView {
|
|
|
17
17
|
transferMoneyParties: FundingAccount[];
|
|
18
18
|
transferMoneyPartiesFetchState: FetchState;
|
|
19
19
|
treasuryAccount: TreasuryAccount;
|
|
20
|
-
/**
|
|
21
|
-
* The user's saved auto-sweep cash-management config, surfaced here so the
|
|
22
|
-
* rules list page can render it alongside the auto-transfer rules.
|
|
23
|
-
* `undefined` when the user hasn't saved auto-sweep settings yet
|
|
24
|
-
* (i.e. `autoSweepFlowState.settingsId == null`).
|
|
25
|
-
*/
|
|
26
|
-
cashManagementRule?: CashManagementRule;
|
|
27
20
|
ruleHistory?: Record<string, CommonHistoryView>;
|
|
28
21
|
}
|
|
29
22
|
export declare const getAutoTransferRules: (state: RootState) => AutoTransferRulesSelectorView;
|
|
@@ -6,30 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getAutoTransferRuleHistory = exports.getAutoTransferRuleById = exports.getAutoTransferRules = void 0;
|
|
7
7
|
const get_1 = __importDefault(require("lodash/get"));
|
|
8
8
|
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
9
|
-
const depositAccountSelector_1 = require("../../../entity/depositAccount/depositAccountSelector");
|
|
10
9
|
const setupViewSelector_1 = require("../commonSetup/setupViewSelector");
|
|
11
10
|
const depositAccountListSelector_1 = require("../zeniAccounts/depositAccountList/depositAccountListSelector");
|
|
12
11
|
const paymentAccountListSelector_1 = require("../zeniAccounts/paymentAccountList/paymentAccountListSelector");
|
|
13
|
-
const buildCashManagementRule = (autoSweepFlowState, depositAccountState, treasuryDetailState) => {
|
|
14
|
-
const { settingsId, bufferAmount, frequency, memo, primaryFundingAccountId, nextTransferDate } = autoSweepFlowState;
|
|
15
|
-
if (settingsId == null || primaryFundingAccountId == null) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
const depositAccount = (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, primaryFundingAccountId);
|
|
19
|
-
return {
|
|
20
|
-
bufferAmount,
|
|
21
|
-
frequency,
|
|
22
|
-
memo,
|
|
23
|
-
settingsId,
|
|
24
|
-
primaryFundingAccount: depositAccount != null
|
|
25
|
-
? (0, setupViewSelector_1.mapDepositAccToFundingAccount)(depositAccount)
|
|
26
|
-
: undefined,
|
|
27
|
-
treasurySummary: treasuryDetailState.accountSummary,
|
|
28
|
-
nextTransferDate,
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
12
|
const getAutoTransferRules = (state) => {
|
|
32
|
-
const { autotransferRulesState,
|
|
13
|
+
const { autotransferRulesState, depositAccountState, paymentAccountState, depositAccountListState, paymentAccountListState, treasuryDetailState, } = state;
|
|
33
14
|
const { rules, error, historyByRuleId, ruleUpdateLocalData, ruleUpdateStatusById, ruleDeleteStatusById, createRuleFetchState, autoTransferReviewDetail, } = autotransferRulesState;
|
|
34
15
|
const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
|
|
35
16
|
const paymentAccountsView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
|
|
@@ -64,7 +45,6 @@ const getAutoTransferRules = (state) => {
|
|
|
64
45
|
transferMoneyParties,
|
|
65
46
|
transferMoneyPartiesFetchState,
|
|
66
47
|
createRuleFetchState,
|
|
67
|
-
cashManagementRule: buildCashManagementRule(autoSweepFlowState, depositAccountState, treasuryDetailState),
|
|
68
48
|
fetchState,
|
|
69
49
|
error,
|
|
70
50
|
version: 0,
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
1
|
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
2
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
4
|
-
import { AutoSweepFrequency } from '../cashManagement/autoSweepFlow/autoSweepFlowState';
|
|
5
|
-
import { FundingAccount } from '../commonSetup/setupViewSelector';
|
|
6
3
|
import { CommonHistoryView } from '../commonHistoryView/commonHistory';
|
|
7
|
-
import { TreasurySummaryWithBalance } from '../treasury/treasuryList/treasuryDetailState';
|
|
8
4
|
import { ReviewTransferDetail } from '../zeniAccounts/transferDetail/transferDetailState';
|
|
9
5
|
import { AutoTransferRuleFrequency, AutoTransferRuleLocalData, AutoTransferRuleType } from './autoTransferRulesPayload';
|
|
10
6
|
export interface AutoTransferRule {
|
|
@@ -31,24 +27,6 @@ export interface DestinationBankAccountMetadata {
|
|
|
31
27
|
accountType: string;
|
|
32
28
|
percentage: number;
|
|
33
29
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Render-ready view of the user's auto-sweep cash-management config,
|
|
36
|
-
* surfaced alongside `AutoTransferRule[]` in `AutoTransferRulesSelectorView`.
|
|
37
|
-
* Kept as a distinct shape (not folded into `AutoTransferRule`) so the rules
|
|
38
|
-
* list can special-case its rendering without polluting the rule type union.
|
|
39
|
-
*
|
|
40
|
-
* Present only when `autoSweepFlowState.settingsId` is set — i.e. the user
|
|
41
|
-
* has saved their auto-sweep settings at least once.
|
|
42
|
-
*/
|
|
43
|
-
export interface CashManagementRule {
|
|
44
|
-
bufferAmount: Amount;
|
|
45
|
-
frequency: AutoSweepFrequency;
|
|
46
|
-
memo: string;
|
|
47
|
-
settingsId: ID;
|
|
48
|
-
nextTransferDate?: ZeniDate;
|
|
49
|
-
primaryFundingAccount?: FundingAccount;
|
|
50
|
-
treasurySummary?: TreasurySummaryWithBalance;
|
|
51
|
-
}
|
|
52
30
|
export interface AutoTransferRulesState extends FetchedState {
|
|
53
31
|
autoTransferReviewDetail: ReviewTransferDetail;
|
|
54
32
|
createRuleFetchState: FetchStateAndError;
|
|
@@ -10,6 +10,17 @@ export interface FieldValueType {
|
|
|
10
10
|
code: string;
|
|
11
11
|
description: string;
|
|
12
12
|
}
|
|
13
|
+
export interface VerificationFormFieldOption {
|
|
14
|
+
label: string;
|
|
15
|
+
}
|
|
16
|
+
export interface VerificationFormSubField {
|
|
17
|
+
fieldValues: FieldValueType[];
|
|
18
|
+
label: string;
|
|
19
|
+
placeholder: string;
|
|
20
|
+
type: string;
|
|
21
|
+
isMultipleOptionsSupported?: boolean;
|
|
22
|
+
options?: Record<string, VerificationFormFieldOption>;
|
|
23
|
+
}
|
|
13
24
|
export interface VerificationFormField {
|
|
14
25
|
fieldValues: FieldValueType[];
|
|
15
26
|
isMultipleValuesAllowed: boolean;
|
|
@@ -17,4 +28,9 @@ export interface VerificationFormField {
|
|
|
17
28
|
name: string;
|
|
18
29
|
placeholder: string;
|
|
19
30
|
type: string;
|
|
31
|
+
default?: boolean;
|
|
32
|
+
isMultipleOptionsSupported?: boolean;
|
|
33
|
+
options?: Record<string, VerificationFormFieldOption>;
|
|
34
|
+
requirements?: string[];
|
|
35
|
+
subfields?: Record<string, VerificationFormSubField>;
|
|
20
36
|
}
|
package/lib/zeniAPI.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export interface RESTAPIEndpoints {
|
|
|
10
10
|
readonly authMicroServiceBaseUrl: string;
|
|
11
11
|
readonly bankingMicroServiceBaseUrl: string;
|
|
12
12
|
readonly cardMicroServiceBaseUrl: string;
|
|
13
|
-
readonly cashManagementAgentBaseUrl: string;
|
|
14
13
|
readonly communicationAgentMicroServiceBaseUrl: string;
|
|
15
14
|
readonly documentAIMicroServiceBaseUrl: string;
|
|
16
15
|
readonly fileMicroServiceBaseUrl: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.84-
|
|
3
|
+
"version": "5.0.84-betaAS1",
|
|
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,31 +0,0 @@
|
|
|
1
|
-
import { toAmount } from '../../../../commonStateTypes/amount';
|
|
2
|
-
import { getNextTransferDate } from '../../../../commonStateTypes/workingDayHelper';
|
|
3
|
-
import { date } from '../../../../zeniDayJS';
|
|
4
|
-
import { toAutoSweepFrequency, } from './autoSweepFlowState';
|
|
5
|
-
export const toSaveAutoSweepSettingsBody = (state) => ({
|
|
6
|
-
first_run_date: getNextTransferDate(state.frequency).format('YYYY-MM-DD'),
|
|
7
|
-
frequency: state.frequency,
|
|
8
|
-
memo: state.memo,
|
|
9
|
-
minimum_buffer_usd: state.bufferAmount.amount,
|
|
10
|
-
});
|
|
11
|
-
/**
|
|
12
|
-
* Map a `GET /cash-management/settings` payload into the slice's writable
|
|
13
|
-
* fields. Defensive on the frequency (string-from-the-wire → union via
|
|
14
|
-
* `toAutoSweepFrequency`, falling back to `'weekly'` if the server returns
|
|
15
|
-
* something we don't model yet). Only the source account *id* is stored
|
|
16
|
-
* here — the full deposit-account payload is published to the entity bucket
|
|
17
|
-
* by the fetch epic.
|
|
18
|
-
*/
|
|
19
|
-
export const toAutoSweepFlowStatePatch = (payload) => {
|
|
20
|
-
const currencyCode = payload.source_bank_account.balances?.currency_code;
|
|
21
|
-
const currencySymbol = payload.source_bank_account.balances?.currency_symbol;
|
|
22
|
-
return {
|
|
23
|
-
bufferAmount: toAmount(payload.minimum_buffer_usd, currencyCode ?? 'USD', currencySymbol ?? '$'),
|
|
24
|
-
frequency: toAutoSweepFrequency(payload.frequency) ?? 'weekly',
|
|
25
|
-
nextTransferDate: payload.next_transfer_date != null && payload.next_transfer_date !== ''
|
|
26
|
-
? date(payload.next_transfer_date)
|
|
27
|
-
: undefined,
|
|
28
|
-
primaryFundingAccountId: payload.source_bank_account.deposit_account_id ?? undefined,
|
|
29
|
-
settingsId: payload.cash_management_settings_id ?? undefined,
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { toAutoSweepFlowStatePatch, } from './autoSweepFlowPayload';
|
|
3
|
-
import { initialAutoSweepFlowState, } from './autoSweepFlowState';
|
|
4
|
-
export const initialState = initialAutoSweepFlowState;
|
|
5
|
-
const autoSweepFlow = createSlice({
|
|
6
|
-
name: 'autoSweepFlow',
|
|
7
|
-
initialState,
|
|
8
|
-
reducers: {
|
|
9
|
-
/**
|
|
10
|
-
* Kicks off `GET /cash-management/settings`. Flips the top-level
|
|
11
|
-
* fetchState to `In-Progress`; the fetch epic picks this up.
|
|
12
|
-
*/
|
|
13
|
-
fetchCashManagementSettings(draft) {
|
|
14
|
-
draft.fetchState = 'In-Progress';
|
|
15
|
-
draft.error = undefined;
|
|
16
|
-
},
|
|
17
|
-
/**
|
|
18
|
-
* Hydrates the form fields with the server-side settings (and stashes
|
|
19
|
-
* the settings id for subsequent saves). Marks the GET as `Completed`.
|
|
20
|
-
*/
|
|
21
|
-
updateCashManagementSettings(draft, action) {
|
|
22
|
-
const patch = toAutoSweepFlowStatePatch(action.payload.data);
|
|
23
|
-
draft.bufferAmount = patch.bufferAmount;
|
|
24
|
-
draft.frequency = patch.frequency;
|
|
25
|
-
draft.nextTransferDate = patch.nextTransferDate;
|
|
26
|
-
draft.primaryFundingAccountId = patch.primaryFundingAccountId;
|
|
27
|
-
draft.settingsId = patch.settingsId;
|
|
28
|
-
draft.fetchState = 'Completed';
|
|
29
|
-
draft.error = undefined;
|
|
30
|
-
},
|
|
31
|
-
updateCashManagementSettingsFetchStatus(draft, action) {
|
|
32
|
-
draft.fetchState = action.payload.fetchState;
|
|
33
|
-
draft.error = action.payload.error;
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* Stage the in-flight form values without submitting them — fired from
|
|
37
|
-
* the setup→review transition so other selectors (and devtools) can see
|
|
38
|
-
* what the user is about to confirm. Leaves `saveStatus` untouched; the
|
|
39
|
-
* actual PUT only kicks off when the user clicks "Confirm Sweep" via
|
|
40
|
-
* `saveAutoSweepSettings`.
|
|
41
|
-
*/
|
|
42
|
-
updateAutoSweepDraft(draft, action) {
|
|
43
|
-
draft.bufferAmount = action.payload.bufferAmount;
|
|
44
|
-
draft.frequency = action.payload.frequency;
|
|
45
|
-
draft.memo = action.payload.memo;
|
|
46
|
-
},
|
|
47
|
-
/**
|
|
48
|
-
* Trigger the PUT for the auto-sweep settings already staged via
|
|
49
|
-
* `updateAutoSweepDraft`. Carries no payload — flips `saveStatus` to
|
|
50
|
-
* `In-Progress` and the save epic reads `bufferAmount` / `frequency` /
|
|
51
|
-
* `memo` straight from the slice. Callers must ensure those fields
|
|
52
|
-
* reflect the user's latest input before dispatching.
|
|
53
|
-
*/
|
|
54
|
-
saveAutoSweepSettings(draft) {
|
|
55
|
-
draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
|
|
56
|
-
},
|
|
57
|
-
updateAutoSweepSettingsFetchStatus(draft, action) {
|
|
58
|
-
draft.saveStatus = {
|
|
59
|
-
fetchState: action.payload.fetchState,
|
|
60
|
-
error: action.payload.error,
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
clearAutoSweepFlow() {
|
|
64
|
-
return initialAutoSweepFlowState;
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
export const { fetchCashManagementSettings, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, updateAutoSweepDraft, saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, clearAutoSweepFlow, } = autoSweepFlow.actions;
|
|
69
|
-
export default autoSweepFlow.reducer;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { getDepositAccountByDepositAccountId } from '../../../../entity/depositAccount/depositAccountSelector';
|
|
2
|
-
import { mapDepositAccToFundingAccount, } from '../../commonSetup/setupViewSelector';
|
|
3
|
-
import { getTreasuryDetail } from '../../treasury/treasuryList/treasuryDetailSelector';
|
|
4
|
-
import { getCashManagementOverviewBanner } from '../cashManagementOverview/cashManagementOverviewSelector';
|
|
5
|
-
import { bufferAmountToRisk, } from './autoSweepFlowState';
|
|
6
|
-
export const getAutoSweepFlow = (state) => {
|
|
7
|
-
const { bufferAmount, frequency, memo, saveStatus, settingsId, primaryFundingAccountId, fetchState, error, } = state.autoSweepFlowState;
|
|
8
|
-
const depositAccount = primaryFundingAccountId != null
|
|
9
|
-
? getDepositAccountByDepositAccountId(state.depositAccountState, primaryFundingAccountId)
|
|
10
|
-
: undefined;
|
|
11
|
-
return {
|
|
12
|
-
fetchState,
|
|
13
|
-
error,
|
|
14
|
-
formData: {
|
|
15
|
-
bufferAmount,
|
|
16
|
-
frequency,
|
|
17
|
-
memo,
|
|
18
|
-
risk: bufferAmountToRisk(bufferAmount.amount),
|
|
19
|
-
},
|
|
20
|
-
primaryFundingAccount: depositAccount != null
|
|
21
|
-
? mapDepositAccToFundingAccount(depositAccount)
|
|
22
|
-
: undefined,
|
|
23
|
-
saveStatus,
|
|
24
|
-
settingsId,
|
|
25
|
-
sweepAmount: getCashManagementOverviewBanner(state).amount,
|
|
26
|
-
treasurySummary: getTreasuryDetail(state).accountSummary,
|
|
27
|
-
version: 0,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { toAmount } from '../../../../commonStateTypes/amount';
|
|
2
|
-
import { stringToUnion } from '../../../../commonStateTypes/stringToUnion';
|
|
3
|
-
/**
|
|
4
|
-
* Cadence at which the auto-sweep transfer fires. Lowercase to match the
|
|
5
|
-
* cash-management settings API contract (and the `SweepFrequency` literal
|
|
6
|
-
* already used by `<AutoSweepSetupPage>` in web-components).
|
|
7
|
-
*/
|
|
8
|
-
export const ALL_AUTO_SWEEP_FREQUENCIES = [
|
|
9
|
-
'daily',
|
|
10
|
-
'weekly',
|
|
11
|
-
'biweekly',
|
|
12
|
-
'monthly',
|
|
13
|
-
];
|
|
14
|
-
export const toAutoSweepFrequency = (v) => stringToUnion(v ?? '', ALL_AUTO_SWEEP_FREQUENCIES);
|
|
15
|
-
/**
|
|
16
|
-
* Risk presets the auto-sweep setup form exposes. Each level maps to a
|
|
17
|
-
* canonical minimum-buffer amount (USD). Selecting a level in the UI is
|
|
18
|
-
* shorthand for choosing that buffer.
|
|
19
|
-
*/
|
|
20
|
-
export const ALL_AUTO_SWEEP_RISK_LEVELS = ['low', 'moderate', 'high'];
|
|
21
|
-
export const toAutoSweepRiskLevel = (v) => stringToUnion(v ?? '', ALL_AUTO_SWEEP_RISK_LEVELS);
|
|
22
|
-
export const RISK_BUFFER_AMOUNT = {
|
|
23
|
-
low: 15000,
|
|
24
|
-
moderate: 10000,
|
|
25
|
-
high: 5000,
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Maps a buffer amount back onto the closest preset risk level. Falls back
|
|
29
|
-
* to `'moderate'` when the amount doesn't match a known preset (e.g. the
|
|
30
|
-
* server returned a custom value). The dropdown in `<AutoSweepSetupPage>`
|
|
31
|
-
* uses this so it can pre-select the user's existing band on edit.
|
|
32
|
-
*/
|
|
33
|
-
export const bufferAmountToRisk = (amount) => {
|
|
34
|
-
const match = Object.entries(RISK_BUFFER_AMOUNT).find(([, presetAmount]) => presetAmount === amount);
|
|
35
|
-
return match != null ? match[0] : 'moderate';
|
|
36
|
-
};
|
|
37
|
-
export const initialAutoSweepFlowState = {
|
|
38
|
-
bufferAmount: toAmount(10000, 'USD', '$'),
|
|
39
|
-
frequency: 'weekly',
|
|
40
|
-
memo: '',
|
|
41
|
-
saveStatus: { fetchState: 'Not-Started', error: undefined },
|
|
42
|
-
nextTransferDate: undefined,
|
|
43
|
-
primaryFundingAccountId: undefined,
|
|
44
|
-
settingsId: undefined,
|
|
45
|
-
fetchState: 'Not-Started',
|
|
46
|
-
error: undefined,
|
|
47
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { updateDepositAccounts } from '../../../../../entity/depositAccount/depositAccountReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
5
|
-
import { fetchCashManagementSettings, updateCashManagementSettings, updateCashManagementSettingsFetchStatus, } from '../autoSweepFlowReducer';
|
|
6
|
-
/**
|
|
7
|
-
* Hits `GET /cash-management/settings` and hydrates the auto-sweep slice
|
|
8
|
-
* with the server's existing settings (frequency, minimum buffer, settings
|
|
9
|
-
* id). Called from the cash management overview page-fetch epic alongside
|
|
10
|
-
* the other top-level fetches.
|
|
11
|
-
*/
|
|
12
|
-
export const fetchCashManagementSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchCashManagementSettings.match), switchMap(() => {
|
|
13
|
-
const endpoint = `${zeniAPI.apiEndPoints.cashManagementAgentBaseUrl}/1.0/cash-management/settings`;
|
|
14
|
-
return zeniAPI
|
|
15
|
-
.getJSON(endpoint)
|
|
16
|
-
.pipe(mergeMap((response) => {
|
|
17
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
18
|
-
return of(
|
|
19
|
-
// Publish the source deposit account into the shared entity
|
|
20
|
-
// bucket so the selector can hydrate the full `FundingAccount`
|
|
21
|
-
// from `getDepositAccountByDepositAccountId` rather than the
|
|
22
|
-
// auto-sweep slice holding a duplicate copy.
|
|
23
|
-
updateDepositAccounts([response.data.source_bank_account]), updateCashManagementSettings({ data: response.data }));
|
|
24
|
-
}
|
|
25
|
-
return of(updateCashManagementSettingsFetchStatus({
|
|
26
|
-
fetchState: 'Error',
|
|
27
|
-
error: response.status,
|
|
28
|
-
}));
|
|
29
|
-
}), catchError((error) => of(updateCashManagementSettingsFetchStatus({
|
|
30
|
-
fetchState: 'Error',
|
|
31
|
-
error: createZeniAPIStatus('Unexpected Error', 'Fetch cash management settings REST API call errored out: ' +
|
|
32
|
-
(error?.message ?? String(error))),
|
|
33
|
-
}))));
|
|
34
|
-
}));
|
package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
4
|
-
import { toSaveAutoSweepSettingsBody, } from '../autoSweepFlowPayload';
|
|
5
|
-
import { saveAutoSweepSettings, updateAutoSweepSettingsFetchStatus, } from '../autoSweepFlowReducer';
|
|
6
|
-
export const saveAutoSweepSettingsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveAutoSweepSettings.match), switchMap(() => {
|
|
7
|
-
const endpoint = `${zeniAPI.apiEndPoints.cashManagementAgentBaseUrl}/1.0/cash-management/settings`;
|
|
8
|
-
const { bufferAmount, frequency, memo, settingsId } = state$.value.autoSweepFlowState;
|
|
9
|
-
const payload = toSaveAutoSweepSettingsBody({
|
|
10
|
-
bufferAmount,
|
|
11
|
-
frequency,
|
|
12
|
-
memo,
|
|
13
|
-
});
|
|
14
|
-
// First-time setup (no settings id from the GET yet) → POST a new
|
|
15
|
-
// record. Subsequent edits update the existing one via PUT.
|
|
16
|
-
const request$ = settingsId == null
|
|
17
|
-
? zeniAPI.postAndGetJSON(endpoint, payload)
|
|
18
|
-
: zeniAPI.putAndGetJSON(endpoint, payload);
|
|
19
|
-
return request$.pipe(mergeMap((response) => {
|
|
20
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
21
|
-
return of(updateAutoSweepSettingsFetchStatus({ fetchState: 'Completed' }));
|
|
22
|
-
}
|
|
23
|
-
return of(updateAutoSweepSettingsFetchStatus({
|
|
24
|
-
fetchState: 'Error',
|
|
25
|
-
error: response?.status,
|
|
26
|
-
}));
|
|
27
|
-
}), catchError((error) => of(updateAutoSweepSettingsFetchStatus({
|
|
28
|
-
fetchState: 'Error',
|
|
29
|
-
error: createZeniAPIStatus('Unexpected Error', 'Save auto-sweep settings REST API call errored out: ' +
|
|
30
|
-
(error?.message ?? String(error))),
|
|
31
|
-
}))));
|
|
32
|
-
}));
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { toAmount } from '../../../../commonStateTypes/amount';
|
|
2
|
-
import { date as zeniDate } from '../../../../zeniDayJS';
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// Converters
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// The cash agent payload reports `currency_code` only; the v1 surface is
|
|
7
|
-
// USD-only, so we pair it with the canonical `$` symbol here. If the agent
|
|
8
|
-
// grows multi-currency support, this is the single place to widen.
|
|
9
|
-
const CASH_AGENT_CURRENCY_SYMBOL = '$';
|
|
10
|
-
export const toUpcomingPaymentEvent = (event) => ({
|
|
11
|
-
accountId: event.account_id,
|
|
12
|
-
accountType: event.account_type,
|
|
13
|
-
amount: toAmount(event.amount_usd, event.currency_code, CASH_AGENT_CURRENCY_SYMBOL),
|
|
14
|
-
label: event.label,
|
|
15
|
-
paymentDate: zeniDate(event.payment_date),
|
|
16
|
-
});
|
|
17
|
-
/**
|
|
18
|
-
* The agent reports a `null` account id whenever the "account" in question is
|
|
19
|
-
* a singleton inferred from the account type (today: the treasury account —
|
|
20
|
-
* there's only one per company, so the type alone identifies it). Callers
|
|
21
|
-
* already branch on `*BankAccountType`, so collapsing the id to `""` keeps the
|
|
22
|
-
* state type a plain `ID` (string) without losing information.
|
|
23
|
-
*/
|
|
24
|
-
const toCashManagementMovement = (payload) => ({
|
|
25
|
-
amount: toAmount(payload.amount, payload.currency_code, CASH_AGENT_CURRENCY_SYMBOL),
|
|
26
|
-
destinationBankAccountId: payload.destination_bank_account_id ?? '',
|
|
27
|
-
destinationBankAccountType: payload.destination_bank_account_type,
|
|
28
|
-
reasoning: payload.reasoning,
|
|
29
|
-
sourceBankAccountId: payload.source_bank_account_id ?? '',
|
|
30
|
-
sourceBankAccountType: payload.source_bank_account_type,
|
|
31
|
-
subMovementType: payload.sub_movement_type,
|
|
32
|
-
});
|
|
33
|
-
const toCashManagementMoneyMovementGroup = (payload) => ({
|
|
34
|
-
movements: payload.movements.map(toCashManagementMovement),
|
|
35
|
-
movementType: payload.movement_type,
|
|
36
|
-
});
|
|
37
|
-
export const toCashManagementBannerData = (payload) => ({
|
|
38
|
-
inflows: payload.inflows.map(toUpcomingPaymentEvent),
|
|
39
|
-
moneyMovements: payload.money_movements.map(toCashManagementMoneyMovementGroup),
|
|
40
|
-
outflows: payload.outflows.map(toUpcomingPaymentEvent),
|
|
41
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { toCashManagementBannerData, } from './cashManagementOverviewPayload';
|
|
3
|
-
import { initialCashManagementBannerState, } from './cashManagementOverviewState';
|
|
4
|
-
export const initialState = {
|
|
5
|
-
banner: initialCashManagementBannerState,
|
|
6
|
-
};
|
|
7
|
-
const cashManagementOverview = createSlice({
|
|
8
|
-
name: 'cashManagementOverview',
|
|
9
|
-
initialState,
|
|
10
|
-
reducers: {
|
|
11
|
-
fetchCashManagementOverviewPage: {
|
|
12
|
-
reducer() { },
|
|
13
|
-
prepare(cacheOverride) {
|
|
14
|
-
return { payload: { cacheOverride } };
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
fetchCashManagementBanner(draft) {
|
|
18
|
-
// Keep `draft.banner.data` so the projection chart renders the last
|
|
19
|
-
// good payload while the refetch is in flight, instead of flickering
|
|
20
|
-
// to the empty/skeleton state on every page revisit.
|
|
21
|
-
draft.banner.fetchState = 'In-Progress';
|
|
22
|
-
draft.banner.error = undefined;
|
|
23
|
-
},
|
|
24
|
-
updateCashManagementBanner(draft, action) {
|
|
25
|
-
draft.banner = {
|
|
26
|
-
fetchState: 'Completed',
|
|
27
|
-
error: undefined,
|
|
28
|
-
data: toCashManagementBannerData(action.payload.data),
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
updateCashManagementBannerFetchStatus(draft, action) {
|
|
32
|
-
draft.banner = {
|
|
33
|
-
...draft.banner,
|
|
34
|
-
fetchState: action.payload.fetchState,
|
|
35
|
-
error: action.payload.error,
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
clearCashManagementOverview(draft) {
|
|
39
|
-
Object.assign(draft, initialState);
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
export const { fetchCashManagementOverviewPage, fetchCashManagementBanner, updateCashManagementBanner, updateCashManagementBannerFetchStatus, clearCashManagementOverview, } = cashManagementOverview.actions;
|
|
44
|
-
export default cashManagementOverview.reducer;
|