diff --git a/packages/desktop-client/src/components/reports/ChooseGraph.tsx b/packages/desktop-client/src/components/reports/ChooseGraph.tsx index 2019433b4831e307ac0e14db371ca3e9ecd1a1b1..2188d075c724a8c7dd53484322539046d99b3931 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 2ded9f97d4be80677c87e55d6e88e8fda691e964..a8dac85fbc4bfa8ce33e39ff1383e7e163bc958f 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 6ad6aeede02d21a27fb650884f0b031a46907226..26faf6cd888d1945bfa8c80c05700b4867517cc9 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 02a0c7da9c73f8c02c1448c169572477a16e6fc7..6f34a07b5039f59fc0941a010abfb87fa861da02 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 0892c5691478378186649f784a154c4893b006b1..e7c70c88b1f149f5be98497a5fe66d9e8f46e275 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 3cace4e4d95982cbaf317bca8dc6d3d5b6038f3f..683969f3cb514ed655b262de4d2908c09f79006f 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 d087bea38ad489021941b0528c35a0082d35fea4..b7f34e1f012ca3dae2a367af9d474785edcac743 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 5a16c916b384e94331c8c639d74397d0f4954507..3abe2077530a26bc0af8ae1ca71808bba9aa8282 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.tsx index 8d27ccfeb3675d79dca75b37d1e0a6c971d1c2f3..ec462b61198c118e6ee28b05168a4c7f00c157df 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 63c275a6e29efab4b4e88427c43c389473510134..adf237c47837541aa33db364d4b09d2589aaabac 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 5b396202518973c253497f8979b3cd72ca126bde..79e89583809a8c9e926fcab4e656bf124ea25e57 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 b0acf116a48ddd979ac93c5c397b1535428b2405..aacda979984e43a0e065aa3e6ba8a7da350a1ba4 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 cceded549bb3ba14036754fd91f980192288af88..307dac6b6694be18d11b674e10c8698b95dbe91c 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 753ec938a36a037a8efb2b4e26df39303f661831..7d15406b0d5e9760b5d67b8854d7ed7f5a926973 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 0000000000000000000000000000000000000000..cd2905e18b7d0e0bb8fd057d4e0219e9b677a233 --- /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.