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

Add daily and weekly to custom reports interval list #2483

Merged
merged 46 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f61709e
Button changes and time filters
carkom Feb 21, 2024
8065909
rename on dashboard
carkom Feb 22, 2024
4d4062e
notes
carkom Feb 22, 2024
eeea9d0
fix time filters
carkom Feb 22, 2024
28599fc
Sort Categories
carkom Feb 22, 2024
76b77e1
Page title
carkom Feb 23, 2024
1162dd1
category sort order
carkom Feb 24, 2024
f8cbfb0
move button
carkom Feb 28, 2024
a34caa6
featureflag
carkom Feb 28, 2024
cf51b01
Highlight report name
carkom Feb 28, 2024
73c0a80
sankey fix
carkom Feb 28, 2024
9b51136
Merge branch 'master' into reportUpdates
carkom Feb 28, 2024
01ae841
VRT
carkom Feb 28, 2024
6cb39ea
Merge branch 'master' into reportUpdates
carkom Feb 28, 2024
00e3b5b
remove doubled element
carkom Feb 28, 2024
2dfa64d
Merge remote-tracking branch 'upstream/master' into addYearlyReports
carkom Mar 15, 2024
bd443ff
adjust to match master
carkom Mar 15, 2024
4dfa53f
add Year
carkom Mar 15, 2024
cd4cffb
notes
carkom Mar 15, 2024
6bb5a7e
lint fix
carkom Mar 15, 2024
299c9e9
update names
carkom Mar 18, 2024
1fb6434
IntervalsUpdates
carkom Mar 18, 2024
b8fd126
fixing bugs
carkom Mar 18, 2024
b58ce46
Merge branch 'master' into addYearlyReports
carkom Mar 18, 2024
44731e8
ts updates
carkom Mar 19, 2024
c81b85c
lint fix
carkom Mar 19, 2024
d982bcb
Merge remote-tracking branch 'upstream/master' into addYearlyReports
carkom Mar 20, 2024
19e5b22
merge fixes
carkom Mar 20, 2024
49304c4
Merge branch 'master' into addYearlyReports
carkom Mar 20, 2024
ee4c72d
notes
carkom Mar 20, 2024
5feb103
simplify lookups
carkom Mar 20, 2024
6809407
Add Daily and Weekly
carkom Mar 21, 2024
1a75d1b
notes
carkom Mar 21, 2024
660e077
Merge branch 'master' into addDailyReports
carkom Mar 21, 2024
930145a
notes
carkom Mar 21, 2024
c2ca8b8
Merge branch 'master' into addDailyReports
carkom Apr 4, 2024
7c8ef5b
Merge branch 'master' into addDailyReports
carkom Apr 8, 2024
ad2191d
merge fix
carkom Apr 8, 2024
f92fc4b
TS fix
carkom Apr 8, 2024
65db5fe
Change week start date based on user prefs
carkom Apr 8, 2024
e58afce
fix weeks
carkom Apr 9, 2024
006541d
Merge branch 'master' into addDailyReports
carkom Apr 14, 2024
e256736
fix averages
carkom Apr 14, 2024
fd9517a
remove $week
carkom Apr 15, 2024
6933ef7
remove date-week
carkom Apr 15, 2024
b1cc23d
TS fixes
carkom Apr 15, 2024
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
12 changes: 4 additions & 8 deletions packages/desktop-client/src/components/reports/ChooseGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-strict-ignore
import React, { useRef } from 'react';

import * as monthUtils from 'loot-core/src/shared/months';
import { type GroupedEntity } from 'loot-core/src/types/models/reports';

import { type CSSProperties } from '../../style';
Expand All @@ -20,8 +19,6 @@ import { ReportTableTotals } from './graphs/tableGraph/ReportTableTotals';
import { ReportOptions } from './ReportOptions';

type ChooseGraphProps = {
startDate: string;
endDate: string;
data: GroupedEntity;
mode: string;
graphType: string;
Expand All @@ -34,11 +31,10 @@ type ChooseGraphProps = {
style?: CSSProperties;
showHiddenCategories?: boolean;
showOffBudget?: boolean;
intervalsCount?: number;
};

export function ChooseGraph({
startDate,
endDate,
data,
mode,
graphType,
Expand All @@ -51,8 +47,8 @@ export function ChooseGraph({
style,
showHiddenCategories,
showOffBudget,
intervalsCount,
}: ChooseGraphProps) {
const intervals: string[] = monthUtils.rangeInclusive(startDate, endDate);
const graphStyle = compact ? { ...style } : { flexGrow: 1 };
const balanceTypeOp = ReportOptions.balanceTypeMap.get(balanceType);
const groupByData =
Expand Down Expand Up @@ -166,7 +162,7 @@ export function ChooseGraph({
groupBy={groupBy}
data={data[groupByData]}
mode={mode}
intervalsCount={intervals.length}
intervalsCount={intervalsCount}
compact={compact}
style={rowStyle}
compactStyle={compactStyle}
Expand All @@ -177,7 +173,7 @@ export function ChooseGraph({
data={data}
mode={mode}
balanceTypeOp={balanceTypeOp}
intervalsCount={intervals.length}
intervalsCount={intervalsCount}
compact={compact}
style={rowStyle}
compactStyle={compactStyle}
Expand Down
103 changes: 94 additions & 9 deletions packages/desktop-client/src/components/reports/ReportOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,106 @@ const groupByOptions = [
];

const dateRangeOptions = [
{ description: 'This month', name: 0, Yearly: false, Monthly: true },
{ description: 'Last month', name: 1, Yearly: false, Monthly: true },
{ description: 'Last 3 months', name: 2, Yearly: false, Monthly: true },
{ description: 'Last 6 months', name: 5, Yearly: false, Monthly: true },
{ description: 'Last 12 months', name: 11, Yearly: false, Monthly: true },
{
description: 'This week',
type: 'Weeks',
name: 0,
Yearly: false,
Monthly: false,
Daily: true,
Weekly: true,
},
{
description: 'Last week',
type: 'Weeks',
name: 1,
Yearly: false,
Monthly: false,
Daily: true,
Weekly: true,
},
{
description: 'This month',
type: 'Months',
name: 0,
Yearly: false,
Monthly: true,
Daily: true,
Weekly: true,
},
{
description: 'Last month',
type: 'Months',
name: 1,
Yearly: false,
Monthly: true,
Daily: true,
Weekly: true,
},
{
description: 'Last 3 months',
type: 'Months',
name: 2,
Yearly: false,
Monthly: true,
Daily: true,
Weekly: true,
},
{
description: 'Last 6 months',
type: 'Months',
name: 5,
Yearly: false,
Monthly: true,
Daily: false,
},
{
description: 'Last 12 months',
type: 'Months',
name: 11,
Yearly: false,
Monthly: true,
Daily: false,
},
{
description: 'Year to date',
name: 'yearToDate',
Yearly: true,
Monthly: true,
Daily: true,
Weekly: true,
},
{
description: 'Last year',
name: 'lastYear',
Yearly: true,
Monthly: true,
Daily: true,
Weekly: true,
},
{
description: 'All time',
name: 'allTime',
Yearly: true,
Monthly: true,
Daily: true,
Weekly: true,
},
{ description: 'Last year', name: 'lastYear', Yearly: true, Monthly: true },
{ description: 'All time', name: 'allMonths', Yearly: true, Monthly: true },
];

const intervalOptions = [
//{ value: 1, description: 'Daily', name: 'Day'},
//{ value: 2, description: 'Weekly', name: 'Week'},
{
description: 'Daily',
name: 'Day',
format: 'yyyy-MM-dd',
range: 'dayRangeInclusive',
},
{
description: 'Weekly',
name: 'Week',
format: 'yyyy-MM-dd',
range: 'weekRangeInclusive',
},
//{ value: 3, description: 'Fortnightly', name: 3},
{
description: 'Monthly',
Expand All @@ -88,6 +170,9 @@ export const ReportOptions = {
dateRangeMap: new Map(
dateRangeOptions.map(item => [item.description, item.name]),
),
dateRangeType: new Map(
dateRangeOptions.map(item => [item.description, item.type]),
),
interval: intervalOptions,
intervalMap: new Map(
intervalOptions.map(item => [item.description, item.name]),
Expand Down
12 changes: 9 additions & 3 deletions packages/desktop-client/src/components/reports/ReportSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { View } from '../common/View';
import { Tooltip } from '../tooltips';

import { CategorySelector } from './CategorySelector';
import { defaultsList } from './disabledList';
import { getLiveRange } from './getLiveRange';
import { ModeButton } from './ModeButton';
import { ReportOptions } from './ReportOptions';
Expand Down Expand Up @@ -39,6 +40,7 @@ export function ReportSidebar({
defaultItems,
defaultModeItems,
earliestTransaction,
firstDayOfWeekIdx,
}) {
const [menuOpen, setMenuOpen] = useState(false);
const onSelectRange = cond => {
Expand All @@ -49,7 +51,9 @@ export function ReportSidebar({
);
onReportChange({ type: 'modify' });
setDateRange(cond);
onChangeDates(...getLiveRange(cond, earliestTransaction));
onChangeDates(
...getLiveRange(cond, earliestTransaction, firstDayOfWeekIdx),
);
};

const onChangeMode = cond => {
Expand Down Expand Up @@ -207,7 +211,7 @@ export function ReportSidebar({
.map(int => int.description)
.includes(customReportItems.dateRange)
) {
onSelectRange('Year to date');
onSelectRange(defaultsList.intervalRange.get(e));
}
}}
options={ReportOptions.interval.map(option => [
Expand Down Expand Up @@ -396,7 +400,7 @@ export function ReportSidebar({
options={ReportOptions.dateRange
.filter(f => f[customReportItems.interval])
.map(option => [option.description, option.description])}
line={customReportItems.interval === 'Monthly' && dateRangeLine}
line={dateRangeLine > 0 && dateRangeLine}
twk3 marked this conversation as resolved.
Show resolved Hide resolved
/>
</View>
) : (
Expand All @@ -419,6 +423,7 @@ export function ReportSidebar({
newValue,
customReportItems.endDate,
customReportItems.interval,
firstDayOfWeekIdx,
),
)
}
Expand Down Expand Up @@ -448,6 +453,7 @@ export function ReportSidebar({
customReportItems.startDate,
newValue,
customReportItems.interval,
firstDayOfWeekIdx,
),
)
}
Expand Down
16 changes: 12 additions & 4 deletions packages/desktop-client/src/components/reports/ReportSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ export function ReportSummary({
{monthUtils.format(
startDate,
ReportOptions.intervalFormat.get(interval),
)}{' '}
-{' '}
)}
{monthUtils.format(
endDate,
startDate,
ReportOptions.intervalFormat.get(interval),
)}
) !==
monthUtils.format(
endDate,
ReportOptions.intervalFormat.get(interval),
) &&
' to ' +
monthUtils.format(
endDate,
ReportOptions.intervalFormat.get(interval),
)}
</Text>
</View>
<View
Expand Down
22 changes: 22 additions & 0 deletions packages/desktop-client/src/components/reports/disabledList.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
const intervalOptions = [
{
description: 'Daily',
defaultRange: 'This month',
},
{
description: 'Weekly',
defaultRange: 'Last 3 months',
},
{
description: 'Monthly',
defaultRange: 'Last 6 months',
},
{
description: 'Yearly',
defaultRange: 'Year to date',
},
];

const totalGraphOptions = [
{
description: 'TableGraph',
Expand Down Expand Up @@ -123,4 +142,7 @@ export const defaultsList = {
new Map([...item.graphs].map(f => [f.description, f.defaultType])),
]),
),
intervalRange: new Map(
intervalOptions.map(item => [item.description, item.defaultRange]),
),
};
12 changes: 9 additions & 3 deletions packages/desktop-client/src/components/reports/getLiveRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import * as monthUtils from 'loot-core/src/shared/months';
import { ReportOptions } from './ReportOptions';
import { getSpecificRange, validateRange } from './reportRanges';

export function getLiveRange(cond: string, earliestTransaction: string) {
export function getLiveRange(
cond: string,
earliestTransaction: string,
firstDayOfWeekIdx?: number,
) {
let dateStart;
let dateEnd;
const rangeName = ReportOptions.dateRangeMap.get(cond);
Expand All @@ -25,15 +29,17 @@ export function getLiveRange(cond: string, earliestTransaction: string) {
'-31',
);
break;
case 'allMonths':
case 'allTime':
dateStart = earliestTransaction;
dateEnd = monthUtils.currentDay();
break;
default:
if (typeof rangeName === 'number') {
[dateStart, dateEnd] = getSpecificRange(
rangeName,
cond === 'Last month' ? 0 : null,
cond === 'Last month' || cond === 'Last week' ? 0 : null,
ReportOptions.dateRangeType.get(cond),
firstDayOfWeekIdx,
);
} else {
break;
Expand Down
Loading
Loading