@mx-cartographer/experiences 6.26.0-alpha.sms7 → 6.26.1-alpha.mega1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/dist/AccountStore-DkL93tXL.mjs +317 -0
  3. package/dist/AccountStore-DkL93tXL.mjs.map +1 -0
  4. package/dist/BudgetUtil-CVqAdv-j.mjs +187 -0
  5. package/dist/BudgetUtil-CVqAdv-j.mjs.map +1 -0
  6. package/dist/CashflowStore-gPEEBiXo.mjs +53 -0
  7. package/dist/CashflowStore-gPEEBiXo.mjs.map +1 -0
  8. package/dist/CategoryStore-m7oieLzP.mjs +260 -0
  9. package/dist/CategoryStore-m7oieLzP.mjs.map +1 -0
  10. package/dist/ConnectMiniWidget-CQWafYtQ.mjs +22966 -0
  11. package/dist/ConnectMiniWidget-CQWafYtQ.mjs.map +1 -0
  12. package/dist/DebtsStore-cUhIgJx6.mjs +145 -0
  13. package/dist/DebtsStore-cUhIgJx6.mjs.map +1 -0
  14. package/dist/Donut-CGNFni9y.mjs +58 -0
  15. package/dist/Donut-CGNFni9y.mjs.map +1 -0
  16. package/dist/FinstrongStore-BDG7l0nI.mjs +183 -0
  17. package/dist/FinstrongStore-BDG7l0nI.mjs.map +1 -0
  18. package/dist/GoalStore-o2waGeyf.mjs +293 -0
  19. package/dist/GoalStore-o2waGeyf.mjs.map +1 -0
  20. package/dist/Loader-CwdK8lfx.mjs +147 -0
  21. package/dist/Loader-CwdK8lfx.mjs.map +1 -0
  22. package/dist/MerchantStore-Cck9IGIH.mjs +125 -0
  23. package/dist/MerchantStore-Cck9IGIH.mjs.map +1 -0
  24. package/dist/NetWorthStore-D5eUfGQt.mjs +66 -0
  25. package/dist/NetWorthStore-D5eUfGQt.mjs.map +1 -0
  26. package/dist/NotificationStore-DCxw8W7u.mjs +141 -0
  27. package/dist/NotificationStore-DCxw8W7u.mjs.map +1 -0
  28. package/dist/RecurringTransactionsStore-Bijrgllq.mjs +337 -0
  29. package/dist/RecurringTransactionsStore-Bijrgllq.mjs.map +1 -0
  30. package/dist/SettingsStore-BhOYgUOa.mjs +352 -0
  31. package/dist/SettingsStore-BhOYgUOa.mjs.map +1 -0
  32. package/dist/TransactionApi-Dnbyi1JL.mjs +175 -0
  33. package/dist/TransactionApi-Dnbyi1JL.mjs.map +1 -0
  34. package/dist/TransactionStore-CiEtt5XJ.mjs +417 -0
  35. package/dist/TransactionStore-CiEtt5XJ.mjs.map +1 -0
  36. package/dist/TrendsStore-Idq3QfoA.mjs +131 -0
  37. package/dist/TrendsStore-Idq3QfoA.mjs.map +1 -0
  38. package/dist/accounts/index.es.js +18 -0
  39. package/dist/accounts/index.es.js.map +1 -0
  40. package/dist/analytics/index.es.js +170 -0
  41. package/dist/analytics/index.es.js.map +1 -0
  42. package/dist/budgets/index.es.js +1116 -0
  43. package/dist/budgets/index.es.js.map +1 -0
  44. package/dist/cashflow/index.es.js +118 -0
  45. package/dist/cashflow/index.es.js.map +1 -0
  46. package/dist/categories/index.es.js +10 -0
  47. package/dist/categories/index.es.js.map +1 -0
  48. package/dist/categories/util/CategoryUtil.d.ts +3 -2
  49. package/dist/common/components/charts/StackedLineChart.d.ts +2 -2
  50. package/dist/common/components/charts/stackedlinechart/CustomLegend.d.ts +1 -0
  51. package/dist/common/context/hooks.d.ts +13 -13
  52. package/dist/common/index.es.js +1549 -0
  53. package/dist/common/index.es.js.map +1 -0
  54. package/dist/common/types/AppData.d.ts +2 -0
  55. package/dist/common/types/Category.d.ts +2 -8
  56. package/dist/common/types/index.d.ts +1 -1
  57. package/dist/dashboard/index.es.js +257 -0
  58. package/dist/dashboard/index.es.js.map +1 -0
  59. package/dist/debts/index.es.js +9 -0
  60. package/dist/debts/index.es.js.map +1 -0
  61. package/dist/finstrong/index.es.js +11 -0
  62. package/dist/finstrong/index.es.js.map +1 -0
  63. package/dist/goals/index.es.js +9 -0
  64. package/dist/goals/index.es.js.map +1 -0
  65. package/dist/help/components/content/section/index.d.ts +15 -15
  66. package/dist/help/index.es.js +6 -0
  67. package/dist/help/index.es.js.map +1 -0
  68. package/dist/investments/index.es.js +1694 -0
  69. package/dist/investments/index.es.js.map +1 -0
  70. package/dist/merchants/index.es.js +7 -0
  71. package/dist/merchants/index.es.js.map +1 -0
  72. package/dist/microinsights/index.es.js +21 -0
  73. package/dist/microinsights/index.es.js.map +1 -0
  74. package/dist/networth/index.es.js +11 -0
  75. package/dist/networth/index.es.js.map +1 -0
  76. package/dist/notifications/index.es.js +116 -0
  77. package/dist/notifications/index.es.js.map +1 -0
  78. package/dist/recurringtransactions/index.es.js +14 -0
  79. package/dist/recurringtransactions/index.es.js.map +1 -0
  80. package/dist/settings/index.es.js +112 -0
  81. package/dist/settings/index.es.js.map +1 -0
  82. package/dist/spending/index.es.js +632 -0
  83. package/dist/spending/index.es.js.map +1 -0
  84. package/dist/transactions/index.es.js +19 -0
  85. package/dist/transactions/index.es.js.map +1 -0
  86. package/dist/trends/components/CategoriesList.d.ts +5 -5
  87. package/dist/trends/components/CategoriesListItem.d.ts +7 -4
  88. package/dist/trends/components/CategoryDetailChart.d.ts +5 -1
  89. package/dist/trends/index.es.js +10 -0
  90. package/dist/trends/index.es.js.map +1 -0
  91. package/dist/trends/stores/TrendsStore.d.ts +11 -16
  92. package/package.json +91 -3
  93. package/dist/index.d.ts +0 -22
  94. package/dist/index.es.js +0 -29873
  95. package/dist/index.es.js.map +0 -1
