@mx-cartographer/experiences 9.4.52 → 9.4.53

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 CHANGED
@@ -1,3 +1,8 @@
1
+ ## [9.4.53] - 10-02-2026
2
+
3
+ - **FIXED** - Recalculated budget amounts now use the three-month spending average instead of varying by browser history MEW-4013
4
+ - **FIXED** - Recalculate budgets drawer now shows a loader, cannot close while saving, and stays open with an error if the save fails MEW-4013
5
+
1
6
  ## [9.4.52] - 10-02-2026
2
7
 
3
8
  - **FIXED** - Storybook stories that crashed or rendered blank now load (MEW-4207)
@@ -1,5 +1,7 @@
1
1
  interface RecalculateBudgetsProps {
2
2
  onRecalculateBudgets?: () => void;
3
3
  }
4
- export declare const RecalculateBudgets: ({ onRecalculateBudgets }: RecalculateBudgetsProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const RecalculateBudgets: (({ onRecalculateBudgets }: RecalculateBudgetsProps) => import("react/jsx-runtime").JSX.Element) & {
5
+ displayName: string;
6
+ };
5
7
  export {};
@@ -1,23 +1,37 @@
1
- import { useBudgetsStore as b, useCategoryStore as h, useGlobalCopyStore as x } from "../../../common/context/hooks.es.js";
2
- import y from "../../../common/components/drawer/Drawer.es.js";
3
- import { RecalculateBudgetRow as _ } from "./RecalculateBudgetRow.es.js";
4
- import i from "react";
5
- import n from "@mui/material/Stack";
6
- import { Text as a } from "@mxenabled/mxui";
7
- import C from "@mui/material/Button";
8
- import { jsx as e, jsxs as c } from "react/jsx-runtime";
9
- import v from "@mui/material/Box";
10
- import B from "@mui/material/List";
11
- var F = ({ onRecalculateBudgets: s }) => {
12
- const { budgets: t, common: m } = x(), { spendCategories: u } = h(), { recalculateBudgets: p, setAlert: d } = b(), [g, o] = i.useState(!1), l = u.filter((r) => r.totalAverageAmount > 0), f = async () => {
13
- await p(l), o(!1), d({
14
- msg: t.alert_recalculated_budgets,
15
- severity: "success"
16
- }), s?.();
1
+ import { useBudgetsStore as _, useCategoryStore as C, useGlobalCopyStore as S } from "../../../common/context/hooks.es.js";
2
+ import B from "../../../common/components/drawer/Drawer.es.js";
3
+ import { RecalculateBudgetRow as A } from "./RecalculateBudgetRow.es.js";
4
+ import o from "react";
5
+ import { observer as k } from "mobx-react-lite";
6
+ import p from "@mui/material/Stack";
7
+ import { Text as l } from "@mxenabled/mxui";
8
+ import w from "@mui/material/Button";
9
+ import { jsx as e, jsxs as i } from "react/jsx-runtime";
10
+ import R from "@mui/material/Box";
11
+ import I from "@mui/material/List";
12
+ import P from "@mui/material/Alert";
13
+ var J = k(({ onRecalculateBudgets: d }) => {
14
+ const { budgets: t, common: n } = S(), { spendCategories: f } = C(), { recalculateBudgets: g, setAlert: h } = _(), [x, s] = o.useState(!1), [c, m] = o.useState(!1), [y, a] = o.useState(!1), u = f.filter((r) => r.totalAverageAmount > 0), b = () => {
15
+ c || (s(!1), a(!1));
16
+ }, v = async () => {
17
+ m(!0), a(!1);
18
+ try {
19
+ const { isSuccess: r } = await g(u);
20
+ if (!r) {
21
+ a(!0);
22
+ return;
23
+ }
24
+ s(!1), h({
25
+ msg: t.alert_recalculated_budgets,
26
+ severity: "success"
27
+ }), d?.();
28
+ } finally {
29
+ m(!1);
30
+ }
17
31
  };
18
- return /* @__PURE__ */ c(i.Fragment, { children: [
19
- /* @__PURE__ */ e(C, {
20
- onClick: () => o(!0),
32
+ return /* @__PURE__ */ i(o.Fragment, { children: [
33
+ /* @__PURE__ */ e(w, {
34
+ onClick: () => s(!0),
21
35
  sx: {
22
36
  mt: 24,
23
37
  mx: 24
@@ -25,7 +39,7 @@ var F = ({ onRecalculateBudgets: s }) => {
25
39
  variant: "text",
26
40
  children: t.recalculate_button
27
41
  }),
28
- /* @__PURE__ */ e(a, {
42
+ /* @__PURE__ */ e(l, {
29
43
  sx: {
30
44
  mx: 24,
31
45
  my: 16,
@@ -35,33 +49,46 @@ var F = ({ onRecalculateBudgets: s }) => {
35
49
  component: "span",
36
50
  children: t.recalculate_help
37
51
  }),
38
- /* @__PURE__ */ e(y, {
39
- ariaLabelClose: m.close_aria,
40
- isOpen: g,
41
- onClose: () => o(!1),
42
- onPrimaryAction: f,
52
+ /* @__PURE__ */ e(B, {
53
+ ariaLabelClose: n.close_aria,
54
+ isOpen: x,
55
+ onClose: b,
56
+ onPrimaryAction: v,
57
+ primaryButtonProps: { loading: c },
43
58
  title: t.recalculate_title,
44
- children: /* @__PURE__ */ c(n, { children: [/* @__PURE__ */ c(n, {
45
- mx: 24,
46
- my: 16,
47
- children: [/* @__PURE__ */ e(a, {
48
- bold: !0,
49
- variant: "body1",
50
- children: t.recalculate_description_top
51
- }), /* @__PURE__ */ e(a, {
52
- component: "span",
53
- variant: "subtitle2",
54
- children: t.recalculate_description_bottom
55
- })]
56
- }), /* @__PURE__ */ e(v, {
57
- bgcolor: "background.paper",
58
- children: /* @__PURE__ */ e(B, { children: l.map((r) => /* @__PURE__ */ e(_, { category: r }, r.guid)) })
59
- })] })
59
+ children: /* @__PURE__ */ i(p, { children: [
60
+ y && /* @__PURE__ */ e(P, {
61
+ role: "alert",
62
+ severity: "error",
63
+ sx: {
64
+ mt: 16,
65
+ mx: 24
66
+ },
67
+ children: n.error_message
68
+ }),
69
+ /* @__PURE__ */ i(p, {
70
+ mx: 24,
71
+ my: 16,
72
+ children: [/* @__PURE__ */ e(l, {
73
+ bold: !0,
74
+ variant: "body1",
75
+ children: t.recalculate_description_top
76
+ }), /* @__PURE__ */ e(l, {
77
+ component: "span",
78
+ variant: "subtitle2",
79
+ children: t.recalculate_description_bottom
80
+ })]
81
+ }),
82
+ /* @__PURE__ */ e(R, {
83
+ bgcolor: "background.paper",
84
+ children: /* @__PURE__ */ e(I, { children: u.map((r) => /* @__PURE__ */ e(A, { category: r }, r.guid)) })
85
+ })
86
+ ] })
60
87
  })
61
88
  ] });
62
- };
89
+ });
63
90
  export {
64
- F as RecalculateBudgets
91
+ J as RecalculateBudgets
65
92
  };
66
93
 
67
94
  //# sourceMappingURL=RecalculateBudgets.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RecalculateBudgets.es.js","names":[],"sources":["../../../../src/budgets/components/addbudget/RecalculateBudgets.tsx"],"sourcesContent":["import React from 'react'\n\nimport Button from '@mui/material/Button'\nimport List from '@mui/material/List'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { Drawer, useBudgetsStore, useCategoryStore, useGlobalCopyStore } from '../../../common'\n\nimport { RecalculateBudgetRow } from './RecalculateBudgetRow'\n\ninterface RecalculateBudgetsProps {\n onRecalculateBudgets?: () => void\n}\n\nexport const RecalculateBudgets = ({ onRecalculateBudgets }: RecalculateBudgetsProps) => {\n const { budgets: copy, common: commonCopy } = useGlobalCopyStore()\n const { spendCategories } = useCategoryStore()\n const { recalculateBudgets, setAlert } = useBudgetsStore()\n\n const [isOpen, setIsOpen] = React.useState(false)\n\n const newBudgetCategories = spendCategories.filter((category) => category.totalAverageAmount > 0)\n\n const handlePrimaryClick = async () => {\n await recalculateBudgets(newBudgetCategories)\n\n setIsOpen(false)\n setAlert({ msg: copy.alert_recalculated_budgets, severity: 'success' })\n onRecalculateBudgets?.()\n }\n\n return (\n <React.Fragment>\n <Button onClick={() => setIsOpen(true)} sx={{ mt: 24, mx: 24 }} variant=\"text\">\n {copy.recalculate_button}\n </Button>\n\n <Text sx={{ mx: 24, my: 16, textAlign: 'center' }} variant=\"subtitle1\" component=\"span\">\n {copy.recalculate_help}\n </Text>\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isOpen}\n onClose={() => setIsOpen(false)}\n onPrimaryAction={handlePrimaryClick}\n title={copy.recalculate_title}\n >\n <Stack>\n <Stack mx={24} my={16}>\n <Text bold={true} variant=\"body1\">\n {copy.recalculate_description_top}\n </Text>\n <Text component=\"span\" variant=\"subtitle2\">\n {copy.recalculate_description_bottom}\n </Text>\n </Stack>\n <Box bgcolor=\"background.paper\">\n <List>\n {newBudgetCategories.map((category) => (\n <RecalculateBudgetRow category={category} key={category.guid} />\n ))}\n </List>\n </Box>\n </Stack>\n </Drawer>\n </React.Fragment>\n )\n}\n"],"mappings":";;;;;;;;;;AAiBA,IAAa,IAAA,CAAsB,EAAE,sBAAA,EAAA,MAAoD;AACvF,QAAM,EAAE,SAAS,GAAM,QAAQ,EAAA,IAAe,EAAmB,GAC3D,EAAE,iBAAA,EAAA,IAAoB,EAAiB,GACvC,EAAE,oBAAA,GAAoB,UAAA,EAAA,IAAa,EAAgB,GAEnD,CAAC,GAAQ,CAAA,IAAa,EAAM,SAAS,EAAK,GAE1C,IAAsB,EAAgB,OAAA,CAAQ,MAAa,EAAS,qBAAqB,CAAC,GAE1F,IAAqB,YAAY;AACrC,UAAM,EAAmB,CAAmB,GAE5C,EAAU,EAAK,GACf,EAAS;AAAA,MAAE,KAAK,EAAK;AAAA,MAA4B,UAAU;AAAA,IAAU,CAAC,GACtE,IAAuB;AAAA,EACzB;AAEA,SACE,gBAAA,EAAC,EAAM,UAAP,EAAA,UAAA;AAAA,IACE,gBAAA,EAAC,GAAD;AAAA,MAAQ,SAAA,MAAe,EAAU,EAAI;AAAA,MAAG,IAAI;AAAA,QAAE,IAAI;AAAA,QAAI,IAAI;AAAA,MAAG;AAAA,MAAG,SAAQ;AAAA,MACrE,UAAA,EAAK;AAAA,IACA,CAAA;AAAA,IAER,gBAAA,EAAC,GAAD;AAAA,MAAM,IAAI;AAAA,QAAE,IAAI;AAAA,QAAI,IAAI;AAAA,QAAI,WAAW;AAAA,MAAS;AAAA,MAAG,SAAQ;AAAA,MAAY,WAAU;AAAA,MAC9E,UAAA,EAAK;AAAA,IACF,CAAA;AAAA,IACN,gBAAA,EAAC,GAAD;AAAA,MACE,gBAAgB,EAAW;AAAA,MACnB,QAAA;AAAA,MACR,SAAA,MAAe,EAAU,EAAK;AAAA,MAC9B,iBAAiB;AAAA,MACjB,OAAO,EAAK;AAAA,MAEZ,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,QAAI,IAAI;AAAA,QAAnB,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,UAAM,MAAM;AAAA,UAAM,SAAQ;AAAA,UACvB,UAAA,EAAK;AAAA,QACF,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,UAAM,WAAU;AAAA,UAAO,SAAQ;AAAA,UAC5B,UAAA,EAAK;AAAA,QACF,CAAA,CACD;AAAA,MACP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,QAAK,SAAQ;AAAA,QACX,UAAA,gBAAA,EAAC,GAAD,EAAA,UACG,EAAoB,IAAA,CAAK,MACxB,gBAAA,EAAC,GAAD,EAAgC,UAAA,EAA+B,GAAhB,EAAS,IAAO,CAChE,EACG,CAAA;AAAA,MACH,CAAA,CACA,EAAA,CAAA;AAAA,IACD,CAAA;AAAA,EACM,EAAA,CAAA;AAEpB"}
1
+ {"version":3,"file":"RecalculateBudgets.es.js","names":[],"sources":["../../../../src/budgets/components/addbudget/RecalculateBudgets.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Alert from '@mui/material/Alert'\nimport Button from '@mui/material/Button'\nimport List from '@mui/material/List'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { Drawer, useBudgetsStore, useCategoryStore, useGlobalCopyStore } from '../../../common'\n\nimport { RecalculateBudgetRow } from './RecalculateBudgetRow'\n\ninterface RecalculateBudgetsProps {\n onRecalculateBudgets?: () => void\n}\n\nexport const RecalculateBudgets = observer(({ onRecalculateBudgets }: RecalculateBudgetsProps) => {\n const { budgets: copy, common: commonCopy } = useGlobalCopyStore()\n const { spendCategories } = useCategoryStore()\n const { recalculateBudgets, setAlert } = useBudgetsStore()\n\n const [isOpen, setIsOpen] = React.useState(false)\n const [isSaving, setIsSaving] = React.useState(false)\n const [isError, setIsError] = React.useState(false)\n\n const newBudgetCategories = spendCategories.filter((category) => category.totalAverageAmount > 0)\n\n const handleClose = () => {\n if (isSaving) return\n setIsOpen(false)\n setIsError(false)\n }\n\n const handlePrimaryClick = async () => {\n setIsSaving(true)\n setIsError(false)\n try {\n const { isSuccess } = await recalculateBudgets(newBudgetCategories)\n if (!isSuccess) {\n setIsError(true)\n return\n }\n setIsOpen(false)\n setAlert({ msg: copy.alert_recalculated_budgets, severity: 'success' })\n onRecalculateBudgets?.()\n } finally {\n setIsSaving(false)\n }\n }\n\n return (\n <React.Fragment>\n <Button onClick={() => setIsOpen(true)} sx={{ mt: 24, mx: 24 }} variant=\"text\">\n {copy.recalculate_button}\n </Button>\n\n <Text sx={{ mx: 24, my: 16, textAlign: 'center' }} variant=\"subtitle1\" component=\"span\">\n {copy.recalculate_help}\n </Text>\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isOpen}\n onClose={handleClose}\n onPrimaryAction={handlePrimaryClick}\n primaryButtonProps={{ loading: isSaving }}\n title={copy.recalculate_title}\n >\n <Stack>\n {isError && (\n <Alert role=\"alert\" severity=\"error\" sx={{ mt: 16, mx: 24 }}>\n {commonCopy.error_message}\n </Alert>\n )}\n <Stack mx={24} my={16}>\n <Text bold={true} variant=\"body1\">\n {copy.recalculate_description_top}\n </Text>\n <Text component=\"span\" variant=\"subtitle2\">\n {copy.recalculate_description_bottom}\n </Text>\n </Stack>\n <Box bgcolor=\"background.paper\">\n <List>\n {newBudgetCategories.map((category) => (\n <RecalculateBudgetRow category={category} key={category.guid} />\n ))}\n </List>\n </Box>\n </Stack>\n </Drawer>\n </React.Fragment>\n )\n})\n"],"mappings":";;;;;;;;;;;;AAmBA,IAAa,IAAqB,EAAA,CAAU,EAAE,sBAAA,EAAA,MAAoD;AAChG,QAAM,EAAE,SAAS,GAAM,QAAQ,EAAA,IAAe,EAAmB,GAC3D,EAAE,iBAAA,EAAA,IAAoB,EAAiB,GACvC,EAAE,oBAAA,GAAoB,UAAA,EA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oB,EAAE,SAAS,EAAS;AAAA,MACxC,OAAO,EAAK;AAAA,MAEZ,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAA;AAAA,QACG,KACC,gBAAA,EAAC,GAAD;AAAA,UAAO,MAAK;AAAA,UAAQ,UAAS;AAAA,UAAQ,IAAI;AAAA,YAAE,IAAI;AAAA,YAAI,IAAI;AAAA,UAAG;AAAA,UACvD,UAAA,EAAW;AAAA,QACP,CAAA;AAAA,QAET,gBAAA,EAAC,GAAD;AAAA,UAAO,IAAI;AAAA,UAAI,IAAI;AAAA,UAAnB,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,YAAM,MAAM;AAAA,YAAM,SAAQ;AAAA,YACvB,UAAA,EAAK;AAAA,UACF,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,YAAM,WAAU;AAAA,YAAO,SAAQ;AAAA,YAC5B,UAAA,EAAK;AAAA,UACF,CAAA,CACD;AAAA;QACP,gBAAA,EAAC,GAAD;AAAA,UAAK,SAAQ;AAAA,UACX,UAAA,gBAAA,EAAC,GAAD,EAAA,UACG,EAAoB,IAAA,CAAK,MACxB,gBAAA,EAAC,GAAD,EAAgC,UAAA,EAA+B,GAAhB,EAAS,IAAO,CAChE,EACG,CAAA;AAAA,QACH,CAAA;AAAA,MACA,EAAA,CAAA;AAAA,IACD,CAAA;AAAA,EACM,EAAA,CAAA;AAEpB,CAAC"}
@@ -1,18 +1,18 @@
1
1
  import { CategoryGuids as o } from "../constants/Category.es.js";
2
2
  import { BudgetsApi as g } from "../api/BudgetsApi.es.js";
3
3
  import { upsertByGuid as n } from "../utils/upsertByGuid.es.js";
4
- import { augmentBudgets as c, findBudget as h, findSubBudget as p } from "../utils/BudgetUtil.es.js";
4
+ import { augmentBudgets as c, findBudget as l, findSubBudget as p } from "../utils/BudgetUtil.es.js";
5
5
  import { endOfMonth as B } from "date-fns/endOfMonth";
6
6
  import { startOfMonth as f } from "date-fns/startOfMonth";
7
- import { startOfToday as l } from "date-fns/startOfToday";
7
+ import { startOfToday as h } from "date-fns/startOfToday";
8
8
  import { makeAutoObservable as S, reaction as b, runInAction as i } from "mobx";
9
9
  var A = class {
10
10
  api = new g("/", "");
11
11
  globalStore;
12
12
  alert = null;
13
13
  dateRange = {
14
- start: f(l()),
15
- end: B(l())
14
+ start: f(h()),
15
+ end: B(h())
16
16
  };
17
17
  budgets = [];
18
18
  selectedBudget;
@@ -27,7 +27,7 @@ var A = class {
27
27
  this.globalStore.recurringTransactionsStore.isDataLoaded || await this.globalStore.recurringTransactionsStore.loadRepeatingTransactionData(), await this.loadBudgets(), b(() => this.detailedBudgets, (t) => {
28
28
  if (t) {
29
29
  const e = this.selectedBudget;
30
- e && (this.selectedBudget = h(t, e.guid));
30
+ e && (this.selectedBudget = l(t, e.guid));
31
31
  const r = this.selectedSubBudget;
32
32
  r && r.parent_guid && (this.selectedSubBudget = p(t, r.guid, r.parent_guid));
33
33
  }
@@ -99,7 +99,8 @@ var A = class {
99
99
  isSuccess: !0
100
100
  };
101
101
  } catch (e) {
102
- return console.error("Error recalculating budgets:", e), this.globalStore.captureException(e, { store: "BudgetsStore" }), {
102
+ return console.error("Error recalculating budgets:", e), this.globalStore.captureException(e, { store: "BudgetsStore" }), await this.loadBudgets().catch(() => {
103
+ }), {
103
104
  data: [],
104
105
  isSuccess: !1
105
106
  };
@@ -1 +1 @@
1
- {"version":3,"file":"BudgetsStore.es.js","names":[],"sources":["../../../src/core/stores/BudgetsStore.ts"],"sourcesContent":["import { makeAutoObservable, reaction, runInAction } from 'mobx'\n\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\n\nimport { Theme } from '@mui/system'\n\nimport { BudgetsApi } from '../api'\nimport { upsertByGuid } from '../utils/upsertByGuid'\nimport { CategoryGuids } from '../constants'\nimport { augmentBudgets, findBudget, findSubBudget } from '../utils/BudgetUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nimport type {\n Budget,\n Category,\n DateRange,\n DetailedBudget,\n DetailedCategory,\n MerchantBudget,\n} from '../types'\n\nexport class BudgetsStore {\n api: BudgetsApi = new BudgetsApi('/', '')\n\n globalStore: GlobalStore\n\n alert: { msg: string; severity: 'success' | 'error' } | null = null\n dateRange: DateRange = { start: startOfMonth(startOfToday()), end: endOfMonth(startOfToday()) }\n budgets: Budget[] = []\n selectedBudget: DetailedBudget | undefined\n selectedSubBudget: DetailedBudget | undefined\n isDataLoaded = false\n theme = {} as Theme\n merchantBudgets: MerchantBudget[] = []\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new BudgetsApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadBudgetData = async () => {\n if (!this.globalStore.recurringTransactionsStore.isDataLoaded) {\n await this.globalStore.recurringTransactionsStore.loadRepeatingTransactionData()\n }\n await this.loadBudgets()\n\n /** Reaction to update the selected budget/sub-budget if detailedBudgets is updated **/\n reaction(\n () => this.detailedBudgets,\n (detailedBudgets) => {\n if (detailedBudgets) {\n const budget = this.selectedBudget\n if (budget) {\n this.selectedBudget = findBudget(detailedBudgets, budget.guid)\n }\n\n const subBudget = this.selectedSubBudget\n if (subBudget && subBudget.parent_guid) {\n this.selectedSubBudget = findSubBudget(\n detailedBudgets,\n subBudget.guid,\n subBudget.parent_guid,\n )\n }\n }\n },\n )\n }\n\n get detailedBudgets(): DetailedBudget[] {\n return augmentBudgets(\n this.budgets.filter(\n (budget: Budget) =>\n budget.category_guid !== CategoryGuids.INCOME &&\n budget.category_guid !== CategoryGuids.TRANSFER &&\n budget.category_guid !== CategoryGuids.INVESTMENTS,\n ),\n this.globalStore.categoryStore.detailedCategories,\n this.globalStore.copyStore.copy.budgets,\n this.theme,\n ).sort((a, b) => {\n if (a.percentage > b.percentage) return -1\n if (a.percentage < b.percentage) return 1\n return 0\n })\n }\n\n // TODO: Replace this with income from recurring transactions. Income budgets are deprecated.\n get incomeBudget(): number | undefined {\n const filteredBudgets = augmentBudgets(\n this.budgets.filter((budget: Budget) => !budget.parent_guid),\n this.globalStore.categoryStore.detailedCategories,\n this.globalStore.copyStore.copy.budgets,\n this.theme,\n )\n\n const incomeBudget = filteredBudgets.reduce(\n (acc, curr) => {\n if (curr.category_guid !== CategoryGuids.INCOME) return acc\n if (!acc || curr.percentage > acc.percentage) return curr\n return acc\n },\n undefined as DetailedBudget | undefined,\n )\n\n return incomeBudget?.amount\n }\n\n get unbudgetedCategories(): DetailedCategory[] {\n return this.globalStore.categoryStore.spendCategories.filter(\n (category) => !this.detailedBudgets.find((budget) => budget.category_guid === category.guid),\n )\n }\n\n get totalBudgeted(): number {\n return this.detailedBudgets.reduce((total, budget) => total + budget.amount, 0)\n }\n\n addBudget = async (category: Category, amount: number, parentGuid: string | null = null) => {\n try {\n const budget = await this.api.addBudget(category, amount, parentGuid)\n runInAction(() => {\n this.budgets = upsertByGuid(this.budgets, budget)\n })\n } catch (error) {\n console.error('Error adding budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n }\n }\n\n deleteBudget = async (guid: string): Promise<boolean> => {\n const guids = [guid, ...this.budgets.filter((b) => b.parent_guid === guid).map((b) => b.guid)]\n const results = await Promise.allSettled(guids.map((g) => this.api.deleteBudget(g)))\n const deleted = new Set(guids.filter((_, i) => results[i].status === 'fulfilled'))\n runInAction(() => {\n this.budgets = this.budgets.filter((b) => !deleted.has(b.guid))\n })\n let failed = false\n for (const [i, r] of results.entries()) {\n if (r.status === 'rejected') {\n failed = true\n console.error('Error deleting budget:', r.reason)\n this.globalStore.captureException(r.reason, { store: 'BudgetsStore', guid: guids[i] })\n }\n }\n return !failed\n }\n\n loadBudgets = async () => {\n try {\n const budgets = await this.api.getBudgets()\n this.setBudgets(budgets)\n } catch (error) {\n console.error('Error occurred while loading budgets:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n throw error\n }\n }\n\n setAlert = (alert: { msg: string; severity: 'success' | 'error' } | null) => (this.alert = alert)\n\n setBudgets = (budgets: Budget[]) => {\n this.budgets = budgets\n this.isDataLoaded = true\n }\n\n setDateRange = (dateRange: DateRange) => (this.dateRange = dateRange)\n\n setSelectedBudget = (budget: DetailedBudget | undefined) => (this.selectedBudget = budget)\n\n setSelectedSubBudget = (budget: DetailedBudget | undefined) => (this.selectedSubBudget = budget)\n\n setTheme = (theme: Theme) => (this.theme = theme)\n\n /**\n * Recalculate budget by using the average amount from top-level categories\n * @param categories Detailed categories\n */\n recalculateBudgets = async (categories: DetailedCategory[]) => {\n try {\n for (const category of categories) {\n const budget = this.budgets.find((budget) => budget.category_guid === category.guid)\n if (budget) {\n await this.api.updateBudget({\n ...budget,\n amount: category.totalAverageAmount,\n })\n } else {\n await this.api.addBudget(category, category.totalAverageAmount)\n }\n }\n const budgetsToDelete = this.budgets.filter(\n (budget) => !categories.find((c) => c.guid === budget.category_guid),\n )\n\n for (const budgetToDelete of budgetsToDelete) {\n await this.api.deleteBudget(budgetToDelete.guid)\n }\n\n await this.loadBudgets()\n\n return { data: this.budgets, isSuccess: true }\n } catch (error) {\n console.error('Error recalculating budgets:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return { data: [], isSuccess: false }\n }\n }\n\n updateBudget = async (budget: Budget): Promise<boolean> => {\n try {\n const updatedBudget = await this.api.updateBudget(budget)\n\n runInAction(() => {\n const index = this.budgets.findIndex((b) => b.guid === budget.guid)\n if (index >= 0) {\n this.budgets[index] = updatedBudget\n }\n })\n return true\n } catch (error) {\n console.error('Error updating budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return false\n }\n }\n\n getMerchantBudgetByMerchantGuid = (merchantGuid: string): MerchantBudget | undefined => {\n return this.merchantBudgets.find(\n (eachMerchantBudget) => eachMerchantBudget?.merchant_guid === merchantGuid,\n )\n }\n\n setMerchantBudgets = (merchantBudgets: MerchantBudget[]) => {\n this.merchantBudgets = merchantBudgets\n }\n\n addMerchantBudget = async (merchantGuid: string, amount: number) => {\n try {\n const newMerchantBudget = await this.api.addMerchantBudget(merchantGuid, amount)\n\n runInAction(() => {\n this.merchantBudgets = upsertByGuid(this.merchantBudgets, newMerchantBudget)\n })\n return { isSuccess: true }\n } catch (error) {\n console.error('Error adding merchant budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return { isSuccess: false }\n }\n }\n\n updateMerchantBudget = async (merchantBudget: MerchantBudget) => {\n try {\n const { guid: merchantBudgetGuid, amount } = merchantBudget\n const updatedMerchantBudget = await this.api.updateMerchantBudget(merchantBudgetGuid, amount)\n\n runInAction(() => {\n const index = this.merchantBudgets.findIndex((b) => b.guid === merchantBudget.guid)\n if (index >= 0) {\n this.merchantBudgets[index] = updatedMerchantBudget\n }\n })\n return { isSuccess: true }\n } catch (error) {\n console.error('Error updating merchant budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return { isSuccess: false }\n }\n }\n\n deleteMerchantBudget = async (merchantBudgetGuid: string) => {\n try {\n await this.api.deleteMerchantBudget(merchantBudgetGuid)\n\n runInAction(() => {\n this.merchantBudgets = this.merchantBudgets.filter((b) => b.guid !== merchantBudgetGuid)\n })\n return { isSuccess: true }\n } catch (error) {\n console.error('Error deleting merchant budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return { isSuccess: false }\n }\n }\n}\n"],"mappings":";;;;;;;;AAwBA,IAAa,IAAb,MAA0B;AAAA,EACxB,MAAkB,IAAI,EAAW,KAAK,EAAE;AAAA,EAExC;AAAA,EAEA,QAA+D;AAAA,EAC/D,YAAuB;AAAA,IAAE,OAAO,EAAa,EAAa,CAAC;AAAA,IAAG,KAAK,EAAW,EAAa,CAAC;AAAA,EAAE;AAAA,EAC9F,UAAoB,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,QAAQ,CAAC;AAAA,EACT,kBAAoC,CAAC;AAAA,EAErC,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM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AM,KAAK,IAAI,qBAAqB,GAAoB,CAAM;AAE5F,aAAA,EAAA,MAAkB;AAChB,cAAM,IAAQ,KAAK,gBAAgB,UAAA,CAAW,MAAM,EAAE,SAAS,EAAe,IAAI;AAClF,QAAI,KAAS,MACX,KAAK,gBAAgB,CAAA,IAAS;AAAA,MAElC,CAAC,GACM,EAAE,WAAW,GAAK;AAAA,IAC3B,SAAS,GAAO;AACd,qBAAQ,MAAM,mCAAmC,CAAK,GACtD,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,eAAe,CAAC,GAC3D,EAAE,WAAW,GAAM;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,uBAAuB,OAAO,MAA+B;AAC3D,QAAI;AACF,mBAAM,KAAK,IAAI,qBAAqB,CAAkB,GAEtD,EAAA,MAAkB;AAChB,aAAK,kBAAkB,KAAK,gBAAgB,OAAA,CAAQ,MAAM,EAAE,SAAS,CAAkB;AAAA,MACzF,CAAC,GACM,EAAE,WAAW,GAAK;AAAA,IAC3B,SAAS,GAAO;AACd,qBAAQ,MAAM,mCAAmC,CAAK,GACtD,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,eAAe,CAAC,GAC3D,EAAE,WAAW,GAAM;AAAA,IAC5B;AAAA,EACF;AACF"}
1
+ {"version":3,"file":"BudgetsStore.es.js","names":[],"sources":["../../../src/core/stores/BudgetsStore.ts"],"sourcesContent":["import { makeAutoObservable, reaction, runInAction } from 'mobx'\n\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\n\nimport { Theme } from '@mui/system'\n\nimport { BudgetsApi } from '../api'\nimport { upsertByGuid } from '../utils/upsertByGuid'\nimport { CategoryGuids } from '../constants'\nimport { augmentBudgets, findBudget, findSubBudget } from '../utils/BudgetUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nimport type {\n Budget,\n Category,\n DateRange,\n DetailedBudget,\n DetailedCategory,\n MerchantBudget,\n} from '../types'\n\nexport class BudgetsStore {\n api: BudgetsApi = new BudgetsApi('/', '')\n\n globalStore: GlobalStore\n\n alert: { msg: string; severity: 'success' | 'error' } | null = null\n dateRange: DateRange = { start: startOfMonth(startOfToday()), end: endOfMonth(startOfToday()) }\n budgets: Budget[] = []\n selectedBudget: DetailedBudget | undefined\n selectedSubBudget: DetailedBudget | undefined\n isDataLoaded = false\n theme = {} as Theme\n merchantBudgets: MerchantBudget[] = []\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new BudgetsApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadBudgetData = async () => {\n if (!this.globalStore.recurringTransactionsStore.isDataLoaded) {\n await this.globalStore.recurringTransactionsStore.loadRepeatingTransactionData()\n }\n await this.loadBudgets()\n\n /** Reaction to update the selected budget/sub-budget if detailedBudgets is updated **/\n reaction(\n () => this.detailedBudgets,\n (detailedBudgets) => {\n if (detailedBudgets) {\n const budget = this.selectedBudget\n if (budget) {\n this.selectedBudget = findBudget(detailedBudgets, budget.guid)\n }\n\n const subBudget = this.selectedSubBudget\n if (subBudget && subBudget.parent_guid) {\n this.selectedSubBudget = findSubBudget(\n detailedBudgets,\n subBudget.guid,\n subBudget.parent_guid,\n )\n }\n }\n },\n )\n }\n\n get detailedBudgets(): DetailedBudget[] {\n return augmentBudgets(\n this.budgets.filter(\n (budget: Budget) =>\n budget.category_guid !== CategoryGuids.INCOME &&\n budget.category_guid !== CategoryGuids.TRANSFER &&\n budget.category_guid !== CategoryGuids.INVESTMENTS,\n ),\n this.globalStore.categoryStore.detailedCategories,\n this.globalStore.copyStore.copy.budgets,\n this.theme,\n ).sort((a, b) => {\n if (a.percentage > b.percentage) return -1\n if (a.percentage < b.percentage) return 1\n return 0\n })\n }\n\n // TODO: Replace this with income from recurring transactions. Income budgets are deprecated.\n get incomeBudget(): number | undefined {\n const filteredBudgets = augmentBudgets(\n this.budgets.filter((budget: Budget) => !budget.parent_guid),\n this.globalStore.categoryStore.detailedCategories,\n this.globalStore.copyStore.copy.budgets,\n this.theme,\n )\n\n const incomeBudget = filteredBudgets.reduce(\n (acc, curr) => {\n if (curr.category_guid !== CategoryGuids.INCOME) return acc\n if (!acc || curr.percentage > acc.percentage) return curr\n return acc\n },\n undefined as DetailedBudget | undefined,\n )\n\n return incomeBudget?.amount\n }\n\n get unbudgetedCategories(): DetailedCategory[] {\n return this.globalStore.categoryStore.spendCategories.filter(\n (category) => !this.detailedBudgets.find((budget) => budget.category_guid === category.guid),\n )\n }\n\n get totalBudgeted(): number {\n return this.detailedBudgets.reduce((total, budget) => total + budget.amount, 0)\n }\n\n addBudget = async (category: Category, amount: number, parentGuid: string | null = null) => {\n try {\n const budget = await this.api.addBudget(category, amount, parentGuid)\n runInAction(() => {\n this.budgets = upsertByGuid(this.budgets, budget)\n })\n } catch (error) {\n console.error('Error adding budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n }\n }\n\n deleteBudget = async (guid: string): Promise<boolean> => {\n const guids = [guid, ...this.budgets.filter((b) => b.parent_guid === guid).map((b) => b.guid)]\n const results = await Promise.allSettled(guids.map((g) => this.api.deleteBudget(g)))\n const deleted = new Set(guids.filter((_, i) => results[i].status === 'fulfilled'))\n runInAction(() => {\n this.budgets = this.budgets.filter((b) => !deleted.has(b.guid))\n })\n let failed = false\n for (const [i, r] of results.entries()) {\n if (r.status === 'rejected') {\n failed = true\n console.error('Error deleting budget:', r.reason)\n this.globalStore.captureException(r.reason, { store: 'BudgetsStore', guid: guids[i] })\n }\n }\n return !failed\n }\n\n loadBudgets = async () => {\n try {\n const budgets = await this.api.getBudgets()\n this.setBudgets(budgets)\n } catch (error) {\n console.error('Error occurred while loading budgets:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n throw error\n }\n }\n\n setAlert = (alert: { msg: string; severity: 'success' | 'error' } | null) => (this.alert = alert)\n\n setBudgets = (budgets: Budget[]) => {\n this.budgets = budgets\n this.isDataLoaded = true\n }\n\n setDateRange = (dateRange: DateRange) => (this.dateRange = dateRange)\n\n setSelectedBudget = (budget: DetailedBudget | undefined) => (this.selectedBudget = budget)\n\n setSelectedSubBudget = (budget: DetailedBudget | undefined) => (this.selectedSubBudget = budget)\n\n setTheme = (theme: Theme) => (this.theme = theme)\n\n /**\n * Recalculate budget by using the average amount from top-level categories\n * @param categories Detailed categories\n */\n recalculateBudgets = async (categories: DetailedCategory[]) => {\n try {\n for (const category of categories) {\n const budget = this.budgets.find((budget) => budget.category_guid === category.guid)\n if (budget) {\n await this.api.updateBudget({\n ...budget,\n amount: category.totalAverageAmount,\n })\n } else {\n await this.api.addBudget(category, category.totalAverageAmount)\n }\n }\n const budgetsToDelete = this.budgets.filter(\n (budget) => !categories.find((c) => c.guid === budget.category_guid),\n )\n\n for (const budgetToDelete of budgetsToDelete) {\n await this.api.deleteBudget(budgetToDelete.guid)\n }\n\n await this.loadBudgets()\n\n return { data: this.budgets, isSuccess: true }\n } catch (error) {\n console.error('Error recalculating budgets:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n // Some budgets may have saved before the failure; reload so a retry updates them.\n await this.loadBudgets().catch(() => undefined)\n return { data: [], isSuccess: false }\n }\n }\n\n updateBudget = async (budget: Budget): Promise<boolean> => {\n try {\n const updatedBudget = await this.api.updateBudget(budget)\n\n runInAction(() => {\n const index = this.budgets.findIndex((b) => b.guid === budget.guid)\n if (index >= 0) {\n this.budgets[index] = updatedBudget\n }\n })\n return true\n } catch (error) {\n console.error('Error updating budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return false\n }\n }\n\n getMerchantBudgetByMerchantGuid = (merchantGuid: string): MerchantBudget | undefined => {\n return this.merchantBudgets.find(\n (eachMerchantBudget) => eachMerchantBudget?.merchant_guid === merchantGuid,\n )\n }\n\n setMerchantBudgets = (merchantBudgets: MerchantBudget[]) => {\n this.merchantBudgets = merchantBudgets\n }\n\n addMerchantBudget = async (merchantGuid: string, amount: number) => {\n try {\n const newMerchantBudget = await this.api.addMerchantBudget(merchantGuid, amount)\n\n runInAction(() => {\n this.merchantBudgets = upsertByGuid(this.merchantBudgets, newMerchantBudget)\n })\n return { isSuccess: true }\n } catch (error) {\n console.error('Error adding merchant budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return { isSuccess: false }\n }\n }\n\n updateMerchantBudget = async (merchantBudget: MerchantBudget) => {\n try {\n const { guid: merchantBudgetGuid, amount } = merchantBudget\n const updatedMerchantBudget = await this.api.updateMerchantBudget(merchantBudgetGuid, amount)\n\n runInAction(() => {\n const index = this.merchantBudgets.findIndex((b) => b.guid === merchantBudget.guid)\n if (index >= 0) {\n this.merchantBudgets[index] = updatedMerchantBudget\n }\n })\n return { isSuccess: true }\n } catch (error) {\n console.error('Error updating merchant budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return { isSuccess: false }\n }\n }\n\n deleteMerchantBudget = async (merchantBudgetGuid: string) => {\n try {\n await this.api.deleteMerchantBudget(merchantBudgetGuid)\n\n runInAction(() => {\n this.merchantBudgets = this.merchantBudgets.filter((b) => b.guid !== merchantBudgetGuid)\n })\n return { isSuccess: true }\n } catch (error) {\n console.error('Error deleting merchant budget:', error)\n this.globalStore.captureException(error, { store: 'BudgetsStore' })\n return { isSuccess: false }\n }\n }\n}\n"],"mappings":";;;;;;;;AAwBA,IAAa,IAAb,MAA0B;AAAA,EACxB,MAAkB,IAAI,EAAW,KAAK,EAAE;AAAA,EAExC;AAAA,EAEA,QAA+D;AAAA,EAC/D,YAAuB;AAAA,IAAE,OAAO,EAAa,EAAa,CAAC;AAAA,IAAG,KAAK,EAAW,EAAa,CAAC;AAAA,EAAE;AAAA,EAC9F,UAAoB,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,QAAQ,CAAC;AAAA,EACT,kBAAoC,CAAC;AAAA,EAErC,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KA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ACF,YAAM,EAAE,MAAM,GAAoB,QAAA,EAAA,IAAW,GACvC,IAAwB,MAAM,KAAK,IAAI,qBAAqB,GAAoB,CAAM;AAE5F,aAAA,EAAA,MAAkB;AAChB,cAAM,IAAQ,KAAK,gBAAgB,UAAA,CAAW,MAAM,EAAE,SAAS,EAAe,IAAI;AAClF,QAAI,KAAS,MACX,KAAK,gBAAgB,CAAA,IAAS;AAAA,MAElC,CAAC,GACM,EAAE,WAAW,GAAK;AAAA,IAC3B,SAAS,GAAO;AACd,qBAAQ,MAAM,mCAAmC,CAAK,GACtD,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,eAAe,CAAC,GAC3D,EAAE,WAAW,GAAM;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,uBAAuB,OAAO,MAA+B;AAC3D,QAAI;AACF,mBAAM,KAAK,IAAI,qBAAqB,CAAkB,GAEtD,EAAA,MAAkB;AAChB,aAAK,kBAAkB,KAAK,gBAAgB,OAAA,CAAQ,MAAM,EAAE,SAAS,CAAkB;AAAA,MACzF,CAAC,GACM,EAAE,WAAW,GAAK;AAAA,IAC3B,SAAS,GAAO;AACd,qBAAQ,MAAM,mCAAmC,CAAK,GACtD,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,eAAe,CAAC,GAC3D,EAAE,WAAW,GAAM;AAAA,IAC5B;AAAA,EACF;AACF"}
@@ -1,7 +1,7 @@
1
- import { CategoryColors as M, CategoryGuids as h, CategoryIcon as N } from "../constants/Category.es.js";
1
+ import { CategoryColors as C, CategoryGuids as h, CategoryIcon as N } from "../constants/Category.es.js";
2
2
  import { DATE_FORMATS_INTL as T, formatDate as b } from "../constants/DateFormats.es.js";
3
3
  import { CategoryIconList as D } from "@mxenabled/mxui";
4
- import { format as c } from "date-fns/format";
4
+ import { format as l } from "date-fns/format";
5
5
  import { startOfMonth as O } from "date-fns/startOfMonth";
6
6
  import { startOfToday as E } from "date-fns/startOfToday";
7
7
  import { subMonths as I } from "date-fns/subMonths";
@@ -12,19 +12,19 @@ var R = 3, f = 12, S = (e, r) => {
12
12
  const t = D.find((o) => o.guid === e);
13
13
  return t ? r.palette.categories[t.colorName] || "" : r.palette.categories.uncategorized || "";
14
14
  }, _ = (e, r, t, o, a = []) => {
15
- const n = e.guid, u = e.parent_guid || n, s = n === u, g = t.find((i) => i.category_guid === n)?.total || 0, d = p(o.filter((i) => i.category_guid === n)), m = p(o.filter((i) => i.category_guid === n || i.top_level_category_guid === n)), l = a.map((i) => _(i, r, t, o)), A = l.reduce((i, C) => i + C.currentAmount, g), v = S(e, r);
15
+ const n = e.guid, u = e.parent_guid || n, s = n === u, g = t.find((i) => i.category_guid === n)?.total || 0, d = y(o.filter((i) => i.category_guid === n)), m = y(o.filter((i) => i.category_guid === n || i.top_level_category_guid === n)), c = a.map((i) => _(i, r, t, o)), A = c.reduce((i, M) => i + M.currentAmount, g), v = S(e, r);
16
16
  return {
17
17
  ...e,
18
18
  currentAmount: g,
19
- averageAmount: y(d),
20
- color: M[u],
19
+ averageAmount: p(d),
20
+ color: C[u],
21
21
  icon: N[u],
22
22
  isTransfer: u === h.TRANSFER,
23
23
  monthlyAmounts: d,
24
24
  name: v,
25
- subCategories: l,
25
+ subCategories: c,
26
26
  totalAmount: s ? A : 0,
27
- totalAverageAmount: y(m),
27
+ totalAverageAmount: p(m),
28
28
  totalMonthlyAmounts: s ? m : []
29
29
  };
30
30
  }, P = (e, r) => e.map((t) => {
@@ -33,16 +33,16 @@ var R = 3, f = 12, S = (e, r) => {
33
33
  ...t,
34
34
  transactions: o
35
35
  };
36
- }), y = (e, r = R) => {
37
- const t = r > history.length ? history.length : r;
36
+ }), p = (e, r = R) => {
37
+ const t = Math.min(r, e.length);
38
38
  return Math.ceil(Math.max(0, e.slice(-t).reduce((o, a) => o + a.amount, 0) / t));
39
- }, p = (e) => {
39
+ }, y = (e) => {
40
40
  const r = [], t = E();
41
41
  for (let o = 0; o <= f; o++) {
42
- const a = O(I(t, f - o)), n = e.filter((u) => u.year_month === Number(c(a, "yyyyMM"))).reduce((u, s) => u + s.total, 0);
42
+ const a = O(I(t, f - o)), n = e.filter((u) => u.year_month === Number(l(a, "yyyyMM"))).reduce((u, s) => u + s.total, 0);
43
43
  r.push({
44
44
  amount: n,
45
- isoDate: c(a, "yyyy-MM-dd"),
45
+ isoDate: l(a, "yyyy-MM-dd"),
46
46
  label: b(a, T.MONTH_YEAR)
47
47
  });
48
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CategoryUtil.es.js","names":[],"sources":["../../../src/core/utils/CategoryUtil.ts"],"sourcesContent":["import { format } from 'date-fns/format'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subMonths } from 'date-fns/subMonths'\n\nimport type { Palette, Theme } from '@mui/material'\n\nimport { CategoryIconList } from '@mxenabled/mxui'\n\nimport {\n CategoryColors,\n CategoryGuids,\n CategoryIcon,\n DATE_FORMATS_INTL,\n formatDate,\n} from '../constants'\n\nimport type {\n Category,\n DateRangeCategoryTotals,\n DetailedCategory,\n DetailedCategoryWithTransactions,\n MonthlyAmount,\n MonthlyCategoryTotals,\n Transaction,\n CategoryCopy,\n CategoryTotal,\n} from '../types'\n\nconst MONTHLY_AVERAGE_LENGTH = 3\nconst MONTHS_OF_HISTORY = 12\n\n/**\n * Resolve the localized display name for a category.\n *\n * Default (MX-supplied) categories arrive from the API with fixed English\n * names, but localized copy for them is delivered via CategoryCopy\n * `default_categories` (keyed by category guid). User-created categories have no\n * localized copy and legitimately fall back to their API name.\n * @param category - The category to resolve a name for\n * @param copy - Category copy containing localized default category names\n */\nexport const getLocalizedCategoryName = (category: Category, copy: CategoryCopy): string => {\n const localizedName = copy.default_categories?.[category.guid]\n return localizedName ? localizedName.replace(/&amp;/g, '&') : category.name\n}\n\n/**\n * Augment categories\n * @param categories - Categories to augment\n * @param monthlyCategoryTotals - Monthly category totals\n * @param currentCategoryTotals - Current month category totals\n * @param copy - Category copy\n */\nexport const augmentCategories = (\n categories: Category[],\n copy: CategoryCopy,\n currentCategoryTotals: DateRangeCategoryTotals[],\n monthlyCategoryTotals: MonthlyCategoryTotals[],\n): DetailedCategory[] => {\n return categories\n .filter((category) => !category.parent_guid)\n .map((category) =>\n getDetailedCategory(\n category,\n copy,\n currentCategoryTotals,\n monthlyCategoryTotals,\n categories.filter((c) => c.parent_guid === category.guid),\n ),\n )\n}\n\nexport const getCategoryColor = (guid: string, theme: Theme) => {\n const categoryInfo = CategoryIconList.find((c) => c.guid === guid)\n if (!categoryInfo) return theme.palette.categories.uncategorized || ''\n\n return theme.palette.categories[categoryInfo.colorName as keyof Palette['categories']] || ''\n}\n\nexport const getCategoryIcon = (guid: string) => {\n return CategoryIconList.find((c) => c.guid === guid)?.icon\n}\n\n/**\n * Get an augmented category with additional details\n * @param category - The category to augment\n * @param copy - Category copy\n * @param currentCategoryTotals - Current month category totals\n * @param monthlyCategoryTotals - Past monthly category totals\n * @param subCategories - Subcategories for the specified category (If applicable)\n */\nconst getDetailedCategory = (\n category: Category,\n copy: CategoryCopy,\n currentCategoryTotals: DateRangeCategoryTotals[],\n monthlyCategoryTotals: MonthlyCategoryTotals[],\n subCategories: Category[] = [],\n): DetailedCategory => {\n const guid = category.guid\n const parentGuid = category.parent_guid || guid\n const isParent = guid === parentGuid\n\n const currentAmount = currentCategoryTotals.find((t) => t.category_guid === guid)?.total || 0\n const monthlyAmounts = getMonthlyAmounts(\n monthlyCategoryTotals.filter((total) => total.category_guid === guid),\n )\n const totalMonthlyAmounts = getMonthlyAmounts(\n monthlyCategoryTotals.filter(\n (total) => total.category_guid === guid || total.top_level_category_guid === guid,\n ),\n )\n const detailedSubCategories = subCategories.map((subCategory) =>\n getDetailedCategory(subCategory, copy, currentCategoryTotals, monthlyCategoryTotals),\n )\n const totalAmount = detailedSubCategories.reduce(\n (total, current) => total + current.currentAmount,\n currentAmount,\n )\n\n const name = getLocalizedCategoryName(category, copy)\n\n return {\n ...category,\n currentAmount,\n averageAmount: getAverage(monthlyAmounts),\n color: CategoryColors[parentGuid],\n icon: CategoryIcon[parentGuid],\n isTransfer: parentGuid === CategoryGuids.TRANSFER,\n monthlyAmounts,\n name,\n subCategories: detailedSubCategories,\n totalAmount: isParent ? totalAmount : 0,\n totalAverageAmount: getAverage(totalMonthlyAmounts),\n totalMonthlyAmounts: isParent ? totalMonthlyAmounts : [],\n }\n}\n/**\n * get the transactions belonging to parent categories\n * @param detailedCategories - detailed categories from the category store\n * @param transactions - sortedTransactions from the transaction store\n */\nexport const getDetailedCategoryTransactions = (\n detailedCategories: DetailedCategory[],\n transactions: Transaction[],\n): DetailedCategoryWithTransactions[] => {\n return detailedCategories.map((category) => {\n const categoryTransactions = transactions.filter(\n (transaction) =>\n transaction.category_guid === category.guid ||\n transaction.top_level_category_guid === category.guid,\n )\n\n return {\n ...category,\n transactions: categoryTransactions,\n }\n })\n}\n\n/**\n * Get the average amount based on the number of months (numMonths) requested\n * @param monthlyAmounts - Monthly amounts to calculate and average from\n * @param numMonths - Number of months to base the average on (DEFAULT: 3)\n */\nconst getAverage = (\n monthlyAmounts: MonthlyAmount[],\n numMonths: number = MONTHLY_AVERAGE_LENGTH,\n): number => {\n const monthsBack = numMonths > history.length ? history.length : numMonths\n\n return Math.ceil(\n Math.max(\n 0,\n monthlyAmounts.slice(-monthsBack).reduce((total, current) => total + current.amount, 0) /\n monthsBack,\n ),\n )\n}\n\n/**\n * Get the last 12 months of amounts for a category\n * @param categoryTotals - Monthly category totals\n */\nconst getMonthlyAmounts = (categoryTotals: MonthlyCategoryTotals[]): MonthlyAmount[] => {\n const monthlyAmounts: MonthlyAmount[] = []\n const today = startOfToday()\n for (let i = 0; i <= MONTHS_OF_HISTORY; i++) {\n const historyDate = startOfMonth(subMonths(today, MONTHS_OF_HISTORY - i))\n const monthlyTotals = categoryTotals.filter(\n (total) => total.year_month === Number(format(historyDate, 'yyyyMM')),\n )\n const totalAmount = monthlyTotals.reduce((acc, curr) => acc + curr.total, 0)\n\n monthlyAmounts.push({\n amount: totalAmount,\n isoDate: format(historyDate, 'yyyy-MM-dd'),\n label: formatDate(historyDate, DATE_FORMATS_INTL.MONTH_YEAR),\n })\n }\n\n return monthlyAmounts\n}\n\nexport const findCategory = (\n categories: Category[],\n categoryGuid: string | undefined,\n): Category | undefined => {\n return categories.find((c) => c.guid === categoryGuid)\n}\n\nexport const findDetailedCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n return detailedCategories.find((dc) => dc.guid === guid)\n}\n\nexport const findDetailedSubCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n const parent = detailedCategories.find((dc) => dc.subCategories.find((sc) => sc.guid === guid))\n if (!parent) return undefined\n\n return parent.subCategories.find((sc) => sc.guid === guid)\n}\n\nexport const findCategoryTotalsByParent = (\n categories: Category[],\n dateRangeTotals: DateRangeCategoryTotals[],\n): CategoryTotal[] => {\n const categoryTotals = [] as CategoryTotal[]\n\n // Iterate over the category data from BE and roll up all categories into parent categories\n // acc is the accumulated category totals of type CategoryTotal that is initialized as an empty []\n // curr is the current DateRangeCategoryTotal\n\n for (const dateRangeTotal of dateRangeTotals) {\n const category = findCategory(categories, dateRangeTotal.category_guid)\n if (!category) continue\n\n const parentGuid = category.parent_guid ?? category.guid\n const parentCategory = findCategory(categories, parentGuid)\n if (!parentCategory) continue\n\n const categoryTotal = {\n amount: dateRangeTotal.total,\n category,\n guid: category.guid,\n subCategoryTotals: [],\n }\n\n const parentCategoryTotal = categoryTotals.find((ct) => ct.guid === parentGuid)\n if (parentCategoryTotal) {\n parentCategoryTotal.amount += dateRangeTotal.total\n parentCategoryTotal.subCategoryTotals.push(categoryTotal)\n } else {\n categoryTotals.push({\n amount: dateRangeTotal.total,\n category: parentCategory,\n guid: parentGuid,\n subCategoryTotals: [categoryTotal],\n })\n }\n }\n\n return categoryTotals\n}\n\nexport const isIncome = (categories: Category[], guid: string) => {\n const category = categories.find((c) => c.guid === guid)\n if (!category) return false\n\n return category.guid === CategoryGuids.INCOME || category.parent_guid === CategoryGuids.INCOME\n}\n"],"mappings":";;;;;;;AA6BA,IAAM,IAAyB,GACzB,IAAoB,IAYb,IAAA,CAA4B,GAAoB,MAA+B;AAC1F,QAAM,IAAgB,EAAK,qBAAqB,EAAS,IAAA;AACzD,SAAO,IAAgB,EAAc,QAAQ,UAAU,GAAG,IAAI,EAAS;AACzE,GASa,IAAA,CACX,GACA,GACA,GACA,MAEO,EACJ,OAAA,CAAQ,MAAa,CAAC,EAAS,WAAW,EAC1C,IAAA,CAAK,MACJ,EACE,GACA,GACA,GACA,GACA,EAAW,OAAA,CAAQ,MAAM,EAAE,gBAAgB,EAAS,IAAI,CAC1D,CACF,GAGS,IAAA,CAAoB,GAAc,MAAiB;AAC9D,QAAM,IAAe,EAAiB,KAAA,CAAM,MAAM,EAAE,SAAS,CAAI;AACjE,SAAK,IAEE,EAAM,QAAQ,WAAW,EAAa,SAAA,KAA6C,KAFhE,EAAM,QAAQ,WAAW,iBAAiB;AAGtE,GAcM,IAAA,CACJ,GACA,GACA,GACA,GACA,IAA4B,CAAC,MACR;AACrB,QAAM,IAAO,EAAS,MAChB,IAAa,EAAS,eAAe,GACrC,IAAW,MAAS,GAEpB,IAAgB,EAAsB,KAAA,CAAM,MAAM,EAAE,kBAAkB,CAAI,GAAG,SAAS,GACtF,IAAiB,EACrB,EAAsB,OAAA,CAAQ,MAAU,EAAM,kBAAkB,CAAI,CACtE,GACM,IAAsB,EAC1B,EAAsB,OAAA,CACnB,MAAU,EAAM,kBAAkB,KAAQ,EAAM,4BAA4B,CAC/E,CACF,GACM,IAAwB,EAAc,IAAA,CAAK,MAC/C,EAAoB,GAAa,GAAM,GAAuB,CAAqB,CACrF,GACM,IAAc,EAAsB,OAAA,CACvC,GAAO,MAAY,IAAQ,EAAQ,eACpC,CACF,GAEM,IAAO,EAAyB,GAAU,CAAI;AAEpD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAA;AAA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X,GACA,MAEO,EAAmB,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI,GAG5C,IAAA,CACX,GACA,MACiC;AACjC,QAAM,IAAS,EAAmB,KAAA,CAAM,MAAO,EAAG,cAAc,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI,CAAC;AAC9F,MAAK;AAEL,WAAO,EAAO,cAAc,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI;AAC3D"}
1
+ {"version":3,"file":"CategoryUtil.es.js","names":[],"sources":["../../../src/core/utils/CategoryUtil.ts"],"sourcesContent":["import { format } from 'date-fns/format'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subMonths } from 'date-fns/subMonths'\n\nimport type { Palette, Theme } from '@mui/material'\n\nimport { CategoryIconList } from '@mxenabled/mxui'\n\nimport {\n CategoryColors,\n CategoryGuids,\n CategoryIcon,\n DATE_FORMATS_INTL,\n formatDate,\n} from '../constants'\n\nimport type {\n Category,\n DateRangeCategoryTotals,\n DetailedCategory,\n DetailedCategoryWithTransactions,\n MonthlyAmount,\n MonthlyCategoryTotals,\n Transaction,\n CategoryCopy,\n CategoryTotal,\n} from '../types'\n\nconst MONTHLY_AVERAGE_LENGTH = 3\nconst MONTHS_OF_HISTORY = 12\n\n/**\n * Resolve the localized display name for a category.\n *\n * Default (MX-supplied) categories arrive from the API with fixed English\n * names, but localized copy for them is delivered via CategoryCopy\n * `default_categories` (keyed by category guid). User-created categories have no\n * localized copy and legitimately fall back to their API name.\n * @param category - The category to resolve a name for\n * @param copy - Category copy containing localized default category names\n */\nexport const getLocalizedCategoryName = (category: Category, copy: CategoryCopy): string => {\n const localizedName = copy.default_categories?.[category.guid]\n return localizedName ? localizedName.replace(/&amp;/g, '&') : category.name\n}\n\n/**\n * Augment categories\n * @param categories - Categories to augment\n * @param monthlyCategoryTotals - Monthly category totals\n * @param currentCategoryTotals - Current month category totals\n * @param copy - Category copy\n */\nexport const augmentCategories = (\n categories: Category[],\n copy: CategoryCopy,\n currentCategoryTotals: DateRangeCategoryTotals[],\n monthlyCategoryTotals: MonthlyCategoryTotals[],\n): DetailedCategory[] => {\n return categories\n .filter((category) => !category.parent_guid)\n .map((category) =>\n getDetailedCategory(\n category,\n copy,\n currentCategoryTotals,\n monthlyCategoryTotals,\n categories.filter((c) => c.parent_guid === category.guid),\n ),\n )\n}\n\nexport const getCategoryColor = (guid: string, theme: Theme) => {\n const categoryInfo = CategoryIconList.find((c) => c.guid === guid)\n if (!categoryInfo) return theme.palette.categories.uncategorized || ''\n\n return theme.palette.categories[categoryInfo.colorName as keyof Palette['categories']] || ''\n}\n\nexport const getCategoryIcon = (guid: string) => {\n return CategoryIconList.find((c) => c.guid === guid)?.icon\n}\n\n/**\n * Get an augmented category with additional details\n * @param category - The category to augment\n * @param copy - Category copy\n * @param currentCategoryTotals - Current month category totals\n * @param monthlyCategoryTotals - Past monthly category totals\n * @param subCategories - Subcategories for the specified category (If applicable)\n */\nconst getDetailedCategory = (\n category: Category,\n copy: CategoryCopy,\n currentCategoryTotals: DateRangeCategoryTotals[],\n monthlyCategoryTotals: MonthlyCategoryTotals[],\n subCategories: Category[] = [],\n): DetailedCategory => {\n const guid = category.guid\n const parentGuid = category.parent_guid || guid\n const isParent = guid === parentGuid\n\n const currentAmount = currentCategoryTotals.find((t) => t.category_guid === guid)?.total || 0\n const monthlyAmounts = getMonthlyAmounts(\n monthlyCategoryTotals.filter((total) => total.category_guid === guid),\n )\n const totalMonthlyAmounts = getMonthlyAmounts(\n monthlyCategoryTotals.filter(\n (total) => total.category_guid === guid || total.top_level_category_guid === guid,\n ),\n )\n const detailedSubCategories = subCategories.map((subCategory) =>\n getDetailedCategory(subCategory, copy, currentCategoryTotals, monthlyCategoryTotals),\n )\n const totalAmount = detailedSubCategories.reduce(\n (total, current) => total + current.currentAmount,\n currentAmount,\n )\n\n const name = getLocalizedCategoryName(category, copy)\n\n return {\n ...category,\n currentAmount,\n averageAmount: getAverage(monthlyAmounts),\n color: CategoryColors[parentGuid],\n icon: CategoryIcon[parentGuid],\n isTransfer: parentGuid === CategoryGuids.TRANSFER,\n monthlyAmounts,\n name,\n subCategories: detailedSubCategories,\n totalAmount: isParent ? totalAmount : 0,\n totalAverageAmount: getAverage(totalMonthlyAmounts),\n totalMonthlyAmounts: isParent ? totalMonthlyAmounts : [],\n }\n}\n/**\n * get the transactions belonging to parent categories\n * @param detailedCategories - detailed categories from the category store\n * @param transactions - sortedTransactions from the transaction store\n */\nexport const getDetailedCategoryTransactions = (\n detailedCategories: DetailedCategory[],\n transactions: Transaction[],\n): DetailedCategoryWithTransactions[] => {\n return detailedCategories.map((category) => {\n const categoryTransactions = transactions.filter(\n (transaction) =>\n transaction.category_guid === category.guid ||\n transaction.top_level_category_guid === category.guid,\n )\n\n return {\n ...category,\n transactions: categoryTransactions,\n }\n })\n}\n\n/**\n * Get the average amount based on the number of months (numMonths) requested\n * @param monthlyAmounts - Monthly amounts to calculate and average from\n * @param numMonths - Number of months to base the average on (DEFAULT: 3)\n */\nconst getAverage = (\n monthlyAmounts: MonthlyAmount[],\n numMonths: number = MONTHLY_AVERAGE_LENGTH,\n): number => {\n const monthsBack = Math.min(numMonths, monthlyAmounts.length)\n\n return Math.ceil(\n Math.max(\n 0,\n monthlyAmounts.slice(-monthsBack).reduce((total, current) => total + current.amount, 0) /\n monthsBack,\n ),\n )\n}\n\n/**\n * Get the last 12 months of amounts for a category\n * @param categoryTotals - Monthly category totals\n */\nconst getMonthlyAmounts = (categoryTotals: MonthlyCategoryTotals[]): MonthlyAmount[] => {\n const monthlyAmounts: MonthlyAmount[] = []\n const today = startOfToday()\n for (let i = 0; i <= MONTHS_OF_HISTORY; i++) {\n const historyDate = startOfMonth(subMonths(today, MONTHS_OF_HISTORY - i))\n const monthlyTotals = categoryTotals.filter(\n (total) => total.year_month === Number(format(historyDate, 'yyyyMM')),\n )\n const totalAmount = monthlyTotals.reduce((acc, curr) => acc + curr.total, 0)\n\n monthlyAmounts.push({\n amount: totalAmount,\n isoDate: format(historyDate, 'yyyy-MM-dd'),\n label: formatDate(historyDate, DATE_FORMATS_INTL.MONTH_YEAR),\n })\n }\n\n return monthlyAmounts\n}\n\nexport const findCategory = (\n categories: Category[],\n categoryGuid: string | undefined,\n): Category | undefined => {\n return categories.find((c) => c.guid === categoryGuid)\n}\n\nexport const findDetailedCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n return detailedCategories.find((dc) => dc.guid === guid)\n}\n\nexport const findDetailedSubCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n const parent = detailedCategories.find((dc) => dc.subCategories.find((sc) => sc.guid === guid))\n if (!parent) return undefined\n\n return parent.subCategories.find((sc) => sc.guid === guid)\n}\n\nexport const findCategoryTotalsByParent = (\n categories: Category[],\n dateRangeTotals: DateRangeCategoryTotals[],\n): CategoryTotal[] => {\n const categoryTotals = [] as CategoryTotal[]\n\n // Iterate over the category data from BE and roll up all categories into parent categories\n // acc is the accumulated category totals of type CategoryTotal that is initialized as an empty []\n // curr is the current DateRangeCategoryTotal\n\n for (const dateRangeTotal of dateRangeTotals) {\n const category = findCategory(categories, dateRangeTotal.category_guid)\n if (!category) continue\n\n const parentGuid = category.parent_guid ?? category.guid\n const parentCategory = findCategory(categories, parentGuid)\n if (!parentCategory) continue\n\n const categoryTotal = {\n amount: dateRangeTotal.total,\n category,\n guid: category.guid,\n subCategoryTotals: [],\n }\n\n const parentCategoryTotal = categoryTotals.find((ct) => ct.guid === parentGuid)\n if (parentCategoryTotal) {\n parentCategoryTotal.amount += dateRangeTotal.total\n parentCategoryTotal.subCategoryTotals.push(categoryTotal)\n } else {\n categoryTotals.push({\n amount: dateRangeTotal.total,\n category: parentCategory,\n guid: parentGuid,\n subCategoryTotals: [categoryTotal],\n })\n }\n }\n\n return categoryTotals\n}\n\nexport const isIncome = (categories: Category[], guid: string) => {\n const category = categories.find((c) => c.guid === guid)\n if (!category) return false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,EAAmB,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI,GAG5C,IAAA,CACX,GACA,MACiC;AACjC,QAAM,IAAS,EAAmB,KAAA,CAAM,MAAO,EAAG,cAAc,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI,CAAC;AAC9F,MAAK;AAEL,WAAO,EAAO,cAAc,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI;AAC3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "9.4.52",
3
+ "version": "9.4.53",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",