Skip to content
Snippets Groups Projects
Unverified Commit 106dce25 authored by Neil's avatar Neil Committed by GitHub
Browse files

Custom Reports update entites (#2244)

* work

* notes

* missing entity

* lint
parent ff113991
No related branches found
No related tags found
No related merge requests found
Showing
with 70 additions and 31 deletions
// @ts-strict-ignore // @ts-strict-ignore
import React, { useRef } from 'react'; import React, { useRef } from 'react';
import {
type GroupedEntity,
type Month,
} from 'loot-core/src/types/models/reports';
import { View } from '../common/View'; import { View } from '../common/View';
import { type DataEntity, type Month } from './entities';
import { AreaGraph } from './graphs/AreaGraph'; import { AreaGraph } from './graphs/AreaGraph';
import { BarGraph } from './graphs/BarGraph'; import { BarGraph } from './graphs/BarGraph';
import { BarLineGraph } from './graphs/BarLineGraph'; import { BarLineGraph } from './graphs/BarLineGraph';
...@@ -16,7 +20,7 @@ import { ReportTableTotals } from './graphs/tableGraph/ReportTableTotals'; ...@@ -16,7 +20,7 @@ import { ReportTableTotals } from './graphs/tableGraph/ReportTableTotals';
import { ReportOptions } from './ReportOptions'; import { ReportOptions } from './ReportOptions';
type ChooseGraphProps = { type ChooseGraphProps = {
data: DataEntity; data: GroupedEntity;
mode: string; mode: string;
graphType: string; graphType: string;
balanceType: string; balanceType: string;
......
...@@ -7,18 +7,17 @@ import { ...@@ -7,18 +7,17 @@ import {
integerToCurrency, integerToCurrency,
amountToInteger, amountToInteger,
} from 'loot-core/src/shared/util'; } from 'loot-core/src/shared/util';
import { type GroupedEntity } from 'loot-core/src/types/models/reports';
import { theme, styles } from '../../style'; import { theme, styles } from '../../style';
import { Text } from '../common/Text'; import { Text } from '../common/Text';
import { View } from '../common/View'; import { View } from '../common/View';
import { PrivacyFilter } from '../PrivacyFilter'; import { PrivacyFilter } from '../PrivacyFilter';
import { type DataEntity } from './entities';
type ReportSummaryProps = { type ReportSummaryProps = {
startDate: string; startDate: string;
endDate: string; endDate: string;
data: DataEntity; data: GroupedEntity;
balanceTypeOp: string; balanceTypeOp: string;
monthsCount: number; monthsCount: number;
}; };
......
...@@ -18,13 +18,13 @@ import { ...@@ -18,13 +18,13 @@ import {
amountToCurrency, amountToCurrency,
amountToCurrencyNoDecimal, amountToCurrencyNoDecimal,
} from 'loot-core/src/shared/util'; } from 'loot-core/src/shared/util';
import { type GroupedEntity } from 'loot-core/src/types/models/reports';
import { theme } from '../../../style'; import { theme } from '../../../style';
import { type CSSProperties } from '../../../style'; import { type CSSProperties } from '../../../style';
import { AlignedText } from '../../common/AlignedText'; import { AlignedText } from '../../common/AlignedText';
import { PrivacyFilter } from '../../PrivacyFilter'; import { PrivacyFilter } from '../../PrivacyFilter';
import { Container } from '../Container'; import { Container } from '../Container';
import { type DataEntity } from '../entities';
import { numberFormatterTooltip } from '../numberFormatter'; import { numberFormatterTooltip } from '../numberFormatter';
import { adjustTextSize } from './adjustTextSize'; import { adjustTextSize } from './adjustTextSize';
...@@ -114,7 +114,7 @@ const customLabel = (props, width, end) => { ...@@ -114,7 +114,7 @@ const customLabel = (props, width, end) => {
type AreaGraphProps = { type AreaGraphProps = {
style?: CSSProperties; style?: CSSProperties;
data: DataEntity; data: GroupedEntity;
balanceTypeOp: string; balanceTypeOp: string;
compact?: boolean; compact?: boolean;
viewLabels: boolean; viewLabels: boolean;
......
...@@ -20,13 +20,13 @@ import { ...@@ -20,13 +20,13 @@ import {
amountToCurrency, amountToCurrency,
amountToCurrencyNoDecimal, amountToCurrencyNoDecimal,
} from 'loot-core/src/shared/util'; } from 'loot-core/src/shared/util';
import { type GroupedEntity } from 'loot-core/src/types/models/reports';
import { theme } from '../../../style'; import { theme } from '../../../style';
import { type CSSProperties } from '../../../style'; import { type CSSProperties } from '../../../style';
import { AlignedText } from '../../common/AlignedText'; import { AlignedText } from '../../common/AlignedText';
import { PrivacyFilter } from '../../PrivacyFilter'; import { PrivacyFilter } from '../../PrivacyFilter';
import { Container } from '../Container'; import { Container } from '../Container';
import { type DataEntity } from '../entities';
import { getCustomTick } from '../getCustomTick'; import { getCustomTick } from '../getCustomTick';
import { numberFormatterTooltip } from '../numberFormatter'; import { numberFormatterTooltip } from '../numberFormatter';
...@@ -127,7 +127,7 @@ const customLabel = props => { ...@@ -127,7 +127,7 @@ const customLabel = props => {
type BarGraphProps = { type BarGraphProps = {
style?: CSSProperties; style?: CSSProperties;
data: DataEntity; data: GroupedEntity;
groupBy: string; groupBy: string;
balanceTypeOp: string; balanceTypeOp: string;
compact?: boolean; compact?: boolean;
......
...@@ -4,10 +4,10 @@ import React, { useState } from 'react'; ...@@ -4,10 +4,10 @@ import React, { useState } from 'react';
import { PieChart, Pie, Cell, Sector, ResponsiveContainer } from 'recharts'; import { PieChart, Pie, Cell, Sector, ResponsiveContainer } from 'recharts';
import { amountToCurrency } from 'loot-core/src/shared/util'; 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 { theme, type CSSProperties } from '../../../style';
import { Container } from '../Container'; import { Container } from '../Container';
import { type DataEntity } from '../entities';
import { adjustTextSize } from './adjustTextSize'; import { adjustTextSize } from './adjustTextSize';
import { renderCustomLabel } from './renderCustomLabel'; import { renderCustomLabel } from './renderCustomLabel';
...@@ -118,7 +118,7 @@ const customLabel = props => { ...@@ -118,7 +118,7 @@ const customLabel = props => {
type DonutGraphProps = { type DonutGraphProps = {
style?: CSSProperties; style?: CSSProperties;
data: DataEntity; data: GroupedEntity;
groupBy: string; groupBy: string;
balanceTypeOp: string; balanceTypeOp: string;
compact?: boolean; compact?: boolean;
......
...@@ -18,13 +18,13 @@ import { ...@@ -18,13 +18,13 @@ import {
amountToCurrency, amountToCurrency,
amountToCurrencyNoDecimal, amountToCurrencyNoDecimal,
} from 'loot-core/src/shared/util'; } from 'loot-core/src/shared/util';
import { type GroupedEntity } from 'loot-core/src/types/models/reports';
import { theme } from '../../../style'; import { theme } from '../../../style';
import { type CSSProperties } from '../../../style'; import { type CSSProperties } from '../../../style';
import { AlignedText } from '../../common/AlignedText'; import { AlignedText } from '../../common/AlignedText';
import { PrivacyFilter } from '../../PrivacyFilter'; import { PrivacyFilter } from '../../PrivacyFilter';
import { Container } from '../Container'; import { Container } from '../Container';
import { type DataEntity } from '../entities';
import { getCustomTick } from '../getCustomTick'; import { getCustomTick } from '../getCustomTick';
import { numberFormatterTooltip } from '../numberFormatter'; import { numberFormatterTooltip } from '../numberFormatter';
...@@ -122,7 +122,7 @@ const customLabel = props => { ...@@ -122,7 +122,7 @@ const customLabel = props => {
type StackedBarGraphProps = { type StackedBarGraphProps = {
style?: CSSProperties; style?: CSSProperties;
data: DataEntity; data: GroupedEntity;
compact?: boolean; compact?: boolean;
viewLabels: boolean; viewLabels: boolean;
}; };
......
...@@ -7,10 +7,11 @@ import React, { ...@@ -7,10 +7,11 @@ import React, {
} from 'react'; } from 'react';
import { type RefProp } from 'react-spring'; import { type RefProp } from 'react-spring';
import { type DataEntity } from 'loot-core/src/types/models/reports';
import { type CSSProperties } from '../../../../style'; import { type CSSProperties } from '../../../../style';
import { Block } from '../../../common/Block'; import { Block } from '../../../common/Block';
import { View } from '../../../common/View'; import { View } from '../../../common/View';
import { type GroupedEntity } from '../../entities';
import { ReportTableList } from './ReportTableList'; import { ReportTableList } from './ReportTableList';
import { ReportTableRow } from './ReportTableRow'; import { ReportTableRow } from './ReportTableRow';
...@@ -22,7 +23,7 @@ type ReportTableProps = { ...@@ -22,7 +23,7 @@ type ReportTableProps = {
style?: CSSProperties; style?: CSSProperties;
groupBy: string; groupBy: string;
balanceTypeOp: 'totalDebts' | 'totalTotals' | 'totalAssets'; balanceTypeOp: 'totalDebts' | 'totalTotals' | 'totalAssets';
data: GroupedEntity[]; data: DataEntity[];
mode: string; mode: string;
monthsCount: number; monthsCount: number;
}; };
......
...@@ -2,15 +2,16 @@ ...@@ -2,15 +2,16 @@
import React, { type UIEventHandler } from 'react'; import React, { type UIEventHandler } from 'react';
import { type RefProp } from 'react-spring'; import { type RefProp } from 'react-spring';
import { type DataEntity } from 'loot-core/src/types/models/reports';
import { styles, theme } from '../../../../style'; import { styles, theme } from '../../../../style';
import { View } from '../../../common/View'; import { View } from '../../../common/View';
import { Row, Cell } from '../../../table'; import { Row, Cell } from '../../../table';
import { type GroupedEntity } from '../../entities';
type ReportTableHeaderProps = { type ReportTableHeaderProps = {
scrollWidth?: number; scrollWidth?: number;
groupBy: string; groupBy: string;
interval?: GroupedEntity[]; interval?: DataEntity[];
balanceType: string; balanceType: string;
headerScrollRef: RefProp<HTMLDivElement>; headerScrollRef: RefProp<HTMLDivElement>;
handleScroll: UIEventHandler<HTMLDivElement>; handleScroll: UIEventHandler<HTMLDivElement>;
......
// @ts-strict-ignore // @ts-strict-ignore
import React from 'react'; import React from 'react';
import { type DataEntity } from 'loot-core/src/types/models/reports';
import { type CSSProperties, theme } from '../../../../style'; import { type CSSProperties, theme } from '../../../../style';
import { View } from '../../../common/View'; import { View } from '../../../common/View';
import { Cell, Row } from '../../../table'; import { Cell, Row } from '../../../table';
import { type GroupedEntity } from '../../entities';
type ReportTableListProps = { type ReportTableListProps = {
data: GroupedEntity[]; data: DataEntity[];
mode?: string; mode?: string;
monthsCount?: number; monthsCount?: number;
groupBy: string; groupBy: string;
......
...@@ -5,13 +5,13 @@ import { ...@@ -5,13 +5,13 @@ import {
amountToInteger, amountToInteger,
integerToCurrency, integerToCurrency,
} from 'loot-core/src/shared/util'; } from 'loot-core/src/shared/util';
import { type DataEntity } from 'loot-core/src/types/models/reports';
import { type CSSProperties, styles, theme } from '../../../../style'; import { type CSSProperties, styles, theme } from '../../../../style';
import { Row, Cell } from '../../../table'; import { Row, Cell } from '../../../table';
import { type GroupedEntity } from '../../entities';
type ReportTableRowProps = { type ReportTableRowProps = {
item: GroupedEntity; item: DataEntity;
balanceTypeOp: 'totalAssets' | 'totalDebts' | 'totalTotals'; balanceTypeOp: 'totalAssets' | 'totalDebts' | 'totalTotals';
groupByItem: 'id' | 'name'; groupByItem: 'id' | 'name';
mode: string; mode: string;
......
...@@ -7,14 +7,14 @@ import { ...@@ -7,14 +7,14 @@ import {
amountToInteger, amountToInteger,
integerToCurrency, integerToCurrency,
} from 'loot-core/src/shared/util'; } from 'loot-core/src/shared/util';
import { type GroupedEntity } from 'loot-core/src/types/models/reports';
import { styles, theme } from '../../../../style'; import { styles, theme } from '../../../../style';
import { View } from '../../../common/View'; import { View } from '../../../common/View';
import { Row, Cell } from '../../../table'; import { Row, Cell } from '../../../table';
import { type DataEntity } from '../../entities';
type ReportTableTotalsProps = { type ReportTableTotalsProps = {
data: DataEntity; data: GroupedEntity;
scrollWidth?: number; scrollWidth?: number;
balanceTypeOp: string; balanceTypeOp: string;
mode: string; mode: string;
......
// @ts-strict-ignore // @ts-strict-ignore
import {
type ItemEntity,
type MonthData,
} from 'loot-core/src/types/models/reports';
import { theme } from '../../../style'; import { theme } from '../../../style';
import { getColorScale } from '../chart-theme'; import { getColorScale } from '../chart-theme';
import { type ItemEntity, type MonthData } from '../entities';
export function calculateLegend( export function calculateLegend(
monthData: MonthData[], monthData: MonthData[],
......
...@@ -3,6 +3,7 @@ export type * from './category'; ...@@ -3,6 +3,7 @@ export type * from './category';
export type * from './category-group'; export type * from './category-group';
export type * from './gocardless'; export type * from './gocardless';
export type * from './payee'; export type * from './payee';
export type * from './reports';
export type * from './rule'; export type * from './rule';
export type * from './schedule'; export type * from './schedule';
export type * from './transaction'; export type * from './transaction';
......
export type DataEntity = { import { type RuleConditionEntity } from './rule';
data: GroupedEntity[];
monthData: GroupedEntity[]; export interface CustomReportEntity {
groupedData: GroupedEntity[]; 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[]; legend: LegendEntity[];
startDate: string; startDate: string;
endDate: string; endDate: string;
totalDebts: number; totalDebts: number;
totalAssets: number; totalAssets: number;
totalTotals: number; totalTotals: number;
}; }
type LegendEntity = { type LegendEntity = {
name: string; name: string;
...@@ -31,7 +53,7 @@ export type MonthData = { ...@@ -31,7 +53,7 @@ export type MonthData = {
totalTotals: number; totalTotals: number;
}; };
export type GroupedEntity = { export interface DataEntity {
id: string; id: string;
name: string; name: string;
date?: string; date?: string;
...@@ -40,7 +62,7 @@ export type GroupedEntity = { ...@@ -40,7 +62,7 @@ export type GroupedEntity = {
totalAssets: number; totalAssets: number;
totalDebts: number; totalDebts: number;
totalTotals: number; totalTotals: number;
}; }
export type Month = { export type Month = {
month: string; month: string;
......
---
category: Maintenance
authors: [carkom]
---
Moving entities and updating existing for custom reports. Also creating a new entity for the custom report data.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment