@zeniai/client-epic-state 5.0.82-betaAK4 → 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/cashManagementOverview/cashManagementOverviewSelector.js +9 -7
- 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
|
@@ -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;
|
|
@@ -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",
|