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

Renaming variables for reports files #2069

Merged
merged 13 commits into from
Dec 12, 2023
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
Expand Up @@ -21,7 +21,7 @@ type ChooseGraphProps = {
graphType: string;
balanceType: string;
groupBy: string;
empty: boolean;
showEmpty: boolean;
scrollWidth: number;
setScrollWidth: (value: number) => void;
months: Month[];
Expand All @@ -32,7 +32,7 @@ export function ChooseGraph({
graphType,
balanceType,
groupBy,
empty,
showEmpty,
scrollWidth,
setScrollWidth,
months,
Expand Down Expand Up @@ -104,7 +104,7 @@ export function ChooseGraph({
>
<ReportTableList
data={data}
empty={empty}
empty={showEmpty}
monthsCount={months.length}
balanceTypeOp={ReportOptions.balanceTypeMap.get(balanceType)}
mode={mode}
Expand Down
13 changes: 7 additions & 6 deletions packages/desktop-client/src/components/reports/ReportOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
} from 'loot-core/src/types/models';

const balanceTypeOptions = [
{ description: 'Expense', format: 'totalDebts' },
{ description: 'Income', format: 'totalAssets' },
{ description: 'Payment', format: 'totalDebts' },
{ description: 'Deposit', format: 'totalAssets' },
{ description: 'Net', format: 'totalTotals' },
];

Expand All @@ -21,10 +21,11 @@ const groupByOptions = [
];

const dateRangeOptions = [
{ description: '1 month', name: 1 },
{ description: '3 months', name: 2 },
{ description: '6 months', name: 5 },
{ description: '1 year', name: 11 },
{ description: 'This month', name: 0 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ question: ‏is this actually correct?

If I open the page on 2nd of January: will it show only 2 days worth of data (1st - 2nd Jan)? Or would it show the last ~30 days?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's by month where monthDiff = 0. So it would show only 2 days. I plan to add an interval selector where you can view data by day or week or year etc. At that point, I'll also add new range options (based on which interval you select) like "last 30 days", "last 7 days", "this week", "last week", etc.

{ description: 'Last month', name: 1 },
{ description: 'Last 3 months', name: 2 },
{ description: 'Last 6 months', name: 5 },
{ description: 'Last 12 months', name: 11 },
{ description: 'Year to date', name: 'yearToDate' },
{ description: 'Last year', name: 'lastYear' },
{ description: 'All time', name: 'allMonths' },
Expand Down
48 changes: 24 additions & 24 deletions packages/desktop-client/src/components/reports/ReportSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function ModeButton({ selected, children, style, onSelect }) {
}

export function ReportSidebar({
start,
end,
startDate,
endDate,
onChangeDates,
dateRange,
setDateRange,
Expand All @@ -64,12 +64,12 @@ export function ReportSidebar({
setBalanceType,
mode,
setMode,
empty,
setEmpty,
hidden,
setHidden,
uncat,
setUncat,
showEmpty,
setShowEmpty,
showOffBudgetHidden,
setShowOffBudgetHidden,
showUncategorized,
setShowUncategorized,
categories,
selectedCategories,
setSelectedCategories,
Expand Down Expand Up @@ -114,7 +114,7 @@ export function ReportSidebar({
} else {
setTypeDisabled(['Net']);
if (['Net'].includes(balanceType)) {
setBalanceType('Expense');
setBalanceType('Payment');
}
}
if (graphType === 'BarGraph') {
Expand Down Expand Up @@ -144,7 +144,7 @@ export function ReportSidebar({
}
}
if (['Net'].includes(balanceType) && graphType !== 'TableGraph') {
setBalanceType('Expense');
setBalanceType('Payment');
}
};

Expand Down Expand Up @@ -274,9 +274,9 @@ export function ReportSidebar({

<Checkbox
id="show-empty-columns"
checked={empty}
value={empty}
onChange={() => setEmpty(!empty)}
checked={showEmpty}
value={showEmpty}
onChange={() => setShowEmpty(!showEmpty)}
/>
<label
htmlFor="show-empty-columns"
Expand All @@ -297,9 +297,9 @@ export function ReportSidebar({

<Checkbox
id="show-hidden-columns"
checked={hidden}
value={hidden}
onChange={() => setHidden(!hidden)}
checked={showOffBudgetHidden}
value={showOffBudgetHidden}
onChange={() => setShowOffBudgetHidden(!showOffBudgetHidden)}
/>
<label
htmlFor="show-hidden-columns"
Expand All @@ -320,9 +320,9 @@ export function ReportSidebar({

<Checkbox
id="show-uncategorized"
checked={uncat}
value={uncat}
onChange={() => setUncat(!uncat)}
checked={showUncategorized}
value={showUncategorized}
onChange={() => setShowUncategorized(!showUncategorized)}
/>
<label
htmlFor="show-uncategorized"
Expand Down Expand Up @@ -387,10 +387,10 @@ export function ReportSidebar({
</Text>
<Select
onChange={newValue =>
onChangeDates(...validateStart(allMonths, newValue, end))
onChangeDates(...validateStart(allMonths, newValue, endDate))
}
value={start}
defaultLabel={monthUtils.format(start, 'MMMM, yyyy')}
value={startDate}
defaultLabel={monthUtils.format(startDate, 'MMMM, yyyy')}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
/>
</View>
Expand All @@ -406,9 +406,9 @@ export function ReportSidebar({
</Text>
<Select
onChange={newValue =>
onChangeDates(...validateEnd(allMonths, start, newValue))
onChangeDates(...validateEnd(allMonths, startDate, newValue))
}
value={end}
value={endDate}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
/>
</View>
Expand Down
17 changes: 10 additions & 7 deletions packages/desktop-client/src/components/reports/ReportSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import View from '../common/View';
import PrivacyFilter from '../PrivacyFilter';

export function ReportSummary({
start,
end,
startDate,
endDate,
data,
balanceTypeOp,
monthsCount,
}) {
const net = data.totalDebts > data.totalAssets ? 'EXPENSE' : 'INCOME';
const net =
Math.abs(data.totalDebts) > Math.abs(data.totalAssets)
? 'PAYMENT'
: 'DEPOSIT';
const average = amountToInteger(data[balanceTypeOp]) / monthsCount;
return (
<View
Expand All @@ -46,8 +49,8 @@ export function ReportSummary({
},
]}
>
{monthUtils.format(start, 'MMM yyyy')} -{' '}
{monthUtils.format(end, 'MMM yyyy')}
{monthUtils.format(startDate, 'MMM yyyy')} -{' '}
{monthUtils.format(endDate, 'MMM yyyy')}
</Text>
</View>
<View
Expand All @@ -72,7 +75,7 @@ export function ReportSummary({
{balanceTypeOp === 'totalDebts'
? 'TOTAL SPENDING'
: balanceTypeOp === 'totalAssets'
? 'TOTAL INCOME'
? 'TOTAL DEPOSITS'
: 'NET ' + net}
</Text>
<Text
Expand Down Expand Up @@ -113,7 +116,7 @@ export function ReportSummary({
{balanceTypeOp === 'totalDebts'
? 'AVERAGE SPENDING'
: balanceTypeOp === 'totalAssets'
? 'AVERAGE INCOME'
? 'AVERAGE DEPOSIT'
: 'AVERAGE NET'}
</Text>
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ export default function ReportTableHeader({
minWidth: 85,
...styles.tnum,
}}
value={'Assets'}
value={'Deposits'}
width="flex"
/>
<Cell
style={{
minWidth: 85,
...styles.tnum,
}}
value={'Debts'}
value={'Payments'}
width="flex"
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ export function ReportTopbar({
if (mode === 'total') {
setGraphType('BarGraph');
if (['Net'].includes(balanceType)) {
setBalanceType('Expense');
setBalanceType('Payment');
}
setTypeDisabled(['Month', 'Year'].includes(groupBy) ? [] : ['Net']);
} else {
setGraphType('StackedBarGraph');
setTypeDisabled(['Net']);
setBalanceType('Expense');
setBalanceType('Payment');
}
}}
style={{ marginRight: 15 }}
Expand All @@ -92,7 +92,7 @@ export function ReportTopbar({
onSelect={() => {
setGraphType('DonutGraph');
setTypeDisabled(['Net']);
setBalanceType('Expense');
setBalanceType('Payment');
}}
style={{ marginRight: 15 }}
disabled={mode === 'total' ? false : true}
Expand Down
Loading