Skip to content

Commit

Permalink
Renaming variables for reports files (#2069)
Browse files Browse the repository at this point in the history
* work

* notes

* error fixes

* updates

* card fix

* fix filters

* splitting PR work

* notes

* fixes

* lint fix

* Update upcoming-release-notes/2069.md

Co-authored-by: Matiss Janis Aboltins <[email protected]>

---------

Co-authored-by: Matiss Janis Aboltins <[email protected]>
  • Loading branch information
carkom and MatissJanis authored Dec 12, 2023
1 parent 36914ab commit 8a721bf
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 148 deletions.
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 },
{ 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

0 comments on commit 8a721bf

Please sign in to comment.