@zeniai/client-epic-state 5.0.82-betaAK3 → 5.0.82-betaAK5
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/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +2 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +9 -7
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.d.ts +7 -0
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +2 -0
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.d.ts +0 -16
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.d.ts +1 -7
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +9 -7
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getDepositAccountByDepositAccountId } from '../../../../entity/depositAccount/depositAccountSelector';
|
|
2
2
|
import { mapDepositAccToFundingAccount, } from '../../commonSetup/setupViewSelector';
|
|
3
3
|
import { getTreasuryDetail } from '../../treasury/treasuryList/treasuryDetailSelector';
|
|
4
|
+
import { getCashManagementOverviewBanner } from '../cashManagementOverview/cashManagementOverviewSelector';
|
|
4
5
|
import { bufferAmountToRisk, } from './autoSweepFlowState';
|
|
5
6
|
export const getAutoSweepFlow = (state) => {
|
|
6
7
|
const { bufferAmount, frequency, memo, saveStatus, settingsId, primaryFundingAccountId, fetchState, error, } = state.autoSweepFlowState;
|
|
@@ -21,6 +22,7 @@ export const getAutoSweepFlow = (state) => {
|
|
|
21
22
|
: undefined,
|
|
22
23
|
saveStatus,
|
|
23
24
|
settingsId,
|
|
25
|
+
sweepAmount: getCashManagementOverviewBanner(state).amount,
|
|
24
26
|
treasurySummary: getTreasuryDetail(state).accountSummary,
|
|
25
27
|
version: 0,
|
|
26
28
|
};
|
|
@@ -92,25 +92,27 @@ export const getCashManagementOverview = (state) => {
|
|
|
92
92
|
const buildProjectionData = (cashBalance, inflowEvents, outflowEvents) => {
|
|
93
93
|
const events = [
|
|
94
94
|
...inflowEvents.map((e) => ({
|
|
95
|
+
amount: e.amount,
|
|
95
96
|
date: e.paymentDate,
|
|
96
|
-
delta: e.amount.amount,
|
|
97
97
|
isInflow: true,
|
|
98
98
|
})),
|
|
99
99
|
...outflowEvents.map((e) => ({
|
|
100
|
+
amount: e.amount,
|
|
100
101
|
date: e.paymentDate,
|
|
101
|
-
|
|
102
|
-
isOutflow: true,
|
|
102
|
+
isInflow: false,
|
|
103
103
|
})),
|
|
104
104
|
].sort((a, b) => a.date.valueOf() - b.date.valueOf());
|
|
105
|
-
let balance = cashBalance
|
|
105
|
+
let balance = cashBalance;
|
|
106
106
|
const points = [{ balance, date: 'Today' }];
|
|
107
107
|
events.forEach((event) => {
|
|
108
|
-
balance
|
|
108
|
+
balance = event.isInflow
|
|
109
|
+
? addAmounts(balance, event.amount)
|
|
110
|
+
: subtractAmounts(balance, event.amount);
|
|
109
111
|
points.push({
|
|
110
112
|
balance,
|
|
111
113
|
date: event.date.format('MMM D'),
|
|
112
|
-
isInflow: event.isInflow,
|
|
113
|
-
isOutflow: event.
|
|
114
|
+
isInflow: event.isInflow ? true : undefined,
|
|
115
|
+
isOutflow: event.isInflow ? undefined : true,
|
|
114
116
|
});
|
|
115
117
|
});
|
|
116
118
|
return points;
|
|
@@ -22,6 +22,13 @@ export interface AutoSweepFlowFormData {
|
|
|
22
22
|
export interface AutoSweepFlowSelectorView extends SelectorView {
|
|
23
23
|
formData: AutoSweepFlowFormData;
|
|
24
24
|
saveStatus: FetchStateAndError;
|
|
25
|
+
/**
|
|
26
|
+
* Recommended sweep amount. Sourced from the cash management banner
|
|
27
|
+
* (the first money_movements[0].movements[0].amount returned by the
|
|
28
|
+
* agent's `/recommend` endpoint). Defaults to zero when the agent
|
|
29
|
+
* hasn't returned a movement yet.
|
|
30
|
+
*/
|
|
31
|
+
sweepAmount: Amount;
|
|
25
32
|
/** Resolved from `primaryFundingAccountId` against the deposit-account
|
|
26
33
|
* entity bucket. `undefined` until the GET fetch publishes the account. */
|
|
27
34
|
primaryFundingAccount?: FundingAccount;
|
|
@@ -4,6 +4,7 @@ exports.getAutoSweepFlow = void 0;
|
|
|
4
4
|
const depositAccountSelector_1 = require("../../../../entity/depositAccount/depositAccountSelector");
|
|
5
5
|
const setupViewSelector_1 = require("../../commonSetup/setupViewSelector");
|
|
6
6
|
const treasuryDetailSelector_1 = require("../../treasury/treasuryList/treasuryDetailSelector");
|
|
7
|
+
const cashManagementOverviewSelector_1 = require("../cashManagementOverview/cashManagementOverviewSelector");
|
|
7
8
|
const autoSweepFlowState_1 = require("./autoSweepFlowState");
|
|
8
9
|
const getAutoSweepFlow = (state) => {
|
|
9
10
|
const { bufferAmount, frequency, memo, saveStatus, settingsId, primaryFundingAccountId, fetchState, error, } = state.autoSweepFlowState;
|
|
@@ -24,6 +25,7 @@ const getAutoSweepFlow = (state) => {
|
|
|
24
25
|
: undefined,
|
|
25
26
|
saveStatus,
|
|
26
27
|
settingsId,
|
|
28
|
+
sweepAmount: (0, cashManagementOverviewSelector_1.getCashManagementOverviewBanner)(state).amount,
|
|
27
29
|
treasurySummary: (0, treasuryDetailSelector_1.getTreasuryDetail)(state).accountSummary,
|
|
28
30
|
version: 0,
|
|
29
31
|
};
|
|
@@ -24,27 +24,11 @@ export declare const RISK_BUFFER_AMOUNT: Record<RiskLevel, number>;
|
|
|
24
24
|
* uses this so it can pre-select the user's existing band on edit.
|
|
25
25
|
*/
|
|
26
26
|
export declare const bufferAmountToRisk: (amount: number) => RiskLevel;
|
|
27
|
-
/**
|
|
28
|
-
* Auto-sweep configuration state.
|
|
29
|
-
*
|
|
30
|
-
* `fetchState` / `error` (inherited from `FetchStateAndError`) track the
|
|
31
|
-
* GET `/cash-management/settings` fetch. `saveStatus` tracks the PUT save
|
|
32
|
-
* separately so the two flows don't stomp on each other's status.
|
|
33
|
-
*
|
|
34
|
-
* `settingsId` is the server-issued id (nullable on the wire — undefined
|
|
35
|
-
* here when the agent has no settings record yet).
|
|
36
|
-
*/
|
|
37
27
|
export interface AutoSweepFlowState extends FetchStateAndError {
|
|
38
28
|
bufferAmount: Amount;
|
|
39
29
|
frequency: AutoSweepFrequency;
|
|
40
30
|
memo: string;
|
|
41
31
|
saveStatus: FetchStateAndError;
|
|
42
|
-
/**
|
|
43
|
-
* Deposit-account id of the primary funding account returned by GET
|
|
44
|
-
* `/cash-management/settings`. The selector resolves it against the
|
|
45
|
-
* deposit-account entity bucket via `getDepositAccountByDepositAccountId`
|
|
46
|
-
* and exposes a hydrated `FundingAccount`.
|
|
47
|
-
*/
|
|
48
32
|
primaryFundingAccountId?: ID;
|
|
49
33
|
settingsId?: ID;
|
|
50
34
|
}
|
|
@@ -6,14 +6,8 @@ import { CashManagementMovement, UpcomingPaymentEvent } from './cashManagementOv
|
|
|
6
6
|
export interface CashManagementOverviewBannerSelectorView extends SelectorView, CashManagementMovement {
|
|
7
7
|
cashManagementSettingsId?: ID;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
* One point on the cash-balance projection line. The first point is today's
|
|
11
|
-
* `cashBalance`; each subsequent point is the running balance after applying
|
|
12
|
-
* the next inflow / outflow event (in chronological order). The `isInflow` /
|
|
13
|
-
* `isOutflow` flags drive the colored dot markers in the chart.
|
|
14
|
-
*/
|
|
15
9
|
export interface CashProjectionPoint {
|
|
16
|
-
balance:
|
|
10
|
+
balance: Amount;
|
|
17
11
|
/** Pre-formatted display label (e.g. `"Today"`, `"May 27"`). */
|
|
18
12
|
date: string;
|
|
19
13
|
isInflow?: boolean;
|
|
@@ -97,25 +97,27 @@ exports.getCashManagementOverview = getCashManagementOverview;
|
|
|
97
97
|
const buildProjectionData = (cashBalance, inflowEvents, outflowEvents) => {
|
|
98
98
|
const events = [
|
|
99
99
|
...inflowEvents.map((e) => ({
|
|
100
|
+
amount: e.amount,
|
|
100
101
|
date: e.paymentDate,
|
|
101
|
-
delta: e.amount.amount,
|
|
102
102
|
isInflow: true,
|
|
103
103
|
})),
|
|
104
104
|
...outflowEvents.map((e) => ({
|
|
105
|
+
amount: e.amount,
|
|
105
106
|
date: e.paymentDate,
|
|
106
|
-
|
|
107
|
-
isOutflow: true,
|
|
107
|
+
isInflow: false,
|
|
108
108
|
})),
|
|
109
109
|
].sort((a, b) => a.date.valueOf() - b.date.valueOf());
|
|
110
|
-
let balance = cashBalance
|
|
110
|
+
let balance = cashBalance;
|
|
111
111
|
const points = [{ balance, date: 'Today' }];
|
|
112
112
|
events.forEach((event) => {
|
|
113
|
-
balance
|
|
113
|
+
balance = event.isInflow
|
|
114
|
+
? addAmounts(balance, event.amount)
|
|
115
|
+
: subtractAmounts(balance, event.amount);
|
|
114
116
|
points.push({
|
|
115
117
|
balance,
|
|
116
118
|
date: event.date.format('MMM D'),
|
|
117
|
-
isInflow: event.isInflow,
|
|
118
|
-
isOutflow: event.
|
|
119
|
+
isInflow: event.isInflow ? true : undefined,
|
|
120
|
+
isOutflow: event.isInflow ? undefined : true,
|
|
119
121
|
});
|
|
120
122
|
});
|
|
121
123
|
return points;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.82-
|
|
3
|
+
"version": "5.0.82-betaAK5",
|
|
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",
|