@mx-cartographer/experiences 9.4.42 → 9.4.44
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 +12 -0
- package/dist/budgets/components/BudgetsEmptyState.es.js +50 -44
- package/dist/budgets/components/BudgetsEmptyState.es.js.map +1 -1
- package/dist/categories/components/CategoryList.es.js +34 -27
- package/dist/categories/components/CategoryList.es.js.map +1 -1
- package/dist/common/components/listitems/CollapseExpandListItem.es.js +26 -25
- package/dist/common/components/listitems/CollapseExpandListItem.es.js.map +1 -1
- package/dist/core/stores/TransactionStore.es.js +1 -1
- package/dist/core/stores/TransactionStore.es.js.map +1 -1
- package/dist/core/types/localization/CommonCopy.d.ts +2 -0
- package/dist/core/types/localization/TrendsCopy.d.ts +0 -1
- package/dist/core/utils/CategoryUtil.d.ts +11 -0
- package/dist/core/utils/CategoryUtil.es.js +36 -32
- package/dist/core/utils/CategoryUtil.es.js.map +1 -1
- package/dist/core/utils/NetWorthUtils.d.ts +2 -2
- package/dist/core/utils/NetWorthUtils.es.js +64 -64
- package/dist/core/utils/NetWorthUtils.es.js.map +1 -1
- package/dist/core/utils/TransactionUtils.d.ts +2 -2
- package/dist/core/utils/TransactionUtils.es.js +93 -92
- package/dist/core/utils/TransactionUtils.es.js.map +1 -1
- package/dist/debts/components/debtstable/AccountCell.es.js +13 -13
- package/dist/debts/components/debtstable/AccountCell.es.js.map +1 -1
- package/dist/finstrong/components/SpendLessThanYouMake/SpendLessThanYouMakeComponent.es.js +40 -36
- package/dist/finstrong/components/SpendLessThanYouMake/SpendLessThanYouMakeComponent.es.js.map +1 -1
- package/dist/networth/components/AssetsLiabilitiesDetail.es.js +47 -47
- package/dist/networth/components/AssetsLiabilitiesDetail.es.js.map +1 -1
- package/dist/spending/components/MiniSpendingChart.es.js +52 -47
- package/dist/spending/components/MiniSpendingChart.es.js.map +1 -1
- package/dist/spending/components/Spending.es.js +82 -74
- package/dist/spending/components/Spending.es.js.map +1 -1
- package/dist/spending/utils/SpendingData.d.ts +7 -5
- package/dist/spending/utils/SpendingData.es.js +34 -31
- package/dist/spending/utils/SpendingData.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,60 +1,64 @@
|
|
|
1
|
-
import { CategoryColors as M, CategoryGuids as h, CategoryIcon as
|
|
2
|
-
import { DATE_FORMATS_INTL as
|
|
3
|
-
import { CategoryIconList as
|
|
1
|
+
import { CategoryColors as M, CategoryGuids as h, CategoryIcon as N } from "../constants/Category.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as T, formatDate as b } from "../constants/DateFormats.es.js";
|
|
3
|
+
import { CategoryIconList as D } from "@mxenabled/mxui";
|
|
4
4
|
import { format as c } from "date-fns/format";
|
|
5
5
|
import { startOfMonth as O } from "date-fns/startOfMonth";
|
|
6
6
|
import { startOfToday as E } from "date-fns/startOfToday";
|
|
7
7
|
import { subMonths as I } from "date-fns/subMonths";
|
|
8
|
-
var R = 3, f = 12,
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
},
|
|
12
|
-
const
|
|
8
|
+
var R = 3, f = 12, S = (e, r) => {
|
|
9
|
+
const t = r.default_categories?.[e.guid];
|
|
10
|
+
return t ? t.replace(/&/g, "&") : e.name;
|
|
11
|
+
}, k = (e, r, t, o) => e.filter((a) => !a.parent_guid).map((a) => _(a, r, t, o, e.filter((n) => n.parent_guid === a.guid))), B = (e, r) => {
|
|
12
|
+
const t = D.find((o) => o.guid === e);
|
|
13
|
+
return t ? r.palette.categories[t.colorName] || "" : r.palette.categories.uncategorized || "";
|
|
14
|
+
}, _ = (e, r, t, o, a = []) => {
|
|
15
|
+
const n = e.guid, u = e.parent_guid || n, s = n === u, g = t.find((i) => i.category_guid === n)?.total || 0, d = p(o.filter((i) => i.category_guid === n)), m = p(o.filter((i) => i.category_guid === n || i.top_level_category_guid === n)), l = a.map((i) => _(i, r, t, o)), A = l.reduce((i, C) => i + C.currentAmount, g), v = S(e, r);
|
|
13
16
|
return {
|
|
14
|
-
...
|
|
17
|
+
...e,
|
|
15
18
|
currentAmount: g,
|
|
16
|
-
averageAmount:
|
|
19
|
+
averageAmount: y(d),
|
|
17
20
|
color: M[u],
|
|
18
|
-
icon:
|
|
21
|
+
icon: N[u],
|
|
19
22
|
isTransfer: u === h.TRANSFER,
|
|
20
23
|
monthlyAmounts: d,
|
|
21
24
|
name: v,
|
|
22
25
|
subCategories: l,
|
|
23
26
|
totalAmount: s ? A : 0,
|
|
24
|
-
totalAverageAmount:
|
|
27
|
+
totalAverageAmount: y(m),
|
|
25
28
|
totalMonthlyAmounts: s ? m : []
|
|
26
29
|
};
|
|
27
|
-
},
|
|
28
|
-
const o =
|
|
30
|
+
}, P = (e, r) => e.map((t) => {
|
|
31
|
+
const o = r.filter((a) => a.category_guid === t.guid || a.top_level_category_guid === t.guid);
|
|
29
32
|
return {
|
|
30
|
-
...
|
|
33
|
+
...t,
|
|
31
34
|
transactions: o
|
|
32
35
|
};
|
|
33
|
-
}),
|
|
34
|
-
const
|
|
35
|
-
return Math.ceil(Math.max(0,
|
|
36
|
-
},
|
|
37
|
-
const
|
|
36
|
+
}), y = (e, r = R) => {
|
|
37
|
+
const t = r > history.length ? history.length : r;
|
|
38
|
+
return Math.ceil(Math.max(0, e.slice(-t).reduce((o, a) => o + a.amount, 0) / t));
|
|
39
|
+
}, p = (e) => {
|
|
40
|
+
const r = [], t = E();
|
|
38
41
|
for (let o = 0; o <= f; o++) {
|
|
39
|
-
const a = O(I(
|
|
40
|
-
|
|
42
|
+
const a = O(I(t, f - o)), n = e.filter((u) => u.year_month === Number(c(a, "yyyyMM"))).reduce((u, s) => u + s.total, 0);
|
|
43
|
+
r.push({
|
|
41
44
|
amount: n,
|
|
42
45
|
isoDate: c(a, "yyyy-MM-dd"),
|
|
43
|
-
label:
|
|
46
|
+
label: b(a, T.MONTH_YEAR)
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
|
-
return
|
|
47
|
-
},
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
return
|
|
49
|
+
return r;
|
|
50
|
+
}, V = (e, r) => e.find((t) => t.guid === r), $ = (e, r) => {
|
|
51
|
+
const t = e.find((o) => o.subCategories.find((a) => a.guid === r));
|
|
52
|
+
if (t)
|
|
53
|
+
return t.subCategories.find((o) => o.guid === r);
|
|
51
54
|
};
|
|
52
55
|
export {
|
|
53
56
|
k as augmentCategories,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
V as findDetailedCategory,
|
|
58
|
+
$ as findDetailedSubCategory,
|
|
59
|
+
B as getCategoryColor,
|
|
60
|
+
P as getDetailedCategoryTransactions,
|
|
61
|
+
S as getLocalizedCategoryName
|
|
58
62
|
};
|
|
59
63
|
|
|
60
64
|
//# sourceMappingURL=CategoryUtil.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoryUtil.es.js","names":[],"sources":["../../../src/core/utils/CategoryUtil.ts"],"sourcesContent":["import { format } from 'date-fns/format'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subMonths } from 'date-fns/subMonths'\n\nimport type { Palette, Theme } from '@mui/material'\n\nimport { CategoryIconList } from '@mxenabled/mxui'\n\nimport {\n CategoryColors,\n CategoryGuids,\n CategoryIcon,\n DATE_FORMATS_INTL,\n formatDate,\n} from '../constants'\n\nimport type {\n Category,\n DateRangeCategoryTotals,\n DetailedCategory,\n DetailedCategoryWithTransactions,\n MonthlyAmount,\n MonthlyCategoryTotals,\n Transaction,\n CategoryCopy,\n CategoryTotal,\n} from '../types'\n\nconst MONTHLY_AVERAGE_LENGTH = 3\nconst MONTHS_OF_HISTORY = 12\n\n/**\n * Augment categories\n * @param categories - Categories to augment\n * @param monthlyCategoryTotals - Monthly category totals\n * @param currentCategoryTotals - Current month category totals\n * @param copy - Category copy\n */\nexport const augmentCategories = (\n categories: Category[],\n copy: CategoryCopy,\n currentCategoryTotals: DateRangeCategoryTotals[],\n monthlyCategoryTotals: MonthlyCategoryTotals[],\n): DetailedCategory[] => {\n return categories\n .filter((category) => !category.parent_guid)\n .map((category) =>\n getDetailedCategory(\n category,\n copy,\n currentCategoryTotals,\n monthlyCategoryTotals,\n categories.filter((c) => c.parent_guid === category.guid),\n ),\n )\n}\n\nexport const getCategoryColor = (guid: string, theme: Theme) => {\n const categoryInfo = CategoryIconList.find((c) => c.guid === guid)\n if (!categoryInfo) return theme.palette.categories.uncategorized || ''\n\n return theme.palette.categories[categoryInfo.colorName as keyof Palette['categories']] || ''\n}\n\nexport const getCategoryIcon = (guid: string) => {\n return CategoryIconList.find((c) => c.guid === guid)?.icon\n}\n\n/**\n * Get an augmented category with additional details\n * @param category - The category to augment\n * @param copy - Category copy\n * @param currentCategoryTotals - Current month category totals\n * @param monthlyCategoryTotals - Past monthly category totals\n * @param subCategories - Subcategories for the specified category (If applicable)\n */\nconst getDetailedCategory = (\n category: Category,\n copy: CategoryCopy,\n currentCategoryTotals: DateRangeCategoryTotals[],\n monthlyCategoryTotals: MonthlyCategoryTotals[],\n subCategories: Category[] = [],\n): DetailedCategory => {\n const guid = category.guid\n const parentGuid = category.parent_guid || guid\n const isParent = guid === parentGuid\n\n const currentAmount = currentCategoryTotals.find((t) => t.category_guid === guid)?.total || 0\n const monthlyAmounts = getMonthlyAmounts(\n monthlyCategoryTotals.filter((total) => total.category_guid === guid),\n )\n const totalMonthlyAmounts = getMonthlyAmounts(\n monthlyCategoryTotals.filter(\n (total) => total.category_guid === guid || total.top_level_category_guid === guid,\n ),\n )\n const detailedSubCategories = subCategories.map((subCategory) =>\n getDetailedCategory(subCategory, copy, currentCategoryTotals, monthlyCategoryTotals),\n )\n const totalAmount = detailedSubCategories.reduce(\n (total, current) => total + current.currentAmount,\n currentAmount,\n )\n\n const name = copy.default_categories[category.guid]\n ? copy.default_categories[category.guid].replace(/&/g, '&')\n : category.name\n\n return {\n ...category,\n currentAmount,\n averageAmount: getAverage(monthlyAmounts),\n color: CategoryColors[parentGuid],\n icon: CategoryIcon[parentGuid],\n isTransfer: parentGuid === CategoryGuids.TRANSFER,\n monthlyAmounts,\n name,\n subCategories: detailedSubCategories,\n totalAmount: isParent ? totalAmount : 0,\n totalAverageAmount: getAverage(totalMonthlyAmounts),\n totalMonthlyAmounts: isParent ? totalMonthlyAmounts : [],\n }\n}\n/**\n * get the transactions belonging to parent categories\n * @param detailedCategories - detailed categories from the category store\n * @param transactions - sortedTransactions from the transaction store\n */\nexport const getDetailedCategoryTransactions = (\n detailedCategories: DetailedCategory[],\n transactions: Transaction[],\n): DetailedCategoryWithTransactions[] => {\n return detailedCategories.map((category) => {\n const categoryTransactions = transactions.filter(\n (transaction) =>\n transaction.category_guid === category.guid ||\n transaction.top_level_category_guid === category.guid,\n )\n\n return {\n ...category,\n transactions: categoryTransactions,\n }\n })\n}\n\n/**\n * Get the average amount based on the number of months (numMonths) requested\n * @param monthlyAmounts - Monthly amounts to calculate and average from\n * @param numMonths - Number of months to base the average on (DEFAULT: 3)\n */\nconst getAverage = (\n monthlyAmounts: MonthlyAmount[],\n numMonths: number = MONTHLY_AVERAGE_LENGTH,\n): number => {\n const monthsBack = numMonths > history.length ? history.length : numMonths\n\n return Math.ceil(\n Math.max(\n 0,\n monthlyAmounts.slice(-monthsBack).reduce((total, current) => total + current.amount, 0) /\n monthsBack,\n ),\n )\n}\n\n/**\n * Get the last 12 months of amounts for a category\n * @param categoryTotals - Monthly category totals\n */\nconst getMonthlyAmounts = (categoryTotals: MonthlyCategoryTotals[]): MonthlyAmount[] => {\n const monthlyAmounts: MonthlyAmount[] = []\n const today = startOfToday()\n for (let i = 0; i <= MONTHS_OF_HISTORY; i++) {\n const historyDate = startOfMonth(subMonths(today, MONTHS_OF_HISTORY - i))\n const monthlyTotals = categoryTotals.filter(\n (total) => total.year_month === Number(format(historyDate, 'yyyyMM')),\n )\n const totalAmount = monthlyTotals.reduce((acc, curr) => acc + curr.total, 0)\n\n monthlyAmounts.push({\n amount: totalAmount,\n isoDate: format(historyDate, 'yyyy-MM-dd'),\n label: formatDate(historyDate, DATE_FORMATS_INTL.MONTH_YEAR),\n })\n }\n\n return monthlyAmounts\n}\n\nexport const findCategory = (\n categories: Category[],\n categoryGuid: string | undefined,\n): Category | undefined => {\n return categories.find((c) => c.guid === categoryGuid)\n}\n\nexport const findDetailedCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n return detailedCategories.find((dc) => dc.guid === guid)\n}\n\nexport const findDetailedSubCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n const parent = detailedCategories.find((dc) => dc.subCategories.find((sc) => sc.guid === guid))\n if (!parent) return undefined\n\n return parent.subCategories.find((sc) => sc.guid === guid)\n}\n\nexport const findCategoryTotalsByParent = (\n categories: Category[],\n dateRangeTotals: DateRangeCategoryTotals[],\n): CategoryTotal[] => {\n const categoryTotals = [] as CategoryTotal[]\n\n // Iterate over the category data from BE and roll up all categories into parent categories\n // acc is the accumulated category totals of type CategoryTotal that is initialized as an empty []\n // curr is the current DateRangeCategoryTotal\n\n for (const dateRangeTotal of dateRangeTotals) {\n const category = findCategory(categories, dateRangeTotal.category_guid)\n if (!category) continue\n\n const parentGuid = category.parent_guid ?? category.guid\n const parentCategory = findCategory(categories, parentGuid)\n if (!parentCategory) continue\n\n const categoryTotal = {\n amount: dateRangeTotal.total,\n category,\n guid: category.guid,\n subCategoryTotals: [],\n }\n\n const parentCategoryTotal = categoryTotals.find((ct) => ct.guid === parentGuid)\n if (parentCategoryTotal) {\n parentCategoryTotal.amount += dateRangeTotal.total\n parentCategoryTotal.subCategoryTotals.push(categoryTotal)\n } else {\n categoryTotals.push({\n amount: dateRangeTotal.total,\n category: parentCategory,\n guid: parentGuid,\n subCategoryTotals: [categoryTotal],\n })\n }\n }\n\n return categoryTotals\n}\n\nexport const isIncome = (categories: Category[], guid: string) => {\n const category = categories.find((c) => c.guid === guid)\n if (!category) return false\n\n return category.guid === CategoryGuids.INCOME || category.parent_guid === CategoryGuids.INCOME\n}\n"],"mappings":";;;;;;;AA6BA,IAAM,IAAyB,GACzB,IAAoB,IASb,IAAA,CACX,GACA,GACA,GACA,MAEO,EACJ,OAAA,CAAQ,MAAa,CAAC,EAAS,WAAW,EAC1C,IAAA,CAAK,MACJ,EACE,GACA,GACA,GACA,GACA,EAAW,OAAA,CAAQ,MAAM,EAAE,gBAAgB,EAAS,IAAI,CAC1D,CACF,GAGS,IAAA,CAAoB,GAAc,MAAiB;AAC9D,QAAM,IAAe,EAAiB,KAAA,CAAM,MAAM,EAAE,SAAS,CAAI;AACjE,SAAK,IAEE,EAAM,QAAQ,WAAW,EAAa,SAAA,KAA6C,KAFhE,EAAM,QAAQ,WAAW,iBAAiB;AAGtE,GAcM,IAAA,CACJ,GACA,GACA,GACA,GACA,IAA4B,CAAC,MACR;AACrB,QAAM,IAAO,EAAS,MAChB,IAAa,EAAS,eAAe,GACrC,IAAW,MAAS,GAEpB,IAAgB,EAAsB,KAAA,CAAM,MAAM,EAAE,kBAAkB,CAAI,GAAG,SAAS,GACtF,IAAiB,EACrB,EAAsB,OAAA,CAAQ,MAAU,EAAM,kBAAkB,CAAI,CACtE,GACM,IAAsB,EAC1B,EAAsB,OAAA,CACnB,MAAU,EAAM,kBAAkB,KAAQ,EAAM,4BAA4B,CAC/E,CACF,GACM,IAAwB,EAAc,IAAA,CAAK,MAC/C,EAAoB,GAAa,GAAM,GAAuB,CAAqB,CACrF,GACM,IAAc,EAAsB,OAAA,CACvC,GAAO,MAAY,IAAQ,EAAQ,eACpC,CACF,GAEM,IAAO,EAAK,mBAAmB,EAAS,IAAA,IAC1C,EAAK,mBAAmB,EAAS,IAAA,EAAM,QAAQ,UAAU,GAAG,IAC5D,EAAS;AAEb,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAA;AAAA,IACA,eAAe,EAAW,CAAc;AAAA,IACxC,OAAO,EAAe,CAAA;AAAA,IACtB,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A,CACX,GACA,MACiC;AACjC,QAAM,IAAS,EAAmB,KAAA,CAAM,MAAO,EAAG,cAAc,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI,CAAC;AAC9F,MAAK;AAEL,WAAO,EAAO,cAAc,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI;AAC3D"}
|
|
1
|
+
{"version":3,"file":"CategoryUtil.es.js","names":[],"sources":["../../../src/core/utils/CategoryUtil.ts"],"sourcesContent":["import { format } from 'date-fns/format'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subMonths } from 'date-fns/subMonths'\n\nimport type { Palette, Theme } from '@mui/material'\n\nimport { CategoryIconList } from '@mxenabled/mxui'\n\nimport {\n CategoryColors,\n CategoryGuids,\n CategoryIcon,\n DATE_FORMATS_INTL,\n formatDate,\n} from '../constants'\n\nimport type {\n Category,\n DateRangeCategoryTotals,\n DetailedCategory,\n DetailedCategoryWithTransactions,\n MonthlyAmount,\n MonthlyCategoryTotals,\n Transaction,\n CategoryCopy,\n CategoryTotal,\n} from '../types'\n\nconst MONTHLY_AVERAGE_LENGTH = 3\nconst MONTHS_OF_HISTORY = 12\n\n/**\n * Resolve the localized display name for a category.\n *\n * Default (MX-supplied) categories arrive from the API with fixed English\n * names, but localized copy for them is delivered via CategoryCopy\n * `default_categories` (keyed by category guid). User-created categories have no\n * localized copy and legitimately fall back to their API name.\n * @param category - The category to resolve a name for\n * @param copy - Category copy containing localized default category names\n */\nexport const getLocalizedCategoryName = (category: Category, copy: CategoryCopy): string => {\n const localizedName = copy.default_categories?.[category.guid]\n return localizedName ? localizedName.replace(/&/g, '&') : category.name\n}\n\n/**\n * Augment categories\n * @param categories - Categories to augment\n * @param monthlyCategoryTotals - Monthly category totals\n * @param currentCategoryTotals - Current month category totals\n * @param copy - Category copy\n */\nexport const augmentCategories = (\n categories: Category[],\n copy: CategoryCopy,\n currentCategoryTotals: DateRangeCategoryTotals[],\n monthlyCategoryTotals: MonthlyCategoryTotals[],\n): DetailedCategory[] => {\n return categories\n .filter((category) => !category.parent_guid)\n .map((category) =>\n getDetailedCategory(\n category,\n copy,\n currentCategoryTotals,\n monthlyCategoryTotals,\n categories.filter((c) => c.parent_guid === category.guid),\n ),\n )\n}\n\nexport const getCategoryColor = (guid: string, theme: Theme) => {\n const categoryInfo = CategoryIconList.find((c) => c.guid === guid)\n if (!categoryInfo) return theme.palette.categories.uncategorized || ''\n\n return theme.palette.categories[categoryInfo.colorName as keyof Palette['categories']] || ''\n}\n\nexport const getCategoryIcon = (guid: string) => {\n return CategoryIconList.find((c) => c.guid === guid)?.icon\n}\n\n/**\n * Get an augmented category with additional details\n * @param category - The category to augment\n * @param copy - Category copy\n * @param currentCategoryTotals - Current month category totals\n * @param monthlyCategoryTotals - Past monthly category totals\n * @param subCategories - Subcategories for the specified category (If applicable)\n */\nconst getDetailedCategory = (\n category: Category,\n copy: CategoryCopy,\n currentCategoryTotals: DateRangeCategoryTotals[],\n monthlyCategoryTotals: MonthlyCategoryTotals[],\n subCategories: Category[] = [],\n): DetailedCategory => {\n const guid = category.guid\n const parentGuid = category.parent_guid || guid\n const isParent = guid === parentGuid\n\n const currentAmount = currentCategoryTotals.find((t) => t.category_guid === guid)?.total || 0\n const monthlyAmounts = getMonthlyAmounts(\n monthlyCategoryTotals.filter((total) => total.category_guid === guid),\n )\n const totalMonthlyAmounts = getMonthlyAmounts(\n monthlyCategoryTotals.filter(\n (total) => total.category_guid === guid || total.top_level_category_guid === guid,\n ),\n )\n const detailedSubCategories = subCategories.map((subCategory) =>\n getDetailedCategory(subCategory, copy, currentCategoryTotals, monthlyCategoryTotals),\n )\n const totalAmount = detailedSubCategories.reduce(\n (total, current) => total + current.currentAmount,\n currentAmount,\n )\n\n const name = getLocalizedCategoryName(category, copy)\n\n return {\n ...category,\n currentAmount,\n averageAmount: getAverage(monthlyAmounts),\n color: CategoryColors[parentGuid],\n icon: CategoryIcon[parentGuid],\n isTransfer: parentGuid === CategoryGuids.TRANSFER,\n monthlyAmounts,\n name,\n subCategories: detailedSubCategories,\n totalAmount: isParent ? totalAmount : 0,\n totalAverageAmount: getAverage(totalMonthlyAmounts),\n totalMonthlyAmounts: isParent ? totalMonthlyAmounts : [],\n }\n}\n/**\n * get the transactions belonging to parent categories\n * @param detailedCategories - detailed categories from the category store\n * @param transactions - sortedTransactions from the transaction store\n */\nexport const getDetailedCategoryTransactions = (\n detailedCategories: DetailedCategory[],\n transactions: Transaction[],\n): DetailedCategoryWithTransactions[] => {\n return detailedCategories.map((category) => {\n const categoryTransactions = transactions.filter(\n (transaction) =>\n transaction.category_guid === category.guid ||\n transaction.top_level_category_guid === category.guid,\n )\n\n return {\n ...category,\n transactions: categoryTransactions,\n }\n })\n}\n\n/**\n * Get the average amount based on the number of months (numMonths) requested\n * @param monthlyAmounts - Monthly amounts to calculate and average from\n * @param numMonths - Number of months to base the average on (DEFAULT: 3)\n */\nconst getAverage = (\n monthlyAmounts: MonthlyAmount[],\n numMonths: number = MONTHLY_AVERAGE_LENGTH,\n): number => {\n const monthsBack = numMonths > history.length ? history.length : numMonths\n\n return Math.ceil(\n Math.max(\n 0,\n monthlyAmounts.slice(-monthsBack).reduce((total, current) => total + current.amount, 0) /\n monthsBack,\n ),\n )\n}\n\n/**\n * Get the last 12 months of amounts for a category\n * @param categoryTotals - Monthly category totals\n */\nconst getMonthlyAmounts = (categoryTotals: MonthlyCategoryTotals[]): MonthlyAmount[] => {\n const monthlyAmounts: MonthlyAmount[] = []\n const today = startOfToday()\n for (let i = 0; i <= MONTHS_OF_HISTORY; i++) {\n const historyDate = startOfMonth(subMonths(today, MONTHS_OF_HISTORY - i))\n const monthlyTotals = categoryTotals.filter(\n (total) => total.year_month === Number(format(historyDate, 'yyyyMM')),\n )\n const totalAmount = monthlyTotals.reduce((acc, curr) => acc + curr.total, 0)\n\n monthlyAmounts.push({\n amount: totalAmount,\n isoDate: format(historyDate, 'yyyy-MM-dd'),\n label: formatDate(historyDate, DATE_FORMATS_INTL.MONTH_YEAR),\n })\n }\n\n return monthlyAmounts\n}\n\nexport const findCategory = (\n categories: Category[],\n categoryGuid: string | undefined,\n): Category | undefined => {\n return categories.find((c) => c.guid === categoryGuid)\n}\n\nexport const findDetailedCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n return detailedCategories.find((dc) => dc.guid === guid)\n}\n\nexport const findDetailedSubCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n const parent = detailedCategories.find((dc) => dc.subCategories.find((sc) => sc.guid === guid))\n if (!parent) return undefined\n\n return parent.subCategories.find((sc) => sc.guid === guid)\n}\n\nexport const findCategoryTotalsByParent = (\n categories: Category[],\n dateRangeTotals: DateRangeCategoryTotals[],\n): CategoryTotal[] => {\n const categoryTotals = [] as CategoryTotal[]\n\n // Iterate over the category data from BE and roll up all categories into parent categories\n // acc is the accumulated category totals of type CategoryTotal that is initialized as an empty []\n // curr is the current DateRangeCategoryTotal\n\n for (const dateRangeTotal of dateRangeTotals) {\n const category = findCategory(categories, dateRangeTotal.category_guid)\n if (!category) continue\n\n const parentGuid = category.parent_guid ?? category.guid\n const parentCategory = findCategory(categories, parentGuid)\n if (!parentCategory) continue\n\n const categoryTotal = {\n amount: dateRangeTotal.total,\n category,\n guid: category.guid,\n subCategoryTotals: [],\n }\n\n const parentCategoryTotal = categoryTotals.find((ct) => ct.guid === parentGuid)\n if (parentCategoryTotal) {\n parentCategoryTotal.amount += dateRangeTotal.total\n parentCategoryTotal.subCategoryTotals.push(categoryTotal)\n } else {\n categoryTotals.push({\n amount: dateRangeTotal.total,\n category: parentCategory,\n guid: parentGuid,\n subCategoryTotals: [categoryTotal],\n })\n }\n }\n\n return categoryTotals\n}\n\nexport const isIncome = (categories: Category[], guid: string) => {\n const category = categories.find((c) => c.guid === guid)\n if (!category) return false\n\n return category.guid === CategoryGuids.INCOME || category.parent_guid === CategoryGuids.INCOME\n}\n"],"mappings":";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A,MACiC;AACjC,QAAM,IAAS,EAAmB,KAAA,CAAM,MAAO,EAAG,cAAc,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI,CAAC;AAC9F,MAAK;AAEL,WAAO,EAAO,cAAc,KAAA,CAAM,MAAO,EAAG,SAAS,CAAI;AAC3D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account, AccountGroup, FinancialAccount, HistoricalAccountBalance, Member, MonthlyAccountBalance, NetWorth } from '../types';
|
|
1
|
+
import { Account, AccountGroup, AccountsCopy, FinancialAccount, HistoricalAccountBalance, Member, MonthlyAccountBalance, NetWorth } from '../types';
|
|
2
2
|
export declare const filterAccounts: (accounts: Account[], members: Member[]) => Account[];
|
|
3
3
|
export declare const flattenBalances: (allBalances: MonthlyAccountBalance[], currentBalances: MonthlyAccountBalance[]) => MonthlyAccountBalance[];
|
|
4
4
|
export declare const getLatestNetWorthData: (chartData: NetWorth[]) => NetWorth | undefined;
|
|
@@ -24,4 +24,4 @@ export declare const buildAssetsLiabilities: (accounts: Account[]) => {
|
|
|
24
24
|
totalLiabilities: number;
|
|
25
25
|
};
|
|
26
26
|
export declare const toMonthlyAccountBalance: (hab: HistoricalAccountBalance) => MonthlyAccountBalance;
|
|
27
|
-
export declare const groupAccounts: (accounts: FinancialAccount[]) => AccountGroup[];
|
|
27
|
+
export declare const groupAccounts: (accounts: FinancialAccount[], accountTypes: AccountsCopy["account_types"]) => AccountGroup[];
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { AccountIcon as _, AccountIconVariants as p
|
|
1
|
+
import { AccountIcon as _, AccountIconVariants as p } from "../types/Account.es.js";
|
|
2
2
|
import { isAccountLiability as d } from "./AccountUtils.es.js";
|
|
3
|
-
import { format as
|
|
4
|
-
import { startOfMonth as
|
|
5
|
-
import { subMonths as
|
|
6
|
-
import { fromUnixTime as
|
|
7
|
-
var h = 13,
|
|
8
|
-
const { is_closed:
|
|
9
|
-
return
|
|
10
|
-
}),
|
|
3
|
+
import { format as y } from "date-fns/format";
|
|
4
|
+
import { startOfMonth as b } from "date-fns/startOfMonth";
|
|
5
|
+
import { subMonths as v } from "date-fns/subMonths";
|
|
6
|
+
import { fromUnixTime as A } from "date-fns/fromUnixTime";
|
|
7
|
+
var h = 13, O = (e, r) => e.filter((s) => {
|
|
8
|
+
const { is_closed: n, is_deleted: i, is_hidden: t, is_manual: o } = s;
|
|
9
|
+
return n || i || t ? !1 : o || !s.guid ? !0 : r.some((g) => e.some((m) => g.guid === m.member_guid));
|
|
10
|
+
}), W = (e, r) => [...e, ...r], G = (e) => {
|
|
11
11
|
if (e && e.length > 0) return e[e.length - 1];
|
|
12
|
-
},
|
|
13
|
-
const t = r.filter(({ year_month:
|
|
14
|
-
const l = t.find((u) => u.account_guid ===
|
|
12
|
+
}, R = (e, r) => e.year_month - r.year_month, M = () => Array.from({ length: h }, (e, r) => Math.floor(b(v(/* @__PURE__ */ new Date(), r)).getTime() / 1e3)).sort(), U = (e, r, s) => !e.length || !r.length ? [] : M().reduceRight((n, i) => {
|
|
13
|
+
const t = r.filter(({ year_month: a }) => a === parseInt(y(A(i), "yyyyMM"))), o = e.map((a) => {
|
|
14
|
+
const l = t.find((u) => u.account_guid === a.guid), c = {
|
|
15
15
|
change: 0,
|
|
16
|
-
guid:
|
|
17
|
-
name:
|
|
18
|
-
type:
|
|
16
|
+
guid: a.guid,
|
|
17
|
+
name: a.name,
|
|
18
|
+
type: a.account_type,
|
|
19
19
|
balance: 0
|
|
20
20
|
};
|
|
21
|
-
if (!l &&
|
|
22
|
-
if (!l &&
|
|
23
|
-
...
|
|
24
|
-
value: d(
|
|
21
|
+
if (!l && n.length === 0 && !a.balance) return c;
|
|
22
|
+
if (!l && n.length === 0) return {
|
|
23
|
+
...c,
|
|
24
|
+
value: d(a) ? -(a.balance ?? 0) : a.balance ?? 0
|
|
25
25
|
};
|
|
26
26
|
if (!l) {
|
|
27
|
-
const u =
|
|
28
|
-
return u ||
|
|
27
|
+
const u = n[0].accounts.find((f) => f.guid === a.guid);
|
|
28
|
+
return u || c;
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
31
31
|
change: l.transaction_total,
|
|
32
|
-
guid:
|
|
33
|
-
name:
|
|
34
|
-
type:
|
|
32
|
+
guid: a.guid,
|
|
33
|
+
name: a.name,
|
|
34
|
+
type: a.account_type,
|
|
35
35
|
value: l.balance
|
|
36
36
|
};
|
|
37
|
-
}), { y: g, change:
|
|
38
|
-
y:
|
|
39
|
-
change:
|
|
37
|
+
}), { y: g, change: m } = o.reduce((a, l) => ({
|
|
38
|
+
y: a.y + (l.value || 0),
|
|
39
|
+
change: a.change + (l.change || 0)
|
|
40
40
|
}), {
|
|
41
41
|
y: 0,
|
|
42
42
|
change: 0
|
|
43
43
|
});
|
|
44
44
|
return [{
|
|
45
45
|
accounts: o,
|
|
46
|
-
x:
|
|
46
|
+
x: i,
|
|
47
47
|
y: g,
|
|
48
|
-
change:
|
|
49
|
-
}, ...
|
|
50
|
-
}, []).slice(h -
|
|
51
|
-
const r = [],
|
|
52
|
-
let
|
|
48
|
+
change: m
|
|
49
|
+
}, ...n];
|
|
50
|
+
}, []).slice(h - s), j = (e) => {
|
|
51
|
+
const r = [], s = [];
|
|
52
|
+
let n = 0, i = 0;
|
|
53
53
|
return e?.accounts.forEach((t) => {
|
|
54
54
|
t.change > 0 && (r.push({
|
|
55
55
|
accountName: t.name,
|
|
56
56
|
gain: t.change
|
|
57
|
-
}),
|
|
57
|
+
}), n += t.change), t.change < 0 && (s.push({
|
|
58
58
|
accountName: t.name,
|
|
59
59
|
loss: t.change
|
|
60
|
-
}),
|
|
60
|
+
}), i += t.change);
|
|
61
61
|
}), {
|
|
62
62
|
netWorth: e,
|
|
63
63
|
gains: r,
|
|
64
|
-
losses:
|
|
65
|
-
totalGains:
|
|
66
|
-
totalLosses:
|
|
64
|
+
losses: s,
|
|
65
|
+
totalGains: n,
|
|
66
|
+
totalLosses: i
|
|
67
67
|
};
|
|
68
|
-
},
|
|
69
|
-
const r = [],
|
|
70
|
-
let
|
|
68
|
+
}, k = (e) => {
|
|
69
|
+
const r = [], s = [];
|
|
70
|
+
let n = 0, i = 0;
|
|
71
71
|
return e.forEach((t) => {
|
|
72
72
|
if (d(t)) {
|
|
73
73
|
const o = t.balance ?? 0;
|
|
74
|
-
|
|
74
|
+
s.push({
|
|
75
75
|
accountName: t.name,
|
|
76
76
|
accountType: t.account_type,
|
|
77
77
|
balance: o
|
|
78
|
-
}),
|
|
78
|
+
}), i += o;
|
|
79
79
|
} else {
|
|
80
80
|
const o = t.balance ?? 0;
|
|
81
81
|
r.push({
|
|
82
82
|
accountName: t.name,
|
|
83
83
|
accountType: t.account_type,
|
|
84
84
|
balance: o
|
|
85
|
-
}),
|
|
85
|
+
}), n += o;
|
|
86
86
|
}
|
|
87
87
|
}), {
|
|
88
88
|
assets: r,
|
|
89
|
-
liabilities:
|
|
90
|
-
totalAssets:
|
|
91
|
-
totalLiabilities:
|
|
89
|
+
liabilities: s,
|
|
90
|
+
totalAssets: n,
|
|
91
|
+
totalLiabilities: i
|
|
92
92
|
};
|
|
93
|
-
},
|
|
93
|
+
}, w = (e) => ({
|
|
94
94
|
account_guid: e.account_guid,
|
|
95
95
|
balance: e.balance,
|
|
96
96
|
credit_transaction_total: 0,
|
|
@@ -101,27 +101,27 @@ var h = 13, W = (e, r) => e.filter((n) => {
|
|
|
101
101
|
user_guid: e.user_guid,
|
|
102
102
|
year: e.year,
|
|
103
103
|
year_month: e.year_month
|
|
104
|
-
}),
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
return n[
|
|
104
|
+
}), x = (e, r) => {
|
|
105
|
+
const s = e.reduce((n, i) => {
|
|
106
|
+
const t = i.accountType;
|
|
107
|
+
return n[t] || (n[t] = []), n[t].push(i), n;
|
|
108
108
|
}, {});
|
|
109
|
-
return Object.entries(
|
|
109
|
+
return Object.entries(s).map(([n, i]) => ({
|
|
110
110
|
icon: p[+n] || _[+n],
|
|
111
|
-
name:
|
|
112
|
-
accounts:
|
|
111
|
+
name: r[+n],
|
|
112
|
+
accounts: i
|
|
113
113
|
}));
|
|
114
114
|
};
|
|
115
115
|
export {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
k as buildAssetsLiabilities,
|
|
117
|
+
U as buildChartData,
|
|
118
|
+
j as buildGainsLosses,
|
|
119
|
+
O as filterAccounts,
|
|
120
|
+
W as flattenBalances,
|
|
121
|
+
G as getLatestNetWorthData,
|
|
122
|
+
x as groupAccounts,
|
|
123
|
+
R as sortByYearMonthAscending,
|
|
124
|
+
w as toMonthlyAccountBalance
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
//# sourceMappingURL=NetWorthUtils.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetWorthUtils.es.js","names":[],"sources":["../../../src/core/utils/NetWorthUtils.ts"],"sourcesContent":["import { format } from 'date-fns/format'\nimport { fromUnixTime } from 'date-fns/fromUnixTime'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { subMonths } from 'date-fns/subMonths'\n\nimport type {\n Account,\n AccountGroup,\n FinancialAccount,\n HistoricalAccountBalance,\n Member,\n MonthlyAccountBalance,\n NetWorth,\n} from '../types'\nimport { AccountTypeName, AccountIcon, AccountIconVariants } from '../types'\nimport { isAccountLiability } from '../utils/AccountUtils'\n\nconst MAX_NUMBER_MONTHS = 13\n\nexport const filterAccounts = (accounts: Account[], members: Member[]) => {\n return accounts.filter((account) => {\n const { is_closed, is_deleted, is_hidden, is_manual } = account\n\n if (is_closed || is_deleted || is_hidden) return false\n if (is_manual || !account.guid) return true\n\n return members.some((member) => {\n return accounts.some((account) => {\n return member.guid === account.member_guid\n })\n })\n })\n}\n\nexport const flattenBalances = (\n allBalances: MonthlyAccountBalance[],\n currentBalances: MonthlyAccountBalance[],\n) => {\n return [...allBalances, ...currentBalances]\n}\n\nexport const getLatestNetWorthData = (chartData: NetWorth[]) => {\n if (chartData && chartData.length > 0) {\n return chartData[chartData.length - 1]\n } else return undefined\n}\n\nexport const sortByYearMonthAscending = (a: MonthlyAccountBalance, b: MonthlyAccountBalance) =>\n a.year_month - b.year_month\n\nconst buildDateTicks = () => {\n return Array.from({ length: MAX_NUMBER_MONTHS }, (_, count) => {\n return Math.floor(startOfMonth(subMonths(new Date(), count)).getTime() / 1000)\n }).sort()\n}\n\nexport const buildChartData = (\n accounts: Account[],\n monthlyAccountBalances: MonthlyAccountBalance[],\n numberOfMonths: number,\n) => {\n if (!accounts.length || !monthlyAccountBalances.length) return []\n const dateTicks = buildDateTicks()\n return dateTicks\n .reduceRight((result: any, x) => {\n const balances = monthlyAccountBalances.filter(\n ({ year_month }) => year_month === parseInt(format(fromUnixTime(x), 'yyyyMM')),\n )\n const accountsWithBalances = accounts.map((account) => {\n const balance = balances.find((balance) => balance.account_guid === account.guid)\n\n const zeroBalance = {\n change: 0,\n guid: account.guid,\n name: account.name,\n type: account.account_type,\n balance: 0,\n }\n\n if (!balance && result.length === 0 && !account.balance) return zeroBalance\n\n // The servers return the monthly account balances in Utah time. Frontend starts all the date calculations\n // in UTC. We get into overlaps for a few hours depending on the timezone with no monthly account balances\n // for all accounts.\n if (!balance && result.length === 0) {\n return {\n ...zeroBalance,\n value: isAccountLiability(account) ? -(account.balance ?? 0) : (account.balance ?? 0),\n }\n }\n\n if (!balance) {\n const lastBalance = result[0].accounts.find((acc: Account) => acc.guid === account.guid)\n\n return lastBalance ? lastBalance : zeroBalance\n }\n\n return {\n change: balance.transaction_total,\n guid: account.guid,\n name: account.name,\n type: account.account_type,\n value: balance.balance,\n }\n })\n\n const { y, change } = accountsWithBalances.reduce(\n (acc, current) => {\n return {\n y: acc.y + (current.value || 0),\n change: acc.change + (current.change || 0),\n }\n },\n { y: 0, change: 0 },\n )\n\n return [\n {\n accounts: accountsWithBalances,\n x,\n y,\n change,\n },\n ...result,\n ]\n }, [])\n .slice(MAX_NUMBER_MONTHS - numberOfMonths)\n}\n\nexport const buildGainsLosses = (selectedData?: NetWorth) => {\n const gains: { accountName: string; gain: number }[] = []\n const losses: { accountName: string; loss: number }[] = []\n let totalGains = 0\n let totalLosses = 0\n\n selectedData?.accounts.forEach((account) => {\n if (account.change > 0) {\n gains.push({ accountName: account.name, gain: account.change })\n totalGains += account.change\n }\n if (account.change < 0) {\n losses.push({ accountName: account.name, loss: account.change })\n totalLosses += account.change\n }\n })\n\n return { netWorth: selectedData, gains, losses, totalGains, totalLosses }\n}\n\nexport const buildAssetsLiabilities = (accounts: Account[]) => {\n const assets: FinancialAccount[] = []\n const liabilities: FinancialAccount[] = []\n let totalAssets = 0\n let totalLiabilities = 0\n\n accounts.forEach((account) => {\n if (isAccountLiability(account)) {\n const balance = account.balance ?? 0\n liabilities.push({ accountName: account.name, accountType: account.account_type, balance })\n totalLiabilities += balance\n } else {\n const balance = account.balance ?? 0\n assets.push({ accountName: account.name, accountType: account.account_type, balance })\n totalAssets += balance\n }\n })\n\n return { assets, liabilities, totalAssets, totalLiabilities }\n}\nexport const toMonthlyAccountBalance = (hab: HistoricalAccountBalance): MonthlyAccountBalance => ({\n account_guid: hab.account_guid,\n balance: hab.balance,\n credit_transaction_total: 0,\n debit_transaction_total: 0,\n id: hab.guid,\n month: hab.month,\n transaction_total: hab.transaction_total ?? 0,\n user_guid: hab.user_guid,\n year: hab.year,\n year_month: hab.year_month,\n})\n\n// groups accounts by account type\n// returns array of account groups, each with an icon, name, and the grouped accounts\nexport const groupAccounts = (accounts: FinancialAccount[]): AccountGroup[] => {\n const groupedAccounts = accounts.reduce<{ [key: number]: FinancialAccount[] }>((acc, account) => {\n const accountType = account.accountType\n if (!acc[accountType]) {\n acc[accountType] = []\n }\n acc[accountType].push(account)\n return acc\n }, {})\n\n return Object.entries(groupedAccounts).map(([accountType, accounts]) => ({\n icon: AccountIconVariants[+accountType] || AccountIcon[+accountType],\n name: AccountTypeName[+accountType],\n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CAAA,MACP,EAAI,CAAA,IAAe,CAAC,IAEtB,EAAI,CAAA,EAAa,KAAK,CAAO,GACtB;AAAA,EACT,GAAG,CAAC,CAAC;AAEL,SAAO,OAAO,QAAQ,CAAe,EAAE,IAAA,CAAK,CAAC,GAAa,CAAA,OAAe;AAAA,IACvE,MAAM,EAAoB,CAAC,CAAA,KAAgB,EAAY,CAAC,CAAA;AAAA,IACxD,MAAM,EAAgB,CAAC,CAAA;AAAA,IACvB,UAAA;AAAA,EACF,EAAE;AACJ"}
|
|
1
|
+
{"version":3,"file":"NetWorthUtils.es.js","names":[],"sources":["../../../src/core/utils/NetWorthUtils.ts"],"sourcesContent":["import { format } from 'date-fns/format'\nimport { fromUnixTime } from 'date-fns/fromUnixTime'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { subMonths } from 'date-fns/subMonths'\n\nimport type {\n Account,\n AccountGroup,\n AccountsCopy,\n FinancialAccount,\n HistoricalAccountBalance,\n Member,\n MonthlyAccountBalance,\n NetWorth,\n} from '../types'\nimport { AccountIcon, AccountIconVariants } from '../types'\nimport { isAccountLiability } from '../utils/AccountUtils'\n\nconst MAX_NUMBER_MONTHS = 13\n\nexport const filterAccounts = (accounts: Account[], members: Member[]) => {\n return accounts.filter((account) => {\n const { is_closed, is_deleted, is_hidden, is_manual } = account\n\n if (is_closed || is_deleted || is_hidden) return false\n if (is_manual || !account.guid) return true\n\n return members.some((member) => {\n return accounts.some((account) => {\n return member.guid === account.member_guid\n })\n })\n })\n}\n\nexport const flattenBalances = (\n allBalances: MonthlyAccountBalance[],\n currentBalances: MonthlyAccountBalance[],\n) => {\n return [...allBalances, ...currentBalances]\n}\n\nexport const getLatestNetWorthData = (chartData: NetWorth[]) => {\n if (chartData && chartData.length > 0) {\n return chartData[chartData.length - 1]\n } else return undefined\n}\n\nexport const sortByYearMonthAscending = (a: MonthlyAccountBalance, b: MonthlyAccountBalance) =>\n a.year_month - b.year_month\n\nconst buildDateTicks = () => {\n return Array.from({ length: MAX_NUMBER_MONTHS }, (_, count) => {\n return Math.floor(startOfMonth(subMonths(new Date(), count)).getTime() / 1000)\n }).sort()\n}\n\nexport const buildChartData = (\n accounts: Account[],\n monthlyAccountBalances: MonthlyAccountBalance[],\n numberOfMonths: number,\n) => {\n if (!accounts.length || !monthlyAccountBalances.length) return []\n const dateTicks = buildDateTicks()\n return dateTicks\n .reduceRight((result: any, x) => {\n const balances = monthlyAccountBalances.filter(\n ({ year_month }) => year_month === parseInt(format(fromUnixTime(x), 'yyyyMM')),\n )\n const accountsWithBalances = accounts.map((account) => {\n const balance = balances.find((balance) => balance.account_guid === account.guid)\n\n const zeroBalance = {\n change: 0,\n guid: account.guid,\n name: account.name,\n type: account.account_type,\n balance: 0,\n }\n\n if (!balance && result.length === 0 && !account.balance) return zeroBalance\n\n // The servers return the monthly account balances in Utah time. Frontend starts all the date calculations\n // in UTC. We get into overlaps for a few hours depending on the timezone with no monthly account balances\n // for all accounts.\n if (!balance && result.length === 0) {\n return {\n ...zeroBalance,\n value: isAccountLiability(account) ? -(account.balance ?? 0) : (account.balance ?? 0),\n }\n }\n\n if (!balance) {\n const lastBalance = result[0].accounts.find((acc: Account) => acc.guid === account.guid)\n\n return lastBalance ? lastBalance : zeroBalance\n }\n\n return {\n change: balance.transaction_total,\n guid: account.guid,\n name: account.name,\n type: account.account_type,\n value: balance.balance,\n }\n })\n\n const { y, change } = accountsWithBalances.reduce(\n (acc, current) => {\n return {\n y: acc.y + (current.value || 0),\n change: acc.change + (current.change || 0),\n }\n },\n { y: 0, change: 0 },\n )\n\n return [\n {\n accounts: accountsWithBalances,\n x,\n y,\n change,\n },\n ...result,\n ]\n }, [])\n .slice(MAX_NUMBER_MONTHS - numberOfMonths)\n}\n\nexport const buildGainsLosses = (selectedData?: NetWorth) => {\n const gains: { accountName: string; gain: number }[] = []\n const losses: { accountName: string; loss: number }[] = []\n let totalGains = 0\n let totalLosses = 0\n\n selectedData?.accounts.forEach((account) => {\n if (account.change > 0) {\n gains.push({ accountName: account.name, gain: account.change })\n totalGains += account.change\n }\n if (account.change < 0) {\n losses.push({ accountName: account.name, loss: account.change })\n totalLosses += account.change\n }\n })\n\n return { netWorth: selectedData, gains, losses, totalGains, totalLosses }\n}\n\nexport const buildAssetsLiabilities = (accounts: Account[]) => {\n const assets: FinancialAccount[] = []\n const liabilities: FinancialAccount[] = []\n let totalAssets = 0\n let totalLiabilities = 0\n\n accounts.forEach((account) => {\n if (isAccountLiability(account)) {\n const balance = account.balance ?? 0\n liabilities.push({ accountName: account.name, accountType: account.account_type, balance })\n totalLiabilities += balance\n } else {\n const balance = account.balance ?? 0\n assets.push({ accountName: account.name, accountType: account.account_type, balance })\n totalAssets += balance\n }\n })\n\n return { assets, liabilities, totalAssets, totalLiabilities }\n}\nexport const toMonthlyAccountBalance = (hab: HistoricalAccountBalance): MonthlyAccountBalance => ({\n account_guid: hab.account_guid,\n balance: hab.balance,\n credit_transaction_total: 0,\n debit_transaction_total: 0,\n id: hab.guid,\n month: hab.month,\n transaction_total: hab.transaction_total ?? 0,\n user_guid: hab.user_guid,\n year: hab.year,\n year_month: hab.year_month,\n})\n\n// groups accounts by account type\n// returns array of account groups, each with an icon, localized name, and the grouped accounts\nexport const groupAccounts = (\n accounts: FinancialAccount[],\n accountTypes: AccountsCopy['account_types'],\n): AccountGroup[] => {\n const groupedAccounts = accounts.reduce<{ [key: number]: FinancialAccount[] }>((acc, account) => {\n const accountType = account.accountType\n if (!acc[accountType]) {\n acc[accountType] = []\n }\n acc[accountType].push(account)\n return acc\n }, {})\n\n return Object.entries(groupedAccounts).map(([accountType, accounts]) => ({\n icon: AccountIconVariants[+accountType] || AccountIcon[+accountType],\n name: accountTypes[+accountType],\n accounts,\n }))\n}\n"],"mappings":";;;;;;AAkBA,IAAM,IAAoB,IAEb,IAAA,CAAkB,GAAqB,MAC3C,EAAS,OAAA,CAAQ,MAAY;AAClC,QAAM,EAAE,WAAA,GAAW,YAAA,GAAY,WAAA,GAAW,WAAA,EAAA,IAA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AAAA,IACvE,MAAM,EAAoB,CAAC,CAAA,KAAgB,EAAY,CAAC,CAAA;AAAA,IACxD,MAAM,EAAa,CAAC,CAAA;AAAA,IACpB,UAAA;AAAA,EACF,EAAE;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TransactionStatus, TransactionType, Category, DetailedAccount, Tag, Tagging, Transaction } from '../types';
|
|
1
|
+
import { TransactionStatus, TransactionType, Category, CategoryCopy, DetailedAccount, Tag, Tagging, Transaction } from '../types';
|
|
2
2
|
import { TransactionFilter } from '../stores/TransactionStore';
|
|
3
3
|
export declare const isTransferTransaction: (transaction: Pick<Transaction, "top_level_category_guid">) => boolean;
|
|
4
|
-
export declare const buildDetailedTransactions: (transactions: Transaction[], accounts: DetailedAccount[], categories: Category[], taggings
|
|
4
|
+
export declare const buildDetailedTransactions: (transactions: Transaction[], accounts: DetailedAccount[], categories: Category[], taggings: Tagging[] | undefined, categoryCopy: CategoryCopy) => {
|
|
5
5
|
account: string;
|
|
6
6
|
accountIsClosed: boolean;
|
|
7
7
|
accountIsHidden: boolean;
|