diff --git a/packages/desktop-client/src/components/reports/ChooseGraph.tsx b/packages/desktop-client/src/components/reports/ChooseGraph.tsx index b195b7eecfe84229efe0ed52d396c88662acf611..bf5dec7b05ab3cd4e496fede7e597df5c16ef7b3 100644 --- a/packages/desktop-client/src/components/reports/ChooseGraph.tsx +++ b/packages/desktop-client/src/components/reports/ChooseGraph.tsx @@ -48,7 +48,9 @@ export function ChooseGraph({ showOffBudget = false, intervalsCount, }: ChooseGraphProps) { - const graphStyle = compact ? { ...style } : { flexGrow: 1 }; + const graphStyle = compact + ? { ...style } + : { flexGrow: 1, overflow: 'hidden' }; const balanceTypeOp = ReportOptions.balanceTypeMap.get(balanceType) || 'totalDebts'; @@ -147,6 +149,7 @@ export function ChooseGraph({ balanceTypeOp={balanceTypeOp} showHiddenCategories={showHiddenCategories} showOffBudget={showOffBudget} + interval={interval} /> ); } @@ -162,6 +165,7 @@ export function ChooseGraph({ groupBy={groupBy} showHiddenCategories={showHiddenCategories} showOffBudget={showOffBudget} + interval={interval} /> ); } diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts index 0ae9c6b0a5222ec7cd688d8a3ba9914c1c41c742..53f0b3bb775bab9ff03e4966348e7abe392d4686 100644 --- a/packages/desktop-client/src/components/reports/ReportOptions.ts +++ b/packages/desktop-client/src/components/reports/ReportOptions.ts @@ -121,7 +121,7 @@ const dateRangeOptions: dateRangeProps[] = [ { description: 'Year to date', name: 'yearToDate', - Daily: true, + Daily: false, Weekly: true, Monthly: true, Yearly: true, @@ -129,7 +129,7 @@ const dateRangeOptions: dateRangeProps[] = [ { description: 'Last year', name: 'lastYear', - Daily: true, + Daily: false, Weekly: true, Monthly: true, Yearly: true, @@ -137,7 +137,7 @@ const dateRangeOptions: dateRangeProps[] = [ { description: 'All time', name: 'allTime', - Daily: true, + Daily: false, Weekly: true, Monthly: true, Yearly: true, diff --git a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx index 94999532993d28e75121443e67c9b1a0872ae95e..03a5934b332a38b2da0570f10e444422479e1138 100644 --- a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx @@ -206,7 +206,7 @@ export function AreaGraph({ top: 0, right: labelsMargin, left: leftMargin, - bottom: 0, + bottom: 10, }} > {compact ? null : ( diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx index 6b455cf2346c782b7b5bf220c57b6c7f093f54ff..e6f1a0a6eb25b4cd8fb8fe92875cf5b47cdee7cc 100644 --- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx @@ -36,6 +36,7 @@ import { numberFormatterTooltip } from '../numberFormatter'; import { adjustTextSize } from './adjustTextSize'; import { renderCustomLabel } from './renderCustomLabel'; +import { showActivity } from './showActivity'; type PayloadChild = { props: { @@ -183,61 +184,6 @@ export function BarGraph({ const leftMargin = Math.abs(largestValue) > 1000000 ? 20 : 0; - const onShowActivity = item => { - const amount = balanceTypeOp === 'totalDebts' ? 'lte' : 'gte'; - const field = groupBy === 'Interval' ? null : groupBy.toLowerCase(); - const hiddenCategories = categories.list - .filter(f => f.hidden) - .map(e => e.id); - const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id); - - const conditions = [ - ...filters, - { field, op: 'is', value: item.id, type: 'id' }, - { - field: 'date', - op: 'gte', - value: data.startDate, - options: { date: true }, - type: 'date', - }, - { - field: 'date', - op: 'lte', - value: data.endDate, - options: { date: true }, - type: 'date', - }, - balanceTypeOp !== 'totalTotals' && { - field: 'amount', - op: amount, - value: 0, - type: 'number', - }, - hiddenCategories.length > 0 && - !showHiddenCategories && { - field: 'category', - op: 'notOneOf', - value: hiddenCategories, - type: 'id', - }, - offBudgetAccounts.length > 0 && - !showOffBudget && { - field: 'account', - op: 'notOneOf', - value: offBudgetAccounts, - type: 'id', - }, - ].filter(f => f); - navigate('/accounts', { - state: { - goBack: true, - conditions, - categoryId: item.id, - }, - }); - }; - return ( <Container style={{ @@ -309,10 +255,23 @@ export function BarGraph({ !['Group', 'Interval'].includes(groupBy) && setPointer('pointer') } - onClick={ + onClick={item => !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && - onShowActivity + showActivity({ + navigate, + categories, + accounts, + balanceTypeOp, + filters, + showHiddenCategories, + showOffBudget, + type: 'totals', + startDate: data.startDate, + endDate: data.endDate, + field: groupBy.toLowerCase(), + id: item.id, + }) } > {viewLabels && !compact && ( diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx index 7267f49b791e5e0884f0f5c2a275b1e21993c981..3eab0f182d4993fe9d3cabf2574313a4317569e0 100644 --- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx @@ -17,6 +17,7 @@ import { Container } from '../Container'; import { adjustTextSize } from './adjustTextSize'; import { renderCustomLabel } from './renderCustomLabel'; +import { showActivity } from './showActivity'; const RADIAN = Math.PI / 180; @@ -207,61 +208,6 @@ export function DonutGraph({ const { isNarrowWidth } = useResponsive(); const [pointer, setPointer] = useState(''); - const onShowActivity = item => { - const amount = balanceTypeOp === 'totalDebts' ? 'lte' : 'gte'; - const field = groupBy === 'Interval' ? null : groupBy.toLowerCase(); - const hiddenCategories = categories.list - .filter(f => f.hidden) - .map(e => e.id); - const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id); - - const conditions = [ - ...filters, - { field, op: 'is', value: item.id, type: 'id' }, - { - field: 'date', - op: 'gte', - value: data.startDate, - options: { date: true }, - type: 'date', - }, - { - field: 'date', - op: 'lte', - value: data.endDate, - options: { date: true }, - type: 'date', - }, - balanceTypeOp !== 'totalTotals' && { - field: 'amount', - op: amount, - value: 0, - type: 'number', - }, - hiddenCategories.length > 0 && - !showHiddenCategories && { - field: 'category', - op: 'notOneOf', - value: hiddenCategories, - type: 'id', - }, - offBudgetAccounts.length > 0 && - !showOffBudget && { - field: 'account', - op: 'notOneOf', - value: offBudgetAccounts, - type: 'id', - }, - ].filter(f => f); - navigate('/accounts', { - state: { - goBack: true, - conditions, - categoryId: item.id, - }, - }); - }; - const getVal = obj => { if (balanceTypeOp === 'totalDebts') { return -1 * obj[balanceTypeOp]; @@ -309,10 +255,23 @@ export function DonutGraph({ setPointer('pointer'); } }} - onClick={ + onClick={item => !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && - onShowActivity + showActivity({ + navigate, + categories, + accounts, + balanceTypeOp, + filters, + showHiddenCategories, + showOffBudget, + type: 'totals', + startDate: data.startDate, + endDate: data.endDate, + field: groupBy.toLowerCase(), + id: item.id, + }) } > {data.legend.map((entry, index) => ( diff --git a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx index 15577b4e95229e6447de1202a8b60fafff70e884..d47575f88b9adf09a0c37f909990f51bd62a5408 100644 --- a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx @@ -31,6 +31,8 @@ import { Container } from '../Container'; import { getCustomTick } from '../getCustomTick'; import { numberFormatterTooltip } from '../numberFormatter'; +import { showActivity } from './showActivity'; + type PayloadItem = { dataKey: string; value: number; @@ -116,6 +118,7 @@ type LineGraphProps = { balanceTypeOp: 'totalAssets' | 'totalDebts' | 'totalTotals'; showHiddenCategories?: boolean; showOffBudget?: boolean; + interval?: string; }; export function LineGraph({ @@ -127,6 +130,7 @@ export function LineGraph({ balanceTypeOp, showHiddenCategories, showOffBudget, + interval, }: LineGraphProps) { const navigate = useNavigate(); const categories = useCategories(); @@ -143,49 +147,20 @@ export function LineGraph({ const leftMargin = Math.abs(largestValue) > 1000000 ? 20 : 5; const onShowActivity = (item, id, payload) => { - const amount = balanceTypeOp === 'totalDebts' ? 'lte' : 'gte'; - const field = groupBy === 'Interval' ? null : groupBy.toLowerCase(); - const hiddenCategories = categories.list - .filter(f => f.hidden) - .map(e => e.id); - const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id); - - const conditions = [ - ...filters, - { field, op: 'is', value: id, type: 'id' }, - { - field: 'date', - op: 'is', - value: payload.payload.dateStart, - options: { date: true }, - }, - balanceTypeOp !== 'totalTotals' && { - field: 'amount', - op: amount, - value: 0, - type: 'number', - }, - hiddenCategories.length > 0 && - !showHiddenCategories && { - field: 'category', - op: 'notOneOf', - value: hiddenCategories, - type: 'id', - }, - offBudgetAccounts.length > 0 && - !showOffBudget && { - field: 'account', - op: 'notOneOf', - value: offBudgetAccounts, - type: 'id', - }, - ].filter(f => f); - navigate('/accounts', { - state: { - goBack: true, - conditions, - categoryId: item.id, - }, + showActivity({ + navigate, + categories, + accounts, + balanceTypeOp, + filters, + showHiddenCategories, + showOffBudget, + type: 'time', + startDate: payload.payload.intervalStartDate, + endDate: payload.payload.intervalEndDate, + field: groupBy.toLowerCase(), + id, + interval, }); }; diff --git a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx index f2c2807eb1dcb7601e941f64fabea8df17a319bb..81463d147d85cdffe1bb60aaecb6e2e7b89a0683 100644 --- a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx @@ -33,6 +33,7 @@ import { getCustomTick } from '../getCustomTick'; import { numberFormatterTooltip } from '../numberFormatter'; import { renderCustomLabel } from './renderCustomLabel'; +import { showActivity } from './showActivity'; type PayloadItem = { name: string; @@ -146,6 +147,7 @@ type StackedBarGraphProps = { balanceTypeOp: 'totalAssets' | 'totalDebts' | 'totalTotals'; showHiddenCategories?: boolean; showOffBudget?: boolean; + interval?: string; }; export function StackedBarGraph({ @@ -158,6 +160,7 @@ export function StackedBarGraph({ balanceTypeOp, showHiddenCategories, showOffBudget, + interval, }: StackedBarGraphProps) { const navigate = useNavigate(); const categories = useCategories(); @@ -173,53 +176,6 @@ export function StackedBarGraph({ const leftMargin = Math.abs(largestValue) > 1000000 ? 20 : 0; - const onShowActivity = (item, id) => { - const amount = balanceTypeOp === 'totalDebts' ? 'lte' : 'gte'; - const field = groupBy === 'Interval' ? null : groupBy.toLowerCase(); - const hiddenCategories = categories.list - .filter(f => f.hidden) - .map(e => e.id); - const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id); - - const conditions = [ - ...filters, - { field, op: 'is', value: id, type: 'id' }, - { - field: 'date', - op: 'is', - value: item.dateStart, - options: { date: true }, - }, - balanceTypeOp !== 'totalTotals' && { - field: 'amount', - op: amount, - value: 0, - type: 'number', - }, - hiddenCategories.length > 0 && - !showHiddenCategories && { - field: 'category', - op: 'notOneOf', - value: hiddenCategories, - type: 'id', - }, - offBudgetAccounts.length > 0 && - !showOffBudget && { - field: 'account', - op: 'notOneOf', - value: offBudgetAccounts, - type: 'id', - }, - ].filter(f => f); - navigate('/accounts', { - state: { - goBack: true, - conditions, - categoryId: item.id, - }, - }); - }; - return ( <Container style={{ @@ -236,7 +192,7 @@ export function StackedBarGraph({ width={width} height={height} data={data.intervalData} - margin={{ top: 0, right: 0, left: leftMargin, bottom: 0 }} + margin={{ top: 0, right: 0, left: leftMargin, bottom: 10 }} style={{ cursor: pointer }} > {(!isNarrowWidth || !compact) && ( @@ -297,7 +253,21 @@ export function StackedBarGraph({ onClick={e => !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && - onShowActivity(e, entry.id) + showActivity({ + navigate, + categories, + accounts, + balanceTypeOp, + filters, + showHiddenCategories, + showOffBudget, + type: 'time', + startDate: e.intervalStartDate, + endDate: e.intervalEndDate, + field: groupBy.toLowerCase(), + id: entry.id, + interval, + }) } > {viewLabels && !compact && ( diff --git a/packages/desktop-client/src/components/reports/graphs/showActivity.ts b/packages/desktop-client/src/components/reports/graphs/showActivity.ts index fdbe64f82682a7115f4b9257572afeaddb98f2fb..892664b8126caf67a0d38bfba5b551418cfb3a26 100644 --- a/packages/desktop-client/src/components/reports/graphs/showActivity.ts +++ b/packages/desktop-client/src/components/reports/graphs/showActivity.ts @@ -1,10 +1,13 @@ import { type NavigateFunction } from 'react-router-dom'; +import * as monthUtils from 'loot-core/src/shared/months'; import { type AccountEntity } from 'loot-core/types/models/account'; import { type CategoryEntity } from 'loot-core/types/models/category'; import { type CategoryGroupEntity } from 'loot-core/types/models/category-group'; import { type RuleConditionEntity } from 'loot-core/types/models/rule'; +import { ReportOptions } from '../ReportOptions'; + type showActivityProps = { navigate: NavigateFunction; categories: { list: CategoryEntity[]; grouped: CategoryGroupEntity[] }; @@ -18,6 +21,7 @@ type showActivityProps = { endDate?: string; field?: string; id?: string; + interval?: string; }; export function showActivity({ @@ -33,22 +37,29 @@ export function showActivity({ endDate, field, id, + interval = 'Day', }: showActivityProps) { - const amount = - balanceTypeOp === 'totalDebts' || type === 'debts' ? 'lte' : 'gte'; + const isOutFlow = + balanceTypeOp === 'totalDebts' || type === 'debts' ? true : false; const hiddenCategories = categories.list.filter(f => f.hidden).map(e => e.id); const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id); + const fromDate = + interval === 'Weekly' + ? 'dayFromDate' + : (((ReportOptions.intervalMap.get(interval) || 'Day').toLowerCase() + + 'FromDate') as 'dayFromDate' | 'monthFromDate' | 'yearFromDate'); + const isDateOp = interval === 'Weekly' || type !== 'time'; const conditions = [ ...filters, id && { field, op: 'is', value: id, type: 'id' }, { field: 'date', - op: type === 'time' ? 'is' : 'gte', - value: startDate, - options: { date: true }, + op: isDateOp ? 'gte' : 'is', + value: isDateOp ? startDate : monthUtils[fromDate](startDate), + type: 'date', }, - type !== 'time' && { + isDateOp && { field: 'date', op: 'lte', value: endDate, @@ -59,9 +70,13 @@ export function showActivity({ (type === 'totals' || type === 'time') ) && { field: 'amount', - op: amount, + op: 'gte', value: 0, - type: 'number', + options: { + type: 'number', + inflow: !isOutFlow, + outflow: isOutFlow, + }, }, hiddenCategories.length > 0 && !showHiddenCategories && { 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 78882fc98bce72ae78f4f021b31cdb07ccbe4cc8..0da32fb5ce4acfb0586d05588d77d6bbea183455 100644 --- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx +++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx @@ -98,6 +98,7 @@ export function ReportTable({ compactStyle={compactStyle} showHiddenCategories={showHiddenCategories} showOffBudget={showOffBudget} + interval={interval} /> ); }, []); @@ -129,6 +130,7 @@ export function ReportTable({ totalScrollRef={totalScrollRef} handleScroll={handleScroll} height={32 + scrollWidthTotals} + interval={interval} /> ); }, 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 cf3de8cf15d17c9f6cf08bb99fc131e73e67df64..57aec0d235ba12ba47922f4c2c363359e98be7f5 100644 --- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx +++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx @@ -32,6 +32,7 @@ type ReportTableRowProps = { totalStyle?: CSSProperties; showHiddenCategories?: boolean; showOffBudget?: boolean; + interval: string; totalScrollRef?: RefObject<HTMLDivElement>; handleScroll?: UIEventHandler<HTMLDivElement>; height?: number; @@ -56,6 +57,7 @@ export const ReportTableRow = memo( totalScrollRef, handleScroll, height, + interval, }: ReportTableRowProps) => { const average = amountToInteger(item[balanceTypeOp]) / intervalsCount; const groupByItem = groupBy === 'Interval' ? 'date' : 'name'; @@ -68,6 +70,7 @@ export const ReportTableRow = memo( const pointer = !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && + !compact && !categories.grouped.map(g => g.id).includes(item.id) ? 'pointer' : 'inherit'; @@ -75,6 +78,7 @@ export const ReportTableRow = memo( const hoverUnderline = !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && + !compact && !categories.grouped.map(g => g.id).includes(item.id) ? { cursor: pointer, @@ -132,6 +136,7 @@ export const ReportTableRow = memo( onClick={() => !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && + !compact && !categories.grouped.map(g => g.id).includes(item.id) && showActivity({ navigate, @@ -143,8 +148,10 @@ export const ReportTableRow = memo( showOffBudget, type: 'time', startDate: intervalItem.intervalStartDate || '', + endDate: intervalItem.intervalEndDate || '', field: groupBy.toLowerCase(), id: item.id, + interval, }) } width="flex" @@ -171,6 +178,7 @@ export const ReportTableRow = memo( onClick={() => !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && + !compact && !categories.grouped.map(g => g.id).includes(item.id) && showActivity({ navigate, @@ -205,6 +213,7 @@ export const ReportTableRow = memo( onClick={() => !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && + !compact && !categories.grouped.map(g => g.id).includes(item.id) && showActivity({ navigate, @@ -240,6 +249,7 @@ export const ReportTableRow = memo( onClick={() => !isNarrowWidth && !['Group', 'Interval'].includes(groupBy) && + !compact && !categories.grouped.map(g => g.id).includes(item.id) && showActivity({ navigate, diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx index ce952a89c6363f290f4ddabf6830c0e4a5763bb8..10a1f870c6f5fecf9be654848b66473853ba1d88 100644 --- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx +++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx @@ -124,8 +124,10 @@ export function CustomReport() { const [dateRange, setDateRange] = useState(loadReport.dateRange); const [dataCheck, setDataCheck] = useState(false); const dateRangeLine = - ReportOptions.dateRange.filter(f => f[interval as keyof dateRangeProps]) - .length - 3; + interval === 'Daily' + ? 0 + : ReportOptions.dateRange.filter(f => f[interval as keyof dateRangeProps]) + .length - 3; const [intervals, setIntervals] = useState( monthUtils.rangeInclusive(startDate, endDate), diff --git a/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts index ab8b3a0e11fe42e4b5ad6e61956aa1aef61aa4d0..0ad83924bf9d4542c523ec9fc615e62b9e0f5ce9 100644 --- a/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts +++ b/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts @@ -155,7 +155,7 @@ export function createCustomSpreadsheet({ let totalDebts = 0; const intervalData = intervals.reduce( - (arr: IntervalEntity[], intervalItem) => { + (arr: IntervalEntity[], intervalItem, index) => { let perIntervalAssets = 0; let perIntervalDebts = 0; const stacked: Record<string, number> = {}; @@ -214,7 +214,11 @@ export function createCustomSpreadsheet({ ReportOptions.intervalFormat.get(interval) || '', ), ...stacked, - intervalStartDate: intervalItem, + intervalStartDate: index === 0 ? startDate : intervalItem, + intervalEndDate: + index + 1 === intervals.length + ? endDate + : monthUtils.subDays(intervals[index + 1], 1), totalDebts: integerToAmount(perIntervalDebts), totalAssets: integerToAmount(perIntervalAssets), totalTotals: integerToAmount(perIntervalDebts + perIntervalAssets), @@ -235,6 +239,8 @@ export function createCustomSpreadsheet({ showOffBudget, showHiddenCategories, showUncategorized, + startDate, + endDate, }); return { ...calc }; }); diff --git a/packages/desktop-client/src/components/reports/spreadsheets/grouped-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/grouped-spreadsheet.ts index 170cc421316248f90d715fd648ddf17ba32b369b..ed3048d291d245501d28c844c3f847c595610e22 100644 --- a/packages/desktop-client/src/components/reports/spreadsheets/grouped-spreadsheet.ts +++ b/packages/desktop-client/src/components/reports/spreadsheets/grouped-spreadsheet.ts @@ -180,6 +180,8 @@ export function createGroupedSpreadsheet({ showOffBudget, showHiddenCategories, showUncategorized, + startDate, + endDate, }); return { ...calc }; }); diff --git a/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts b/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts index a01332e4b94db79d636f13cd5b7943d579155808..3f4bc44b7b488dbe772107e09e3995f1ef69ac6a 100644 --- a/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts +++ b/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts @@ -1,3 +1,4 @@ +import * as monthUtils from 'loot-core/src/shared/months'; import { amountToInteger, integerToAmount } from 'loot-core/src/shared/util'; import { type GroupedEntity, @@ -20,6 +21,8 @@ type recalculateProps = { showOffBudget?: boolean; showHiddenCategories?: boolean; showUncategorized?: boolean; + startDate: string; + endDate: string; }; export function recalculate({ @@ -31,11 +34,13 @@ export function recalculate({ showOffBudget, showHiddenCategories, showUncategorized, + startDate, + endDate, }: recalculateProps): GroupedEntity { let totalAssets = 0; let totalDebts = 0; const intervalData = intervals.reduce( - (arr: IntervalEntity[], intervalItem) => { + (arr: IntervalEntity[], intervalItem, index) => { const last = arr.length === 0 ? null : arr[arr.length - 1]; const intervalAssets = filterHiddenItems( @@ -77,7 +82,11 @@ export function recalculate({ totalDebts: integerToAmount(intervalDebts), totalTotals: integerToAmount(intervalAssets + intervalDebts), change, - intervalStartDate: intervalItem, + intervalStartDate: index === 0 ? startDate : intervalItem, + intervalEndDate: + index + 1 === intervals.length + ? endDate + : monthUtils.subDays(intervals[index + 1], 1), }); return arr; diff --git a/packages/loot-core/src/types/models/reports.d.ts b/packages/loot-core/src/types/models/reports.d.ts index ca893d5f140480c922daba1669a054c04412021c..eccc1c79f99816f76cce4fc98f042110a5c87324 100644 --- a/packages/loot-core/src/types/models/reports.d.ts +++ b/packages/loot-core/src/types/models/reports.d.ts @@ -79,6 +79,7 @@ export type IntervalEntity = { date?: string; change?: number; intervalStartDate?: string; + intervalEndDate?: string; totalAssets: number; totalDebts: number; totalTotals: number; diff --git a/upcoming-release-notes/2785.md b/upcoming-release-notes/2785.md new file mode 100644 index 0000000000000000000000000000000000000000..7b7979ac19d694d945f7b8e317014ad804041118 --- /dev/null +++ b/upcoming-release-notes/2785.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [carkom] +--- + +Hardens "showActivity" elements of custom reports, switched to "inflow/outflow" filters. Fixes issue with weekly show activity clicks not filtering dates correctly.