@mx-cartographer/experiences 9.0.3 → 9.1.0-alpha.bb1
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/CHANGELOG.md +0 -4
- package/dist/Analytics-BKzTPees.mjs +61 -0
- package/dist/GlobalCopyApi-BeXzaDH9.mjs +487 -0
- package/dist/HeaderCell-EhCUSjvj.mjs +10 -0
- package/dist/Loader-BlVzRtUd.mjs +73 -0
- package/dist/MiniWidgetContainer-COwnjfy7.mjs +110 -0
- package/dist/OriginalBalanceAction-sbiqaxok.mjs +110 -0
- package/dist/SpendingLegend-D15ixlQ1.mjs +222 -0
- package/dist/accounts/index.es.js +12 -1598
- package/dist/accounts-DkyAiLpg.mjs +15632 -0
- package/dist/analytics/index.es.js +155 -139
- package/dist/budgets/index.es.js +1317 -1266
- package/dist/cashflow/index.es.js +1047 -942
- package/dist/categories/index.es.js +4 -4
- package/dist/common/index.es.js +101 -310
- package/dist/core/index.es.js +80 -104
- package/dist/core-BexP5oiV.mjs +4047 -0
- package/dist/dashboard/index.es.js +185 -141
- package/dist/debts/index.es.js +1384 -1272
- package/dist/finstrong/index.es.js +3366 -3471
- package/dist/goals/index.es.js +1103 -984
- package/dist/help/index.es.js +3 -25
- package/dist/help-CctDYrAH.mjs +2308 -0
- package/dist/insights/index.es.js +93 -4843
- package/dist/investments/index.es.js +1533 -1522
- package/dist/merchants/index.es.js +75 -64
- package/dist/microinsights/index.es.js +15 -824
- package/dist/microinsights-CRf3ChsJ.mjs +1814 -0
- package/dist/networth/index.es.js +550 -503
- package/dist/notifications/index.es.js +169 -161
- package/dist/recurringtransactions/index.es.js +10 -962
- package/dist/recurringtransactions-gbJ_NA8u.mjs +1564 -0
- package/dist/settings/index.es.js +13 -880
- package/dist/settings-ZMHe439l.mjs +1526 -0
- package/dist/spending/index.es.js +400 -456
- package/dist/transactions/index.es.js +10 -603
- package/dist/trends/index.es.js +1268 -1407
- package/package.json +28 -28
- package/dist/Account-BaJmiJAG.mjs +0 -118
- package/dist/Account-BxHMlV9R.mjs +0 -30
- package/dist/AccountDetailsHeader-DIysk_4w.mjs +0 -95
- package/dist/AccountDisplayName-CO7z3v99.mjs +0 -11
- package/dist/AccountFields-mwJ8NXsX.mjs +0 -141
- package/dist/AccountListItem-BDXHs4tV.mjs +0 -94
- package/dist/AccountUtils-T5_Odvos.mjs +0 -27
- package/dist/Accounts-CseLC3lL.mjs +0 -5
- package/dist/Analytics-CkYXKvco.mjs +0 -53
- package/dist/Analytics-CzGzz_sE.mjs +0 -136
- package/dist/ApiEndpoints-DXwIYNUV.mjs +0 -49
- package/dist/BudgetUtil-Bg2AQJpQ.mjs +0 -74
- package/dist/Category-DEKZGLYe.mjs +0 -301
- package/dist/CategorySelectorDrawer-8soGrhB8.mjs +0 -430
- package/dist/Connect-Dk6GZEsA.mjs +0 -39
- package/dist/ConnectCard-CCep7Zqe.mjs +0 -54
- package/dist/ConnectDrawer-Cnjr3Ddg.mjs +0 -58
- package/dist/ConnectionsDrawer-CtfPXk0M.mjs +0 -54
- package/dist/CurrencyDialog-DumQCTPO.mjs +0 -373
- package/dist/CurrencyInput-adTIRtL3.mjs +0 -87
- package/dist/CurrencyText-CCbE6MmF.mjs +0 -20
- package/dist/DateFormats-HudZ3Bjs.mjs +0 -64
- package/dist/DateUtil-Bhq59ZVg.mjs +0 -58
- package/dist/DebtUtils-DD3186U-.mjs +0 -153
- package/dist/Dialog-Bvd2n8hz.mjs +0 -66
- package/dist/Donut-SzzfZDHF.mjs +0 -88
- package/dist/Drawer-BXqqBMxg.mjs +0 -174
- package/dist/EmbeddedCard-DPwJjqMH.mjs +0 -856
- package/dist/EmptyState-CJUDc3kD.mjs +0 -84
- package/dist/Error-Dogaw2jO.mjs +0 -84
- package/dist/ErrorBoundary-CsdOcnJ9.mjs +0 -23
- package/dist/ExportCsvAction-Bw02ZJEj.mjs +0 -24
- package/dist/GlobalAccountFilter-7Cg2-9A5.mjs +0 -237
- package/dist/GlobalCopyApi-wcnDUzMV.mjs +0 -128
- package/dist/GoalsUtil-C9EnLWvC.mjs +0 -107
- package/dist/HeaderCell-P8w6CmfO.mjs +0 -6
- package/dist/Help-CkQTjORd.mjs +0 -299
- package/dist/Help-DJ8PrVHX.mjs +0 -3209
- package/dist/IconBacking-DgT8DCeh.mjs +0 -39
- package/dist/InformationTooltip-4su8bn1e.mjs +0 -41
- package/dist/InvestmentUtil-BItV7uEs.mjs +0 -134
- package/dist/LineChart-CejWS_rh.mjs +0 -612
- package/dist/ListItemAction-CzZ8s39Z.mjs +0 -69
- package/dist/ListItemRow-kH1rn8Xu.mjs +0 -67
- package/dist/ListItemWrapper-B5r-YQQ_.mjs +0 -42
- package/dist/Loader-CxeBwuPG.mjs +0 -21
- package/dist/Localization-DnoVyBNK.mjs +0 -38
- package/dist/ManageIncome-D1yBODQi.mjs +0 -595
- package/dist/MicroWidgetContainer-CfKdQfhi.mjs +0 -45
- package/dist/MiniWidgetContainer-BdPiUU-u.mjs +0 -66
- package/dist/NetWorthUtils-DilGN1nW.mjs +0 -95
- package/dist/Notification-DTNYSd8P.mjs +0 -7
- package/dist/NotificationSettings-B4JA5IKE.mjs +0 -677
- package/dist/NotificationUtils-BRGFTePr.mjs +0 -23
- package/dist/NumberFormatting--XMeeBfr.mjs +0 -49
- package/dist/OriginalBalanceAction-BybTXDtO.mjs +0 -114
- package/dist/RecurringSettings-D2xbNb67.mjs +0 -88
- package/dist/RecurringTransactionsUtil-B3rLEx_g.mjs +0 -253
- package/dist/ResponsiveButton-CC9F_Ezk.mjs +0 -45
- package/dist/SearchBox-Cpgu_gdO.mjs +0 -50
- package/dist/Select-BFt-HD-L.mjs +0 -55
- package/dist/SelectionBox-B4xELRgp.mjs +0 -48
- package/dist/SingleSegmentDonut-7Uy6VEld.mjs +0 -69
- package/dist/Sizes-DISGrlUg.mjs +0 -6
- package/dist/SkeletonLoader-BaNboJjD.mjs +0 -38
- package/dist/SpendingData-Fii_xATx.mjs +0 -53
- package/dist/SpendingLegend-5Ct_FZ8o.mjs +0 -193
- package/dist/StatusBar-CPfSXe80.mjs +0 -30
- package/dist/TabContentContainer-CnMXkVqr.mjs +0 -21
- package/dist/ToggleListItem-Dl1lXNwj.mjs +0 -91
- package/dist/TransactionDetails-DctXr07p.mjs +0 -1714
- package/dist/TransactionUtils-BphBJBbU.mjs +0 -234
- package/dist/TrendsUtil-D9z3kIj_.mjs +0 -69
- package/dist/UserStore-CRpKQjpP.mjs +0 -3002
- package/dist/ViewMoreMicroCard-BD_MNc2z.mjs +0 -1295
- package/dist/WidgetContainer-CmbU4CBH.mjs +0 -482
- package/dist/hooks-BaO_gOI6.mjs +0 -77
- package/dist/useAccountDisplayName-CFa_MrS6.mjs +0 -15
- package/dist/useAriaLive-MkYebyUR.mjs +0 -35
- package/dist/useDimensions-CeDR9V8N.mjs +0 -36
- package/dist/useInsightsEnabled-DaNLPmUU.mjs +0 -11
- package/dist/useScreenSize-mWpmnh5w.mjs +0 -36
- package/dist/useWidgetLoadTimer-CJb-RELP.mjs +0 -19
|
@@ -0,0 +1,4047 @@
|
|
|
1
|
+
import { d as fe, f as G, h as l, i as S, l as z, n as Z, p as Dt, s as C, t as ye, u as he } from "./GlobalCopyApi-BeXzaDH9.mjs";
|
|
2
|
+
import { CategoryIconList as Tt } from "@mxenabled/mxui";
|
|
3
|
+
import { addDays as Ie } from "date-fns/addDays";
|
|
4
|
+
import { addMonths as P } from "date-fns/addMonths";
|
|
5
|
+
import { endOfMonth as B } from "date-fns/endOfMonth";
|
|
6
|
+
import { format as K } from "date-fns/format";
|
|
7
|
+
import { isBefore as I } from "date-fns/isBefore";
|
|
8
|
+
import { startOfMonth as M } from "date-fns/startOfMonth";
|
|
9
|
+
import { startOfToday as R } from "date-fns/startOfToday";
|
|
10
|
+
import { subMonths as k } from "date-fns/subMonths";
|
|
11
|
+
import { intlFormat as yt } from "date-fns/intlFormat";
|
|
12
|
+
import { isSameDay as ue } from "date-fns/isSameDay";
|
|
13
|
+
import { isWithinInterval as at } from "date-fns/isWithinInterval";
|
|
14
|
+
import { addYears as Ae } from "date-fns/addYears";
|
|
15
|
+
import { endOfToday as ge } from "date-fns/endOfToday";
|
|
16
|
+
import { subDays as ee } from "date-fns/subDays";
|
|
17
|
+
import { subYears as St } from "date-fns/subYears";
|
|
18
|
+
import { autorun as Ct, makeAutoObservable as p, observable as Nt, reaction as st, runInAction as g } from "mobx";
|
|
19
|
+
import wt from "posthog-js";
|
|
20
|
+
import _e from "numeral";
|
|
21
|
+
import { differenceInDays as vt } from "date-fns/differenceInDays";
|
|
22
|
+
import { getUnixTime as T } from "date-fns/getUnixTime";
|
|
23
|
+
import { getDate as Se } from "date-fns/getDate";
|
|
24
|
+
import { fromUnixTime as L } from "date-fns/fromUnixTime";
|
|
25
|
+
import { getMonth as J } from "date-fns/getMonth";
|
|
26
|
+
import { fromUnixTime as Ce, isSameDay as Lt } from "date-fns";
|
|
27
|
+
import { isAfter as V } from "date-fns/isAfter";
|
|
28
|
+
import { addQuarters as j } from "date-fns/addQuarters";
|
|
29
|
+
import { addWeeks as te } from "date-fns/addWeeks";
|
|
30
|
+
import { formatISO as rt } from "date-fns/formatISO";
|
|
31
|
+
import { lastDayOfMonth as Ot } from "date-fns/lastDayOfMonth";
|
|
32
|
+
import { nextDay as ae } from "date-fns/nextDay";
|
|
33
|
+
import { parseISO as bt } from "date-fns/parseISO";
|
|
34
|
+
import { setDate as Q } from "date-fns/setDate";
|
|
35
|
+
import { setDay as Mt } from "date-fns/setDay";
|
|
36
|
+
import { setDayOfYear as nt } from "date-fns/setDayOfYear";
|
|
37
|
+
import { subQuarters as it } from "date-fns/subQuarters";
|
|
38
|
+
import { subWeeks as Gt } from "date-fns/subWeeks";
|
|
39
|
+
import { getDay as Pt } from "date-fns/getDay";
|
|
40
|
+
import { addSeconds as Ut } from "date-fns/addSeconds";
|
|
41
|
+
import { differenceInCalendarMonths as Bt } from "date-fns/differenceInCalendarMonths";
|
|
42
|
+
var N = {
|
|
43
|
+
TIME_STAMP_HOUR_MINUTE: {
|
|
44
|
+
hour: "numeric",
|
|
45
|
+
minute: "numeric"
|
|
46
|
+
},
|
|
47
|
+
DAY: { day: "numeric" },
|
|
48
|
+
DAY_OF_WEEK: { weekday: "long" },
|
|
49
|
+
DAY_OF_WEEK_MONTH_DAY: {
|
|
50
|
+
day: "numeric",
|
|
51
|
+
month: "long",
|
|
52
|
+
weekday: "long"
|
|
53
|
+
},
|
|
54
|
+
FULL_MONTH_DAY: {
|
|
55
|
+
day: "numeric",
|
|
56
|
+
month: "long"
|
|
57
|
+
},
|
|
58
|
+
MONTH: { month: "short" },
|
|
59
|
+
MONTH_DAY: {
|
|
60
|
+
day: "numeric",
|
|
61
|
+
month: "short"
|
|
62
|
+
},
|
|
63
|
+
MONTH_LONG: { month: "long" },
|
|
64
|
+
MONTH_SHORT: { month: "short" },
|
|
65
|
+
MONTH_SHORT_YEAR: {
|
|
66
|
+
month: "short",
|
|
67
|
+
year: "numeric"
|
|
68
|
+
},
|
|
69
|
+
MONTH_YEAR: {
|
|
70
|
+
month: "long",
|
|
71
|
+
year: "numeric"
|
|
72
|
+
},
|
|
73
|
+
YEAR_MONTH_DAY: {
|
|
74
|
+
day: "2-digit",
|
|
75
|
+
month: "2-digit",
|
|
76
|
+
year: "numeric"
|
|
77
|
+
},
|
|
78
|
+
MONTH_DAY_YEAR: {
|
|
79
|
+
month: "short",
|
|
80
|
+
day: "2-digit",
|
|
81
|
+
year: "numeric"
|
|
82
|
+
},
|
|
83
|
+
MED_MONTH_SHORT_DAY_FULL_YEAR: {
|
|
84
|
+
month: "short",
|
|
85
|
+
day: "numeric",
|
|
86
|
+
year: "numeric"
|
|
87
|
+
}
|
|
88
|
+
}, w = (e, t) => yt(new Date(e), Object.assign(t), { locale: z() }), se = class {
|
|
89
|
+
fetchInstance;
|
|
90
|
+
constructor(e, t, a) {
|
|
91
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
92
|
+
}
|
|
93
|
+
createAccount = async (e) => this.fetchInstance.post(l.ACCOUNTS, e).then((t) => t.account).catch((t) => t);
|
|
94
|
+
deleteAccount = async (e) => this.fetchInstance.delete(`${l.ACCOUNTS}/${e}`).catch((t) => t);
|
|
95
|
+
getAccounts = async () => this.fetchInstance.get(l.ACCOUNTS).then((e) => e.accounts).catch((e) => e);
|
|
96
|
+
getInstitutions = async () => this.fetchInstance.get(l.INSTITUTIONS).then((e) => e).catch((e) => e);
|
|
97
|
+
getMembers = async () => this.fetchInstance.get(l.MEMBERS).then((e) => e.members).catch((e) => e);
|
|
98
|
+
getMonthlyAccountBalances = async (e) => this.fetchInstance.get(`${l.ACCOUNTS}/${e}/monthly_account_balances`).then((t) => t.monthly_account_balances).catch((t) => t);
|
|
99
|
+
mergeAccounts = async (e) => this.fetchInstance.put(`${l.ACCOUNTS}/merge`, { accounts: e }).then((t) => t).catch((t) => t);
|
|
100
|
+
refreshAllMembers = async () => this.fetchInstance.get(`${l.MEMBERS}/refresh_all`).then((e) => e).catch((e) => e);
|
|
101
|
+
updateAccount = async (e) => this.fetchInstance.put(`${l.ACCOUNTS}/${e.guid}`, e).then((t) => t.account).catch((t) => t);
|
|
102
|
+
}, Ne = class {
|
|
103
|
+
fetchInstance;
|
|
104
|
+
constructor(e, t, a) {
|
|
105
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
106
|
+
}
|
|
107
|
+
getAppData = async () => this.fetchInstance.get(l.APP_DATA).then((e) => e);
|
|
108
|
+
}, we = class {
|
|
109
|
+
fetchInstance;
|
|
110
|
+
constructor(e) {
|
|
111
|
+
this.fetchInstance = new S(e, "", {
|
|
112
|
+
Accept: "application/json",
|
|
113
|
+
"Content-Type": "application/json"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
getBanner = async (e) => {
|
|
117
|
+
try {
|
|
118
|
+
const t = `/banner/${e}/account_widget_banner`;
|
|
119
|
+
return this.fetchInstance?.get(t).then((a) => a.banner) ?? {};
|
|
120
|
+
} catch (t) {
|
|
121
|
+
return console.error("Error fetching banner:", t), null;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}, ve = class {
|
|
125
|
+
fetchInstance;
|
|
126
|
+
constructor(e, t, a) {
|
|
127
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
128
|
+
}
|
|
129
|
+
addBudget = async (e, t, a = null) => this.fetchInstance.post(l.BUDGETS, {
|
|
130
|
+
amount: t,
|
|
131
|
+
category_guid: e.guid,
|
|
132
|
+
category_name: e.name,
|
|
133
|
+
parent_guid: a
|
|
134
|
+
}).then((s) => s.budget).catch((s) => {
|
|
135
|
+
throw s;
|
|
136
|
+
});
|
|
137
|
+
deleteBudget = async (e) => this.fetchInstance.delete(`${l.BUDGETS}/${e}`).then((t) => t).catch((t) => {
|
|
138
|
+
throw t;
|
|
139
|
+
});
|
|
140
|
+
getBudgets = async () => this.fetchInstance.get(l.BUDGETS).then((e) => e.budgets).catch((e) => e);
|
|
141
|
+
updateBudget = async (e) => this.fetchInstance.put(`${l.BUDGETS}/${e.guid}`, e).then((t) => t.budget).catch((t) => {
|
|
142
|
+
throw t;
|
|
143
|
+
});
|
|
144
|
+
addMerchantBudget = async (e, t) => this.fetchInstance.post(l.MERCHANT_BUDGETS, {
|
|
145
|
+
amount: t,
|
|
146
|
+
merchant_guid: e
|
|
147
|
+
}).then((a) => a.merchant_budget).catch((a) => {
|
|
148
|
+
throw a;
|
|
149
|
+
});
|
|
150
|
+
updateMerchantBudget = async (e, t) => this.fetchInstance.put(`${l.MERCHANT_BUDGETS}/${e}`, { amount: t }).then((a) => a.merchant_budget).catch((a) => {
|
|
151
|
+
throw a;
|
|
152
|
+
});
|
|
153
|
+
deleteMerchantBudget = async (e) => this.fetchInstance.delete(`${l.MERCHANT_BUDGETS}/${e}`).then((t) => t).catch((t) => {
|
|
154
|
+
throw t;
|
|
155
|
+
});
|
|
156
|
+
}, Le = class {
|
|
157
|
+
fetchInstance;
|
|
158
|
+
constructor(e, t, a) {
|
|
159
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
160
|
+
}
|
|
161
|
+
addCategory = async (e) => this.fetchInstance.post(l.CATEGORIES, e).then((t) => t.category);
|
|
162
|
+
getCategories = async () => this.fetchInstance.get(l.CATEGORIES).then((e) => e.categories);
|
|
163
|
+
getDateRangeCategoryTotals = async (e, t, a) => a.length === 0 ? [] : this.fetchInstance.post(`${l.DATE_RANGE_CATEGORY_TOTALS}/from/${e}/to/${t}`, { account_guid: a.map((s) => s.guid) }).then((s) => s.date_range_category_totals);
|
|
164
|
+
getMonthlyCategoryTotals = async (e, t, a) => {
|
|
165
|
+
try {
|
|
166
|
+
const s = `${l.MONTHLY_CATEGORY_TOTALS}/from/${e}/to/${t}`;
|
|
167
|
+
if (a) {
|
|
168
|
+
const r = a.length === 0 ? [""] : a.map((n) => n.guid);
|
|
169
|
+
return (await this.fetchInstance.post(s, { account_guid: r })).monthly_category_totals;
|
|
170
|
+
} else return (await this.fetchInstance.get(s)).monthly_category_totals;
|
|
171
|
+
} catch (s) {
|
|
172
|
+
throw console.error("Error fetching monthly category totals:", s), s;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
removeCategory = async (e) => this.fetchInstance.delete(`${l.CATEGORIES}/${e}`);
|
|
176
|
+
updateCategory = async (e) => this.fetchInstance.put(`${l.CATEGORIES}/${e.guid}`, e).then((t) => t.category);
|
|
177
|
+
}, Oe = class {
|
|
178
|
+
fetchInstance;
|
|
179
|
+
constructor(e, t, a) {
|
|
180
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
181
|
+
}
|
|
182
|
+
calculateHealthScore = async () => this.fetchInstance.post(`${l.HEALTH_SCORES}/calculate`).then((e) => e.health_score);
|
|
183
|
+
getAverageHealthScores = async () => this.fetchInstance.get(`${l.HEALTH_SCORES}/monthly_averages`).then((e) => e);
|
|
184
|
+
getDebtSpend = async () => this.fetchInstance.get(`${l.HEALTH_SCORES}/transactions/debt_spend`).then((e) => e);
|
|
185
|
+
getIncome = async () => this.fetchInstance.get(`${l.HEALTH_SCORES}/transactions/income`).then((e) => e);
|
|
186
|
+
getMonthlySummaries = async () => this.fetchInstance.get(`${l.HEALTH_SCORES}/monthly_summaries`).then((e) => e);
|
|
187
|
+
getHealthScoreChangeReports = async (e, t) => this.fetchInstance.get(`${l.HEALTH_SCORES}/change_report/from/${e}/to/${t}`).then((a) => a);
|
|
188
|
+
getPeerScore = async (e) => this.fetchInstance.get(`${l.HEALTH_SCORES}/average/${e}`).then((t) => t);
|
|
189
|
+
getSpendingFeeTransactions = async () => this.fetchInstance.get(`${l.HEALTH_SCORES}/transactions/spending_fee`).then((e) => e);
|
|
190
|
+
getStandardSpend = async () => this.fetchInstance.get(`${l.HEALTH_SCORES}/transactions/standard_spend`).then((e) => e);
|
|
191
|
+
}, be = class {
|
|
192
|
+
fetchInstance;
|
|
193
|
+
constructor(e, t, a) {
|
|
194
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
195
|
+
}
|
|
196
|
+
addGoal = async (e) => this.fetchInstance.post(l.GOALS, e).then((t) => t.goal);
|
|
197
|
+
addRetirementGoal = async (e) => this.fetchInstance.post(l.RETIREMENT_GOALS, e).then((t) => t.retirement_goal);
|
|
198
|
+
addRetirementGoalAccount = async (e) => this.fetchInstance.post(l.RETIREMENT_GOAL_ACCOUNTS, e).then((t) => t.retirement_goal_account);
|
|
199
|
+
getGoalByGuid = async (e) => this.fetchInstance.get(`${l.GOALS}/${e}`).then((t) => t.goal);
|
|
200
|
+
getGoals = async () => this.fetchInstance.get(l.GOALS).then((e) => e.goals);
|
|
201
|
+
getMonthlyCashFlowProfile = async () => this.fetchInstance.get(l.MONTHLY_CASH_FLOW_PROFILE).then((e) => e.monthly_cash_flow_profile);
|
|
202
|
+
getRetirementGoals = async () => this.fetchInstance.get(l.RETIREMENT_GOALS).then((e) => e.retirement_goals);
|
|
203
|
+
getRetirementGoalAccounts = async () => this.fetchInstance.get(l.RETIREMENT_GOAL_ACCOUNTS).then((e) => e.retirement_goal_accounts);
|
|
204
|
+
removeGoal = async (e) => this.fetchInstance.delete(`${l.GOALS}/${e}`).then((t) => t);
|
|
205
|
+
removeRetirementGoal = async (e) => this.fetchInstance.delete(`${l.RETIREMENT_GOALS}/${e}`).then((t) => t);
|
|
206
|
+
removeRetirementGoalAccount = async (e) => this.fetchInstance.delete(`${l.RETIREMENT_GOAL_ACCOUNTS}/${e}`).then((t) => t);
|
|
207
|
+
reorderGoals = async (e) => this.fetchInstance.post(`${l.GOALS}/reposition`, { goals: e }).then((t) => t.goals);
|
|
208
|
+
updateGoal = async (e) => this.fetchInstance.put(`${l.GOALS}/${e.guid}`, e).then((t) => t.goal);
|
|
209
|
+
updateMonthlyCashFlowProfile = async (e) => this.fetchInstance.put(`${l.MONTHLY_CASH_FLOW_PROFILE}`, e).then((t) => t.monthly_cash_flow_profile);
|
|
210
|
+
updateRetirementGoal = async (e) => this.fetchInstance.put(`${l.RETIREMENT_GOALS}/${e.guid}`, e).then((t) => t.retirement_goal);
|
|
211
|
+
}, Me = class {
|
|
212
|
+
fetchInstance;
|
|
213
|
+
constructor(e, t, a) {
|
|
214
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
215
|
+
}
|
|
216
|
+
createSupportTicket = async (e) => this.fetchInstance.post(l.SUPPORT_TICKETS, e).then((t) => t);
|
|
217
|
+
}, Ge = class {
|
|
218
|
+
fetchInstance;
|
|
219
|
+
constructor(e, t, a) {
|
|
220
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
221
|
+
}
|
|
222
|
+
getHoldings = async () => this.fetchInstance.get(l.HOLDINGS).then((e) => e.holdings);
|
|
223
|
+
updateHoldings = async (e) => this.fetchInstance.put(`${l.HOLDINGS}/${e.guid}`, e).then((t) => t.holding);
|
|
224
|
+
}, Pe = class {
|
|
225
|
+
fetchInstance;
|
|
226
|
+
constructor(e, t, a) {
|
|
227
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
228
|
+
}
|
|
229
|
+
getMerchants = async (e = [], t = [], a = 1, s = 25) => {
|
|
230
|
+
let r = l.MERCHANTS;
|
|
231
|
+
return r += `?page=${a}&per_page=${s}`, e.length && e.forEach((n) => r += `&fuzzy_name[]=${n}`), t.length && t.forEach((n) => r += `&guid[]=${n}`), this.fetchInstance.get(r).then((n) => n.merchants);
|
|
232
|
+
};
|
|
233
|
+
getMerchantByGuid = async (e) => this.fetchInstance.get(`${l.MERCHANTS}/${e}`).then((t) => t.merchant);
|
|
234
|
+
}, Ue = class {
|
|
235
|
+
fetchInstance;
|
|
236
|
+
constructor(e, t, a) {
|
|
237
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
238
|
+
}
|
|
239
|
+
getNotifications = () => this.fetchInstance.get(l.NOTIFICATIONS).then((e) => e.notifications.map((t) => t.notification)).finally();
|
|
240
|
+
updateNotification = (e) => this.fetchInstance.put(`${l.NOTIFICATIONS}/${e.guid}`, {
|
|
241
|
+
guid: e.guid,
|
|
242
|
+
has_been_viewed: e.has_been_viewed
|
|
243
|
+
}).then((t) => t.notification).finally();
|
|
244
|
+
markAllAsViewed = (e) => this.fetchInstance.put(`${l.NOTIFICATIONS}/mark_all_as_viewed`, { channel: e }).finally();
|
|
245
|
+
}, Be = class {
|
|
246
|
+
fetchInstance;
|
|
247
|
+
constructor(e, t, a) {
|
|
248
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
249
|
+
}
|
|
250
|
+
addRepeatingTransaction = async (e) => this.fetchInstance.post(l.REPEATING_TRANSACTIONS, e).then((t) => t.repeating_transaction);
|
|
251
|
+
getRepeatingTransactions = async () => this.fetchInstance.get(l.REPEATING_TRANSACTIONS).then((e) => e.repeating_transactions);
|
|
252
|
+
updateRepeatingTransaction = async (e) => this.fetchInstance.put(`${l.REPEATING_TRANSACTIONS}/${e.guid}`, e).then((t) => t.repeating_transaction);
|
|
253
|
+
deleteRepeatingTransaction = async (e) => this.fetchInstance.delete(`${l.REPEATING_TRANSACTIONS}/${e}`).then((t) => t);
|
|
254
|
+
}, Ur = class {
|
|
255
|
+
fetchInstance;
|
|
256
|
+
constructor(e, t, a) {
|
|
257
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
258
|
+
}
|
|
259
|
+
addScheduledPayment = async (e) => this.fetchInstance.post(l.SCHEDULED_PAYMENTS, {
|
|
260
|
+
...e,
|
|
261
|
+
is_recurring: "true",
|
|
262
|
+
transaction_type: oe.DEBIT
|
|
263
|
+
}).then((t) => t.scheduled_payment);
|
|
264
|
+
getScheduledPayments = async () => this.fetchInstance.get(l.SCHEDULED_PAYMENTS).then((e) => e.scheduled_payments);
|
|
265
|
+
updateScheduledPayment = async (e) => this.fetchInstance.put(`${l.SCHEDULED_PAYMENTS}/${e.guid}`, e).then((t) => t.scheduled_payment);
|
|
266
|
+
deleteScheduledPayment = async (e) => this.fetchInstance.delete(`${l.SCHEDULED_PAYMENTS}/${e}`).then((t) => t);
|
|
267
|
+
}, xe = class {
|
|
268
|
+
fetchInstance;
|
|
269
|
+
constructor(e, t, a) {
|
|
270
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
271
|
+
}
|
|
272
|
+
deleteDevice = async (e) => this.fetchInstance.delete(`${l.DEVICES}/${e}`).then((t) => t);
|
|
273
|
+
generateDeviceToken = async () => this.fetchInstance.get(`${l.USER}/mobile_token`).then((e) => e.mobile_token);
|
|
274
|
+
getDevices = async () => this.fetchInstance.get(l.DEVICES).then((e) => e.map((t) => t.device));
|
|
275
|
+
getNotificationProfiles = async () => this.fetchInstance.get(l.NOTIFICATION_PROFILES).then((e) => e.notification_profiles);
|
|
276
|
+
sendEmailVerification = async () => this.fetchInstance.post(l.EMAIL_VERIFICATIONS);
|
|
277
|
+
sendPhoneVerification = async () => this.fetchInstance.post(l.PHONE_VERIFICATIONS + "/deliver");
|
|
278
|
+
verifyPhoneToken = async (e) => this.fetchInstance.post(l.PHONE_VERIFICATIONS + "/verify", { sms_verification_token: e }).then((t) => ({ verified: t.verified }));
|
|
279
|
+
updateDevice = async (e) => this.fetchInstance.put(`${l.DEVICES}/${e.guid}`, e).then((t) => t.device);
|
|
280
|
+
updateNotificationProfile = async (e) => this.fetchInstance.put(`${l.NOTIFICATION_PROFILES}/${e.guid}`, e).then((t) => t.notification_profile);
|
|
281
|
+
updateUserCommunicationProfile = async (e) => this.fetchInstance.put(l.USER_COMMUNICATION_PROFILE, e).then((t) => t.user_communication_profile);
|
|
282
|
+
getInsightsNotificationProfiles = async () => this.fetchInstance.get(`${l.NOTIFICATION_PROFILES}/${l.INSIGHTS_NOTIFICATION_PROFILES}`).then((e) => e);
|
|
283
|
+
}, re = class {
|
|
284
|
+
fetchInstance;
|
|
285
|
+
constructor(e, t, a) {
|
|
286
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
287
|
+
}
|
|
288
|
+
addTag = async (e) => this.fetchInstance.post(l.TAGS, e).then((t) => t.tag).catch((t) => t);
|
|
289
|
+
addTagging = async (e) => this.fetchInstance.post(l.TAGGINGS, e).then((t) => t.tagging).catch((t) => t);
|
|
290
|
+
addTransaction = async (e) => this.fetchInstance.post(l.TRANSACTIONS, e).then((t) => t.transaction).catch((t) => t);
|
|
291
|
+
addTransactionRule = async (e) => this.fetchInstance.post(l.TRANSACTION_RULES, e).then((t) => t).catch((t) => t);
|
|
292
|
+
getTaggings = async () => this.fetchInstance.get(l.TAGGINGS).then((e) => e.map((t) => t.tagging));
|
|
293
|
+
getTags = async () => this.fetchInstance.get(l.TAGS).then((e) => e.map((t) => t.tag));
|
|
294
|
+
getTransactionRules = async () => this.fetchInstance.get(l.TRANSACTION_RULES).then((e) => e.transaction_rules);
|
|
295
|
+
getTransactionsByDateRange = async (e, t) => this.fetchInstance.get(`${l.TRANSACTIONS}/by_date/${e}/${t}`).then((a) => a.map((s) => s.transaction));
|
|
296
|
+
getTransactionsByAccountsAndDateRange = async (e, t, a) => {
|
|
297
|
+
console.warn("DEPRECATED: getTransactionsByAccountsAndDateRange will be removed");
|
|
298
|
+
const s = e.reduce((r, n, i) => `${r}account_guids[]=${n}${i !== e.length - 1 ? "&" : ""}`, "");
|
|
299
|
+
return this.fetchInstance.get(`${l.TRANSACTIONS}/by_date/${t}/${a}?${s}`).then((r) => r.map((n) => n.transaction));
|
|
300
|
+
};
|
|
301
|
+
getTransactionsByGuids = async (e) => (console.warn("DEPRECATED: getTransactionsByGuids will be removed"), this.fetchInstance.post(`${l.TRANSACTIONS}/by_guids`, { guids: e.join("+") }).then((t) => t.map((a) => a.transaction)));
|
|
302
|
+
getTransactionsByCategoryAndDate = async (e, t, a) => (console.warn("DEPRECATED: getTransactionsByCategoryAndDate will be removed"), this.fetchInstance.get(`${l.TRANSACTIONS}/by_category_guid/${e}/by_date/${t}/${a}`).then((s) => s.map((r) => r.transaction)));
|
|
303
|
+
getTransactionsByCategoryDateAndAccounts = async (e, t, a, s) => {
|
|
304
|
+
console.warn("DEPRECATED: getTransactionsByCategoryDateAndAccounts will be removed");
|
|
305
|
+
const r = s.reduce((n, i, o) => `${n}account_guids[]=${i}${o !== s.length - 1 ? "&" : ""}`, "");
|
|
306
|
+
return this.fetchInstance.get(`${l.TRANSACTIONS}/by_category_guid/${e}/by_date/${t}/${a}?${r}`).then((n) => n.map((i) => i.transaction));
|
|
307
|
+
};
|
|
308
|
+
getTransactionsByCategoriesDateAndAccounts = async (e, t, a, s) => {
|
|
309
|
+
console.warn("DEPRECATED: getTransactionsByCategoriesDateAndAccounts will be removed");
|
|
310
|
+
const r = s.reduce((n, i, o) => `${n}account_guids[]=${i}${o !== s.length - 1 ? "&" : ""}`, "");
|
|
311
|
+
return this.fetchInstance.get(`${l.TRANSACTIONS}/by_category_guids/${e.join("+")}/by_date/${t}/${a}?${r}`).then((n) => n.map((i) => i.transaction));
|
|
312
|
+
};
|
|
313
|
+
getTransactionsByTopLevelCategoryAndDate = async (e, t, a, s = []) => {
|
|
314
|
+
console.warn("DEPRECATED: getTransactionsByTopLevelCategoryAndDate will be removed");
|
|
315
|
+
let r = `${l.TRANSACTIONS}/by_top_level_category_guid/${e}/by_date/${t}/${a}`;
|
|
316
|
+
if (s.length > 0) {
|
|
317
|
+
const n = s.reduce((i, o, c) => `${i}account_guids[]=${o}${c !== s.length - 1 ? "&" : ""}`, "");
|
|
318
|
+
r += `?${n}`;
|
|
319
|
+
}
|
|
320
|
+
return this.fetchInstance.get(r).then((n) => n.map((i) => i.transaction));
|
|
321
|
+
};
|
|
322
|
+
removeTag = async (e) => this.fetchInstance.delete(`${l.TAGS}/${e}`).then((t) => t).catch((t) => t);
|
|
323
|
+
removeTagging = async (e) => this.fetchInstance.delete(`${l.TAGGINGS}/${e}`).then((t) => t).catch((t) => t);
|
|
324
|
+
removeTransaction = async (e) => this.fetchInstance.delete(`${l.TRANSACTIONS}/${e}`).then((t) => t);
|
|
325
|
+
removeTransactionRule = async (e) => this.fetchInstance.delete(`${l.TRANSACTION_RULES}/${e}`).catch((t) => t);
|
|
326
|
+
removeTransactionSplit = async (e) => this.fetchInstance.delete(`${l.TRANSACTIONS}/${e}/unsplit`).then((t) => t).catch((t) => t);
|
|
327
|
+
updateTransactionRule = async (e) => this.fetchInstance.put(`${l.TRANSACTION_RULES}/${e.guid}`, e).then((t) => t).catch((t) => t);
|
|
328
|
+
updateTag = async (e) => this.fetchInstance.put(`${l.TAGS}/${e.guid}`, e).then((t) => t.tag).catch((t) => t);
|
|
329
|
+
updateTransaction = async (e) => this.fetchInstance.put(`${l.TRANSACTIONS}/${e.guid}`, e).then((t) => t.transaction).catch((t) => t);
|
|
330
|
+
}, He = class {
|
|
331
|
+
fetchInstance;
|
|
332
|
+
constructor(e, t, a) {
|
|
333
|
+
this.fetchInstance = new S(e, t, void 0, a);
|
|
334
|
+
}
|
|
335
|
+
getUserFeatures = async () => this.fetchInstance.get(l.USER_FEATURES).then((e) => e.user_features).catch((e) => e);
|
|
336
|
+
updateUser = async (e) => this.fetchInstance.put(l.USER, e).then((t) => t.user);
|
|
337
|
+
updateUserProfile = async (e) => this.fetchInstance.put(`${l.USER_PROFILES}/${e.guid}`, e).then((t) => t.user_profile);
|
|
338
|
+
}, $e = class {
|
|
339
|
+
fetchInstance;
|
|
340
|
+
constructor(e, t) {
|
|
341
|
+
this.fetchInstance = new S(e, t);
|
|
342
|
+
}
|
|
343
|
+
requestWidgetUrl = async (e) => this.fetchInstance.post(l.WIDGET_URLS, e).then((t) => t.widget_url);
|
|
344
|
+
}, u = /* @__PURE__ */ (function(e) {
|
|
345
|
+
return e[e.ANY = 0] = "ANY", e[e.CHECKING = 1] = "CHECKING", e[e.SAVINGS = 2] = "SAVINGS", e[e.LOAN = 3] = "LOAN", e[e.CREDIT_CARD = 4] = "CREDIT_CARD", e[e.INVESTMENT = 5] = "INVESTMENT", e[e.LINE_OF_CREDIT = 6] = "LINE_OF_CREDIT", e[e.MORTGAGE = 7] = "MORTGAGE", e[e.PROPERTY = 8] = "PROPERTY", e[e.CASH = 9] = "CASH", e[e.INSURANCE = 10] = "INSURANCE", e[e.PREPAID = 11] = "PREPAID", e[e.CHECKING_LINE_OF_CREDIT = 12] = "CHECKING_LINE_OF_CREDIT", e[e.DIGITAL_WALLET = 13] = "DIGITAL_WALLET", e;
|
|
346
|
+
})({}), ce = /* @__PURE__ */ (function(e) {
|
|
347
|
+
return e[e.NONE = 0] = "NONE", e[e.MONEY_MARKET = 1] = "MONEY_MARKET", e[e.CERTIFICATE_OF_DEPOSIT = 2] = "CERTIFICATE_OF_DEPOSIT", e[e.AUTO = 3] = "AUTO", e[e.STUDENT = 4] = "STUDENT", e[e.SMALL_BUSINESS = 5] = "SMALL_BUSINESS", e[e.PERSONAL = 6] = "PERSONAL", e[e.PERSONAL_WITH_COLLATERAL = 7] = "PERSONAL_WITH_COLLATERAL", e[e.HOME_EQUITY = 8] = "HOME_EQUITY", e[e.PLAN_401_K = 9] = "PLAN_401_K", e[e.PLAN_403_B = 10] = "PLAN_403_B", e[e.PLAN_529 = 11] = "PLAN_529", e[e.IRA = 12] = "IRA", e[e.ROLLOVER_IRA = 13] = "ROLLOVER_IRA", e[e.ROTH_IRA = 14] = "ROTH_IRA", e[e.TAXABLE = 15] = "TAXABLE", e[e.NON_TAXABLE = 16] = "NON_TAXABLE", e[e.BROKERAGE = 17] = "BROKERAGE", e[e.TRUST = 18] = "TRUST", e[e.UNIFORM_GIFTS_TO_MINORS_ACT = 19] = "UNIFORM_GIFTS_TO_MINORS_ACT", e[e.PLAN_457 = 20] = "PLAN_457", e[e.PENSION = 21] = "PENSION", e[e.EMPLOYEE_STOCK_OWNERSHIP_PLAN = 22] = "EMPLOYEE_STOCK_OWNERSHIP_PLAN", e[e.SIMPLIFIED_EMPLOYEE_PENSION = 23] = "SIMPLIFIED_EMPLOYEE_PENSION", e[e.SIMPLE_IRA = 24] = "SIMPLE_IRA", e[e.BOAT = 25] = "BOAT", e[e.POWERSPORTS = 26] = "POWERSPORTS", e[e.RV = 27] = "RV", e[e.HELOC = 28] = "HELOC", e[e.PLAN_ROTH_401_K = 29] = "PLAN_ROTH_401_K", e[e.FIXED_ANNUITY = 30] = "FIXED_ANNUITY", e[e.VARIABLE_ANNUITY = 31] = "VARIABLE_ANNUITY", e[e.VEHICLE_INSURANCE = 32] = "VEHICLE_INSURANCE", e[e.DISABILITY = 33] = "DISABILITY", e[e.HEALTH = 34] = "HEALTH", e[e.LONG_TERM_CARE = 35] = "LONG_TERM_CARE", e[e.PROPERTY_AND_CASUALTY = 36] = "PROPERTY_AND_CASUALTY", e[e.UNIVERSAL_LIFE = 37] = "UNIVERSAL_LIFE", e[e.TERM_LIFE = 38] = "TERM_LIFE", e[e.WHOLE_LIFE = 39] = "WHOLE_LIFE", e[e.ACCIDENTAL_DEATH_AND_DISMEMBERMENT = 40] = "ACCIDENTAL_DEATH_AND_DISMEMBERMENT", e[e.VARIABLE_UNIVERSAL_LIFE = 41] = "VARIABLE_UNIVERSAL_LIFE", e[e.HSA = 42] = "HSA", e[e.TAX_FREE_SAVINGS_ACCOUNT = 43] = "TAX_FREE_SAVINGS_ACCOUNT", e[e.INDIVIDUAL = 44] = "INDIVIDUAL", e[e.REGISTERED_RETIREMENT_INCOME_FUND = 45] = "REGISTERED_RETIREMENT_INCOME_FUND", e[e.CASH_MANAGEMENT_ACCOUNT = 46] = "CASH_MANAGEMENT_ACCOUNT", e[e.EMPLOYEE_STOCK_PURCHASE_PLAN = 47] = "EMPLOYEE_STOCK_PURCHASE_PLAN", e[e.REGISTERED_EDUCATION_SAVINGS_PLAN = 48] = "REGISTERED_EDUCATION_SAVINGS_PLAN", e[e.PROFIT_SHARING_PLAN = 49] = "PROFIT_SHARING_PLAN", e[e.UNIFORM_TRANSFER_TO_MINORS_ACT = 50] = "UNIFORM_TRANSFER_TO_MINORS_ACT", e[e.PLAN_401_A = 51] = "PLAN_401_A", e[e.SARSEP_IRA = 52] = "SARSEP_IRA", e[e.FIXED_ANNUITY_TRADITIONAL_IRA = 53] = "FIXED_ANNUITY_TRADITIONAL_IRA", e[e.VARIABLE_ANNUITY_TRADITIONAL_IRA = 54] = "VARIABLE_ANNUITY_TRADITIONAL_IRA", e[e.SEPP_IRA = 55] = "SEPP_IRA", e[e.INHERITED_TRADITIONAL_IRA = 56] = "INHERITED_TRADITIONAL_IRA", e[e.FIXED_ANNUITY_ROTH_IRA = 57] = "FIXED_ANNUITY_ROTH_IRA", e[e.VARIABLE_ANNUITY_ROTH_IRA = 58] = "VARIABLE_ANNUITY_ROTH_IRA", e[e.INHERITED_ROTH_IRA = 59] = "INHERITED_ROTH_IRA", e[e.COVERDELL = 60] = "COVERDELL", e[e.ADVISORY_ACCOUNT = 61] = "ADVISORY_ACCOUNT", e[e.BROKERAGE_MARGIN = 62] = "BROKERAGE_MARGIN", e[e.CHARITABLE_GIFT_ACCOUNT = 63] = "CHARITABLE_GIFT_ACCOUNT", e[e.CHURCH_ACCOUNT = 64] = "CHURCH_ACCOUNT", e[e.CONSERVATORSHIP = 65] = "CONSERVATORSHIP", e[e.CUSTODIAL = 66] = "CUSTODIAL", e[e.DEFINED_BENEFIT_PLAN = 67] = "DEFINED_BENEFIT_PLAN", e[e.DEFINED_CONTRIBUTION_PLAN = 68] = "DEFINED_CONTRIBUTION_PLAN", e[e.EDUCATIONAL = 69] = "EDUCATIONAL", e[e.ESTATE = 70] = "ESTATE", e[e.EXECUTOR = 71] = "EXECUTOR", e[e.GROUP_RETIREMENT_SAVINGS_PLAN = 72] = "GROUP_RETIREMENT_SAVINGS_PLAN", e[e.GUARANTEED_INVESTMENT_CERTIFICATE = 73] = "GUARANTEED_INVESTMENT_CERTIFICATE", e[e.HRA = 74] = "HRA", e[e.INDEXED_ANNUITY = 75] = "INDEXED_ANNUITY", e[e.INVESTMENT_CLUB = 76] = "INVESTMENT_CLUB", e[e.IRREVOCABLE_TRUST = 77] = "IRREVOCABLE_TRUST", e[e.JOINT_TENANTS_BY_ENTIRITY = 78] = "JOINT_TENANTS_BY_ENTIRITY", e[e.JOINT_TENANTS_COMMUNITY_PROPERTY = 79] = "JOINT_TENANTS_COMMUNITY_PROPERTY", e[e.JOINT_TENANTS_IN_COMMON = 80] = "JOINT_TENANTS_IN_COMMON", e[e.JOINT_TENANTS_WITH_RIGHTS_OF_SURVIVORSHIP = 81] = "JOINT_TENANTS_WITH_RIGHTS_OF_SURVIVORSHIP", e[e.KEOUGH_PLAN = 82] = "KEOUGH_PLAN", e[e.LIFE_INCOME_FUND = 83] = "LIFE_INCOME_FUND", e[e.LIVING_TRUST = 84] = "LIVING_TRUST", e[e.LOCKED_IN_RETIREMENT_ACCOUNT = 85] = "LOCKED_IN_RETIREMENT_ACCOUNT", e[e.LOCKED_IN_RETIREMENT_INVESTMENT_FUND = 86] = "LOCKED_IN_RETIREMENT_INVESTMENT_FUND", e[e.LOCKED_IN_RETIREMENT_SAVINGS_ACCOUNT = 87] = "LOCKED_IN_RETIREMENT_SAVINGS_ACCOUNT", e[e.MONEY_PURCHASE_PLAN = 88] = "MONEY_PURCHASE_PLAN", e[e.PARTNERSHIP = 89] = "PARTNERSHIP", e[e.PLAN_409_A = 90] = "PLAN_409_A", e[e.PLAN_ROTH_403_B = 91] = "PLAN_ROTH_403_B", e[e.REGISTERED_DISABILITY_SAVINGS_PLAN = 92] = "REGISTERED_DISABILITY_SAVINGS_PLAN", e[e.REGISTERED_LOCKED_IN_SAVINGS_PLAN = 93] = "REGISTERED_LOCKED_IN_SAVINGS_PLAN", e[e.REGISTERED_PENSION_PLAN = 94] = "REGISTERED_PENSION_PLAN", e[e.REGISTERED_RETIREMENT_SAVINGS_PLAN = 95] = "REGISTERED_RETIREMENT_SAVINGS_PLAN", e[e.REVOCABLE_TRUST = 96] = "REVOCABLE_TRUST", e[e.ROTH_CONVERSION = 97] = "ROTH_CONVERSION", e[e.SOLE_PROPRIETORSHIP = 98] = "SOLE_PROPRIETORSHIP", e[e.SPOUSAL_IRA = 99] = "SPOUSAL_IRA", e[e.SPOUSAL_ROTH_IRA = 100] = "SPOUSAL_ROTH_IRA", e[e.TESTAMENTARY_TRUST = 101] = "TESTAMENTARY_TRUST", e[e.THRIFT_SAVINGS_PLAN = 102] = "THRIFT_SAVINGS_PLAN", e[e.INHERITED_ANNUITY = 103] = "INHERITED_ANNUITY", e[e.CORPORATE_ACCOUNT = 104] = "CORPORATE_ACCOUNT", e[e.LIMITED_LIABILITY_ACCOUNT = 105] = "LIMITED_LIABILITY_ACCOUNT", e[e.HSA_SAVINGS = 106] = "HSA_SAVINGS", e[e.HSA_CHECKING = 107] = "HSA_CHECKING", e;
|
|
348
|
+
})({}), Br = /* @__PURE__ */ (function(e) {
|
|
349
|
+
return e[e.REAL_ESTATE = 0] = "REAL_ESTATE", e[e.VEHICLE = 1] = "VEHICLE", e[e.ART = 2] = "ART", e[e.JEWELRY = 3] = "JEWELRY", e[e.FURNITURE = 4] = "FURNITURE", e[e.APPLIANCES = 5] = "APPLIANCES", e[e.COMPUTER = 6] = "COMPUTER", e[e.ELECTRONICS = 7] = "ELECTRONICS", e[e.SPORTS_EQUIPMENT = 8] = "SPORTS_EQUIPMENT", e[e.MISCELLANEOUS = 9] = "MISCELLANEOUS", e;
|
|
350
|
+
})({}), xr = /* @__PURE__ */ (function(e) {
|
|
351
|
+
return e[e.CREATED = 0] = "CREATED", e[e.PREVENTED = 1] = "PREVENTED", e[e.DENIED = 2] = "DENIED", e[e.CHALLENGED = 3] = "CHALLENGED", e[e.REJECTED = 4] = "REJECTED", e[e.LOCKED = 5] = "LOCKED", e[e.CONNECTED = 6] = "CONNECTED", e[e.IMPEDED = 7] = "IMPEDED", e[e.RECONNECTED = 8] = "RECONNECTED", e[e.DEGRADED = 9] = "DEGRADED", e[e.DISCONNECTED = 10] = "DISCONNECTED", e[e.DISCONTINUED = 11] = "DISCONTINUED", e[e.CLOSED = 12] = "CLOSED", e[e.DELAYED = 13] = "DELAYED", e[e.FAILED = 14] = "FAILED", e[e.UPDATED = 15] = "UPDATED", e[e.DISABLED = 16] = "DISABLED", e[e.IMPORTED = 17] = "IMPORTED", e[e.RESUMED = 18] = "RESUMED", e[e.EXPIRED = 19] = "EXPIRED", e[e.IMPAIRED = 20] = "IMPAIRED", e[e.PENDING = 21] = "PENDING", e;
|
|
352
|
+
})({}), xt = [
|
|
353
|
+
0,
|
|
354
|
+
15,
|
|
355
|
+
18
|
|
356
|
+
], ot = [3, 4], ct = [
|
|
357
|
+
1,
|
|
358
|
+
2,
|
|
359
|
+
5,
|
|
360
|
+
7,
|
|
361
|
+
9,
|
|
362
|
+
10,
|
|
363
|
+
11,
|
|
364
|
+
12,
|
|
365
|
+
13,
|
|
366
|
+
14,
|
|
367
|
+
16,
|
|
368
|
+
17,
|
|
369
|
+
19,
|
|
370
|
+
20
|
|
371
|
+
], Hr = [...ct, ...ot], q = /* @__PURE__ */ (function(e) {
|
|
372
|
+
return e.Connected = "Connected", e.Error = "Error", e.Processing = "Processing", e.RequiresMfa = "RequiresMfa", e;
|
|
373
|
+
})({}), $r = {
|
|
374
|
+
3: "Challenged",
|
|
375
|
+
12: "Closed",
|
|
376
|
+
9: "Degraded",
|
|
377
|
+
13: "Delayed",
|
|
378
|
+
2: "Denied",
|
|
379
|
+
16: "Disabled",
|
|
380
|
+
10: "Disconnected",
|
|
381
|
+
11: "Discontinued",
|
|
382
|
+
19: "Expired",
|
|
383
|
+
14: "Failed",
|
|
384
|
+
20: "Impaired",
|
|
385
|
+
7: "Impeded",
|
|
386
|
+
17: "Imported",
|
|
387
|
+
5: "Locked",
|
|
388
|
+
1: "Prevented",
|
|
389
|
+
4: "Rejected"
|
|
390
|
+
}, Ht = {
|
|
391
|
+
0: "Any",
|
|
392
|
+
9: "Cash",
|
|
393
|
+
1: "Checking",
|
|
394
|
+
12: "Checking Line of Credit",
|
|
395
|
+
4: "Credit Card",
|
|
396
|
+
13: "Digital Wallet",
|
|
397
|
+
10: "Insurance",
|
|
398
|
+
5: "Investment",
|
|
399
|
+
6: "Line of Credit",
|
|
400
|
+
3: "Loan",
|
|
401
|
+
7: "Mortgage",
|
|
402
|
+
11: "Prepaid",
|
|
403
|
+
8: "Property",
|
|
404
|
+
2: "Savings"
|
|
405
|
+
}, $t = {
|
|
406
|
+
0: "account_balance",
|
|
407
|
+
9: "monetization_on",
|
|
408
|
+
1: "checkbook",
|
|
409
|
+
12: "checkbook",
|
|
410
|
+
4: "credit_card",
|
|
411
|
+
13: "wallet",
|
|
412
|
+
10: "monitor_heart",
|
|
413
|
+
5: "trending_up",
|
|
414
|
+
6: "add_credit",
|
|
415
|
+
3: "loans",
|
|
416
|
+
7: "house",
|
|
417
|
+
11: "credit_card",
|
|
418
|
+
8: "key",
|
|
419
|
+
2: "savings"
|
|
420
|
+
}, Ft = { 5: "bid_landscape" }, Fr = {
|
|
421
|
+
0: "Real Estate",
|
|
422
|
+
1: "Vehicle",
|
|
423
|
+
2: "Art",
|
|
424
|
+
3: "Jewelry",
|
|
425
|
+
4: "Furniture",
|
|
426
|
+
5: "Appliances",
|
|
427
|
+
6: "Computer",
|
|
428
|
+
7: "Electronics",
|
|
429
|
+
8: "Sports Equipment",
|
|
430
|
+
9: "Miscellaneous"
|
|
431
|
+
}, kr = {
|
|
432
|
+
0: "home_work",
|
|
433
|
+
1: "directions_car",
|
|
434
|
+
2: "insert_photo",
|
|
435
|
+
3: "diamond",
|
|
436
|
+
4: "chair",
|
|
437
|
+
5: "kitchen",
|
|
438
|
+
6: "computer",
|
|
439
|
+
7: "camera_alt",
|
|
440
|
+
8: "sports_baseball",
|
|
441
|
+
9: "monetization_on"
|
|
442
|
+
}, Vr = /* @__PURE__ */ (function(e) {
|
|
443
|
+
return e[e.UNKNOWN = 0] = "UNKNOWN", e[e.CORRECT = 1] = "CORRECT", e[e.INCORRECT = 2] = "INCORRECT", e;
|
|
444
|
+
})({}), Yr = /* @__PURE__ */ (function(e) {
|
|
445
|
+
return e.Missed = "Missed", e.Paid = "Paid", e.Upcoming = "Upcoming expense", e.Income = "Income", e;
|
|
446
|
+
})({}), Wr = /* @__PURE__ */ (function(e) {
|
|
447
|
+
return e[e.Unknown = 0] = "Unknown", e[e.Subscription = 1] = "Subscription", e[e.Bill = 2] = "Bill", e;
|
|
448
|
+
})({}), y = /* @__PURE__ */ (function(e) {
|
|
449
|
+
return 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;
|
|
450
|
+
})({}), Kr = /* @__PURE__ */ (function(e) {
|
|
451
|
+
return 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;
|
|
452
|
+
})({}), x = /* @__PURE__ */ (function(e) {
|
|
453
|
+
return 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;
|
|
454
|
+
})({}), jr = /* @__PURE__ */ (function(e) {
|
|
455
|
+
return e.Accounts = "accounts", e.Budgets = "budgets", e.Insights = "insights", e.Personal = "personal", e;
|
|
456
|
+
})({}), v = /* @__PURE__ */ (function(e) {
|
|
457
|
+
return e[e.DebtPaymentReminder = 3] = "DebtPaymentReminder", e[e.AccountBalanceLow = 6] = "AccountBalanceLow", e[e.AccountDepositLarge = 7] = "AccountDepositLarge", e[e.TransactionExpenseLarge = 8] = "TransactionExpenseLarge", e[e.TransactionFeeCharge = 9] = "TransactionFeeCharge", e[e.InternationalTransaction = 23] = "InternationalTransaction", e[e.AccountDepositLargePosted = 48] = "AccountDepositLargePosted", e;
|
|
458
|
+
})({}), ne = /* @__PURE__ */ (function(e) {
|
|
459
|
+
return e[e.BudgetExceeded = 1] = "BudgetExceeded", e[e.BudgetOffTarget = 2] = "BudgetOffTarget", e;
|
|
460
|
+
})({}), f = /* @__PURE__ */ (function(e) {
|
|
461
|
+
return e[e.AccountBalanceLow = 33] = "AccountBalanceLow", e[e.AccountDepositHigh = 34] = "AccountDepositHigh", e[e.BillAmountNotStandard = 49] = "BillAmountNotStandard", e[e.BudgetExceeded = 35] = "BudgetExceeded", e[e.BudgetOffTarget = 36] = "BudgetOffTarget", e[e.CategoryBudget = 43] = "CategoryBudget", e[e.CategorySpending = 50] = "CategorySpending", e[e.CreditCardCloseToLimit = 51] = "CreditCardCloseToLimit", e[e.DebtPaymentReminder = 37] = "DebtPaymentReminder", e[e.DebtPaymentReminderV3 = 66] = "DebtPaymentReminderV3", e[e.DiscoveredAccounts = 52] = "DiscoveredAccounts", e[e.DuplicatePayment = 42] = "DuplicatePayment", e[e.GoalProgress = 38] = "GoalProgress", e[e.MonthlySpendComparison = 53] = "MonthlySpendComparison", e[e.MonthlySpendToIncomeComparison = 54] = "MonthlySpendToIncomeComparison", e[e.MonthlySubscriptionAggregate = 55] = "MonthlySubscriptionAggregate", e[e.MonthlyTopMerchantSpending = 56] = "MonthlyTopMerchantSpending", e[e.PromotionalCampaignMessages = 67] = "PromotionalCampaignMessages", e[e.SaveAnExtra100Dollars = 57] = "SaveAnExtra100Dollars", e[e.SavingsOpportunity = 58] = "SavingsOpportunity", e[e.SetUpDirectDeposit = 59] = "SetUpDirectDeposit", e[e.SpendingPlanBudgetExceeded = 45] = "SpendingPlanBudgetExceeded", e[e.SpendingPlanCategorySpending = 44] = "SpendingPlanCategorySpending", e[e.SwitchDirectDeposit = 60] = "SwitchDirectDeposit", e[e.TransactionExpenseLarge = 39] = "TransactionExpenseLarge", e[e.TransactionFeeCharge = 40] = "TransactionFeeCharge", e[e.TransactionIsInternational = 41] = "TransactionIsInternational", e[e.TransparentOverdraft = 68] = "TransparentOverdraft", e[e.UncategorizedTransactions = 61] = "UncategorizedTransactions", e[e.UnifiedDeposit = 62] = "UnifiedDeposit", e[e.UpcomingBill = 63] = "UpcomingBill", e[e.WeekendSpendingSummary = 64] = "WeekendSpendingSummary", e[e.WeeklyNewMerchants = 65] = "WeeklyNewMerchants", e;
|
|
462
|
+
})({}), oe = /* @__PURE__ */ (function(e) {
|
|
463
|
+
return e[e.CREDIT = 1] = "CREDIT", e[e.DEBIT = 2] = "DEBIT", e;
|
|
464
|
+
})({}), lt = /* @__PURE__ */ (function(e) {
|
|
465
|
+
return e[e.POSTED = 1] = "POSTED", e[e.PENDING = 2] = "PENDING", e;
|
|
466
|
+
})({}), Qr = /* @__PURE__ */ (function(e) {
|
|
467
|
+
return e.Desktop = "Desktop", e.Mobile = "Mobile", e;
|
|
468
|
+
})({}), E = /* @__PURE__ */ (function(e) {
|
|
469
|
+
return e[e.Unknown = 0] = "Unknown", e[e.EveryWeek = 1] = "EveryWeek", e[e.EveryOtherWeek = 2] = "EveryOtherWeek", e[e.EveryMonth = 3] = "EveryMonth", e[e.EveryOtherMonth = 4] = "EveryOtherMonth", e[e.EveryQuarter = 5] = "EveryQuarter", e[e.EveryOtherQuarter = 6] = "EveryOtherQuarter", e[e.EveryYear = 7] = "EveryYear", e[e.TwiceAMonth = 8] = "TwiceAMonth", e;
|
|
470
|
+
})({}), O = /* @__PURE__ */ (function(e) {
|
|
471
|
+
return e[e.Paid = 0] = "Paid", e[e.Missed = 1] = "Missed", e[e.Upcoming = 2] = "Upcoming", e;
|
|
472
|
+
})({}), ie = /* @__PURE__ */ (function(e) {
|
|
473
|
+
return e[e.Expense = 0] = "Expense", e[e.Income = 1] = "Income", e;
|
|
474
|
+
})({}), kt = /* @__PURE__ */ (function(e) {
|
|
475
|
+
return e[e.Unknown = 0] = "Unknown", e[e.Subscription = 1] = "Subscription", e[e.Bill = 2] = "Bill", e[e.Income = 3] = "Income", e[e.Transfer = 4] = "Transfer", e;
|
|
476
|
+
})({}), dt = (e) => e && (e.account_type === u.CREDIT_CARD || e.account_type === u.LOAN || e.account_type === u.MORTGAGE || e.account_type === u.LINE_OF_CREDIT || e.account_type === u.CHECKING_LINE_OF_CREDIT), zr = (e) => e.is_manual || !e.guid, Xr = (e) => e.account_type === u.LINE_OF_CREDIT || e.account_type === u.CREDIT_CARD || e.account_type === u.CHECKING_LINE_OF_CREDIT, Jr = (e) => e.account_type === u.SAVINGS || e.account_type === u.CHECKING || e.account_type === u.LINE_OF_CREDIT || e.account_type === u.CREDIT_CARD || e.account_type === u.LOAN || e.account_type === u.MORTGAGE, qr = (e) => e.account_type === u.LOAN || e.account_type === u.MORTGAGE, Vt = (e, t, a, s, r) => e.filter((n) => !(n.member_is_managed_by_user && s)).filter((n) => !(!n.member_is_managed_by_user && r)).sort(Wt).map((n) => Yt(n, t.find((i) => i.guid === n.institution_guid), a.find((i) => i.guid === n.member_guid))), Yt = (e, t, a) => {
|
|
477
|
+
let s = q.Connected;
|
|
478
|
+
a && (ct.includes(a.connection_status) ? s = q.Error : xt.includes(a.connection_status) ? s = q.Processing : ot.includes(a.connection_status) && (s = q.RequiresMfa));
|
|
479
|
+
const r = [e.user_name || e.feed_name || "", e.account_number ? `*${e.account_number}` : ""].join(" ").trim();
|
|
480
|
+
return {
|
|
481
|
+
...e,
|
|
482
|
+
connectionStatus: s,
|
|
483
|
+
displayName: r,
|
|
484
|
+
institution: t,
|
|
485
|
+
member: a
|
|
486
|
+
};
|
|
487
|
+
}, Wt = (e, t) => e.account_type > t.account_type ? 1 : e.account_type < t.account_type ? -1 : (e.name || "") > (t.name || "") ? 1 : (e.name || "") < (t.name || "") ? -1 : 0, Kt = (e, t) => !!e.find((a) => a.feature_name === t)?.is_enabled, jt = class {
|
|
488
|
+
globalStore;
|
|
489
|
+
api = new se("/", "");
|
|
490
|
+
accounts = [];
|
|
491
|
+
accountsLoaded = !1;
|
|
492
|
+
accountsLoading = !1;
|
|
493
|
+
institutions = [];
|
|
494
|
+
institutionsLoaded = !1;
|
|
495
|
+
institutionsLoading = !1;
|
|
496
|
+
members = [];
|
|
497
|
+
membersLoaded = !1;
|
|
498
|
+
membersLoading = !1;
|
|
499
|
+
uiStore;
|
|
500
|
+
constructor(e) {
|
|
501
|
+
this.globalStore = e, this.uiStore = new Qt(), this.api = new se(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
502
|
+
}
|
|
503
|
+
loadAccountData = async () => {
|
|
504
|
+
await Promise.all([
|
|
505
|
+
this.loadAccounts(),
|
|
506
|
+
this.loadMembers(),
|
|
507
|
+
this.loadInstitutions()
|
|
508
|
+
]);
|
|
509
|
+
};
|
|
510
|
+
get isAccountDataLoaded() {
|
|
511
|
+
return this.accountsLoaded && this.membersLoaded && this.institutionsLoaded;
|
|
512
|
+
}
|
|
513
|
+
get detailedAccounts() {
|
|
514
|
+
const e = this.globalStore.userStore.userFeatures, t = Kt(e, "MD_EXCLUDE_EXTERNAL_ACCOUNTS"), a = this.globalStore.appConfig.config.display_only_external_accounts_in_accounts && this.globalStore.appConfig.options.subtype === "accounts";
|
|
515
|
+
return Vt(this.accounts, this.institutions, this.members, t, a);
|
|
516
|
+
}
|
|
517
|
+
get accountsByTypeMap() {
|
|
518
|
+
return this.detailedAccounts.reduce((e, t) => {
|
|
519
|
+
const a = t.account_type;
|
|
520
|
+
let s = e.get(a);
|
|
521
|
+
return s || (s = []), s.push(t), e.set(a, s), e;
|
|
522
|
+
}, /* @__PURE__ */ new Map());
|
|
523
|
+
}
|
|
524
|
+
get cashAccounts() {
|
|
525
|
+
return this.detailedAccounts.filter((e) => e.account_type === u.CASH || e.account_type === u.CHECKING || e.account_type === u.PREPAID || e.account_type === u.SAVINGS || e.account_type === u.CHECKING_LINE_OF_CREDIT);
|
|
526
|
+
}
|
|
527
|
+
get cashBalance() {
|
|
528
|
+
return this.cashAccounts.reduce((e, t) => e + (t?.balance || 0), 0);
|
|
529
|
+
}
|
|
530
|
+
get checkingAccounts() {
|
|
531
|
+
return this.detailedAccounts.filter((e) => e.account_type === u.CHECKING);
|
|
532
|
+
}
|
|
533
|
+
get debtAccounts() {
|
|
534
|
+
return this.detailedAccounts.filter((e) => e.account_type === u.CREDIT_CARD || e.account_type === u.LOAN || e.account_type === u.MORTGAGE || e.account_type === u.LINE_OF_CREDIT || e.account_type === u.CHECKING_LINE_OF_CREDIT);
|
|
535
|
+
}
|
|
536
|
+
get finstrongAccounts() {
|
|
537
|
+
const e = /* @__PURE__ */ new Set([
|
|
538
|
+
u.CHECKING,
|
|
539
|
+
u.SAVINGS,
|
|
540
|
+
u.CREDIT_CARD,
|
|
541
|
+
u.INVESTMENT
|
|
542
|
+
]);
|
|
543
|
+
return this.detailedAccounts.filter((t) => e.has(t.account_type));
|
|
544
|
+
}
|
|
545
|
+
get investmentAccounts() {
|
|
546
|
+
return this.detailedAccounts.filter((e) => e.account_type === u.INVESTMENT);
|
|
547
|
+
}
|
|
548
|
+
get manualAccounts() {
|
|
549
|
+
return this.detailedAccounts.filter((e) => e.is_manual);
|
|
550
|
+
}
|
|
551
|
+
get savingsAccounts() {
|
|
552
|
+
return this.detailedAccounts.filter((e) => e.account_type === u.SAVINGS);
|
|
553
|
+
}
|
|
554
|
+
get retirementAccounts() {
|
|
555
|
+
return this.detailedAccounts.filter((e) => e.account_type === u.INVESTMENT || e.account_type === u.SAVINGS || e.account_type === u.CHECKING || e.account_type === u.CASH || e.account_type === u.PROPERTY || e.account_type === u.INSURANCE && (e.account_subtype === ce.WHOLE_LIFE || e.account_subtype === ce.UNIVERSAL_LIFE || e.account_subtype === ce.VARIABLE_UNIVERSAL_LIFE));
|
|
556
|
+
}
|
|
557
|
+
get visibleAccounts() {
|
|
558
|
+
return this.detailedAccounts.filter((e) => !e.is_hidden && !e.is_closed);
|
|
559
|
+
}
|
|
560
|
+
get visibleCashAccounts() {
|
|
561
|
+
return this.cashAccounts.filter((e) => !e.is_hidden);
|
|
562
|
+
}
|
|
563
|
+
get visibleCashBalance() {
|
|
564
|
+
return this.visibleCashAccounts.reduce((e, t) => e + (t?.balance || 0), 0);
|
|
565
|
+
}
|
|
566
|
+
get visibleCheckingAccounts() {
|
|
567
|
+
return this.checkingAccounts.filter((e) => !e.is_hidden);
|
|
568
|
+
}
|
|
569
|
+
get visibleDebtAccounts() {
|
|
570
|
+
return this.debtAccounts.filter((e) => !e.is_hidden);
|
|
571
|
+
}
|
|
572
|
+
get visibleFinstrongAccounts() {
|
|
573
|
+
return this.finstrongAccounts.filter((e) => !(e.is_closed || e.is_deleted || e.is_hidden));
|
|
574
|
+
}
|
|
575
|
+
get visibleRetirementAccounts() {
|
|
576
|
+
return this.retirementAccounts.filter((e) => !e.is_hidden);
|
|
577
|
+
}
|
|
578
|
+
get visibleInvestmentAccounts() {
|
|
579
|
+
return this.investmentAccounts.filter((e) => !e.is_hidden);
|
|
580
|
+
}
|
|
581
|
+
get visibleSavingsAccounts() {
|
|
582
|
+
return this.savingsAccounts.filter((e) => !e.is_hidden);
|
|
583
|
+
}
|
|
584
|
+
get savingsAndCheckingAccountsBalance() {
|
|
585
|
+
return this.savingsAndCheckingAccounts.reduce((e, t) => e + (t?.balance || 0), 0);
|
|
586
|
+
}
|
|
587
|
+
get savingsAndCheckingAccounts() {
|
|
588
|
+
return this.accounts.filter((e) => e.account_type === u.SAVINGS || e.account_type === u.CHECKING);
|
|
589
|
+
}
|
|
590
|
+
setAccounts = (e) => {
|
|
591
|
+
this.accounts = e, this.accountsLoading = !1, this.accountsLoaded = !0;
|
|
592
|
+
};
|
|
593
|
+
setMembers = (e) => {
|
|
594
|
+
this.members = e, this.membersLoading = !1, this.membersLoaded = !0;
|
|
595
|
+
};
|
|
596
|
+
setInstitutions = (e) => {
|
|
597
|
+
this.institutions = e, this.institutionsLoading = !1, this.institutionsLoaded = !0;
|
|
598
|
+
};
|
|
599
|
+
addAccount = async (e) => {
|
|
600
|
+
try {
|
|
601
|
+
const t = await this.api.createAccount(e);
|
|
602
|
+
g(() => {
|
|
603
|
+
this.accounts = [...this.accounts, t];
|
|
604
|
+
});
|
|
605
|
+
} catch (t) {
|
|
606
|
+
console.error(`Error occurred while adding an account: ${t}`);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
loadAccounts = async () => {
|
|
610
|
+
if (!this.accountsLoading) {
|
|
611
|
+
this.accountsLoading = !0;
|
|
612
|
+
try {
|
|
613
|
+
const e = await this.api.getAccounts();
|
|
614
|
+
this.setAccounts(e);
|
|
615
|
+
} catch (e) {
|
|
616
|
+
console.error(`Error occurred while loading accounts: ${e}`);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
loadInstitutions = async () => {
|
|
621
|
+
if (!this.institutionsLoading) {
|
|
622
|
+
this.institutionsLoading = !0;
|
|
623
|
+
try {
|
|
624
|
+
const e = await this.api.getInstitutions();
|
|
625
|
+
this.setInstitutions(e);
|
|
626
|
+
} catch (e) {
|
|
627
|
+
console.error(`Error occurred while loading institutions: ${e}`);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
loadMembers = async () => {
|
|
632
|
+
if (!this.membersLoading) {
|
|
633
|
+
this.membersLoading = !0;
|
|
634
|
+
try {
|
|
635
|
+
const e = await this.api.getMembers();
|
|
636
|
+
this.setMembers(e);
|
|
637
|
+
} catch (e) {
|
|
638
|
+
console.error(`Error occurred while loading members: ${e}`);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
mergeAccounts = async (e) => {
|
|
643
|
+
try {
|
|
644
|
+
const t = await this.api.mergeAccounts(e), a = t[Object.keys(t)[0]];
|
|
645
|
+
g(() => {
|
|
646
|
+
const s = this.accounts.findIndex((n) => n.guid === e[1]);
|
|
647
|
+
this.accounts.splice(s, 1);
|
|
648
|
+
const r = this.accounts.findIndex((n) => n.guid === e[0]);
|
|
649
|
+
this.accounts.splice(r, 1, a);
|
|
650
|
+
});
|
|
651
|
+
} catch (t) {
|
|
652
|
+
console.error(`Error occurred while merging accounts: ${t}`);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
refreshAccounts = async () => {
|
|
656
|
+
await Promise.all([
|
|
657
|
+
this.loadAccounts(),
|
|
658
|
+
this.loadInstitutions(),
|
|
659
|
+
this.loadMembers()
|
|
660
|
+
]);
|
|
661
|
+
};
|
|
662
|
+
refreshMembers = async () => {
|
|
663
|
+
try {
|
|
664
|
+
await this.api.refreshAllMembers();
|
|
665
|
+
} catch (e) {
|
|
666
|
+
console.error(`Error occurredwhile refreshing members: ${e}`);
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
removeAccount = async (e) => {
|
|
670
|
+
try {
|
|
671
|
+
await this.api.deleteAccount(e);
|
|
672
|
+
const t = this.accounts.findIndex((a) => a.guid === e);
|
|
673
|
+
this.accounts.splice(t, 1);
|
|
674
|
+
} catch (t) {
|
|
675
|
+
console.error(`Error occurred while removing an account: ${t}`);
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
updateAccount = async (e) => {
|
|
679
|
+
try {
|
|
680
|
+
const t = await this.api.updateAccount(e), a = this.accounts.findIndex((s) => s.guid === t.guid);
|
|
681
|
+
this.accounts.splice(a, 1, t);
|
|
682
|
+
} catch (t) {
|
|
683
|
+
console.error(`Error occurred while updating account: ${t}`);
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
updateAccountBalance = (e, t) => {
|
|
687
|
+
const a = this.accounts.find((s) => s.guid === e);
|
|
688
|
+
a && g(() => {
|
|
689
|
+
a.balance = (a.balance || 0) + t;
|
|
690
|
+
});
|
|
691
|
+
};
|
|
692
|
+
updateAccountFilter = async (e) => {
|
|
693
|
+
const t = [];
|
|
694
|
+
for (const [r, n] of e.entries()) {
|
|
695
|
+
const i = this.accounts.find((o) => o.guid === r);
|
|
696
|
+
i && i.is_excluded_from_accounts === n && (i.is_excluded_from_accounts = !n, t.push(this.api.updateAccount(i)));
|
|
697
|
+
}
|
|
698
|
+
const a = await Promise.all(t), s = [...this.accounts];
|
|
699
|
+
for (const r of a) {
|
|
700
|
+
const n = s.findIndex((i) => i.guid === r.guid);
|
|
701
|
+
n !== -1 && s.splice(n, 1, r);
|
|
702
|
+
}
|
|
703
|
+
this.setAccounts(s);
|
|
704
|
+
};
|
|
705
|
+
}, Qt = class {
|
|
706
|
+
selectedAccount = {};
|
|
707
|
+
selectedMember = {};
|
|
708
|
+
constructor() {
|
|
709
|
+
p(this);
|
|
710
|
+
}
|
|
711
|
+
setSelectedAccount = (e) => this.selectedAccount = e;
|
|
712
|
+
setSelectedMember = (e) => this.selectedMember = e;
|
|
713
|
+
}, zt = class {
|
|
714
|
+
globalStore;
|
|
715
|
+
api = new Ne("/", "");
|
|
716
|
+
bannerApi = new we("/");
|
|
717
|
+
appData = {};
|
|
718
|
+
isAppDataLoaded = !1;
|
|
719
|
+
banner = {};
|
|
720
|
+
constructor(e) {
|
|
721
|
+
this.globalStore = e, this.api = new Ne(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
722
|
+
}
|
|
723
|
+
get appConfig() {
|
|
724
|
+
return this.globalStore.appConfig;
|
|
725
|
+
}
|
|
726
|
+
get clientCommunicationProfile() {
|
|
727
|
+
return this.appData.client_communication_profile;
|
|
728
|
+
}
|
|
729
|
+
get clientInsightProfile() {
|
|
730
|
+
return this.appData.client_insight_profile;
|
|
731
|
+
}
|
|
732
|
+
get user() {
|
|
733
|
+
return this.appData.user;
|
|
734
|
+
}
|
|
735
|
+
get userCommunicationProfile() {
|
|
736
|
+
return this.appData.user_communication_profile;
|
|
737
|
+
}
|
|
738
|
+
get userProfile() {
|
|
739
|
+
return this.appData.user_profile;
|
|
740
|
+
}
|
|
741
|
+
setAppData = (e) => {
|
|
742
|
+
this.appData = e, this.bannerApi = new we(e.address?.bullseye || "/"), this.isAppDataLoaded = !0;
|
|
743
|
+
};
|
|
744
|
+
loadAppData = async () => {
|
|
745
|
+
try {
|
|
746
|
+
const e = await this.api.getAppData();
|
|
747
|
+
this.setAppData(e);
|
|
748
|
+
} catch (e) {
|
|
749
|
+
console.error(`Error loading app data: ${e}`);
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
loadBanner = async () => {
|
|
753
|
+
try {
|
|
754
|
+
const e = this.user?.guid ?? null, t = e ? await this.bannerApi.getBanner(e) : {};
|
|
755
|
+
g(() => {
|
|
756
|
+
this.banner = t;
|
|
757
|
+
});
|
|
758
|
+
} catch (e) {
|
|
759
|
+
console.error(`Error loading banner: ${e}`);
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
setUser = (e) => this.appData.user = e;
|
|
763
|
+
setUserCommunicationProfile = (e) => this.appData.user_communication_profile = e;
|
|
764
|
+
setUserProfile = (e) => this.appData.user_profile = e;
|
|
765
|
+
}, Xt = class {
|
|
766
|
+
globalStore;
|
|
767
|
+
survey = null;
|
|
768
|
+
currentQuestionIndex = 0;
|
|
769
|
+
question = null;
|
|
770
|
+
response = null;
|
|
771
|
+
responses = {};
|
|
772
|
+
constructor(e) {
|
|
773
|
+
this.globalStore = e, p(this);
|
|
774
|
+
}
|
|
775
|
+
get isLastQuestion() {
|
|
776
|
+
return this.currentQuestionIndex === this.surveyQuestions.length - 1;
|
|
777
|
+
}
|
|
778
|
+
get questionCount() {
|
|
779
|
+
return `${this.currentQuestionIndex + 1}/${this.surveyQuestions.length}`;
|
|
780
|
+
}
|
|
781
|
+
get responsePayload() {
|
|
782
|
+
return {
|
|
783
|
+
$survey_id: this.surveyId,
|
|
784
|
+
...this.responses
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
get surveyId() {
|
|
788
|
+
return window.app?.postHogPublicKey === "phc_KclQGnOZEaYCttkpiVpuyOYeBlixGo6xNphYgWV4CXo" ? "0196caa6-9b37-0000-98a7-f04e8d56faf5" : "0196a6b0-ccde-0000-b980-0b84ea2fef4a";
|
|
789
|
+
}
|
|
790
|
+
get surveyQuestions() {
|
|
791
|
+
return this.survey ? this.survey.questions : [];
|
|
792
|
+
}
|
|
793
|
+
loadSurvey = (e = !1) => {
|
|
794
|
+
wt.getActiveMatchingSurveys((t) => {
|
|
795
|
+
g(() => {
|
|
796
|
+
if (t.length > 0) {
|
|
797
|
+
const a = t.find((s) => s.id === this.surveyId);
|
|
798
|
+
a && (this.survey = a, this.currentQuestionIndex = 0, this.question = a.questions[0], this.response = null, this.responses = {});
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
}, e);
|
|
802
|
+
};
|
|
803
|
+
nextQuestion = () => {
|
|
804
|
+
this.currentQuestionIndex < this.surveyQuestions.length - 1 && (this.currentQuestionIndex += 1), this.response = null, this.question = this.surveyQuestions[this.currentQuestionIndex];
|
|
805
|
+
};
|
|
806
|
+
resetStore = () => {
|
|
807
|
+
this.survey = null, this.currentQuestionIndex = 0, this.question = null, this.response = null, this.responses = {};
|
|
808
|
+
};
|
|
809
|
+
setResponse = (e) => {
|
|
810
|
+
this.response = e, this.question && (this.responses[`$survey_response_${this.question.id}`] = e);
|
|
811
|
+
};
|
|
812
|
+
};
|
|
813
|
+
function Jt(e, t, a, s = "asc") {
|
|
814
|
+
const r = s === "desc" ? -1 : 1;
|
|
815
|
+
return [...e, ...t].sort((n, i) => n[a] < i[a] ? -1 * r : n[a] > i[a] ? 1 * r : 0);
|
|
816
|
+
}
|
|
817
|
+
var qt = (e) => ({
|
|
818
|
+
...e,
|
|
819
|
+
image_url: e.image_url,
|
|
820
|
+
guid: e.guid,
|
|
821
|
+
created_at: e.created_at,
|
|
822
|
+
dismissed_at: e.dismissed_at,
|
|
823
|
+
active_at: e.campaign_activated_at,
|
|
824
|
+
displayed_at: e.has_been_viewed,
|
|
825
|
+
post_message_secondary: e.pulse_post_message_secondary,
|
|
826
|
+
title: e.pulse_title || e.campaign_name,
|
|
827
|
+
html_title: e.pulse_title || e.campaign_name,
|
|
828
|
+
short_title: e.pulse_title || e.campaign_name,
|
|
829
|
+
html_short_title: e.pulse_title || e.campaign_name,
|
|
830
|
+
micro_title: e.pulse_title || e.campaign_name,
|
|
831
|
+
html_micro_title: e.pulse_title || e.campaign_name,
|
|
832
|
+
supporting_action: e.pulse_call_to_action_text_secondary,
|
|
833
|
+
description: e.pulse_body,
|
|
834
|
+
html_description: e.pulse_body,
|
|
835
|
+
micro_description: e.pulse_body,
|
|
836
|
+
html_micro_description: e.pulse_body,
|
|
837
|
+
call_to_action: e.pulse_call_to_action_text,
|
|
838
|
+
html_micro_call_to_action: e.pulse_call_to_action_text,
|
|
839
|
+
micro_call_to_action: e.pulse_call_to_action_text,
|
|
840
|
+
is_dismissed: e.has_been_dismissed,
|
|
841
|
+
icon_type: 5,
|
|
842
|
+
template: "MarketingOffer",
|
|
843
|
+
account_guids: [],
|
|
844
|
+
data_series: {},
|
|
845
|
+
has_been_displayed: !1,
|
|
846
|
+
is_obsolete: !1,
|
|
847
|
+
is_refreshable: !1,
|
|
848
|
+
is_sampled: !1,
|
|
849
|
+
merchant_guids: [],
|
|
850
|
+
payload: {},
|
|
851
|
+
pulse_campaign_name: e.campaign_name,
|
|
852
|
+
scheduled_payment_guids: [],
|
|
853
|
+
transaction_guids: [],
|
|
854
|
+
user_guid: "",
|
|
855
|
+
user_verification: 0
|
|
856
|
+
}), Zt = class {
|
|
857
|
+
globalStore;
|
|
858
|
+
api = new Z("/", "");
|
|
859
|
+
beats = [];
|
|
860
|
+
isLoading = !1;
|
|
861
|
+
constructor(e) {
|
|
862
|
+
this.globalStore = e, this.api = new Z(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
863
|
+
}
|
|
864
|
+
loadBeats = async () => {
|
|
865
|
+
this.isLoading = !0;
|
|
866
|
+
const e = await this.api.getBeats(), t = (await this.api.getOffers()).map((a) => qt(a));
|
|
867
|
+
g(() => {
|
|
868
|
+
this.beats = Jt(e, t, "active_at", "desc"), this.isLoading = !1;
|
|
869
|
+
});
|
|
870
|
+
};
|
|
871
|
+
getFilteredBeats(e) {
|
|
872
|
+
const { categoryGuids: t, templates: a } = e;
|
|
873
|
+
let s = this.beats;
|
|
874
|
+
return t && (s = this.filterBeatsByCategory(s, t)), a && (s = this.filterBeatsByTemplate(s, a)), s;
|
|
875
|
+
}
|
|
876
|
+
filterBeatsByCategory(e, t) {
|
|
877
|
+
return e.filter((a) => a.category_guids?.some((s) => t.includes(s)));
|
|
878
|
+
}
|
|
879
|
+
filterBeatsByTemplate(e, t) {
|
|
880
|
+
return e.filter((a) => t.some((s) => a.template === s));
|
|
881
|
+
}
|
|
882
|
+
}, ea = 3, Fe = 12, ta = (e, t, a, s) => e.filter((r) => !r.parent_guid).map((r) => ht(r, t, a, s, e.filter((n) => n.parent_guid === r.guid))), Zr = (e, t) => {
|
|
883
|
+
const a = Tt.find((s) => s.guid === e);
|
|
884
|
+
return a ? t.palette.categories[a.colorName] || "" : t.palette.categories.uncategorized || "";
|
|
885
|
+
}, ht = (e, t, a, s, r = []) => {
|
|
886
|
+
const n = e.guid, i = e.parent_guid || n, o = n === i, c = a.find((A) => A.category_guid === n)?.total || 0, d = Ve(s.filter((A) => A.category_guid === n)), h = Ve(s.filter((A) => A.category_guid === n || A.top_level_category_guid === n)), _ = r.map((A) => ht(A, t, a, s)), m = _.reduce((A, Y) => A + Y.currentAmount, c), D = t.default_categories[e.guid] ? t.default_categories[e.guid].replace(/&/g, "&") : e.name;
|
|
887
|
+
return {
|
|
888
|
+
...e,
|
|
889
|
+
currentAmount: c,
|
|
890
|
+
averageAmount: ke(d),
|
|
891
|
+
color: he[i],
|
|
892
|
+
icon: Dt[i],
|
|
893
|
+
isTransfer: i === G.TRANSFER,
|
|
894
|
+
monthlyAmounts: d,
|
|
895
|
+
name: D,
|
|
896
|
+
subCategories: _,
|
|
897
|
+
totalAmount: o ? m : 0,
|
|
898
|
+
totalAverageAmount: ke(h),
|
|
899
|
+
totalMonthlyAmounts: o ? h : []
|
|
900
|
+
};
|
|
901
|
+
}, aa = (e, t) => e.map((a) => {
|
|
902
|
+
const s = t.filter((r) => r.category_guid === a.guid || r.top_level_category_guid === a.guid);
|
|
903
|
+
return {
|
|
904
|
+
...a,
|
|
905
|
+
transactions: s
|
|
906
|
+
};
|
|
907
|
+
}), ke = (e, t = ea) => {
|
|
908
|
+
const a = t > history.length ? history.length : t;
|
|
909
|
+
return Math.ceil(Math.max(0, e.slice(-a).reduce((s, r) => s + r.amount, 0) / a));
|
|
910
|
+
}, Ve = (e) => {
|
|
911
|
+
const t = [], a = R();
|
|
912
|
+
for (let s = 0; s <= Fe; s++) {
|
|
913
|
+
const r = M(k(a, Fe - s)), n = e.filter((i) => i.year_month === Number(K(r, "yyyyMM"))).reduce((i, o) => i + o.total, 0);
|
|
914
|
+
t.push({
|
|
915
|
+
amount: n,
|
|
916
|
+
isoDate: K(r, "yyyy-MM-dd"),
|
|
917
|
+
label: w(r, N.MONTH_YEAR)
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
return t;
|
|
921
|
+
}, sa = (e, t) => e.find((a) => a.guid === t), ra = (e, t) => {
|
|
922
|
+
const a = e.find((s) => s.subCategories.find((r) => r.guid === t));
|
|
923
|
+
if (a)
|
|
924
|
+
return a.subCategories.find((s) => s.guid === t);
|
|
925
|
+
}, en = 9999999999e-2, Ye = /* @__PURE__ */ (function(e) {
|
|
926
|
+
return e.CAD = "CAD", e.USD = "USD", e;
|
|
927
|
+
})({}), tn = (e, t, a) => {
|
|
928
|
+
const s = [], r = (t - e) / (a - 1);
|
|
929
|
+
for (let n = 0; n < a; n++) {
|
|
930
|
+
const i = e + n * r;
|
|
931
|
+
s.push(i);
|
|
932
|
+
}
|
|
933
|
+
return s[a - 1] = t, s.map(Math.round);
|
|
934
|
+
}, me = (e, t, a) => z() === "fr-ca" ? _e(e).format(`${t} $`, a) : _e(e).format(`$${t}`, a), an = () => z() === "fr-ca" ? Ye.CAD : Ye.USD, na = (e) => e != null && e !== "" && isFinite(e), ia = {
|
|
935
|
+
style: "percent",
|
|
936
|
+
minimumFractionDigits: 2,
|
|
937
|
+
maximumFractionDigits: 2
|
|
938
|
+
}, oa = (e, t = ia) => na(e) ? new Intl.NumberFormat(z(), t).format(Number(e)) : e, ca = (e) => new Intl.PluralRules(z(), e), We = (e, t = { type: "ordinal" }, a = {
|
|
939
|
+
one: "st",
|
|
940
|
+
two: "nd",
|
|
941
|
+
few: "rd",
|
|
942
|
+
other: "th"
|
|
943
|
+
}) => `${e}${a[ca(t).select(e)]}`, Ke = (e, t) => !e && !t ? 0 : !e && t ? 101 : t / e * 100, je = (e, t) => {
|
|
944
|
+
const a = {
|
|
945
|
+
background: t.palette.success.main,
|
|
946
|
+
description: e <= 100 ? t.palette.text.secondary : t.palette.error.main,
|
|
947
|
+
text: t.palette.common.white,
|
|
948
|
+
mercury: t.palette.success.lighter
|
|
949
|
+
};
|
|
950
|
+
return e > 100 ? (a.background = t.palette.error.main, a.mercury = t.palette.error.lighter) : e > 80 && (a.background = t.palette.warning.main, a.text = t.palette.grey[900], a.mercury = t.palette.warning.lighter), a;
|
|
951
|
+
}, sn = (e) => e.map((t) => {
|
|
952
|
+
const a = t.transaction_total;
|
|
953
|
+
return t.amount - a;
|
|
954
|
+
}).reduce((t, a) => t + a, 0), Qe = (e, t, a, s) => {
|
|
955
|
+
const r = [];
|
|
956
|
+
for (const n of e) {
|
|
957
|
+
const i = sa(t, n.category_guid);
|
|
958
|
+
if (!i) continue;
|
|
959
|
+
const o = i.totalAmount, c = Ke(n.amount, o), d = n.amount - o;
|
|
960
|
+
r.push({
|
|
961
|
+
...n,
|
|
962
|
+
budgetColors: je(c, s),
|
|
963
|
+
category: i,
|
|
964
|
+
description: C(d < 0 ? a.budget_remaining_over : a.budget_remaining_left, me(Math.abs(d), "0,0")),
|
|
965
|
+
percentage: c,
|
|
966
|
+
subBudgets: [],
|
|
967
|
+
transaction_total: o
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
for (const n of e) {
|
|
971
|
+
const i = ra(t, n.category_guid);
|
|
972
|
+
if (!i) continue;
|
|
973
|
+
const o = i.currentAmount, c = r.find((_) => _.category_guid === i.parent_guid);
|
|
974
|
+
if (!c) continue;
|
|
975
|
+
const d = n.amount - o, h = Ke(n.amount, o);
|
|
976
|
+
c && c.subBudgets.push({
|
|
977
|
+
...n,
|
|
978
|
+
budgetColors: je(h, s),
|
|
979
|
+
category: i,
|
|
980
|
+
description: C(d < 0 ? a.budget_remaining_over : a.budget_remaining_left, me(Math.abs(d), "0,0")),
|
|
981
|
+
percentage: h,
|
|
982
|
+
subBudgets: [],
|
|
983
|
+
transaction_total: o
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
return r;
|
|
987
|
+
}, pe = (e, t) => e.find((a) => a.guid === t), la = (e, t, a) => {
|
|
988
|
+
const s = pe(e, a);
|
|
989
|
+
if (s)
|
|
990
|
+
return pe(s.subBudgets, t);
|
|
991
|
+
}, rn = (e, t) => {
|
|
992
|
+
const a = Math.max(0, t - e), s = t > 0 ? Math.min(100, e / t * 100) : 0;
|
|
993
|
+
let r = "success";
|
|
994
|
+
return s >= 100 ? r = "error" : s >= 50 && (r = "warning"), {
|
|
995
|
+
remainingAmount: a,
|
|
996
|
+
spentPercentage: s,
|
|
997
|
+
iconColor: r
|
|
998
|
+
};
|
|
999
|
+
}, da = class {
|
|
1000
|
+
api = new ve("/", "");
|
|
1001
|
+
globalStore;
|
|
1002
|
+
alert = "";
|
|
1003
|
+
dateRange = {
|
|
1004
|
+
start: M(R()),
|
|
1005
|
+
end: B(R())
|
|
1006
|
+
};
|
|
1007
|
+
budgets = [];
|
|
1008
|
+
selectedBudget;
|
|
1009
|
+
selectedSubBudget;
|
|
1010
|
+
isDataLoaded = !1;
|
|
1011
|
+
theme = {};
|
|
1012
|
+
merchantBudgets = [];
|
|
1013
|
+
constructor(e) {
|
|
1014
|
+
this.globalStore = e, this.api = new ve(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
1015
|
+
}
|
|
1016
|
+
loadBudgetData = async () => {
|
|
1017
|
+
this.globalStore.recurringTransactionsStore.isDataLoaded || await this.globalStore.recurringTransactionsStore.loadRepeatingTransactionData(), await this.loadBudgets(), st(() => this.detailedBudgets, (e) => {
|
|
1018
|
+
if (e) {
|
|
1019
|
+
const t = this.selectedBudget;
|
|
1020
|
+
t && (this.selectedBudget = pe(e, t.guid));
|
|
1021
|
+
const a = this.selectedSubBudget;
|
|
1022
|
+
a && a.parent_guid && (this.selectedSubBudget = la(e, a.guid, a.parent_guid));
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
};
|
|
1026
|
+
get detailedBudgets() {
|
|
1027
|
+
return Qe(this.budgets.filter((e) => e.category_guid !== G.INCOME && e.category_guid !== G.TRANSFER && e.category_guid !== G.INVESTMENTS), this.globalStore.categoryStore.detailedCategories, this.globalStore.copyStore.copy.budgets, this.theme).sort((e, t) => e.percentage > t.percentage ? -1 : e.percentage < t.percentage ? 1 : 0);
|
|
1028
|
+
}
|
|
1029
|
+
get incomeBudget() {
|
|
1030
|
+
return Qe(this.budgets.filter((e) => !e.parent_guid), this.globalStore.categoryStore.detailedCategories, this.globalStore.copyStore.copy.budgets, this.theme).reduce((e, t) => t.category_guid !== G.INCOME ? e : !e || t.percentage > e.percentage ? t : e, void 0)?.amount;
|
|
1031
|
+
}
|
|
1032
|
+
get unbudgetedCategories() {
|
|
1033
|
+
return this.globalStore.categoryStore.spendCategories.filter((e) => !this.detailedBudgets.find((t) => t.category_guid === e.guid));
|
|
1034
|
+
}
|
|
1035
|
+
get totalBudgeted() {
|
|
1036
|
+
return this.detailedBudgets.reduce((e, t) => e + t.amount, 0);
|
|
1037
|
+
}
|
|
1038
|
+
addBudget = async (e, t, a = null) => {
|
|
1039
|
+
try {
|
|
1040
|
+
const s = await this.api.addBudget(e, t, a);
|
|
1041
|
+
g(() => {
|
|
1042
|
+
this.budgets.push(s);
|
|
1043
|
+
});
|
|
1044
|
+
} catch (s) {
|
|
1045
|
+
console.error(`Error adding budget: ${s}`);
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
deleteBudget = async (e) => {
|
|
1049
|
+
try {
|
|
1050
|
+
await this.api.deleteBudget(e), g(() => {
|
|
1051
|
+
const t = this.budgets.findIndex((a) => a.guid === e);
|
|
1052
|
+
t >= 0 && this.budgets.splice(t, 1);
|
|
1053
|
+
});
|
|
1054
|
+
} catch (t) {
|
|
1055
|
+
console.error(`Error deleting budget: ${t}`);
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
loadBudgets = async () => {
|
|
1059
|
+
try {
|
|
1060
|
+
const e = await this.api.getBudgets();
|
|
1061
|
+
this.setBudgets(e);
|
|
1062
|
+
} catch (e) {
|
|
1063
|
+
throw console.error(`Error occurred while loading budgets: ${e}`), e;
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
setAlert = (e) => this.alert = e;
|
|
1067
|
+
setBudgets = (e) => {
|
|
1068
|
+
this.budgets = e, this.isDataLoaded = !0;
|
|
1069
|
+
};
|
|
1070
|
+
setDateRange = (e) => this.dateRange = e;
|
|
1071
|
+
setSelectedBudget = (e) => this.selectedBudget = e;
|
|
1072
|
+
setSelectedSubBudget = (e) => this.selectedSubBudget = e;
|
|
1073
|
+
setTheme = (e) => this.theme = e;
|
|
1074
|
+
recalculateBudgets = async (e) => {
|
|
1075
|
+
try {
|
|
1076
|
+
for (const a of e) {
|
|
1077
|
+
const s = this.budgets.find((r) => r.category_guid === a.guid);
|
|
1078
|
+
s ? await this.api.updateBudget({
|
|
1079
|
+
...s,
|
|
1080
|
+
amount: a.totalAverageAmount
|
|
1081
|
+
}) : await this.api.addBudget(a, a.totalAverageAmount);
|
|
1082
|
+
}
|
|
1083
|
+
const t = this.budgets.filter((a) => !e.find((s) => s.guid === a.category_guid));
|
|
1084
|
+
for (const a of t) await this.api.deleteBudget(a.guid);
|
|
1085
|
+
return await this.loadBudgets(), {
|
|
1086
|
+
data: this.budgets,
|
|
1087
|
+
isSuccess: !0
|
|
1088
|
+
};
|
|
1089
|
+
} catch (t) {
|
|
1090
|
+
return console.error("error recalculating budgets", t), {
|
|
1091
|
+
data: [],
|
|
1092
|
+
isSuccess: !1
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
updateBudget = async (e) => {
|
|
1097
|
+
try {
|
|
1098
|
+
const t = await this.api.updateBudget(e);
|
|
1099
|
+
g(() => {
|
|
1100
|
+
const a = this.budgets.findIndex((s) => s.guid === e.guid);
|
|
1101
|
+
a >= 0 && (this.budgets[a] = t);
|
|
1102
|
+
});
|
|
1103
|
+
} catch (t) {
|
|
1104
|
+
console.error(`Error updating budget: ${t}`);
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
getMerchantBudgetByMerchantGuid = (e) => this.merchantBudgets.find((t) => t?.merchant_guid === e);
|
|
1108
|
+
setMerchantBudgets = (e) => {
|
|
1109
|
+
this.merchantBudgets = e;
|
|
1110
|
+
};
|
|
1111
|
+
addMerchantBudget = async (e, t) => {
|
|
1112
|
+
try {
|
|
1113
|
+
const a = await this.api.addMerchantBudget(e, t);
|
|
1114
|
+
return g(() => {
|
|
1115
|
+
this.merchantBudgets.push(a);
|
|
1116
|
+
}), { isSuccess: !0 };
|
|
1117
|
+
} catch (a) {
|
|
1118
|
+
return console.error(`Error adding merchant budget: ${a}`), { isSuccess: !1 };
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
updateMerchantBudget = async (e) => {
|
|
1122
|
+
try {
|
|
1123
|
+
const { guid: t, amount: a } = e, s = await this.api.updateMerchantBudget(t, a);
|
|
1124
|
+
return g(() => {
|
|
1125
|
+
const r = this.merchantBudgets.findIndex((n) => n.guid === e.guid);
|
|
1126
|
+
r >= 0 && (this.merchantBudgets[r] = s);
|
|
1127
|
+
}), { isSuccess: !0 };
|
|
1128
|
+
} catch (t) {
|
|
1129
|
+
return console.error(`Error updating merchant budget: ${t}`), { isSuccess: !1 };
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
deleteMerchantBudget = async (e) => {
|
|
1133
|
+
try {
|
|
1134
|
+
return await this.api.deleteMerchantBudget(e), g(() => {
|
|
1135
|
+
this.merchantBudgets = this.merchantBudgets.filter((t) => t.guid !== e);
|
|
1136
|
+
}), { isSuccess: !0 };
|
|
1137
|
+
} catch (t) {
|
|
1138
|
+
return console.error(`Error deleting merchant budget: ${t}`), { isSuccess: !1 };
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
}, ha = class {
|
|
1142
|
+
globalStore;
|
|
1143
|
+
uiStore;
|
|
1144
|
+
constructor(e) {
|
|
1145
|
+
this.globalStore = e, this.uiStore = new ua(), p(this);
|
|
1146
|
+
}
|
|
1147
|
+
completeOnboarding = async () => {
|
|
1148
|
+
const e = {
|
|
1149
|
+
...this.globalStore.userStore.userProfile,
|
|
1150
|
+
has_completed_cash_flow_onboarding: !0
|
|
1151
|
+
};
|
|
1152
|
+
await this.globalStore.userStore.updateUserProfile(e);
|
|
1153
|
+
};
|
|
1154
|
+
}, ua = class {
|
|
1155
|
+
dateRange = {
|
|
1156
|
+
start: R(),
|
|
1157
|
+
end: Ie(R(), 30)
|
|
1158
|
+
};
|
|
1159
|
+
isDirty = !1;
|
|
1160
|
+
nextIncome = void 0;
|
|
1161
|
+
upcomingExpenses = [];
|
|
1162
|
+
selectedCashAccounts = [];
|
|
1163
|
+
constructor() {
|
|
1164
|
+
p(this);
|
|
1165
|
+
}
|
|
1166
|
+
get daysUntilNextIncome() {
|
|
1167
|
+
return this.nextIncome ? Math.abs(vt(R(), this.nextIncome.expectedDate)) : 0;
|
|
1168
|
+
}
|
|
1169
|
+
get expensesTilNextIncome() {
|
|
1170
|
+
return this.upcomingExpenses.filter((e) => I(e.expectedDate, this.nextIncome?.expectedDate || B(/* @__PURE__ */ new Date())));
|
|
1171
|
+
}
|
|
1172
|
+
setNextIncome = (e) => {
|
|
1173
|
+
this.nextIncome = e;
|
|
1174
|
+
};
|
|
1175
|
+
setUpcomingExpenses = (e) => {
|
|
1176
|
+
this.upcomingExpenses = e;
|
|
1177
|
+
};
|
|
1178
|
+
setSelectedCashAccounts = (e) => this.selectedCashAccounts = e;
|
|
1179
|
+
}, ga = class {
|
|
1180
|
+
globalStore;
|
|
1181
|
+
uiStore;
|
|
1182
|
+
api = new Le("/", "");
|
|
1183
|
+
categories = [];
|
|
1184
|
+
categoriesLoaded = !1;
|
|
1185
|
+
categoriesLoading = !1;
|
|
1186
|
+
dateRangeCategoryTotals = [];
|
|
1187
|
+
monthlyCategoryTotals = [];
|
|
1188
|
+
dateRangeTotalsLoaded = !1;
|
|
1189
|
+
dateRangeTotalsLoading = !1;
|
|
1190
|
+
monthlyTotalsLoaded = !1;
|
|
1191
|
+
monthlyTotalsLoading = !1;
|
|
1192
|
+
constructor(e) {
|
|
1193
|
+
this.globalStore = e, this.uiStore = new _a(), this.api = new Le(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
1194
|
+
}
|
|
1195
|
+
get detailedCategories() {
|
|
1196
|
+
return this.globalStore.isInitialized ? ta(this.categories, this.globalStore.copyStore.copy.categories, this.dateRangeCategoryTotals, this.monthlyCategoryTotals) : [];
|
|
1197
|
+
}
|
|
1198
|
+
get detailedCategoriesWithTransactions() {
|
|
1199
|
+
return aa(this.detailedCategories, this.globalStore.transactionStore.sortedTransactions);
|
|
1200
|
+
}
|
|
1201
|
+
get incomeCategories() {
|
|
1202
|
+
return this.detailedCategories.filter((e) => e.is_income);
|
|
1203
|
+
}
|
|
1204
|
+
get spendCategories() {
|
|
1205
|
+
return this.detailedCategories.filter((e) => !e.is_income && !e.isTransfer && e.guid !== G.INVESTMENTS);
|
|
1206
|
+
}
|
|
1207
|
+
get transferCategories() {
|
|
1208
|
+
return this.detailedCategories.filter((e) => e.isTransfer);
|
|
1209
|
+
}
|
|
1210
|
+
setCategories = (e) => {
|
|
1211
|
+
this.categories = e, this.categoriesLoading = !1, this.categoriesLoaded = !0;
|
|
1212
|
+
};
|
|
1213
|
+
setMonthlyCategoryTotals = (e) => {
|
|
1214
|
+
this.monthlyCategoryTotals = e, this.monthlyTotalsLoading = !1, this.monthlyTotalsLoaded = !0;
|
|
1215
|
+
};
|
|
1216
|
+
setDateRangeCategoryTotals = (e) => {
|
|
1217
|
+
this.dateRangeCategoryTotals = e, this.dateRangeTotalsLoading = !1, this.dateRangeTotalsLoaded = !0;
|
|
1218
|
+
};
|
|
1219
|
+
get trendsCategories() {
|
|
1220
|
+
return this.detailedCategories.filter((e) => e.totalAmount !== 0).filter((e) => e.guid !== G.INVESTMENTS && e.guid !== G.TRANSFER);
|
|
1221
|
+
}
|
|
1222
|
+
addCategory = async (e, t) => {
|
|
1223
|
+
const a = {
|
|
1224
|
+
name: e,
|
|
1225
|
+
parent_guid: t
|
|
1226
|
+
};
|
|
1227
|
+
try {
|
|
1228
|
+
await this.api.addCategory(a), await this.loadCategories();
|
|
1229
|
+
} catch (s) {
|
|
1230
|
+
console.error(`Error occurred while adding category: ${s}`);
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
loadCategories = async () => {
|
|
1234
|
+
if (!this.categoriesLoading) {
|
|
1235
|
+
this.categoriesLoading = !0;
|
|
1236
|
+
try {
|
|
1237
|
+
const e = await this.api.getCategories();
|
|
1238
|
+
this.setCategories(e);
|
|
1239
|
+
} catch (e) {
|
|
1240
|
+
console.error(`Error occurred while getting categories: ${e}`);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
loadDateRangeCategoryTotals = async (e, t, a) => {
|
|
1245
|
+
if (!this.dateRangeTotalsLoading) {
|
|
1246
|
+
this.dateRangeTotalsLoading = !0;
|
|
1247
|
+
try {
|
|
1248
|
+
const s = await this.api.getDateRangeCategoryTotals(T(t), T(a), e);
|
|
1249
|
+
this.setDateRangeCategoryTotals(s);
|
|
1250
|
+
} catch (s) {
|
|
1251
|
+
console.error(`Error occurred while getting date range category totals: ${s}`);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
loadMonthlyCategoryTotals = async (e = this.globalStore.globalUiStore.selectedAccounts, t, a) => {
|
|
1256
|
+
if (this.monthlyTotalsLoading) return;
|
|
1257
|
+
this.monthlyTotalsLoading = !0;
|
|
1258
|
+
const s = T(M(t ?? k(/* @__PURE__ */ new Date(), 11))), r = T(B(a ?? /* @__PURE__ */ new Date()));
|
|
1259
|
+
try {
|
|
1260
|
+
const n = await this.api.getMonthlyCategoryTotals(s, r, e);
|
|
1261
|
+
this.setMonthlyCategoryTotals(n);
|
|
1262
|
+
} catch (n) {
|
|
1263
|
+
console.error(`Error occurred while getting monthly category totals: ${n}`);
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
reloadCategoryTotals = async (e, t, a) => {
|
|
1267
|
+
const s = t ?? k(/* @__PURE__ */ new Date(), 11), r = a ?? B(/* @__PURE__ */ new Date());
|
|
1268
|
+
try {
|
|
1269
|
+
await Promise.all([this.loadMonthlyCategoryTotals(e, s, r), this.loadDateRangeCategoryTotals(e, s, r)]);
|
|
1270
|
+
} catch (n) {
|
|
1271
|
+
console.error(`Error occurred while getting category totals: ${n}`);
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
removeCategory = async (e) => {
|
|
1275
|
+
try {
|
|
1276
|
+
await this.api.removeCategory(e), await this.loadCategories();
|
|
1277
|
+
} catch (t) {
|
|
1278
|
+
console.error(`Error occurred while removing category: ${t}`);
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
updateCategory = async (e) => {
|
|
1282
|
+
try {
|
|
1283
|
+
await this.api.updateCategory(e), await this.loadCategories();
|
|
1284
|
+
} catch (t) {
|
|
1285
|
+
console.error(`Error occurred while updating category: ${t}`);
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
getCategoryName = (e) => this.categories.find((t) => t.guid === e)?.name ?? fe[e];
|
|
1289
|
+
}, _a = class {
|
|
1290
|
+
expandedGuid = null;
|
|
1291
|
+
selectedGuid = null;
|
|
1292
|
+
searchValue = "";
|
|
1293
|
+
showSelected = !0;
|
|
1294
|
+
shouldDisableDrawerScroll = !1;
|
|
1295
|
+
unselectable = [];
|
|
1296
|
+
unselectableText = "";
|
|
1297
|
+
savedOnSelect;
|
|
1298
|
+
constructor() {
|
|
1299
|
+
p(this);
|
|
1300
|
+
}
|
|
1301
|
+
setExpandedGuid = (e) => this.expandedGuid = e;
|
|
1302
|
+
setSelectedGuid = (e) => this.selectedGuid = e;
|
|
1303
|
+
setSearchValue = (e) => this.searchValue = e;
|
|
1304
|
+
setShouldDisableDrawerScroll = (e) => this.shouldDisableDrawerScroll = e;
|
|
1305
|
+
setShowSelected = (e) => this.showSelected = e;
|
|
1306
|
+
setUnselectable = (e) => this.unselectable = e;
|
|
1307
|
+
setUnselectableText = (e) => this.unselectableText = e;
|
|
1308
|
+
onSelect = (e) => this.savedOnSelect(e);
|
|
1309
|
+
setOnSelect = (e) => this.savedOnSelect = e;
|
|
1310
|
+
}, ma = class {
|
|
1311
|
+
globalStore;
|
|
1312
|
+
widgetApi = new $e("/", "");
|
|
1313
|
+
constructor(e) {
|
|
1314
|
+
this.globalStore = e, this.widgetApi = new $e(e.endpoint, e.sessionToken), p(this);
|
|
1315
|
+
}
|
|
1316
|
+
loadWidget = async ({ widget: e = "connect_widget", mode: t = "light", ...a }) => await this.widgetApi.requestWidgetUrl({ widget_url: {
|
|
1317
|
+
widget_type: e,
|
|
1318
|
+
color_scheme: t,
|
|
1319
|
+
...a
|
|
1320
|
+
} });
|
|
1321
|
+
}, W = /* @__PURE__ */ (function(e) {
|
|
1322
|
+
return e[e.FASTEST_PAYOFF_FIRST = 1] = "FASTEST_PAYOFF_FIRST", e[e.HIGHEST_INTEREST = 2] = "HIGHEST_INTEREST", e[e.LOWEST_BALANCE = 3] = "LOWEST_BALANCE", e[e.HIGHEST_BALANCE = 4] = "HIGHEST_BALANCE", e;
|
|
1323
|
+
})({}), pa = { unnamed_label: "Unnamed Debt" }, nn = (e, t, a = 0) => {
|
|
1324
|
+
const s = e.map((c) => ({ ...c }));
|
|
1325
|
+
Ia(s, t);
|
|
1326
|
+
const r = /* @__PURE__ */ new Date(), n = [];
|
|
1327
|
+
let i = 0, o = 1;
|
|
1328
|
+
for (const c of s) n.push({
|
|
1329
|
+
...c,
|
|
1330
|
+
dataset: [{
|
|
1331
|
+
x: new Date(r),
|
|
1332
|
+
y: c.balance
|
|
1333
|
+
}]
|
|
1334
|
+
});
|
|
1335
|
+
for (; s.some((c) => c.balance >= 0.01 && !c.is_impossible); ) {
|
|
1336
|
+
let c = !1, d = !1, h = !1;
|
|
1337
|
+
for (const [_, m] of s.entries()) {
|
|
1338
|
+
if (m.balance <= 0.01) continue;
|
|
1339
|
+
const D = n[_].dataset, A = (m.interest_rate ?? 0) / 100 / 12, Y = m.balance * A, H = m.monthly_payment ?? 0;
|
|
1340
|
+
let U = H, $ = 0;
|
|
1341
|
+
!h && a > 0 && (U += a, h = !0), !d && i > 0 && ($ = i, d = !0), m.balance += Y;
|
|
1342
|
+
const X = Math.min(m.balance, U + $);
|
|
1343
|
+
if (X <= Y) {
|
|
1344
|
+
m.is_impossible = !0, n[_].is_impossible = !0, n[_].priority = void 0, D.push({
|
|
1345
|
+
x: new Date(r),
|
|
1346
|
+
y: m.balance
|
|
1347
|
+
});
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
m.balance -= X, m.balance = m.balance < 0.01 ? 0 : m.balance, D.push({
|
|
1351
|
+
x: new Date(r),
|
|
1352
|
+
y: Math.max(0, m.balance),
|
|
1353
|
+
payment: X,
|
|
1354
|
+
extra: $
|
|
1355
|
+
}), m.balance <= 0 && (i += H, n[_].projected_payoff_date = new Date(r)), X > 0 && (c = !0);
|
|
1356
|
+
}
|
|
1357
|
+
c && r.setMonth(r.getMonth() + 1);
|
|
1358
|
+
}
|
|
1359
|
+
return n.forEach((c) => {
|
|
1360
|
+
(c.interest_rate === void 0 || c.monthly_payment === void 0) && (c.projected_payoff_date = void 0);
|
|
1361
|
+
}), n.forEach((c) => {
|
|
1362
|
+
c.priority = !c.is_paid_off && !c.is_impossible ? o++ : void 0;
|
|
1363
|
+
}), n;
|
|
1364
|
+
}, on = (e, t, a) => ({
|
|
1365
|
+
description: t ? e.empty_state_description : e.empty_state_description_no_aggregation,
|
|
1366
|
+
header: t ? e.empty_state_header : e.empty_state_header_no_aggregation,
|
|
1367
|
+
onClickHandler: t ? a : void 0,
|
|
1368
|
+
primaryButton: t ? e.connect_accounts : void 0
|
|
1369
|
+
});
|
|
1370
|
+
function Ea(e, t) {
|
|
1371
|
+
const a = e.filter((n) => n.account_type === u.CHECKING_LINE_OF_CREDIT ? Number(n.balance) <= 0 : n.is_excluded_from_debts !== !0), s = t.filter((n) => a.some((i) => i.guid === n.account_guid)).map((n) => ze(a.find((i) => i.guid === n.account_guid), n)), r = a.filter((n) => !s.some((i) => i.account.guid === n.guid)).map((n) => ze(n));
|
|
1372
|
+
return [...s, ...r];
|
|
1373
|
+
}
|
|
1374
|
+
function ze(e, t) {
|
|
1375
|
+
const a = {
|
|
1376
|
+
account: e,
|
|
1377
|
+
goal: t,
|
|
1378
|
+
guid: e.guid
|
|
1379
|
+
};
|
|
1380
|
+
if (t) {
|
|
1381
|
+
const s = t.payment_due_at ? Se(L(t.payment_due_at)) : 1, r = M(/* @__PURE__ */ new Date()).setDate(s);
|
|
1382
|
+
a.balance = Math.abs(t.amount - t.current_amount), a.interest_rate = t.interest_rate, a.is_paid_off = t.is_complete, a.monthly_payment = t.monthly_payment, a.name = t.name, a.original_balance = t.initial_amount, a.payment_due_date = r;
|
|
1383
|
+
} else {
|
|
1384
|
+
const s = e.payment_due_at ? Se(L(e.payment_due_at)) : 1, r = M(/* @__PURE__ */ new Date()).setDate(s), n = e.balance ?? 0, i = e.minimum_payment ?? void 0, o = e.interest_rate ?? e.apr ?? e.apy;
|
|
1385
|
+
a.balance = Math.max(n, 0), a.interest_rate = o, a.is_paid_off = n === 0, a.monthly_payment = i, a.name = e?.name ?? pa.unnamed_label, a.original_balance = e.original_balance, a.payment_due_date = r;
|
|
1386
|
+
}
|
|
1387
|
+
return a.is_impossible = !1, a.priority = void 0, a.projected_payoff_date = void 0, a;
|
|
1388
|
+
}
|
|
1389
|
+
var fa = (e) => (e[e.length - 1] || {}).timestamp, Ia = (e, t) => {
|
|
1390
|
+
const [a, s] = e.reduce(([r, n], i) => (i.is_paid_off || i.is_impossible ? n.push({
|
|
1391
|
+
...i,
|
|
1392
|
+
minimumPayments: []
|
|
1393
|
+
}) : r.push(Aa(i)), [r, n]), [[], []]);
|
|
1394
|
+
switch (t) {
|
|
1395
|
+
case W.FASTEST_PAYOFF_FIRST:
|
|
1396
|
+
a.sort((r, n) => (r.minimumFinalPayment ?? 0) - (n.minimumFinalPayment ?? 0));
|
|
1397
|
+
break;
|
|
1398
|
+
case W.HIGHEST_INTEREST:
|
|
1399
|
+
a.sort((r, n) => (n.interest_rate ?? 0) - (r.interest_rate ?? 0));
|
|
1400
|
+
break;
|
|
1401
|
+
case W.LOWEST_BALANCE:
|
|
1402
|
+
a.sort((r, n) => r.balance - n.balance);
|
|
1403
|
+
break;
|
|
1404
|
+
case W.HIGHEST_BALANCE:
|
|
1405
|
+
a.sort((r, n) => n.balance - r.balance);
|
|
1406
|
+
break;
|
|
1407
|
+
default:
|
|
1408
|
+
a.sort((r, n) => r.balance - n.balance);
|
|
1409
|
+
}
|
|
1410
|
+
e.splice(0, e.length, ...a, ...s);
|
|
1411
|
+
}, Aa = (e) => {
|
|
1412
|
+
const { monthly_payment: t, interest_rate: a, balance: s, payment_due_date: r } = e, n = Da(Ra(s, a ?? 0, t ?? 0), s, a ?? 0, t ?? 0, r), i = fa(n);
|
|
1413
|
+
return {
|
|
1414
|
+
...e,
|
|
1415
|
+
minimumFinalPayment: i,
|
|
1416
|
+
minimumPayments: n
|
|
1417
|
+
};
|
|
1418
|
+
}, Ra = (e, t = 0, a = 0) => {
|
|
1419
|
+
if (a === 0) return 0;
|
|
1420
|
+
const s = t / 1200;
|
|
1421
|
+
return Math.ceil(s === 0 ? e / a : -Math.log(1 - s * e / a) / Math.log(1 + s));
|
|
1422
|
+
}, Da = (e, t, a, s, r) => {
|
|
1423
|
+
const n = [];
|
|
1424
|
+
if (a === 0) {
|
|
1425
|
+
for (let o = 0; o < e; o++) {
|
|
1426
|
+
const c = t - s * (o + 1), d = t - s * o, h = c >= 0 ? s : d;
|
|
1427
|
+
n.push({
|
|
1428
|
+
balance: c >= 0 ? c : 0,
|
|
1429
|
+
interest: a,
|
|
1430
|
+
payment: h,
|
|
1431
|
+
principal: h,
|
|
1432
|
+
timestamp: T(P(L(r), o + 1))
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
return n;
|
|
1436
|
+
}
|
|
1437
|
+
const i = a / 1200;
|
|
1438
|
+
for (let o = 0; o < e; o++) {
|
|
1439
|
+
const c = T(P(L(r), o + 1)), d = Math.pow(1 + i, o), h = t * d - s * ((d - 1) / i), _ = Math.pow(1 + i, o + 1), m = t * _ - s * ((_ - 1) / i), D = s + Math.min(m, 0), A = h * i;
|
|
1440
|
+
n.push({
|
|
1441
|
+
balance: Math.max(0, m),
|
|
1442
|
+
interest: A,
|
|
1443
|
+
payment: D,
|
|
1444
|
+
principal: D - A,
|
|
1445
|
+
timestamp: c
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
return n;
|
|
1449
|
+
}, Ta = class {
|
|
1450
|
+
globalStore;
|
|
1451
|
+
uiStore;
|
|
1452
|
+
constructor(e) {
|
|
1453
|
+
this.globalStore = e, this.uiStore = new ya(), p(this);
|
|
1454
|
+
}
|
|
1455
|
+
get debts() {
|
|
1456
|
+
const { visibleDebtAccounts: e } = this.globalStore.accountStore, { selectedAccountGuids: t } = this.globalStore.globalUiStore, { debtGoals: a } = this.globalStore.goalStore;
|
|
1457
|
+
return Ea(t.length ? e.filter((s) => t.includes(s.guid)) : e, a);
|
|
1458
|
+
}
|
|
1459
|
+
get totalMonthlyPayments() {
|
|
1460
|
+
return this.debts.map((e) => Number(e.monthly_payment)).filter((e) => !isNaN(e)).reduce((e, t) => e + t, 0);
|
|
1461
|
+
}
|
|
1462
|
+
}, ya = class {
|
|
1463
|
+
isLoading = !1;
|
|
1464
|
+
selectedDebtChartData = {};
|
|
1465
|
+
selectedDebtPriority = W.LOWEST_BALANCE;
|
|
1466
|
+
constructor() {
|
|
1467
|
+
p(this);
|
|
1468
|
+
}
|
|
1469
|
+
get showError() {
|
|
1470
|
+
const { interest_rate: e, monthly_payment: t } = this.selectedDebtChartData;
|
|
1471
|
+
return e === void 0 || t === void 0;
|
|
1472
|
+
}
|
|
1473
|
+
get showCompleted() {
|
|
1474
|
+
return this.selectedDebtChartData.is_paid_off;
|
|
1475
|
+
}
|
|
1476
|
+
setIsLoading = (e) => this.isLoading = e;
|
|
1477
|
+
setSelectedDebtChartData = (e) => this.selectedDebtChartData = e;
|
|
1478
|
+
setSelectedDebtPriority = (e) => this.selectedDebtPriority = e;
|
|
1479
|
+
}, Sa = (e) => e.sort((t, a) => t.monthly_health_score_average.year !== a.monthly_health_score_average.year ? t.monthly_health_score_average.year - a.monthly_health_score_average.year : t.monthly_health_score_average.month - a.monthly_health_score_average.month).map((t) => ({
|
|
1480
|
+
x: w(new Date(0, t.monthly_health_score_average.month - 1, 1), N.MONTH_SHORT),
|
|
1481
|
+
y: Math.round(t.monthly_health_score_average.average_health_score)
|
|
1482
|
+
})), Ca = (e) => e.map(({ transaction: t }) => ({ ...t })).sort((t, a) => a.date - t.date), Na = class {
|
|
1483
|
+
api = new Oe("/", "");
|
|
1484
|
+
augmentedChartData = [];
|
|
1485
|
+
averageHealthScores = [];
|
|
1486
|
+
monthlySummaries = [];
|
|
1487
|
+
incomeTransactions = [];
|
|
1488
|
+
debtSpendTransactions = [];
|
|
1489
|
+
spendingFeeTransactions = [];
|
|
1490
|
+
spendTransactions = [];
|
|
1491
|
+
globalStore;
|
|
1492
|
+
healthScore = {};
|
|
1493
|
+
healthScoreChange;
|
|
1494
|
+
healthScoreChangeReports = [];
|
|
1495
|
+
peerScore = null;
|
|
1496
|
+
isSpendingInitialized = !1;
|
|
1497
|
+
isIncomeInitialized = !1;
|
|
1498
|
+
constructor(e) {
|
|
1499
|
+
this.globalStore = e, this.api = new Oe(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
1500
|
+
}
|
|
1501
|
+
setSpendingInitialized = (e) => {
|
|
1502
|
+
this.isSpendingInitialized = e;
|
|
1503
|
+
};
|
|
1504
|
+
setIncomeInitialized = (e) => {
|
|
1505
|
+
this.isIncomeInitialized = e;
|
|
1506
|
+
};
|
|
1507
|
+
calculateHealthScore = async (e = !0) => {
|
|
1508
|
+
try {
|
|
1509
|
+
const t = await this.api.calculateHealthScore();
|
|
1510
|
+
let a = 0;
|
|
1511
|
+
e && await this.loadHealthScoreChangeReports(), a = (t?.health_score || 0) - (this.healthScoreChangeReports.at(-1)?.older_health_score || 0), g(() => {
|
|
1512
|
+
this.healthScore = t, this.healthScoreChange = a;
|
|
1513
|
+
});
|
|
1514
|
+
} catch (t) {
|
|
1515
|
+
console.error("Error calculating health score:", t);
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
loadAverageHealthScores = async () => {
|
|
1519
|
+
try {
|
|
1520
|
+
const e = await this.api.getAverageHealthScores();
|
|
1521
|
+
g(() => {
|
|
1522
|
+
this.averageHealthScores = e;
|
|
1523
|
+
});
|
|
1524
|
+
} catch (e) {
|
|
1525
|
+
console.error("Error loading average health scores:", e);
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
loadMonthlySummaries = async () => {
|
|
1529
|
+
try {
|
|
1530
|
+
const e = await this.api.getMonthlySummaries();
|
|
1531
|
+
g(() => {
|
|
1532
|
+
this.monthlySummaries = e;
|
|
1533
|
+
});
|
|
1534
|
+
} catch (e) {
|
|
1535
|
+
console.error("Error loading monthly summaries:", e);
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
loadDebtSpend = async () => {
|
|
1539
|
+
try {
|
|
1540
|
+
const e = await this.api.getDebtSpend();
|
|
1541
|
+
g(() => {
|
|
1542
|
+
this.debtSpendTransactions = e;
|
|
1543
|
+
});
|
|
1544
|
+
} catch (e) {
|
|
1545
|
+
console.error("Error loading debt spend:", e);
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
loadIncome = async () => {
|
|
1549
|
+
this.setIncomeInitialized(!1);
|
|
1550
|
+
try {
|
|
1551
|
+
const e = await this.api.getIncome();
|
|
1552
|
+
g(() => {
|
|
1553
|
+
this.incomeTransactions = e, this.setIncomeInitialized(!0);
|
|
1554
|
+
});
|
|
1555
|
+
} catch (e) {
|
|
1556
|
+
console.error("Error loading income:", e);
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
loadHealthScoreChangeReports = async () => {
|
|
1560
|
+
const e = T(k(/* @__PURE__ */ new Date(), 2)), t = T(/* @__PURE__ */ new Date());
|
|
1561
|
+
try {
|
|
1562
|
+
const a = await this.api.getHealthScoreChangeReports(e, t);
|
|
1563
|
+
g(() => {
|
|
1564
|
+
this.healthScoreChangeReports = a;
|
|
1565
|
+
});
|
|
1566
|
+
} catch (a) {
|
|
1567
|
+
console.error("Error loading health score change reports:", a);
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
loadPeerScore = async () => {
|
|
1571
|
+
const e = K(L(this.globalStore.appDataStore.user.birthday), "yyyy");
|
|
1572
|
+
try {
|
|
1573
|
+
const t = await this.api.getPeerScore(e);
|
|
1574
|
+
g(() => {
|
|
1575
|
+
this.peerScore = t;
|
|
1576
|
+
});
|
|
1577
|
+
} catch (t) {
|
|
1578
|
+
console.error("Error loading peer score:", t);
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
loadAugmentedChartData = async () => {
|
|
1582
|
+
try {
|
|
1583
|
+
const e = await this.api.getAverageHealthScores();
|
|
1584
|
+
g(() => {
|
|
1585
|
+
this.augmentedChartData = Sa(e);
|
|
1586
|
+
});
|
|
1587
|
+
} catch (e) {
|
|
1588
|
+
console.error(`Error occurred while getting augmented chart data: ${e}`);
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
getSpendingFeeTransactions = async () => {
|
|
1592
|
+
try {
|
|
1593
|
+
const e = Ca(await this.api.getSpendingFeeTransactions());
|
|
1594
|
+
g(() => {
|
|
1595
|
+
this.spendingFeeTransactions = e;
|
|
1596
|
+
});
|
|
1597
|
+
} catch (e) {
|
|
1598
|
+
console.error(`Error occurred while getting spending fee transactions: ${e}`);
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
loadSpendTransactions = async () => {
|
|
1602
|
+
this.setSpendingInitialized(!1);
|
|
1603
|
+
try {
|
|
1604
|
+
const e = await this.api.getStandardSpend();
|
|
1605
|
+
g(() => {
|
|
1606
|
+
this.spendTransactions = [...e], this.setSpendingInitialized(!0);
|
|
1607
|
+
});
|
|
1608
|
+
} catch (e) {
|
|
1609
|
+
console.error("Error loading spend transactions:", e);
|
|
1610
|
+
}
|
|
1611
|
+
};
|
|
1612
|
+
get spendAndDebtTransactions() {
|
|
1613
|
+
return [...this.spendTransactions, ...this.debtSpendTransactions];
|
|
1614
|
+
}
|
|
1615
|
+
get allTransactions() {
|
|
1616
|
+
return {
|
|
1617
|
+
income: this.incomeTransactions,
|
|
1618
|
+
debtSpend: this.debtSpendTransactions,
|
|
1619
|
+
spendingFee: this.spendingFeeTransactions,
|
|
1620
|
+
spend: this.spendTransactions
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
handleFinstrongWidgetPrimaryCtaClick = (e) => () => {
|
|
1624
|
+
};
|
|
1625
|
+
}, Xe = {
|
|
1626
|
+
clientConfig: {},
|
|
1627
|
+
clientStyleProfile: {},
|
|
1628
|
+
config: {
|
|
1629
|
+
assets_prefix: "/assets",
|
|
1630
|
+
bundle: "widgetLoader",
|
|
1631
|
+
client_guid: "",
|
|
1632
|
+
dashboard_accounts_index: 6,
|
|
1633
|
+
dashboard_accounts_location: 0,
|
|
1634
|
+
dashboard_activity_index: 2,
|
|
1635
|
+
dashboard_activity_location: 0,
|
|
1636
|
+
dashboard_budgets_index: 5,
|
|
1637
|
+
dashboard_budgets_location: 1,
|
|
1638
|
+
dashboard_cash_flow_index: 0,
|
|
1639
|
+
dashboard_cash_flow_location: 0,
|
|
1640
|
+
dashboard_connect_index: 7,
|
|
1641
|
+
dashboard_connect_location: 1,
|
|
1642
|
+
dashboard_insights_index: 3,
|
|
1643
|
+
dashboard_insights_location: 1,
|
|
1644
|
+
dashboard_spending_index: 1,
|
|
1645
|
+
dashboard_spending_location: 1,
|
|
1646
|
+
dashboard_survey_index: 8,
|
|
1647
|
+
dashboard_survey_location: 1,
|
|
1648
|
+
dashboard_trends_index: 4,
|
|
1649
|
+
dashboard_trends_location: 0,
|
|
1650
|
+
display_account_number_in_accounts: !0,
|
|
1651
|
+
display_add_manual_transaction_in_transactions: !0,
|
|
1652
|
+
display_available_balance_in_accounts: !0,
|
|
1653
|
+
display_email_edit_field_in_settings: !0,
|
|
1654
|
+
display_mobile_devices_in_settings: !0,
|
|
1655
|
+
display_notification_settings_in_settings: !0,
|
|
1656
|
+
display_only_external_accounts_in_accounts: !1,
|
|
1657
|
+
display_password_options_in_settings: !0,
|
|
1658
|
+
display_sms_edit_field_in_settings: !0,
|
|
1659
|
+
display_terms_and_conditions: !0,
|
|
1660
|
+
display_user_profile_in_settings: !0,
|
|
1661
|
+
display_user_transaction_rules_in_settings: !0,
|
|
1662
|
+
display_widget_headings: !0,
|
|
1663
|
+
enable_add_account_in_zero_state: !0,
|
|
1664
|
+
enable_aggregation_prompts: !0,
|
|
1665
|
+
enable_external_accounts_in_goals_widget: !0,
|
|
1666
|
+
enable_funds_transfers_in_goals_widget: !1,
|
|
1667
|
+
enable_manual_accounts: !0,
|
|
1668
|
+
enable_mark_account_closed_for_held_accounts: !0,
|
|
1669
|
+
enable_mark_account_duplicate_for_held_accounts: !0,
|
|
1670
|
+
enable_renaming_home_accounts: !0,
|
|
1671
|
+
enable_support_requests: !1,
|
|
1672
|
+
language: "en-US",
|
|
1673
|
+
product_name: "Money Dashboard",
|
|
1674
|
+
session_token: "",
|
|
1675
|
+
show_account_nicknames_in_master: !1,
|
|
1676
|
+
show_accounts_widget_in_master: !0,
|
|
1677
|
+
show_budgets_widget_in_master: !0,
|
|
1678
|
+
show_carousel_card_border_in_pulse_micro_widget: !1,
|
|
1679
|
+
show_cash_flow_widget_in_master: !0,
|
|
1680
|
+
show_connections_widget_in_master: !0,
|
|
1681
|
+
show_debts_widget_in_master: !0,
|
|
1682
|
+
show_finstrong_widget_in_master: !0,
|
|
1683
|
+
show_full_experience_link_in_pulse_micro_widget: !1,
|
|
1684
|
+
show_full_experience_link_in_pulse_mini_widget: !1,
|
|
1685
|
+
show_goals_widget_in_master: !0,
|
|
1686
|
+
show_help_widget_in_master: !0,
|
|
1687
|
+
show_horizontal_padding_in_pulse_micro_widget: !0,
|
|
1688
|
+
show_icon_in_pulse_micro_widget: !0,
|
|
1689
|
+
show_insights_widget_in_master: !0,
|
|
1690
|
+
show_investments_widget_in_master: !1,
|
|
1691
|
+
show_mx_branding: !0,
|
|
1692
|
+
show_navigation_controls_in_pulse_micro_widget: !0,
|
|
1693
|
+
show_net_worth_widget_in_master: !0,
|
|
1694
|
+
show_notifications_widget_in_master: !0,
|
|
1695
|
+
show_recurring_transactions_widget_in_master: !0,
|
|
1696
|
+
show_settings_widget_in_master: !0,
|
|
1697
|
+
show_spending_plan_widget_in_master: !1,
|
|
1698
|
+
show_spending_widget_in_master: !0,
|
|
1699
|
+
show_transactions_widget_in_master: !0,
|
|
1700
|
+
show_trends_widget_in_master: !0,
|
|
1701
|
+
type: "money-dashboard",
|
|
1702
|
+
websocket: {
|
|
1703
|
+
hmac: "",
|
|
1704
|
+
token: "",
|
|
1705
|
+
url: ""
|
|
1706
|
+
},
|
|
1707
|
+
widgets_display_name: "Money Dashboard "
|
|
1708
|
+
},
|
|
1709
|
+
honeyBadgerPublicKey: "",
|
|
1710
|
+
options: {
|
|
1711
|
+
assets_prefix: "/assets",
|
|
1712
|
+
brokaw_auth: {
|
|
1713
|
+
token: "",
|
|
1714
|
+
hmac: "",
|
|
1715
|
+
url: ""
|
|
1716
|
+
},
|
|
1717
|
+
brokaw_websocket_url: "",
|
|
1718
|
+
bundle: "widgetLoader",
|
|
1719
|
+
custom_copy_namespace: "",
|
|
1720
|
+
language: "en-US",
|
|
1721
|
+
product_name: "Master Widget",
|
|
1722
|
+
session_token: "",
|
|
1723
|
+
subtype: "master",
|
|
1724
|
+
type: "money_dashboard"
|
|
1725
|
+
},
|
|
1726
|
+
postHogPublicKey: "phc_1fVYJICC69TpW4wagp9o2XqQ8E7X98cAmcR5psSpfkE",
|
|
1727
|
+
userFeatures: []
|
|
1728
|
+
}, cn = class {
|
|
1729
|
+
appConfig = Xe;
|
|
1730
|
+
endpoint = "/";
|
|
1731
|
+
sessionToken = "";
|
|
1732
|
+
onError;
|
|
1733
|
+
onStoreUpdate;
|
|
1734
|
+
accountStore;
|
|
1735
|
+
appDataStore;
|
|
1736
|
+
analyticsStore;
|
|
1737
|
+
beatStore;
|
|
1738
|
+
budgetsStore;
|
|
1739
|
+
cashflowStore;
|
|
1740
|
+
categoryStore;
|
|
1741
|
+
connectStore;
|
|
1742
|
+
copyStore;
|
|
1743
|
+
debtsStore;
|
|
1744
|
+
finstrongStore;
|
|
1745
|
+
goalStore;
|
|
1746
|
+
helpStore;
|
|
1747
|
+
holdingStore;
|
|
1748
|
+
merchantStore;
|
|
1749
|
+
netWorthStore;
|
|
1750
|
+
notificationStore;
|
|
1751
|
+
recurringTransactionsStore;
|
|
1752
|
+
settingsStore;
|
|
1753
|
+
transactionStore;
|
|
1754
|
+
trendsStore;
|
|
1755
|
+
userStore;
|
|
1756
|
+
globalUiStore;
|
|
1757
|
+
constructor(e = Xe, t = "/", a, s) {
|
|
1758
|
+
this.appConfig = e, this.endpoint = t, this.sessionToken = e.options.session_token ?? "", this.onError = a, this.onStoreUpdate = s, this.accountStore = new jt(this), this.appDataStore = new zt(this), this.analyticsStore = new Xt(this), this.beatStore = new Zt(this), this.budgetsStore = new da(this), this.cashflowStore = new ha(this), this.categoryStore = new ga(this), this.connectStore = new ma(this), this.copyStore = new va(this), this.debtsStore = new Ta(this), this.finstrongStore = new Na(this), this.goalStore = new La(this), this.helpStore = new Ga(this), this.holdingStore = new Ya(this), this.merchantStore = new Wa(this), this.netWorthStore = new Za(this), this.notificationStore = new ts(this), this.recurringTransactionsStore = new As(this), this.settingsStore = new Ts(this), this.transactionStore = new xs(this), this.trendsStore = new js(this), this.userStore = new Qs(this), this.globalUiStore = new wa(this), p(this), Ct(() => {
|
|
1759
|
+
const { transactions: r } = this.transactionStore;
|
|
1760
|
+
this.emitUpdate({ transactions: r });
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
get isInitialized() {
|
|
1764
|
+
return this.globalUiStore.isInitialized;
|
|
1765
|
+
}
|
|
1766
|
+
emitUpdate = (e) => {
|
|
1767
|
+
this.onStoreUpdate?.(e);
|
|
1768
|
+
};
|
|
1769
|
+
loadConfigData = async () => {
|
|
1770
|
+
await Promise.all([
|
|
1771
|
+
this.copyStore.loadCopy(),
|
|
1772
|
+
this.appDataStore.loadAppData(),
|
|
1773
|
+
this.accountStore.refreshMembers(),
|
|
1774
|
+
this.userStore.loadUserFeatures()
|
|
1775
|
+
]);
|
|
1776
|
+
};
|
|
1777
|
+
loadData = async ({ accounts: e, appData: t, associatedBeats: a, categories: s, institutions: r, transactionRules: n, transactions: i, userFeatures: o, merchantBudgets: c } = {}) => {
|
|
1778
|
+
(!t || !o) && await this.loadConfigData(), t && this.appDataStore.setAppData(t), o && this.userStore.setUserFeatures(o), e && (await this.accountStore.loadMembers(), r && this.accountStore.setInstitutions(r), this.accountStore.setAccounts(e)), a && this.transactionStore.setAssociatedBeats(a), s && this.categoryStore.setCategories(s), i && this.transactionStore.setTransactions(i), n && this.transactionStore.setTransactionRules(n), c && this.budgetsStore.setMerchantBudgets(c);
|
|
1779
|
+
};
|
|
1780
|
+
}, wa = class {
|
|
1781
|
+
globalStore;
|
|
1782
|
+
accountFilterMap = /* @__PURE__ */ new Map();
|
|
1783
|
+
displayedDate = /* @__PURE__ */ new Date();
|
|
1784
|
+
displayedDateRange = {
|
|
1785
|
+
start: M(this.displayedDate),
|
|
1786
|
+
end: B(this.displayedDate)
|
|
1787
|
+
};
|
|
1788
|
+
constructor(e) {
|
|
1789
|
+
p(this), this.globalStore = e, st(() => this.globalStore.accountStore.visibleAccounts, (t) => {
|
|
1790
|
+
this.populateAccountFilterMap(t);
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
get allSelectedAccounts() {
|
|
1794
|
+
return this.globalStore.accountStore.detailedAccounts.filter((e) => !e.is_excluded_from_accounts);
|
|
1795
|
+
}
|
|
1796
|
+
get selectedAccounts() {
|
|
1797
|
+
return this.globalStore.accountStore.visibleAccounts.filter((e) => !e.is_excluded_from_accounts);
|
|
1798
|
+
}
|
|
1799
|
+
get selectedAccountGuids() {
|
|
1800
|
+
return this.selectedAccounts.map((e) => e.guid);
|
|
1801
|
+
}
|
|
1802
|
+
get isCopyLoaded() {
|
|
1803
|
+
return this.globalStore.copyStore.isInitialized;
|
|
1804
|
+
}
|
|
1805
|
+
get isConfigLoaded() {
|
|
1806
|
+
return this.globalStore.appDataStore.isAppDataLoaded;
|
|
1807
|
+
}
|
|
1808
|
+
get areUserFeaturesLoaded() {
|
|
1809
|
+
return this.globalStore.userStore.userFeaturesLoaded;
|
|
1810
|
+
}
|
|
1811
|
+
get isInitialized() {
|
|
1812
|
+
return this.isCopyLoaded && this.isConfigLoaded && this.areUserFeaturesLoaded;
|
|
1813
|
+
}
|
|
1814
|
+
populateAccountFilterMap = (e) => {
|
|
1815
|
+
e && e.forEach((t) => {
|
|
1816
|
+
this.accountFilterMap.set(t.guid, !t.is_excluded_from_accounts);
|
|
1817
|
+
});
|
|
1818
|
+
};
|
|
1819
|
+
resetAccountFilterMap = () => {
|
|
1820
|
+
this.accountFilterMap.clear(), this.populateAccountFilterMap(this.globalStore.accountStore.visibleAccounts);
|
|
1821
|
+
};
|
|
1822
|
+
updateAccountFilterMap = (e, t) => {
|
|
1823
|
+
this.accountFilterMap.set(e, t);
|
|
1824
|
+
};
|
|
1825
|
+
setDisplayedDate = (e, t) => {
|
|
1826
|
+
this.displayedDate = t, this.displayedDateRange = {
|
|
1827
|
+
start: e,
|
|
1828
|
+
end: t
|
|
1829
|
+
};
|
|
1830
|
+
};
|
|
1831
|
+
get shouldDisableNextDate() {
|
|
1832
|
+
return J(this.displayedDate) === J(P(/* @__PURE__ */ new Date(), 1));
|
|
1833
|
+
}
|
|
1834
|
+
get shouldDisablePrevDate() {
|
|
1835
|
+
return J(this.displayedDate) === J(/* @__PURE__ */ new Date());
|
|
1836
|
+
}
|
|
1837
|
+
}, va = class {
|
|
1838
|
+
globalStore;
|
|
1839
|
+
api = new ye("/", "");
|
|
1840
|
+
copy = {};
|
|
1841
|
+
featureNamespace = "experiences";
|
|
1842
|
+
isInitialized = !1;
|
|
1843
|
+
constructor(e) {
|
|
1844
|
+
this.globalStore = e, this.api = new ye(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
1845
|
+
}
|
|
1846
|
+
loadCopy = async () => {
|
|
1847
|
+
await this.getCopy(this.featureNamespace), g(() => {
|
|
1848
|
+
this.isInitialized = !0;
|
|
1849
|
+
});
|
|
1850
|
+
};
|
|
1851
|
+
getCopy = async (e, t = "") => {
|
|
1852
|
+
try {
|
|
1853
|
+
const a = await this.api.getGlobalCopy(e, t);
|
|
1854
|
+
g(() => {
|
|
1855
|
+
this.copy = a[e];
|
|
1856
|
+
});
|
|
1857
|
+
} catch (a) {
|
|
1858
|
+
console.error(`Error occurred while fetching ${this.featureNamespace} copy: ${a}`);
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
1861
|
+
};
|
|
1862
|
+
function ln(e, t) {
|
|
1863
|
+
const a = t.track_type === y.DEBT_TRACK ? t.initial_amount : t.amount;
|
|
1864
|
+
let s = t.current_amount / a;
|
|
1865
|
+
s > 1 && (s = 1), s = t.track_type === y.DEBT_TRACK ? 1 - s : s, isNaN(s) && (s = 1);
|
|
1866
|
+
let r = "chart.chart1", n = "common.black";
|
|
1867
|
+
t.track_type === y.DEBT_TRACK ? (n = "common.white", r = "chart.chart5") : t.track_type === y.RETIREMENT_TRACK && (r = "chart.chart6");
|
|
1868
|
+
const i = {
|
|
1869
|
+
style: "percent",
|
|
1870
|
+
minimumFractionDigits: 0,
|
|
1871
|
+
maximumFractionDigits: 0
|
|
1872
|
+
}, o = t.is_complete ? t.completed_at : t.projected_to_complete_at, c = o ? L(o) : /* @__PURE__ */ new Date(), d = C(e.goal_percentage, oa(s, i)), h = C(t.is_complete ? e.completed_label : e.goal_projection, w(c, N.MONTH_SHORT_YEAR));
|
|
1873
|
+
return {
|
|
1874
|
+
backgroundColor: r,
|
|
1875
|
+
color: n,
|
|
1876
|
+
percentage: s,
|
|
1877
|
+
percentageText: d,
|
|
1878
|
+
projectedText: h
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
function dn(e) {
|
|
1882
|
+
return [
|
|
1883
|
+
{
|
|
1884
|
+
bgcolor: "chart.chart1",
|
|
1885
|
+
icon: "attach_money",
|
|
1886
|
+
label: e.saving_goal_label,
|
|
1887
|
+
description: e.saving_goal_description,
|
|
1888
|
+
subTypes: [
|
|
1889
|
+
{
|
|
1890
|
+
icon: "ecg_heart",
|
|
1891
|
+
label: e.saving_goal_emergency_fund,
|
|
1892
|
+
metaType: x.EMERGENCY_FUND
|
|
1893
|
+
},
|
|
1894
|
+
{
|
|
1895
|
+
icon: "directions_car",
|
|
1896
|
+
label: e.saving_gaol_automobile,
|
|
1897
|
+
metaType: x.AUTOMOBILE
|
|
1898
|
+
},
|
|
1899
|
+
{
|
|
1900
|
+
icon: "school",
|
|
1901
|
+
label: e.saving_goal_college,
|
|
1902
|
+
metaType: x.COLLEGE
|
|
1903
|
+
},
|
|
1904
|
+
{
|
|
1905
|
+
icon: "home",
|
|
1906
|
+
label: e.saving_goal_home,
|
|
1907
|
+
metaType: x.HOUSE
|
|
1908
|
+
},
|
|
1909
|
+
{
|
|
1910
|
+
icon: "mountain_flag",
|
|
1911
|
+
label: e.saving_goal_recreational,
|
|
1912
|
+
metaType: x.RECREATIONAL_VEHICLE
|
|
1913
|
+
},
|
|
1914
|
+
{
|
|
1915
|
+
icon: "airplane_ticket",
|
|
1916
|
+
label: e.saving_goal_vacation,
|
|
1917
|
+
metaType: x.VACATION
|
|
1918
|
+
},
|
|
1919
|
+
{
|
|
1920
|
+
icon: "desktop_windows",
|
|
1921
|
+
label: e.saving_goal_electronic,
|
|
1922
|
+
metaType: x.ELECTRONIC
|
|
1923
|
+
},
|
|
1924
|
+
{
|
|
1925
|
+
icon: "payments",
|
|
1926
|
+
label: e.saving_goal_other,
|
|
1927
|
+
metaType: x.OTHER
|
|
1928
|
+
}
|
|
1929
|
+
],
|
|
1930
|
+
type: y.SAVINGS_TRACK
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
bgcolor: "chart.chart5",
|
|
1934
|
+
icon: "note_stack",
|
|
1935
|
+
label: e.debt_goal_label,
|
|
1936
|
+
description: e.debt_goal_description,
|
|
1937
|
+
subTypes: [],
|
|
1938
|
+
type: y.DEBT_TRACK
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
bgcolor: "chart.chart6",
|
|
1942
|
+
icon: "person",
|
|
1943
|
+
label: e.retirement_goal_label,
|
|
1944
|
+
description: e.retirement_goal_description,
|
|
1945
|
+
subTypes: [],
|
|
1946
|
+
type: y.RETIREMENT_TRACK
|
|
1947
|
+
}
|
|
1948
|
+
];
|
|
1949
|
+
}
|
|
1950
|
+
var hn = (e, t) => {
|
|
1951
|
+
switch (e) {
|
|
1952
|
+
case y.DEBT_TRACK:
|
|
1953
|
+
return C(t.zero_state_ongoing, "debt");
|
|
1954
|
+
case y.SAVINGS_TRACK:
|
|
1955
|
+
return C(t.zero_state_ongoing, "saving");
|
|
1956
|
+
default:
|
|
1957
|
+
return C(t.zero_state_ongoing, "retirement");
|
|
1958
|
+
}
|
|
1959
|
+
}, Je = (e, t) => T(Ae(L(t), e)), La = class {
|
|
1960
|
+
globalStore;
|
|
1961
|
+
api = new be("/", "");
|
|
1962
|
+
goals = [];
|
|
1963
|
+
goalsLoaded = !1;
|
|
1964
|
+
retirementGoals = [];
|
|
1965
|
+
retirementGoalsLoaded = !1;
|
|
1966
|
+
retirementGoalAccounts = [];
|
|
1967
|
+
retirementGoalAccountsLoaded = !1;
|
|
1968
|
+
monthlyCashFlowProfile = void 0;
|
|
1969
|
+
monthlyCashFlowProfileLoaded = !1;
|
|
1970
|
+
newRetirementGoalAccounts = [];
|
|
1971
|
+
alert = "";
|
|
1972
|
+
selectedGoal = void 0;
|
|
1973
|
+
constructor(e) {
|
|
1974
|
+
this.globalStore = e, this.api = new be(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
1975
|
+
}
|
|
1976
|
+
get allGoals() {
|
|
1977
|
+
if (!this.isAllGoalDataLoaded) return [];
|
|
1978
|
+
const e = this.globalStore.copyStore.copy.goals, t = this.globalStore.userStore.user.birthday;
|
|
1979
|
+
return [...this.goals, ...this.retirementGoals.map((a) => ({
|
|
1980
|
+
...a,
|
|
1981
|
+
amount: a.target_amount,
|
|
1982
|
+
name: e.retirement,
|
|
1983
|
+
track_type: y.RETIREMENT_TRACK,
|
|
1984
|
+
projected_to_complete_at: a.retirement_age && t ? Je(a.retirement_age, t) : void 0
|
|
1985
|
+
}))];
|
|
1986
|
+
}
|
|
1987
|
+
get orderedGoals() {
|
|
1988
|
+
return this.allGoals.slice().sort((e, t) => e.position - t.position);
|
|
1989
|
+
}
|
|
1990
|
+
get debtGoals() {
|
|
1991
|
+
return this.orderedGoals.filter((e) => e.track_type === y.DEBT_TRACK);
|
|
1992
|
+
}
|
|
1993
|
+
get retirmentGoals() {
|
|
1994
|
+
return this.orderedGoals.filter((e) => e.track_type === y.RETIREMENT_TRACK);
|
|
1995
|
+
}
|
|
1996
|
+
get savingGoals() {
|
|
1997
|
+
return this.orderedGoals.filter((e) => e.track_type === y.SAVINGS_TRACK);
|
|
1998
|
+
}
|
|
1999
|
+
get ongoingGoalsForMicroWidget() {
|
|
2000
|
+
const e = this.allGoals.filter((a) => !a.is_complete && a.track_type !== y.EMERGENCY_FUND_TRACK && a.track_type !== null), t = [
|
|
2001
|
+
y.SAVINGS_TRACK,
|
|
2002
|
+
y.DEBT_TRACK,
|
|
2003
|
+
y.RETIREMENT_TRACK
|
|
2004
|
+
];
|
|
2005
|
+
return e.sort((a, s) => (a.track_type ? t.indexOf(a.track_type) : -1) - (s.track_type ? t.indexOf(s.track_type) : -1)).slice(0, 3);
|
|
2006
|
+
}
|
|
2007
|
+
get isAllGoalDataLoaded() {
|
|
2008
|
+
return this.goalsLoaded && this.retirementGoalsLoaded && this.retirementGoalAccountsLoaded && this.monthlyCashFlowProfileLoaded;
|
|
2009
|
+
}
|
|
2010
|
+
setGoals = (e) => {
|
|
2011
|
+
this.goals = e, this.goalsLoaded = !0;
|
|
2012
|
+
};
|
|
2013
|
+
setRetirementGoals = (e) => {
|
|
2014
|
+
this.retirementGoals = e, this.retirementGoalsLoaded = !0;
|
|
2015
|
+
};
|
|
2016
|
+
setRetirementGoalAccounts = (e) => {
|
|
2017
|
+
this.retirementGoalAccounts = e, this.retirementGoalAccountsLoaded = !0;
|
|
2018
|
+
};
|
|
2019
|
+
setMonthlyCashFlowProfile = (e) => {
|
|
2020
|
+
this.monthlyCashFlowProfile = e, this.monthlyCashFlowProfileLoaded = !0;
|
|
2021
|
+
};
|
|
2022
|
+
loadGoalData = async () => {
|
|
2023
|
+
await Promise.all([
|
|
2024
|
+
this.loadGoals(),
|
|
2025
|
+
this.loadRetirementGoals(),
|
|
2026
|
+
this.loadRetirementGoalAccounts(),
|
|
2027
|
+
this.loadMonthlyCashFlowProfile()
|
|
2028
|
+
]);
|
|
2029
|
+
};
|
|
2030
|
+
loadGoals = async () => {
|
|
2031
|
+
try {
|
|
2032
|
+
const e = await this.api.getGoals();
|
|
2033
|
+
this.setGoals(e);
|
|
2034
|
+
} catch (e) {
|
|
2035
|
+
console.error(`Error occured while getting goals: ${e}`);
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
loadRetirementGoals = async () => {
|
|
2039
|
+
try {
|
|
2040
|
+
const e = await this.api.getRetirementGoals();
|
|
2041
|
+
this.setRetirementGoals(e);
|
|
2042
|
+
} catch (e) {
|
|
2043
|
+
console.error(`Error occurred while loading retirement goals: ${e}`);
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
loadRetirementGoalAccounts = async () => {
|
|
2047
|
+
try {
|
|
2048
|
+
const e = await this.api.getRetirementGoalAccounts();
|
|
2049
|
+
this.setRetirementGoalAccounts(e);
|
|
2050
|
+
} catch (e) {
|
|
2051
|
+
console.error(`Error occurred while loading retirement goal accounts: ${e}`);
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
loadMonthlyCashFlowProfile = async () => {
|
|
2055
|
+
try {
|
|
2056
|
+
const e = await this.api.getMonthlyCashFlowProfile();
|
|
2057
|
+
this.setMonthlyCashFlowProfile(e);
|
|
2058
|
+
} catch (e) {
|
|
2059
|
+
console.error(`Error occurred while loading monthly cash flow profile: ${e}`);
|
|
2060
|
+
}
|
|
2061
|
+
};
|
|
2062
|
+
addGoal = async (e) => {
|
|
2063
|
+
try {
|
|
2064
|
+
const t = await this.api.addGoal(e);
|
|
2065
|
+
this.setGoals([...this.goals, t]);
|
|
2066
|
+
} catch (t) {
|
|
2067
|
+
console.error(`Error occurred while adding goal: ${t}`);
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2070
|
+
addRetirementGoal = async (e) => {
|
|
2071
|
+
const t = this.globalStore.copyStore.copy.goals;
|
|
2072
|
+
try {
|
|
2073
|
+
const a = await this.api.addRetirementGoal(e), s = [], r = this.globalStore.userStore.user.birthday;
|
|
2074
|
+
for (const n of this.newRetirementGoalAccounts) {
|
|
2075
|
+
const i = await this.api.addRetirementGoalAccount({
|
|
2076
|
+
...n,
|
|
2077
|
+
retirement_goal_guid: a.guid
|
|
2078
|
+
});
|
|
2079
|
+
s.push(i);
|
|
2080
|
+
}
|
|
2081
|
+
this.setNewRetirementGoalAccounts([]), this.retirementGoals = [...this.retirementGoals, {
|
|
2082
|
+
...a,
|
|
2083
|
+
amount: a.target_amount,
|
|
2084
|
+
name: t.retirement,
|
|
2085
|
+
track_type: y.RETIREMENT_TRACK,
|
|
2086
|
+
projected_to_complete_at: a.retirement_age && r ? Je(a.retirement_age, r) : void 0
|
|
2087
|
+
}], this.setRetirementGoalAccounts([...this.retirementGoalAccounts, ...s]);
|
|
2088
|
+
} catch (a) {
|
|
2089
|
+
console.error(`Error occurred while adding retirement goal: ${a}`);
|
|
2090
|
+
}
|
|
2091
|
+
};
|
|
2092
|
+
addRetirementGoalAccount = async (e) => {
|
|
2093
|
+
try {
|
|
2094
|
+
const t = await this.api.addRetirementGoalAccount(e);
|
|
2095
|
+
g(() => {
|
|
2096
|
+
this.retirementGoalAccounts = [...this.retirementGoalAccounts, t];
|
|
2097
|
+
});
|
|
2098
|
+
} catch (t) {
|
|
2099
|
+
console.error(`Error occurred while adding retirement goal account: ${t}`);
|
|
2100
|
+
}
|
|
2101
|
+
};
|
|
2102
|
+
deleteGoal = async (e) => {
|
|
2103
|
+
try {
|
|
2104
|
+
await this.api.removeGoal(e);
|
|
2105
|
+
const t = this.goals.findIndex((a) => a.guid === e);
|
|
2106
|
+
t >= 0 && this.goals.splice(t, 1);
|
|
2107
|
+
} catch (t) {
|
|
2108
|
+
console.error(`Error occured while deleting goal: ${t}`);
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
deleteRetirementGoal = async (e) => {
|
|
2112
|
+
try {
|
|
2113
|
+
const t = this.retirementGoalAccounts.filter((s) => s.retirement_goal_guid === e.guid);
|
|
2114
|
+
for (const s of t) await this.deleteRetirementGoalAccount(s.guid);
|
|
2115
|
+
await this.api.removeRetirementGoal(e.guid);
|
|
2116
|
+
const a = this.retirementGoals.findIndex((s) => s.guid === e.guid);
|
|
2117
|
+
a >= 0 && this.retirementGoals.splice(a, 1);
|
|
2118
|
+
} catch (t) {
|
|
2119
|
+
console.error(`Error deleting retirement goal: ${t}`);
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
deleteRetirementGoalAccount = async (e) => {
|
|
2123
|
+
try {
|
|
2124
|
+
await this.api.removeRetirementGoalAccount(e);
|
|
2125
|
+
const t = this.retirementGoalAccounts.findIndex((a) => a.guid === e);
|
|
2126
|
+
t >= 0 && this.retirementGoalAccounts.splice(t, 1);
|
|
2127
|
+
} catch (t) {
|
|
2128
|
+
console.error(`Error deleting retirement goal account: ${t}`);
|
|
2129
|
+
}
|
|
2130
|
+
};
|
|
2131
|
+
reorderGoals = async (e) => {
|
|
2132
|
+
try {
|
|
2133
|
+
const t = await this.api.reorderGoals(e);
|
|
2134
|
+
g(() => {
|
|
2135
|
+
for (const a of t) {
|
|
2136
|
+
const s = this.goals.findIndex((r) => r.guid === a.guid);
|
|
2137
|
+
s >= 0 && (this.goals[s].position = a.position);
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
} catch (t) {
|
|
2141
|
+
console.error(`Error reordering goals: ${t}`);
|
|
2142
|
+
}
|
|
2143
|
+
};
|
|
2144
|
+
setAlert = (e) => this.alert = e;
|
|
2145
|
+
setNewRetirementGoalAccounts = (e) => {
|
|
2146
|
+
this.newRetirementGoalAccounts = e;
|
|
2147
|
+
};
|
|
2148
|
+
setSelectedGoal = (e) => this.selectedGoal = e;
|
|
2149
|
+
updateGoal = async (e) => {
|
|
2150
|
+
try {
|
|
2151
|
+
const t = await this.api.updateGoal(e);
|
|
2152
|
+
g(() => {
|
|
2153
|
+
const a = this.goals.findIndex((s) => s.guid === e.guid);
|
|
2154
|
+
a >= 0 && (this.goals[a] = t), this.selectedGoal?.guid === e.guid && this.setSelectedGoal(t);
|
|
2155
|
+
});
|
|
2156
|
+
} catch (t) {
|
|
2157
|
+
console.error(`Error occurred while updating goal: ${t}`);
|
|
2158
|
+
}
|
|
2159
|
+
};
|
|
2160
|
+
updateRetirementGoal = async (e) => {
|
|
2161
|
+
try {
|
|
2162
|
+
const t = await this.api.updateRetirementGoal({
|
|
2163
|
+
...e,
|
|
2164
|
+
target_amount: e.amount
|
|
2165
|
+
});
|
|
2166
|
+
g(() => {
|
|
2167
|
+
const a = this.retirementGoals.findIndex((s) => s.guid === e.guid);
|
|
2168
|
+
a >= 0 && (this.retirementGoals[a] = t), this.selectedGoal?.guid === e.guid && this.setSelectedGoal(this.allGoals.find((s) => s.guid === e.guid));
|
|
2169
|
+
});
|
|
2170
|
+
} catch (t) {
|
|
2171
|
+
console.error(`Error occurred while updating goal: ${t}`);
|
|
2172
|
+
}
|
|
2173
|
+
};
|
|
2174
|
+
updateMonthlyCashFlowProfile = async (e) => {
|
|
2175
|
+
try {
|
|
2176
|
+
const t = await this.api.updateMonthlyCashFlowProfile(e);
|
|
2177
|
+
this.setMonthlyCashFlowProfile(t);
|
|
2178
|
+
} catch (t) {
|
|
2179
|
+
console.error(`Error occurred while updating monthly Cash Flow profile: ${t}`);
|
|
2180
|
+
}
|
|
2181
|
+
};
|
|
2182
|
+
}, Oa = [
|
|
2183
|
+
{
|
|
2184
|
+
flags: ["show_accounts_widget_in_master"],
|
|
2185
|
+
guid: "accounts",
|
|
2186
|
+
icon: "account_balance",
|
|
2187
|
+
title: "Accounts",
|
|
2188
|
+
topics: [
|
|
2189
|
+
{ topicKey: "accounts-overview" },
|
|
2190
|
+
{ topicKey: "trouble-adding-an-account" },
|
|
2191
|
+
{ topicKey: "need-to-fix-a-broken-account" },
|
|
2192
|
+
{ topicKey: "seeing-outdated-accounts-or-paid-off-loans" },
|
|
2193
|
+
{ topicKey: "seeing-duplicate-accounts" }
|
|
2194
|
+
]
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
flags: ["show_transactions_widget_in_master"],
|
|
2198
|
+
guid: "transactions",
|
|
2199
|
+
icon: "receipt_long",
|
|
2200
|
+
title: "Transactions",
|
|
2201
|
+
topics: [
|
|
2202
|
+
{ topicKey: "transactions-overview" },
|
|
2203
|
+
{ topicKey: "seeing-duplicate-transactions" },
|
|
2204
|
+
{ topicKey: "missing-transactions" },
|
|
2205
|
+
{ topicKey: "pending-transactions" },
|
|
2206
|
+
{ topicKey: "exporting-transactions" }
|
|
2207
|
+
]
|
|
2208
|
+
},
|
|
2209
|
+
{
|
|
2210
|
+
flags: ["show_spending_widget_in_master"],
|
|
2211
|
+
guid: "spending",
|
|
2212
|
+
icon: "donut_small",
|
|
2213
|
+
title: "Spending",
|
|
2214
|
+
topics: [
|
|
2215
|
+
{ topicKey: "spending-widget-overview" },
|
|
2216
|
+
{ topicKey: "not-seeing-all-spending-categories" },
|
|
2217
|
+
{ topicKey: "spending-categories-seem-inaccurate" }
|
|
2218
|
+
]
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
flags: ["show_budgets_widget_in_master"],
|
|
2222
|
+
guid: "budgets",
|
|
2223
|
+
icon: "bubble_chart",
|
|
2224
|
+
title: "Budgets",
|
|
2225
|
+
topics: [{ topicKey: "budgets-overview" }]
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
flags: ["show_trends_widget_in_master"],
|
|
2229
|
+
guid: "trends",
|
|
2230
|
+
icon: "multiline_chart",
|
|
2231
|
+
title: "Trends",
|
|
2232
|
+
topics: [{ topicKey: "trends-overview" }]
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
flags: ["show_debts_widget_in_master"],
|
|
2236
|
+
guid: "debts",
|
|
2237
|
+
icon: "note_stack",
|
|
2238
|
+
title: "Debts",
|
|
2239
|
+
topics: [{ topicKey: "debts-overview" }]
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
flags: ["show_net_worth_widget_in_master"],
|
|
2243
|
+
guid: "networth",
|
|
2244
|
+
icon: "elevation",
|
|
2245
|
+
title: "Net Worth",
|
|
2246
|
+
topics: [{ topicKey: "net-worth-overview" }]
|
|
2247
|
+
},
|
|
2248
|
+
{
|
|
2249
|
+
flags: ["show_goals_widget_in_master"],
|
|
2250
|
+
guid: "goals",
|
|
2251
|
+
icon: "trophy",
|
|
2252
|
+
title: "Goals",
|
|
2253
|
+
topics: [{ topicKey: "goals-overview" }]
|
|
2254
|
+
},
|
|
2255
|
+
{
|
|
2256
|
+
flags: ["show_cash_flow_widget_in_master"],
|
|
2257
|
+
guid: "cashflow",
|
|
2258
|
+
icon: "flowsheet",
|
|
2259
|
+
title: "Cash Flow",
|
|
2260
|
+
topics: [{ topicKey: "cash-flow-overview" }]
|
|
2261
|
+
},
|
|
2262
|
+
{
|
|
2263
|
+
flags: ["show_recurring_transactions_widget_in_master"],
|
|
2264
|
+
guid: "recurring_transactions",
|
|
2265
|
+
icon: "currency_exchange",
|
|
2266
|
+
title: "Recurring Transactions",
|
|
2267
|
+
topics: [{
|
|
2268
|
+
label: "Recurring Transactions Widget Overview",
|
|
2269
|
+
topicKey: "overview"
|
|
2270
|
+
}]
|
|
2271
|
+
},
|
|
2272
|
+
{
|
|
2273
|
+
flags: ["show_investments_widget_in_master"],
|
|
2274
|
+
guid: "investments",
|
|
2275
|
+
icon: "bid_landscape",
|
|
2276
|
+
title: "Investments",
|
|
2277
|
+
topics: [{ topicKey: "investments-overview" }]
|
|
2278
|
+
},
|
|
2279
|
+
{
|
|
2280
|
+
flags: ["show_notifications_widget_in_master"],
|
|
2281
|
+
guid: "alerts",
|
|
2282
|
+
icon: "account_balance",
|
|
2283
|
+
title: "Alerts",
|
|
2284
|
+
topics: [{ topicKey: "notifications-overview" }]
|
|
2285
|
+
},
|
|
2286
|
+
{
|
|
2287
|
+
guid: "general",
|
|
2288
|
+
icon: "info",
|
|
2289
|
+
title: "General",
|
|
2290
|
+
topics: [
|
|
2291
|
+
{ topicKey: "is-my-data-private-and-secure" },
|
|
2292
|
+
{ topicKey: "why-are-some-of-my-transactions-uncategorized" },
|
|
2293
|
+
{ topicKey: "why-cant-i-see-the-software" },
|
|
2294
|
+
{ topicKey: "how-do-i-log-out-of-the-software" }
|
|
2295
|
+
]
|
|
2296
|
+
},
|
|
2297
|
+
{
|
|
2298
|
+
guid: "insights",
|
|
2299
|
+
icon: "lightbulb",
|
|
2300
|
+
title: "Insights",
|
|
2301
|
+
topics: [{ topicKey: "insights-widget-overview" }]
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
flags: ["display_mobile_devices_in_settings"],
|
|
2305
|
+
guid: "mobile",
|
|
2306
|
+
icon: "phone_iphone",
|
|
2307
|
+
title: "Mobile",
|
|
2308
|
+
topics: [{ topicKey: "mobile-devices-overview" }]
|
|
2309
|
+
}
|
|
2310
|
+
], un = [
|
|
2311
|
+
{
|
|
2312
|
+
guid: "personal_information",
|
|
2313
|
+
icon: "person",
|
|
2314
|
+
topics: [
|
|
2315
|
+
{ type: "external" },
|
|
2316
|
+
{ type: "external" },
|
|
2317
|
+
{ type: "internal" },
|
|
2318
|
+
{ type: "external" }
|
|
2319
|
+
]
|
|
2320
|
+
},
|
|
2321
|
+
{
|
|
2322
|
+
guid: "money_movement",
|
|
2323
|
+
icon: "currency_exchange",
|
|
2324
|
+
topics: [
|
|
2325
|
+
{ type: "external" },
|
|
2326
|
+
{ type: "external" },
|
|
2327
|
+
{ type: "external" },
|
|
2328
|
+
{ type: "external" }
|
|
2329
|
+
]
|
|
2330
|
+
},
|
|
2331
|
+
{
|
|
2332
|
+
guid: "institution",
|
|
2333
|
+
icon: "account_balance",
|
|
2334
|
+
topics: [
|
|
2335
|
+
{ type: "external" },
|
|
2336
|
+
{ type: "other" },
|
|
2337
|
+
{ type: "internal" },
|
|
2338
|
+
{ type: "internal" }
|
|
2339
|
+
]
|
|
2340
|
+
},
|
|
2341
|
+
{
|
|
2342
|
+
guid: "transactions",
|
|
2343
|
+
icon: "compare_arrows",
|
|
2344
|
+
topics: [
|
|
2345
|
+
{ type: "internal" },
|
|
2346
|
+
{ type: "external" },
|
|
2347
|
+
{ type: "internal" }
|
|
2348
|
+
]
|
|
2349
|
+
}
|
|
2350
|
+
], gn = [
|
|
2351
|
+
{ type: "external" },
|
|
2352
|
+
{ type: "external" },
|
|
2353
|
+
{ type: "external" },
|
|
2354
|
+
{ type: "external" },
|
|
2355
|
+
{ type: "other" },
|
|
2356
|
+
{ type: "internal" }
|
|
2357
|
+
], ba = (e, t) => e.guid === "general" || e.guid === "insights" ? !0 : e.flags ? e.flags.every((a) => t[a]) : !1, Ma = (e, t) => {
|
|
2358
|
+
const a = [];
|
|
2359
|
+
for (const s of Oa) {
|
|
2360
|
+
const r = t[s.guid];
|
|
2361
|
+
if (!r) continue;
|
|
2362
|
+
const n = {
|
|
2363
|
+
...s,
|
|
2364
|
+
title: r.label,
|
|
2365
|
+
topics: s.topics.map(({ topicKey: i }, o) => ({
|
|
2366
|
+
topicKey: i,
|
|
2367
|
+
label: r.topics[o]
|
|
2368
|
+
}))
|
|
2369
|
+
};
|
|
2370
|
+
ba(n, e) && a.push(n);
|
|
2371
|
+
}
|
|
2372
|
+
return a;
|
|
2373
|
+
}, Ga = class {
|
|
2374
|
+
alert = {
|
|
2375
|
+
message: "",
|
|
2376
|
+
severity: void 0
|
|
2377
|
+
};
|
|
2378
|
+
api = new Me("/", "");
|
|
2379
|
+
appConfig;
|
|
2380
|
+
globalStore;
|
|
2381
|
+
isLoading = !1;
|
|
2382
|
+
constructor(e) {
|
|
2383
|
+
this.globalStore = e, this.api = new Me(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
2384
|
+
}
|
|
2385
|
+
createSupportTicket = async (e) => {
|
|
2386
|
+
try {
|
|
2387
|
+
this.isLoading = !0, await this.api.createSupportTicket(e), this.setAlert(this.copy.request_support_submit_success_message, "success");
|
|
2388
|
+
} catch (t) {
|
|
2389
|
+
this.setAlert(this.copy.request_support_submit_failure_message, "error"), console.error("Error occurred while submitting:", t);
|
|
2390
|
+
} finally {
|
|
2391
|
+
this.isLoading = !1;
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
setAlert = (e, t = void 0) => this.alert = {
|
|
2395
|
+
message: e,
|
|
2396
|
+
severity: t
|
|
2397
|
+
};
|
|
2398
|
+
get copy() {
|
|
2399
|
+
return this.globalStore.copyStore.copy.help;
|
|
2400
|
+
}
|
|
2401
|
+
get helpCategories() {
|
|
2402
|
+
const { client_communication_profile: e, client_profile: t } = this.globalStore.appDataStore.appData, { help: { category_list: a } } = this.globalStore.copyStore.copy;
|
|
2403
|
+
return Ma({
|
|
2404
|
+
...e,
|
|
2405
|
+
...t,
|
|
2406
|
+
...this.globalStore.appConfig.config
|
|
2407
|
+
}, a);
|
|
2408
|
+
}
|
|
2409
|
+
}, ut = /* @__PURE__ */ (function(e) {
|
|
2410
|
+
return e.Stocks = "stocks", e.Bonds = "bonds", e;
|
|
2411
|
+
})({}), Pa = {
|
|
2412
|
+
UNKNOWN: 0,
|
|
2413
|
+
LARGE_VALUE: 1,
|
|
2414
|
+
LARGE_CORE: 2,
|
|
2415
|
+
LARGE_GROWTH: 3,
|
|
2416
|
+
MID_VALUE: 4,
|
|
2417
|
+
MID_CORE: 5,
|
|
2418
|
+
MID_GROWTH: 6,
|
|
2419
|
+
SMALL_VALUE: 7,
|
|
2420
|
+
SMALL_CORE: 8,
|
|
2421
|
+
SMALL_GROWTH: 9
|
|
2422
|
+
}, Re = {
|
|
2423
|
+
0: "UNKNOWN",
|
|
2424
|
+
1: "LARGE_VALUE",
|
|
2425
|
+
2: "LARGE_CORE",
|
|
2426
|
+
3: "LARGE_GROWTH",
|
|
2427
|
+
4: "MID_VALUE",
|
|
2428
|
+
5: "MID_CORE",
|
|
2429
|
+
6: "MID_GROWTH",
|
|
2430
|
+
7: "SMALL_VALUE",
|
|
2431
|
+
8: "SMALL_CORE",
|
|
2432
|
+
9: "SMALL_GROWTH"
|
|
2433
|
+
}, Ua = {
|
|
2434
|
+
UNKNOWN: 0,
|
|
2435
|
+
HIGH_LIMITED: 1,
|
|
2436
|
+
HIGH_MODERATE: 2,
|
|
2437
|
+
HIGH_EXTENSIVE: 3,
|
|
2438
|
+
MEDIUM_LIMITED: 4,
|
|
2439
|
+
MEDIUM_MODERATE: 5,
|
|
2440
|
+
MEDIUM_EXTENSIVE: 6,
|
|
2441
|
+
LOW_LIMITED: 7,
|
|
2442
|
+
LOW_MODERATE: 8,
|
|
2443
|
+
LOW_EXTENSIVE: 9
|
|
2444
|
+
}, De = {
|
|
2445
|
+
0: "UNKNOWN",
|
|
2446
|
+
1: "HIGH_LIMITED",
|
|
2447
|
+
2: "HIGH_MODERATE",
|
|
2448
|
+
3: "HIGH_EXTENSIVE",
|
|
2449
|
+
4: "MEDIUM_LIMITED",
|
|
2450
|
+
5: "MEDIUM_MODERATE",
|
|
2451
|
+
6: "MEDIUM_EXTENSIVE",
|
|
2452
|
+
7: "LOW_LIMITED",
|
|
2453
|
+
8: "LOW_MODERATE",
|
|
2454
|
+
9: "LOW_EXTENSIVE"
|
|
2455
|
+
}, gt = (e, t = 3) => {
|
|
2456
|
+
const a = Object.keys(e).map(Number).filter((r) => r !== 0).sort((r, n) => r - n), s = [];
|
|
2457
|
+
for (let r = 0; r < a.length; r += t) s.push(a.slice(r, r + t).map((n) => e[n]));
|
|
2458
|
+
return s;
|
|
2459
|
+
}, Ba = gt(De), xa = gt(Re), Ha = (e) => {
|
|
2460
|
+
const t = qe(e, Et), a = qe(e, mt), s = (r, n) => {
|
|
2461
|
+
const i = r.reduce((c, d) => c + It(d), 0), o = r.reduce((c, d) => {
|
|
2462
|
+
const h = n(d);
|
|
2463
|
+
return Object.keys(h).forEach((_) => c[_] = (c[_] || 0) + h[_]), c;
|
|
2464
|
+
}, {});
|
|
2465
|
+
return Object.fromEntries(Object.entries(o).map(([c, d]) => [c, d / i * 100]));
|
|
2466
|
+
};
|
|
2467
|
+
return {
|
|
2468
|
+
stocks: s(t, pt),
|
|
2469
|
+
bonds: s(a, _t)
|
|
2470
|
+
};
|
|
2471
|
+
}, $a = (e) => {
|
|
2472
|
+
const t = e.filter((r) => !isNaN(r.equity_classification)), a = e.filter((r) => !isNaN(r.fixed_income_classification)), s = (r, n, i) => r.reduce((o, c) => {
|
|
2473
|
+
const d = n(c);
|
|
2474
|
+
return Object.keys(i).forEach((h) => {
|
|
2475
|
+
o[h] = (o[h] || 0) + (d[h] || 0);
|
|
2476
|
+
}), o;
|
|
2477
|
+
}, {});
|
|
2478
|
+
return {
|
|
2479
|
+
stocks: s(t, pt, Pa),
|
|
2480
|
+
bonds: s(a, _t, Ua)
|
|
2481
|
+
};
|
|
2482
|
+
}, Fa = (e, t) => Object.fromEntries(Object.entries(e).map(([a, s]) => [a, s * t / 100])), _t = (e) => ft(e, mt, De), mt = (e) => ({ [De[e.fixed_income_classification]]: 100 }), pt = (e) => ft(e, Et, Re), Et = (e) => {
|
|
2483
|
+
const { large_core_weight: t, large_growth_weight: a, large_value_weight: s, mid_core_weight: r, mid_growth_weight: n, mid_value_weight: i, small_core_weight: o, small_growth_weight: c, small_value_weight: d, unknown_weight: h, equity_classification: _ } = e, m = {
|
|
2484
|
+
LARGE_CORE: t ?? 0,
|
|
2485
|
+
LARGE_GROWTH: a ?? 0,
|
|
2486
|
+
LARGE_VALUE: s ?? 0,
|
|
2487
|
+
MID_CORE: r ?? 0,
|
|
2488
|
+
MID_GROWTH: n ?? 0,
|
|
2489
|
+
MID_VALUE: i ?? 0,
|
|
2490
|
+
SMALL_CORE: o ?? 0,
|
|
2491
|
+
SMALL_GROWTH: c ?? 0,
|
|
2492
|
+
SMALL_VALUE: d ?? 0,
|
|
2493
|
+
UNKNOWN: h ?? 0
|
|
2494
|
+
};
|
|
2495
|
+
return Te(m) === 0 && _ !== void 0 ? { [Re[_]]: 100 } : m;
|
|
2496
|
+
}, ft = (e, t, a) => {
|
|
2497
|
+
const s = t(e), r = It(e), n = Fa(s, r);
|
|
2498
|
+
if (Te(n) === 0) {
|
|
2499
|
+
const i = String(e.equity_classification ?? e.fixed_income_classification);
|
|
2500
|
+
if (i in a) return { [a[i]]: r };
|
|
2501
|
+
console.error(`Invalid classification key: ${i}`);
|
|
2502
|
+
}
|
|
2503
|
+
return n;
|
|
2504
|
+
}, _n = (e) => e.split("_").map((t) => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase()).join(" "), ka = (e) => e >= 1 ? `${_e(e).format("0")}%` : "< 1%", It = (e) => e.calculated_market_value ?? e.market_value, qe = (e, t) => e.filter((a) => {
|
|
2505
|
+
const s = Te(t(a));
|
|
2506
|
+
return s > 80 && s < 120;
|
|
2507
|
+
}), Va = (e, t) => {
|
|
2508
|
+
const a = t === ut.Stocks ? xa : Ba, s = e[t];
|
|
2509
|
+
return !s || !s || Object.keys(s).length === 0 ? a.map((r) => r.map(() => "0%")) : a.map((r) => r.map((n) => ka(s[n] ?? 0)));
|
|
2510
|
+
}, Te = (e) => Object.values(e).reduce((t, a) => t + a, 0), Ya = class {
|
|
2511
|
+
analysisType = ut.Stocks;
|
|
2512
|
+
api = new Ge("/", "");
|
|
2513
|
+
holdings = [];
|
|
2514
|
+
holdingsLoaded = !1;
|
|
2515
|
+
globalStore;
|
|
2516
|
+
showConnectionsWidget = !1;
|
|
2517
|
+
constructor(e) {
|
|
2518
|
+
this.globalStore = e, this.api = new Ge(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
2519
|
+
}
|
|
2520
|
+
get analysisChartData() {
|
|
2521
|
+
return Va(Ha(this.visibleHoldings), this.analysisType);
|
|
2522
|
+
}
|
|
2523
|
+
get analysisDetails() {
|
|
2524
|
+
return $a(this.visibleHoldings)[this.analysisType] || {};
|
|
2525
|
+
}
|
|
2526
|
+
get visibleHoldings() {
|
|
2527
|
+
return this.holdings.filter((e) => this.globalStore.globalUiStore.selectedAccountGuids.includes(e.account_guid));
|
|
2528
|
+
}
|
|
2529
|
+
setHoldings = (e) => {
|
|
2530
|
+
this.holdings = e, this.holdingsLoaded = !0;
|
|
2531
|
+
};
|
|
2532
|
+
setShowConnectionsWidget = (e) => {
|
|
2533
|
+
this.showConnectionsWidget = e;
|
|
2534
|
+
};
|
|
2535
|
+
loadHoldings = async () => {
|
|
2536
|
+
try {
|
|
2537
|
+
const e = await this.api.getHoldings();
|
|
2538
|
+
this.setHoldings(e);
|
|
2539
|
+
} catch (e) {
|
|
2540
|
+
console.error(`Error occured while getting holdings: ${e}`);
|
|
2541
|
+
}
|
|
2542
|
+
};
|
|
2543
|
+
setAnalysisType = (e) => {
|
|
2544
|
+
this.analysisType = e;
|
|
2545
|
+
};
|
|
2546
|
+
updateHoldings = async (e) => {
|
|
2547
|
+
this.holdingsLoaded = !1;
|
|
2548
|
+
try {
|
|
2549
|
+
const t = await this.api.updateHoldings(e), a = this.holdings.findIndex(({ guid: s }) => s === e.guid);
|
|
2550
|
+
if (a >= 0) {
|
|
2551
|
+
const s = [...this.holdings];
|
|
2552
|
+
s[a] = t, g(() => {
|
|
2553
|
+
this.holdings = s, this.holdingsLoaded = !0;
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2556
|
+
} catch (t) {
|
|
2557
|
+
console.error(`Error occurred while updating holding: ${t}`);
|
|
2558
|
+
}
|
|
2559
|
+
};
|
|
2560
|
+
}, Wa = class {
|
|
2561
|
+
globalStore;
|
|
2562
|
+
api = new Pe("/", "");
|
|
2563
|
+
merchant = null;
|
|
2564
|
+
merchants = [];
|
|
2565
|
+
isLoading = !1;
|
|
2566
|
+
constructor(e) {
|
|
2567
|
+
this.globalStore = e, this.api = new Pe(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
2568
|
+
}
|
|
2569
|
+
loadMerchants = async (e = "") => {
|
|
2570
|
+
this.isLoading = !0;
|
|
2571
|
+
const t = await this.api.getMerchants([e]);
|
|
2572
|
+
g(() => {
|
|
2573
|
+
this.merchants = t, this.isLoading = !1;
|
|
2574
|
+
});
|
|
2575
|
+
};
|
|
2576
|
+
loadMerchantByGuid = async (e) => {
|
|
2577
|
+
const t = await this.api.getMerchantByGuid(e);
|
|
2578
|
+
g(() => this.merchant = t);
|
|
2579
|
+
};
|
|
2580
|
+
}, At = 13, Ka = (e, t) => e.filter((a) => {
|
|
2581
|
+
const { is_closed: s, is_deleted: r, is_hidden: n, is_manual: i } = a;
|
|
2582
|
+
return s || r || n ? !1 : i || !a.guid ? !0 : t.some((o) => e.some((c) => o.guid === c.member_guid));
|
|
2583
|
+
}), ja = (e, t) => [...e, ...t], Ze = (e) => {
|
|
2584
|
+
if (e && e.length > 0) return e[e.length - 1];
|
|
2585
|
+
}, Qa = (e, t) => e.year_month - t.year_month, za = () => Array.from({ length: At }, (e, t) => Math.floor(M(k(/* @__PURE__ */ new Date(), t)).getTime() / 1e3)).sort(), Xa = (e, t, a) => !e.length || !t.length ? [] : za().reduceRight((s, r) => {
|
|
2586
|
+
const n = t.filter(({ year_month: d }) => d === parseInt(K(L(r), "yyyyMM"))), i = e.map((d) => {
|
|
2587
|
+
const h = n.find((m) => m.account_guid === d.guid), _ = {
|
|
2588
|
+
change: 0,
|
|
2589
|
+
guid: d.guid,
|
|
2590
|
+
name: d.name,
|
|
2591
|
+
type: d.account_type,
|
|
2592
|
+
balance: 0
|
|
2593
|
+
};
|
|
2594
|
+
if (!h && s.length === 0 && !d.balance) return _;
|
|
2595
|
+
if (!h && s.length === 0) return {
|
|
2596
|
+
..._,
|
|
2597
|
+
value: dt(d) ? -(d.balance ?? 0) : d.balance ?? 0
|
|
2598
|
+
};
|
|
2599
|
+
if (!h) {
|
|
2600
|
+
const m = s[0].accounts.find((D) => D.guid === d.guid);
|
|
2601
|
+
return m || _;
|
|
2602
|
+
}
|
|
2603
|
+
return {
|
|
2604
|
+
change: h.transaction_total,
|
|
2605
|
+
guid: d.guid,
|
|
2606
|
+
name: d.name,
|
|
2607
|
+
type: d.account_type,
|
|
2608
|
+
value: h.balance
|
|
2609
|
+
};
|
|
2610
|
+
}), { y: o, change: c } = i.reduce((d, h) => ({
|
|
2611
|
+
y: d.y + (h.value || 0),
|
|
2612
|
+
change: d.change + (h.change || 0)
|
|
2613
|
+
}), {
|
|
2614
|
+
y: 0,
|
|
2615
|
+
change: 0
|
|
2616
|
+
});
|
|
2617
|
+
return [{
|
|
2618
|
+
accounts: i,
|
|
2619
|
+
x: r,
|
|
2620
|
+
y: o,
|
|
2621
|
+
change: c
|
|
2622
|
+
}, ...s];
|
|
2623
|
+
}, []).slice(At - a), Ja = (e) => {
|
|
2624
|
+
const t = [], a = [];
|
|
2625
|
+
let s = 0, r = 0;
|
|
2626
|
+
return e?.accounts.forEach((n) => {
|
|
2627
|
+
n.change > 0 && (t.push({
|
|
2628
|
+
accountName: n.name,
|
|
2629
|
+
gain: n.change
|
|
2630
|
+
}), s += n.change), n.change < 0 && (a.push({
|
|
2631
|
+
accountName: n.name,
|
|
2632
|
+
loss: n.change
|
|
2633
|
+
}), r += n.change);
|
|
2634
|
+
}), {
|
|
2635
|
+
netWorth: e,
|
|
2636
|
+
gains: t,
|
|
2637
|
+
losses: a,
|
|
2638
|
+
totalGains: s,
|
|
2639
|
+
totalLosses: r
|
|
2640
|
+
};
|
|
2641
|
+
}, qa = (e) => {
|
|
2642
|
+
const t = [], a = [];
|
|
2643
|
+
let s = 0, r = 0;
|
|
2644
|
+
return e.forEach((n) => {
|
|
2645
|
+
if (dt(n)) {
|
|
2646
|
+
const i = n.balance ?? 0;
|
|
2647
|
+
a.push({
|
|
2648
|
+
accountName: n.name,
|
|
2649
|
+
accountType: n.account_type,
|
|
2650
|
+
balance: i
|
|
2651
|
+
}), r += i;
|
|
2652
|
+
} else {
|
|
2653
|
+
const i = n.balance ?? 0;
|
|
2654
|
+
t.push({
|
|
2655
|
+
accountName: n.name,
|
|
2656
|
+
accountType: n.account_type,
|
|
2657
|
+
balance: i
|
|
2658
|
+
}), s += i;
|
|
2659
|
+
}
|
|
2660
|
+
}), {
|
|
2661
|
+
assets: t,
|
|
2662
|
+
liabilities: a,
|
|
2663
|
+
totalAssets: s,
|
|
2664
|
+
totalLiabilities: r
|
|
2665
|
+
};
|
|
2666
|
+
}, mn = (e) => {
|
|
2667
|
+
const t = e.reduce((a, s) => {
|
|
2668
|
+
const r = s.accountType;
|
|
2669
|
+
return a[r] || (a[r] = []), a[r].push(s), a;
|
|
2670
|
+
}, {});
|
|
2671
|
+
return Object.entries(t).map(([a, s]) => ({
|
|
2672
|
+
icon: Ft[+a] || $t[+a],
|
|
2673
|
+
name: Ht[+a],
|
|
2674
|
+
accounts: s
|
|
2675
|
+
}));
|
|
2676
|
+
}, Za = class {
|
|
2677
|
+
globalStore;
|
|
2678
|
+
accountsApi = new se("/", "");
|
|
2679
|
+
monthlyAccountBalances = [];
|
|
2680
|
+
monthlyAccountBalancesLoaded = !1;
|
|
2681
|
+
hoveredIndex = -1;
|
|
2682
|
+
selectedIndex = -1;
|
|
2683
|
+
timeframe = 6;
|
|
2684
|
+
constructor(e) {
|
|
2685
|
+
this.globalStore = e, this.accountsApi = new se(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
2686
|
+
}
|
|
2687
|
+
get isNetWorthDataLoaded() {
|
|
2688
|
+
return this.globalStore.accountStore.isAccountDataLoaded && this.monthlyAccountBalancesLoaded;
|
|
2689
|
+
}
|
|
2690
|
+
get netWorthAccounts() {
|
|
2691
|
+
return Ka(this.globalStore.globalUiStore.selectedAccounts, this.globalStore.accountStore.members);
|
|
2692
|
+
}
|
|
2693
|
+
get netWorthData() {
|
|
2694
|
+
return {
|
|
2695
|
+
accounts: this.netWorthAccounts,
|
|
2696
|
+
monthlyAccountBalances: this.monthlyAccountBalances
|
|
2697
|
+
};
|
|
2698
|
+
}
|
|
2699
|
+
get netWorthChartData() {
|
|
2700
|
+
return Xa(this.netWorthAccounts, this.monthlyAccountBalances, this.timeframe);
|
|
2701
|
+
}
|
|
2702
|
+
get selectedData() {
|
|
2703
|
+
if (!(!this.netWorthChartData || this.netWorthChartData.length === 0))
|
|
2704
|
+
return this.selectedIndex === -1 ? Ze(this.netWorthChartData) : this.netWorthChartData[this.selectedIndex];
|
|
2705
|
+
}
|
|
2706
|
+
get hoveredData() {
|
|
2707
|
+
return this.hoveredIndex >= 0 ? this.netWorthChartData[this.hoveredIndex] : void 0;
|
|
2708
|
+
}
|
|
2709
|
+
get gainsLosses() {
|
|
2710
|
+
return Ja(this.selectedData);
|
|
2711
|
+
}
|
|
2712
|
+
get assetsLiabilities() {
|
|
2713
|
+
const { assets: e, liabilities: t, totalAssets: a, totalLiabilities: s } = qa(this.netWorthData.accounts);
|
|
2714
|
+
return {
|
|
2715
|
+
netWorth: Ze(this.netWorthChartData),
|
|
2716
|
+
assets: e,
|
|
2717
|
+
liabilities: t,
|
|
2718
|
+
totalAssets: a,
|
|
2719
|
+
totalLiabilities: s
|
|
2720
|
+
};
|
|
2721
|
+
}
|
|
2722
|
+
loadNetWorthData = async () => {
|
|
2723
|
+
this.globalStore.accountStore.isAccountDataLoaded || await this.globalStore.accountStore.loadAccountData();
|
|
2724
|
+
const e = (await Promise.all(this.netWorthAccounts.map((t) => this.getMonthlyAccountBalances(t.guid)))).reduce(ja, []).sort(Qa);
|
|
2725
|
+
this.setMonthlyAccountBalances(e);
|
|
2726
|
+
};
|
|
2727
|
+
getMonthlyAccountBalances = async (e) => {
|
|
2728
|
+
try {
|
|
2729
|
+
return await this.accountsApi.getMonthlyAccountBalances(e);
|
|
2730
|
+
} catch (t) {
|
|
2731
|
+
return console.error(`Error occured while fetching monthly account balances: ${t}`), [];
|
|
2732
|
+
}
|
|
2733
|
+
};
|
|
2734
|
+
setHoveredIndex = (e) => this.hoveredIndex = e;
|
|
2735
|
+
setMonthlyAccountBalances = (e) => {
|
|
2736
|
+
this.monthlyAccountBalances = e, this.monthlyAccountBalancesLoaded = !0;
|
|
2737
|
+
};
|
|
2738
|
+
setSelectedIndex = (e) => this.selectedIndex = e;
|
|
2739
|
+
setTimeframe = (e) => this.timeframe = e;
|
|
2740
|
+
}, le = null, pn = () => (le || (le = new Set(Object.values(f).filter((e) => typeof e == "number"))), le), En = (e, t) => !Lt(Ce(t[e].delivered_at), Ce(t[e - 1]?.delivered_at));
|
|
2741
|
+
function es(e) {
|
|
2742
|
+
const a = Math.floor(Date.now() / 1e3);
|
|
2743
|
+
return e.filter((s) => a - s.delivered_at <= 2592e3);
|
|
2744
|
+
}
|
|
2745
|
+
var ts = class {
|
|
2746
|
+
globalStore;
|
|
2747
|
+
api = new Ue("/", "");
|
|
2748
|
+
isLoading = !0;
|
|
2749
|
+
notifications = [];
|
|
2750
|
+
notificationsLoaded = !1;
|
|
2751
|
+
constructor(e) {
|
|
2752
|
+
this.globalStore = e, this.api = new Ue(e.endpoint, e.sessionToken, e.onError), p(this, { notifications: Nt });
|
|
2753
|
+
}
|
|
2754
|
+
get newNotifications() {
|
|
2755
|
+
return this.recentNotifications.filter((e) => !e.has_been_viewed);
|
|
2756
|
+
}
|
|
2757
|
+
get recentNotifications() {
|
|
2758
|
+
return es(this.notifications);
|
|
2759
|
+
}
|
|
2760
|
+
setNotifications = (e) => {
|
|
2761
|
+
this.notifications = e, this.notificationsLoaded = !0;
|
|
2762
|
+
};
|
|
2763
|
+
loadNotifications = async () => {
|
|
2764
|
+
this.isLoading = !0;
|
|
2765
|
+
try {
|
|
2766
|
+
const e = await this.api.getNotifications();
|
|
2767
|
+
this.setNotifications(e);
|
|
2768
|
+
} catch (e) {
|
|
2769
|
+
console.error(`Error occurred while loading notifications: ${e}`);
|
|
2770
|
+
} finally {
|
|
2771
|
+
g(() => {
|
|
2772
|
+
this.isLoading = !1;
|
|
2773
|
+
});
|
|
2774
|
+
}
|
|
2775
|
+
};
|
|
2776
|
+
markAllAsViewed = async () => {
|
|
2777
|
+
await this.api.markAllAsViewed();
|
|
2778
|
+
};
|
|
2779
|
+
updateNotification = async (e) => {
|
|
2780
|
+
e.has_been_viewed = !0, await this.api.updateNotification(e);
|
|
2781
|
+
};
|
|
2782
|
+
}, as = (e) => {
|
|
2783
|
+
let t = ae(e, Pt(e));
|
|
2784
|
+
for (; I(t, R()); ) t = te(t, 1);
|
|
2785
|
+
return t;
|
|
2786
|
+
}, ss = (e) => {
|
|
2787
|
+
let t = e;
|
|
2788
|
+
for (; I(t, R()); ) t = te(t, 2);
|
|
2789
|
+
return t;
|
|
2790
|
+
}, rs = (e) => {
|
|
2791
|
+
let t = Q(R(), e.getDate());
|
|
2792
|
+
for (; I(t, R()); ) t = P(t, 1);
|
|
2793
|
+
return t;
|
|
2794
|
+
}, ns = (e) => {
|
|
2795
|
+
let t = e;
|
|
2796
|
+
for (; I(t, R()); ) t = P(t, 2);
|
|
2797
|
+
return t;
|
|
2798
|
+
}, is = (e) => {
|
|
2799
|
+
let t = j(e, 1);
|
|
2800
|
+
for (; I(t, R()); ) t = j(t, 1);
|
|
2801
|
+
return t;
|
|
2802
|
+
}, os = (e) => {
|
|
2803
|
+
let t = e;
|
|
2804
|
+
for (; I(t, R()); ) t = j(t, 2);
|
|
2805
|
+
return t;
|
|
2806
|
+
}, cs = (e) => Ae(e, 1), fn = (e) => {
|
|
2807
|
+
const t = L(e);
|
|
2808
|
+
return new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate());
|
|
2809
|
+
}, In = (e) => w(L(e), N.DAY_OF_WEEK_MONTH_DAY), An = (e) => e ? w(L(e), N.MONTH_YEAR) : "", ls = (e) => {
|
|
2810
|
+
if (!e) return "";
|
|
2811
|
+
let t = e.user_name || e.feed_name || "";
|
|
2812
|
+
return e.account_number && (t = `${t} *${e.account_number}`), t;
|
|
2813
|
+
}, ds = (e, t) => {
|
|
2814
|
+
const a = [], s = e.recurrence_type === E.EveryYear, r = e.transactions.find((d) => d.repeating_transaction_guid === e.guid);
|
|
2815
|
+
if (!s && !r) return [];
|
|
2816
|
+
const n = bt(e.predicted_occurs_on), i = {
|
|
2817
|
+
accountGuid: e.account?.guid || "",
|
|
2818
|
+
amount: e.amount,
|
|
2819
|
+
categoryGuid: r?.category_guid || "",
|
|
2820
|
+
expectedDate: n,
|
|
2821
|
+
frequency: e.recurrence_type,
|
|
2822
|
+
institutionGuid: e.account?.institution_guid || "",
|
|
2823
|
+
institutionName: ls(e.account),
|
|
2824
|
+
merchantGuid: e.merchant_guid,
|
|
2825
|
+
name: e.description,
|
|
2826
|
+
recurrenceDay: e.recurrence_day,
|
|
2827
|
+
repeatingTransactionGuid: e.guid,
|
|
2828
|
+
secondRecurrenceDay: e.second_recurrence_day,
|
|
2829
|
+
status: O.Upcoming,
|
|
2830
|
+
type: e.repeating_transaction_type === kt.Income ? ie.Income : ie.Expense,
|
|
2831
|
+
transaction: void 0
|
|
2832
|
+
}, o = t.start, c = t.end;
|
|
2833
|
+
switch (e.recurrence_type) {
|
|
2834
|
+
case E.EveryWeek:
|
|
2835
|
+
a.push(...hs(i, o, c));
|
|
2836
|
+
break;
|
|
2837
|
+
case E.EveryOtherWeek:
|
|
2838
|
+
a.push(...us(i, o, c));
|
|
2839
|
+
break;
|
|
2840
|
+
case E.TwiceAMonth:
|
|
2841
|
+
a.push(...gs(i, o, c));
|
|
2842
|
+
break;
|
|
2843
|
+
case E.EveryMonth:
|
|
2844
|
+
a.push(..._s(i, o, c));
|
|
2845
|
+
break;
|
|
2846
|
+
case E.EveryOtherMonth:
|
|
2847
|
+
a.push(...ms(i, o, c));
|
|
2848
|
+
break;
|
|
2849
|
+
case E.EveryQuarter:
|
|
2850
|
+
a.push(...ps(i, o, c));
|
|
2851
|
+
break;
|
|
2852
|
+
case E.EveryOtherQuarter:
|
|
2853
|
+
a.push(...Es(i, o, c));
|
|
2854
|
+
break;
|
|
2855
|
+
case E.EveryYear:
|
|
2856
|
+
a.push(...fs(i, o, c));
|
|
2857
|
+
break;
|
|
2858
|
+
}
|
|
2859
|
+
for (const d of a) {
|
|
2860
|
+
const h = e.transactions.find((_) => _.repeating_transaction_guid === e.guid && _.date > T(ee(d.expectedDate, 5)) && _.date < T(Ie(d.expectedDate, 5)));
|
|
2861
|
+
h ? (d.transaction = h, d.status = O.Paid, d.occurredOnDate = L(h.date)) : I(d.expectedDate, ee(R(), 3)) && (d.status = O.Missed);
|
|
2862
|
+
}
|
|
2863
|
+
return a;
|
|
2864
|
+
}, hs = (e, t, a) => {
|
|
2865
|
+
const s = [];
|
|
2866
|
+
let r = ae(t, e.recurrenceDay);
|
|
2867
|
+
for (; I(r, a); )
|
|
2868
|
+
s.push({
|
|
2869
|
+
...e,
|
|
2870
|
+
expectedDate: r
|
|
2871
|
+
}), r = ae(r, e.recurrenceDay);
|
|
2872
|
+
return s;
|
|
2873
|
+
}, us = (e, t, a) => {
|
|
2874
|
+
const s = [];
|
|
2875
|
+
let r = e.expectedDate;
|
|
2876
|
+
if (I(r, t)) for (; I(r, t); ) r = te(r, 2);
|
|
2877
|
+
else {
|
|
2878
|
+
for (; V(r, t) || ue(r, t); ) r = Gt(r, 2);
|
|
2879
|
+
r = te(r, 2);
|
|
2880
|
+
}
|
|
2881
|
+
for (; I(r, a); )
|
|
2882
|
+
s.push({
|
|
2883
|
+
...e,
|
|
2884
|
+
expectedDate: r
|
|
2885
|
+
}), r = Ie(r, 14);
|
|
2886
|
+
return s;
|
|
2887
|
+
}, gs = (e, t, a) => {
|
|
2888
|
+
const s = [];
|
|
2889
|
+
let r = Q(t, e.recurrenceDay);
|
|
2890
|
+
for (; I(r, a); )
|
|
2891
|
+
s.push({
|
|
2892
|
+
...e,
|
|
2893
|
+
expectedDate: r
|
|
2894
|
+
}), r = P(r, 1);
|
|
2895
|
+
let n = e.secondRecurrenceDay && e.secondRecurrenceDay < 28 ? Q(t, e.secondRecurrenceDay) : Ot(t);
|
|
2896
|
+
for (; I(n, a); )
|
|
2897
|
+
s.push({
|
|
2898
|
+
...e,
|
|
2899
|
+
expectedDate: n
|
|
2900
|
+
}), n = P(n, 1);
|
|
2901
|
+
return s;
|
|
2902
|
+
}, _s = (e, t, a) => {
|
|
2903
|
+
const s = [];
|
|
2904
|
+
let r = Q(t, e.recurrenceDay);
|
|
2905
|
+
for (s.push({
|
|
2906
|
+
...e,
|
|
2907
|
+
expectedDate: r
|
|
2908
|
+
}), r = P(r, 1); I(r, a); )
|
|
2909
|
+
s.push({
|
|
2910
|
+
...e,
|
|
2911
|
+
expectedDate: r
|
|
2912
|
+
}), r = P(r, 1);
|
|
2913
|
+
return s;
|
|
2914
|
+
}, ms = (e, t, a) => {
|
|
2915
|
+
const s = [], r = e.expectedDate;
|
|
2916
|
+
let n = I(r, a) ? r : k(r, 2);
|
|
2917
|
+
for (; I(n, a); )
|
|
2918
|
+
V(n, t) && s.push({
|
|
2919
|
+
...e,
|
|
2920
|
+
expectedDate: n
|
|
2921
|
+
}), n = P(n, 2);
|
|
2922
|
+
return s;
|
|
2923
|
+
}, ps = (e, t, a) => {
|
|
2924
|
+
const s = [], r = e.expectedDate;
|
|
2925
|
+
let n = I(r, a) ? r : it(r, 1);
|
|
2926
|
+
for (; I(n, a); )
|
|
2927
|
+
V(n, t) && s.push({
|
|
2928
|
+
...e,
|
|
2929
|
+
expectedDate: n
|
|
2930
|
+
}), n = j(n, 1);
|
|
2931
|
+
return s;
|
|
2932
|
+
}, Es = (e, t, a) => {
|
|
2933
|
+
const s = [], r = e.expectedDate;
|
|
2934
|
+
let n = I(r, a) ? r : it(r, 2);
|
|
2935
|
+
for (; I(n, a); )
|
|
2936
|
+
V(n, t) && s.push({
|
|
2937
|
+
...e,
|
|
2938
|
+
expectedDate: n
|
|
2939
|
+
}), n = j(n, 2);
|
|
2940
|
+
return s;
|
|
2941
|
+
}, fs = (e, t, a) => {
|
|
2942
|
+
const s = [], r = e.expectedDate;
|
|
2943
|
+
let n = I(r, a) ? r : St(r, 1);
|
|
2944
|
+
for (; I(n, a); )
|
|
2945
|
+
V(n, t) && s.push({
|
|
2946
|
+
...e,
|
|
2947
|
+
expectedDate: n
|
|
2948
|
+
}), n = Ae(n, 1);
|
|
2949
|
+
return s;
|
|
2950
|
+
}, Is = (e, t) => {
|
|
2951
|
+
const a = [];
|
|
2952
|
+
for (const s of e) {
|
|
2953
|
+
const r = ds(s, t);
|
|
2954
|
+
a.push(...r);
|
|
2955
|
+
}
|
|
2956
|
+
return a.sort((s, r) => T(s.occurredOnDate || s.expectedDate) - T(r.occurredOnDate || r.expectedDate));
|
|
2957
|
+
}, de = (e, t, a) => {
|
|
2958
|
+
const s = [];
|
|
2959
|
+
for (const r of t) {
|
|
2960
|
+
const n = a.filter((i) => i.repeating_transaction_guid === r.guid);
|
|
2961
|
+
a.length > 0 && s.push({
|
|
2962
|
+
...r,
|
|
2963
|
+
account: e.find((i) => i.guid === r.account_guid),
|
|
2964
|
+
transactions: n
|
|
2965
|
+
});
|
|
2966
|
+
}
|
|
2967
|
+
return s;
|
|
2968
|
+
}, Rn = (e) => e.reduce((t, a) => {
|
|
2969
|
+
const s = rt(a.expectedDate, { representation: "date" }), r = t.find((n) => n.date.toString() === a.expectedDate.toString());
|
|
2970
|
+
return r ? r.recurrences.push(a) : t.push({
|
|
2971
|
+
date: a.expectedDate,
|
|
2972
|
+
id: `date-${s}`,
|
|
2973
|
+
recurrences: [a]
|
|
2974
|
+
}), t;
|
|
2975
|
+
}, []), Dn = (e, t, a) => {
|
|
2976
|
+
const s = ae(R(), t.recurrence_day), r = nt(R(), t.recurrence_day), n = We(t.recurrence_day), i = t.second_recurrence_day ? We(t.second_recurrence_day) : "";
|
|
2977
|
+
let o = a ? C(e.monthly_ordinal, n) : e.monthly;
|
|
2978
|
+
switch (t.recurrence_type) {
|
|
2979
|
+
case E.EveryQuarter:
|
|
2980
|
+
o = a ? C(e.quarterly_ordinal, n) : e.quarterly;
|
|
2981
|
+
break;
|
|
2982
|
+
case E.EveryWeek:
|
|
2983
|
+
o = a ? C(e.weekly_ordinal, w(s, N.DAY_OF_WEEK)) : e.weekly;
|
|
2984
|
+
break;
|
|
2985
|
+
case E.EveryYear:
|
|
2986
|
+
o = a ? C(e.anually_ordinal, w(r, N.MONTH_DAY)) : e.anually;
|
|
2987
|
+
break;
|
|
2988
|
+
case E.EveryOtherWeek:
|
|
2989
|
+
o = a ? C(e.every_other_week_ordinal, w(s, N.DAY_OF_WEEK)) : e.every_other_week;
|
|
2990
|
+
break;
|
|
2991
|
+
case E.EveryOtherMonth:
|
|
2992
|
+
o = a ? C(e.every_other_month_ordinal, n) : e.every_other_month;
|
|
2993
|
+
break;
|
|
2994
|
+
case E.EveryOtherQuarter:
|
|
2995
|
+
o = a ? C(e.every_other_quarter_ordinal, n) : e.every_other_quarter;
|
|
2996
|
+
break;
|
|
2997
|
+
case E.TwiceAMonth:
|
|
2998
|
+
o = a ? C(e.twice_a_month_ordinal, n, i) : e.twice_a_month;
|
|
2999
|
+
break;
|
|
3000
|
+
}
|
|
3001
|
+
return o;
|
|
3002
|
+
}, Tn = (e, t, a) => {
|
|
3003
|
+
let s = t;
|
|
3004
|
+
a !== void 0 && (e === E.EveryWeek || e === E.EveryOtherWeek ? s = Mt(t, a) : e === E.EveryYear ? s = nt(t, a) : s = Q(t, a));
|
|
3005
|
+
let r = s;
|
|
3006
|
+
switch (e) {
|
|
3007
|
+
case E.EveryWeek:
|
|
3008
|
+
r = as(s);
|
|
3009
|
+
break;
|
|
3010
|
+
case E.EveryOtherWeek:
|
|
3011
|
+
r = ss(s);
|
|
3012
|
+
break;
|
|
3013
|
+
case E.EveryMonth:
|
|
3014
|
+
r = rs(s);
|
|
3015
|
+
break;
|
|
3016
|
+
case E.EveryOtherMonth:
|
|
3017
|
+
r = ns(s);
|
|
3018
|
+
break;
|
|
3019
|
+
case E.EveryQuarter:
|
|
3020
|
+
r = is(s);
|
|
3021
|
+
break;
|
|
3022
|
+
case E.EveryOtherQuarter:
|
|
3023
|
+
r = os(s);
|
|
3024
|
+
break;
|
|
3025
|
+
case E.EveryYear:
|
|
3026
|
+
r = cs(s);
|
|
3027
|
+
break;
|
|
3028
|
+
}
|
|
3029
|
+
return r;
|
|
3030
|
+
}, et = (e, t) => at(t.expectedDate, e), F = (e, t) => e + t.amount, As = class {
|
|
3031
|
+
globalStore;
|
|
3032
|
+
api = new Be("/", "");
|
|
3033
|
+
repeatingTransactions = [];
|
|
3034
|
+
isDataLoaded = !1;
|
|
3035
|
+
selectedDay;
|
|
3036
|
+
dateRange = {
|
|
3037
|
+
start: M(R()),
|
|
3038
|
+
end: B(R())
|
|
3039
|
+
};
|
|
3040
|
+
constructor(e) {
|
|
3041
|
+
this.globalStore = e, this.api = new Be(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
3042
|
+
}
|
|
3043
|
+
get detailedRepeatingTransactions() {
|
|
3044
|
+
return de(this.globalStore.accountStore.visibleAccounts, this.repeatingTransactions, this.globalStore.transactionStore.transactions);
|
|
3045
|
+
}
|
|
3046
|
+
get recurrences() {
|
|
3047
|
+
const e = this.globalStore.accountStore.visibleAccounts;
|
|
3048
|
+
return Is(this.detailedRepeatingTransactions, this.dateRange).filter((t) => e.some((a) => a.guid === t.accountGuid && !a.is_excluded_from_accounts)).filter((t) => at(t.expectedDate, this.dateRange));
|
|
3049
|
+
}
|
|
3050
|
+
get pastRecurrences() {
|
|
3051
|
+
return this.recurrences.filter((e) => e.status === O.Paid || e.status === O.Missed);
|
|
3052
|
+
}
|
|
3053
|
+
get upcomingRecurrences() {
|
|
3054
|
+
return this.recurrences.filter((e) => V(e.expectedDate, ee(R(), 3)) && I(e.expectedDate, this.dateRange.end) && e.status === O.Upcoming);
|
|
3055
|
+
}
|
|
3056
|
+
get expenses() {
|
|
3057
|
+
return this.recurrences.filter((e) => e.type === ie.Expense);
|
|
3058
|
+
}
|
|
3059
|
+
get upcomingExpenses() {
|
|
3060
|
+
return this.expenses.filter((e) => e.status === O.Upcoming);
|
|
3061
|
+
}
|
|
3062
|
+
get income() {
|
|
3063
|
+
return this.recurrences.filter((e) => e.type === ie.Income);
|
|
3064
|
+
}
|
|
3065
|
+
get upcomingIncome() {
|
|
3066
|
+
return this.income.filter((e) => e.status === O.Upcoming);
|
|
3067
|
+
}
|
|
3068
|
+
get nextIncomeRecurrence() {
|
|
3069
|
+
return this.upcomingIncome.find((e) => V(e.expectedDate, R()));
|
|
3070
|
+
}
|
|
3071
|
+
get currentMonthExpenses() {
|
|
3072
|
+
return this.expenses.filter((e) => et(this.dateRange, e));
|
|
3073
|
+
}
|
|
3074
|
+
get currentMonthIncome() {
|
|
3075
|
+
return this.income.filter((e) => et(this.dateRange, e));
|
|
3076
|
+
}
|
|
3077
|
+
get expenseTotal() {
|
|
3078
|
+
return this.currentMonthExpenses.reduce(F, 0);
|
|
3079
|
+
}
|
|
3080
|
+
get paidExpenseTotal() {
|
|
3081
|
+
return this.currentMonthExpenses.filter((e) => e.status === O.Paid).reduce(F, 0);
|
|
3082
|
+
}
|
|
3083
|
+
get missedExpenseTotal() {
|
|
3084
|
+
return this.currentMonthExpenses.filter((e) => e.status === O.Missed).reduce(F, 0);
|
|
3085
|
+
}
|
|
3086
|
+
get upcomingExpenseTotal() {
|
|
3087
|
+
return this.currentMonthExpenses.filter((e) => e.status === O.Upcoming).reduce(F, 0);
|
|
3088
|
+
}
|
|
3089
|
+
get incomeTotal() {
|
|
3090
|
+
return this.currentMonthIncome.reduce(F, 0);
|
|
3091
|
+
}
|
|
3092
|
+
get paidIncomeTotal() {
|
|
3093
|
+
return this.currentMonthIncome.filter((e) => e.status === O.Paid).reduce(F, 0);
|
|
3094
|
+
}
|
|
3095
|
+
get upcomingIncomeTotal() {
|
|
3096
|
+
return this.currentMonthIncome.filter((e) => e.status === O.Upcoming).reduce(F, 0);
|
|
3097
|
+
}
|
|
3098
|
+
get selectedDayRecurrences() {
|
|
3099
|
+
return this.selectedDay && this.recurrences.filter((e) => this.selectedDay && ue(e.occurredOnDate || e.expectedDate, this.selectedDay));
|
|
3100
|
+
}
|
|
3101
|
+
setRepeatingTransactions = (e) => {
|
|
3102
|
+
this.repeatingTransactions = e, this.isDataLoaded = !0;
|
|
3103
|
+
};
|
|
3104
|
+
setDateRange = (e) => this.dateRange = e;
|
|
3105
|
+
setSelectedDay = (e) => {
|
|
3106
|
+
this.selectedDay = this.selectedDay && ue(e, this.selectedDay) ? void 0 : e;
|
|
3107
|
+
};
|
|
3108
|
+
loadRepeatingTransactionData = async () => {
|
|
3109
|
+
await Promise.all([
|
|
3110
|
+
this.globalStore.accountStore.loadAccountData(),
|
|
3111
|
+
this.globalStore.categoryStore.loadCategories(),
|
|
3112
|
+
this.globalStore.transactionStore.loadTransactionData()
|
|
3113
|
+
]), await this.loadRepeatingTransactions();
|
|
3114
|
+
};
|
|
3115
|
+
loadRepeatingTransactions = async () => {
|
|
3116
|
+
try {
|
|
3117
|
+
const e = await this.api.getRepeatingTransactions();
|
|
3118
|
+
this.setRepeatingTransactions(e);
|
|
3119
|
+
} catch (e) {
|
|
3120
|
+
console.error(`Error occurred while getting repeating transactions: ${e}`);
|
|
3121
|
+
}
|
|
3122
|
+
};
|
|
3123
|
+
addRepeatingTransaction = async (e, t) => {
|
|
3124
|
+
try {
|
|
3125
|
+
const a = await this.api.addRepeatingTransaction(e);
|
|
3126
|
+
await this.globalStore.transactionStore.updateTransaction({
|
|
3127
|
+
...t,
|
|
3128
|
+
repeating_transaction_guid: a.guid
|
|
3129
|
+
}), g(() => {
|
|
3130
|
+
this.repeatingTransactions = [...this.repeatingTransactions, ...de(this.globalStore.accountStore.visibleAccounts, [a], this.globalStore.transactionStore.transactions)];
|
|
3131
|
+
});
|
|
3132
|
+
} catch (a) {
|
|
3133
|
+
console.error(`Error occurred while adding repeating transaction: ${a}`);
|
|
3134
|
+
}
|
|
3135
|
+
};
|
|
3136
|
+
deleteRepeatingTransaction = async (e) => {
|
|
3137
|
+
try {
|
|
3138
|
+
await this.api.deleteRepeatingTransaction(e), g(() => {
|
|
3139
|
+
this.repeatingTransactions = [...this.repeatingTransactions.filter((t) => t.guid !== e)];
|
|
3140
|
+
});
|
|
3141
|
+
} catch (t) {
|
|
3142
|
+
console.error(`Error occurred while deleting repeating transaction: ${t}`);
|
|
3143
|
+
}
|
|
3144
|
+
};
|
|
3145
|
+
updateRepeatingTransaction = async (e) => {
|
|
3146
|
+
try {
|
|
3147
|
+
const t = await this.api.updateRepeatingTransaction(e), a = this.repeatingTransactions.findIndex((s) => s.guid === t.guid);
|
|
3148
|
+
if (a < 0) return;
|
|
3149
|
+
g(() => {
|
|
3150
|
+
this.repeatingTransactions = [
|
|
3151
|
+
...this.repeatingTransactions.slice(0, a),
|
|
3152
|
+
...de(this.globalStore.accountStore.visibleAccounts, [t], this.globalStore.transactionStore.transactions),
|
|
3153
|
+
...this.repeatingTransactions.slice(a + 1)
|
|
3154
|
+
];
|
|
3155
|
+
});
|
|
3156
|
+
} catch (t) {
|
|
3157
|
+
console.error(`Error occurred while updating repeating transaction: ${t}`);
|
|
3158
|
+
}
|
|
3159
|
+
};
|
|
3160
|
+
}, tt = "PARENT-ENTITY", Rs = (e, t) => ({
|
|
3161
|
+
[ne.BudgetExceeded]: t.notification_budget_exceeded,
|
|
3162
|
+
[ne.BudgetOffTarget]: t.notification_budget_off_target,
|
|
3163
|
+
[v.DebtPaymentReminder]: t.notification_debt_payment_reminder,
|
|
3164
|
+
[v.AccountBalanceLow]: t.notification_low_balance,
|
|
3165
|
+
[v.AccountDepositLargePosted]: t.notification_large_deposit,
|
|
3166
|
+
[v.AccountDepositLarge]: t.notification_large_deposit,
|
|
3167
|
+
[v.TransactionExpenseLarge]: t.notification_large_expense,
|
|
3168
|
+
[v.TransactionFeeCharge]: t.notification_transaction_fee,
|
|
3169
|
+
[v.InternationalTransaction]: t.notification_transaction_is_international,
|
|
3170
|
+
[f.AccountBalanceLow]: t.account_balance_low,
|
|
3171
|
+
[f.BillAmountNotStandard]: t.bill_amount_not_standard,
|
|
3172
|
+
[f.CategorySpending]: t.category_spending,
|
|
3173
|
+
[f.CreditCardCloseToLimit]: t.credit_card_close_to_limit,
|
|
3174
|
+
[f.DebtPaymentReminder]: t.debt_payment_reminder,
|
|
3175
|
+
[f.DuplicatePayment]: t.duplicate_payment,
|
|
3176
|
+
[f.MonthlySpendComparison]: t.monthly_spend_comparison,
|
|
3177
|
+
[f.MonthlySpendToIncomeComparison]: t.monthly_spend_to_income_comparison,
|
|
3178
|
+
[f.MonthlySubscriptionAggregate]: t.monthly_subscription_aggregate,
|
|
3179
|
+
[f.MonthlyTopMerchantSpending]: t.monthly_top_merchant_spending,
|
|
3180
|
+
[f.SaveAnExtra100Dollars]: t.save_an_extra_100_dollars,
|
|
3181
|
+
[f.SavingsOpportunity]: t.savings_opportunity,
|
|
3182
|
+
[f.SetUpDirectDeposit]: t.set_up_direct_deposit,
|
|
3183
|
+
[f.SwitchDirectDeposit]: t.switch_direct_deposit,
|
|
3184
|
+
[f.UncategorizedTransactions]: t.uncategorized_transactions,
|
|
3185
|
+
[f.UnifiedDeposit]: t.unified_deposit,
|
|
3186
|
+
[f.UpcomingBill]: t.upcoming_bill,
|
|
3187
|
+
[f.WeekendSpendingSummary]: t.weekend_spending_summary,
|
|
3188
|
+
[f.WeeklyNewMerchants]: t.weekly_new_merchants,
|
|
3189
|
+
[f.DiscoveredAccounts]: t.discovered_account,
|
|
3190
|
+
[f.TransactionExpenseLarge]: t.large_transaction,
|
|
3191
|
+
[f.PromotionalCampaignMessages]: t.promotional_campaign_messages,
|
|
3192
|
+
[f.TransparentOverdraft]: t.transparent_overdraft
|
|
3193
|
+
})[e] || "", Ds = (e, t, a, s, r, n) => {
|
|
3194
|
+
const i = [], { email_notifications_enabled: o, sms_notifications_enabled: c, push_notifications_enabled: d } = t, { opted_out_of_email_notifications: h, opted_out_of_sms_notifications: _, opted_out_of_push_notifications: m } = r;
|
|
3195
|
+
for (const D of s.filter((A) => A.entity_guid === tt)) {
|
|
3196
|
+
const A = Rs(D.notification_type, a), Y = s.filter((U) => U.entity_guid !== tt && U.notification_type === D.notification_type && e.some(($) => $.guid === U.entity_guid)), H = [];
|
|
3197
|
+
o && !h && D.email_channel && n.email && H.push(a.delivery_method_email_label), c && !_ && D.sms_channel && n.phone && H.push(a.delivery_method_sms_label), d && !m && D.push_channel && H.push(a.delivery_method_push_label), i.push({
|
|
3198
|
+
...D,
|
|
3199
|
+
children: Y.map((U) => ({
|
|
3200
|
+
...U,
|
|
3201
|
+
account: e.find(($) => $.guid === U.entity_guid),
|
|
3202
|
+
label: A
|
|
3203
|
+
})),
|
|
3204
|
+
deliveryMethodsLabel: H.join(", "),
|
|
3205
|
+
label: A
|
|
3206
|
+
});
|
|
3207
|
+
}
|
|
3208
|
+
return i;
|
|
3209
|
+
}, Ts = class {
|
|
3210
|
+
globalStore;
|
|
3211
|
+
api = new xe("/", "");
|
|
3212
|
+
transactionApi = new re("/", "");
|
|
3213
|
+
alert = {
|
|
3214
|
+
message: "",
|
|
3215
|
+
severity: void 0
|
|
3216
|
+
};
|
|
3217
|
+
devices = [];
|
|
3218
|
+
notificationProfiles = [];
|
|
3219
|
+
selectedRule = void 0;
|
|
3220
|
+
transactionRules = [];
|
|
3221
|
+
constructor(e) {
|
|
3222
|
+
this.globalStore = e, this.api = new xe(e.endpoint, e.sessionToken, e.onError), this.transactionApi = new re(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
3223
|
+
}
|
|
3224
|
+
get accountProfiles() {
|
|
3225
|
+
const e = this.globalStore.appDataStore.clientCommunicationProfile;
|
|
3226
|
+
return this.detailedNotificationProfiles.filter((t) => t.notification_type === v.DebtPaymentReminder && e.debt_payment_reminder_notifications_enabled || t.notification_type === v.AccountBalanceLow && e.low_balance_notifications_enabled || t.notification_type === v.AccountDepositLarge && e.large_deposit_notifications_enabled || t.notification_type === v.TransactionExpenseLarge && e.large_expense_notifications_enabled || t.notification_type === v.TransactionFeeCharge && e.transaction_fee_notifications_enabled || t.notification_type === v.InternationalTransaction && e.transaction_is_international_notifications_enabled || t.notification_type === v.AccountDepositLargePosted && e.large_deposit_posted_notifications_enabled);
|
|
3227
|
+
}
|
|
3228
|
+
get budgetProfiles() {
|
|
3229
|
+
const e = this.globalStore.appDataStore.clientCommunicationProfile;
|
|
3230
|
+
return this.detailedNotificationProfiles.filter((t) => t.notification_type === ne.BudgetExceeded && e.budget_exceeded_notifications_enabled || t.notification_type === ne.BudgetOffTarget && e.budget_off_target_notifications_enabled);
|
|
3231
|
+
}
|
|
3232
|
+
get insightsProfiles() {
|
|
3233
|
+
return this.detailedNotificationProfiles.filter((e) => Object.values(f).includes(e.notification_type));
|
|
3234
|
+
}
|
|
3235
|
+
get clientCommunicationProfile() {
|
|
3236
|
+
return this.globalStore.appDataStore.clientCommunicationProfile;
|
|
3237
|
+
}
|
|
3238
|
+
get copy() {
|
|
3239
|
+
return this.globalStore.copyStore.copy.settings;
|
|
3240
|
+
}
|
|
3241
|
+
get detailedNotificationProfiles() {
|
|
3242
|
+
return this.globalStore.isInitialized ? Ds(this.globalStore.accountStore.accounts, this.clientCommunicationProfile, this.copy, this.notificationProfiles, this.userCommunicationsProfile, this.globalStore.userStore.user) : [];
|
|
3243
|
+
}
|
|
3244
|
+
get userCommunicationsProfile() {
|
|
3245
|
+
return this.globalStore.appDataStore.userCommunicationProfile;
|
|
3246
|
+
}
|
|
3247
|
+
deleteDevice = async (e) => {
|
|
3248
|
+
try {
|
|
3249
|
+
await this.api.deleteDevice(e);
|
|
3250
|
+
const t = this.devices.findIndex((a) => a.guid === e);
|
|
3251
|
+
return t >= 0 && g(() => {
|
|
3252
|
+
this.devices.splice(t, 1);
|
|
3253
|
+
}), { success: !0 };
|
|
3254
|
+
} catch {
|
|
3255
|
+
return console.error(`Error deleting device: ${e}`), { success: !1 };
|
|
3256
|
+
}
|
|
3257
|
+
};
|
|
3258
|
+
deleteTransactionRule = async () => {
|
|
3259
|
+
this.selectedRule && this.transactionApi.removeTransactionRule(this.selectedRule?.guid).then(() => {
|
|
3260
|
+
this.setAlert(this.copy.delete_rule_success, "success"), this.loadTransactionRules();
|
|
3261
|
+
}).catch(() => {
|
|
3262
|
+
this.setAlert(this.copy.delete_rule_error, "error");
|
|
3263
|
+
});
|
|
3264
|
+
};
|
|
3265
|
+
generateDeviceToken = async () => {
|
|
3266
|
+
try {
|
|
3267
|
+
return await this.api.generateDeviceToken();
|
|
3268
|
+
} catch (e) {
|
|
3269
|
+
console.error(`Error generating device token: ${e}`);
|
|
3270
|
+
}
|
|
3271
|
+
};
|
|
3272
|
+
loadDevices = async () => {
|
|
3273
|
+
try {
|
|
3274
|
+
const e = await this.api.getDevices();
|
|
3275
|
+
g(() => {
|
|
3276
|
+
this.devices = e;
|
|
3277
|
+
});
|
|
3278
|
+
} catch (e) {
|
|
3279
|
+
console.error(`Error loading devices: ${e}`);
|
|
3280
|
+
}
|
|
3281
|
+
};
|
|
3282
|
+
loadNotificationProfiles = async () => {
|
|
3283
|
+
try {
|
|
3284
|
+
const e = await this.api.getNotificationProfiles();
|
|
3285
|
+
g(() => {
|
|
3286
|
+
this.notificationProfiles = e;
|
|
3287
|
+
});
|
|
3288
|
+
} catch (e) {
|
|
3289
|
+
console.error(`Error loading notification profiles: ${e}`);
|
|
3290
|
+
}
|
|
3291
|
+
};
|
|
3292
|
+
loadTransactionRules = async () => {
|
|
3293
|
+
try {
|
|
3294
|
+
const e = await this.transactionApi.getTransactionRules();
|
|
3295
|
+
g(() => {
|
|
3296
|
+
this.transactionRules = e;
|
|
3297
|
+
});
|
|
3298
|
+
} catch (e) {
|
|
3299
|
+
console.error(`Error loading transaction rules: ${e}`);
|
|
3300
|
+
}
|
|
3301
|
+
};
|
|
3302
|
+
sendEmailVerification = async () => {
|
|
3303
|
+
try {
|
|
3304
|
+
await this.api.sendEmailVerification(), this.setAlert(this.copy.verification_sent_success, "success");
|
|
3305
|
+
} catch (e) {
|
|
3306
|
+
console.error(`Error sending email verification: ${e}`), this.setAlert(this.copy.verification_sent_error, "error");
|
|
3307
|
+
}
|
|
3308
|
+
};
|
|
3309
|
+
sendPhoneVerification = async () => {
|
|
3310
|
+
try {
|
|
3311
|
+
await this.api.sendPhoneVerification(), this.setAlert(this.copy.verification_sent_success, "success");
|
|
3312
|
+
} catch (e) {
|
|
3313
|
+
console.error(`Error sending phone verification: ${e}`), this.setAlert(this.copy.verification_sent_error, "error");
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
setAlert = (e, t = void 0) => this.alert = {
|
|
3317
|
+
message: e,
|
|
3318
|
+
severity: t
|
|
3319
|
+
};
|
|
3320
|
+
setSelectedRule = (e) => {
|
|
3321
|
+
this.selectedRule = e;
|
|
3322
|
+
};
|
|
3323
|
+
updateDevice = async (e) => {
|
|
3324
|
+
try {
|
|
3325
|
+
const t = await this.api.updateDevice(e), a = this.devices.findIndex((s) => s.guid === e.guid);
|
|
3326
|
+
return a >= 0 && g(() => {
|
|
3327
|
+
this.devices[a] = t;
|
|
3328
|
+
}), { success: !0 };
|
|
3329
|
+
} catch (t) {
|
|
3330
|
+
return console.error(`Error updating device: ${t}`), { success: !1 };
|
|
3331
|
+
}
|
|
3332
|
+
};
|
|
3333
|
+
updateNotificationProfile = async (e) => {
|
|
3334
|
+
try {
|
|
3335
|
+
const t = await this.api.updateNotificationProfile(e), a = this.notificationProfiles.findIndex((s) => s.guid === e.guid);
|
|
3336
|
+
a >= 0 && g(() => {
|
|
3337
|
+
this.notificationProfiles[a] = t;
|
|
3338
|
+
});
|
|
3339
|
+
} catch (t) {
|
|
3340
|
+
console.error(`Error updating notification profile: ${t}`);
|
|
3341
|
+
}
|
|
3342
|
+
};
|
|
3343
|
+
updateRuleCategory = async (e) => {
|
|
3344
|
+
this.transactionApi.updateTransactionRule(e).then(() => {
|
|
3345
|
+
this.loadTransactionRules();
|
|
3346
|
+
});
|
|
3347
|
+
};
|
|
3348
|
+
updateRulePayee = async (e) => {
|
|
3349
|
+
this.transactionApi.updateTransactionRule(e).then(() => {
|
|
3350
|
+
this.setAlert(this.copy.edit_payee_success, "success"), this.loadTransactionRules();
|
|
3351
|
+
}).catch(() => {
|
|
3352
|
+
this.setAlert(this.copy.edit_payee_error, "error");
|
|
3353
|
+
});
|
|
3354
|
+
};
|
|
3355
|
+
updateUser = async (e) => {
|
|
3356
|
+
this.globalStore.userStore.updateUser(e).then(() => {
|
|
3357
|
+
this.setAlert(this.copy.information_updated_success, "success");
|
|
3358
|
+
}).catch(() => {
|
|
3359
|
+
this.setAlert(this.copy.information_updated_error, "error");
|
|
3360
|
+
});
|
|
3361
|
+
};
|
|
3362
|
+
updateUserCommunicationProfile = async (e) => {
|
|
3363
|
+
try {
|
|
3364
|
+
const t = await this.api.updateUserCommunicationProfile(e);
|
|
3365
|
+
this.globalStore.appDataStore.setUserCommunicationProfile(t);
|
|
3366
|
+
} catch (t) {
|
|
3367
|
+
console.error(`Error occurred while updating user communication profile: ${t}`);
|
|
3368
|
+
}
|
|
3369
|
+
};
|
|
3370
|
+
verifyPhoneToken = async (e) => {
|
|
3371
|
+
try {
|
|
3372
|
+
const { verified: t } = await this.api.verifyPhoneToken(e);
|
|
3373
|
+
if (!t) throw new Error();
|
|
3374
|
+
this.setAlert(this.copy.verified_phone_success, "success");
|
|
3375
|
+
} catch (t) {
|
|
3376
|
+
console.error(`Error verifying phone token: ${t}`), this.setAlert(this.copy.verified_phone_error, "error");
|
|
3377
|
+
}
|
|
3378
|
+
};
|
|
3379
|
+
}, Rt = {
|
|
3380
|
+
ASC: "ASC",
|
|
3381
|
+
DESC: "DESC",
|
|
3382
|
+
DIRECTION: {
|
|
3383
|
+
ASC: "ascending",
|
|
3384
|
+
DESC: "descending"
|
|
3385
|
+
},
|
|
3386
|
+
ALIGN: {
|
|
3387
|
+
center: "center",
|
|
3388
|
+
left: "flex-start",
|
|
3389
|
+
right: "flex-end"
|
|
3390
|
+
}
|
|
3391
|
+
}, ys = {
|
|
3392
|
+
account_guid: "",
|
|
3393
|
+
amount: 0,
|
|
3394
|
+
currency_code: "",
|
|
3395
|
+
date: 0,
|
|
3396
|
+
description: "",
|
|
3397
|
+
duplicate: !1,
|
|
3398
|
+
feed_description: "",
|
|
3399
|
+
feed_status: lt.POSTED,
|
|
3400
|
+
feed_transaction_date: 0,
|
|
3401
|
+
has_been_split: !1,
|
|
3402
|
+
has_been_viewed: !1,
|
|
3403
|
+
is_cleared: !1,
|
|
3404
|
+
is_flagged: !1,
|
|
3405
|
+
is_hidden: !1,
|
|
3406
|
+
is_manual: !0,
|
|
3407
|
+
is_personal: !0,
|
|
3408
|
+
is_reimbursable: !1,
|
|
3409
|
+
is_subscription: !1,
|
|
3410
|
+
is_void: !1,
|
|
3411
|
+
revision: 1,
|
|
3412
|
+
transaction_type: oe.DEBIT,
|
|
3413
|
+
user_guid: "",
|
|
3414
|
+
is_duplicate: !1,
|
|
3415
|
+
feed_transacted_at: 0,
|
|
3416
|
+
guid: "",
|
|
3417
|
+
memo: void 0,
|
|
3418
|
+
tags: []
|
|
3419
|
+
}, Ee = {
|
|
3420
|
+
FLAG: "flag",
|
|
3421
|
+
DATE: "date",
|
|
3422
|
+
PAYEE: "payee",
|
|
3423
|
+
CATEGORY: "category",
|
|
3424
|
+
ACCOUNT: "account",
|
|
3425
|
+
AMOUNT: "amount"
|
|
3426
|
+
}, Ss = (e, t, a, s = []) => {
|
|
3427
|
+
const r = t.reduce((o, c) => ({
|
|
3428
|
+
...o,
|
|
3429
|
+
[c.guid]: c
|
|
3430
|
+
}), {}), n = a.reduce((o, c) => ({
|
|
3431
|
+
...o,
|
|
3432
|
+
[c.guid]: c
|
|
3433
|
+
}), {}), i = s.reduce((o, c) => {
|
|
3434
|
+
const { transaction_guid: d, tag_guid: h } = c;
|
|
3435
|
+
if (!o[d]) return {
|
|
3436
|
+
...o,
|
|
3437
|
+
[d]: [h]
|
|
3438
|
+
};
|
|
3439
|
+
const _ = [...o[d], h];
|
|
3440
|
+
return {
|
|
3441
|
+
...o,
|
|
3442
|
+
[d]: _
|
|
3443
|
+
};
|
|
3444
|
+
}, {});
|
|
3445
|
+
return e.map((o) => {
|
|
3446
|
+
const c = r[o.account_guid], d = o.category_guid ? n[o.category_guid] : null, h = i[o.guid] ?? [];
|
|
3447
|
+
return {
|
|
3448
|
+
...o,
|
|
3449
|
+
account: c?.user_name || "Unknown",
|
|
3450
|
+
accountIsClosed: c?.is_closed,
|
|
3451
|
+
accountIsHidden: c?.is_hidden,
|
|
3452
|
+
category: d?.name || "Uncategorized",
|
|
3453
|
+
isIncome: o.top_level_category_guid === G.INCOME,
|
|
3454
|
+
isPending: o.feed_status === lt.PENDING,
|
|
3455
|
+
number: c?.account_number || "",
|
|
3456
|
+
payee: o.description,
|
|
3457
|
+
tags: h
|
|
3458
|
+
};
|
|
3459
|
+
});
|
|
3460
|
+
}, Cs = "uncategorized", Ns = (e, t, a, s, r, n) => {
|
|
3461
|
+
const i = vs(ws(e, r, n), a, s);
|
|
3462
|
+
return t.forEach((o) => {
|
|
3463
|
+
const c = i.findIndex((h) => h.guid === o), d = n.filter((h) => h.parent_guid === o);
|
|
3464
|
+
i.splice(c + 1, 0, ...d);
|
|
3465
|
+
}), i;
|
|
3466
|
+
}, ws = (e, t, a) => {
|
|
3467
|
+
const { accounts: s = [], dateRange: r = {
|
|
3468
|
+
start: M(R()),
|
|
3469
|
+
end: ge()
|
|
3470
|
+
}, custom: n = () => !0, searchTerm: i = "", showSplits: o = !1 } = e;
|
|
3471
|
+
return a.filter((c) => o ? !c.has_been_split : !c.parent_guid).filter((c) => !!s.find((d) => d === c.account_guid)).filter((c) => c.date >= T(r.start) && c.date <= T(r.end)).filter(n).filter((c) => {
|
|
3472
|
+
if (i === Cs && c.has_been_split) return !1;
|
|
3473
|
+
if (/^spl/i.test(i) && (c.has_been_split || c.parent_guid)) return !0;
|
|
3474
|
+
const d = c.tags.some((_) => b(i, t.find((m) => m.guid === _)?.name)), h = L(c.date);
|
|
3475
|
+
return b(i, c.payee) || b(i, c.feed_description) || b(i, c.category) || b(i, w(h, N.MONTH)) || b(i, w(h, N.DAY)) || b(i, w(h, N.FULL_MONTH_DAY)) || b(i, w(h, N.MONTH_DAY_YEAR)) || b(i, K(h, "do")) || b(i, c.account) || b(i, me(c.amount, "0,0.00")) || b(i, c.memo) || d;
|
|
3476
|
+
});
|
|
3477
|
+
}, vs = (e, t, a) => [...e].sort((s, r) => {
|
|
3478
|
+
const n = t, i = (s[n] || "") > (r[n] || "");
|
|
3479
|
+
let o = i ? -1 : 1, c = i ? 1 : -1;
|
|
3480
|
+
return (t === Ee.DATE || t === Ee.AMOUNT) && (o = i ? 1 : -1, c = i ? -1 : 1), a === Rt.ASC ? o : c;
|
|
3481
|
+
}), b = (e, t) => {
|
|
3482
|
+
const a = e.toLowerCase().split(" "), s = t?.toString().toLowerCase() ?? "";
|
|
3483
|
+
return a.every((r) => s.indexOf(r) > -1);
|
|
3484
|
+
};
|
|
3485
|
+
function Ls(e) {
|
|
3486
|
+
return new Set(e.filter((t) => t.parent_guid !== void 0).map((t) => t.parent_guid));
|
|
3487
|
+
}
|
|
3488
|
+
function Os(e) {
|
|
3489
|
+
return e.reduce((t, a) => (a.parent_guid && (t[a.parent_guid] || (t[a.parent_guid] = []), t[a.parent_guid].push(a)), t), {});
|
|
3490
|
+
}
|
|
3491
|
+
function bs(e, t) {
|
|
3492
|
+
const a = Ls(t), s = Os(t), r = /* @__PURE__ */ new Set(), n = [];
|
|
3493
|
+
for (const i of e) a.has(i.guid) ? (s[i.guid] ?? []).slice().sort((o, c) => Math.abs(c.amount) - Math.abs(o.amount)).forEach((o) => {
|
|
3494
|
+
r.has(o.guid) || (n.push(o), r.add(o.guid));
|
|
3495
|
+
}) : r.has(i.guid) || (n.push(i), r.add(i.guid));
|
|
3496
|
+
return n;
|
|
3497
|
+
}
|
|
3498
|
+
var yn = (e, t) => {
|
|
3499
|
+
const a = Ps(Ms(e, t)), s = new Blob([a], { type: "text/csv;charset=utf-8;" }), r = document.createElement("a");
|
|
3500
|
+
r.href = URL.createObjectURL(s), r.setAttribute("download", "transactions.csv"), document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(r.href);
|
|
3501
|
+
}, Ms = (e, t) => e.map((a) => ({
|
|
3502
|
+
Date: w(L(a.date), N.YEAR_MONTH_DAY),
|
|
3503
|
+
Description: Us(a),
|
|
3504
|
+
"Original Description": a.feed_description,
|
|
3505
|
+
Amount: `${a.amount}`,
|
|
3506
|
+
Type: a.transaction_type === oe.CREDIT ? "Credit" : "Debit",
|
|
3507
|
+
"Parent Category": fe[a.top_level_category_guid || ""],
|
|
3508
|
+
Category: a.category,
|
|
3509
|
+
Account: a.account,
|
|
3510
|
+
Tags: Bs(a, t),
|
|
3511
|
+
Memo: a.memo,
|
|
3512
|
+
Pending: a.isPending ? "TRUE" : "FALSE"
|
|
3513
|
+
})), Gs = (e) => e ? /[,"\n\r]/.test(e) ? `"${e.replace(/"/g, '""')}"` : e : "", Ps = (e) => Object.keys(e[0]).join(",").concat(`\r
|
|
3514
|
+
`) + e.map((t) => Object.values(t).map(Gs).join(",")).join(`\r
|
|
3515
|
+
`), Us = (e) => {
|
|
3516
|
+
let t = e.parent_guid ? "Split: " : "";
|
|
3517
|
+
return t += e.is_hidden ? "(Excluded) " : "", t += e.description, t;
|
|
3518
|
+
}, Bs = (e, t) => e.tags.map((a) => t.filter((s) => s.guid === a)[0]?.name ?? "").join(" "), xs = class {
|
|
3519
|
+
globalStore;
|
|
3520
|
+
uiStore;
|
|
3521
|
+
api = new re("/", "");
|
|
3522
|
+
beatApi = new Z("/", "");
|
|
3523
|
+
associatedBeats = [];
|
|
3524
|
+
associatedBeatsLoaded = !1;
|
|
3525
|
+
associatedBeatsLoading = !1;
|
|
3526
|
+
transactions = [];
|
|
3527
|
+
transactionsLoaded = !1;
|
|
3528
|
+
transactionsLoading = !1;
|
|
3529
|
+
taggings = [];
|
|
3530
|
+
taggingsLoaded = !1;
|
|
3531
|
+
taggingsLoading = !1;
|
|
3532
|
+
tags = [];
|
|
3533
|
+
tagsLoaded = !1;
|
|
3534
|
+
tagsLoading = !1;
|
|
3535
|
+
transactionRules = [];
|
|
3536
|
+
transactionRulesLoaded = !1;
|
|
3537
|
+
transactionRulesLoading = !1;
|
|
3538
|
+
cachedStartDate = ee(R(), 90);
|
|
3539
|
+
filter = {};
|
|
3540
|
+
isLoading = !0;
|
|
3541
|
+
alert = "";
|
|
3542
|
+
sortColumn = Ee.DATE;
|
|
3543
|
+
sortDirection = Rt.DESC;
|
|
3544
|
+
constructor(e) {
|
|
3545
|
+
this.globalStore = e, this.uiStore = new Hs(), this.api = new re(e.endpoint, e.sessionToken, e.onError), this.beatApi = new Z(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
3546
|
+
}
|
|
3547
|
+
loadTransactionData = async () => {
|
|
3548
|
+
this.globalStore.accountStore.isAccountDataLoaded || await this.globalStore.accountStore.loadAccountData(), this.globalStore.categoryStore.categoriesLoaded || await this.globalStore.categoryStore.loadCategories(), await Promise.all([
|
|
3549
|
+
this.loadAssociatedBeats(M(/* @__PURE__ */ new Date())),
|
|
3550
|
+
this.loadTags(),
|
|
3551
|
+
this.loadTaggings(),
|
|
3552
|
+
this.loadTransactionRules(),
|
|
3553
|
+
this.loadTransactions(this.cachedStartDate)
|
|
3554
|
+
]);
|
|
3555
|
+
};
|
|
3556
|
+
get isTransactionDataLoaded() {
|
|
3557
|
+
return this.associatedBeatsLoaded && this.tagsLoaded && this.taggingsLoaded && this.transactionRulesLoaded && this.transactionsLoaded;
|
|
3558
|
+
}
|
|
3559
|
+
get detailedTransactions() {
|
|
3560
|
+
return this.isTransactionDataLoaded ? Ss(this.transactions, this.globalStore.accountStore.visibleAccounts, this.globalStore.categoryStore.categories, this.taggings) : [];
|
|
3561
|
+
}
|
|
3562
|
+
get sortedTransactions() {
|
|
3563
|
+
return Ns(this.filter, this.uiStore.expandedSplits, this.sortColumn, this.sortDirection, this.tags, this.detailedTransactions);
|
|
3564
|
+
}
|
|
3565
|
+
get sortedTransactionsWithSplits() {
|
|
3566
|
+
return bs(this.sortedTransactions, this.detailedTransactions);
|
|
3567
|
+
}
|
|
3568
|
+
setAssociatedBeats = (e) => {
|
|
3569
|
+
this.associatedBeats = e, this.associatedBeatsLoading = !1, this.associatedBeatsLoaded = !0;
|
|
3570
|
+
};
|
|
3571
|
+
setTaggings = (e) => {
|
|
3572
|
+
this.taggings = e, this.taggingsLoading = !1, this.taggingsLoaded = !0;
|
|
3573
|
+
};
|
|
3574
|
+
setTags = (e) => {
|
|
3575
|
+
this.tags = e, this.tagsLoading = !1, this.tagsLoaded = !0;
|
|
3576
|
+
};
|
|
3577
|
+
setTransactionRules = (e) => {
|
|
3578
|
+
this.transactionRules = e, this.transactionRulesLoading = !1, this.transactionRulesLoaded = !0;
|
|
3579
|
+
};
|
|
3580
|
+
setTransactions = (e) => {
|
|
3581
|
+
this.transactions = e, this.transactionsLoading = !1, this.transactionsLoaded = !0;
|
|
3582
|
+
};
|
|
3583
|
+
setAlert = (e) => {
|
|
3584
|
+
this.alert = e;
|
|
3585
|
+
};
|
|
3586
|
+
addTag = async (e) => {
|
|
3587
|
+
await this.api.addTag({ name: e }), await this.loadTags();
|
|
3588
|
+
};
|
|
3589
|
+
addTagging = async (e, t) => {
|
|
3590
|
+
await this.api.addTagging({
|
|
3591
|
+
tag_guid: e,
|
|
3592
|
+
transaction_guid: t
|
|
3593
|
+
});
|
|
3594
|
+
};
|
|
3595
|
+
addOrUpdateTransactionRule = async (e, t) => {
|
|
3596
|
+
const a = this.transactionRules.find((s) => s.guid === t.user_transaction_rule_guid);
|
|
3597
|
+
a ? await this.api.updateTransactionRule({
|
|
3598
|
+
...a,
|
|
3599
|
+
category_guid: e,
|
|
3600
|
+
description: t.description
|
|
3601
|
+
}) : await this.api.addTransactionRule({
|
|
3602
|
+
category_guid: e,
|
|
3603
|
+
description: t.description,
|
|
3604
|
+
match_description: t.description
|
|
3605
|
+
}), await this.loadTransactionRules();
|
|
3606
|
+
};
|
|
3607
|
+
addTransaction = async (e) => {
|
|
3608
|
+
const t = await this.api.addTransaction(e);
|
|
3609
|
+
if (t) {
|
|
3610
|
+
this.setTransactions([t, ...this.transactions]);
|
|
3611
|
+
const a = t.transaction_type === oe.CREDIT ? t.amount : -t.amount;
|
|
3612
|
+
this.globalStore.accountStore.updateAccountBalance(t.account_guid, a);
|
|
3613
|
+
}
|
|
3614
|
+
};
|
|
3615
|
+
loadAssociatedBeats = async (e) => {
|
|
3616
|
+
if (this.associatedBeatsLoading) return;
|
|
3617
|
+
this.associatedBeatsLoading = !0;
|
|
3618
|
+
const t = e ? rt(e, { representation: "date" }) : void 0;
|
|
3619
|
+
try {
|
|
3620
|
+
const a = await this.beatApi.getBeatsWithAssociatedTransaction(t);
|
|
3621
|
+
this.setAssociatedBeats(a);
|
|
3622
|
+
} catch (a) {
|
|
3623
|
+
console.error(`Error occurred while loading associated beats: ${a}`);
|
|
3624
|
+
}
|
|
3625
|
+
};
|
|
3626
|
+
loadTags = async () => {
|
|
3627
|
+
if (!this.tagsLoading) {
|
|
3628
|
+
this.tagsLoading = !0;
|
|
3629
|
+
try {
|
|
3630
|
+
const e = await this.api.getTags();
|
|
3631
|
+
this.setTags(e);
|
|
3632
|
+
} catch (e) {
|
|
3633
|
+
console.error(`Error occurred while loading tags: ${e}`);
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
};
|
|
3637
|
+
loadTaggings = async () => {
|
|
3638
|
+
if (!this.taggingsLoading) {
|
|
3639
|
+
this.taggingsLoading = !0;
|
|
3640
|
+
try {
|
|
3641
|
+
const e = await this.api.getTaggings();
|
|
3642
|
+
this.setTaggings(e);
|
|
3643
|
+
} catch (e) {
|
|
3644
|
+
console.error(`Error occurred while loading taggings: ${e}`);
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
};
|
|
3648
|
+
loadTransactionRules = async () => {
|
|
3649
|
+
if (this.transactionRulesLoading) return;
|
|
3650
|
+
this.transactionRulesLoading = !0;
|
|
3651
|
+
const e = await this.api.getTransactionRules();
|
|
3652
|
+
this.setTransactionRules(e);
|
|
3653
|
+
};
|
|
3654
|
+
loadTransactions = async (e = this.cachedStartDate) => {
|
|
3655
|
+
if (!this.transactionsLoading) {
|
|
3656
|
+
this.setIsLoading(!0), this.transactionsLoading = !0, this.transactions = [];
|
|
3657
|
+
try {
|
|
3658
|
+
const t = await this.api.getTransactionsByDateRange(T(e), T(ge()));
|
|
3659
|
+
this.setTransactions(t);
|
|
3660
|
+
} catch (t) {
|
|
3661
|
+
console.error(`Error occurred while loading transactions: ${t}`);
|
|
3662
|
+
}
|
|
3663
|
+
this.setIsLoading(!1);
|
|
3664
|
+
}
|
|
3665
|
+
};
|
|
3666
|
+
modifyTransactionByAccountGuid = (e, t) => {
|
|
3667
|
+
this.transactions = this.transactions.map((a) => a.account_guid === e ? {
|
|
3668
|
+
...a,
|
|
3669
|
+
...t
|
|
3670
|
+
} : a);
|
|
3671
|
+
};
|
|
3672
|
+
removeTag = async (e) => {
|
|
3673
|
+
await this.api.removeTag(e), await this.loadTags();
|
|
3674
|
+
};
|
|
3675
|
+
removeTagging = async (e) => {
|
|
3676
|
+
await this.api.removeTagging(e);
|
|
3677
|
+
};
|
|
3678
|
+
removeTransaction = async (e) => {
|
|
3679
|
+
await this.api.removeTransaction(e);
|
|
3680
|
+
const t = this.transactions.findIndex((a) => a.guid === e);
|
|
3681
|
+
if (t >= 0) {
|
|
3682
|
+
const a = [...this.transactions];
|
|
3683
|
+
a.splice(t, 1), this.setTransactions(a);
|
|
3684
|
+
}
|
|
3685
|
+
};
|
|
3686
|
+
setFilter = (e) => {
|
|
3687
|
+
this.filter = e, e.dateRange && I(e.dateRange.start, this.cachedStartDate) && this.loadTransactions(e.dateRange.start).then(() => {
|
|
3688
|
+
e.dateRange && (this.cachedStartDate = e.dateRange.start);
|
|
3689
|
+
});
|
|
3690
|
+
};
|
|
3691
|
+
setIsLoading = (e) => this.isLoading = e;
|
|
3692
|
+
splitTransaction = async (e, t) => {
|
|
3693
|
+
const a = await this.api.updateTransaction(e), s = [];
|
|
3694
|
+
for (let n = 0; n < t.length; n++) {
|
|
3695
|
+
const i = await this.api.addTransaction(t[n]);
|
|
3696
|
+
s.push(i);
|
|
3697
|
+
}
|
|
3698
|
+
const r = this.transactions.findIndex((n) => n.guid === e.guid);
|
|
3699
|
+
if (r >= 0) {
|
|
3700
|
+
const n = this.transactions.filter((i) => i.guid !== e.guid && i.parent_guid !== e.guid);
|
|
3701
|
+
this.setTransactions([
|
|
3702
|
+
...n.slice(0, r),
|
|
3703
|
+
a,
|
|
3704
|
+
...s,
|
|
3705
|
+
...n.slice(r)
|
|
3706
|
+
]);
|
|
3707
|
+
}
|
|
3708
|
+
};
|
|
3709
|
+
unSplitTransaction = async (e) => {
|
|
3710
|
+
const t = this.transactions.filter((n) => n.parent_guid === e);
|
|
3711
|
+
await this.api.removeTransactionSplit(e);
|
|
3712
|
+
const a = [...this.transactions];
|
|
3713
|
+
t.forEach((n) => {
|
|
3714
|
+
const i = a.findIndex((o) => o.guid === n.guid);
|
|
3715
|
+
i >= 0 && a.splice(i, 1);
|
|
3716
|
+
});
|
|
3717
|
+
const s = a.findIndex((n) => n.guid === e), r = a[s];
|
|
3718
|
+
r.has_been_split = !1, s >= 0 && this.setTransactions([
|
|
3719
|
+
...a.slice(0, s),
|
|
3720
|
+
r,
|
|
3721
|
+
...a.slice(s + 1)
|
|
3722
|
+
]);
|
|
3723
|
+
};
|
|
3724
|
+
updateTaggings = async (e, t) => {
|
|
3725
|
+
const a = this.taggings.filter((n) => n.transaction_guid === t), s = new Set(a.map((n) => n.tag_guid)), r = new Set(e);
|
|
3726
|
+
for (const n of e) s.has(n) || await this.addTagging(n, t);
|
|
3727
|
+
for (const n of a) r.has(n.tag_guid) || await this.removeTagging(n.guid);
|
|
3728
|
+
await this.loadTaggings();
|
|
3729
|
+
};
|
|
3730
|
+
updateTag = async (e) => {
|
|
3731
|
+
await this.api.updateTag(e), await this.loadTags();
|
|
3732
|
+
};
|
|
3733
|
+
updateTransaction = async (e) => {
|
|
3734
|
+
const t = await this.api.updateTransaction(e), a = this.transactions.findIndex((s) => s.guid === e.guid);
|
|
3735
|
+
a >= 0 && this.setTransactions([
|
|
3736
|
+
...this.transactions.slice(0, a),
|
|
3737
|
+
t,
|
|
3738
|
+
...this.transactions.slice(a + 1)
|
|
3739
|
+
]);
|
|
3740
|
+
};
|
|
3741
|
+
loadEmbeddedInstanceTransactions = async (e) => {
|
|
3742
|
+
try {
|
|
3743
|
+
const t = await this.api.getTransactionsByDateRange(T(e), T(ge()));
|
|
3744
|
+
this.cachedStartDate = e, this.transactions = t;
|
|
3745
|
+
} catch (t) {
|
|
3746
|
+
console.error(`Error occurred while loading embedded instance transactions: ${t}`);
|
|
3747
|
+
}
|
|
3748
|
+
};
|
|
3749
|
+
}, Hs = class {
|
|
3750
|
+
beginDate = M(/* @__PURE__ */ new Date());
|
|
3751
|
+
endDate = B(/* @__PURE__ */ new Date());
|
|
3752
|
+
expandedSplits = [];
|
|
3753
|
+
height = 550;
|
|
3754
|
+
width = 1e3;
|
|
3755
|
+
shouldDisableDrawerScroll = !1;
|
|
3756
|
+
searchValue = "";
|
|
3757
|
+
selectedAccountGuids = [];
|
|
3758
|
+
manualTransaction = ys;
|
|
3759
|
+
isAmountValid = !1;
|
|
3760
|
+
showInsights = !1;
|
|
3761
|
+
constructor() {
|
|
3762
|
+
p(this);
|
|
3763
|
+
}
|
|
3764
|
+
setDateRange = (e, t) => {
|
|
3765
|
+
this.beginDate = e, this.endDate = t;
|
|
3766
|
+
};
|
|
3767
|
+
setIsAmountValid = (e) => this.isAmountValid = e;
|
|
3768
|
+
setSearchValue = (e) => this.searchValue = e;
|
|
3769
|
+
setSelectedAccountGuids = (e) => this.selectedAccountGuids = e;
|
|
3770
|
+
setShouldDisableDrawerScroll = (e) => this.shouldDisableDrawerScroll = e;
|
|
3771
|
+
setShowInsights = (e) => {
|
|
3772
|
+
this.showInsights = e;
|
|
3773
|
+
};
|
|
3774
|
+
setSize = (e, t) => {
|
|
3775
|
+
this.height = e, this.width = t;
|
|
3776
|
+
};
|
|
3777
|
+
toggleSplit = (e) => {
|
|
3778
|
+
const t = [...this.expandedSplits], a = this.expandedSplits.findIndex((s) => s === e);
|
|
3779
|
+
a >= 0 ? t.splice(a, 1) : t.push(e), this.expandedSplits = t;
|
|
3780
|
+
};
|
|
3781
|
+
clearExpandedSplits = () => {
|
|
3782
|
+
this.expandedSplits.length !== 0 && (this.expandedSplits = []);
|
|
3783
|
+
};
|
|
3784
|
+
updateManualTransaction = (e) => {
|
|
3785
|
+
this.manualTransaction = e;
|
|
3786
|
+
};
|
|
3787
|
+
}, $s = (e) => he[e] ?? he.default, Fs = (e) => fe[e];
|
|
3788
|
+
function ks(e, t) {
|
|
3789
|
+
const a = [], s = new Date(e);
|
|
3790
|
+
for (; s <= t; ) {
|
|
3791
|
+
const r = s.getFullYear(), n = String(s.getMonth() + 1).padStart(2, "0");
|
|
3792
|
+
a.push(+`${r}${n}`), s.setMonth(s.getMonth() + 1);
|
|
3793
|
+
}
|
|
3794
|
+
return a;
|
|
3795
|
+
}
|
|
3796
|
+
var Vs = (e) => e.reduce((t, a) => {
|
|
3797
|
+
const s = {
|
|
3798
|
+
top_level_category_guid: a.top_level_category_guid,
|
|
3799
|
+
category_guid: a.category_guid,
|
|
3800
|
+
amount: a.total,
|
|
3801
|
+
year_month: a.year_month
|
|
3802
|
+
}, { top_level_category_guid: r, category_guid: n } = s;
|
|
3803
|
+
return t[n] || (t[n] = []), t[n].push(s), r !== n && (t[r] || (t[r] = []), t[r].push(s)), t;
|
|
3804
|
+
}, {}), Sn = (e, t, a) => {
|
|
3805
|
+
const s = Vs(e), r = ks(t, a);
|
|
3806
|
+
return Object.entries(s).map(([n, i]) => {
|
|
3807
|
+
const o = i[0].top_level_category_guid, c = r.map((d) => {
|
|
3808
|
+
const h = i.filter((D) => D.year_month === d).reduce((D, A) => D + Math.abs(A.amount), 0), _ = Number(String(d).slice(0, 4)), m = Number(String(d).slice(4));
|
|
3809
|
+
return {
|
|
3810
|
+
x: new Date(_, m - 1),
|
|
3811
|
+
y: h
|
|
3812
|
+
};
|
|
3813
|
+
}).sort((d, h) => d.x.getTime() - h.x.getTime());
|
|
3814
|
+
return {
|
|
3815
|
+
top_level_category_guid: o,
|
|
3816
|
+
category_guid: n,
|
|
3817
|
+
category_name: Fs(n),
|
|
3818
|
+
category_color: $s(o),
|
|
3819
|
+
dataset: c
|
|
3820
|
+
};
|
|
3821
|
+
});
|
|
3822
|
+
}, Cn = (e, t) => {
|
|
3823
|
+
const a = typeof e == "string" ? parseFloat(e.replace(/[^0-9.-]+/g, "")) : e, s = typeof t == "string" ? parseFloat(t.replace(/[^0-9.-]+/g, "")) : t;
|
|
3824
|
+
return (a || 0) - (s || 0);
|
|
3825
|
+
}, Nn = (e, t) => e.indexOf("General") >= 0 ? 1 : e.localeCompare(t), Ys = (e, t) => {
|
|
3826
|
+
const a = e.subCategories.filter((n) => n.currentAmount !== 0), s = e.totalMonthlyAmounts.slice(-t), r = (n) => n.substring(0, 3) + " " + n.slice(-4);
|
|
3827
|
+
return s.map((n) => {
|
|
3828
|
+
const i = r(n.label), o = a.map((d) => {
|
|
3829
|
+
const h = d.monthlyAmounts.slice(-t).find((_) => r(_.label) === i);
|
|
3830
|
+
return {
|
|
3831
|
+
label: d.name,
|
|
3832
|
+
amount: Math.abs(h?.amount || 0),
|
|
3833
|
+
header: i
|
|
3834
|
+
};
|
|
3835
|
+
}), c = e.monthlyAmounts.slice(-t).find((d) => r(d.label) === i);
|
|
3836
|
+
return [{
|
|
3837
|
+
label: e.name,
|
|
3838
|
+
amount: Math.abs(c?.amount || 0),
|
|
3839
|
+
header: i
|
|
3840
|
+
}, ...o].sort((d, h) => h.amount - d.amount);
|
|
3841
|
+
});
|
|
3842
|
+
}, Ws = (e, t) => ({
|
|
3843
|
+
monthlyAmounts: e ? e.totalMonthlyAmounts.slice(-t).map((a) => ({
|
|
3844
|
+
x: a.label.substring(0, 3),
|
|
3845
|
+
y: Math.abs(a.amount)
|
|
3846
|
+
})) : [],
|
|
3847
|
+
tooltipLabels: e ? Ys(e, t) : []
|
|
3848
|
+
}), Ks = (e) => e.slice().filter((t) => t.totalAmount !== 0 && !t.isTransfer && t.guid !== G.INVESTMENTS).sort((t, a) => Math.abs(a.totalAmount) - Math.abs(t.totalAmount)), js = class {
|
|
3849
|
+
globalStore;
|
|
3850
|
+
selectedCategoryData = null;
|
|
3851
|
+
selectedDateRange;
|
|
3852
|
+
visibleListLength = 5;
|
|
3853
|
+
constructor(e) {
|
|
3854
|
+
this.globalStore = e, this.selectedDateRange = {
|
|
3855
|
+
start: Ut(B(k(/* @__PURE__ */ new Date(), 6)), 1),
|
|
3856
|
+
end: B(/* @__PURE__ */ new Date())
|
|
3857
|
+
}, p(this);
|
|
3858
|
+
}
|
|
3859
|
+
setSelectedCategoryData = (e) => {
|
|
3860
|
+
this.selectedCategoryData = e;
|
|
3861
|
+
};
|
|
3862
|
+
setSelectedDateRange = (e) => {
|
|
3863
|
+
this.selectedDateRange = e;
|
|
3864
|
+
};
|
|
3865
|
+
setVisibleListLength = (e) => {
|
|
3866
|
+
this.visibleListLength = e;
|
|
3867
|
+
};
|
|
3868
|
+
get sortedDetailedCategoriesWithTransactions() {
|
|
3869
|
+
return Ks(this.globalStore.categoryStore.detailedCategoriesWithTransactions);
|
|
3870
|
+
}
|
|
3871
|
+
get selectedDateRangeMonthCount() {
|
|
3872
|
+
return Bt(this.selectedDateRange.end, this.selectedDateRange.start) + 1;
|
|
3873
|
+
}
|
|
3874
|
+
get selectedDateRangeMonthRange() {
|
|
3875
|
+
return `${w(this.selectedDateRange.start, N.MONTH_LONG)} - ${w(this.selectedDateRange.end, N.MONTH_LONG)}`;
|
|
3876
|
+
}
|
|
3877
|
+
get visibleCategories() {
|
|
3878
|
+
return this.sortedDetailedCategoriesWithTransactions.slice(0, this.visibleListLength);
|
|
3879
|
+
}
|
|
3880
|
+
get collapsedCategories() {
|
|
3881
|
+
return this.sortedDetailedCategoriesWithTransactions.slice(this.visibleListLength);
|
|
3882
|
+
}
|
|
3883
|
+
get categoryDetailsChartData() {
|
|
3884
|
+
return Ws(this.selectedCategoryData, this.selectedDateRangeMonthCount);
|
|
3885
|
+
}
|
|
3886
|
+
}, Qs = class {
|
|
3887
|
+
globalStore;
|
|
3888
|
+
api = new He("/", "");
|
|
3889
|
+
userFeatures = [];
|
|
3890
|
+
userFeaturesLoaded = !1;
|
|
3891
|
+
constructor(e) {
|
|
3892
|
+
this.globalStore = e, this.api = new He(e.endpoint, e.sessionToken, e.onError), p(this);
|
|
3893
|
+
}
|
|
3894
|
+
get userProfile() {
|
|
3895
|
+
return this.globalStore.appDataStore.userProfile;
|
|
3896
|
+
}
|
|
3897
|
+
get user() {
|
|
3898
|
+
return this.globalStore.appDataStore.user;
|
|
3899
|
+
}
|
|
3900
|
+
setUserFeatures = (e) => {
|
|
3901
|
+
this.userFeatures = e, this.userFeaturesLoaded = !0;
|
|
3902
|
+
};
|
|
3903
|
+
loadUserFeatures = async () => {
|
|
3904
|
+
try {
|
|
3905
|
+
const e = await this.api.getUserFeatures();
|
|
3906
|
+
this.setUserFeatures(e);
|
|
3907
|
+
} catch (e) {
|
|
3908
|
+
console.error(`Error occurred while loading user features: ${e}`);
|
|
3909
|
+
}
|
|
3910
|
+
};
|
|
3911
|
+
updateUser = async (e) => {
|
|
3912
|
+
try {
|
|
3913
|
+
const t = await this.api.updateUser(e);
|
|
3914
|
+
this.globalStore.appDataStore.setUser(t);
|
|
3915
|
+
} catch (t) {
|
|
3916
|
+
console.error(`Error updating User: ${t}`);
|
|
3917
|
+
}
|
|
3918
|
+
};
|
|
3919
|
+
updateUserProfile = async (e) => {
|
|
3920
|
+
try {
|
|
3921
|
+
const t = await this.api.updateUserProfile(e);
|
|
3922
|
+
this.globalStore.appDataStore.setUserProfile(t);
|
|
3923
|
+
} catch (t) {
|
|
3924
|
+
console.error(`Error occurred while updating user profile: ${t}`);
|
|
3925
|
+
}
|
|
3926
|
+
};
|
|
3927
|
+
};
|
|
3928
|
+
export {
|
|
3929
|
+
ca as $,
|
|
3930
|
+
Pe as $t,
|
|
3931
|
+
ln as A,
|
|
3932
|
+
Vr as At,
|
|
3933
|
+
nn as B,
|
|
3934
|
+
Hr as Bt,
|
|
3935
|
+
Ya as C,
|
|
3936
|
+
f as Ct,
|
|
3937
|
+
un as D,
|
|
3938
|
+
y as Dt,
|
|
3939
|
+
Ga as E,
|
|
3940
|
+
x as Et,
|
|
3941
|
+
cn as F,
|
|
3942
|
+
Ht as Ft,
|
|
3943
|
+
da as G,
|
|
3944
|
+
$r as Gt,
|
|
3945
|
+
ma as H,
|
|
3946
|
+
kr as Ht,
|
|
3947
|
+
Na as I,
|
|
3948
|
+
q as It,
|
|
3949
|
+
me as J,
|
|
3950
|
+
re as Jt,
|
|
3951
|
+
sn as K,
|
|
3952
|
+
$e as Kt,
|
|
3953
|
+
Ta as L,
|
|
3954
|
+
xr as Lt,
|
|
3955
|
+
hn as M,
|
|
3956
|
+
Ft as Mt,
|
|
3957
|
+
va as N,
|
|
3958
|
+
ce as Nt,
|
|
3959
|
+
gn as O,
|
|
3960
|
+
Yr as Ot,
|
|
3961
|
+
wa as P,
|
|
3962
|
+
u as Pt,
|
|
3963
|
+
an as Q,
|
|
3964
|
+
Ue as Qt,
|
|
3965
|
+
on as R,
|
|
3966
|
+
ct as Rt,
|
|
3967
|
+
Wa as S,
|
|
3968
|
+
ne as St,
|
|
3969
|
+
ut as T,
|
|
3970
|
+
Kr as Tt,
|
|
3971
|
+
ga as U,
|
|
3972
|
+
Br as Ut,
|
|
3973
|
+
W as V,
|
|
3974
|
+
xt as Vt,
|
|
3975
|
+
ha as W,
|
|
3976
|
+
Fr as Wt,
|
|
3977
|
+
oa as X,
|
|
3978
|
+
Ur as Xt,
|
|
3979
|
+
We as Y,
|
|
3980
|
+
xe as Yt,
|
|
3981
|
+
tn as Z,
|
|
3982
|
+
Be as Zt,
|
|
3983
|
+
ts as _,
|
|
3984
|
+
kt as _t,
|
|
3985
|
+
Sn as a,
|
|
3986
|
+
ve as an,
|
|
3987
|
+
Xt as at,
|
|
3988
|
+
Za as b,
|
|
3989
|
+
oe as bt,
|
|
3990
|
+
ys as c,
|
|
3991
|
+
se as cn,
|
|
3992
|
+
Kt as ct,
|
|
3993
|
+
Dn as d,
|
|
3994
|
+
Xr as dt,
|
|
3995
|
+
Ge as en,
|
|
3996
|
+
na as et,
|
|
3997
|
+
Tn as f,
|
|
3998
|
+
Jr as ft,
|
|
3999
|
+
fn as g,
|
|
4000
|
+
ie as gt,
|
|
4001
|
+
In as h,
|
|
4002
|
+
O as ht,
|
|
4003
|
+
Nn as i,
|
|
4004
|
+
Le as in,
|
|
4005
|
+
Zt as it,
|
|
4006
|
+
dn as j,
|
|
4007
|
+
$t as jt,
|
|
4008
|
+
La as k,
|
|
4009
|
+
Wr as kt,
|
|
4010
|
+
Ts as l,
|
|
4011
|
+
N as ln,
|
|
4012
|
+
dt as lt,
|
|
4013
|
+
An as m,
|
|
4014
|
+
E as mt,
|
|
4015
|
+
js as n,
|
|
4016
|
+
be as nn,
|
|
4017
|
+
en as nt,
|
|
4018
|
+
xs as o,
|
|
4019
|
+
we as on,
|
|
4020
|
+
zt as ot,
|
|
4021
|
+
Rn as p,
|
|
4022
|
+
qr as pt,
|
|
4023
|
+
rn as q,
|
|
4024
|
+
He as qt,
|
|
4025
|
+
Cn as r,
|
|
4026
|
+
Oe as rn,
|
|
4027
|
+
Zr as rt,
|
|
4028
|
+
yn as s,
|
|
4029
|
+
Ne as sn,
|
|
4030
|
+
jt as st,
|
|
4031
|
+
Qs as t,
|
|
4032
|
+
Me as tn,
|
|
4033
|
+
Ye as tt,
|
|
4034
|
+
As as u,
|
|
4035
|
+
w as un,
|
|
4036
|
+
zr as ut,
|
|
4037
|
+
pn as v,
|
|
4038
|
+
Qr as vt,
|
|
4039
|
+
_n as w,
|
|
4040
|
+
jr as wt,
|
|
4041
|
+
mn as x,
|
|
4042
|
+
v as xt,
|
|
4043
|
+
En as y,
|
|
4044
|
+
lt as yt,
|
|
4045
|
+
Ia as z,
|
|
4046
|
+
ot as zt
|
|
4047
|
+
};
|