@@ -0,0 +1,66 @@
1
+ import { makeAutoObservable as i, runInAction as s } from "mobx";
2
+ import { aj as l, ak as h, al as u, am as D, an as c, ao as d, ap as b } from "./ConnectMiniWidget-CQWafYtQ.mjs";
3
+ class A {
4
+ globalStore;
5
+ netWorthData = { accounts: [], monthlyAccountBalances: [] };
6
+ netWorthChartData = [];
7
+ hoveredData;
8
+ selectedData;
9
+ constructor(t) {
10
+ this.globalStore = t, i(this);
11
+ }
12
+ loadNetWorthData = async (t) => {
13
+ try {
14
+ const a = this.globalStore.accountStore.members, e = l(t, a), r = await (await Promise.all(
15
+ e.map((n) => this.globalStore.accountStore.api.getMonthlyAccountBalances(n.guid))
16
+ )).reduce(h, []).sort(u);
17
+ s(() => {
18
+ this.netWorthData = {
19
+ accounts: e,
20
+ monthlyAccountBalances: r
21
+ };
22
+ });
23
+ } catch (a) {
24
+ console.error(`Error occured while loading net worth data: ${a}`);
25
+ }
26
+ };
27
+ loadChartData = async (t) => {
28
+ try {
29
+ const { accounts: a, monthlyAccountBalances: e } = this.netWorthData, o = await D(a, e, t), r = c(o);
30
+ s(() => {
31
+ this.netWorthChartData = o, this.selectedData = r;
32
+ });
33
+ } catch (a) {
34
+ console.error(`Error occured while loading chart data: ${a}`);
35
+ }
36
+ };
37
+ get gainsLosses() {
38
+ return d(this.selectedData);
39
+ }
40
+ get assetsLiabilities() {
41
+ const { assets: t, liabilities: a, totalAssets: e, totalLiabilities: o } = b(
42
+ this.netWorthData.accounts
43
+ );
44
+ return {
45
+ netWorth: c(this.netWorthChartData),
46
+ assets: t,
47
+ liabilities: a,
48
+ totalAssets: e,
49
+ totalLiabilities: o
50
+ };
51
+ }
52
+ setSelectedData = (t) => {
53
+ s(() => {
54
+ this.selectedData = this.netWorthChartData[t];
55
+ });
56
+ };
57
+ setHoveredData = (t) => {
58
+ s(() => {
59
+ this.hoveredData = t !== null ? this.netWorthChartData[t] : void 0;
60
+ });
61
+ };
62
+ }
63
+ export {
64
+ A as N
65
+ };
66
+ //# sourceMappingURL=NetWorthStore-D5eUfGQt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetWorthStore-D5eUfGQt.mjs","sources":["../src/networth/stores/NetWorthStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport type { Account, GlobalStore } from '../../common'\n\nimport { AssetsLiabilities, GainsLosses, NetWorth, NetWorthData } from '../types/NetWorth'\nimport {\n filterAccounts,\n flattenBalances,\n buildAssetsLiabilities,\n buildChartData,\n buildGainsLosses,\n getLatestNetWorthData,\n sortByYearMonthAscending,\n} from '../utils/NetWorthUtils'\n\nexport class NetWorthStore {\n globalStore: GlobalStore\n\n netWorthData: NetWorthData = { accounts: [], monthlyAccountBalances: [] }\n netWorthChartData: NetWorth[] = []\n hoveredData?: NetWorth\n selectedData?: NetWorth\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n makeAutoObservable(this)\n }\n\n loadNetWorthData = async (accounts: Account[]) => {\n try {\n const members = this.globalStore.accountStore.members\n\n const netWorthAccounts = filterAccounts(accounts, members)\n\n const accountBalances = await Promise.all(\n netWorthAccounts.map((account: Account) => {\n return this.globalStore.accountStore.api.getMonthlyAccountBalances(account.guid)\n }),\n )\n\n const monthlyAccountBalances = await accountBalances\n .reduce(flattenBalances, [])\n .sort(sortByYearMonthAscending)\n\n runInAction(() => {\n this.netWorthData = {\n accounts: netWorthAccounts,\n monthlyAccountBalances,\n }\n })\n } catch (error) {\n console.error(`Error occured while loading net worth data: ${error}`)\n }\n }\n\n loadChartData = async (numberOfMonths: number) => {\n try {\n const { accounts, monthlyAccountBalances } = this.netWorthData\n const chartData = await buildChartData(accounts, monthlyAccountBalances, numberOfMonths)\n const selectedData = getLatestNetWorthData(chartData)\n\n runInAction(() => {\n this.netWorthChartData = chartData\n this.selectedData = selectedData\n })\n } catch (error) {\n console.error(`Error occured while loading chart data: ${error}`)\n }\n }\n\n get gainsLosses(): GainsLosses {\n return buildGainsLosses(this.selectedData)\n }\n\n get assetsLiabilities(): AssetsLiabilities {\n const { assets, liabilities, totalAssets, totalLiabilities } = buildAssetsLiabilities(\n this.netWorthData.accounts,\n )\n return {\n netWorth: getLatestNetWorthData(this.netWorthChartData),\n assets,\n liabilities,\n totalAssets,\n totalLiabilities,\n }\n }\n\n setSelectedData = (dataIndex: number) => {\n runInAction(() => {\n this.selectedData = this.netWorthChartData[dataIndex]\n })\n }\n\n setHoveredData = (dataIndex: number | null) => {\n runInAction(() => {\n this.hoveredData = dataIndex !== null ? this.netWorthChartData[dataIndex] : undefined\n })\n }\n}\n"],"names":["NetWorthStore","globalStore","makeAutoObservable","accounts","members","netWorthAccounts","filterAccounts","monthlyAccountBalances","account","flattenBalances","sortByYearMonthAscending","runInAction","error","numberOfMonths","chartData","buildChartData","selectedData","getLatestNetWorthData","buildGainsLosses","assets","liabilities","totalAssets","totalLiabilities","buildAssetsLiabilities","dataIndex"],"mappings":";;AAeO,MAAMA,EAAc;AAAA,EACzB;AAAA,EAEA,eAA6B,EAAE,UAAU,CAAI,GAAA,wBAAwB,CAAG,EAAA;AAAA,EACxE,oBAAgC,CAAA;AAAA,EAChC;AAAA,EACA;AAAA,EAEA,YAAYC,GAA0B;AACpC,SAAK,cAAcA,GACnBC,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,mBAAmB,OAAOC,MAAwB;AAC5C,QAAA;AACI,YAAAC,IAAU,KAAK,YAAY,aAAa,SAExCC,IAAmBC,EAAeH,GAAUC,CAAO,GAQnDG,IAAyB,OANP,MAAM,QAAQ;AAAA,QACpCF,EAAiB,IAAI,CAACG,MACb,KAAK,YAAY,aAAa,IAAI,0BAA0BA,EAAQ,IAAI,CAChF;AAAA,MAAA,GAIA,OAAOC,GAAiB,EAAE,EAC1B,KAAKC,CAAwB;AAEhC,MAAAC,EAAY,MAAM;AAChB,aAAK,eAAe;AAAA,UAClB,UAAUN;AAAA,UACV,wBAAAE;AAAA,QAAA;AAAA,MACF,CACD;AAAA,aACMK,GAAO;AACN,cAAA,MAAM,+CAA+CA,CAAK,EAAE;AAAA,IACtE;AAAA,EAAA;AAAA,EAGF,gBAAgB,OAAOC,MAA2B;AAC5C,QAAA;AACF,YAAM,EAAE,UAAAV,GAAU,wBAAAI,MAA2B,KAAK,cAC5CO,IAAY,MAAMC,EAAeZ,GAAUI,GAAwBM,CAAc,GACjFG,IAAeC,EAAsBH,CAAS;AAEpD,MAAAH,EAAY,MAAM;AAChB,aAAK,oBAAoBG,GACzB,KAAK,eAAeE;AAAA,MAAA,CACrB;AAAA,aACMJ,GAAO;AACN,cAAA,MAAM,2CAA2CA,CAAK,EAAE;AAAA,IAClE;AAAA,EAAA;AAAA,EAGF,IAAI,cAA2B;AACtB,WAAAM,EAAiB,KAAK,YAAY;AAAA,EAC3C;AAAA,EAEA,IAAI,oBAAuC;AACzC,UAAM,EAAE,QAAAC,GAAQ,aAAAC,GAAa,aAAAC,GAAa,kBAAAC,EAAqB,IAAAC;AAAA,MAC7D,KAAK,aAAa;AAAA,IAAA;AAEb,WAAA;AAAA,MACL,UAAUN,EAAsB,KAAK,iBAAiB;AAAA,MACtD,QAAAE;AAAA,MACA,aAAAC;AAAA,MACA,aAAAC;AAAA,MACA,kBAAAC;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,kBAAkB,CAACE,MAAsB;AACvC,IAAAb,EAAY,MAAM;AACX,WAAA,eAAe,KAAK,kBAAkBa,CAAS;AAAA,IAAA,CACrD;AAAA,EAAA;AAAA,EAGH,iBAAiB,CAACA,MAA6B;AAC7C,IAAAb,EAAY,MAAM;AAChB,WAAK,cAAca,MAAc,OAAO,KAAK,kBAAkBA,CAAS,IAAI;AAAA,IAAA,CAC7E;AAAA,EAAA;AAEL;"}
@@ -0,0 +1,141 @@
1
+ import { makeAutoObservable as m, observable as e, runInAction as a } from "mobx";
2
+ import "bowser";
3
+ import "date-fns/getUnixTime";
4
+ import "date-fns/intlFormat";
5
+ import { ae as n, af as o, au as s } from "./ConnectMiniWidget-CQWafYtQ.mjs";
6
+ import "date-fns/addMonths";
7
+ import "date-fns/addQuarters";
8
+ import "date-fns/addWeeks";
9
+ import "date-fns/addYears";
10
+ import "date-fns/getDay";
11
+ import "date-fns/isBefore";
12
+ import "date-fns/nextDay";
13
+ import "date-fns/setDate";
14
+ import "date-fns/startOfToday";
15
+ import "date-fns/fromUnixTime";
16
+ import "react";
17
+ import "numeral";
18
+ import "@mui/material";
19
+ import "react/jsx-runtime";
20
+ import "@mui/material/Button";
21
+ import "@mxenabled/mxui";
22
+ import "@mui/material/Tooltip";
23
+ import "@mui/material/Box";
24
+ import "@mui/material/IconButton";
25
+ import "./Loader-CwdK8lfx.mjs";
26
+ import "@mui/material/styles/useTheme";
27
+ import "@mui/material/useMediaQuery";
28
+ import "@mxenabled/cssinjs";
29
+ import "date-fns/addDays";
30
+ import "date-fns/eachDayOfInterval";
31
+ import "date-fns/eachWeekOfInterval";
32
+ import "date-fns/endOfMonth";
33
+ import "date-fns/format";
34
+ import "date-fns/isSameMonth";
35
+ import "date-fns/startOfMonth";
36
+ import "date-fns/subMonths";
37
+ import "@mui/material/Paper";
38
+ import "@mxenabled/mx-icons";
39
+ import "date-fns/isSameDay";
40
+ import "date-fns/isWithinInterval";
41
+ import "d3";
42
+ import "@mui/material/styles";
43
+ import "@mui/x-charts";
44
+ import "@mui/x-charts/ChartsTooltip";
45
+ import "@mui/material/Stack";
46
+ import "date-fns/differenceInCalendarDays";
47
+ import "date-fns/endOfToday";
48
+ import "date-fns/endOfYear";
49
+ import "date-fns/startOfYear";
50
+ import "date-fns/subDays";
51
+ import "date-fns/subYears";
52
+ import "@mui/material/ButtonGroup";
53
+ import "@mui/material/Tab";
54
+ import "@mui/material/Tabs";
55
+ import "@mui/material/ToggleButton";
56
+ import "@mui/material/ToggleButtonGroup";
57
+ import "@mui/material/Dialog";
58
+ import "@mui/material/DialogContent";
59
+ import "@mui/material/Card";
60
+ import "@mui/material/CardContent";
61
+ import "@mui/material/CardHeader";
62
+ import "uuid";
63
+ import "@mui/material/CircularProgress";
64
+ import "@mui/material/FormControlLabel";
65
+ import "@mui/material/Radio";
66
+ import "@mui/material/Avatar";
67
+ import "@mui/material/ListItem";
68
+ import "@mui/material/ListItemAvatar";
69
+ import "@mui/material/ListItemButton";
70
+ import "@mui/material/ListItemText";
71
+ import "@mui/material/ListItemIcon";
72
+ import "@mui/material/MenuItem";
73
+ import "@mui/material/TextField";
74
+ import "@mui/material/Switch";
75
+ import "posthog-js";
76
+ import "date-fns/differenceInDays";
77
+ import "@mui/x-data-grid-pro";
78
+ import "date-fns";
79
+ import "@mui/material/Divider";
80
+ import "@mui/material/List";
81
+ import "date-fns/formatISO";
82
+ import "date-fns/isAfter";
83
+ import "date-fns/parseISO";
84
+ import "date-fns/subQuarters";
85
+ import "date-fns/lastDayOfMonth";
86
+ import "date-fns/setDayOfYear";
87
+ import "date-fns/addSeconds";
88
+ import "date-fns/differenceInCalendarMonths";
89
+ import "date-fns/getMonth";
90
+ class r {
91
+ fetchInstance;
92
+ constructor(i, t) {
93
+ this.fetchInstance = new n(i, t);
94
+ }
95
+ getNotifications = () => this.fetchInstance.get(o.NOTIFICATIONS).then(
96
+ (i) => i.notifications.map((t) => t.notification)
97
+ ).finally();
98
+ updateNotification = (i) => this.fetchInstance.put(`${o.NOTIFICATIONS}/${i.guid}`, {
99
+ guid: i.guid,
100
+ has_been_viewed: i.has_been_viewed
101
+ }).then((t) => t.notification).finally();
102
+ // Note: The notifications/mark_all_as_viewed endpoint is broken, but still returns 202.
103
+ // A bug ticket has been filed to fix it, but should not require any changes here.
104
+ markAllAsViewed = (i) => this.fetchInstance.put(`${o.NOTIFICATIONS}/mark_all_as_viewed`, { channel: i }).finally();
105
+ }
106
+ class Ki {
107
+ globalStore;
108
+ api = new r("/", "");
109
+ isLoading = !0;
110
+ notifications = [];
111
+ recentNotifications = [];
112
+ constructor(i) {
113
+ this.globalStore = i, this.api = new r(i.endpoint, i.sessionToken), m(this, { notifications: e });
114
+ }
115
+ // Used in Money Dashboard
116
+ get newNotifications() {
117
+ return this.recentNotifications.filter((i) => !i.has_been_viewed);
118
+ }
119
+ loadNotifications = async () => {
120
+ try {
121
+ this.isLoading = !0;
122
+ const i = await this.api.getNotifications();
123
+ a(() => {
124
+ this.notifications = i, this.recentNotifications = s(i), this.isLoading = !1;
125
+ });
126
+ } catch (i) {
127
+ console.error(`Error occurred while loading notifications: ${i}`);
128
+ }
129
+ };
130
+ markAllAsViewed = async () => {
131
+ this.notifications.forEach((i) => i.has_been_viewed = !0), await this.api.markAllAsViewed(), await this.loadNotifications();
132
+ };
133
+ updateNotification = async (i) => {
134
+ i.has_been_viewed = !0, await this.api.updateNotification(i);
135
+ };
136
+ }
137
+ export {
138
+ Ki as N,
139
+ r as a
140
+ };
141
+ //# sourceMappingURL=NotificationStore-DCxw8W7u.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationStore-DCxw8W7u.mjs","sources":["../src/common/api/NotificationApi.ts","../src/notifications/stores/NotificationStore.ts"],"sourcesContent":["import Fetch from '../utils/Fetch'\n\nimport { ApiEndpoints } from '../constants'\n\nimport type { Notification } from '../types'\n\nexport class NotificationApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string) {\n this.fetchInstance = new Fetch(endpoint, token)\n }\n\n getNotifications = () => {\n return this.fetchInstance\n .get(ApiEndpoints.NOTIFICATIONS)\n .then((data) =>\n data.notifications.map((obj: { notification: Notification }) => obj.notification),\n )\n .finally()\n }\n\n updateNotification = (notification: Notification) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.NOTIFICATIONS}/${notification.guid}`, {\n guid: notification.guid,\n has_been_viewed: notification.has_been_viewed,\n })\n .then((data) => data.notification)\n .finally()\n }\n\n // Note: The notifications/mark_all_as_viewed endpoint is broken, but still returns 202.\n // A bug ticket has been filed to fix it, but should not require any changes here.\n markAllAsViewed = (channel?: number) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.NOTIFICATIONS}/mark_all_as_viewed`, { channel })\n .finally()\n }\n}\n","import { makeAutoObservable, observable, runInAction } from 'mobx'\n\nimport { NotificationApi, type Notification, GlobalStore } from '../../common'\n\nimport { filterRecentNotifications } from '../utils/NotificationUtils'\nexport class NotificationStore {\n globalStore: GlobalStore\n api = new NotificationApi('/', '')\n\n isLoading: boolean = true\n notifications: Notification[] = []\n recentNotifications: Notification[] = []\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new NotificationApi(globalStore.endpoint, globalStore.sessionToken)\n\n makeAutoObservable(this, { notifications: observable })\n }\n\n // Used in Money Dashboard\n get newNotifications(): Notification[] {\n return this.recentNotifications.filter((n) => !n.has_been_viewed)\n }\n\n loadNotifications = async () => {\n try {\n this.isLoading = true\n const data = await this.api.getNotifications()\n\n runInAction(() => {\n this.notifications = data\n this.recentNotifications = filterRecentNotifications(data)\n this.isLoading = false\n })\n } catch (error) {\n console.error(`Error occurred while loading notifications: ${error}`)\n }\n }\n\n markAllAsViewed = async () => {\n // Optimistically update the UI\n this.notifications.forEach((n) => (n.has_been_viewed = true))\n // Update on the server\n // (NOTE: The notifications/mark_all_as_viewed endpoint is broken, but still returns 202)\n await this.api.markAllAsViewed()\n await this.loadNotifications()\n }\n\n updateNotification = async (notification: Notification) => {\n notification.has_been_viewed = true\n await this.api.updateNotification(notification)\n }\n}\n"],"names":["NotificationApi","endpoint","token","Fetch","ApiEndpoints","data","obj","notification","channel","NotificationStore","globalStore","makeAutoObservable","observable","n","runInAction","filterRecentNotifications","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,MAAMA,EAAgB;AAAA,EAC3B;AAAA,EAEA,YAAYC,GAAkBC,GAAe;AAC3C,SAAK,gBAAgB,IAAIC,EAAMF,GAAUC,CAAK;AAAA,EAChD;AAAA,EAEA,mBAAmB,MACV,KAAK,cACT,IAAIE,EAAa,aAAa,EAC9B;AAAA,IAAK,CAACC,MACLA,EAAK,cAAc,IAAI,CAACC,MAAwCA,EAAI,YAAY;AAAA,IAEjF,QAAQ;AAAA,EAGb,qBAAqB,CAACC,MACb,KAAK,cACT,IAAI,GAAGH,EAAa,aAAa,IAAIG,EAAa,IAAI,IAAI;AAAA,IACzD,MAAMA,EAAa;AAAA,IACnB,iBAAiBA,EAAa;AAAA,EAAA,CAC/B,EACA,KAAK,CAACF,MAASA,EAAK,YAAY,EAChC;;;EAKL,kBAAkB,CAACG,MACV,KAAK,cACT,IAAI,GAAGJ,EAAa,aAAa,uBAAuB,EAAE,SAAAI,GAAS,EACnE,QAAQ;AAEf;AClCO,MAAMC,GAAkB;AAAA,EAC7B;AAAA,EACA,MAAM,IAAIT,EAAgB,KAAK,EAAE;AAAA,EAEjC,YAAqB;AAAA,EACrB,gBAAgC,CAAA;AAAA,EAChC,sBAAsC,CAAA;AAAA,EAEtC,YAAYU,GAA0B;AACpC,SAAK,cAAcA,GACnB,KAAK,MAAM,IAAIV,EAAgBU,EAAY,UAAUA,EAAY,YAAY,GAE7EC,EAAmB,MAAM,EAAE,eAAeC,EAAY,CAAA;AAAA,EACxD;AAAA;AAAA,EAGA,IAAI,mBAAmC;AACrC,WAAO,KAAK,oBAAoB,OAAO,CAACC,MAAM,CAACA,EAAE,eAAe;AAAA,EAClE;AAAA,EAEA,oBAAoB,YAAY;AAC1B,QAAA;AACF,WAAK,YAAY;AACjB,YAAMR,IAAO,MAAM,KAAK,IAAI,iBAAiB;AAE7C,MAAAS,EAAY,MAAM;AAChB,aAAK,gBAAgBT,GAChB,KAAA,sBAAsBU,EAA0BV,CAAI,GACzD,KAAK,YAAY;AAAA,MAAA,CAClB;AAAA,aACMW,GAAO;AACN,cAAA,MAAM,+CAA+CA,CAAK,EAAE;AAAA,IACtE;AAAA,EAAA;AAAA,EAGF,kBAAkB,YAAY;AAE5B,SAAK,cAAc,QAAQ,CAACH,MAAOA,EAAE,kBAAkB,EAAK,GAGtD,MAAA,KAAK,IAAI,mBACf,MAAM,KAAK;EAAkB;AAAA,EAG/B,qBAAqB,OAAON,MAA+B;AACzD,IAAAA,EAAa,kBAAkB,IACzB,MAAA,KAAK,IAAI,mBAAmBA,CAAY;AAAA,EAAA;AAElD;"}
@@ -0,0 +1,337 @@
1
+ import { makeAutoObservable as S, runInAction as s } from "mobx";
2
+ import { endOfMonth as l } from "date-fns/endOfMonth";
3
+ import { isAfter as m } from "date-fns/isAfter";
4
+ import { isBefore as I } from "date-fns/isBefore";
5
+ import { isSameDay as u } from "date-fns/isSameDay";
6
+ import { isWithinInterval as T } from "date-fns/isWithinInterval";
7
+ import { startOfMonth as f } from "date-fns/startOfMonth";
8
+ import { startOfToday as o } from "date-fns/startOfToday";
9
+ import { subDays as y } from "date-fns/subDays";
10
+ import "bowser";
11
+ import "date-fns/getUnixTime";
12
+ import "date-fns/intlFormat";
13
+ import { ae as x, af as c, aO as E, aP as i, aQ as g, aR as p } from "./ConnectMiniWidget-CQWafYtQ.mjs";
14
+ import "date-fns/addMonths";
15
+ import "date-fns/addQuarters";
16
+ import "date-fns/addWeeks";
17
+ import "date-fns/addYears";
18
+ import "date-fns/getDay";
19
+ import "date-fns/nextDay";
20
+ import "date-fns/setDate";
21
+ import "date-fns/fromUnixTime";
22
+ import "react";
23
+ import "numeral";
24
+ import "@mui/material";
25
+ import "react/jsx-runtime";
26
+ import "@mui/material/Button";
27
+ import "@mxenabled/mxui";
28
+ import "@mui/material/Tooltip";
29
+ import "@mui/material/Box";
30
+ import "@mui/material/IconButton";
31
+ import "./Loader-CwdK8lfx.mjs";
32
+ import "@mui/material/styles/useTheme";
33
+ import "@mui/material/useMediaQuery";
34
+ import "@mxenabled/cssinjs";
35
+ import "date-fns/addDays";
36
+ import "date-fns/eachDayOfInterval";
37
+ import "date-fns/eachWeekOfInterval";
38
+ import "date-fns/format";
39
+ import "date-fns/isSameMonth";
40
+ import "date-fns/subMonths";
41
+ import "@mui/material/Paper";
42
+ import "@mxenabled/mx-icons";
43
+ import "d3";
44
+ import "@mui/material/styles";
45
+ import "@mui/x-charts";
46
+ import "@mui/x-charts/ChartsTooltip";
47
+ import "@mui/material/Stack";
48
+ import "date-fns/differenceInCalendarDays";
49
+ import "date-fns/endOfToday";
50
+ import "date-fns/endOfYear";
51
+ import "date-fns/startOfYear";
52
+ import "date-fns/subYears";
53
+ import "@mui/material/ButtonGroup";
54
+ import "@mui/material/Tab";
55
+ import "@mui/material/Tabs";
56
+ import "@mui/material/ToggleButton";
57
+ import "@mui/material/ToggleButtonGroup";
58
+ import "@mui/material/Dialog";
59
+ import "@mui/material/DialogContent";
60
+ import "@mui/material/Card";
61
+ import "@mui/material/CardContent";
62
+ import "@mui/material/CardHeader";
63
+ import "uuid";
64
+ import "@mui/material/CircularProgress";
65
+ import "@mui/material/FormControlLabel";
66
+ import "@mui/material/Radio";
67
+ import "@mui/material/Avatar";
68
+ import "@mui/material/ListItem";
69
+ import "@mui/material/ListItemAvatar";
70
+ import "@mui/material/ListItemButton";
71
+ import "@mui/material/ListItemText";
72
+ import "@mui/material/ListItemIcon";
73
+ import "@mui/material/MenuItem";
74
+ import "@mui/material/TextField";
75
+ import "@mui/material/Switch";
76
+ import "posthog-js";
77
+ import "date-fns/differenceInDays";
78
+ import "@mui/x-data-grid-pro";
79
+ import "date-fns";
80
+ import "@mui/material/Divider";
81
+ import "@mui/material/List";
82
+ import "date-fns/formatISO";
83
+ import "date-fns/parseISO";
84
+ import "date-fns/subQuarters";
85
+ import "date-fns/lastDayOfMonth";
86
+ import "date-fns/setDayOfYear";
87
+ import "date-fns/addSeconds";
88
+ import "date-fns/differenceInCalendarMonths";
89
+ import "date-fns/getMonth";
90
+ class h {
91
+ fetchInstance;
92
+ constructor(t, e) {
93
+ this.fetchInstance = new x(t, e);
94
+ }
95
+ addRepeatingTransaction = async (t) => this.fetchInstance.post(c.REPEATING_TRANSACTIONS, t).then((e) => e.repeating_transaction);
96
+ getRepeatingTransactions = async () => this.fetchInstance.get(c.REPEATING_TRANSACTIONS).then((t) => t.repeating_transactions);
97
+ updateRepeatingTransaction = async (t) => this.fetchInstance.put(
98
+ `${c.REPEATING_TRANSACTIONS}/${t.guid}`,
99
+ t
100
+ ).then((e) => e.repeating_transaction);
101
+ deleteRepeatingTransaction = async (t) => this.fetchInstance.delete(`${c.REPEATING_TRANSACTIONS}/${t}`).then((e) => e);
102
+ }
103
+ const d = (a) => T(a.expectedDate, {
104
+ start: f(o()),
105
+ end: l(o())
106
+ }), n = (a, t) => a + t.amount;
107
+ class oe {
108
+ globalStore;
109
+ api = new h("/", "");
110
+ transactions = [];
111
+ repeatingTransactions = [];
112
+ selectedDay;
113
+ dateRange = { start: f(o()), end: l(o()) };
114
+ isDataLoaded = !1;
115
+ constructor(t) {
116
+ this.globalStore = t, this.api = new h(t.endpoint, t.sessionToken), S(this);
117
+ }
118
+ /**
119
+ * Returns all recurrences built from repeating transactions and filtered by accounts.
120
+ */
121
+ get recurrences() {
122
+ const t = this.globalStore.accountStore.visibleAccounts;
123
+ return E(this.repeatingTransactions, this.dateRange).filter((e) => t.some((r) => r.guid === e.accountGuid && !r.is_excluded_from_accounts)).filter((e) => T(e.expectedDate, this.dateRange));
124
+ }
125
+ /**
126
+ * Returns all recurrences that have occurred in the past, including those that are paid or missed
127
+ */
128
+ get pastRecurrences() {
129
+ return this.recurrences.filter(
130
+ (t) => t.status === i.Paid || t.status === i.Missed
131
+ );
132
+ }
133
+ /**
134
+ * Returns all recurrences that are expected to occur through the end of the month
135
+ * or should have occurred in the last 3 days.
136
+ */
137
+ get upcomingRecurrences() {
138
+ return this.recurrences.filter(
139
+ (t) => m(t.expectedDate, y(o(), 3)) && I(t.expectedDate, this.dateRange.end) && t.status === i.Upcoming
140
+ );
141
+ }
142
+ /**
143
+ * Returns all expense recurrences.
144
+ */
145
+ get expenses() {
146
+ return this.recurrences.filter(
147
+ (t) => t.type === g.Expense
148
+ );
149
+ }
150
+ /**
151
+ * Returns the upcoming expense recurrences.
152
+ */
153
+ get upcomingExpenses() {
154
+ return this.expenses.filter(
155
+ (t) => t.status === i.Upcoming
156
+ );
157
+ }
158
+ /**
159
+ * Returns all income recurrences.
160
+ */
161
+ get income() {
162
+ return this.recurrences.filter(
163
+ (t) => t.type === g.Income
164
+ );
165
+ }
166
+ /**
167
+ * Returns the upcoming income recurrences.
168
+ */
169
+ get upcomingIncome() {
170
+ return this.income.filter(
171
+ (t) => t.status === i.Upcoming
172
+ );
173
+ }
174
+ get nextIncomeRecurrence() {
175
+ return this.upcomingIncome.find((t) => m(t.expectedDate, o()));
176
+ }
177
+ /**
178
+ * Returns the expense recurrences for the current month.
179
+ */
180
+ get currentMonthExpenses() {
181
+ return this.expenses.filter(d);
182
+ }
183
+ /**
184
+ * Returns the income recurrences for the current month.
185
+ */
186
+ get currentMonthIncome() {
187
+ return this.income.filter(d);
188
+ }
189
+ /**
190
+ * Calculates the total amount of all expenses for the current month.
191
+ */
192
+ get expenseTotal() {
193
+ return this.currentMonthExpenses.reduce(n, 0);
194
+ }
195
+ /**
196
+ * Calculates the total amount of all paid expenses for the current month.
197
+ */
198
+ get paidExpenseTotal() {
199
+ return this.currentMonthExpenses.filter((t) => t.status === i.Paid).reduce(n, 0);
200
+ }
201
+ /**
202
+ * Calculates the total amount of all missed expenses for the current month.
203
+ */
204
+ get missedExpenseTotal() {
205
+ return this.currentMonthExpenses.filter((t) => t.status === i.Missed).reduce(n, 0);
206
+ }
207
+ /**
208
+ * Calculates the total amount of all upcoming expenses for the current month.
209
+ */
210
+ get upcomingExpenseTotal() {
211
+ return this.currentMonthExpenses.filter((t) => t.status === i.Upcoming).reduce(n, 0);
212
+ }
213
+ /**
214
+ * Calculates the total amount of all income for the current month.
215
+ */
216
+ get incomeTotal() {
217
+ return this.currentMonthIncome.reduce(n, 0);
218
+ }
219
+ /**
220
+ * Calculates the total amount of all paid income for the current month.
221
+ */
222
+ get paidIncomeTotal() {
223
+ return this.currentMonthIncome.filter((t) => t.status === i.Paid).reduce(n, 0);
224
+ }
225
+ /**
226
+ * Calculates the total amount of all upcoming income for the current month.
227
+ */
228
+ get upcomingIncomeTotal() {
229
+ return this.currentMonthIncome.filter((t) => t.status === i.Upcoming).reduce(n, 0);
230
+ }
231
+ /**
232
+ * Get the recurrences for the currently selected day.
233
+ */
234
+ get selectedDayRecurrences() {
235
+ return this.selectedDay && this.recurrences.filter(
236
+ (t) => this.selectedDay && u(t.occurredOnDate || t.expectedDate, this.selectedDay)
237
+ );
238
+ }
239
+ /**
240
+ * Set the date range for filtering recurrences.
241
+ * @param dateRange - The date range to set.
242
+ */
243
+ setDateRange = (t) => this.dateRange = t;
244
+ /**
245
+ * Set the currently selected day.
246
+ * @param day - The day to select.
247
+ */
248
+ setSelectedDay = (t) => {
249
+ this.selectedDay = this.selectedDay && u(t, this.selectedDay) ? void 0 : t;
250
+ };
251
+ /**
252
+ * Load repeating transactions and augment them with additional data.
253
+ */
254
+ loadRepeatingTransactions = async () => {
255
+ try {
256
+ const t = await this.api.getRepeatingTransactions();
257
+ s(() => {
258
+ this.repeatingTransactions = p(
259
+ this.globalStore.accountStore.visibleAccounts,
260
+ t,
261
+ this.globalStore.transactionStore.transactions
262
+ ), this.isDataLoaded = !0;
263
+ });
264
+ } catch (t) {
265
+ console.error(`Error occurred while getting repeating transactions: ${t}`);
266
+ }
267
+ };
268
+ /**
269
+ * Add a new repeating transaction and link it to the associated transaction.
270
+ * @param repeatingTransaction - The repeating transaction to add.
271
+ * @param transaction - The transaction associated with the repeating transaction.
272
+ */
273
+ addRepeatingTransaction = async (t, e) => {
274
+ try {
275
+ const r = await this.api.addRepeatingTransaction(t);
276
+ await this.globalStore.transactionStore.updateTransaction({
277
+ ...e,
278
+ repeating_transaction_guid: r.guid
279
+ }), s(() => {
280
+ this.repeatingTransactions = [
281
+ ...this.repeatingTransactions,
282
+ ...p(
283
+ this.globalStore.accountStore.visibleAccounts,
284
+ [r],
285
+ this.globalStore.transactionStore.transactions
286
+ )
287
+ ];
288
+ });
289
+ } catch (r) {
290
+ console.error(`Error occurred while adding repeating transaction: ${r}`);
291
+ }
292
+ };
293
+ /**
294
+ * Delete a repeating transaction by its GUID.
295
+ * @param guid - The GUID of the repeating transaction to delete.
296
+ */
297
+ deleteRepeatingTransaction = async (t) => {
298
+ try {
299
+ await this.api.deleteRepeatingTransaction(t), s(() => {
300
+ this.repeatingTransactions = [
301
+ ...this.repeatingTransactions.filter((e) => e.guid !== t)
302
+ ];
303
+ });
304
+ } catch (e) {
305
+ console.error(`Error occurred while deleting repeating transaction: ${e}`);
306
+ }
307
+ };
308
+ /**
309
+ * Update an existing repeating transaction.
310
+ * @param transaction - The repeating transaction to update.
311
+ */
312
+ updateRepeatingTransaction = async (t) => {
313
+ try {
314
+ const e = await this.api.updateRepeatingTransaction(t), r = this.repeatingTransactions.findIndex(
315
+ (R) => R.guid === e.guid
316
+ );
317
+ if (r < 0) return;
318
+ s(() => {
319
+ this.repeatingTransactions = [
320
+ ...this.repeatingTransactions.slice(0, r),
321
+ ...p(
322
+ this.globalStore.accountStore.visibleAccounts,
323
+ [e],
324
+ this.globalStore.transactionStore.transactions
325
+ ),
326
+ ...this.repeatingTransactions.slice(r + 1)
327
+ ];
328
+ });
329
+ } catch (e) {
330
+ console.error(`Error occurred while updating repeating transaction: ${e}`);
331
+ }
332
+ };
333
+ }
334
+ export {
335
+ oe as R
336
+ };
337
+ //# sourceMappingURL=RecurringTransactionsStore-Bijrgllq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecurringTransactionsStore-Bijrgllq.mjs","sources":["../src/recurringtransactions/api/RepeatingTransactionsApi.ts","../src/recurringtransactions/stores/RecurringTransactionsStore.ts"],"sourcesContent":["import { ApiEndpoints, Fetch } from '../../common'\nimport { RepeatingTransaction } from '../../common'\n\nexport class RepeatingTransactionsApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string) {\n this.fetchInstance = new Fetch(endpoint, token)\n }\n\n addRepeatingTransaction = async (repeatingTransaction: RepeatingTransaction) => {\n return this.fetchInstance\n .post(ApiEndpoints.REPEATING_TRANSACTIONS, repeatingTransaction)\n .then((data) => data.repeating_transaction)\n }\n\n getRepeatingTransactions = async () => {\n return this.fetchInstance\n .get(ApiEndpoints.REPEATING_TRANSACTIONS)\n .then((data) => data.repeating_transactions)\n }\n\n updateRepeatingTransaction = async (repeatingTransaction: RepeatingTransaction) => {\n return this.fetchInstance\n .put(\n `${ApiEndpoints.REPEATING_TRANSACTIONS}/${repeatingTransaction.guid}`,\n repeatingTransaction,\n )\n .then((data) => data.repeating_transaction)\n }\n\n deleteRepeatingTransaction = async (guid: string) => {\n return this.fetchInstance\n .delete(`${ApiEndpoints.REPEATING_TRANSACTIONS}/${guid}`)\n .then((data) => data)\n }\n}\n","import { makeAutoObservable, runInAction } from 'mobx'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { isAfter } from 'date-fns/isAfter'\nimport { isBefore } from 'date-fns/isBefore'\nimport { isSameDay } from 'date-fns/isSameDay'\nimport { isWithinInterval } from 'date-fns/isWithinInterval'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subDays } from 'date-fns/subDays'\n\nimport {\n type Recurrence,\n type RepeatingTransaction,\n type Transaction,\n GlobalStore,\n RecurrenceStatus,\n RecurrenceType,\n type DateRange,\n} from '../../common'\n\nimport { RepeatingTransactionsApi } from '../api/RepeatingTransactionsApi'\nimport { augmentRepeatingTransactions, buildAllRecurrences } from '../util/RecurringTransactions'\n\nconst currentMonthFilter = (recurrence: Recurrence) =>\n isWithinInterval(recurrence.expectedDate, {\n start: startOfMonth(startOfToday()),\n end: endOfMonth(startOfToday()),\n })\n\nconst recurrenceTotalReducer = (total: number, recurrence: Recurrence) => total + recurrence.amount\n\nexport class RecurringTransactionsStore {\n globalStore: GlobalStore\n api = new RepeatingTransactionsApi('/', '')\n\n transactions: Transaction[] = []\n repeatingTransactions: RepeatingTransaction[] = []\n selectedDay: Date | undefined\n dateRange: DateRange = { start: startOfMonth(startOfToday()), end: endOfMonth(startOfToday()) }\n\n isDataLoaded: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new RepeatingTransactionsApi(globalStore.endpoint, globalStore.sessionToken)\n\n makeAutoObservable(this)\n }\n\n /**\n * Returns all recurrences built from repeating transactions and filtered by accounts.\n */\n get recurrences(): Recurrence[] {\n const accounts = this.globalStore.accountStore.visibleAccounts\n\n return buildAllRecurrences(this.repeatingTransactions, this.dateRange)\n .filter((r) => accounts.some((a) => a.guid === r.accountGuid && !a.is_excluded_from_accounts))\n .filter((r) => isWithinInterval(r.expectedDate, this.dateRange))\n }\n\n /**\n * Returns all recurrences that have occurred in the past, including those that are paid or missed\n */\n get pastRecurrences(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) =>\n recurrence.status === RecurrenceStatus.Paid ||\n recurrence.status === RecurrenceStatus.Missed,\n )\n }\n\n /**\n * Returns all recurrences that are expected to occur through the end of the month\n * or should have occurred in the last 3 days.\n */\n get upcomingRecurrences(): Recurrence[] {\n return this.recurrences.filter(\n (r) =>\n isAfter(r.expectedDate, subDays(startOfToday(), 3)) &&\n isBefore(r.expectedDate, this.dateRange.end) &&\n r.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns all expense recurrences.\n */\n get expenses(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) => recurrence.type === RecurrenceType.Expense,\n )\n }\n\n /**\n * Returns the upcoming expense recurrences.\n */\n get upcomingExpenses(): Recurrence[] {\n return this.expenses.filter(\n (recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n /**\n * Returns all income recurrences.\n */\n get income(): Recurrence[] {\n return this.recurrences.filter(\n (recurrence: Recurrence) => recurrence.type === RecurrenceType.Income,\n )\n }\n\n /**\n * Returns the upcoming income recurrences.\n */\n get upcomingIncome(): Recurrence[] {\n return this.income.filter(\n (recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming,\n )\n }\n\n get nextIncomeRecurrence() {\n return this.upcomingIncome.find((r) => isAfter(r.expectedDate, startOfToday()))\n }\n\n /**\n * Returns the expense recurrences for the current month.\n */\n get currentMonthExpenses(): Recurrence[] {\n return this.expenses.filter(currentMonthFilter)\n }\n\n /**\n * Returns the income recurrences for the current month.\n */\n get currentMonthIncome(): Recurrence[] {\n return this.income.filter(currentMonthFilter)\n }\n\n /**\n * Calculates the total amount of all expenses for the current month.\n */\n get expenseTotal(): number {\n return this.currentMonthExpenses.reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all paid expenses for the current month.\n */\n get paidExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Paid)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all missed expenses for the current month.\n */\n get missedExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Missed)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all upcoming expenses for the current month.\n */\n get upcomingExpenseTotal(): number {\n return this.currentMonthExpenses\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all income for the current month.\n */\n get incomeTotal(): number {\n return this.currentMonthIncome.reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all paid income for the current month.\n */\n get paidIncomeTotal(): number {\n return this.currentMonthIncome\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Paid)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Calculates the total amount of all upcoming income for the current month.\n */\n get upcomingIncomeTotal(): number {\n return this.currentMonthIncome\n .filter((recurrence: Recurrence) => recurrence.status === RecurrenceStatus.Upcoming)\n .reduce(recurrenceTotalReducer, 0)\n }\n\n /**\n * Get the recurrences for the currently selected day.\n */\n get selectedDayRecurrences(): Recurrence[] | undefined {\n return (\n this.selectedDay &&\n this.recurrences.filter(\n (recurrence: Recurrence) =>\n this.selectedDay &&\n isSameDay(recurrence.occurredOnDate || recurrence.expectedDate, this.selectedDay),\n )\n )\n }\n\n /**\n * Set the date range for filtering recurrences.\n * @param dateRange - The date range to set.\n */\n setDateRange = (dateRange: DateRange) => (this.dateRange = dateRange)\n\n /**\n * Set the currently selected day.\n * @param day - The day to select.\n */\n setSelectedDay = (day: Date) => {\n this.selectedDay = this.selectedDay && isSameDay(day, this.selectedDay) ? undefined : day\n }\n\n /**\n * Load repeating transactions and augment them with additional data.\n */\n loadRepeatingTransactions = async () => {\n try {\n const repeatingTransactions = await this.api.getRepeatingTransactions()\n\n runInAction(() => {\n this.repeatingTransactions = augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n repeatingTransactions,\n this.globalStore.transactionStore.transactions,\n )\n this.isDataLoaded = true\n })\n } catch (error) {\n console.error(`Error occurred while getting repeating transactions: ${error}`)\n }\n }\n\n /**\n * Add a new repeating transaction and link it to the associated transaction.\n * @param repeatingTransaction - The repeating transaction to add.\n * @param transaction - The transaction associated with the repeating transaction.\n */\n addRepeatingTransaction = async (\n repeatingTransaction: RepeatingTransaction,\n transaction: Transaction,\n ) => {\n try {\n const newRepeating = await this.api.addRepeatingTransaction(repeatingTransaction)\n\n await this.globalStore.transactionStore.updateTransaction({\n ...transaction,\n repeating_transaction_guid: newRepeating.guid,\n })\n\n runInAction(() => {\n this.repeatingTransactions = [\n ...this.repeatingTransactions,\n ...augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n [newRepeating],\n this.globalStore.transactionStore.transactions,\n ),\n ]\n })\n } catch (error) {\n console.error(`Error occurred while adding repeating transaction: ${error}`)\n }\n }\n\n /**\n * Delete a repeating transaction by its GUID.\n * @param guid - The GUID of the repeating transaction to delete.\n */\n deleteRepeatingTransaction = async (guid: string) => {\n try {\n await this.api.deleteRepeatingTransaction(guid)\n\n runInAction(() => {\n this.repeatingTransactions = [\n ...this.repeatingTransactions.filter((rt) => rt.guid !== guid),\n ]\n })\n } catch (error) {\n console.error(`Error occurred while deleting repeating transaction: ${error}`)\n }\n }\n\n /**\n * Update an existing repeating transaction.\n * @param transaction - The repeating transaction to update.\n */\n updateRepeatingTransaction = async (transaction: RepeatingTransaction) => {\n try {\n const updatedTransaction = await this.api.updateRepeatingTransaction(transaction)\n\n const index = this.repeatingTransactions.findIndex(\n (rt) => rt.guid === updatedTransaction.guid,\n )\n if (index < 0) return\n\n runInAction(() => {\n this.repeatingTransactions = [\n ...this.repeatingTransactions.slice(0, index),\n ...augmentRepeatingTransactions(\n this.globalStore.accountStore.visibleAccounts,\n [updatedTransaction],\n this.globalStore.transactionStore.transactions,\n ),\n ...this.repeatingTransactions.slice(index + 1),\n ]\n })\n } catch (error) {\n console.error(`Error occurred while updating repeating transaction: ${error}`)\n }\n }\n}\n"],"names":["RepeatingTransactionsApi","endpoint","token","Fetch","repeatingTransaction","ApiEndpoints","data","guid","currentMonthFilter","recurrence","isWithinInterval","startOfMonth","startOfToday","endOfMonth","recurrenceTotalReducer","total","RecurringTransactionsStore","globalStore","makeAutoObservable","accounts","buildAllRecurrences","r","a","RecurrenceStatus","isAfter","subDays","isBefore","RecurrenceType","isSameDay","dateRange","day","repeatingTransactions","runInAction","augmentRepeatingTransactions","error","transaction","newRepeating","rt","updatedTransaction","index"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,EAAyB;AAAA,EACpC;AAAA,EAEA,YAAYC,GAAkBC,GAAe;AAC3C,SAAK,gBAAgB,IAAIC,EAAMF,GAAUC,CAAK;AAAA,EAChD;AAAA,EAEA,0BAA0B,OAAOE,MACxB,KAAK,cACT,KAAKC,EAAa,wBAAwBD,CAAoB,EAC9D,KAAK,CAACE,MAASA,EAAK,qBAAqB;AAAA,EAG9C,2BAA2B,YAClB,KAAK,cACT,IAAID,EAAa,sBAAsB,EACvC,KAAK,CAACC,MAASA,EAAK,sBAAsB;AAAA,EAG/C,6BAA6B,OAAOF,MAC3B,KAAK,cACT;AAAA,IACC,GAAGC,EAAa,sBAAsB,IAAID,EAAqB,IAAI;AAAA,IACnEA;AAAA,EAED,EAAA,KAAK,CAACE,MAASA,EAAK,qBAAqB;AAAA,EAG9C,6BAA6B,OAAOC,MAC3B,KAAK,cACT,OAAO,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