A local-first personal finance app
Custom Reports update entites (#2244)
Neil106dce25dd85
diff --git a/packages/desktop-client/src/components/reports/ChooseGraph.tsx b/packages/desktop-client/src/components/reports/ChooseGraph.tsxindex 2019433b48..2188d075c7 100644--- a/packages/desktop-client/src/components/reports/ChooseGraph.tsx+++ b/packages/desktop-client/src/components/reports/ChooseGraph.tsx@@ -1,9 +1,13 @@// @ts-strict-ignoreimport React, { useRef } from 'react';+import {+ type GroupedEntity,+ type Month,+} from 'loot-core/src/types/models/reports';+import { View } from '../common/View';-import { type DataEntity, type Month } from './entities';import { AreaGraph } from './graphs/AreaGraph';import { BarGraph } from './graphs/BarGraph';import { BarLineGraph } from './graphs/BarLineGraph';@@ -16,7 +20,7 @@ import { ReportTableTotals } from './graphs/tableGraph/ReportTableTotals';import { ReportOptions } from './ReportOptions';type ChooseGraphProps = {- data: DataEntity;+ data: GroupedEntity;mode: string;graphType: string;balanceType: string;diff --git a/packages/desktop-client/src/components/reports/ReportSummary.tsx b/packages/desktop-client/src/components/reports/ReportSummary.tsxindex 2ded9f97d4..a8dac85fbc 100644--- a/packages/desktop-client/src/components/reports/ReportSummary.tsx+++ b/packages/desktop-client/src/components/reports/ReportSummary.tsx@@ -7,18 +7,17 @@ import {integerToCurrency,amountToInteger,} from 'loot-core/src/shared/util';+import { type GroupedEntity } from 'loot-core/src/types/models/reports';import { theme, styles } from '../../style';import { Text } from '../common/Text';import { View } from '../common/View';import { PrivacyFilter } from '../PrivacyFilter';-import { type DataEntity } from './entities';-type ReportSummaryProps = {startDate: string;endDate: string;- data: DataEntity;+ data: GroupedEntity;balanceTypeOp: string;monthsCount: number;};diff --git a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsxindex 6ad6aeede0..26faf6cd88 100644--- a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx+++ b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx@@ -18,13 +18,13 @@ import {amountToCurrency,amountToCurrencyNoDecimal,} from 'loot-core/src/shared/util';+import { type GroupedEntity } from 'loot-core/src/types/models/reports';import { theme } from '../../../style';import { type CSSProperties } from '../../../style';import { AlignedText } from '../../common/AlignedText';import { PrivacyFilter } from '../../PrivacyFilter';import { Container } from '../Container';-import { type DataEntity } from '../entities';import { numberFormatterTooltip } from '../numberFormatter';import { adjustTextSize } from './adjustTextSize';@@ -114,7 +114,7 @@ const customLabel = (props, width, end) => {type AreaGraphProps = {style?: CSSProperties;- data: DataEntity;+ data: GroupedEntity;balanceTypeOp: string;compact?: boolean;viewLabels: boolean;diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsxindex 02a0c7da9c..6f34a07b50 100644--- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx+++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx@@ -20,13 +20,13 @@ import {amountToCurrency,amountToCurrencyNoDecimal,} from 'loot-core/src/shared/util';+import { type GroupedEntity } from 'loot-core/src/types/models/reports';import { theme } from '../../../style';import { type CSSProperties } from '../../../style';import { AlignedText } from '../../common/AlignedText';import { PrivacyFilter } from '../../PrivacyFilter';import { Container } from '../Container';-import { type DataEntity } from '../entities';import { getCustomTick } from '../getCustomTick';import { numberFormatterTooltip } from '../numberFormatter';@@ -127,7 +127,7 @@ const customLabel = props => {type BarGraphProps = {style?: CSSProperties;- data: DataEntity;+ data: GroupedEntity;groupBy: string;balanceTypeOp: string;compact?: boolean;diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsxindex 0892c56914..e7c70c88b1 100644--- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx+++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx@@ -4,10 +4,10 @@ import React, { useState } from 'react';import { PieChart, Pie, Cell, Sector, ResponsiveContainer } from 'recharts';import { amountToCurrency } from 'loot-core/src/shared/util';+import { type GroupedEntity } from 'loot-core/src/types/models/reports';import { theme, type CSSProperties } from '../../../style';import { Container } from '../Container';-import { type DataEntity } from '../entities';import { adjustTextSize } from './adjustTextSize';import { renderCustomLabel } from './renderCustomLabel';@@ -118,7 +118,7 @@ const customLabel = props => {type DonutGraphProps = {style?: CSSProperties;- data: DataEntity;+ data: GroupedEntity;groupBy: string;balanceTypeOp: string;compact?: boolean;diff --git a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsxindex 3cace4e4d9..683969f3cb 100644--- a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx+++ b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx@@ -18,13 +18,13 @@ import {amountToCurrency,amountToCurrencyNoDecimal,} from 'loot-core/src/shared/util';+import { type GroupedEntity } from 'loot-core/src/types/models/reports';import { theme } from '../../../style';import { type CSSProperties } from '../../../style';import { AlignedText } from '../../common/AlignedText';import { PrivacyFilter } from '../../PrivacyFilter';import { Container } from '../Container';-import { type DataEntity } from '../entities';import { getCustomTick } from '../getCustomTick';import { numberFormatterTooltip } from '../numberFormatter';@@ -122,7 +122,7 @@ const customLabel = props => {type StackedBarGraphProps = {style?: CSSProperties;- data: DataEntity;+ data: GroupedEntity;compact?: boolean;viewLabels: boolean;};diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsxindex d087bea38a..b7f34e1f01 100644--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx@@ -7,10 +7,11 @@ import React, {} from 'react';import { type RefProp } from 'react-spring';+import { type DataEntity } from 'loot-core/src/types/models/reports';+import { type CSSProperties } from '../../../../style';import { Block } from '../../../common/Block';import { View } from '../../../common/View';-import { type GroupedEntity } from '../../entities';import { ReportTableList } from './ReportTableList';import { ReportTableRow } from './ReportTableRow';@@ -22,7 +23,7 @@ type ReportTableProps = {style?: CSSProperties;groupBy: string;balanceTypeOp: 'totalDebts' | 'totalTotals' | 'totalAssets';- data: GroupedEntity[];+ data: DataEntity[];mode: string;monthsCount: number;};diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableHeader.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableHeader.tsxindex 5a16c916b3..3abe207753 100644--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableHeader.tsx+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableHeader.tsx@@ -2,15 +2,16 @@import React, { type UIEventHandler } from 'react';import { type RefProp } from 'react-spring';+import { type DataEntity } from 'loot-core/src/types/models/reports';+import { styles, theme } from '../../../../style';import { View } from '../../../common/View';import { Row, Cell } from '../../../table';-import { type GroupedEntity } from '../../entities';type ReportTableHeaderProps = {scrollWidth?: number;groupBy: string;- interval?: GroupedEntity[];+ interval?: DataEntity[];balanceType: string;headerScrollRef: RefProp<HTMLDivElement>;handleScroll: UIEventHandler<HTMLDivElement>;diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsxindex 8d27ccfeb3..ec462b6119 100644--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx@@ -1,13 +1,14 @@// @ts-strict-ignoreimport React from 'react';+import { type DataEntity } from 'loot-core/src/types/models/reports';+import { type CSSProperties, theme } from '../../../../style';import { View } from '../../../common/View';import { Cell, Row } from '../../../table';-import { type GroupedEntity } from '../../entities';type ReportTableListProps = {- data: GroupedEntity[];+ data: DataEntity[];mode?: string;monthsCount?: number;groupBy: string;diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsxindex 63c275a6e2..adf237c478 100644--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx@@ -5,13 +5,13 @@ import {amountToInteger,integerToCurrency,} from 'loot-core/src/shared/util';+import { type DataEntity } from 'loot-core/src/types/models/reports';import { type CSSProperties, styles, theme } from '../../../../style';import { Row, Cell } from '../../../table';-import { type GroupedEntity } from '../../entities';type ReportTableRowProps = {- item: GroupedEntity;+ item: DataEntity;balanceTypeOp: 'totalAssets' | 'totalDebts' | 'totalTotals';groupByItem: 'id' | 'name';mode: string;diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableTotals.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableTotals.tsxindex 5b39620251..79e8958380 100644--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableTotals.tsx+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableTotals.tsx@@ -7,14 +7,14 @@ import {amountToInteger,integerToCurrency,} from 'loot-core/src/shared/util';+import { type GroupedEntity } from 'loot-core/src/types/models/reports';import { styles, theme } from '../../../../style';import { View } from '../../../common/View';import { Row, Cell } from '../../../table';-import { type DataEntity } from '../../entities';type ReportTableTotalsProps = {- data: DataEntity;+ data: GroupedEntity;scrollWidth?: number;balanceTypeOp: string;mode: string;diff --git a/packages/desktop-client/src/components/reports/spreadsheets/calculateLegend.ts b/packages/desktop-client/src/components/reports/spreadsheets/calculateLegend.tsindex b0acf116a4..aacda97998 100644--- a/packages/desktop-client/src/components/reports/spreadsheets/calculateLegend.ts+++ b/packages/desktop-client/src/components/reports/spreadsheets/calculateLegend.ts@@ -1,7 +1,11 @@// @ts-strict-ignore+import {+ type ItemEntity,+ type MonthData,+} from 'loot-core/src/types/models/reports';+import { theme } from '../../../style';import { getColorScale } from '../chart-theme';-import { type ItemEntity, type MonthData } from '../entities';export function calculateLegend(monthData: MonthData[],diff --git a/packages/loot-core/src/types/models/index.d.ts b/packages/loot-core/src/types/models/index.d.tsindex cceded549b..307dac6b66 100644--- a/packages/loot-core/src/types/models/index.d.ts+++ b/packages/loot-core/src/types/models/index.d.ts@@ -3,6 +3,7 @@ export type * from './category';export type * from './category-group';export type * from './gocardless';export type * from './payee';+export type * from './reports';export type * from './rule';export type * from './schedule';export type * from './transaction';diff --git a/packages/desktop-client/src/components/reports/entities.d.ts b/packages/loot-core/src/types/models/reports.d.tssimilarity index 51%rename from packages/desktop-client/src/components/reports/entities.d.tsrename to packages/loot-core/src/types/models/reports.d.tsindex 753ec938a3..7d15406b0d 100644--- a/packages/desktop-client/src/components/reports/entities.d.ts+++ b/packages/loot-core/src/types/models/reports.d.ts@@ -1,14 +1,36 @@-export type DataEntity = {- data: GroupedEntity[];- monthData: GroupedEntity[];- groupedData: GroupedEntity[];+import { type RuleConditionEntity } from './rule';++export interface CustomReportEntity {+ reportId?: string;+ mode: string;+ groupBy: string;+ balanceType: string;+ showEmpty: boolean;+ showOffBudgetHidden: boolean;+ showUncategorized: boolean;+ graphType: string;+ selectedCategories;+ filters: RuleConditionEntity;+ conditionsOp: string;+ name: string;+ startDate: string;+ endDate: string;+ isDateStatic: boolean;+ data: GroupedEntity;+ tombstone?: boolean;+}++export interface GroupedEntity {+ data: DataEntity[];+ monthData: DataEntity[];+ groupedData: DataEntity[];legend: LegendEntity[];startDate: string;endDate: string;totalDebts: number;totalAssets: number;totalTotals: number;-};+}type LegendEntity = {name: string;@@ -31,7 +53,7 @@ export type MonthData = {totalTotals: number;};-export type GroupedEntity = {+export interface DataEntity {id: string;name: string;date?: string;@@ -40,7 +62,7 @@ export type GroupedEntity = {totalAssets: number;totalDebts: number;totalTotals: number;-};+}export type Month = {month: string;diff --git a/upcoming-release-notes/2244.md b/upcoming-release-notes/2244.mdnew file mode 100644index 0000000000..cd2905e18b--- /dev/null+++ b/upcoming-release-notes/2244.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [carkom]+---++Moving entities and updating existing for custom reports. Also creating a new entity for the custom report data.