@mx-cartographer/experiences 7.7.2 → 7.8.0-alpha-ram-goal-bug

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/Account-BiB1F8lL.mjs +118 -0
  3. package/dist/{Account-BfkKlfsW.mjs → Account-DuOz1a27.mjs} +1 -1
  4. package/dist/AccountApi-DgZ8ILj1.mjs +19 -0
  5. package/dist/{AccountDetailsHeader-DqYIuhOs.mjs → AccountDetailsHeader-Cf2TUJnM.mjs} +4 -4
  6. package/dist/AccountDisplayName-CO7z3v99.mjs +11 -0
  7. package/dist/{AccountFields-yP8QdgPd.mjs → AccountFields-UdOvbQ5H.mjs} +7 -6
  8. package/dist/{AccountListItem-DMbu9ehd.mjs → AccountListItem-BPVxmNT_.mjs} +7 -7
  9. package/dist/AccountStore-BbPWe2C9.mjs +244 -0
  10. package/dist/Accounts-M-LTzStv.mjs +27 -0
  11. package/dist/{CategoryStore-Cnw9yUys.mjs → CategoryStore-BYICdb9m.mjs} +73 -73
  12. package/dist/CategoryUtil-meuejJqP.mjs +80 -0
  13. package/dist/{ConnectionsDrawer-BqR6FWJO.mjs → ConnectionsDrawer-BDpVTTSe.mjs} +1 -1
  14. package/dist/{DebtsStore-DuSdXM1k.mjs → DebtsStore-BIbOVCPe.mjs} +12 -12
  15. package/dist/{ExportCsvAction-HK5CeZWR.mjs → ExportCsvAction-CDuzTva1.mjs} +2 -2
  16. package/dist/GlobalAccountFilter-DQCPNc95.mjs +316 -0
  17. package/dist/GoalStore-B4LVt_kH.mjs +422 -0
  18. package/dist/{ManageIncome-BrTrlplL.mjs → ManageIncome-CL3hv8i9.mjs} +44 -44
  19. package/dist/NetWorthStore-yV43kJro.mjs +168 -0
  20. package/dist/{NotificationSettings-D4Vh3z8I.mjs → NotificationSettings-SPg3pwbX.mjs} +171 -169
  21. package/dist/{NotificationStore-CDX_kqHa.mjs → NotificationStore-Ck2KdNmT.mjs} +22 -14
  22. package/dist/{RecurringSettings-D2V6l77l.mjs → RecurringSettings-Bmnnpb48.mjs} +16 -16
  23. package/dist/{RecurringTransactionsStore-Caf1cq4v.mjs → RecurringTransactionsStore-BQBEJOPP.mjs} +91 -81
  24. package/dist/{RecurringTransactions-Bf4lX0Cn.mjs → RepeatingTransaction-miZVnk_A.mjs} +4 -4
  25. package/dist/{SettingsStore-krIRNwHK.mjs → SettingsStore-BHpuyujx.mjs} +1 -1
  26. package/dist/SkeletonLoader-BaNboJjD.mjs +38 -0
  27. package/dist/{SpendingLegend-gTCJLLkV.mjs → SpendingLegend-CD60HCYS.mjs} +33 -33
  28. package/dist/{TransactionDetails-7MHOshKQ.mjs → TransactionDetails-BDhz3DLT.mjs} +2 -2
  29. package/dist/TransactionStore-BSp5bOKg.mjs +705 -0
  30. package/dist/{User-LJpEwPtn.mjs → User-B0LnmiKO.mjs} +21 -20
  31. package/dist/WidgetContainer-BbPS3Yxz.mjs +555 -0
  32. package/dist/accounts/index.es.js +421 -391
  33. package/dist/accounts/stores/AccountStore.d.ts +30 -23
  34. package/dist/accounts/utils/Accounts.d.ts +2 -1
  35. package/dist/budgets/index.es.js +546 -540
  36. package/dist/budgets/store/BudgetsStore.d.ts +1 -0
  37. package/dist/cashflow/index.es.js +444 -457
  38. package/dist/categories/index.es.js +1 -1
  39. package/dist/categories/stores/CategoryStore.d.ts +10 -5
  40. package/dist/categories/util/CategoryUtil.d.ts +3 -2
  41. package/dist/common/components/GlobalAccountFilter.d.ts +11 -0
  42. package/dist/common/components/SkeletonLoader.d.ts +7 -0
  43. package/dist/common/components/WidgetContainer.d.ts +7 -6
  44. package/dist/common/components/globalaccountfilter/GlobalAccountFilterList.d.ts +7 -0
  45. package/dist/common/components/index.d.ts +2 -2
  46. package/dist/common/hooks/useAriaLive.d.ts +1 -1
  47. package/dist/common/index.es.js +459 -445
  48. package/dist/common/stores/AppDataStore.d.ts +3 -1
  49. package/dist/common/stores/GlobalCopyStore.d.ts +0 -1
  50. package/dist/common/stores/GlobalStore.d.ts +3 -3
  51. package/dist/common/stores/GlobalUiStore.d.ts +10 -6
  52. package/dist/common/stores/UserStore.d.ts +3 -2
  53. package/dist/common/types/Account.d.ts +9 -6
  54. package/dist/dashboard/index.es.js +84 -116
  55. package/dist/debts/index.es.js +417 -413
  56. package/dist/{exportTransactionsToCSV-BrTYdSgJ.mjs → exportTransactionsToCSV-DtQ7ovAR.mjs} +1 -1
  57. package/dist/finstrong/index.es.js +1167 -1110
  58. package/dist/goals/index.es.js +618 -598
  59. package/dist/goals/stores/GoalStore.d.ts +19 -4
  60. package/dist/help/index.es.js +13 -13
  61. package/dist/investments/index.es.js +330 -325
  62. package/dist/investments/stores/HoldingStore.d.ts +1 -0
  63. package/dist/networth/components/NetWorthChart.d.ts +3 -2
  64. package/dist/networth/components/NetWorthList.d.ts +3 -3
  65. package/dist/networth/index.es.js +423 -433
  66. package/dist/networth/stores/NetWorthStore.d.ts +20 -9
  67. package/dist/networth/utils/NetWorthUtils.d.ts +2 -2
  68. package/dist/notifications/index.es.js +90 -91
  69. package/dist/notifications/stores/NotificationStore.d.ts +3 -1
  70. package/dist/recurringtransactions/components/MicroWidgetContent.d.ts +3 -0
  71. package/dist/recurringtransactions/index.es.js +543 -562
  72. package/dist/recurringtransactions/stores/RecurringTransactionsStore.d.ts +4 -2
  73. package/dist/settings/index.es.js +253 -248
  74. package/dist/spending/index.es.js +282 -301
  75. package/dist/transactions/index.es.js +269 -263
  76. package/dist/transactions/stores/TransactionStore.d.ts +26 -77
  77. package/dist/transactions/stores/UiStore.d.ts +0 -2
  78. package/dist/trends/index.es.js +708 -699
  79. package/dist/{useAccountDisplayName-BTvP_pw6.mjs → useAccountDisplayName-Bot2tb4n.mjs} +1 -1
  80. package/package.json +3 -3
  81. package/dist/AccountStore-CWFzg8-E.mjs +0 -260
  82. package/dist/Accounts-CWt-NRq8.mjs +0 -9
  83. package/dist/CategoryUtil-DZflYFam.mjs +0 -78
  84. package/dist/ConnectDrawer-BOjfI6rz.mjs +0 -563
  85. package/dist/GoalStore-C7ahxxLi.mjs +0 -364
  86. package/dist/NetWorthStore-xWIo9CYU.mjs +0 -150
  87. package/dist/TransactionStore-DJwPaZuM.mjs +0 -677
  88. package/dist/WidgetContainer-CrK6tyHr.mjs +0 -572
  89. package/dist/common/components/accountfilter/AccountFilter.d.ts +0 -20
  90. package/dist/common/components/accountfilter/AccountFilterOptions.d.ts +0 -31
  91. package/dist/common/components/accountfilter/index.d.ts +0 -1
  92. package/dist/{ToggleListItem-ciFTiqRS.mjs → Notification-Bs1fdbzI.mjs} +1 -1
