@mx-cartographer/experiences 9.4.55 → 9.4.57

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,12 @@
1
+ ## [9.4.57] - 10-06-2026
2
+
3
+ - **FIXED** - Spending transaction list puts a transaction in the same month as the chart when the bank dates it at midnight UTC MEW-4191
4
+ - **CHANGED** - Transaction list date range and date search use the date shown on the row for every viewer timezone MEW-4191
5
+
6
+ ## [9.4.56] - 10-06-2026
7
+
8
+ - **FIXED** - Transactions in the Sub Budget drawer now open the Transaction Details drawer when clicked MEW-4015
9
+
1
10
  ## [9.4.55] - 10-05-2026
2
11
 
3
12
  - **FIXED** - Color contrast in the Transaction Details calendar and Cancel buttons MEW-4123
@@ -6,7 +6,7 @@ import A from "../../../transactions/components/shared/TransactionList.es.js";
6
6
  import E from "../../../transactions/components/shared/TransactionDetails.es.js";
7
7
  import { Header as W } from "./Header.es.js";
8
8
  import { SubBudgetList as H } from "./SubBudgetList.es.js";
9
- import i from "react";
9
+ import c from "react";
10
10
  import { observer as M } from "mobx-react-lite";
11
11
  import e from "@mui/material/Stack";
12
12
  import { Icon as O } from "@mxenabled/mxui";
@@ -14,18 +14,18 @@ import R from "@mui/material/Button";
14
14
  import { jsx as t, jsxs as r } from "react/jsx-runtime";
15
15
  import p from "@mui/material/Tab";
16
16
  import V from "@mui/material/Tabs";
17
- var st = M(({ budget: c }) => {
18
- const { is_mobile_webview: u } = k(), { setAlert: f } = D(), { budgets: o, common: b, transactions: h } = j(), { isDesktop: _, isSmallTablet: T, isTablet: g } = I(), { sortedTransactions: s, sortedTransactionsWithSplits: C, tags: S } = G(), [a, v] = i.useState(0), [l, m] = i.useState(""), n = i.useMemo(() => s.find((d) => d.guid === l), [l, s]), x = (d, B) => {
17
+ var st = M(({ budget: l }) => {
18
+ const { is_mobile_webview: u } = k(), { setAlert: f } = D(), { budgets: o, common: b, transactions: h } = j(), { isDesktop: T, isSmallTablet: _, isTablet: C } = I(), { sortedTransactions: s, sortedTransactionsWithSplits: g, tags: S } = G(), [a, v] = c.useState(0), [m, n] = c.useState(""), i = c.useMemo(() => s.find((d) => d.guid === m), [m, s]), x = (d, B) => {
19
19
  v(B);
20
20
  }, w = () => {
21
- z(C, S), f({
21
+ z(g, S), f({
22
22
  msg: o.alert_csv_downloaded,
23
23
  severity: "success"
24
24
  });
25
- }, y = s.length > 0 && !u && (_ || g && !T);
25
+ }, y = s.length > 0 && !u && (T || C && !_);
26
26
  return /* @__PURE__ */ r(e, {
27
27
  gap: 24,
28
- children: [/* @__PURE__ */ t(W, { budget: c }), /* @__PURE__ */ r(e, { children: [
28
+ children: [/* @__PURE__ */ t(W, { budget: l }), /* @__PURE__ */ r(e, { children: [
29
29
  /* @__PURE__ */ r(V, {
30
30
  onChange: x,
31
31
  sx: { width: "100%" },
@@ -49,15 +49,18 @@ var st = M(({ budget: c }) => {
49
49
  })
50
50
  }), /* @__PURE__ */ t(A, {
51
51
  height: "100%",
52
- onClick: m
52
+ onClick: n
53
53
  })] }),
54
- a === 1 && /* @__PURE__ */ t(H, { budget: c }),
54
+ a === 1 && /* @__PURE__ */ t(H, {
55
+ budget: l,
56
+ onTransactionClick: n
57
+ }),
55
58
  /* @__PURE__ */ t(L, {
56
59
  ariaLabelClose: b.close_aria,
57
- isOpen: !!n,
58
- onClose: () => m(""),
60
+ isOpen: !!i,
61
+ onClose: () => n(""),
59
62
  title: o.details_transaction_drawer,
60
- children: n && /* @__PURE__ */ t(E, { transaction: n })
63
+ children: i && /* @__PURE__ */ t(E, { transaction: i })
61
64
  })
62
65
  ] })]
63
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"BudgetDetails.es.js","names":[],"sources":["../../../../src/budgets/components/budgetdetails/BudgetDetails.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport Tab from '@mui/material/Tab'\nimport Tabs from '@mui/material/Tabs'\n\nimport { Icon } from '@mxenabled/mxui'\n\nimport {\n Drawer,\n useAppConfig,\n useBudgetsStore,\n useGlobalCopyStore,\n useScreenSize,\n useTransactionStore,\n} from '../../../common'\nimport { type DetailedBudget } from '../../../core'\nimport { exportTransactionsToCSV } from '../../../core/utils/TransactionUtils'\n\nimport { TransactionDetails, TransactionList } from '../../../transactions'\n\nimport { Header } from './Header'\nimport { SubBudgetList } from './SubBudgetList'\n\ninterface BudgetDetailsProps {\n budget: DetailedBudget\n}\n\nexport const BudgetDetails: React.FC<BudgetDetailsProps> = observer(({ budget }) => {\n const { is_mobile_webview } = useAppConfig()\n const { setAlert } = useBudgetsStore()\n const { budgets: copy, common: commonCopy, transactions: transactionCopy } = useGlobalCopyStore()\n const { isDesktop, isSmallTablet, isTablet } = useScreenSize()\n const {\n sortedTransactions: transactions,\n sortedTransactionsWithSplits,\n tags,\n } = useTransactionStore()\n\n const [selectedTab, setSelectedTab] = React.useState(0)\n const [transactionGuid, setTransactionGuid] = React.useState('')\n\n const transaction = React.useMemo(\n () => transactions.find((t) => t.guid === transactionGuid),\n [transactionGuid, transactions],\n )\n\n const handleTabChange = (_event: React.SyntheticEvent, newValue: number) => {\n setSelectedTab(newValue)\n }\n\n const handleExportToCsv = () => {\n exportTransactionsToCSV(sortedTransactionsWithSplits, tags)\n setAlert({ msg: copy.alert_csv_downloaded, severity: 'success' })\n }\n\n const shouldShowExportButton =\n transactions.length > 0 && !is_mobile_webview && (isDesktop || (isTablet && !isSmallTablet))\n\n return (\n <Stack gap={24}>\n <Header budget={budget} />\n\n <Stack>\n <Tabs\n onChange={handleTabChange}\n sx={{ width: '100%' }}\n textColor=\"primary\"\n value={selectedTab}\n variant=\"fullWidth\"\n >\n <Tab label={copy.details_transactions_tab} />\n <Tab label={copy.details_subbudgets_tab} />\n </Tabs>\n {selectedTab === 0 && (\n <Stack>\n {shouldShowExportButton && (\n <Stack direction=\"row\" justifyContent=\"right\" mb={-24} mr={8} mt={8} zIndex={1}>\n <Button\n onClick={handleExportToCsv}\n startIcon={<Icon name=\"ios_share\" />}\n variant=\"text\"\n >\n {transactionCopy.export_csv_btn}\n </Button>\n </Stack>\n )}\n <TransactionList height=\"100%\" onClick={setTransactionGuid} />\n </Stack>\n )}\n {selectedTab === 1 && <SubBudgetList budget={budget} />}\n\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={Boolean(transaction)}\n onClose={() => setTransactionGuid('')}\n title={copy.details_transaction_drawer}\n >\n {transaction && <TransactionDetails transaction={transaction} />}\n </Drawer>\n </Stack>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,IAAa,KAA8C,EAAA,CAAU,EAAE,QAAA,EAAA,MAAa;AAClF,QAAM,EAAE,mBAAA,EAAA,IAAsB,EAAa,GACrC,EAAE,UAAA,EAAA,IAAa,EAAgB,GAC/B,EAAE,SAAS,GAAM,QAAQ,GAAY,cAAc,EAAA,IAAoB,EAAmB,GAC1F,EAAE,WAAA,GAAW,eAAA,GAAe,UAAA,EAAA,IAAa,EAAc,GACvD,EACJ,oBAAoB,GACpB,8BAAA,GACA,MAAA,EAAA,IACE,EAAoB,GAElB,CAAC,GAAa,CAAA,IAAkB,EAAM,SAAS,CAAC,GAChD,CAAC,GAAiB,CAAA,IAAsB,EAAM,SAAS,EAAE,GAEzD,IAAc,EAAM,QAAA,MAClB,EAAa,KAAA,CAAM,MAAM,EAAE,SAAS,CAAe,GACzD,CAAC,GAAiB,CAAY,CAChC,GAEM,IAAA,CAAmB,GAA8B,MAAqB;AAC1E,IAAA,EAAe,CAAQ;AAAA,EACzB,GAEM,IAAA,MAA0B;AAC9B,IAAA,EAAwB,GAA8B,CAAI,GAC1D,EAAS;AAAA,MAAE,KAAK,EAAK;AAAA,MAAsB,UAAU;AAAA,IAAU,CAAC;AAAA,EAClE,GAEM,IACJ,EAAa,SAAS,KAAK,CAAC,MAAsB,KAAc,KAAY,CAAC;AAE/E,SAC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,CACF;AAAA;AAEX,CAAC"}
1
+ {"version":3,"file":"BudgetDetails.es.js","names":[],"sources":["../../../../src/budgets/components/budgetdetails/BudgetDetails.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport Tab from '@mui/material/Tab'\nimport Tabs from '@mui/material/Tabs'\n\nimport { Icon } from '@mxenabled/mxui'\n\nimport {\n Drawer,\n useAppConfig,\n useBudgetsStore,\n useGlobalCopyStore,\n useScreenSize,\n useTransactionStore,\n} from '../../../common'\nimport { type DetailedBudget } from '../../../core'\nimport { exportTransactionsToCSV } from '../../../core/utils/TransactionUtils'\n\nimport { TransactionDetails, TransactionList } from '../../../transactions'\n\nimport { Header } from './Header'\nimport { SubBudgetList } from './SubBudgetList'\n\ninterface BudgetDetailsProps {\n budget: DetailedBudget\n}\n\nexport const BudgetDetails: React.FC<BudgetDetailsProps> = observer(({ budget }) => {\n const { is_mobile_webview } = useAppConfig()\n const { setAlert } = useBudgetsStore()\n const { budgets: copy, common: commonCopy, transactions: transactionCopy } = useGlobalCopyStore()\n const { isDesktop, isSmallTablet, isTablet } = useScreenSize()\n const {\n sortedTransactions: transactions,\n sortedTransactionsWithSplits,\n tags,\n } = useTransactionStore()\n\n const [selectedTab, setSelectedTab] = React.useState(0)\n const [transactionGuid, setTransactionGuid] = React.useState('')\n\n const transaction = React.useMemo(\n () => transactions.find((t) => t.guid === transactionGuid),\n [transactionGuid, transactions],\n )\n\n const handleTabChange = (_event: React.SyntheticEvent, newValue: number) => {\n setSelectedTab(newValue)\n }\n\n const handleExportToCsv = () => {\n exportTransactionsToCSV(sortedTransactionsWithSplits, tags)\n setAlert({ msg: copy.alert_csv_downloaded, severity: 'success' })\n }\n\n const shouldShowExportButton =\n transactions.length > 0 && !is_mobile_webview && (isDesktop || (isTablet && !isSmallTablet))\n\n return (\n <Stack gap={24}>\n <Header budget={budget} />\n\n <Stack>\n <Tabs\n onChange={handleTabChange}\n sx={{ width: '100%' }}\n textColor=\"primary\"\n value={selectedTab}\n variant=\"fullWidth\"\n >\n <Tab label={copy.details_transactions_tab} />\n <Tab label={copy.details_subbudgets_tab} />\n </Tabs>\n {selectedTab === 0 && (\n <Stack>\n {shouldShowExportButton && (\n <Stack direction=\"row\" justifyContent=\"right\" mb={-24} mr={8} mt={8} zIndex={1}>\n <Button\n onClick={handleExportToCsv}\n startIcon={<Icon name=\"ios_share\" />}\n variant=\"text\"\n >\n {transactionCopy.export_csv_btn}\n </Button>\n </Stack>\n )}\n <TransactionList height=\"100%\" onClick={setTransactionGuid} />\n </Stack>\n )}\n {selectedTab === 1 && (\n <SubBudgetList budget={budget} onTransactionClick={setTransactionGuid} />\n )}\n\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={Boolean(transaction)}\n onClose={() => setTransactionGuid('')}\n title={copy.details_transaction_drawer}\n >\n {transaction && <TransactionDetails transaction={transaction} />}\n </Drawer>\n </Stack>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,IAAa,KAA8C,EAAA,CAAU,EAAE,QAAA,EAAA,MAAa;AAClF,QAAM,EAAE,mBAAA,EAAA,IAAsB,EAAa,GACrC,EAAE,UAAA,EAAA,IAAa,EAAgB,GAC/B,EAAE,SAAS,GAAM,QAAQ,GAAY,cAAc,EAAA,IAAoB,EAAmB,GAC1F,EAAE,WAAA,GAAW,eAAA,GAAe,UAAA,EAAA,IAAa,EAAc,GACvD,EACJ,oBAAoB,GACpB,8BAAA,GACA,MAAA,EAAA,IACE,EAAoB,GAElB,CAAC,GAAa,CAAA,IAAkB,EAAM,SAAS,CAAC,GAChD,CAAC,GAAiB,CAAA,IAAsB,EAAM,SAAS,EAAE,GAEzD,IAAc,EAAM,QAAA,MAClB,EAAa,KAAA,CAAM,MAAM,EAAE,SAAS,CAAe,GACzD,CAAC,GAAiB,CAAY,CAChC,GAEM,IAAA,CAAmB,GAA8B,MAAqB;AAC1E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B;AAAA,MAAqB,CAAA;AAAA,MAG1E,gBAAA,EAAC,GAAD;AAAA,QACE,gBAAgB,EAAW;AAAA,QAC3B,QAAQ,EAAQ;AAAA,QAChB,SAAA,MAAe,EAAmB,EAAE;AAAA,QACpC,OAAO,EAAK;AAAA,QAEX,UAAA,KAAe,gBAAA,EAAC,GAAD,EAAiC,aAAA,EAAc,CAAA;AAAA,MACzD,CAAA;AAAA,IACH,EAAA,CAAA,CACF;AAAA;AAEX,CAAC"}
@@ -1,7 +1,9 @@
1
- import { default as React } from 'react';
2
1
  import { DetailedBudget } from '../../../core';
3
2
  interface SubBudgetListProps {
4
3
  budget: DetailedBudget;
4
+ onTransactionClick: (guid: string) => void;
5
5
  }
6
- export declare const SubBudgetList: React.FC<SubBudgetListProps>;
6
+ export declare const SubBudgetList: (({ budget, onTransactionClick }: SubBudgetListProps) => import("react/jsx-runtime").JSX.Element) & {
7
+ displayName: string;
8
+ };
7
9
  export {};
@@ -1,44 +1,44 @@
1
- import { buildDynamicCopy as c } from "../../../core/utils/Localization.es.js";
2
- import { useBudgetsStore as O, useGlobalCopyStore as T, useTransactionStore as N } from "../../../common/context/hooks.es.js";
1
+ import { buildDynamicCopy as d } from "../../../core/utils/Localization.es.js";
2
+ import { useBudgetsStore as T, useGlobalCopyStore as N, useTransactionStore as k } from "../../../common/context/hooks.es.js";
3
3
  import b from "../../../common/components/dialog/Dialog.es.js";
4
4
  import w from "../../../common/components/drawer/Drawer.es.js";
5
5
  import F from "../../../transactions/components/shared/TransactionList.es.js";
6
6
  import { BudgetAmount as L } from "../shared/BudgetAmount.es.js";
7
7
  import { Header as P } from "./Header.es.js";
8
- import { SubBudgetZeroState as k } from "../budgetlist/SubBudgetZeroState.es.js";
9
- import { SubBudgetRow as E } from "../budgetlist/SubBudgetRow.es.js";
10
- import { AddSubBudget as j } from "./AddSubBudget.es.js";
8
+ import { SubBudgetZeroState as E } from "../budgetlist/SubBudgetZeroState.es.js";
9
+ import { SubBudgetRow as j } from "../budgetlist/SubBudgetRow.es.js";
10
+ import { AddSubBudget as I } from "./AddSubBudget.es.js";
11
11
  import i from "react";
12
- import { observer as I } from "mobx-react-lite";
13
- import R from "@mui/material/Stack";
14
- import { Text as $ } from "@mxenabled/mxui";
12
+ import { observer as R } from "mobx-react-lite";
13
+ import $ from "@mui/material/Stack";
14
+ import { Text as G } from "@mxenabled/mxui";
15
15
  import { jsx as r, jsxs as s } from "react/jsx-runtime";
16
- import G from "@mui/material/Divider";
17
- import H from "@mui/material/List";
18
- var ae = I(({ budget: n }) => {
19
- const { category: h, subBudgets: u } = n, { budgets: o, common: l } = T(), { deleteBudget: S, selectedSubBudget: e, setAlert: g, setSelectedSubBudget: B, updateBudget: C } = O(), { filter: p, setFilter: y } = N(), [x, m] = i.useState(!1), [v, d] = i.useState(!1), [a, f] = i.useState("");
16
+ import H from "@mui/material/Divider";
17
+ import M from "@mui/material/List";
18
+ var se = R(({ budget: n, onTransactionClick: h }) => {
19
+ const { category: S, subBudgets: u } = n, { budgets: o, common: l } = N(), { deleteBudget: B, selectedSubBudget: e, setAlert: g, setSelectedSubBudget: C, updateBudget: x } = T(), { filter: p, setFilter: y } = k(), [v, m] = i.useState(!1), [A, c] = i.useState(!1), [a, f] = i.useState("");
20
20
  i.useEffect(() => {
21
21
  e && (f(`${e.amount}`), y({
22
22
  ...p,
23
23
  custom: (t) => t.category_guid === e.category_guid
24
24
  }));
25
25
  }, [e]);
26
- const A = async () => {
26
+ const D = async () => {
27
27
  if (e) {
28
- const t = await C({
28
+ const t = await x({
29
29
  ...e,
30
30
  amount: Number(a)
31
31
  });
32
32
  m(!1), t || g({
33
- msg: c(o.error_alert_edit_merchant_budget, e.category.name),
33
+ msg: d(o.error_alert_edit_merchant_budget, e.category.name),
34
34
  severity: "error"
35
35
  });
36
36
  }
37
- }, D = async () => {
37
+ }, O = async () => {
38
38
  if (e) {
39
- const t = await S(e.guid);
40
- d(!1), t ? _() : g({
41
- msg: c(o.error_alert_delete_merchant_budget, e.category.name),
39
+ const t = await B(e.guid);
40
+ c(!1), t ? _() : g({
41
+ msg: d(o.error_alert_delete_merchant_budget, e.category.name),
42
42
  severity: "error"
43
43
  });
44
44
  }
@@ -46,13 +46,13 @@ var ae = I(({ budget: n }) => {
46
46
  y({
47
47
  ...p,
48
48
  custom: (t) => t.category_guid === n.category_guid || t.top_level_category_guid === n.category_guid
49
- }), B(void 0);
49
+ }), C(void 0);
50
50
  };
51
51
  return /* @__PURE__ */ s(i.Fragment, { children: [
52
- /* @__PURE__ */ s(H, {
52
+ /* @__PURE__ */ s(M, {
53
53
  sx: { bgcolor: "background.paper" },
54
- children: [u.length === 0 ? /* @__PURE__ */ r(k, {}) : u.map((t) => /* @__PURE__ */ s(i.Fragment, { children: [/* @__PURE__ */ r(E, { budget: t }), /* @__PURE__ */ r(G, {})] }, t.guid)), /* @__PURE__ */ r(j, {
55
- category: h,
54
+ children: [u.length === 0 ? /* @__PURE__ */ r(E, {}) : u.map((t) => /* @__PURE__ */ s(i.Fragment, { children: [/* @__PURE__ */ r(j, { budget: t }), /* @__PURE__ */ r(H, {})] }, t.guid)), /* @__PURE__ */ r(I, {
55
+ category: S,
56
56
  parentBudget: n
57
57
  })]
58
58
  }),
@@ -61,13 +61,16 @@ var ae = I(({ budget: n }) => {
61
61
  isOpen: !!e,
62
62
  onClose: _,
63
63
  onPrimaryAction: () => m(!0),
64
- onSecondaryAction: () => d(!0),
64
+ onSecondaryAction: () => c(!0),
65
65
  primaryText: o.details_edit_button,
66
66
  secondaryText: o.details_delete_button,
67
67
  title: o.details_title,
68
- children: e && /* @__PURE__ */ s(R, {
68
+ children: e && /* @__PURE__ */ s($, {
69
69
  gap: 24,
70
- children: [/* @__PURE__ */ r(P, { budget: e }), /* @__PURE__ */ r(F, { height: "100%" })]
70
+ children: [/* @__PURE__ */ r(P, { budget: e }), /* @__PURE__ */ r(F, {
71
+ height: "100%",
72
+ onClick: h
73
+ })]
71
74
  })
72
75
  }),
73
76
  e && /* @__PURE__ */ s(i.Fragment, { children: [/* @__PURE__ */ r(b, {
@@ -76,9 +79,9 @@ var ae = I(({ budget: n }) => {
76
79
  title: o.details_edit_title_subbudget
77
80
  },
78
81
  disablePrimaryButton: a === "" || Number(a) < 0 || isNaN(Number(a)),
79
- isOpen: x,
82
+ isOpen: v,
80
83
  onClose: () => m(!1),
81
- onPrimaryAction: A,
84
+ onPrimaryAction: D,
82
85
  primaryText: o.edit_save_button,
83
86
  sx: { "& .MuiStack-root:first-of-type": { pb: 8 } },
84
87
  children: /* @__PURE__ */ r(L, {
@@ -91,21 +94,21 @@ var ae = I(({ budget: n }) => {
91
94
  close_aria: l.close_aria,
92
95
  title: o.delete_title
93
96
  },
94
- isOpen: v,
95
- onClose: () => d(!1),
96
- onPrimaryAction: D,
97
+ isOpen: A,
98
+ onClose: () => c(!1),
99
+ onPrimaryAction: O,
97
100
  primaryColor: "error",
98
101
  primaryText: "Delete",
99
102
  secondaryColor: "inherit",
100
- children: /* @__PURE__ */ r($, {
103
+ children: /* @__PURE__ */ r(G, {
101
104
  variant: "subtitle1",
102
- children: c(o.delete_description, e.category.name)
105
+ children: d(o.delete_description, e.category.name)
103
106
  })
104
107
  })] })
105
108
  ] });
106
109
  });
107
110
  export {
108
- ae as SubBudgetList
111
+ se as SubBudgetList
109
112
  };
110
113
 
111
114
  //# sourceMappingURL=SubBudgetList.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubBudgetList.es.js","names":[],"sources":["../../../../src/budgets/components/budgetdetails/SubBudgetList.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Divider from '@mui/material/Divider'\nimport List from '@mui/material/List'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport {\n Dialog,\n Drawer,\n useBudgetsStore,\n useGlobalCopyStore,\n useTransactionStore,\n} from '../../../common'\nimport { type Budget, type DetailedBudget, type Transaction } from '../../../core'\n\nimport { TransactionList } from '../../../transactions'\n\nimport { SubBudgetZeroState } from '../budgetlist/SubBudgetZeroState'\nimport { SubBudgetRow } from '../budgetlist/SubBudgetRow'\nimport { BudgetAmount } from '../shared/BudgetAmount'\nimport { AddSubBudget } from './AddSubBudget'\nimport { Header } from './Header'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\n\ninterface SubBudgetListProps {\n budget: DetailedBudget\n}\n\nexport const SubBudgetList: React.FC<SubBudgetListProps> = observer(({ budget }) => {\n const { category, subBudgets } = budget\n const { budgets: copy, common: commonCopy } = useGlobalCopyStore()\n const { deleteBudget, selectedSubBudget, setAlert, setSelectedSubBudget, updateBudget } =\n useBudgetsStore()\n const { filter, setFilter } = useTransactionStore()\n\n const [isEditOpen, setIsEditOpen] = React.useState(false)\n const [isDeleteOpen, setIsDeleteOpen] = React.useState(false)\n const [amount, setAmount] = React.useState(``)\n\n React.useEffect(() => {\n if (selectedSubBudget) {\n setAmount(`${selectedSubBudget.amount}`)\n setFilter({\n ...filter,\n custom: (t: Transaction) => t.category_guid === selectedSubBudget.category_guid,\n })\n }\n }, [selectedSubBudget])\n\n const handleUpdateBudget = async () => {\n if (selectedSubBudget) {\n const result = await updateBudget({\n ...selectedSubBudget,\n amount: Number(amount),\n } as Budget)\n setIsEditOpen(false)\n if (!result) {\n setAlert({\n msg: buildDynamicCopy(\n copy.error_alert_edit_merchant_budget,\n selectedSubBudget.category.name,\n ) as string,\n severity: 'error',\n })\n }\n }\n }\n\n const handleDeleteBudget = async () => {\n if (selectedSubBudget) {\n const result = await deleteBudget(selectedSubBudget.guid)\n setIsDeleteOpen(false)\n if (result) {\n handleClose()\n } else {\n setAlert({\n msg: buildDynamicCopy(\n copy.error_alert_delete_merchant_budget,\n selectedSubBudget.category.name,\n ) as string,\n severity: 'error',\n })\n }\n }\n }\n\n const handleClose = () => {\n setFilter({\n ...filter,\n custom: (t: Transaction) =>\n t.category_guid === budget.category_guid ||\n t.top_level_category_guid === budget.category_guid,\n })\n setSelectedSubBudget(undefined)\n }\n\n return (\n <React.Fragment>\n <List sx={{ bgcolor: 'background.paper' }}>\n {subBudgets.length === 0 ? (\n <SubBudgetZeroState />\n ) : (\n subBudgets.map((subBudget) => (\n <React.Fragment key={subBudget.guid}>\n <SubBudgetRow budget={subBudget} />\n <Divider />\n </React.Fragment>\n ))\n )}\n <AddSubBudget category={category} parentBudget={budget} />\n </List>\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={Boolean(selectedSubBudget)}\n onClose={handleClose}\n onPrimaryAction={() => setIsEditOpen(true)}\n onSecondaryAction={() => setIsDeleteOpen(true)}\n primaryText={copy.details_edit_button}\n secondaryText={copy.details_delete_button}\n title={copy.details_title}\n >\n {selectedSubBudget && (\n <Stack gap={24}>\n <Header budget={selectedSubBudget} />\n <TransactionList height=\"100%\" />\n </Stack>\n )}\n </Drawer>\n\n {selectedSubBudget && (\n <React.Fragment>\n <Dialog\n copy={{ close_aria: commonCopy.close_aria, title: copy.details_edit_title_subbudget }}\n disablePrimaryButton={amount === '' || Number(amount) < 0 || isNaN(Number(amount))}\n isOpen={isEditOpen}\n onClose={() => setIsEditOpen(false)}\n onPrimaryAction={handleUpdateBudget}\n primaryText={copy.edit_save_button}\n sx={{\n '& .MuiStack-root:first-of-type': {\n pb: 8,\n },\n }}\n >\n <BudgetAmount\n amount={amount}\n categoryName={selectedSubBudget.category.name}\n onAmountChanged={setAmount}\n />\n </Dialog>\n\n <Dialog\n copy={{ close_aria: commonCopy.close_aria, title: copy.delete_title }}\n isOpen={isDeleteOpen}\n onClose={() => setIsDeleteOpen(false)}\n onPrimaryAction={handleDeleteBudget}\n primaryColor=\"error\"\n primaryText=\"Delete\"\n secondaryColor=\"inherit\"\n >\n <Text variant=\"subtitle1\">\n {buildDynamicCopy(copy.delete_description, selectedSubBudget.category.name) as string}\n </Text>\n </Dialog>\n </React.Fragment>\n )}\n </React.Fragment>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,IAAa,KAA8C,EAAA,CAAU,EAAE,QAAA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AAM,IAAI,KAAK,MAAM,OAAO,CAAM,CAAC;AAAA,MACjF,QAAQ;AAAA,MACR,SAAA,MAAe,EAAc,EAAK;AAAA,MAClC,iBAAiB;AAAA,MACjB,aAAa,EAAK;AAAA,MAClB,IAAI,EACF,kCAAkC,EAChC,IAAI,EACN,EACF;AAAA,MAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,QACU,QAAA;AAAA,QACR,cAAc,EAAkB,SAAS;AAAA,QACzC,iBAAiB;AAAA,MAClB,CAAA;AAAA,IACK,CAAA,GAER,gBAAA,EAAC,GAAD;AAAA,MACE,MAAM;AAAA,QAAE,YAAY,EAAW;AAAA,QAAY,OAAO,EAAK;AAAA,MAAa;AAAA,MACpE,QAAQ;AAAA,MACR,SAAA,MAAe,EAAgB,EAAK;AAAA,MACpC,iBAAiB;AAAA,MACjB,cAAa;AAAA,MACb,aAAY;AAAA,MACZ,gBAAe;AAAA,MAEf,UAAA,gBAAA,EAAC,GAAD;AAAA,QAAM,SAAQ;AAAA,QACX,UAAA,EAAiB,EAAK,oBAAoB,EAAkB,SAAS,IAAI;AAAA,MACtE,CAAA;AAAA,IACA,CAAA,CACM,EAAA,CAAA;AAAA,EAEJ,EAAA,CAAA;AAEpB,CAAC"}
1
+ {"version":3,"file":"SubBudgetList.es.js","names":[],"sources":["../../../../src/budgets/components/budgetdetails/SubBudgetList.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Divider from '@mui/material/Divider'\nimport List from '@mui/material/List'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport {\n Dialog,\n Drawer,\n useBudgetsStore,\n useGlobalCopyStore,\n useTransactionStore,\n} from '../../../common'\nimport { type Budget, type DetailedBudget, type Transaction } from '../../../core'\n\nimport { TransactionList } from '../../../transactions'\n\nimport { SubBudgetZeroState } from '../budgetlist/SubBudgetZeroState'\nimport { SubBudgetRow } from '../budgetlist/SubBudgetRow'\nimport { BudgetAmount } from '../shared/BudgetAmount'\nimport { AddSubBudget } from './AddSubBudget'\nimport { Header } from './Header'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\n\ninterface SubBudgetListProps {\n budget: DetailedBudget\n onTransactionClick: (guid: string) => void\n}\n\nexport const SubBudgetList = observer(({ budget, onTransactionClick }: SubBudgetListProps) => {\n const { category, subBudgets } = budget\n const { budgets: copy, common: commonCopy } = useGlobalCopyStore()\n const { deleteBudget, selectedSubBudget, setAlert, setSelectedSubBudget, updateBudget } =\n useBudgetsStore()\n const { filter, setFilter } = useTransactionStore()\n\n const [isEditOpen, setIsEditOpen] = React.useState(false)\n const [isDeleteOpen, setIsDeleteOpen] = React.useState(false)\n const [amount, setAmount] = React.useState(``)\n\n React.useEffect(() => {\n if (selectedSubBudget) {\n setAmount(`${selectedSubBudget.amount}`)\n setFilter({\n ...filter,\n custom: (t: Transaction) => t.category_guid === selectedSubBudget.category_guid,\n })\n }\n }, [selectedSubBudget])\n\n const handleUpdateBudget = async () => {\n if (selectedSubBudget) {\n const result = await updateBudget({\n ...selectedSubBudget,\n amount: Number(amount),\n } as Budget)\n setIsEditOpen(false)\n if (!result) {\n setAlert({\n msg: buildDynamicCopy(\n copy.error_alert_edit_merchant_budget,\n selectedSubBudget.category.name,\n ) as string,\n severity: 'error',\n })\n }\n }\n }\n\n const handleDeleteBudget = async () => {\n if (selectedSubBudget) {\n const result = await deleteBudget(selectedSubBudget.guid)\n setIsDeleteOpen(false)\n if (result) {\n handleClose()\n } else {\n setAlert({\n msg: buildDynamicCopy(\n copy.error_alert_delete_merchant_budget,\n selectedSubBudget.category.name,\n ) as string,\n severity: 'error',\n })\n }\n }\n }\n\n const handleClose = () => {\n setFilter({\n ...filter,\n custom: (t: Transaction) =>\n t.category_guid === budget.category_guid ||\n t.top_level_category_guid === budget.category_guid,\n })\n setSelectedSubBudget(undefined)\n }\n\n return (\n <React.Fragment>\n <List sx={{ bgcolor: 'background.paper' }}>\n {subBudgets.length === 0 ? (\n <SubBudgetZeroState />\n ) : (\n subBudgets.map((subBudget) => (\n <React.Fragment key={subBudget.guid}>\n <SubBudgetRow budget={subBudget} />\n <Divider />\n </React.Fragment>\n ))\n )}\n <AddSubBudget category={category} parentBudget={budget} />\n </List>\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={Boolean(selectedSubBudget)}\n onClose={handleClose}\n onPrimaryAction={() => setIsEditOpen(true)}\n onSecondaryAction={() => setIsDeleteOpen(true)}\n primaryText={copy.details_edit_button}\n secondaryText={copy.details_delete_button}\n title={copy.details_title}\n >\n {selectedSubBudget && (\n <Stack gap={24}>\n <Header budget={selectedSubBudget} />\n <TransactionList height=\"100%\" onClick={onTransactionClick} />\n </Stack>\n )}\n </Drawer>\n\n {selectedSubBudget && (\n <React.Fragment>\n <Dialog\n copy={{ close_aria: commonCopy.close_aria, title: copy.details_edit_title_subbudget }}\n disablePrimaryButton={amount === '' || Number(amount) < 0 || isNaN(Number(amount))}\n isOpen={isEditOpen}\n onClose={() => setIsEditOpen(false)}\n onPrimaryAction={handleUpdateBudget}\n primaryText={copy.edit_save_button}\n sx={{\n '& .MuiStack-root:first-of-type': {\n pb: 8,\n },\n }}\n >\n <BudgetAmount\n amount={amount}\n categoryName={selectedSubBudget.category.name}\n onAmountChanged={setAmount}\n />\n </Dialog>\n\n <Dialog\n copy={{ close_aria: commonCopy.close_aria, title: copy.delete_title }}\n isOpen={isDeleteOpen}\n onClose={() => setIsDeleteOpen(false)}\n onPrimaryAction={handleDeleteBudget}\n primaryColor=\"error\"\n primaryText=\"Delete\"\n secondaryColor=\"inherit\"\n >\n <Text variant=\"subtitle1\">\n {buildDynamicCopy(copy.delete_description, selectedSubBudget.category.name) as string}\n </Text>\n </Dialog>\n </React.Fragment>\n )}\n </React.Fragment>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,IAAa,KAAgB,EAAA,CAAU,EAAE,QAAA,GAAQ,oBAAA,EAAA,MAA6C;AAC5F,QAAM,EAAE,UAAA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AI,KAAK,MAAM,OAAO,CAAM,CAAC;AAAA,MACjF,QAAQ;AAAA,MACR,SAAA,MAAe,EAAc,EAAK;AAAA,MAClC,iBAAiB;AAAA,MACjB,aAAa,EAAK;AAAA,MAClB,IAAI,EACF,kCAAkC,EAChC,IAAI,EACN,EACF;AAAA,MAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,QACU,QAAA;AAAA,QACR,cAAc,EAAkB,SAAS;AAAA,QACzC,iBAAiB;AAAA,MAClB,CAAA;AAAA,IACK,CAAA,GAER,gBAAA,EAAC,GAAD;AAAA,MACE,MAAM;AAAA,QAAE,YAAY,EAAW;AAAA,QAAY,OAAO,EAAK;AAAA,MAAa;AAAA,MACpE,QAAQ;AAAA,MACR,SAAA,MAAe,EAAgB,EAAK;AAAA,MACpC,iBAAiB;AAAA,MACjB,cAAa;AAAA,MACb,aAAY;AAAA,MACZ,gBAAe;AAAA,MAEf,UAAA,gBAAA,EAAC,GAAD;AAAA,QAAM,SAAQ;AAAA,QACX,UAAA,EAAiB,EAAK,oBAAoB,EAAkB,SAAS,IAAI;AAAA,MACtE,CAAA;AAAA,IACA,CAAA,CACM,EAAA,CAAA;AAAA,EAEJ,EAAA,CAAA;AAEpB,CAAC"}
@@ -1,20 +1,19 @@
1
1
  import { BeatApi as d } from "../api/BeatApi.es.js";
2
2
  import { TransactionApi as g } from "../api/TransactionApi.es.js";
3
- import { upsertByGuid as p } from "../utils/upsertByGuid.es.js";
4
- import { TransactionType as T } from "../types/Transaction.es.js";
5
- import { TABLE_CONST as f } from "../constants/Table.es.js";
6
- import { COLUMN_NAMES as S, DEFAULT_TRANSACTION as w } from "../constants/Transaction.es.js";
7
- import { buildDetailedTransactions as m, flattenTransactionsWithSplits as y, sortAndFilterTransactions as L } from "../utils/TransactionUtils.es.js";
8
- import { endOfMonth as E } from "date-fns/endOfMonth";
9
- import { isBefore as b } from "date-fns/isBefore";
10
- import { startOfMonth as h } from "date-fns/startOfMonth";
11
- import { startOfToday as x } from "date-fns/startOfToday";
12
- import { endOfToday as l } from "date-fns/endOfToday";
3
+ import { upsertByGuid as T } from "../utils/upsertByGuid.es.js";
4
+ import { TransactionType as f } from "../types/Transaction.es.js";
5
+ import { endOfUtcDay as l, startOfUtcDay as h } from "../utils/DateUtil.es.js";
6
+ import { TABLE_CONST as S } from "../constants/Table.es.js";
7
+ import { COLUMN_NAMES as w, DEFAULT_TRANSACTION as y } from "../constants/Transaction.es.js";
8
+ import { buildDetailedTransactions as m, flattenTransactionsWithSplits as L, sortAndFilterTransactions as E } from "../utils/TransactionUtils.es.js";
9
+ import { endOfMonth as b } from "date-fns/endOfMonth";
10
+ import { isBefore as x } from "date-fns/isBefore";
11
+ import { startOfMonth as u } from "date-fns/startOfMonth";
12
+ import { startOfToday as c } from "date-fns/startOfToday";
13
13
  import { subDays as D } from "date-fns/subDays";
14
- import { makeAutoObservable as u, runInAction as o } from "mobx";
15
- import { getUnixTime as c } from "date-fns/getUnixTime";
14
+ import { makeAutoObservable as p, runInAction as o } from "mobx";
16
15
  import { formatISO as A } from "date-fns/formatISO";
17
- var j = class {
16
+ var P = class {
18
17
  globalStore;
19
18
  uiStore;
20
19
  api = new g("/", "");
@@ -35,18 +34,18 @@ var j = class {
35
34
  transactionRulesLoaded = !1;
36
35
  transactionRulesLoading = !1;
37
36
  transactionSplitting = !1;
38
- cachedStartDate = D(x(), 90);
37
+ cachedStartDate = D(c(), 90);
39
38
  filter = {};
40
39
  isLoading = !0;
41
40
  alert = "";
42
- sortColumn = S.DATE;
43
- sortDirection = f.DESC;
41
+ sortColumn = w.DATE;
42
+ sortDirection = S.DESC;
44
43
  constructor(t) {
45
- this.globalStore = t, this.uiStore = new R(), this.api = new g(t.endpoint, t.sessionToken, t.onError), this.beatApi = new d(t.endpoint, t.sessionToken, t.onError), u(this);
44
+ this.globalStore = t, this.uiStore = new R(), this.api = new g(t.endpoint, t.sessionToken, t.onError), this.beatApi = new d(t.endpoint, t.sessionToken, t.onError), p(this);
46
45
  }
47
46
  loadTransactionData = async () => {
48
47
  this.globalStore.accountStore.isAccountDataLoaded || await this.globalStore.accountStore.loadAccountData(), this.globalStore.categoryStore.categoriesLoaded || await this.globalStore.categoryStore.loadCategories(), await Promise.all([
49
- this.loadAssociatedBeats(h(/* @__PURE__ */ new Date())),
48
+ this.loadAssociatedBeats(u(/* @__PURE__ */ new Date())),
50
49
  this.loadTags(),
51
50
  this.loadTaggings(),
52
51
  this.loadTransactionRules(),
@@ -60,10 +59,10 @@ var j = class {
60
59
  return this.isTransactionDataLoaded ? m(this.transactions, this.globalStore.accountStore.visibleAccounts, this.globalStore.categoryStore.categories, this.taggings, this.globalStore.copyStore.copy.categories) : [];
61
60
  }
62
61
  get sortedTransactions() {
63
- return L(this.filter, this.uiStore.expandedSplits, this.sortColumn, this.sortDirection, this.tags, this.detailedTransactions);
62
+ return E(this.filter, this.uiStore.expandedSplits, this.sortColumn, this.sortDirection, this.tags, this.detailedTransactions);
64
63
  }
65
64
  get sortedTransactionsWithSplits() {
66
- return y(this.sortedTransactions, this.detailedTransactions);
65
+ return L(this.sortedTransactions, this.detailedTransactions);
67
66
  }
68
67
  setAssociatedBeats = (t) => {
69
68
  this.associatedBeats = t, this.associatedBeatsLoading = !1, this.associatedBeatsLoaded = !0;
@@ -120,8 +119,8 @@ var j = class {
120
119
  try {
121
120
  const a = await this.api.addTransaction(t);
122
121
  a && o(() => {
123
- this.setTransactions(p(this.transactions, a, !0));
124
- const s = a.transaction_type === T.CREDIT ? a.amount : -a.amount;
122
+ this.setTransactions(T(this.transactions, a, !0));
123
+ const s = a.transaction_type === f.CREDIT ? a.amount : -a.amount;
125
124
  this.globalStore.accountStore.updateAccountBalance(a.account_guid, s);
126
125
  });
127
126
  } catch (a) {
@@ -192,7 +191,7 @@ var j = class {
192
191
  if (!this.transactionsLoading) {
193
192
  this.setIsLoading(!0), this.transactionsLoading = !0;
194
193
  try {
195
- const a = await this.api.getTransactionsByDateRange(c(t), c(l()));
194
+ const a = await this.api.getTransactionsByDateRange(h(t), l(c()));
196
195
  this.setTransactions(a), o(() => {
197
196
  this.cachedStartDate = t;
198
197
  });
@@ -238,7 +237,7 @@ var j = class {
238
237
  }
239
238
  };
240
239
  setFilter = (t) => {
241
- this.filter = t, t.dateRange && b(t.dateRange.start, this.cachedStartDate) && this.loadTransactions(t.dateRange.start);
240
+ this.filter = t, t.dateRange && x(t.dateRange.start, this.cachedStartDate) && this.loadTransactions(t.dateRange.start);
242
241
  };
243
242
  setIsLoading = (t) => this.isLoading = t;
244
243
  splitTransaction = async (t, a) => {
@@ -320,26 +319,26 @@ var j = class {
320
319
  };
321
320
  loadEmbeddedInstanceTransactions = async (t) => {
322
321
  try {
323
- const a = await this.api.getTransactionsByDateRange(c(t), c(l()));
322
+ const a = await this.api.getTransactionsByDateRange(h(t), l(c()));
324
323
  this.cachedStartDate = t, this.transactions = a;
325
324
  } catch (a) {
326
325
  console.error("Error occurred while loading embedded instance transactions:", a), this.globalStore.captureException(a, { store: "TransactionStore" });
327
326
  }
328
327
  };
329
328
  }, R = class {
330
- beginDate = h(/* @__PURE__ */ new Date());
331
- endDate = E(/* @__PURE__ */ new Date());
329
+ beginDate = u(/* @__PURE__ */ new Date());
330
+ endDate = b(/* @__PURE__ */ new Date());
332
331
  expandedSplits = [];
333
332
  height = 550;
334
333
  width = 1e3;
335
334
  shouldDisableDrawerScroll = !1;
336
335
  searchValue = "";
337
336
  selectedAccountGuids = [];
338
- manualTransaction = w;
337
+ manualTransaction = y;
339
338
  isAmountValid = !1;
340
339
  showInsights = !1;
341
340
  constructor() {
342
- u(this);
341
+ p(this);
343
342
  }
344
343
  setDateRange = (t, a) => {
345
344
  this.beginDate = t, this.endDate = a;
@@ -366,7 +365,7 @@ var j = class {
366
365
  };
367
366
  };
368
367
  export {
369
- j as TransactionStore,
368
+ P as TransactionStore,
370
369
  R as UiStore
371
370
  };
372
371
 
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionStore.es.js","names":[],"sources":["../../../src/core/stores/TransactionStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { endOfToday } from 'date-fns/endOfToday'\nimport { formatISO } from 'date-fns/formatISO'\nimport { getUnixTime } from 'date-fns/getUnixTime'\nimport { isBefore } from 'date-fns/isBefore'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subDays } from 'date-fns/subDays'\n\nimport { BeatApi, TransactionApi } from '../api'\nimport { TABLE_CONST } from '../constants/Table'\nimport { COLUMN_NAMES, DEFAULT_TRANSACTION } from '../constants/Transaction'\nimport { TransactionType } from '../types'\nimport type { Beat, Tag, Tagging, Transaction, TransactionRule } from '../types'\nimport {\n buildDetailedTransactions,\n flattenTransactionsWithSplits,\n sortAndFilterTransactions,\n} from '../utils/TransactionUtils'\n\nimport { GlobalStore } from './GlobalStore'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nexport type TransactionFilter = {\n accounts?: string[]\n dateRange?: { start: Date; end: Date }\n custom?: (value: Transaction) => boolean\n searchTerm?: string\n showSplits?: boolean\n}\n\nexport class TransactionStore {\n globalStore: GlobalStore\n uiStore: UiStore\n api = new TransactionApi('/', '')\n beatApi = new BeatApi('/', '')\n\n associatedBeats: Beat[] = []\n associatedBeatsLoaded: boolean = false\n associatedBeatsLoading: boolean = false\n transactions: Transaction[] = []\n transactionsLoaded: boolean = false\n transactionsLoading: boolean = false\n taggings: Tagging[] = []\n taggingsLoaded: boolean = false\n taggingsLoading: boolean = false\n tags: Tag[] = []\n tagsLoaded: boolean = false\n tagsLoading: boolean = false\n transactionRules: TransactionRule[] = []\n transactionRulesLoaded: boolean = false\n transactionRulesLoading: boolean = false\n transactionSplitting: boolean = false\n\n cachedStartDate: Date = subDays(startOfToday(), 90)\n filter: TransactionFilter = {}\n isLoading = true\n\n alert = ''\n\n sortColumn = COLUMN_NAMES.DATE\n sortDirection = TABLE_CONST.DESC\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.uiStore = new UiStore()\n this.api = new TransactionApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n this.beatApi = new BeatApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadTransactionData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n if (!this.globalStore.categoryStore.categoriesLoaded) {\n await this.globalStore.categoryStore.loadCategories()\n }\n await Promise.all([\n this.loadAssociatedBeats(startOfMonth(new Date())),\n this.loadTags(),\n this.loadTaggings(),\n this.loadTransactionRules(),\n // By default loads 90 days of transactions\n this.loadTransactions(this.cachedStartDate),\n ])\n }\n\n get isTransactionDataLoaded(): boolean {\n return (\n this.associatedBeatsLoaded &&\n this.tagsLoaded &&\n this.taggingsLoaded &&\n this.transactionRulesLoaded &&\n this.transactionsLoaded\n )\n }\n\n get detailedTransactions(): Transaction[] {\n return this.isTransactionDataLoaded\n ? buildDetailedTransactions(\n this.transactions,\n this.globalStore.accountStore.visibleAccounts,\n this.globalStore.categoryStore.categories,\n this.taggings,\n this.globalStore.copyStore.copy.categories,\n )\n : []\n }\n\n get sortedTransactions(): Transaction[] {\n return sortAndFilterTransactions(\n this.filter,\n this.uiStore.expandedSplits,\n this.sortColumn,\n this.sortDirection,\n this.tags,\n this.detailedTransactions,\n )\n }\n\n get sortedTransactionsWithSplits(): Transaction[] {\n return flattenTransactionsWithSplits(this.sortedTransactions, this.detailedTransactions)\n }\n\n setAssociatedBeats = (beats: Beat[]) => {\n this.associatedBeats = beats\n this.associatedBeatsLoading = false\n this.associatedBeatsLoaded = true\n }\n\n setTaggings = (taggings: Tagging[]) => {\n this.taggings = taggings\n this.taggingsLoading = false\n this.taggingsLoaded = true\n }\n\n setTags = (tags: Tag[]) => {\n this.tags = tags\n this.tagsLoading = false\n this.tagsLoaded = true\n }\n\n setTransactionRules = (transactionRules: TransactionRule[]) => {\n this.transactionRules = transactionRules\n this.transactionRulesLoading = false\n this.transactionRulesLoaded = true\n }\n\n setTransactions = (transactions: Transaction[]) => {\n this.transactions = transactions\n this.transactionsLoading = false\n this.transactionsLoaded = true\n }\n\n setAlert = (alert: string) => {\n this.alert = alert\n }\n\n addTag = async (name: string) => {\n try {\n await this.api.addTag({ name } as Tag)\n await this.loadTags()\n } catch (error) {\n console.error('Error occurred while adding tag:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n addTagging = async (tagGuid: string, transactionGuid: string) => {\n try {\n await this.api.addTagging({\n tag_guid: tagGuid,\n transaction_guid: transactionGuid,\n } as Tagging)\n } catch (error) {\n console.error('Error occurred while adding tagging:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n addOrUpdateTransactionRule = async (categoryGuid: string, transaction: Transaction) => {\n try {\n const existingRule = this.transactionRules.find(\n (rule: TransactionRule) => rule.guid === transaction.user_transaction_rule_guid,\n ) as TransactionRule | undefined\n\n if (existingRule) {\n await this.api.updateTransactionRule({\n ...existingRule,\n category_guid: categoryGuid,\n description: transaction.description,\n } as TransactionRule)\n } else {\n await this.api.addTransactionRule({\n category_guid: categoryGuid,\n description: transaction.description,\n match_description: transaction.description,\n } as TransactionRule)\n }\n await this.loadTransactionRules()\n } catch (error) {\n console.error('Error occurred while adding/updating transaction rule:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n addTransaction = async (transaction: Transaction) => {\n try {\n const newTransaction = await this.api.addTransaction(transaction)\n\n if (newTransaction) {\n runInAction(() => {\n this.setTransactions(upsertByGuid(this.transactions, newTransaction, true))\n\n // Brokaw may insert the transaction via WebSocket, but it never\n // updates the account balance — that only happens here.\n // See: money-dashboard/src/util/BrokawClient.ts::handleTransactionEvents (search \"setTransactions\")\n // If that handler ever calls updateAccountBalance, remove this call or guard on !existing.\n const balanceChange =\n newTransaction.transaction_type === TransactionType.CREDIT\n ? newTransaction.amount\n : -newTransaction.amount\n\n this.globalStore.accountStore.updateAccountBalance(\n newTransaction.account_guid,\n balanceChange,\n )\n })\n }\n } catch (error) {\n console.error('Error occurred while adding transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n loadAssociatedBeats = async (fromDate?: Date) => {\n if (this.associatedBeatsLoading) return\n\n this.associatedBeatsLoading = true\n const fromDateISO = fromDate ? formatISO(fromDate, { representation: 'date' }) : undefined\n try {\n const beats = await this.beatApi.getBeatsWithAssociatedTransaction(fromDateISO)\n this.setAssociatedBeats(beats)\n } catch (error) {\n console.error('Error occurred while loading associated beats:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n this.setAssociatedBeats([])\n } finally {\n // Clear the in-flight flag even on failure so a later load (e.g. a widget\n // remount) can retry instead of being no-oped by the guard above, which would\n // leave isTransactionDataLoaded false and the list empty until a hard refresh.\n runInAction(() => {\n this.associatedBeatsLoading = false\n })\n }\n }\n\n loadTags = async () => {\n if (this.tagsLoading) return\n\n this.tagsLoading = true\n try {\n const tags = await this.api.getTags()\n this.setTags(tags)\n } catch (error) {\n console.error('Error occurred while loading tags:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n } finally {\n runInAction(() => {\n this.tagsLoading = false\n })\n }\n }\n\n loadTaggings = async () => {\n if (this.taggingsLoading) return\n\n this.taggingsLoading = true\n try {\n const taggings = await this.api.getTaggings()\n this.setTaggings(taggings)\n } catch (error) {\n console.error('Error occurred while loading taggings:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n this.setTaggings([])\n } finally {\n runInAction(() => {\n this.taggingsLoading = false\n })\n }\n }\n\n loadTransactionRules = async () => {\n if (this.transactionRulesLoading) return\n\n this.transactionRulesLoading = true\n try {\n const transactionRules = await this.api.getTransactionRules()\n this.setTransactionRules(transactionRules)\n } catch (error) {\n // Catch so a rejection can't abort the Promise.all in loadTransactionData.\n console.error('Error occurred while loading transaction rules:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n this.setTransactionRules([])\n } finally {\n runInAction(() => {\n this.transactionRulesLoading = false\n })\n }\n }\n\n loadTransactions = async (startDate: Date = this.cachedStartDate) => {\n if (this.transactionsLoading) return\n\n this.setIsLoading(true)\n this.transactionsLoading = true\n\n try {\n const transactions = await this.api.getTransactionsByDateRange(\n getUnixTime(startDate),\n getUnixTime(endOfToday()),\n )\n this.setTransactions(transactions)\n // Advance the cache only after the range is actually loaded, so the invariant\n // \"we hold transactions back to cachedStartDate\" always holds.\n runInAction(() => {\n this.cachedStartDate = startDate\n })\n } catch (error) {\n console.error('Error occurred while loading transactions:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n } finally {\n // See loadAssociatedBeats: clear the flag on failure so retries aren't no-oped.\n runInAction(() => {\n this.transactionsLoading = false\n })\n this.setIsLoading(false)\n }\n }\n\n modifyTransactionByAccountGuid = (guid: string, updates: Partial<Transaction>) => {\n this.transactions = this.transactions.map((txn) =>\n txn.account_guid === guid ? { ...txn, ...updates } : txn,\n )\n }\n\n removeTag = async (tagGuid: string) => {\n try {\n await this.api.removeTag(tagGuid)\n await this.loadTags()\n } catch (error) {\n console.error('Error occurred while removing tag:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n removeTagging = async (taggingGuid: string) => {\n try {\n await this.api.removeTagging(taggingGuid)\n } catch (error) {\n console.error('Error occurred while removing tagging:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n removeTransaction = async (transactionGuid: string) => {\n try {\n await this.api.removeTransaction(transactionGuid)\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transactionGuid)\n\n if (index >= 0) {\n const updatedTransactions = [...this.transactions]\n updatedTransactions.splice(index, 1)\n this.setTransactions(updatedTransactions)\n }\n } catch (error) {\n console.error('Error occurred while removing transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n setFilter = (filter: TransactionFilter) => {\n this.filter = filter\n\n // Only reload if the new start date is prior to the cached start date; end date\n // is always today. loadTransactions advances cachedStartDate on success, so we\n // must not advance it here (a skipped/failed load would leave the list empty).\n if (filter.dateRange && isBefore(filter.dateRange.start, this.cachedStartDate)) {\n this.loadTransactions(filter.dateRange.start)\n }\n }\n\n setIsLoading = (isLoading: boolean) => (this.isLoading = isLoading)\n\n splitTransaction = async (transaction: Transaction, splits: Transaction[]) => {\n if (this.transactionSplitting) return\n this.transactionSplitting = true\n\n try {\n const updatedTransaction = await this.api.updateTransaction(transaction)\n const children = [] as Transaction[]\n\n for (let i = 0; i < splits.length; i++) {\n const child = await this.api.addTransaction(splits[i])\n children.push(child)\n }\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transaction.guid)\n\n if (index >= 0) {\n // Remove old parent and any existing children\n const filtered = this.transactions.filter(\n (t) => t.guid !== transaction.guid && t.parent_guid !== transaction.guid,\n )\n\n // Insert updated parent + new children at original position\n this.setTransactions([\n ...filtered.slice(0, index),\n updatedTransaction,\n ...children,\n ...filtered.slice(index),\n ])\n }\n } catch (error) {\n console.error('Error occurred while splitting transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n throw error\n } finally {\n this.transactionSplitting = false\n }\n }\n\n unSplitTransaction = async (guid: string) => {\n try {\n const children = this.transactions.filter((t) => t.parent_guid === guid)\n\n await this.api.removeTransactionSplit(guid)\n\n // Remove children\n const transactions = [...this.transactions]\n children.forEach((child) => {\n const index = transactions.findIndex((t) => t.guid === child.guid)\n\n if (index >= 0) {\n transactions.splice(index, 1)\n }\n })\n\n // Update parent\n const index = transactions.findIndex((t) => t.guid === guid)\n\n runInAction(() => {\n const transaction = transactions[index]\n if (transaction) {\n transaction.has_been_split = false\n }\n\n if (index >= 0) {\n this.setTransactions([\n ...transactions.slice(0, index),\n transaction,\n ...transactions.slice(index + 1),\n ])\n }\n })\n } catch (error) {\n console.error('Error occurred while unsplitting transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n updateTaggings = async (tagGuids: string[], transactionGuid: string) => {\n try {\n const currentTaggings = this.taggings.filter((t) => t.transaction_guid === transactionGuid)\n\n const currentTagGuids = new Set(currentTaggings.map((t) => t.tag_guid))\n const incomingTagGuids = new Set(tagGuids)\n\n // Add new taggings that don't already exist\n for (const tagGuid of tagGuids) {\n if (!currentTagGuids.has(tagGuid)) {\n await this.addTagging(tagGuid, transactionGuid)\n }\n }\n\n // Remove taggings that are no longer needed\n for (const tagging of currentTaggings) {\n if (!incomingTagGuids.has(tagging.tag_guid)) {\n await this.removeTagging(tagging.guid)\n }\n }\n\n await this.loadTaggings()\n } catch (error) {\n console.error('Error occurred while updating taggings:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n updateTag = async (tag: Tag) => {\n try {\n await this.api.updateTag(tag)\n await this.loadTags()\n } catch (error) {\n console.error('Error occurred while updating tag:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n updateTransaction = async (transaction: Transaction) => {\n try {\n const updatedTransaction = await this.api.updateTransaction(transaction)\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transaction.guid)\n\n if (index >= 0) {\n this.setTransactions([\n ...this.transactions.slice(0, index),\n updatedTransaction,\n ...this.transactions.slice(index + 1),\n ])\n }\n } catch (error) {\n console.error('Error occurred while updating transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n // This is used for loading the transactions list on demand, on clicking the different transactions of the insightful beats.\n loadEmbeddedInstanceTransactions = async (fromDate: Date) => {\n try {\n const transactions = await this.api.getTransactionsByDateRange(\n getUnixTime(fromDate),\n getUnixTime(endOfToday()),\n )\n this.cachedStartDate = fromDate\n this.transactions = transactions\n } catch (error) {\n console.error('Error occurred while loading embedded instance transactions:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n}\n\nexport class UiStore {\n beginDate = startOfMonth(new Date())\n endDate = endOfMonth(new Date())\n\n expandedSplits = [] as string[]\n height = 550\n width = 1000\n shouldDisableDrawerScroll = false\n\n searchValue = ''\n selectedAccountGuids = [] as string[]\n\n manualTransaction: Transaction = DEFAULT_TRANSACTION\n isAmountValid = false\n\n showInsights = false\n\n constructor() {\n makeAutoObservable(this)\n }\n\n setDateRange = (beginDate: Date, endDate: Date) => {\n this.beginDate = beginDate\n this.endDate = endDate\n }\n\n setIsAmountValid = (valid: boolean) => (this.isAmountValid = valid)\n\n setSearchValue = (searchValue: string) => (this.searchValue = searchValue)\n\n setSelectedAccountGuids = (accountGuids: string[]) => (this.selectedAccountGuids = accountGuids)\n\n setShouldDisableDrawerScroll = (shouldDisable: boolean) =>\n (this.shouldDisableDrawerScroll = shouldDisable)\n\n setShowInsights = (showInsights: boolean) => {\n this.showInsights = showInsights\n }\n\n setSize = (height: number, width: number) => {\n this.height = height\n this.width = width\n }\n\n toggleSplit = (guid: string) => {\n const expandedSplits = [...this.expandedSplits]\n const index = this.expandedSplits.findIndex((splitGuid) => splitGuid === guid)\n\n if (index >= 0) {\n expandedSplits.splice(index, 1)\n } else {\n expandedSplits.push(guid)\n }\n\n this.expandedSplits = expandedSplits\n }\n\n clearExpandedSplits = () => {\n if (this.expandedSplits.length === 0) return\n this.expandedSplits = []\n }\n\n updateManualTransaction = (manualTransaction: Transaction) => {\n this.manualTransaction = manualTransaction\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,IAAa,IAAb,MAA8B;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,MAAM,IAAI,EAAe,KAAK,EAAE;AAAA,EAChC,UAAU,IAAI,EAAQ,KAAK,EAAE;AAAA,EAE7B,kBAA0B,CAAC;AAAA,EAC3B,wBAAiC;AAAA,EACjC,yBAAkC;AAAA,EAClC,eAA8B,CAAC;AAAA,EAC/B,qBAA8B;AAAA,EAC9B,sBAA+B;AAAA,EAC/B,WAAsB,CAAC;AAAA,EACvB,iBAA0B;AAAA,EAC1B,kBAA2B;AAAA,EAC3B,OAAc,CAAC;AAAA,EACf,aAAsB;AAAA,EACtB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;AAAA,EACf;AAAA,EAEA,cAAA,CAAe,MAAiB;AAC9B,UAAM,IAAiB,CAAC,GAAG,KAAK,cAAc,GACxC,IAAQ,KAAK,eAAe,UAAA,CAAW,MAAc,MAAc,CAAI;AAE7E,IAAI,KAAS,IACX,EAAe,OAAO,GAAO,CAAC,IAE9B,EAAe,KAAK,CAAI,GAG1B,KAAK,iBAAiB;AAAA,EACxB;AAAA,EAEA,sBAAA,MAA4B;AAC1B,IAAI,KAAK,eAAe,WAAW,MACnC,KAAK,iBAAiB,CAAC;AAAA,EACzB;AAAA,EAEA,0BAAA,CAA2B,MAAmC;AAC5D,SAAK,oBAAoB;AAAA,EAC3B;AACF"}
1
+ {"version":3,"file":"TransactionStore.es.js","names":[],"sources":["../../../src/core/stores/TransactionStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { formatISO } from 'date-fns/formatISO'\nimport { isBefore } from 'date-fns/isBefore'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subDays } from 'date-fns/subDays'\n\nimport { endOfUtcDay, startOfUtcDay } from '../utils/DateUtil'\n\nimport { BeatApi, TransactionApi } from '../api'\nimport { TABLE_CONST } from '../constants/Table'\nimport { COLUMN_NAMES, DEFAULT_TRANSACTION } from '../constants/Transaction'\nimport { TransactionType } from '../types'\nimport type { Beat, Tag, Tagging, Transaction, TransactionRule } from '../types'\nimport {\n buildDetailedTransactions,\n flattenTransactionsWithSplits,\n sortAndFilterTransactions,\n} from '../utils/TransactionUtils'\n\nimport { GlobalStore } from './GlobalStore'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nexport type TransactionFilter = {\n accounts?: string[]\n dateRange?: { start: Date; end: Date }\n custom?: (value: Transaction) => boolean\n searchTerm?: string\n showSplits?: boolean\n}\n\nexport class TransactionStore {\n globalStore: GlobalStore\n uiStore: UiStore\n api = new TransactionApi('/', '')\n beatApi = new BeatApi('/', '')\n\n associatedBeats: Beat[] = []\n associatedBeatsLoaded: boolean = false\n associatedBeatsLoading: boolean = false\n transactions: Transaction[] = []\n transactionsLoaded: boolean = false\n transactionsLoading: boolean = false\n taggings: Tagging[] = []\n taggingsLoaded: boolean = false\n taggingsLoading: boolean = false\n tags: Tag[] = []\n tagsLoaded: boolean = false\n tagsLoading: boolean = false\n transactionRules: TransactionRule[] = []\n transactionRulesLoaded: boolean = false\n transactionRulesLoading: boolean = false\n transactionSplitting: boolean = false\n\n cachedStartDate: Date = subDays(startOfToday(), 90)\n filter: TransactionFilter = {}\n isLoading = true\n\n alert = ''\n\n sortColumn = COLUMN_NAMES.DATE\n sortDirection = TABLE_CONST.DESC\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.uiStore = new UiStore()\n this.api = new TransactionApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n this.beatApi = new BeatApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadTransactionData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n if (!this.globalStore.categoryStore.categoriesLoaded) {\n await this.globalStore.categoryStore.loadCategories()\n }\n await Promise.all([\n this.loadAssociatedBeats(startOfMonth(new Date())),\n this.loadTags(),\n this.loadTaggings(),\n this.loadTransactionRules(),\n // By default loads 90 days of transactions\n this.loadTransactions(this.cachedStartDate),\n ])\n }\n\n get isTransactionDataLoaded(): boolean {\n return (\n this.associatedBeatsLoaded &&\n this.tagsLoaded &&\n this.taggingsLoaded &&\n this.transactionRulesLoaded &&\n this.transactionsLoaded\n )\n }\n\n get detailedTransactions(): Transaction[] {\n return this.isTransactionDataLoaded\n ? buildDetailedTransactions(\n this.transactions,\n this.globalStore.accountStore.visibleAccounts,\n this.globalStore.categoryStore.categories,\n this.taggings,\n this.globalStore.copyStore.copy.categories,\n )\n : []\n }\n\n get sortedTransactions(): Transaction[] {\n return sortAndFilterTransactions(\n this.filter,\n this.uiStore.expandedSplits,\n this.sortColumn,\n this.sortDirection,\n this.tags,\n this.detailedTransactions,\n )\n }\n\n get sortedTransactionsWithSplits(): Transaction[] {\n return flattenTransactionsWithSplits(this.sortedTransactions, this.detailedTransactions)\n }\n\n setAssociatedBeats = (beats: Beat[]) => {\n this.associatedBeats = beats\n this.associatedBeatsLoading = false\n this.associatedBeatsLoaded = true\n }\n\n setTaggings = (taggings: Tagging[]) => {\n this.taggings = taggings\n this.taggingsLoading = false\n this.taggingsLoaded = true\n }\n\n setTags = (tags: Tag[]) => {\n this.tags = tags\n this.tagsLoading = false\n this.tagsLoaded = true\n }\n\n setTransactionRules = (transactionRules: TransactionRule[]) => {\n this.transactionRules = transactionRules\n this.transactionRulesLoading = false\n this.transactionRulesLoaded = true\n }\n\n setTransactions = (transactions: Transaction[]) => {\n this.transactions = transactions\n this.transactionsLoading = false\n this.transactionsLoaded = true\n }\n\n setAlert = (alert: string) => {\n this.alert = alert\n }\n\n addTag = async (name: string) => {\n try {\n await this.api.addTag({ name } as Tag)\n await this.loadTags()\n } catch (error) {\n console.error('Error occurred while adding tag:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n addTagging = async (tagGuid: string, transactionGuid: string) => {\n try {\n await this.api.addTagging({\n tag_guid: tagGuid,\n transaction_guid: transactionGuid,\n } as Tagging)\n } catch (error) {\n console.error('Error occurred while adding tagging:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n addOrUpdateTransactionRule = async (categoryGuid: string, transaction: Transaction) => {\n try {\n const existingRule = this.transactionRules.find(\n (rule: TransactionRule) => rule.guid === transaction.user_transaction_rule_guid,\n ) as TransactionRule | undefined\n\n if (existingRule) {\n await this.api.updateTransactionRule({\n ...existingRule,\n category_guid: categoryGuid,\n description: transaction.description,\n } as TransactionRule)\n } else {\n await this.api.addTransactionRule({\n category_guid: categoryGuid,\n description: transaction.description,\n match_description: transaction.description,\n } as TransactionRule)\n }\n await this.loadTransactionRules()\n } catch (error) {\n console.error('Error occurred while adding/updating transaction rule:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n addTransaction = async (transaction: Transaction) => {\n try {\n const newTransaction = await this.api.addTransaction(transaction)\n\n if (newTransaction) {\n runInAction(() => {\n this.setTransactions(upsertByGuid(this.transactions, newTransaction, true))\n\n // Brokaw may insert the transaction via WebSocket, but it never\n // updates the account balance — that only happens here.\n // See: money-dashboard/src/util/BrokawClient.ts::handleTransactionEvents (search \"setTransactions\")\n // If that handler ever calls updateAccountBalance, remove this call or guard on !existing.\n const balanceChange =\n newTransaction.transaction_type === TransactionType.CREDIT\n ? newTransaction.amount\n : -newTransaction.amount\n\n this.globalStore.accountStore.updateAccountBalance(\n newTransaction.account_guid,\n balanceChange,\n )\n })\n }\n } catch (error) {\n console.error('Error occurred while adding transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n loadAssociatedBeats = async (fromDate?: Date) => {\n if (this.associatedBeatsLoading) return\n\n this.associatedBeatsLoading = true\n const fromDateISO = fromDate ? formatISO(fromDate, { representation: 'date' }) : undefined\n try {\n const beats = await this.beatApi.getBeatsWithAssociatedTransaction(fromDateISO)\n this.setAssociatedBeats(beats)\n } catch (error) {\n console.error('Error occurred while loading associated beats:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n this.setAssociatedBeats([])\n } finally {\n // Clear the in-flight flag even on failure so a later load (e.g. a widget\n // remount) can retry instead of being no-oped by the guard above, which would\n // leave isTransactionDataLoaded false and the list empty until a hard refresh.\n runInAction(() => {\n this.associatedBeatsLoading = false\n })\n }\n }\n\n loadTags = async () => {\n if (this.tagsLoading) return\n\n this.tagsLoading = true\n try {\n const tags = await this.api.getTags()\n this.setTags(tags)\n } catch (error) {\n console.error('Error occurred while loading tags:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n } finally {\n runInAction(() => {\n this.tagsLoading = false\n })\n }\n }\n\n loadTaggings = async () => {\n if (this.taggingsLoading) return\n\n this.taggingsLoading = true\n try {\n const taggings = await this.api.getTaggings()\n this.setTaggings(taggings)\n } catch (error) {\n console.error('Error occurred while loading taggings:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n this.setTaggings([])\n } finally {\n runInAction(() => {\n this.taggingsLoading = false\n })\n }\n }\n\n loadTransactionRules = async () => {\n if (this.transactionRulesLoading) return\n\n this.transactionRulesLoading = true\n try {\n const transactionRules = await this.api.getTransactionRules()\n this.setTransactionRules(transactionRules)\n } catch (error) {\n // Catch so a rejection can't abort the Promise.all in loadTransactionData.\n console.error('Error occurred while loading transaction rules:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n this.setTransactionRules([])\n } finally {\n runInAction(() => {\n this.transactionRulesLoading = false\n })\n }\n }\n\n loadTransactions = async (startDate: Date = this.cachedStartDate) => {\n if (this.transactionsLoading) return\n\n this.setIsLoading(true)\n this.transactionsLoading = true\n\n try {\n const transactions = await this.api.getTransactionsByDateRange(\n startOfUtcDay(startDate),\n endOfUtcDay(startOfToday()),\n )\n this.setTransactions(transactions)\n // Advance the cache only after the range is actually loaded, so the invariant\n // \"we hold transactions back to cachedStartDate\" always holds.\n runInAction(() => {\n this.cachedStartDate = startDate\n })\n } catch (error) {\n console.error('Error occurred while loading transactions:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n } finally {\n // See loadAssociatedBeats: clear the flag on failure so retries aren't no-oped.\n runInAction(() => {\n this.transactionsLoading = false\n })\n this.setIsLoading(false)\n }\n }\n\n modifyTransactionByAccountGuid = (guid: string, updates: Partial<Transaction>) => {\n this.transactions = this.transactions.map((txn) =>\n txn.account_guid === guid ? { ...txn, ...updates } : txn,\n )\n }\n\n removeTag = async (tagGuid: string) => {\n try {\n await this.api.removeTag(tagGuid)\n await this.loadTags()\n } catch (error) {\n console.error('Error occurred while removing tag:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n removeTagging = async (taggingGuid: string) => {\n try {\n await this.api.removeTagging(taggingGuid)\n } catch (error) {\n console.error('Error occurred while removing tagging:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n removeTransaction = async (transactionGuid: string) => {\n try {\n await this.api.removeTransaction(transactionGuid)\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transactionGuid)\n\n if (index >= 0) {\n const updatedTransactions = [...this.transactions]\n updatedTransactions.splice(index, 1)\n this.setTransactions(updatedTransactions)\n }\n } catch (error) {\n console.error('Error occurred while removing transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n setFilter = (filter: TransactionFilter) => {\n this.filter = filter\n\n // Only reload if the new start date is prior to the cached start date; end date\n // is always today. loadTransactions advances cachedStartDate on success, so we\n // must not advance it here (a skipped/failed load would leave the list empty).\n if (filter.dateRange && isBefore(filter.dateRange.start, this.cachedStartDate)) {\n this.loadTransactions(filter.dateRange.start)\n }\n }\n\n setIsLoading = (isLoading: boolean) => (this.isLoading = isLoading)\n\n splitTransaction = async (transaction: Transaction, splits: Transaction[]) => {\n if (this.transactionSplitting) return\n this.transactionSplitting = true\n\n try {\n const updatedTransaction = await this.api.updateTransaction(transaction)\n const children = [] as Transaction[]\n\n for (let i = 0; i < splits.length; i++) {\n const child = await this.api.addTransaction(splits[i])\n children.push(child)\n }\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transaction.guid)\n\n if (index >= 0) {\n // Remove old parent and any existing children\n const filtered = this.transactions.filter(\n (t) => t.guid !== transaction.guid && t.parent_guid !== transaction.guid,\n )\n\n // Insert updated parent + new children at original position\n this.setTransactions([\n ...filtered.slice(0, index),\n updatedTransaction,\n ...children,\n ...filtered.slice(index),\n ])\n }\n } catch (error) {\n console.error('Error occurred while splitting transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n throw error\n } finally {\n this.transactionSplitting = false\n }\n }\n\n unSplitTransaction = async (guid: string) => {\n try {\n const children = this.transactions.filter((t) => t.parent_guid === guid)\n\n await this.api.removeTransactionSplit(guid)\n\n // Remove children\n const transactions = [...this.transactions]\n children.forEach((child) => {\n const index = transactions.findIndex((t) => t.guid === child.guid)\n\n if (index >= 0) {\n transactions.splice(index, 1)\n }\n })\n\n // Update parent\n const index = transactions.findIndex((t) => t.guid === guid)\n\n runInAction(() => {\n const transaction = transactions[index]\n if (transaction) {\n transaction.has_been_split = false\n }\n\n if (index >= 0) {\n this.setTransactions([\n ...transactions.slice(0, index),\n transaction,\n ...transactions.slice(index + 1),\n ])\n }\n })\n } catch (error) {\n console.error('Error occurred while unsplitting transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n updateTaggings = async (tagGuids: string[], transactionGuid: string) => {\n try {\n const currentTaggings = this.taggings.filter((t) => t.transaction_guid === transactionGuid)\n\n const currentTagGuids = new Set(currentTaggings.map((t) => t.tag_guid))\n const incomingTagGuids = new Set(tagGuids)\n\n // Add new taggings that don't already exist\n for (const tagGuid of tagGuids) {\n if (!currentTagGuids.has(tagGuid)) {\n await this.addTagging(tagGuid, transactionGuid)\n }\n }\n\n // Remove taggings that are no longer needed\n for (const tagging of currentTaggings) {\n if (!incomingTagGuids.has(tagging.tag_guid)) {\n await this.removeTagging(tagging.guid)\n }\n }\n\n await this.loadTaggings()\n } catch (error) {\n console.error('Error occurred while updating taggings:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n updateTag = async (tag: Tag) => {\n try {\n await this.api.updateTag(tag)\n await this.loadTags()\n } catch (error) {\n console.error('Error occurred while updating tag:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n updateTransaction = async (transaction: Transaction) => {\n try {\n const updatedTransaction = await this.api.updateTransaction(transaction)\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transaction.guid)\n\n if (index >= 0) {\n this.setTransactions([\n ...this.transactions.slice(0, index),\n updatedTransaction,\n ...this.transactions.slice(index + 1),\n ])\n }\n } catch (error) {\n console.error('Error occurred while updating transaction:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n\n // This is used for loading the transactions list on demand, on clicking the different transactions of the insightful beats.\n loadEmbeddedInstanceTransactions = async (fromDate: Date) => {\n try {\n const transactions = await this.api.getTransactionsByDateRange(\n startOfUtcDay(fromDate),\n endOfUtcDay(startOfToday()),\n )\n this.cachedStartDate = fromDate\n this.transactions = transactions\n } catch (error) {\n console.error('Error occurred while loading embedded instance transactions:', error)\n this.globalStore.captureException(error, { store: 'TransactionStore' })\n }\n }\n}\n\nexport class UiStore {\n beginDate = startOfMonth(new Date())\n endDate = endOfMonth(new Date())\n\n expandedSplits = [] as string[]\n height = 550\n width = 1000\n shouldDisableDrawerScroll = false\n\n searchValue = ''\n selectedAccountGuids = [] as string[]\n\n manualTransaction: Transaction = DEFAULT_TRANSACTION\n isAmountValid = false\n\n showInsights = false\n\n constructor() {\n makeAutoObservable(this)\n }\n\n setDateRange = (beginDate: Date, endDate: Date) => {\n this.beginDate = beginDate\n this.endDate = endDate\n }\n\n setIsAmountValid = (valid: boolean) => (this.isAmountValid = valid)\n\n setSearchValue = (searchValue: string) => (this.searchValue = searchValue)\n\n setSelectedAccountGuids = (accountGuids: string[]) => (this.selectedAccountGuids = accountGuids)\n\n setShouldDisableDrawerScroll = (shouldDisable: boolean) =>\n (this.shouldDisableDrawerScroll = shouldDisable)\n\n setShowInsights = (showInsights: boolean) => {\n this.showInsights = showInsights\n }\n\n setSize = (height: number, width: number) => {\n this.height = height\n this.width = width\n }\n\n toggleSplit = (guid: string) => {\n const expandedSplits = [...this.expandedSplits]\n const index = this.expandedSplits.findIndex((splitGuid) => splitGuid === guid)\n\n if (index >= 0) {\n expandedSplits.splice(index, 1)\n } else {\n expandedSplits.push(guid)\n }\n\n this.expandedSplits = expandedSplits\n }\n\n clearExpandedSplits = () => {\n if (this.expandedSplits.length === 0) return\n this.expandedSplits = []\n }\n\n updateManualTransaction =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AEf,cAAc;AACZ,IAAA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,eAAA,CAAgB,GAAiB,MAAkB;AACjD,SAAK,YAAY,GACjB,KAAK,UAAU;AAAA,EACjB;AAAA,EAEA,mBAAA,CAAoB,MAAoB,KAAK,gBAAgB;AAAA,EAE7D,iBAAA,CAAkB,MAAyB,KAAK,cAAc;AAAA,EAE9D,0BAAA,CAA2B,MAA4B,KAAK,uBAAuB;AAAA,EAEnF,+BAAA,CAAgC,MAC7B,KAAK,4BAA4B;AAAA,EAEpC,kBAAA,CAAmB,MAA0B;AAC3C,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,UAAA,CAAW,GAAgB,MAAkB;AAC3C,SAAK,SAAS,GACd,KAAK,QAAQ;AAAA,EACf;AAAA,EAEA,cAAA,CAAe,MAAiB;AAC9B,UAAM,IAAiB,CAAC,GAAG,KAAK,cAAc,GACxC,IAAQ,KAAK,eAAe,UAAA,CAAW,MAAc,MAAc,CAAI;AAE7E,IAAI,KAAS,IACX,EAAe,OAAO,GAAO,CAAC,IAE9B,EAAe,KAAK,CAAI,GAG1B,KAAK,iBAAiB;AAAA,EACxB;AAAA,EAEA,sBAAA,MAA4B;AAC1B,IAAI,KAAK,eAAe,WAAW,MACnC,KAAK,iBAAiB,CAAC;AAAA,EACzB;AAAA,EAEA,0BAAA,CAA2B,MAAmC;AAC5D,SAAK,oBAAoB;AAAA,EAC3B;AACF"}
@@ -9,6 +9,8 @@ export declare const getNextBiQuarterlyDate: (date: Date) => Date;
9
9
  export declare const getNextYearlyDate: (date: Date) => Date;
10
10
  export declare const fromUnixUTC: (utcTime: number) => Date;
11
11
  export declare const toUnixUTC: (date: Date) => number;
12
+ export declare const startOfUtcDay: (date: Date) => number;
13
+ export declare const endOfUtcDay: (date: Date) => number;
12
14
  export declare const fromUnixToDayOfWeekAndDate: (date: number) => string;
13
15
  export declare const fromUnixUTCToDayOfWeekAndDate: (date: number) => string;
14
16
  export declare const fromTimestampToMonthYear: (timestamp?: number) => string;
@@ -1,37 +1,37 @@
1
- import { DATE_FORMATS_INTL as g, formatDate as x } from "../constants/DateFormats.es.js";
1
+ import { DATE_FORMATS_INTL as s, formatDate as T } from "../constants/DateFormats.es.js";
2
2
  import { addMonths as i } from "date-fns/addMonths";
3
3
  import { endOfMonth as h } from "date-fns/endOfMonth";
4
4
  import { isBefore as n } from "date-fns/isBefore";
5
5
  import { startOfToday as a } from "date-fns/startOfToday";
6
6
  import { addYears as M } from "date-fns/addYears";
7
- import { addQuarters as s } from "date-fns/addQuarters";
7
+ import { addQuarters as g } from "date-fns/addQuarters";
8
8
  import { addWeeks as y } from "date-fns/addWeeks";
9
- import { getDay as d } from "date-fns/getDay";
10
- import { nextDay as v } from "date-fns/nextDay";
9
+ import { getDay as v } from "date-fns/getDay";
10
+ import { nextDay as U } from "date-fns/nextDay";
11
11
  import { setDate as u } from "date-fns/setDate";
12
- import { fromUnixTime as T } from "date-fns/fromUnixTime";
12
+ import { fromUnixTime as x } from "date-fns/fromUnixTime";
13
13
  var B = (t) => {
14
- const e = d(t);
15
- let r = v(t, e);
14
+ const e = v(t);
15
+ let r = U(t, e);
16
16
  for (; n(r, a()); ) r = y(r, 1);
17
17
  return r;
18
18
  }, H = (t) => {
19
19
  let e = t;
20
20
  for (; n(e, a()); ) e = y(e, 2);
21
21
  return e;
22
- }, p = (t, e) => {
23
- const r = a(), [o, m] = [t, e].sort((f, l) => f - l), D = (f, l) => l >= 28 ? h(f) : u(f, l);
22
+ }, c = (t, e) => {
23
+ const r = a(), [o, l] = [t, e].sort((m, f) => m - f), D = (m, f) => f >= 28 ? h(m) : u(m, f);
24
24
  return [
25
25
  D(r, o),
26
- D(r, m),
26
+ D(r, l),
27
27
  D(i(r, 1), o),
28
- D(i(r, 1), m),
28
+ D(i(r, 1), l),
29
29
  D(i(r, 2), o),
30
- D(i(r, 2), m)
30
+ D(i(r, 2), l)
31
31
  ];
32
32
  }, Q = (t, e) => {
33
- const r = a(), o = p(t, e);
34
- return o.find((m) => !n(m, r)) ?? o[o.length - 1];
33
+ const r = a(), o = c(t, e);
34
+ return o.find((l) => !n(l, r)) ?? o[o.length - 1];
35
35
  }, K = (t) => {
36
36
  let e = u(a(), t.getDate());
37
37
  for (; n(e, a()); ) e = i(e, 1);
@@ -41,22 +41,23 @@ var B = (t) => {
41
41
  for (; n(e, a()); ) e = i(e, 2);
42
42
  return e;
43
43
  }, S = (t) => {
44
- let e = s(t, 1);
45
- for (; n(e, a()); ) e = s(e, 1);
44
+ let e = g(t, 1);
45
+ for (; n(e, a()); ) e = g(e, 1);
46
46
  return e;
47
47
  }, I = (t) => {
48
48
  let e = t;
49
- for (; n(e, a()); ) e = s(e, 2);
49
+ for (; n(e, a()); ) e = g(e, 2);
50
50
  return e;
51
- }, L = (t) => M(t, 1), c = (t) => {
52
- const e = T(t);
51
+ }, L = (t) => M(t, 1), p = (t) => {
52
+ const e = x(t);
53
53
  return new Date(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate());
54
- }, b = (t) => Math.floor(Date.UTC(t.getFullYear(), t.getMonth(), t.getDate(), t.getHours(), t.getMinutes(), t.getSeconds()) / 1e3), j = (t) => x(T(t), g.DAY_OF_WEEK_MONTH_DAY), q = (t) => x(c(t), g.DAY_OF_WEEK_MONTH_DAY), z = (t) => t ? x(T(t), g.MONTH_YEAR) : "";
54
+ }, b = (t) => Math.floor(Date.UTC(t.getFullYear(), t.getMonth(), t.getDate(), t.getHours(), t.getMinutes(), t.getSeconds()) / 1e3), j = (t) => Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()) / 1e3, q = (t) => Date.UTC(t.getFullYear(), t.getMonth(), t.getDate(), 23, 59, 59) / 1e3, z = (t) => T(x(t), s.DAY_OF_WEEK_MONTH_DAY), G = (t) => T(p(t), s.DAY_OF_WEEK_MONTH_DAY), J = (t) => t ? T(x(t), s.MONTH_YEAR) : "";
55
55
  export {
56
- z as fromTimestampToMonthYear,
57
- j as fromUnixToDayOfWeekAndDate,
58
- c as fromUnixUTC,
59
- q as fromUnixUTCToDayOfWeekAndDate,
56
+ q as endOfUtcDay,
57
+ J as fromTimestampToMonthYear,
58
+ z as fromUnixToDayOfWeekAndDate,
59
+ p as fromUnixUTC,
60
+ G as fromUnixUTCToDayOfWeekAndDate,
60
61
  R as getNextBiMonthlyDate,
61
62
  I as getNextBiQuarterlyDate,
62
63
  H as getNextBiWeeklyDate,
@@ -65,7 +66,8 @@ export {
65
66
  Q as getNextTwiceMonthlyDate,
66
67
  B as getNextWeeklyDate,
67
68
  L as getNextYearlyDate,
68
- p as getTwiceMonthlyDates,
69
+ c as getTwiceMonthlyDates,
70
+ j as startOfUtcDay,
69
71
  b as toUnixUTC
70
72
  };
71
73
 
@@ -1 +1 @@
1
- {"version":3,"file":"DateUtil.es.js","names":[],"sources":["../../../src/core/utils/DateUtil.ts"],"sourcesContent":["import { addMonths } from 'date-fns/addMonths'\nimport { addQuarters } from 'date-fns/addQuarters'\nimport { addWeeks } from 'date-fns/addWeeks'\nimport { addYears } from 'date-fns/addYears'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { getDay } from 'date-fns/getDay'\nimport { isBefore } from 'date-fns/isBefore'\nimport { nextDay } from 'date-fns/nextDay'\nimport { setDate } from 'date-fns/setDate'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { fromUnixTime } from 'date-fns/fromUnixTime'\nimport { type Day } from 'date-fns'\n\nimport { DATE_FORMATS_INTL, formatDate } from '../constants'\n\nexport const getNextWeeklyDate = (date: Date): Date => {\n const dayOfWeek = getDay(date)\n let nextDate = nextDay(date, dayOfWeek as Day)\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addWeeks(nextDate, 1)\n }\n return nextDate\n}\n\nexport const getNextBiWeeklyDate = (date: Date): Date => {\n let nextDate = date\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addWeeks(nextDate, 2)\n }\n return nextDate\n}\n\nexport const getTwiceMonthlyDates = (day1: number, day2: number): Date[] => {\n const today = startOfToday()\n const [firstDay, secondDay] = [day1, day2].sort((a, b) => a - b)\n const makeDateForDay = (month: Date, day: number) =>\n day >= 28 ? endOfMonth(month) : setDate(month, day)\n\n return [\n makeDateForDay(today, firstDay),\n makeDateForDay(today, secondDay),\n makeDateForDay(addMonths(today, 1), firstDay),\n makeDateForDay(addMonths(today, 1), secondDay),\n makeDateForDay(addMonths(today, 2), firstDay),\n makeDateForDay(addMonths(today, 2), secondDay),\n ]\n}\n\nexport const getNextTwiceMonthlyDate = (day1: number, day2: number): Date => {\n const today = startOfToday()\n const candidates = getTwiceMonthlyDates(day1, day2)\n return candidates.find((c) => !isBefore(c, today)) ?? candidates[candidates.length - 1]\n}\n\nexport const getNextMonthlyDate = (date: Date): Date => {\n let nextDate = setDate(startOfToday(), date.getDate())\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addMonths(nextDate, 1)\n }\n return nextDate\n}\n\nexport const getNextBiMonthlyDate = (date: Date): Date => {\n let nextDate = date\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addMonths(nextDate, 2)\n }\n return nextDate\n}\n\nexport const getNextQuarterlyDate = (date: Date): Date => {\n let nextDate = addQuarters(date, 1)\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addQuarters(nextDate, 1)\n }\n return nextDate\n}\n\nexport const getNextBiQuarterlyDate = (date: Date): Date => {\n let nextDate = date\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addQuarters(nextDate, 2)\n }\n return nextDate\n}\n\nexport const getNextYearlyDate = (date: Date): Date => {\n return addYears(date, 1)\n}\n\nexport const fromUnixUTC = (utcTime: number) => {\n const date = fromUnixTime(utcTime)\n return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())\n}\n\n// Inverse of fromUnixUTC: emits unix seconds for the Date's wall-clock time read\n// at UTC, so a local-midnight boundary serializes to UTC midnight instead of\n// being shifted by the viewer's timezone offset.\nexport const toUnixUTC = (date: Date) =>\n Math.floor(\n Date.UTC(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n ) / 1000,\n )\n\nexport const fromUnixToDayOfWeekAndDate = (date: number) =>\n formatDate(fromUnixTime(date), DATE_FORMATS_INTL.DAY_OF_WEEK_MONTH_DAY)\n\n// UTC variant for post dates, which are absolute calendar dates that must not\n// shift across the day boundary when localized.\nexport const fromUnixUTCToDayOfWeekAndDate = (date: number) =>\n formatDate(fromUnixUTC(date), DATE_FORMATS_INTL.DAY_OF_WEEK_MONTH_DAY)\n\nexport const fromTimestampToMonthYear = (timestamp?: number) =>\n timestamp ? formatDate(fromUnixTime(timestamp), DATE_FORMATS_INTL.MONTH_YEAR) : ''\n"],"mappings":";;;;;;;;;;;;AAeA,IAAa,IAAA,CAAqB,MAAqB;AACrD,QAAM,IAAY,EAAO,CAAI;AAC7B,MAAI,IAAW,EAAQ,GAAM,CAAgB;AAC7C,SAAO,EAAS,GAAU,EAAa,CAAC,IACtC,CAAA,IAAW,EAAS,GAAU,CAAC;AAEjC,SAAO;AACT,GAEa,IAAA,CAAuB,MAAqB;AACvD,MAAI,IAAW;AACf,SAAO,EAAS,GAAU,EAAa,CAAC,IACtC,CAAA,IAAW,EAAS,GAAU,CAAC;AAEjC,SAAO;AACT,GAEa,IAAA,CAAwB,GAAc,MAAyB;AAC1E,QAAM,IAAQ,EAAa,GACrB,CAAC,GAAU,CAAA,IAAa,CAAC,GAAM,CAAI,EAAE,KAAA,CAAM,GAAG,MAAM,IAAI,CAAC,GACzD,IAAA,CAAkB,GAAa,MACnC,KAAO,KAAK,EAAW,CAAK,IAAI,EAAQ,GAAO,CAAG;AAEpD,SAAO;AAAA,IACL,EAAe,GAAO,CAAQ;AAAA,IAC9B,EAAe,GAAO,CAAS;AAAA,IAC/B,EAAe,EAAU,GAAO,CAAC,GAAG,CAAQ;AAAA,IAC5C,EAAe,EAAU,GAAO,CAAC,GAAG,CAAS;AAAA,IAC7C,EAAe,EAAU,GAAO,CAAC,GAAG,CAAQ;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EAAa,CAAI,GAAG,EAAkB,qBAAqB,GAI3D,IAAA,CAAiC,MAC5C,EAAW,EAAY,CAAI,GAAG,EAAkB,qBAAqB,GAE1D,IAAA,CAA4B,MACvC,IAAY,EAAW,EAAa,CAAS,GAAG,EAAkB,UAAU,IAAI"}
1
+ {"version":3,"file":"DateUtil.es.js","names":[],"sources":["../../../src/core/utils/DateUtil.ts"],"sourcesContent":["import { addMonths } from 'date-fns/addMonths'\nimport { addQuarters } from 'date-fns/addQuarters'\nimport { addWeeks } from 'date-fns/addWeeks'\nimport { addYears } from 'date-fns/addYears'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { getDay } from 'date-fns/getDay'\nimport { isBefore } from 'date-fns/isBefore'\nimport { nextDay } from 'date-fns/nextDay'\nimport { setDate } from 'date-fns/setDate'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { fromUnixTime } from 'date-fns/fromUnixTime'\nimport { type Day } from 'date-fns'\n\nimport { DATE_FORMATS_INTL, formatDate } from '../constants'\n\nexport const getNextWeeklyDate = (date: Date): Date => {\n const dayOfWeek = getDay(date)\n let nextDate = nextDay(date, dayOfWeek as Day)\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addWeeks(nextDate, 1)\n }\n return nextDate\n}\n\nexport const getNextBiWeeklyDate = (date: Date): Date => {\n let nextDate = date\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addWeeks(nextDate, 2)\n }\n return nextDate\n}\n\nexport const getTwiceMonthlyDates = (day1: number, day2: number): Date[] => {\n const today = startOfToday()\n const [firstDay, secondDay] = [day1, day2].sort((a, b) => a - b)\n const makeDateForDay = (month: Date, day: number) =>\n day >= 28 ? endOfMonth(month) : setDate(month, day)\n\n return [\n makeDateForDay(today, firstDay),\n makeDateForDay(today, secondDay),\n makeDateForDay(addMonths(today, 1), firstDay),\n makeDateForDay(addMonths(today, 1), secondDay),\n makeDateForDay(addMonths(today, 2), firstDay),\n makeDateForDay(addMonths(today, 2), secondDay),\n ]\n}\n\nexport const getNextTwiceMonthlyDate = (day1: number, day2: number): Date => {\n const today = startOfToday()\n const candidates = getTwiceMonthlyDates(day1, day2)\n return candidates.find((c) => !isBefore(c, today)) ?? candidates[candidates.length - 1]\n}\n\nexport const getNextMonthlyDate = (date: Date): Date => {\n let nextDate = setDate(startOfToday(), date.getDate())\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addMonths(nextDate, 1)\n }\n return nextDate\n}\n\nexport const getNextBiMonthlyDate = (date: Date): Date => {\n let nextDate = date\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addMonths(nextDate, 2)\n }\n return nextDate\n}\n\nexport const getNextQuarterlyDate = (date: Date): Date => {\n let nextDate = addQuarters(date, 1)\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addQuarters(nextDate, 1)\n }\n return nextDate\n}\n\nexport const getNextBiQuarterlyDate = (date: Date): Date => {\n let nextDate = date\n while (isBefore(nextDate, startOfToday())) {\n nextDate = addQuarters(nextDate, 2)\n }\n return nextDate\n}\n\nexport const getNextYearlyDate = (date: Date): Date => {\n return addYears(date, 1)\n}\n\nexport const fromUnixUTC = (utcTime: number) => {\n const date = fromUnixTime(utcTime)\n return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())\n}\n\n// Inverse of fromUnixUTC: emits unix seconds for the Date's wall-clock time read\n// at UTC, so a local-midnight boundary serializes to UTC midnight instead of\n// being shifted by the viewer's timezone offset.\nexport const toUnixUTC = (date: Date) =>\n Math.floor(\n Date.UTC(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n ) / 1000,\n )\n\n// Unix-second bounds of the Date's calendar day read as a UTC day. Ignores the\n// wall-clock time, so a DST zone whose local midnight does not exist (startOfDay\n// returns 01:00) still yields the UTC-midnight bound. (MEW-4191)\nexport const startOfUtcDay = (date: Date) =>\n Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) / 1000\n\nexport const endOfUtcDay = (date: Date) =>\n Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59) / 1000\n\nexport const fromUnixToDayOfWeekAndDate = (date: number) =>\n formatDate(fromUnixTime(date), DATE_FORMATS_INTL.DAY_OF_WEEK_MONTH_DAY)\n\n// UTC variant for post dates, which are absolute calendar dates that must not\n// shift across the day boundary when localized.\nexport const fromUnixUTCToDayOfWeekAndDate = (date: number) =>\n formatDate(fromUnixUTC(date), DATE_FORMATS_INTL.DAY_OF_WEEK_MONTH_DAY)\n\nexport const fromTimestampToMonthYear = (timestamp?: number) =>\n timestamp ? formatDate(fromUnixTime(timestamp), DATE_FORMATS_INTL.MONTH_YEAR) : ''\n"],"mappings":";;;;;;;;;;;;AAeA,IAAa,IAAA,CAAqB,MAAqB;AACrD,QAAM,IAAY,EAAO,CAAI;AAC7B,MAAI,IAAW,EAAQ,GAAM,CAAgB;AAC7C,SAAO,EAAS,GAAU,EAAa,CAAC,IACtC,CAAA,IAAW,EAAS,GAAU,CAAC;AAEjC,SAAO;AACT,GAEa,IAAA,CAAuB,MAAqB;AACvD,MAAI,IAAW;AACf,SAAO,EAAS,GAAU,EAAa,CAAC,IACtC,CAAA,IAAW,EAAS,GAAU,CAAC;AAEjC,SAAO;AACT,GAEa,IAAA,CAAwB,GAAc,MAAyB;AAC1E,QAAM,IAAQ,EAAa,GACrB,CAAC,GAAU,CAAA,IAAa,CAAC,GAAM,CAAI,EAAE,KAAA,CAAM,GAAG,MAAM,IAAI,CAAC,GACzD,IAAA,CAAkB,GAAa,MACnC,KAAO,KAAK,EAAW,CAAK,IAAI,EAAQ,GAAO,CAAG;AAEpD,SAAO;AAAA,IACL,EAAe,GAAO,CAAQ;AAAA,IAC9B,EAAe,GAAO,CAAS;AAAA,IAC/B,EAAe,EAAU,GAAO,CAAC,GAAG,CAAQ;AAAA,IAC5C,EAAe,EAAU,GAAO,CAAC,GAAG,CAAS;AAAA,IAC7C,EAAe,EAAU,GAAO,CAAC,GAAG,CAAQ;AAAA,IAC5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K,YAAY,GAAG,EAAK,SAAS,GAAG,EAAK,QAAQ,CAAC,IAAI,KAErD,IAAA,CAAe,MAC1B,KAAK,IAAI,EAAK,YAAY,GAAG,EAAK,SAAS,GAAG,EAAK,QAAQ,GAAG,IAAI,IAAI,EAAE,IAAI,KAEjE,IAAA,CAA8B,MACzC,EAAW,EAAa,CAAI,GAAG,EAAkB,qBAAqB,GAI3D,IAAA,CAAiC,MAC5C,EAAW,EAAY,CAAI,GAAG,EAAkB,qBAAqB,GAE1D,IAAA,CAA4B,MACvC,IAAY,EAAW,EAAa,CAAS,GAAG,EAAkB,UAAU,IAAI"}
@@ -1,22 +1,20 @@
1
- import { CategoryGuidToName as y, CategoryGuids as h } from "../constants/Category.es.js";
1
+ import { CategoryGuidToName as y, CategoryGuids as T } from "../constants/Category.es.js";
2
2
  import { DATE_FORMATS_INTL as m, formatDate as f } from "../constants/DateFormats.es.js";
3
3
  import { TransactionStatus as C, TransactionType as v } from "../types/Transaction.es.js";
4
4
  import { getLocalizedCategoryName as A } from "./CategoryUtil.es.js";
5
- import { formatCurrency as E } from "./NumberFormatting.es.js";
6
- import { fromUnixUTC as S } from "./DateUtil.es.js";
7
- import { TABLE_CONST as b } from "../constants/Table.es.js";
5
+ import { formatCurrency as O } from "./NumberFormatting.es.js";
6
+ import { endOfUtcDay as D, fromUnixUTC as h, startOfUtcDay as E } from "./DateUtil.es.js";
7
+ import { TABLE_CONST as S } from "../constants/Table.es.js";
8
8
  import { COLUMN_NAMES as _ } from "../constants/Transaction.es.js";
9
- import { format as O } from "date-fns/format";
10
- import { startOfMonth as D } from "date-fns/startOfMonth";
11
- import { startOfToday as N } from "date-fns/startOfToday";
12
- import { endOfToday as M } from "date-fns/endOfToday";
13
- import { fromUnixTime as U } from "date-fns/fromUnixTime";
14
- import { getUnixTime as T } from "date-fns/getUnixTime";
15
- var te = (t) => t.top_level_category_guid === h.TRANSFER, re = (t, r, o, d = [], i) => {
9
+ import { format as b } from "date-fns/format";
10
+ import { startOfMonth as N } from "date-fns/startOfMonth";
11
+ import { startOfToday as M } from "date-fns/startOfToday";
12
+ import { endOfToday as U } from "date-fns/endOfToday";
13
+ var X = (t) => t.top_level_category_guid === T.TRANSFER, ee = (t, r, n, d = [], i) => {
16
14
  const c = r.reduce((e, s) => ({
17
15
  ...e,
18
16
  [s.guid]: s
19
- }), {}), n = o.reduce((e, s) => ({
17
+ }), {}), o = n.reduce((e, s) => ({
20
18
  ...e,
21
19
  [s.guid]: s
22
20
  }), {}), a = d.reduce((e, s) => {
@@ -32,7 +30,7 @@ var te = (t) => t.top_level_category_guid === h.TRANSFER, re = (t, r, o, d = [],
32
30
  };
33
31
  }, {});
34
32
  return t.map((e) => {
35
- const s = c[e.account_guid], u = e.category_guid ? n[e.category_guid] : null, g = a[e.guid] ?? [];
33
+ const s = c[e.account_guid], u = e.category_guid ? o[e.category_guid] : null, g = a[e.guid] ?? [];
36
34
  return {
37
35
  ...e,
38
36
  account: s?.user_name || "Unknown",
@@ -40,78 +38,78 @@ var te = (t) => t.top_level_category_guid === h.TRANSFER, re = (t, r, o, d = [],
40
38
  accountIsHidden: s?.is_hidden,
41
39
  category: u ? A(u, i) : "Uncategorized",
42
40
  institutionName: s?.institution?.name || s?.institutionName || void 0,
43
- isIncome: e.top_level_category_guid === h.INCOME,
41
+ isIncome: e.top_level_category_guid === T.INCOME,
44
42
  isPending: e.feed_status === C.PENDING,
45
43
  number: s?.account_number || "",
46
44
  payee: e.description,
47
45
  tags: g
48
46
  };
49
47
  });
50
- }, L = "uncategorized", oe = (t, r, o, d, i, c) => {
51
- const n = R(t, i, c), a = I(n, o, d);
48
+ }, L = "uncategorized", te = (t, r, n, d, i, c) => {
49
+ const o = R(t, i, c), a = I(o, n, d);
52
50
  return r.forEach((e) => {
53
51
  const s = a.findIndex((g) => g.guid === e), u = c.filter((g) => g.parent_guid === e);
54
52
  a.splice(s + 1, 0, ...u);
55
53
  }), a;
56
- }, R = (t, r, o) => {
54
+ }, R = (t, r, n) => {
57
55
  const { accounts: d = [], dateRange: i = {
58
- start: D(N()),
59
- end: M()
60
- }, custom: c = () => !0, searchTerm: n = "", showSplits: a = !1 } = t;
61
- return o.filter((e) => a ? !e.has_been_split : !e.parent_guid).filter((e) => !!d.find((s) => s === e.account_guid)).filter((e) => e.date >= T(i.start) && e.date <= T(i.end)).filter(c).filter((e) => {
62
- if (n === L && e.has_been_split) return !1;
63
- if (/^spl/i.test(n) && (e.has_been_split || e.parent_guid)) return !0;
64
- const s = e.tags.some((g) => p(n, r.find((l) => l.guid === g)?.name)), u = U(e.date);
65
- return p(n, e.payee) || p(n, e.feed_description) || p(n, e.category) || p(n, f(u, m.MONTH)) || p(n, f(u, m.DAY)) || p(n, f(u, m.FULL_MONTH_DAY)) || p(n, f(u, m.MONTH_DAY_YEAR)) || p(n, O(u, "do")) || p(n, e.account) || p(n, E(e.amount, "0,0.00")) || p(n, e.memo) || s;
56
+ start: N(M()),
57
+ end: U()
58
+ }, custom: c = () => !0, searchTerm: o = "", showSplits: a = !1 } = t;
59
+ return n.filter((e) => a ? !e.has_been_split : !e.parent_guid).filter((e) => !!d.find((s) => s === e.account_guid)).filter((e) => e.date >= E(i.start) && e.date <= D(i.end)).filter(c).filter((e) => {
60
+ if (o === L && e.has_been_split) return !1;
61
+ if (/^spl/i.test(o) && (e.has_been_split || e.parent_guid)) return !0;
62
+ const s = e.tags.some((g) => p(o, r.find((l) => l.guid === g)?.name)), u = h(e.date);
63
+ return p(o, e.payee) || p(o, e.feed_description) || p(o, e.category) || p(o, f(u, m.MONTH)) || p(o, f(u, m.DAY)) || p(o, f(u, m.FULL_MONTH_DAY)) || p(o, f(u, m.MONTH_DAY_YEAR)) || p(o, b(u, "do")) || p(o, e.account) || p(o, O(e.amount, "0,0.00")) || p(o, e.memo) || s;
66
64
  });
67
- }, I = (t, r, o) => [...t].sort((d, i) => {
68
- const c = r, n = (d[c] || "") > (i[c] || "");
69
- let a = n ? -1 : 1, e = n ? 1 : -1;
70
- return (r === _.DATE || r === _.AMOUNT) && (a = n ? 1 : -1, e = n ? -1 : 1), o === b.ASC ? a : e;
65
+ }, I = (t, r, n) => [...t].sort((d, i) => {
66
+ const c = r, o = (d[c] || "") > (i[c] || "");
67
+ let a = o ? -1 : 1, e = o ? 1 : -1;
68
+ return (r === _.DATE || r === _.AMOUNT) && (a = o ? 1 : -1, e = o ? -1 : 1), n === S.ASC ? a : e;
71
69
  }), p = (t, r) => {
72
- const o = t.toLowerCase().split(" "), d = r?.toString().toLowerCase() ?? "";
73
- return o.every((i) => d.indexOf(i) > -1);
70
+ const n = t.toLowerCase().split(" "), d = r?.toString().toLowerCase() ?? "";
71
+ return n.every((i) => d.indexOf(i) > -1);
74
72
  };
75
73
  function w(t) {
76
74
  return new Set(t.filter((r) => r.parent_guid !== void 0).map((r) => r.parent_guid));
77
75
  }
78
76
  function j(t) {
79
- return t.reduce((r, o) => (o.parent_guid && (r[o.parent_guid] || (r[o.parent_guid] = []), r[o.parent_guid].push(o)), r), {});
77
+ return t.reduce((r, n) => (n.parent_guid && (r[n.parent_guid] || (r[n.parent_guid] = []), r[n.parent_guid].push(n)), r), {});
80
78
  }
81
- function ne(t, r) {
82
- const o = w(r), d = j(r), i = /* @__PURE__ */ new Set(), c = [];
83
- for (const n of t) o.has(n.guid) ? (d[n.guid] ?? []).slice().sort((a, e) => Math.abs(e.amount) - Math.abs(a.amount)).forEach((a) => {
79
+ function re(t, r) {
80
+ const n = w(r), d = j(r), i = /* @__PURE__ */ new Set(), c = [];
81
+ for (const o of t) n.has(o.guid) ? (d[o.guid] ?? []).slice().sort((a, e) => Math.abs(e.amount) - Math.abs(a.amount)).forEach((a) => {
84
82
  i.has(a.guid) || (c.push(a), i.add(a.guid));
85
- }) : i.has(n.guid) || (c.push(n), i.add(n.guid));
83
+ }) : i.has(o.guid) || (c.push(o), i.add(o.guid));
86
84
  return c;
87
85
  }
88
- var ie = (t, r) => {
89
- const o = x(G(t, r)), d = new Blob([o], { type: "text/csv;charset=utf-8;" }), i = document.createElement("a");
86
+ var ne = (t, r) => {
87
+ const n = F(G(t, r)), d = new Blob([n], { type: "text/csv;charset=utf-8;" }), i = document.createElement("a");
90
88
  i.href = URL.createObjectURL(d), i.setAttribute("download", "transactions.csv"), document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(i.href);
91
- }, G = (t, r) => t.map((o) => ({
92
- Date: f(S(o.date), m.YEAR_MONTH_DAY),
93
- Description: F(o),
94
- "Original Description": o.feed_description,
95
- Amount: `${o.amount}`,
96
- Type: o.transaction_type === v.CREDIT ? "Credit" : "Debit",
97
- "Parent Category": y[o.top_level_category_guid || ""],
98
- Category: o.category,
99
- Account: o.account,
100
- Tags: B(o, r),
101
- Memo: o.memo,
102
- Pending: o.isPending ? "TRUE" : "FALSE"
103
- })), P = (t) => t ? /[,"\n\r]/.test(t) ? `"${t.replace(/"/g, '""')}"` : t : "", x = (t) => t.length === 0 ? "" : Object.keys(t[0]).join(",").concat(`\r
89
+ }, G = (t, r) => t.map((n) => ({
90
+ Date: f(h(n.date), m.YEAR_MONTH_DAY),
91
+ Description: B(n),
92
+ "Original Description": n.feed_description,
93
+ Amount: `${n.amount}`,
94
+ Type: n.transaction_type === v.CREDIT ? "Credit" : "Debit",
95
+ "Parent Category": y[n.top_level_category_guid || ""],
96
+ Category: n.category,
97
+ Account: n.account,
98
+ Tags: Y(n, r),
99
+ Memo: n.memo,
100
+ Pending: n.isPending ? "TRUE" : "FALSE"
101
+ })), P = (t) => t ? /[,"\n\r]/.test(t) ? `"${t.replace(/"/g, '""')}"` : t : "", F = (t) => t.length === 0 ? "" : Object.keys(t[0]).join(",").concat(`\r
104
102
  `) + t.map((r) => Object.values(r).map(P).join(",")).join(`\r
105
- `), F = (t) => {
103
+ `), B = (t) => {
106
104
  let r = t.parent_guid ? "Split: " : "";
107
105
  return r += t.is_hidden ? "(Excluded) " : "", r += t.description, r;
108
- }, B = (t, r) => t.tags.map((o) => r.filter((d) => d.guid === o)[0]?.name ?? "").join(" ");
106
+ }, Y = (t, r) => t.tags.map((n) => r.filter((d) => d.guid === n)[0]?.name ?? "").join(" ");
109
107
  export {
110
- re as buildDetailedTransactions,
111
- ie as exportTransactionsToCSV,
112
- ne as flattenTransactionsWithSplits,
113
- te as isTransferTransaction,
114
- oe as sortAndFilterTransactions
108
+ ee as buildDetailedTransactions,
109
+ ne as exportTransactionsToCSV,
110
+ re as flattenTransactionsWithSplits,
111
+ X as isTransferTransaction,
112
+ te as sortAndFilterTransactions
115
113
  };
116
114
 
117
115
  //# sourceMappingURL=TransactionUtils.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionUtils.es.js","names":[],"sources":["../../../src/core/utils/TransactionUtils.ts"],"sourcesContent":["import { endOfToday } from 'date-fns/endOfToday'\nimport { format } from 'date-fns/format'\nimport { fromUnixTime } from 'date-fns/fromUnixTime'\nimport { getUnixTime } from 'date-fns/getUnixTime'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\n\nimport { TABLE_CONST } from '../constants/Table'\nimport {\n CategoryGuids,\n CategoryGuidToName,\n DATE_FORMATS_INTL,\n formatDate,\n ORDINAL_DATE_FORMAT,\n} from '../constants'\nimport { COLUMN_NAMES } from '../constants/Transaction'\nimport { TransactionStatus, TransactionType } from '../types'\nimport type { Category, CategoryCopy, DetailedAccount, Tag, Tagging, Transaction } from '../types'\n\nimport { type TransactionFilter } from '../stores/TransactionStore'\n\nimport { getLocalizedCategoryName } from './CategoryUtil'\nimport { fromUnixUTC } from './DateUtil'\nimport { formatCurrency } from './NumberFormatting'\n\ninterface AccountsMap {\n [key: string]: DetailedAccount\n}\n\n// True for account-to-account transfers (top-level Transfer category). Used to\n// swap the payee/description for the institution name in the transaction detail\n// header, the table Payee column, and the mobile list.\nexport const isTransferTransaction = (\n transaction: Pick<Transaction, 'top_level_category_guid'>,\n): boolean => transaction.top_level_category_guid === CategoryGuids.TRANSFER\n\ninterface CategoriesMap {\n [key: string]: Category\n}\n\ninterface TaggingsMap {\n [key: string]: string[]\n}\n\nexport const buildDetailedTransactions = (\n transactions: Transaction[],\n accounts: DetailedAccount[],\n categories: Category[],\n taggings: Tagging[] = [],\n categoryCopy: CategoryCopy,\n) => {\n const accountsMap = accounts.reduce((acc: AccountsMap, account: DetailedAccount) => {\n return { ...acc, [account.guid]: account }\n }, {})\n\n const categoriesMap = categories.reduce((acc: CategoriesMap, category: Category) => {\n return { ...acc, [category.guid]: category }\n }, {})\n\n const taggingsMap = taggings.reduce((acc: TaggingsMap, tagging: Tagging) => {\n const { transaction_guid, tag_guid } = tagging\n\n if (!acc[transaction_guid]) {\n return {\n ...acc,\n [transaction_guid]: [tag_guid],\n }\n }\n const tags = [...acc[transaction_guid], tag_guid] as string[]\n\n return {\n ...acc,\n [transaction_guid]: tags,\n }\n }, {})\n\n return transactions.map((transaction: Transaction) => {\n const account = accountsMap[transaction.account_guid]\n const category = transaction.category_guid ? categoriesMap[transaction.category_guid] : null\n const tags = taggingsMap[transaction.guid] ?? []\n\n return {\n ...transaction,\n account: account?.user_name || 'Unknown',\n accountIsClosed: account?.is_closed,\n accountIsHidden: account?.is_hidden,\n category: category ? getLocalizedCategoryName(category, categoryCopy) : 'Uncategorized',\n institutionName: account?.institution?.name || account?.institutionName || undefined,\n isIncome: transaction.top_level_category_guid === CategoryGuids.INCOME,\n isPending: transaction.feed_status === TransactionStatus.PENDING,\n number: account?.account_number || '',\n payee: transaction.description,\n tags,\n }\n })\n}\n\nconst UNCATEGORIZED_TERM = 'uncategorized'\n\nexport const sortAndFilterTransactions = (\n filter: TransactionFilter,\n expandedSplits: string[],\n sortColumn: string,\n sortDirection: string,\n tags: Tag[],\n transactions: Transaction[],\n) => {\n const filteredTransactions = filterTransactions(filter, tags, transactions)\n\n const sortedTransactions = sortTransactions(filteredTransactions, sortColumn, sortDirection)\n\n expandedSplits.forEach((guid) => {\n const index = sortedTransactions.findIndex((t) => t.guid === guid)\n const children = transactions.filter((t) => t.parent_guid === guid)\n sortedTransactions.splice(index + 1, 0, ...children)\n })\n return sortedTransactions\n}\n\nconst filterTransactions = (\n filter: TransactionFilter,\n tags: Tag[],\n transactions: Transaction[],\n) => {\n const {\n accounts = [],\n dateRange = { start: startOfMonth(startOfToday()), end: endOfToday() },\n custom = () => true,\n searchTerm: searchFilter = '',\n showSplits = false,\n } = filter\n\n return (\n transactions\n // Filters out parent of split transactions when showSplits is true and filters out split\n // transaction children when showSplits is false\n .filter((t) => (showSplits ? !t.has_been_split : !t.parent_guid))\n // Filter for selected accounts\n .filter((t) => Boolean(accounts.find((guid) => guid === t.account_guid)))\n // Filter for Date Range.\n // NOTE: bounds are local-midnight (getUnixTime of a local Date) while dates\n // are rendered/exported on the UTC calendar day (fromUnixUTC). For a\n // midnight-UTC row near a month boundary in a negative-offset browser the\n // two can disagree by a day. Left as-is here to keep this fix low-risk;\n // unifying range + search on UTC is tracked with the core-data ISO\n // migration (MEW-3961 follow-up).\n .filter((t) => t.date >= getUnixTime(dateRange.start) && t.date <= getUnixTime(dateRange.end))\n // Custom filter\n .filter(custom)\n // Search filter\n .filter((transaction) => {\n // Don't return uncategorized split transactions\n if (searchFilter === UNCATEGORIZED_TERM && transaction.has_been_split) {\n return false\n }\n\n // Split check - When searching for \"Splits\" and transaction is a split or is a parent of a split(s)\n const splitPattern = /^spl/i\n if (\n splitPattern.test(searchFilter) &&\n (transaction.has_been_split || Boolean(transaction.parent_guid))\n ) {\n return true\n }\n\n // Check transactions tags\n const isTagIncludedInSearch = transaction.tags.some((guid) =>\n isIncludedInSearch(searchFilter, tags.find((tag) => tag.guid === guid)?.name),\n )\n const date = fromUnixTime(transaction.date)\n return (\n isIncludedInSearch(searchFilter, transaction.payee) ||\n isIncludedInSearch(searchFilter, transaction.feed_description) ||\n isIncludedInSearch(searchFilter, transaction.category) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.MONTH)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.DAY)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.FULL_MONTH_DAY)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.MONTH_DAY_YEAR)) ||\n isIncludedInSearch(searchFilter, format(date, ORDINAL_DATE_FORMAT)) ||\n isIncludedInSearch(searchFilter, transaction.account) ||\n isIncludedInSearch(searchFilter, formatCurrency(transaction.amount, '0,0.00')) ||\n isIncludedInSearch(searchFilter, transaction.memo) ||\n isTagIncludedInSearch\n )\n })\n )\n}\n\nconst sortTransactions = (\n transactions: Transaction[],\n sortColumn: string,\n sortDirection: string,\n) => {\n return [...transactions].sort((a: Transaction, b: Transaction) => {\n const column = sortColumn as keyof Transaction\n const sortCompare = (a[column] || '') > (b[column] || '')\n\n let sortASC = sortCompare ? -1 : 1\n let sortDESC = sortCompare ? 1 : -1\n\n if (sortColumn === COLUMN_NAMES.DATE || sortColumn === COLUMN_NAMES.AMOUNT) {\n sortASC = sortCompare ? 1 : -1\n sortDESC = sortCompare ? -1 : 1\n }\n\n return sortDirection === TABLE_CONST.ASC ? sortASC : sortDESC\n })\n}\n\n/**\n * Determines if a value is included within the terms set in the search bar\n */\nconst isIncludedInSearch = (searchFilter: string, value: string | null | undefined) => {\n const lowerCasedTerms = searchFilter.toLowerCase().split(' ')\n const lowerCasedValue = value?.toString().toLowerCase() ?? ''\n\n return lowerCasedTerms.every((filter) => lowerCasedValue.indexOf(filter) > -1)\n}\n\n// TODO: Change the way formatting data is exported in order to handle localization\ntype FormattedTransaction = {\n Date: string\n Description: string\n 'Original Description': string\n Amount: string\n Type: string\n 'Parent Category': string\n Category: string\n Account: string\n Tags: string\n Memo: string\n Pending: string\n}\n\n/**\n * Collects the GUIDs of all transactions that act as parents\n * to one or more split (child) transactions.\n */\nfunction extractParentTransactionGuids(transactions: Transaction[]): Set<string> {\n return new Set(\n transactions.filter((tx) => tx.parent_guid !== undefined).map((tx) => tx.parent_guid!),\n )\n}\n\n/**\n * Organizes child transactions by their parent transaction GUID.\n * Returns a map from parent GUID to an array of its child transactions.\n */\nfunction mapChildTransactionsByParent(transactions: Transaction[]): Record<string, Transaction[]> {\n return transactions.reduce<Record<string, Transaction[]>>((accumulator, tx) => {\n if (tx.parent_guid) {\n if (!accumulator[tx.parent_guid]) accumulator[tx.parent_guid] = []\n accumulator[tx.parent_guid].push(tx)\n }\n return accumulator\n }, {})\n}\n\n/**\n * Produces a list of transactions based on the given sorted transactions,\n * where parent transactions that have split children are replaced by those\n * children sorted by descending absolute amount. All other transactions\n * are included as-is, with duplicates removed.\n */\nexport function flattenTransactionsWithSplits(\n sortedTransactions: Transaction[],\n allTransactions: Transaction[],\n): Transaction[] {\n // Set of parent transaction GUIDs that have split child transactions\n const parentTransactionGuidsWithSplits = extractParentTransactionGuids(allTransactions)\n\n // Map from parent GUID to array of its child split transactions\n const childTransactionsGroupedByParent = mapChildTransactionsByParent(allTransactions)\n\n // Track GUIDs of transactions already included in the result to avoid duplicates\n const processedTransactionGuids = new Set<string>()\n\n // Resulting list of transactions with parents replaced by their split children\n const flattenedTransactionList: Transaction[] = []\n\n for (const transaction of sortedTransactions) {\n if (parentTransactionGuidsWithSplits.has(transaction.guid)) {\n // This transaction is a parent with splits, so replace it with its children\n const splitChildTransactions = childTransactionsGroupedByParent[transaction.guid] ?? []\n\n splitChildTransactions\n .slice()\n .sort((a, b) => Math.abs(b.amount) - Math.abs(a.amount))\n .forEach((childTransaction) => {\n if (!processedTransactionGuids.has(childTransaction.guid)) {\n flattenedTransactionList.push(childTransaction)\n processedTransactionGuids.add(childTransaction.guid)\n }\n })\n } else if (!processedTransactionGuids.has(transaction.guid)) {\n // Normal transaction (no splits), add as-is if not already added\n flattenedTransactionList.push(transaction)\n processedTransactionGuids.add(transaction.guid)\n }\n }\n\n return flattenedTransactionList\n}\n\nexport const exportTransactionsToCSV = (transactions: Transaction[], tags: Tag[]) => {\n const csvContent = structureCSVData(formatTransactions(transactions, tags))\n\n const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })\n const link = document.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.setAttribute('download', 'transactions.csv')\n\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n\n URL.revokeObjectURL(link.href)\n}\n\n/**\n * Formats a list of transactions into a list that will be used when\n * downloaded to a CSV file.\n */\nconst formatTransactions = (transactions: Transaction[], tags: Tag[]) => {\n return transactions.map((transaction) => ({\n // Post dates are calendar days; format on the UTC day so the export can't\n // shift to the prior day in a Western-offset browser.\n Date: formatDate(fromUnixUTC(transaction.date), DATE_FORMATS_INTL.YEAR_MONTH_DAY),\n Description: getDescription(transaction),\n 'Original Description': transaction.feed_description,\n Amount: `${transaction.amount}`,\n Type: transaction.transaction_type === TransactionType.CREDIT ? 'Credit' : 'Debit',\n 'Parent Category': CategoryGuidToName[transaction.top_level_category_guid || ''],\n Category: transaction.category,\n Account: transaction.account,\n Tags: getTags(transaction, tags),\n Memo: transaction.memo,\n Pending: transaction.isPending ? 'TRUE' : 'FALSE',\n })) as FormattedTransaction[]\n}\n\n/**\n * Escapes a value for safe CSV output\n */\nconst escapeCsvField = (field?: string | null): string => {\n if (!field) return ''\n return /[,\"\\n\\r]/.test(field) ? `\"${field.replace(/\"/g, '\"\"')}\"` : field\n}\n\n/**\n * Structures the CSV file data using the formatted transactions\n */\nconst structureCSVData = (formattedTransactions: FormattedTransaction[]) => {\n // Guard the empty export: Object.keys(undefined) would throw for a zero-row\n // list (e.g. an over-filtered range), so emit an empty file instead.\n if (formattedTransactions.length === 0) return ''\n\n const csvHeader = Object.keys(formattedTransactions[0]).join(',').concat('\\r\\n')\n const csvRows = formattedTransactions\n .map((transaction) => Object.values(transaction).map(escapeCsvField).join(','))\n .join('\\r\\n')\n\n return csvHeader + csvRows\n}\n\n/**\n * Get the description for a transaction that will be used within the CSV copy.\n * We want to highlight that split transactions are a split as well as\n * hidden transactions are hidden.\n */\nconst getDescription = (transaction: Transaction) => {\n let description = transaction.parent_guid ? 'Split: ' : ''\n description += transaction.is_hidden ? '(Excluded) ' : ''\n description += transaction.description\n\n return description\n}\n\nconst getTags = (transaction: Transaction, tags: Tag[]) => {\n return transaction.tags\n .map((tagGuid) => {\n const tag = tags.filter((t) => t.guid === tagGuid)[0]\n\n return tag?.name ?? ''\n })\n .join(' ')\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,IAAa,KAAA,CACX,MACY,EAAY,4BAA4B,EAAc,UAUvD,KAAA,CACX,GACA,GACA,GACA,IAAsB,CAAC,GACvB,MACG;AACH,QAAM,IAAc,EAAS,OAAA,CAAQ,GAAkB,OAC9C;AAAA,IAAE,GAAG;AAAA,IAAM,CAAA,EAAQ,IAAA,GAAO;AAAA,EAAQ,IACxC,CAAC,CAAC,GAEC,IAAgB,EAAW,OAAA,CAAQ,GAAoB,OACpD;AAAA,IAAE,GAAG;AAAA,IAAM,CAAA,EAAS,IAAA,GAAO;AAAA,EAAS,IAC1C,CAAC,CAAC,GAEC,IAAc,EAAS,OAAA,CAAQ,GAAkB,MAAqB;AAC1E,UAAM,EAAE,kBAAA,GAAkB,UAAA,EAAA,IAAa;AAEvC,QAAI,CAAC,EAAI,CAAA,EACP,QAAO;AAAA,MACL,GAAG;AAAA,MACF,CAAA,CAAA,GAAmB,CAAC,CAAQ;AAAA,IAC/B;AAEF,UAAM,IAAO,CAAC,GAAG,EAAI,CAAA,GAAmB,CAAQ;AAEhD,WAAO;AAAA,MACL,GAAG;AAAA,MACF,CAAA,CAAA,GAAmB;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,EAAa,IAAA,CAAK,MAA6B;AACpD,UAAM,IAAU,EAAY,EAAY,YAAA,GAClC,IAAW,EAAY,gBAAgB,EAAc,EAAY,aAAA,IAAiB,MAClF,IAAO,EAAY,EAAY,IAAA,KAAS,CAAC;AAE/C,WAAO;AAAA,MACL,GAAG;AAAA,MACH,SAAS,GAAS,aAAa;AAAA,MAC/B,iBAAiB,GAAS;AAAA,MA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E,SAAS,CAAO,EAAE,CAAA,GAEvC,QAAQ,EACrB,EACA,KAAK,GAAG"}
1
+ {"version":3,"file":"TransactionUtils.es.js","names":[],"sources":["../../../src/core/utils/TransactionUtils.ts"],"sourcesContent":["import { endOfToday } from 'date-fns/endOfToday'\nimport { format } from 'date-fns/format'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\n\nimport { TABLE_CONST } from '../constants/Table'\nimport {\n CategoryGuids,\n CategoryGuidToName,\n DATE_FORMATS_INTL,\n formatDate,\n ORDINAL_DATE_FORMAT,\n} from '../constants'\nimport { COLUMN_NAMES } from '../constants/Transaction'\nimport { TransactionStatus, TransactionType } from '../types'\nimport type { Category, CategoryCopy, DetailedAccount, Tag, Tagging, Transaction } from '../types'\n\nimport { type TransactionFilter } from '../stores/TransactionStore'\n\nimport { getLocalizedCategoryName } from './CategoryUtil'\nimport { endOfUtcDay, fromUnixUTC, startOfUtcDay } from './DateUtil'\nimport { formatCurrency } from './NumberFormatting'\n\ninterface AccountsMap {\n [key: string]: DetailedAccount\n}\n\n// True for account-to-account transfers (top-level Transfer category). Used to\n// swap the payee/description for the institution name in the transaction detail\n// header, the table Payee column, and the mobile list.\nexport const isTransferTransaction = (\n transaction: Pick<Transaction, 'top_level_category_guid'>,\n): boolean => transaction.top_level_category_guid === CategoryGuids.TRANSFER\n\ninterface CategoriesMap {\n [key: string]: Category\n}\n\ninterface TaggingsMap {\n [key: string]: string[]\n}\n\nexport const buildDetailedTransactions = (\n transactions: Transaction[],\n accounts: DetailedAccount[],\n categories: Category[],\n taggings: Tagging[] = [],\n categoryCopy: CategoryCopy,\n) => {\n const accountsMap = accounts.reduce((acc: AccountsMap, account: DetailedAccount) => {\n return { ...acc, [account.guid]: account }\n }, {})\n\n const categoriesMap = categories.reduce((acc: CategoriesMap, category: Category) => {\n return { ...acc, [category.guid]: category }\n }, {})\n\n const taggingsMap = taggings.reduce((acc: TaggingsMap, tagging: Tagging) => {\n const { transaction_guid, tag_guid } = tagging\n\n if (!acc[transaction_guid]) {\n return {\n ...acc,\n [transaction_guid]: [tag_guid],\n }\n }\n const tags = [...acc[transaction_guid], tag_guid] as string[]\n\n return {\n ...acc,\n [transaction_guid]: tags,\n }\n }, {})\n\n return transactions.map((transaction: Transaction) => {\n const account = accountsMap[transaction.account_guid]\n const category = transaction.category_guid ? categoriesMap[transaction.category_guid] : null\n const tags = taggingsMap[transaction.guid] ?? []\n\n return {\n ...transaction,\n account: account?.user_name || 'Unknown',\n accountIsClosed: account?.is_closed,\n accountIsHidden: account?.is_hidden,\n category: category ? getLocalizedCategoryName(category, categoryCopy) : 'Uncategorized',\n institutionName: account?.institution?.name || account?.institutionName || undefined,\n isIncome: transaction.top_level_category_guid === CategoryGuids.INCOME,\n isPending: transaction.feed_status === TransactionStatus.PENDING,\n number: account?.account_number || '',\n payee: transaction.description,\n tags,\n }\n })\n}\n\nconst UNCATEGORIZED_TERM = 'uncategorized'\n\nexport const sortAndFilterTransactions = (\n filter: TransactionFilter,\n expandedSplits: string[],\n sortColumn: string,\n sortDirection: string,\n tags: Tag[],\n transactions: Transaction[],\n) => {\n const filteredTransactions = filterTransactions(filter, tags, transactions)\n\n const sortedTransactions = sortTransactions(filteredTransactions, sortColumn, sortDirection)\n\n expandedSplits.forEach((guid) => {\n const index = sortedTransactions.findIndex((t) => t.guid === guid)\n const children = transactions.filter((t) => t.parent_guid === guid)\n sortedTransactions.splice(index + 1, 0, ...children)\n })\n return sortedTransactions\n}\n\nconst filterTransactions = (\n filter: TransactionFilter,\n tags: Tag[],\n transactions: Transaction[],\n) => {\n const {\n accounts = [],\n dateRange = { start: startOfMonth(startOfToday()), end: endOfToday() },\n custom = () => true,\n searchTerm: searchFilter = '',\n showSplits = false,\n } = filter\n\n return (\n transactions\n // Filters out parent of split transactions when showSplits is true and filters out split\n // transaction children when showSplits is false\n .filter((t) => (showSplits ? !t.has_been_split : !t.parent_guid))\n // Filter for selected accounts\n .filter((t) => Boolean(accounts.find((guid) => guid === t.account_guid)))\n // Date range on the UTC calendar day, the same day the Date cell, CSV export\n // and category totals use. Local-midnight bounds put a midnight-UTC row near\n // a month boundary in a different month than the chart. (MEW-4191)\n .filter(\n (t) => t.date >= startOfUtcDay(dateRange.start) && t.date <= endOfUtcDay(dateRange.end),\n )\n // Custom filter\n .filter(custom)\n // Search filter\n .filter((transaction) => {\n // Don't return uncategorized split transactions\n if (searchFilter === UNCATEGORIZED_TERM && transaction.has_been_split) {\n return false\n }\n\n // Split check - When searching for \"Splits\" and transaction is a split or is a parent of a split(s)\n const splitPattern = /^spl/i\n if (\n splitPattern.test(searchFilter) &&\n (transaction.has_been_split || Boolean(transaction.parent_guid))\n ) {\n return true\n }\n\n // Check transactions tags\n const isTagIncludedInSearch = transaction.tags.some((guid) =>\n isIncludedInSearch(searchFilter, tags.find((tag) => tag.guid === guid)?.name),\n )\n const date = fromUnixUTC(transaction.date)\n return (\n isIncludedInSearch(searchFilter, transaction.payee) ||\n isIncludedInSearch(searchFilter, transaction.feed_description) ||\n isIncludedInSearch(searchFilter, transaction.category) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.MONTH)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.DAY)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.FULL_MONTH_DAY)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.MONTH_DAY_YEAR)) ||\n isIncludedInSearch(searchFilter, format(date, ORDINAL_DATE_FORMAT)) ||\n isIncludedInSearch(searchFilter, transaction.account) ||\n isIncludedInSearch(searchFilter, formatCurrency(transaction.amount, '0,0.00')) ||\n isIncludedInSearch(searchFilter, transaction.memo) ||\n isTagIncludedInSearch\n )\n })\n )\n}\n\nconst sortTransactions = (\n transactions: Transaction[],\n sortColumn: string,\n sortDirection: string,\n) => {\n return [...transactions].sort((a: Transaction, b: Transaction) => {\n const column = sortColumn as keyof Transaction\n const sortCompare = (a[column] || '') > (b[column] || '')\n\n let sortASC = sortCompare ? -1 : 1\n let sortDESC = sortCompare ? 1 : -1\n\n if (sortColumn === COLUMN_NAMES.DATE || sortColumn === COLUMN_NAMES.AMOUNT) {\n sortASC = sortCompare ? 1 : -1\n sortDESC = sortCompare ? -1 : 1\n }\n\n return sortDirection === TABLE_CONST.ASC ? sortASC : sortDESC\n })\n}\n\n/**\n * Determines if a value is included within the terms set in the search bar\n */\nconst isIncludedInSearch = (searchFilter: string, value: string | null | undefined) => {\n const lowerCasedTerms = searchFilter.toLowerCase().split(' ')\n const lowerCasedValue = value?.toString().toLowerCase() ?? ''\n\n return lowerCasedTerms.every((filter) => lowerCasedValue.indexOf(filter) > -1)\n}\n\n// TODO: Change the way formatting data is exported in order to handle localization\ntype FormattedTransaction = {\n Date: string\n Description: string\n 'Original Description': string\n Amount: string\n Type: string\n 'Parent Category': string\n Category: string\n Account: string\n Tags: string\n Memo: string\n Pending: string\n}\n\n/**\n * Collects the GUIDs of all transactions that act as parents\n * to one or more split (child) transactions.\n */\nfunction extractParentTransactionGuids(transactions: Transaction[]): Set<string> {\n return new Set(\n transactions.filter((tx) => tx.parent_guid !== undefined).map((tx) => tx.parent_guid!),\n )\n}\n\n/**\n * Organizes child transactions by their parent transaction GUID.\n * Returns a map from parent GUID to an array of its child transactions.\n */\nfunction mapChildTransactionsByParent(transactions: Transaction[]): Record<string, Transaction[]> {\n return transactions.reduce<Record<string, Transaction[]>>((accumulator, tx) => {\n if (tx.parent_guid) {\n if (!accumulator[tx.parent_guid]) accumulator[tx.parent_guid] = []\n accumulator[tx.parent_guid].push(tx)\n }\n return accumulator\n }, {})\n}\n\n/**\n * Produces a list of transactions based on the given sorted transactions,\n * where parent transactions that have split children are replaced by those\n * children sorted by descending absolute amount. All other transactions\n * are included as-is, with duplicates removed.\n */\nexport function flattenTransactionsWithSplits(\n sortedTransactions: Transaction[],\n allTransactions: Transaction[],\n): Transaction[] {\n // Set of parent transaction GUIDs that have split child transactions\n const parentTransactionGuidsWithSplits = extractParentTransactionGuids(allTransactions)\n\n // Map from parent GUID to array of its child split transactions\n const childTransactionsGroupedByParent = mapChildTransactionsByParent(allTransactions)\n\n // Track GUIDs of transactions already included in the result to avoid duplicates\n const processedTransactionGuids = new Set<string>()\n\n // Resulting list of transactions with parents replaced by their split children\n const flattenedTransactionList: Transaction[] = []\n\n for (const transaction of sortedTransactions) {\n if (parentTransactionGuidsWithSplits.has(transaction.guid)) {\n // This transaction is a parent with splits, so replace it with its children\n const splitChildTransactions = childTransactionsGroupedByParent[transaction.guid] ?? []\n\n splitChildTransactions\n .slice()\n .sort((a, b) => Math.abs(b.amount) - Math.abs(a.amount))\n .forEach((childTransaction) => {\n if (!processedTransactionGuids.has(childTransaction.guid)) {\n flattenedTransactionList.push(childTransaction)\n processedTransactionGuids.add(childTransaction.guid)\n }\n })\n } else if (!processedTransactionGuids.has(transaction.guid)) {\n // Normal transaction (no splits), add as-is if not already added\n flattenedTransactionList.push(transaction)\n processedTransactionGuids.add(transaction.guid)\n }\n }\n\n return flattenedTransactionList\n}\n\nexport const exportTransactionsToCSV = (transactions: Transaction[], tags: Tag[]) => {\n const csvContent = structureCSVData(formatTransactions(transactions, tags))\n\n const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })\n const link = document.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.setAttribute('download', 'transactions.csv')\n\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n\n URL.revokeObjectURL(link.href)\n}\n\n/**\n * Formats a list of transactions into a list that will be used when\n * downloaded to a CSV file.\n */\nconst formatTransactions = (transactions: Transaction[], tags: Tag[]) => {\n return transactions.map((transaction) => ({\n // Post dates are calendar days; format on the UTC day so the export can't\n // shift to the prior day in a Western-offset browser.\n Date: formatDate(fromUnixUTC(transaction.date), DATE_FORMATS_INTL.YEAR_MONTH_DAY),\n Description: getDescription(transaction),\n 'Original Description': transaction.feed_description,\n Amount: `${transaction.amount}`,\n Type: transaction.transaction_type === TransactionType.CREDIT ? 'Credit' : 'Debit',\n 'Parent Category': CategoryGuidToName[transaction.top_level_category_guid || ''],\n Category: transaction.category,\n Account: transaction.account,\n Tags: getTags(transaction, tags),\n Memo: transaction.memo,\n Pending: transaction.isPending ? 'TRUE' : 'FALSE',\n })) as FormattedTransaction[]\n}\n\n/**\n * Escapes a value for safe CSV output\n */\nconst escapeCsvField = (field?: string | null): string => {\n if (!field) return ''\n return /[,\"\\n\\r]/.test(field) ? `\"${field.replace(/\"/g, '\"\"')}\"` : field\n}\n\n/**\n * Structures the CSV file data using the formatted transactions\n */\nconst structureCSVData = (formattedTransactions: FormattedTransaction[]) => {\n // Guard the empty export: Object.keys(undefined) would throw for a zero-row\n // list (e.g. an over-filtered range), so emit an empty file instead.\n if (formattedTransactions.length === 0) return ''\n\n const csvHeader = Object.keys(formattedTransactions[0]).join(',').concat('\\r\\n')\n const csvRows = formattedTransactions\n .map((transaction) => Object.values(transaction).map(escapeCsvField).join(','))\n .join('\\r\\n')\n\n return csvHeader + csvRows\n}\n\n/**\n * Get the description for a transaction that will be used within the CSV copy.\n * We want to highlight that split transactions are a split as well as\n * hidden transactions are hidden.\n */\nconst getDescription = (transaction: Transaction) => {\n let description = transaction.parent_guid ? 'Split: ' : ''\n description += transaction.is_hidden ? '(Excluded) ' : ''\n description += transaction.description\n\n return description\n}\n\nconst getTags = (transaction: Transaction, tags: Tag[]) => {\n return transaction.tags\n .map((tagGuid) => {\n const tag = tags.filter((t) => t.guid === tagGuid)[0]\n\n return tag?.name ?? ''\n })\n .join(' ')\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,IAAa,IAAA,CACX,MACY,EAAY,4BAA4B,EAAc,UAUvD,KAAA,CACX,GACA,GACA,GACA,IAAsB,CAAC,GACvB,MACG;AACH,QAAM,IAAc,EAAS,OAAA,CAAQ,GAAkB,OAC9C;AAAA,IAAE,GAAG;AAAA,IAAM,CAAA,EAAQ,IAAA,GAAO;AAAA,EAAQ,I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AAA,EAC3E,mBAAmB,EAAmB,EAAY,2BAA2B,EAAA;AAAA,EAC7E,UAAU,EAAY;AAAA,EACtB,SAAS,EAAY;AAAA,EACrB,MAAM,EAAQ,GAAa,CAAI;AAAA,EAC/B,MAAM,EAAY;AAAA,EAClB,SAAS,EAAY,YAAY,SAAS;AAC5C,EAAE,GAME,IAAA,CAAkB,MACjB,IACE,WAAW,KAAK,CAAK,IAAI,IAAI,EAAM,QAAQ,MAAM,IAAI,CAAA,MAAO,IADhD,IAOf,IAAA,CAAoB,MAGpB,EAAsB,WAAW,IAAU,KAE7B,OAAO,KAAK,EAAsB,CAAA,CAAE,EAAE,KAAK,GAAG,EAAE,OAAO;AAAA,CAKlE,IAJS,EACb,IAAA,CAAK,MAAgB,OAAO,OAAO,CAAW,EAAE,IAAI,CAAc,EAAE,KAAK,GAAG,CAAC,EAC7E,KAAK;AAAA,CAEW,GAQf,IAAA,CAAkB,MAA6B;AACnD,MAAI,IAAc,EAAY,cAAc,YAAY;AACxD,SAAA,KAAe,EAAY,YAAY,gBAAgB,IACvD,KAAe,EAAY,aAEpB;AACT,GAEM,IAAA,CAAW,GAA0B,MAClC,EAAY,KAChB,IAAA,CAAK,MACQ,EAAK,OAAA,CAAQ,MAAM,EAAE,SAAS,CAAO,EAAE,CAAA,GAEvC,QAAQ,EACrB,EACA,KAAK,GAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "9.4.55",
3
+ "version": "9.4.57",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",