@mx-cartographer/experiences 9.7.182 → 9.7.184
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 +9 -0
- package/dist/core/types/localization/CommonCopy.d.ts +1 -0
- package/dist/core/utils/TransactionUtils.d.ts +1 -0
- package/dist/core/utils/TransactionUtils.es.js +96 -95
- package/dist/core/utils/TransactionUtils.es.js.map +1 -1
- package/dist/finstrong/components/onboarding/OnboardingAddMonthlyIncome.es.js +20 -20
- package/dist/finstrong/components/onboarding/OnboardingAddMonthlyIncome.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +27 -27
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js +46 -28
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.d.ts +2 -0
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +13 -16
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/CompactInsightCard.es.js +28 -27
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/transactions/components/shared/TransactionList.d.ts +1 -0
- package/dist/transactions/components/shared/TransactionList.es.js +58 -57
- package/dist/transactions/components/shared/TransactionList.es.js.map +1 -1
- package/dist/transactions/components/shared/TransactionTable.es.js +57 -49
- package/dist/transactions/components/shared/TransactionTable.es.js.map +1 -1
- package/dist/transactions/components/shared/transactiontable/cells/DateCell.d.ts +4 -2
- package/dist/transactions/components/shared/transactiontable/cells/DateCell.es.js +14 -9
- package/dist/transactions/components/shared/transactiontable/cells/DateCell.es.js.map +1 -1
- package/dist/transactions/utils/Transactions.d.ts +1 -1
- package/dist/transactions/utils/Transactions.es.js +15 -23
- package/dist/transactions/utils/Transactions.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [9.7.184] - 11-18-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - Monthly Credit Card Interest Summary V2 card: charges tile, institution micro logo and its Storybook QA page (WEC-2336)
|
|
4
|
+
- **CHANGED** - AccountBlock: `charges_summary` replaces `interest_charges_summary`; its category icon draws the top-level category on a 25% tinted tile, per Figma (WEC-2336)
|
|
5
|
+
|
|
6
|
+
## [9.7.183] - 11-17-2026
|
|
7
|
+
|
|
8
|
+
- **FIXED** - pending transactions in transaction lists match the legacy widget (WELL-133)
|
|
9
|
+
|
|
1
10
|
## [9.7.182] - 11-17-2026
|
|
2
11
|
|
|
3
12
|
* **ADDED** - Weekend Spending Summary docs and fixtures
|
|
@@ -62,6 +62,7 @@ export declare const buildDetailedTransactions: (transactions: Transaction[], ac
|
|
|
62
62
|
is_duplicate: boolean;
|
|
63
63
|
feed_transacted_at: number | null;
|
|
64
64
|
}[];
|
|
65
|
+
export declare const sortPendingFirst: (transactions: Transaction[]) => Transaction[];
|
|
65
66
|
export declare const sortAndFilterTransactions: (filter: TransactionFilter, expandedSplits: string[], sortColumn: string, sortDirection: string, tags: Tag[], transactions: Transaction[]) => Transaction[];
|
|
66
67
|
/**
|
|
67
68
|
* Produces a list of transactions based on the given sorted transactions,
|
|
@@ -1,116 +1,117 @@
|
|
|
1
1
|
import { CategoryGuidToName as y, CategoryGuids as T } from "../constants/Category.es.js";
|
|
2
|
-
import { DATE_FORMATS_INTL as
|
|
3
|
-
import { TransactionStatus as
|
|
4
|
-
import { endOfUtcDay as
|
|
2
|
+
import { DATE_FORMATS_INTL as l, formatDate as m } from "../constants/DateFormats.es.js";
|
|
3
|
+
import { TransactionStatus as C, TransactionType as A } from "../types/Transaction.es.js";
|
|
4
|
+
import { endOfUtcDay as O, fromUnixUTC as h, startOfUtcDay as S } from "./DateUtil.es.js";
|
|
5
5
|
import { formatCurrency as b } from "./NumberFormatting.es.js";
|
|
6
6
|
import { getLocalizedCategoryName as D } from "./CategoryUtil.es.js";
|
|
7
7
|
import { TABLE_CONST as E } from "../constants/Table.es.js";
|
|
8
8
|
import { COLUMN_NAMES as _ } from "../constants/Transaction.es.js";
|
|
9
|
-
import { format as
|
|
10
|
-
import { startOfMonth as
|
|
11
|
-
import { startOfToday as
|
|
12
|
-
import { endOfToday as
|
|
13
|
-
var
|
|
14
|
-
const c =
|
|
15
|
-
...
|
|
16
|
-
[
|
|
17
|
-
}), {}),
|
|
18
|
-
...
|
|
19
|
-
[
|
|
20
|
-
}), {}),
|
|
21
|
-
const { transaction_guid:
|
|
22
|
-
if (!
|
|
23
|
-
...
|
|
24
|
-
[
|
|
9
|
+
import { format as N } from "date-fns/format";
|
|
10
|
+
import { startOfMonth as M } from "date-fns/startOfMonth";
|
|
11
|
+
import { startOfToday as U } from "date-fns/startOfToday";
|
|
12
|
+
import { endOfToday as L } from "date-fns/endOfToday";
|
|
13
|
+
var ee = (e) => e.top_level_category_guid === T.TRANSFER, te = (e) => !e.has_been_viewed && !e.parent_guid, re = (e, t, r, u = [], s) => {
|
|
14
|
+
const c = t.reduce((o, a) => ({
|
|
15
|
+
...o,
|
|
16
|
+
[a.guid]: a
|
|
17
|
+
}), {}), i = r.reduce((o, a) => ({
|
|
18
|
+
...o,
|
|
19
|
+
[a.guid]: a
|
|
20
|
+
}), {}), d = u.reduce((o, a) => {
|
|
21
|
+
const { transaction_guid: g, tag_guid: f } = a;
|
|
22
|
+
if (!o[g]) return {
|
|
23
|
+
...o,
|
|
24
|
+
[g]: [f]
|
|
25
25
|
};
|
|
26
|
-
const
|
|
26
|
+
const v = [...o[g], f];
|
|
27
27
|
return {
|
|
28
|
-
...
|
|
29
|
-
[
|
|
28
|
+
...o,
|
|
29
|
+
[g]: v
|
|
30
30
|
};
|
|
31
|
-
}, {});
|
|
32
|
-
return
|
|
33
|
-
const
|
|
31
|
+
}, {}), n = new Set(e.filter((o) => o.feed_status === C.PENDING).map((o) => o.guid));
|
|
32
|
+
return e.map((o) => {
|
|
33
|
+
const a = c[o.account_guid], g = o.category_guid ? i[o.category_guid] : null, f = d[o.guid] ?? [];
|
|
34
34
|
return {
|
|
35
|
-
...
|
|
36
|
-
account:
|
|
37
|
-
accountIsClosed:
|
|
38
|
-
accountIsHidden:
|
|
39
|
-
category:
|
|
40
|
-
institutionName:
|
|
41
|
-
isIncome:
|
|
42
|
-
isPending:
|
|
43
|
-
number:
|
|
44
|
-
payee:
|
|
45
|
-
tags:
|
|
35
|
+
...o,
|
|
36
|
+
account: a?.user_name || "Unknown",
|
|
37
|
+
accountIsClosed: a?.is_closed,
|
|
38
|
+
accountIsHidden: a?.is_hidden,
|
|
39
|
+
category: g ? D(g, s) : "Uncategorized",
|
|
40
|
+
institutionName: a?.institution?.name || a?.institutionName || void 0,
|
|
41
|
+
isIncome: o.top_level_category_guid === T.INCOME,
|
|
42
|
+
isPending: n.has(o.guid) || o.parent_guid != null && n.has(o.parent_guid),
|
|
43
|
+
number: a?.account_number || "",
|
|
44
|
+
payee: o.description,
|
|
45
|
+
tags: f
|
|
46
46
|
};
|
|
47
47
|
});
|
|
48
|
-
},
|
|
49
|
-
const
|
|
50
|
-
return
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
}),
|
|
54
|
-
},
|
|
55
|
-
const { accounts:
|
|
56
|
-
start:
|
|
57
|
-
end:
|
|
58
|
-
}, custom: c = () => !0, searchTerm:
|
|
59
|
-
return
|
|
60
|
-
if (
|
|
61
|
-
if (/^spl/i.test(
|
|
62
|
-
const
|
|
63
|
-
return p(
|
|
48
|
+
}, ne = (e) => [...e.filter((t) => t.isPending), ...e.filter((t) => !t.isPending)], R = "uncategorized", ie = (e, t, r, u, s, c) => {
|
|
49
|
+
const i = w(e, s, c), d = I(i, r, u);
|
|
50
|
+
return t.forEach((n) => {
|
|
51
|
+
const o = d.findIndex((g) => g.guid === n), a = c.filter((g) => g.parent_guid === n);
|
|
52
|
+
d.splice(o + 1, 0, ...a);
|
|
53
|
+
}), d;
|
|
54
|
+
}, w = (e, t, r) => {
|
|
55
|
+
const { accounts: u = [], dateRange: s = {
|
|
56
|
+
start: M(U()),
|
|
57
|
+
end: L()
|
|
58
|
+
}, custom: c = () => !0, searchTerm: i = "", showSplits: d = !1 } = e;
|
|
59
|
+
return r.filter((n) => d ? !n.has_been_split : !n.parent_guid).filter((n) => !!u.find((o) => o === n.account_guid)).filter((n) => n.date >= S(s.start) && n.date <= O(s.end)).filter(c).filter((n) => {
|
|
60
|
+
if (i === R && n.has_been_split) return !1;
|
|
61
|
+
if (/^spl/i.test(i) && (n.has_been_split || n.parent_guid)) return !0;
|
|
62
|
+
const o = n.tags.some((g) => p(i, t.find((f) => f.guid === g)?.name)), a = h(n.date);
|
|
63
|
+
return p(i, n.payee) || p(i, n.feed_description) || p(i, n.category) || p(i, m(a, l.MONTH)) || p(i, m(a, l.DAY)) || p(i, m(a, l.FULL_MONTH_DAY)) || p(i, m(a, l.MONTH_DAY_YEAR)) || p(i, N(a, "do")) || p(i, n.account) || p(i, b(n.amount, "0,0.00")) || p(i, n.memo) || o;
|
|
64
64
|
});
|
|
65
|
-
}, I = (t, r
|
|
66
|
-
const c =
|
|
67
|
-
let
|
|
68
|
-
return (
|
|
69
|
-
}), p = (
|
|
70
|
-
const
|
|
71
|
-
return
|
|
65
|
+
}, I = (e, t, r) => [...e].sort((u, s) => {
|
|
66
|
+
const c = t, i = (u[c] || "") > (s[c] || "");
|
|
67
|
+
let d = i ? -1 : 1, n = i ? 1 : -1;
|
|
68
|
+
return (t === _.DATE || t === _.AMOUNT) && (d = i ? 1 : -1, n = i ? -1 : 1), r === E.ASC ? d : n;
|
|
69
|
+
}), p = (e, t) => {
|
|
70
|
+
const r = e.toLowerCase().split(" "), u = t?.toString().toLowerCase() ?? "";
|
|
71
|
+
return r.every((s) => u.indexOf(s) > -1);
|
|
72
72
|
};
|
|
73
|
-
function
|
|
74
|
-
return new Set(
|
|
73
|
+
function P(e) {
|
|
74
|
+
return new Set(e.filter((t) => t.parent_guid !== void 0).map((t) => t.parent_guid));
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
76
|
+
function G(e) {
|
|
77
|
+
return e.reduce((t, r) => (r.parent_guid && (t[r.parent_guid] || (t[r.parent_guid] = []), t[r.parent_guid].push(r)), t), {});
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
const
|
|
81
|
-
for (const
|
|
82
|
-
|
|
83
|
-
}) :
|
|
79
|
+
function oe(e, t) {
|
|
80
|
+
const r = P(t), u = G(t), s = /* @__PURE__ */ new Set(), c = [];
|
|
81
|
+
for (const i of e) r.has(i.guid) ? (u[i.guid] ?? []).slice().sort((d, n) => Math.abs(n.amount) - Math.abs(d.amount)).forEach((d) => {
|
|
82
|
+
s.has(d.guid) || (c.push(d), s.add(d.guid));
|
|
83
|
+
}) : s.has(i.guid) || (c.push(i), s.add(i.guid));
|
|
84
84
|
return c;
|
|
85
85
|
}
|
|
86
|
-
var
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
Date:
|
|
91
|
-
Description:
|
|
92
|
-
"Original Description":
|
|
93
|
-
Amount: `${
|
|
94
|
-
Type:
|
|
95
|
-
"Parent Category": y[
|
|
96
|
-
Category:
|
|
97
|
-
Account:
|
|
98
|
-
Tags:
|
|
99
|
-
Memo:
|
|
100
|
-
Pending:
|
|
101
|
-
})),
|
|
102
|
-
`) +
|
|
103
|
-
`),
|
|
104
|
-
let
|
|
105
|
-
return
|
|
106
|
-
},
|
|
86
|
+
var se = (e, t) => {
|
|
87
|
+
const r = B(j(e, t)), u = new Blob([r], { type: "text/csv;charset=utf-8;" }), s = document.createElement("a");
|
|
88
|
+
s.href = URL.createObjectURL(u), s.setAttribute("download", "transactions.csv"), document.body.appendChild(s), s.click(), document.body.removeChild(s), URL.revokeObjectURL(s.href);
|
|
89
|
+
}, j = (e, t) => e.map((r) => ({
|
|
90
|
+
Date: m(h(r.date), l.YEAR_MONTH_DAY),
|
|
91
|
+
Description: Y(r),
|
|
92
|
+
"Original Description": r.feed_description,
|
|
93
|
+
Amount: `${r.amount}`,
|
|
94
|
+
Type: r.transaction_type === A.CREDIT ? "Credit" : "Debit",
|
|
95
|
+
"Parent Category": y[r.top_level_category_guid || ""],
|
|
96
|
+
Category: r.category,
|
|
97
|
+
Account: r.account,
|
|
98
|
+
Tags: k(r, t),
|
|
99
|
+
Memo: r.memo,
|
|
100
|
+
Pending: r.isPending ? "TRUE" : "FALSE"
|
|
101
|
+
})), F = (e) => e ? /[,"\n\r]/.test(e) ? `"${e.replace(/"/g, '""')}"` : e : "", B = (e) => e.length === 0 ? "" : Object.keys(e[0]).join(",").concat(`\r
|
|
102
|
+
`) + e.map((t) => Object.values(t).map(F).join(",")).join(`\r
|
|
103
|
+
`), Y = (e) => {
|
|
104
|
+
let t = e.parent_guid ? "Split: " : "";
|
|
105
|
+
return t += e.is_hidden ? "(Excluded) " : "", t += e.description, t;
|
|
106
|
+
}, k = (e, t) => e.tags.map((r) => t.filter((u) => u.guid === r)[0]?.name ?? "").join(" ");
|
|
107
107
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
re as buildDetailedTransactions,
|
|
109
|
+
se as exportTransactionsToCSV,
|
|
110
|
+
oe as flattenTransactionsWithSplits,
|
|
111
|
+
ee as isTransferTransaction,
|
|
112
|
+
te as isUnviewedTransaction,
|
|
113
|
+
ie as sortAndFilterTransactions,
|
|
114
|
+
ne as sortPendingFirst
|
|
114
115
|
};
|
|
115
116
|
|
|
116
117
|
//# 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 { 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\nexport const isUnviewedTransaction = (\n transaction: Pick<Transaction, 'has_been_viewed' | 'parent_guid'>,\n): boolean => !transaction.has_been_viewed && !transaction.parent_guid\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,UAEvD,KAAA,CACX,MACY,CAAC,EAAY,mBAAmB,CAAC,EAAY,aAU9C,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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,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"}
|
|
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\nexport const isUnviewedTransaction = (\n transaction: Pick<Transaction, 'has_been_viewed' | 'parent_guid'>,\n): boolean => !transaction.has_been_viewed && !transaction.parent_guid\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 const pendingTransactionGuids = new Set(\n transactions.filter((t) => t.feed_status === TransactionStatus.PENDING).map((t) => t.guid),\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 // Without this, pending-first lists would move a split child away from its parent.\n isPending:\n pendingTransactionGuids.has(transaction.guid) ||\n (transaction.parent_guid != null && pendingTransactionGuids.has(transaction.parent_guid)),\n number: account?.account_number || '',\n payee: transaction.description,\n tags,\n }\n })\n}\n\nexport const sortPendingFirst = (transactions: Transaction[]) => [\n ...transactions.filter((t) => t.isPending),\n ...transactions.filter((t) => !t.isPending),\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,KAAA,CACX,MACY,EAAY,4BAA4B,EAAc,UAEvD,KAAA,CACX,MACY,CAAC,EAAY,mBAAmB,CAAC,EAAY,aAU9C,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,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romUnixToDayOfWeekAndDate as x } from "../../../core/utils/DateUtil.es.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { hasInsetBorder as v,
|
|
3
|
+
import D from "../../../transactions/components/shared/transactionlist/TransactionRow.es.js";
|
|
4
|
+
import I from "../../../common/components/SubheaderRow.es.js";
|
|
5
|
+
import { hasInsetBorder as v, shouldShowSubheader as A } from "../../../transactions/utils/Transactions.es.js";
|
|
6
6
|
import { AddRecurringTransactionDetails as C } from "../../../recurringtransactions/components/shared/recurringsettings/AddRecurringTransactionDetails.es.js";
|
|
7
7
|
import { OnboardingSteps as _ } from "../../../core/types/Finstrong.es.js";
|
|
8
8
|
import m from "react";
|
|
@@ -13,35 +13,35 @@ import { Add as R } from "@mxenabled/mx-icons";
|
|
|
13
13
|
import { jsx as r, jsxs as n } from "react/jsx-runtime";
|
|
14
14
|
import a from "@mui/material/Box";
|
|
15
15
|
import k from "@mui/material/Divider";
|
|
16
|
-
var B = ({ firstDay: p, frequency: f, secondDay: h, incomeTransactions: o, setCurrentStep:
|
|
17
|
-
const { finstrong: g } =
|
|
16
|
+
var B = ({ firstDay: p, frequency: f, secondDay: h, incomeTransactions: o, setCurrentStep: u, setFirstDay: c, setFrequency: l, setSecondDay: s, transaction: d }) => {
|
|
17
|
+
const { finstrong: g } = S();
|
|
18
18
|
return /* @__PURE__ */ n(m.Fragment, { children: [/* @__PURE__ */ n(F, { children: [!!o.length && /* @__PURE__ */ r(a, {
|
|
19
19
|
sx: { pb: 24 },
|
|
20
|
-
children: o.reduce((
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
/* @__PURE__ */ r(
|
|
20
|
+
children: o.reduce((t, e, i) => {
|
|
21
|
+
if (e.guid === d.guid) return t;
|
|
22
|
+
const b = A(i, o), y = v(i, o);
|
|
23
|
+
return t.push(/* @__PURE__ */ n(m.Fragment, { children: [
|
|
24
|
+
b && /* @__PURE__ */ r(I, { children: x(e.date) }),
|
|
25
|
+
/* @__PURE__ */ r(D, {
|
|
26
26
|
component: "div",
|
|
27
|
-
transaction:
|
|
27
|
+
transaction: e
|
|
28
28
|
}),
|
|
29
|
-
/* @__PURE__ */ r(k, { sx: { ml:
|
|
30
|
-
] },
|
|
29
|
+
/* @__PURE__ */ r(k, { sx: { ml: y ? 44 : 0 } })
|
|
30
|
+
] }, e.guid)), t;
|
|
31
31
|
}, [])
|
|
32
32
|
}), /* @__PURE__ */ r(C, {
|
|
33
33
|
firstDay: p,
|
|
34
34
|
frequency: f,
|
|
35
|
-
onFirstDayChange:
|
|
36
|
-
onFrequencyChange:
|
|
37
|
-
onSecondDayChange:
|
|
35
|
+
onFirstDayChange: c,
|
|
36
|
+
onFrequencyChange: l,
|
|
37
|
+
onSecondDayChange: s,
|
|
38
38
|
secondDay: h,
|
|
39
|
-
transaction:
|
|
39
|
+
transaction: d
|
|
40
40
|
})] }), /* @__PURE__ */ r(a, {
|
|
41
41
|
sx: { px: 24 },
|
|
42
42
|
children: /* @__PURE__ */ r(O, {
|
|
43
43
|
fullWidth: !0,
|
|
44
|
-
onClick: () =>
|
|
44
|
+
onClick: () => u({
|
|
45
45
|
step: _.MonthlyIncome,
|
|
46
46
|
type: "main"
|
|
47
47
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingAddMonthlyIncome.es.js","names":[],"sources":["../../../../src/finstrong/components/onboarding/OnboardingAddMonthlyIncome.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Divider from '@mui/material/Divider'\nimport Stack from '@mui/material/Stack'\n\nimport { Add } from '@mxenabled/mx-icons'\n\nimport { useGlobalCopyStore } from '../../../common'\nimport { Frequency, type Transaction } from '../../../core'\nimport SubheaderRow from '../../../common/components/SubheaderRow'\nimport { OnboardingSteps } from '../../../core/types/Finstrong'\nimport { fromUnixToDayOfWeekAndDate } from '../../../core/utils/DateUtil'\nimport { AddRecurringTransactionDetails } from '../../../recurringtransactions'\nimport { TransactionRow } from '../../../transactions'\nimport { hasInsetBorder,
|
|
1
|
+
{"version":3,"file":"OnboardingAddMonthlyIncome.es.js","names":[],"sources":["../../../../src/finstrong/components/onboarding/OnboardingAddMonthlyIncome.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Divider from '@mui/material/Divider'\nimport Stack from '@mui/material/Stack'\n\nimport { Add } from '@mxenabled/mx-icons'\n\nimport { useGlobalCopyStore } from '../../../common'\nimport { Frequency, type Transaction } from '../../../core'\nimport SubheaderRow from '../../../common/components/SubheaderRow'\nimport { OnboardingSteps } from '../../../core/types/Finstrong'\nimport { fromUnixToDayOfWeekAndDate } from '../../../core/utils/DateUtil'\nimport { AddRecurringTransactionDetails } from '../../../recurringtransactions'\nimport { TransactionRow } from '../../../transactions'\nimport { hasInsetBorder, shouldShowSubheader } from '../../../transactions/utils/Transactions'\n\nimport type { StepState } from './OnboardingStepsDrawer'\n\ninterface OnboardingAddMonthlyIncomeProps {\n firstDay: number\n frequency: Frequency\n secondDay: number\n incomeTransactions: Transaction[]\n setCurrentStep: (step: StepState) => void\n setFirstDay: (day: number) => void\n setFrequency: (frequency: Frequency) => void\n setSecondDay: (day: number) => void\n transaction: Transaction\n}\n\nconst OnboardingAddMonthlyIncome = ({\n firstDay,\n frequency,\n secondDay,\n incomeTransactions,\n setCurrentStep,\n setFirstDay,\n setFrequency,\n setSecondDay,\n transaction,\n}: OnboardingAddMonthlyIncomeProps) => {\n const { finstrong: copy } = useGlobalCopyStore()\n\n return (\n <React.Fragment>\n <Stack>\n {!!incomeTransactions.length && (\n <Box sx={{ pb: 24 }}>\n {incomeTransactions.reduce<React.JSX.Element[]>((elements, txn, i) => {\n if (txn.guid === transaction.guid) return elements\n\n const showSubheader = shouldShowSubheader(i, incomeTransactions)\n const isInset = hasInsetBorder(i, incomeTransactions)\n\n elements.push(\n <React.Fragment key={txn.guid}>\n {showSubheader && <SubheaderRow>{fromUnixToDayOfWeekAndDate(txn.date)}</SubheaderRow>}\n <TransactionRow component=\"div\" transaction={txn} />\n <Divider sx={{ ml: isInset ? 44 : 0 }} />\n </React.Fragment>,\n )\n\n return elements\n }, [])}\n </Box>\n )}\n <AddRecurringTransactionDetails\n firstDay={firstDay}\n frequency={frequency}\n onFirstDayChange={setFirstDay}\n onFrequencyChange={setFrequency}\n onSecondDayChange={setSecondDay}\n secondDay={secondDay}\n transaction={transaction}\n />\n </Stack>\n\n <Box sx={{ px: 24 }}>\n <Button\n fullWidth={true}\n onClick={() => setCurrentStep({ step: OnboardingSteps.MonthlyIncome, type: 'main' })}\n startIcon={<Add />}\n >\n {copy.onboarding_add_more_income}\n </Button>\n </Box>\n </React.Fragment>\n )\n}\n\nexport default observer(OnboardingAddMonthlyIncome)\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,IAAM,IAAA,CAA8B,EAClC,UAAA,GACA,WAAA,GACA,WAAA,GACA,oBAAA,GACA,gBAAA,GACA,aAAA,GACA,cAAA,GACA,cAAA,GACA,aAAA,EAAA,MACqC;AACrC,QAAM,EAAE,WAAW,EAAA,IAAS,EAAmB;AAE/C,SACE,gBAAA,EAAC,EAAM,UAAP,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD,EAAA,UAAA,CACG,CAAC,CAAC,EAAmB,UACpB,gBAAA,EAAC,GAAD;AAAA,IAAK,IAAI,EAAE,IAAI,GAAG;AAAA,IACf,UAAA,EAAmB,OAAA,CAA6B,GAAU,GAAK,MAAM;AACpE,UAAI,EAAI,SAAS,EAAY,KAAM,QAAO;AAE1C,YAAM,IAAgB,EAAoB,GAAG,CAAkB,GACzD,IAAU,EAAe,GAAG,CAAkB;AAEpD,aAAA,EAAS,KACP,gBAAA,EAAC,EAAM,UAAP,EAAA,UAAA;AAAA,QACG,KAAiB,gBAAA,EAAC,GAAD,EAAA,UAAe,EAA2B,EAAI,IAAI,EAAgB,CAAA;AAAA,QACpF,gBAAA,EAAC,GAAD;AAAA,UAAgB,WAAU;AAAA,UAAM,aAAa;AAAA,QAAM,CAAA;AAAA,QACnD,gBAAA,EAAC,GAAD,EAAS,IAAI,EAAE,IAAI,IAAU,KAAK,EAAE,EAAI,CAAA;AAAA,MAC1B,EAAA,GAJK,EAAI,IAIT,CAClB,GAEO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,EACF,CAAA,GAEP,gBAAA,EAAC,GAAD;AAAA,IACY,UAAA;AAAA,IACC,WAAA;AAAA,IACX,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACR,WAAA;AAAA,IACE,aAAA;AAAA,EACd,CAAA,CACI,EAAA,CAAA,GAEP,gBAAA,EAAC,GAAD;AAAA,IAAK,IAAI,EAAE,IAAI,GAAG;AAAA,IAChB,UAAA,gBAAA,EAAC,GAAD;AAAA,MACE,WAAW;AAAA,MACX,SAAA,MAAe,EAAe;AAAA,QAAE,MAAM,EAAgB;AAAA,QAAe,MAAM;AAAA,MAAO,CAAC;AAAA,MACnF,WAAW,gBAAA,EAAC,GAAD,CAAM,CAAA;AAAA,MAEhB,UAAA,EAAK;AAAA,IACA,CAAA;AAAA,EACL,CAAA,CACS,EAAA,CAAA;AAEpB,GAEA,IAAe,EAAS,CAA0B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { slot as
|
|
1
|
+
import { slot as s } from "../../../../core/types/Insights.es.js";
|
|
2
2
|
import { CURRENCY_FORMAT as T, formatCurrency as k } from "../../../../core/utils/NumberFormatting.es.js";
|
|
3
|
-
import { resolveVariantConfig as
|
|
4
|
-
import { asLogoRef as
|
|
3
|
+
import { resolveVariantConfig as j } from "../../resolveVariantConfig.es.js";
|
|
4
|
+
import { asLogoRef as I, asNumber as N, asText as x } from "../../slotReaders.es.js";
|
|
5
5
|
import { useContainerDimensions as P } from "../../../hooks/useContainerDimensions.es.js";
|
|
6
6
|
import E from "../../../components/LogoFromGuid.es.js";
|
|
7
7
|
import { Confetti as O } from "../../../components/shared/Confetti.es.js";
|
|
@@ -16,17 +16,17 @@ import { IconComponent as q } from "./IconComponent.es.js";
|
|
|
16
16
|
import { useRef as J } from "react";
|
|
17
17
|
import t from "@mui/material/Stack";
|
|
18
18
|
import { Text as l } from "@mxenabled/mxui";
|
|
19
|
-
import { Icon as
|
|
19
|
+
import { Icon as S } from "@mxenabled/mx-icons";
|
|
20
20
|
import { jsx as o, jsxs as r } from "react/jsx-runtime";
|
|
21
21
|
import { useTheme as Q } from "@mui/material/styles";
|
|
22
|
-
import
|
|
22
|
+
import a from "@mui/material/Box";
|
|
23
23
|
var vo = ({ payload: g }) => {
|
|
24
|
-
const h = Q(), b = J(null), { height: w, width: R } = P(b), { instance_slot: n } = g, { variant: p, institution_guid:
|
|
24
|
+
const h = Q(), b = J(null), { height: w, width: R } = P(b), { instance_slot: n } = g, { variant: p, institution_guid: z, institution_name: D, icon_name: A, merchant_name: L } = n;
|
|
25
25
|
if (K(p)) return /* @__PURE__ */ o(M, { payload: g });
|
|
26
|
-
const { data: i } = n, m = i !== void 0, u = m ? N(
|
|
26
|
+
const { data: i } = n, m = i !== void 0, u = m ? N(s(i, "amount")) : n.amount, v = x(s(i, "sub_text")), y = m ? v : n.sub_text, V = m ? v : n.label, c = m ? x(s(i, "header_text")) : n.header_text, d = I(s(i, "logo")) ?? I(s(i, "icon")), e = j(Y(h), p, "default", "AccountBlock");
|
|
27
27
|
if (e?.isConfetti) {
|
|
28
|
-
const f = H(
|
|
29
|
-
paidOffCard: /* @__PURE__ */ o(
|
|
28
|
+
const f = H(d?.guid), B = {
|
|
29
|
+
paidOffCard: /* @__PURE__ */ o(a, {
|
|
30
30
|
sx: {
|
|
31
31
|
flexShrink: 0,
|
|
32
32
|
height: 32,
|
|
@@ -49,7 +49,7 @@ var vo = ({ payload: g }) => {
|
|
|
49
49
|
role: "presentation",
|
|
50
50
|
width: 55
|
|
51
51
|
}),
|
|
52
|
-
logo: /* @__PURE__ */ o(
|
|
52
|
+
logo: /* @__PURE__ */ o(a, {
|
|
53
53
|
sx: {
|
|
54
54
|
borderRadius: "4px",
|
|
55
55
|
flexShrink: 0,
|
|
@@ -66,28 +66,28 @@ var vo = ({ payload: g }) => {
|
|
|
66
66
|
justifyContent: "center",
|
|
67
67
|
width: "100%"
|
|
68
68
|
},
|
|
69
|
-
children: /* @__PURE__ */ o(
|
|
69
|
+
children: /* @__PURE__ */ o(S, {
|
|
70
70
|
"aria-hidden": !0,
|
|
71
71
|
name: f,
|
|
72
72
|
size: e.logo_icon_size ?? 24,
|
|
73
73
|
sx: { color: "success.contrastText" }
|
|
74
74
|
})
|
|
75
|
-
}) :
|
|
76
|
-
logo:
|
|
75
|
+
}) : d?.guid ? /* @__PURE__ */ o(E, {
|
|
76
|
+
logo: d,
|
|
77
77
|
size: 48
|
|
78
78
|
}) : null
|
|
79
79
|
})
|
|
80
|
-
}[e.graphic ?? "logo"],
|
|
80
|
+
}[e.graphic ?? "logo"], F = x(s(i, "secondary_text")) || (L ?? D), C = e.secondarySource === "merchant" ? F : V, _ = C ? /* @__PURE__ */ o(l, {
|
|
81
81
|
color: e.secondaryColor,
|
|
82
82
|
variant: e.secondaryVariant,
|
|
83
83
|
children: C
|
|
84
|
-
}) : null,
|
|
84
|
+
}) : null, $ = u != null ? /* @__PURE__ */ o(l, {
|
|
85
85
|
bold: !e.amountKeepsVariantWeight,
|
|
86
86
|
color: "success.dark",
|
|
87
87
|
variant: e.amountVariant,
|
|
88
88
|
children: `${e.amountPrefix ?? ""}${k(u, T.cents)}`
|
|
89
89
|
}) : null;
|
|
90
|
-
return /* @__PURE__ */ r(
|
|
90
|
+
return /* @__PURE__ */ r(a, {
|
|
91
91
|
ref: b,
|
|
92
92
|
sx: {
|
|
93
93
|
backgroundImage: e.gradient,
|
|
@@ -97,7 +97,7 @@ var vo = ({ payload: g }) => {
|
|
|
97
97
|
p: 16,
|
|
98
98
|
width: "100%"
|
|
99
99
|
},
|
|
100
|
-
children: [/* @__PURE__ */ o(
|
|
100
|
+
children: [/* @__PURE__ */ o(a, {
|
|
101
101
|
sx: {
|
|
102
102
|
inset: 0,
|
|
103
103
|
pointerEvents: "none",
|
|
@@ -118,7 +118,7 @@ var vo = ({ payload: g }) => {
|
|
|
118
118
|
width: "100%",
|
|
119
119
|
zIndex: 2
|
|
120
120
|
},
|
|
121
|
-
children: [e.categoryStrip &&
|
|
121
|
+
children: [e.categoryStrip && c && /* @__PURE__ */ o(a, {
|
|
122
122
|
sx: {
|
|
123
123
|
bgcolor: "success.main",
|
|
124
124
|
px: 12,
|
|
@@ -127,7 +127,7 @@ var vo = ({ payload: g }) => {
|
|
|
127
127
|
children: /* @__PURE__ */ o(l, {
|
|
128
128
|
color: "success.contrastText",
|
|
129
129
|
variant: "caption",
|
|
130
|
-
children:
|
|
130
|
+
children: c
|
|
131
131
|
})
|
|
132
132
|
}), /* @__PURE__ */ r(t, {
|
|
133
133
|
sx: {
|
|
@@ -144,12 +144,12 @@ var vo = ({ payload: g }) => {
|
|
|
144
144
|
flexDirection: "row",
|
|
145
145
|
...e.rowSx
|
|
146
146
|
},
|
|
147
|
-
children: [/* @__PURE__ */ o(
|
|
147
|
+
children: [/* @__PURE__ */ o(a, {
|
|
148
148
|
sx: {
|
|
149
149
|
display: "flex",
|
|
150
150
|
flexShrink: 0
|
|
151
151
|
},
|
|
152
|
-
children:
|
|
152
|
+
children: B
|
|
153
153
|
}), /* @__PURE__ */ r(t, {
|
|
154
154
|
sx: {
|
|
155
155
|
flex: "1 0 0",
|
|
@@ -157,7 +157,7 @@ var vo = ({ payload: g }) => {
|
|
|
157
157
|
},
|
|
158
158
|
children: [
|
|
159
159
|
e.secondaryPosition === "above" && _,
|
|
160
|
-
|
|
160
|
+
$,
|
|
161
161
|
e.secondaryPosition === "below" && _
|
|
162
162
|
]
|
|
163
163
|
})]
|
|
@@ -176,7 +176,7 @@ var vo = ({ payload: g }) => {
|
|
|
176
176
|
boxShadow: h.shadows[1],
|
|
177
177
|
width: "100%"
|
|
178
178
|
},
|
|
179
|
-
children: [
|
|
179
|
+
children: [c && /* @__PURE__ */ o(U, { headerText: c }), /* @__PURE__ */ r(t, {
|
|
180
180
|
sx: {
|
|
181
181
|
alignItems: "center",
|
|
182
182
|
bgcolor: "background.paper",
|
|
@@ -184,14 +184,14 @@ var vo = ({ payload: g }) => {
|
|
|
184
184
|
gap: 16,
|
|
185
185
|
p: 16,
|
|
186
186
|
width: "100%",
|
|
187
|
-
...
|
|
187
|
+
...c && {
|
|
188
188
|
borderTopLeftRadius: "0",
|
|
189
189
|
borderTopRightRadius: "0"
|
|
190
190
|
},
|
|
191
|
-
...(
|
|
191
|
+
...(z || A || d?.guid) && { flexDirection: "row" }
|
|
192
192
|
},
|
|
193
193
|
children: [/* @__PURE__ */ o(q, {
|
|
194
|
-
logo:
|
|
194
|
+
logo: d,
|
|
195
195
|
slot: n,
|
|
196
196
|
variant: p
|
|
197
197
|
}), /* @__PURE__ */ r(t, { children: [u != null && /* @__PURE__ */ o(l, {
|
|
@@ -203,7 +203,7 @@ var vo = ({ payload: g }) => {
|
|
|
203
203
|
flexDirection: "row",
|
|
204
204
|
alignItems: "center"
|
|
205
205
|
},
|
|
206
|
-
children: [e.sub_logo && /* @__PURE__ */ o(
|
|
206
|
+
children: [e.sub_logo && /* @__PURE__ */ o(S, {
|
|
207
207
|
color: "warning",
|
|
208
208
|
fill: !0,
|
|
209
209
|
name: e.sub_logo,
|