@@ -1,364 +0,0 @@
1
- import { jsxs as g, jsx as _ } from "react/jsx-runtime";
2
- import u from "react";
3
- import T from "@mui/material/Button";
4
- import I from "@mui/material/Card";
5
- import N from "@mui/material/CardContent";
6
- import O from "@mui/material/CardHeader";
7
- import S from "@mui/material/Stack";
8
- import { AccountBalance as w, ChevronRight as L } from "@mxenabled/mx-icons";
9
- import { Text as A } from "@mxenabled/mxui";
10
- import { l as b } from "./ConnectDrawer-BOjfI6rz.mjs";
11
- import { a as y } from "./hooks-ZMp65DFz.mjs";
12
- import { makeAutoObservable as D, runInAction as c } from "mobx";
13
- import { F as v, A as i } from "./Fetch-DecPFeGU.mjs";
14
- import { fromUnixTime as G } from "date-fns/fromUnixTime";
15
- import { addYears as x } from "date-fns/addYears";
16
- import { getUnixTime as K } from "date-fns/getUnixTime";
17
- import { b as E } from "./Localization-2MODESHW.mjs";
18
- import { a as F } from "./NumberFormatting-DjTD0t3W.mjs";
19
- import { f as B, D as U } from "./Dialog-B4PI-_bL.mjs";
20
- var a = /* @__PURE__ */ ((e) => (e[e.DEBT_TRACK = 1] = "DEBT_TRACK", e[e.SAVINGS_TRACK = 2] = "SAVINGS_TRACK", e[e.RETIREMENT_TRACK = 3] = "RETIREMENT_TRACK", e[e.EMERGENCY_FUND_TRACK = 4] = "EMERGENCY_FUND_TRACK", e))(a || {}), $ = /* @__PURE__ */ ((e) => (e[e.SAVE_AMOUNT = 1] = "SAVE_AMOUNT", e[e.KEEP_BALANCE_BELOW = 2] = "KEEP_BALANCE_BELOW", e[e.KEEP_BALANCE_ABOVE = 3] = "KEEP_BALANCE_ABOVE", e[e.ACTION = 4] = "ACTION", e))($ || {}), l = /* @__PURE__ */ ((e) => (e[e.AUTOMOBILE = 1] = "AUTOMOBILE", e[e.COLLEGE = 2] = "COLLEGE", e[e.HOUSE = 3] = "HOUSE", e[e.RECREATIONAL_VEHICLE = 4] = "RECREATIONAL_VEHICLE", e[e.VACATION = 5] = "VACATION", e[e.ELECTRONIC = 6] = "ELECTRONIC", e[e.OTHER = 7] = "OTHER", e[e.RETIREMENT = 8] = "RETIREMENT", e[e.EMERGENCY_FUND = 9] = "EMERGENCY_FUND", e[e.SETUP_BUDGETS = 10] = "SETUP_BUDGETS", e[e.START_MONEY_MANAGEMENT = 11] = "START_MONEY_MANAGEMENT", e[e.CREDIT_CARD = 12] = "CREDIT_CARD", e[e.LINE_OF_CREDIT = 13] = "LINE_OF_CREDIT", e[e.LOANS = 14] = "LOANS", e))(l || {});
21
- const at = ({ description: e, label: t, title: o }) => {
22
- const { config: r } = y(), [n, s] = u.useState(!1);
23
- return /* @__PURE__ */ g(u.Fragment, { children: [
24
- /* @__PURE__ */ g(I, { sx: { m: 24 }, children: [
25
- /* @__PURE__ */ _(
26
- O,
27
- {
28
- avatar: /* @__PURE__ */ _(w, {}),
29
- sx: { ".MuiCardHeader-avatar": { mr: 8 } },
30
- title: /* @__PURE__ */ _(A, { bold: !0, variant: "Body", children: o })
31
- }
32
- ),
33
- /* @__PURE__ */ _(N, { sx: { ":last-child": { pb: 4 }, ml: 28, py: 0 }, children: /* @__PURE__ */ g(S, { alignItems: "flex-start", spacing: 2, children: [
34
- /* @__PURE__ */ _(A, { color: "text.secondary", sx: { textWrap: "wrap" }, variant: "ParagraphSmall", children: e }),
35
- r.show_connections_widget_in_master && /* @__PURE__ */ _(
36
- T,
37
- {
38
- endIcon: /* @__PURE__ */ _(L, {}),
39
- onClick: () => s(!0),
40
- sx: {
41
- pl: 0,
42
- ":hover": {
43
- bgcolor: "unset"
44
- }
45
- },
46
- variant: "text",
47
- children: t
48
- }
49
- )
50
- ] }) })
51
- ] }),
52
- /* @__PURE__ */ _(
53
- b,
54
- {
55
- onClose: () => s(!1),
56
- showConnectWidget: n,
57
- title: t
58
- }
59
- )
60
- ] });
61
- };
62
- class R {
63
- fetchInstance;
64
- constructor(t, o, r) {
65
- this.fetchInstance = new v(t, o, void 0, r);
66
- }
67
- addGoal = async (t) => this.fetchInstance.post(i.GOALS, t).then((o) => o.goal);
68
- addRetirementGoal = async (t) => this.fetchInstance.post(i.RETIREMENT_GOALS, t).then((o) => o.retirement_goal);
69
- addRetirementGoalAccount = async (t) => this.fetchInstance.post(i.RETIREMENT_GOAL_ACCOUNTS, t).then((o) => o.retirement_goal_account);
70
- getGoalByGuid = async (t) => this.fetchInstance.get(`${i.GOALS}/${t}`).then((o) => o.goal);
71
- getGoals = async () => this.fetchInstance.get(i.GOALS).then((t) => t.goals);
72
- getMonthlyCashFlowProfile = async () => this.fetchInstance.get(i.MONTHLY_CASH_FLOW_PROFILE).then((t) => t.monthly_cash_flow_profile);
73
- getRetirementGoals = async () => this.fetchInstance.get(i.RETIREMENT_GOALS).then((t) => t.retirement_goals);
74
- getRetirementGoalAccounts = async () => this.fetchInstance.get(i.RETIREMENT_GOAL_ACCOUNTS).then((t) => t.retirement_goal_accounts);
75
- removeGoal = async (t) => this.fetchInstance.delete(`${i.GOALS}/${t}`).then((o) => o);
76
- removeRetirementGoal = async (t) => this.fetchInstance.delete(`${i.RETIREMENT_GOALS}/${t}`).then((o) => o);
77
- removeRetirementGoalAccount = async (t) => this.fetchInstance.delete(`${i.RETIREMENT_GOAL_ACCOUNTS}/${t}`).then((o) => o);
78
- reorderGoals = async (t) => this.fetchInstance.post(`${i.GOALS}/reposition`, { goals: t }).then((o) => o.goals);
79
- updateGoal = async (t) => this.fetchInstance.put(`${i.GOALS}/${t.guid}`, t).then((o) => o.goal);
80
- updateMonthlyCashFlowProfile = async (t) => this.fetchInstance.put(`${i.MONTHLY_CASH_FLOW_PROFILE}`, t).then((o) => o.monthly_cash_flow_profile);
81
- updateRetirementGoal = async (t) => this.fetchInstance.put(`${i.RETIREMENT_GOALS}/${t.guid}`, t).then((o) => o.retirement_goal);
82
- }
83
- function it(e, t) {
84
- const o = t.track_type === a.DEBT_TRACK ? t.initial_amount : t.amount;
85
- let r = t.current_amount / o;
86
- r > 1 && (r = 1), r = t.track_type === a.DEBT_TRACK ? 1 - r : r, isNaN(r) && (r = 1);
87
- let n = "chart.chart1", s = "common.black";
88
- t.track_type === a.DEBT_TRACK ? (s = "common.white", n = "chart.chart5") : t.track_type === a.RETIREMENT_TRACK && (n = "chart.chart6");
89
- const h = {
90
- style: "percent",
91
- minimumFractionDigits: 0,
92
- maximumFractionDigits: 0
93
- }, d = t.is_complete ? t.completed_at : t.projected_to_complete_at, m = d ? G(d) : /* @__PURE__ */ new Date(), f = E(
94
- e.goal_percentage,
95
- F(r, h)
96
- ), p = E(
97
- t.is_complete ? e.completed_label : e.goal_projection,
98
- B(m, U.MONTH_SHORT_YEAR)
99
- );
100
- return {
101
- backgroundColor: n,
102
- color: s,
103
- percentage: r,
104
- percentageText: f,
105
- projectedText: p
106
- };
107
- }
108
- function st(e) {
109
- return [
110
- {
111
- bgcolor: "chart.chart1",
112
- icon: "attach_money",
113
- label: e.saving_goal_label,
114
- description: e.saving_goal_description,
115
- subTypes: [
116
- {
117
- icon: "ecg_heart",
118
- label: e.saving_goal_emergency_fund,
119
- metaType: l.EMERGENCY_FUND
120
- },
121
- {
122
- icon: "directions_car",
123
- label: e.saving_gaol_automobile,
124
- metaType: l.AUTOMOBILE
125
- },
126
- { icon: "school", label: e.saving_goal_college, metaType: l.COLLEGE },
127
- { icon: "home", label: e.saving_goal_home, metaType: l.HOUSE },
128
- {
129
- icon: "mountain_flag",
130
- label: e.saving_goal_recreational,
131
- metaType: l.RECREATIONAL_VEHICLE
132
- },
133
- { icon: "airplane_ticket", label: e.saving_goal_vacation, metaType: l.VACATION },
134
- {
135
- icon: "desktop_windows",
136
- label: e.saving_goal_electronic,
137
- metaType: l.ELECTRONIC
138
- },
139
- { icon: "payments", label: e.saving_goal_other, metaType: l.OTHER }
140
- ],
141
- type: a.SAVINGS_TRACK
142
- },
143
- {
144
- bgcolor: "chart.chart5",
145
- icon: "note_stack",
146
- label: e.debt_goal_label,
147
- description: e.debt_goal_description,
148
- subTypes: [],
149
- type: a.DEBT_TRACK
150
- },
151
- {
152
- bgcolor: "chart.chart6",
153
- icon: "person",
154
- label: e.retirement_goal_label,
155
- description: e.retirement_goal_description,
156
- subTypes: [],
157
- type: a.RETIREMENT_TRACK
158
- }
159
- ];
160
- }
161
- const ct = (e, t) => {
162
- switch (e) {
163
- case a.DEBT_TRACK:
164
- return E(t.zero_state_ongoing, "debt");
165
- case a.SAVINGS_TRACK:
166
- return E(t.zero_state_ongoing, "saving");
167
- default:
168
- return E(t.zero_state_ongoing, "retirement");
169
- }
170
- }, C = (e, t) => {
171
- const o = G(t), r = x(o, e);
172
- return K(r);
173
- };
174
- class lt {
175
- globalStore;
176
- api = new R("/", "");
177
- alert = "";
178
- goals = [];
179
- retirementGoalAccounts = [];
180
- newRetirementGoalAccounts = [];
181
- selectedGoal = void 0;
182
- monthlyCashFlowProfile = void 0;
183
- goalsLoaded = !1;
184
- constructor(t) {
185
- this.globalStore = t, this.api = new R(t.endpoint, t.sessionToken, t.onError), D(this);
186
- }
187
- get orderedGoals() {
188
- return this.goals.slice().sort((t, o) => t.position - o.position);
189
- }
190
- get debtGoals() {
191
- return this.orderedGoals.filter((t) => t.track_type === a.DEBT_TRACK);
192
- }
193
- get retirmentGoals() {
194
- return this.orderedGoals.filter((t) => t.track_type === a.RETIREMENT_TRACK);
195
- }
196
- get savingGoals() {
197
- return this.orderedGoals.filter((t) => t.track_type === a.SAVINGS_TRACK);
198
- }
199
- get ongoingGoalsForMicroWidget() {
200
- const t = this.goals.filter(
201
- (r) => !r.is_complete && r.track_type !== a.EMERGENCY_FUND_TRACK && r.track_type !== null
202
- ), o = [
203
- a.SAVINGS_TRACK,
204
- a.DEBT_TRACK,
205
- a.RETIREMENT_TRACK
206
- ];
207
- return t.sort((r, n) => {
208
- const s = r.track_type ? o.indexOf(r.track_type) : -1, h = n.track_type ? o.indexOf(n.track_type) : -1;
209
- return s - h;
210
- }).slice(0, 3);
211
- }
212
- addGoal = async (t) => {
213
- try {
214
- const o = await this.api.addGoal(t);
215
- c(() => {
216
- this.goals = [...this.goals, o];
217
- });
218
- } catch (o) {
219
- console.error(`Error occurred while adding goal: ${o}`);
220
- }
221
- };
222
- addRetirementGoal = async (t) => {
223
- const o = this.globalStore.copyStore.copy.goals;
224
- try {
225
- const r = await this.api.addRetirementGoal(t), n = [], s = this.globalStore.userStore.user.birthday;
226
- for (const h of this.newRetirementGoalAccounts) {
227
- const d = await this.api.addRetirementGoalAccount({
228
- ...h,
229
- retirement_goal_guid: r.guid
230
- });
231
- n.push(d);
232
- }
233
- this.setNewRetirementGoalAccounts([]), c(() => {
234
- this.goals = [
235
- ...this.goals,
236
- {
237
- ...r,
238
- amount: r.target_amount,
239
- name: o.retirement,
240
- track_type: a.RETIREMENT_TRACK,
241
- projected_to_complete_at: r.retirement_age && s ? C(r.retirement_age, s) : void 0
242
- }
243
- ], this.retirementGoalAccounts = [...this.retirementGoalAccounts, ...n];
244
- });
245
- } catch (r) {
246
- console.error(`Error occurred while adding retirement goal: ${r}`);
247
- }
248
- };
249
- addRetirementGoalAccount = async (t) => {
250
- try {
251
- const o = await this.api.addRetirementGoalAccount(t);
252
- c(() => {
253
- this.retirementGoalAccounts = [...this.retirementGoalAccounts, o];
254
- });
255
- } catch (o) {
256
- console.error(`Error occurred while adding retirement goal account: ${o}`);
257
- }
258
- };
259
- loadGoals = async () => {
260
- const t = this.globalStore.copyStore.copy.goals;
261
- try {
262
- const o = await this.api.getGoals(), r = await this.api.getRetirementGoals(), n = await this.api.getRetirementGoalAccounts(), s = await this.api.getMonthlyCashFlowProfile(), h = this.globalStore.userStore.user.birthday, d = [
263
- ...o,
264
- ...r.map((m) => ({
265
- ...m,
266
- amount: m.target_amount,
267
- name: t.retirement,
268
- track_type: a.RETIREMENT_TRACK,
269
- projected_to_complete_at: m.retirement_age && h ? C(m.retirement_age, h) : void 0
270
- }))
271
- ];
272
- c(() => {
273
- this.goals = d, this.retirementGoalAccounts = n, this.monthlyCashFlowProfile = s, this.goalsLoaded = !0;
274
- });
275
- } catch (o) {
276
- console.error(`Error occured while getting goals: ${o}`);
277
- }
278
- };
279
- deleteGoal = async (t) => {
280
- try {
281
- await this.api.removeGoal(t), c(() => {
282
- const o = this.goals.findIndex((r) => r.guid === t);
283
- o >= 0 && this.goals.splice(o, 1);
284
- });
285
- } catch (o) {
286
- console.error(`Error occured while deleting goal: ${o}`);
287
- }
288
- };
289
- deleteRetirementGoal = async (t) => {
290
- try {
291
- const o = this.retirementGoalAccounts.filter(
292
- (r) => r.retirement_goal_guid === t.guid
293
- );
294
- for (const r of o)
295
- await this.deleteRetirementGoalAccount(r.guid);
296
- await this.api.removeRetirementGoal(t.guid), c(() => {
297
- const r = this.goals.findIndex((n) => n.guid === t.guid);
298
- r >= 0 && this.goals.splice(r, 1);
299
- });
300
- } catch (o) {
301
- console.error(`Error deleting retirement goal: ${o}`);
302
- }
303
- };
304
- deleteRetirementGoalAccount = async (t) => {
305
- try {
306
- await this.api.removeRetirementGoalAccount(t), c(() => {
307
- const o = this.retirementGoalAccounts.findIndex((r) => r.guid === t);
308
- o >= 0 && this.retirementGoalAccounts.splice(o, 1);
309
- });
310
- } catch (o) {
311
- console.error(`Error deleting retirement goal account: ${o}`);
312
- }
313
- };
314
- reorderGoals = async (t) => {
315
- try {
316
- const o = await this.api.reorderGoals(t);
317
- c(() => {
318
- for (const r of o) {
319
- const n = this.goals.findIndex((s) => s.guid === r.guid);
320
- n >= 0 && (this.goals[n].position = r.position);
321
- }
322
- });
323
- } catch (o) {
324
- console.error(`Error reordering goals: ${o}`);
325
- }
326
- };
327
- setAlert = (t) => this.alert = t;
328
- setNewRetirementGoalAccounts = (t) => {
329
- this.newRetirementGoalAccounts = t;
330
- };
331
- setSelectedGoal = (t) => this.selectedGoal = t;
332
- updateGoal = async (t) => {
333
- try {
334
- const o = await this.api.updateGoal(t);
335
- c(() => {
336
- const r = this.goals.findIndex((n) => n.guid === t.guid);
337
- r >= 0 && (this.goals[r] = o), this.selectedGoal?.guid === t.guid && this.setSelectedGoal(o);
338
- });
339
- } catch (o) {
340
- console.error(`Error occurred while updating goal: ${o}`);
341
- }
342
- };
343
- updateMonthlyCashFlowProfile = async (t) => {
344
- try {
345
- const o = await this.api.updateMonthlyCashFlowProfile(t);
346
- c(() => {
347
- this.monthlyCashFlowProfile = o;
348
- });
349
- } catch (o) {
350
- console.error(`Error occurred while updating monthly Cash Flow profile: ${o}`);
351
- }
352
- };
353
- }
354
- export {
355
- at as C,
356
- $ as G,
357
- l as M,
358
- a as T,
359
- ct as a,
360
- st as b,
361
- R as c,
362
- lt as d,
363
- it as g
364
- };
@@ -1,150 +0,0 @@
1
- import { makeAutoObservable as D, runInAction as u } from "mobx";
2
- import { format as A } from "date-fns/format";
3
- import { fromUnixTime as W } from "date-fns/fromUnixTime";
4
- import { startOfMonth as _ } from "date-fns/startOfMonth";
5
- import { subMonths as B } from "date-fns/subMonths";
6
- import { a as b } from "./Accounts-CWt-NRq8.mjs";
7
- import { e as N, a as M, f as v } from "./ConnectDrawer-BOjfI6rz.mjs";
8
- const f = 13, L = (n, t) => n.filter((e) => {
9
- const { is_closed: r, is_deleted: s, is_hidden: a, is_manual: i } = e;
10
- return r || s || a ? !1 : i || !e.guid ? !0 : t.some((l) => n.some((g) => l.guid === g.member_guid));
11
- }), S = (n, t) => [...n, ...t], d = (n) => {
12
- if (n && n.length > 0)
13
- return n[n.length - 1];
14
- }, T = (n, t) => n.year_month - t.year_month, w = () => Array.from({ length: f }, (n, t) => Math.floor(_(B(/* @__PURE__ */ new Date(), t)).getTime() / 1e3)).sort(), C = (n, t, e) => !n.length || !t.length ? [] : w().reduceRight((s, a) => {
15
- const i = t.filter(
16
- ({ year_month: o }) => o === parseInt(A(W(a), "yyyyMM"))
17
- ), l = n.map((o) => {
18
- const c = i.find((h) => h.account_guid === o.guid), m = {
19
- change: 0,
20
- guid: o.guid,
21
- name: o.name,
22
- type: o.account_type,
23
- balance: 0
24
- };
25
- if (!c && s.length === 0 && !o.balance) return m;
26
- if (!c && s.length === 0)
27
- return {
28
- ...m,
29
- value: b(o) ? -(o.balance ?? 0) : o.balance ?? 0
30
- };
31
- if (!c) {
32
- const h = s[0].accounts.find((y) => y.guid === o.guid);
33
- return h || m;
34
- }
35
- return {
36
- change: c.transaction_total,
37
- guid: o.guid,
38
- name: o.name,
39
- type: o.account_type,
40
- value: c.balance
41
- };
42
- }), { y: g, change: p } = l.reduce(
43
- (o, c) => ({
44
- y: o.y + (c.value || 0),
45
- change: o.change + (c.change || 0)
46
- }),
47
- { y: 0, change: 0 }
48
- );
49
- return [
50
- {
51
- accounts: l,
52
- x: a,
53
- y: g,
54
- change: p
55
- },
56
- ...s
57
- ];
58
- }, []).slice(f - e), E = (n) => {
59
- const t = [], e = [];
60
- let r = 0, s = 0;
61
- return n?.accounts.forEach((a) => {
62
- a.change > 0 && (t.push({ accountName: a.name, gain: a.change }), r += a.change), a.change < 0 && (e.push({ accountName: a.name, loss: a.change }), s += a.change);
63
- }), { netWorth: n, gains: t, losses: e, totalGains: r, totalLosses: s };
64
- }, k = (n) => {
65
- const t = [], e = [];
66
- let r = 0, s = 0;
67
- return n.forEach((a) => {
68
- if (b(a)) {
69
- const i = a.balance ?? 0;
70
- e.push({ accountName: a.name, accountType: a.account_type, balance: i }), s += i;
71
- } else {
72
- const i = a.balance ?? 0;
73
- t.push({ accountName: a.name, accountType: a.account_type, balance: i }), r += i;
74
- }
75
- }), { assets: t, liabilities: e, totalAssets: r, totalLiabilities: s };
76
- }, j = (n) => {
77
- const t = n.reduce((e, r) => {
78
- const s = r.accountType;
79
- return e[s] || (e[s] = []), e[s].push(r), e;
80
- }, {});
81
- return Object.entries(t).map(([e, r]) => ({
82
- icon: N[+e] || M[+e],
83
- name: v[+e],
84
- accounts: r
85
- }));
86
- };
87
- class z {
88
- globalStore;
89
- netWorthData = { accounts: [], monthlyAccountBalances: [] };
90
- netWorthChartData = [];
91
- hoveredData;
92
- selectedData;
93
- constructor(t) {
94
- this.globalStore = t, D(this);
95
- }
96
- loadNetWorthData = async (t) => {
97
- try {
98
- const e = this.globalStore.accountStore.members, r = L(t, e), a = await (await Promise.all(
99
- r.map((i) => this.globalStore.accountStore.api.getMonthlyAccountBalances(i.guid))
100
- )).reduce(S, []).sort(T);
101
- u(() => {
102
- this.netWorthData = {
103
- accounts: r,
104
- monthlyAccountBalances: a
105
- };
106
- });
107
- } catch (e) {
108
- console.error(`Error occured while loading net worth data: ${e}`);
109
- }
110
- };
111
- loadChartData = async (t) => {
112
- try {
113
- const { accounts: e, monthlyAccountBalances: r } = this.netWorthData, s = await C(e, r, t), a = d(s);
114
- u(() => {
115
- this.netWorthChartData = s, this.selectedData = a;
116
- });
117
- } catch (e) {
118
- console.error(`Error occured while loading chart data: ${e}`);
119
- }
120
- };
121
- get gainsLosses() {
122
- return E(this.selectedData);
123
- }
124
- get assetsLiabilities() {
125
- const { assets: t, liabilities: e, totalAssets: r, totalLiabilities: s } = k(
126
- this.netWorthData.accounts
127
- );
128
- return {
129
- netWorth: d(this.netWorthChartData),
130
- assets: t,
131
- liabilities: e,
132
- totalAssets: r,
133
- totalLiabilities: s
134
- };
135
- }
136
- setSelectedData = (t) => {
137
- u(() => {
138
- this.selectedData = this.netWorthChartData[t];
139
- });
140
- };
141
- setHoveredData = (t) => {
142
- u(() => {
143
- this.hoveredData = t !== null ? this.netWorthChartData[t] : void 0;
144
- });
145
- };
146
- }
147
- export {
148
- z as N,
149
- j as g
150
- };