diff --git a/packages/desktop-client/src/components/reports/ChooseGraph.tsx b/packages/desktop-client/src/components/reports/ChooseGraph.tsx index 2019433b483..2188d075c72 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-ignore import 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.tsx index 2ded9f97d4b..a8dac85fbc4 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.tsx index 6ad6aeede02..26faf6cd888 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.tsx index 02a0c7da9c7..6f34a07b503 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.tsx index 0892c569147..e7c70c88b1f 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.tsx index 3cace4e4d95..683969f3cb5 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.tsx index d087bea38ad..b7f34e1f012 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.tsx index 5a16c916b38..3abe2077530 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; handleScroll: UIEventHandler; diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx index 8d27ccfeb36..ec462b61198 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-ignore import 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.tsx index 63c275a6e29..adf237c4783 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.tsx index 5b396202518..79e89583809 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.ts index b0acf116a48..aacda979984 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.ts index cceded549bb..307dac6b669 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.ts similarity index 51% rename from packages/desktop-client/src/components/reports/entities.d.ts rename to packages/loot-core/src/types/models/reports.d.ts index 753ec938a36..7d15406b0d5 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.md new file mode 100644 index 00000000000..cd2905e18b7 --- /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.