Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Reports update entites #2244

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -114,7 +114,7 @@ const customLabel = (props, width, end) => {

type AreaGraphProps = {
style?: CSSProperties;
data: DataEntity;
data: GroupedEntity;
balanceTypeOp: string;
compact?: boolean;
viewLabels: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -127,7 +127,7 @@ const customLabel = props => {

type BarGraphProps = {
style?: CSSProperties;
data: DataEntity;
data: GroupedEntity;
groupBy: string;
balanceTypeOp: string;
compact?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -118,7 +118,7 @@ const customLabel = props => {

type DonutGraphProps = {
style?: CSSProperties;
data: DataEntity;
data: GroupedEntity;
groupBy: string;
balanceTypeOp: string;
compact?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -122,7 +122,7 @@ const customLabel = props => {

type StackedBarGraphProps = {
style?: CSSProperties;
data: DataEntity;
data: GroupedEntity;
compact?: boolean;
viewLabels: boolean;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -22,7 +23,7 @@ type ReportTableProps = {
style?: CSSProperties;
groupBy: string;
balanceTypeOp: 'totalDebts' | 'totalTotals' | 'totalAssets';
data: GroupedEntity[];
data: DataEntity[];
mode: string;
monthsCount: number;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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[],
Expand Down
1 change: 1 addition & 0 deletions packages/loot-core/src/types/models/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -31,7 +53,7 @@ export type MonthData = {
totalTotals: number;
};

export type GroupedEntity = {
export interface DataEntity {
id: string;
name: string;
date?: string;
Expand All @@ -40,7 +62,7 @@ export type GroupedEntity = {
totalAssets: number;
totalDebts: number;
totalTotals: number;
};
}

export type Month = {
month: string;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2244.md
Original file line number Diff line number Diff line change
@@ -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.