diff --git a/packages/desktop-client/src/components/reports/Custom.js b/packages/desktop-client/src/components/reports/Custom.js index a3b48d90b2d..95dbe8e16a9 100644 --- a/packages/desktop-client/src/components/reports/Custom.js +++ b/packages/desktop-client/src/components/reports/Custom.js @@ -5,7 +5,7 @@ import * as d from 'date-fns'; import { send } from 'loot-core/src/platform/client/fetch'; import * as monthUtils from 'loot-core/src/shared/months'; -import { integerToCurrency } from 'loot-core/src/shared/util'; +import { amountToCurrency } from 'loot-core/src/shared/util'; import useCategories from '../../hooks/useCategories'; import useFilters from '../../hooks/useFilters'; @@ -16,6 +16,8 @@ import ChartPie from '../../icons/v1/ChartPie'; import InboxFull from '../../icons/v1/InboxFull'; import ListBullet from '../../icons/v1/ListBullet'; import { theme, styles } from '../../style'; +import AlignedText from '../common/AlignedText'; +import Block from '../common/Block'; import Button from '../common/Button'; import Select from '../common/Select'; import Text from '../common/Text'; @@ -24,7 +26,6 @@ import { FilterButton, AppliedFilters } from '../filters/FiltersMenu'; import { Checkbox } from '../forms'; import PrivacyFilter from '../PrivacyFilter'; -import Change from './Change'; import AreaGraph from './graphs/AreaGraph'; import BarGraph from './graphs/BarGraph'; import BarLineGraph from './graphs/BarLineGraph'; @@ -108,7 +109,7 @@ export default function Custom() { const [allMonths, setAllMonths] = useState(null); const [start, setStart] = useState( - monthUtils.subMonths(monthUtils.currentMonth(), 5), + monthUtils.subMonths(monthUtils.currentMonth(), 1), ); const [end, setEnd] = useState(monthUtils.currentMonth()); @@ -135,8 +136,19 @@ export default function Custom() { accounts, filters, conditionsOp, + hidden, ); - }, [start, end, split, categories, payees, accounts, filters, conditionsOp]); + }, [ + start, + end, + split, + categories, + payees, + accounts, + filters, + conditionsOp, + hidden, + ]); const data = useReport('default', getGraphData); useEffect(() => { @@ -762,31 +774,6 @@ export default function Custom() { flexGrow: 1, }} > - {graphType !== 'TableGraph' && ( - - - - {integerToCurrency(0)} - - - - - - - )} + {graphType !== 'TableGraph' && ( + + + + { + typeOptions.find(opt => opt.value === type) + .description + } + : + + } + right={ + + + {amountToCurrency( + Math.abs( + data[ + typeOptions.find(opt => opt.value === type) + .format + ], + ), + )} + + + } + /> + + + )} {(viewSplit || viewSummary) && ( diff --git a/packages/desktop-client/src/components/reports/Overview.js b/packages/desktop-client/src/components/reports/Overview.js index a5af1a432ae..be6ef57517e 100644 --- a/packages/desktop-client/src/components/reports/Overview.js +++ b/packages/desktop-client/src/components/reports/Overview.js @@ -156,6 +156,7 @@ function CashFlowCard() { const params = useMemo(() => simpleCashFlow(start, end), [start, end]); const data = useReport('cash_flow_simple', params); + const [isCardHovered, setIsCardHovered] = useState(false); const onCardHover = useCallback(() => setIsCardHovered(true)); const onCardHoverEnd = useCallback(() => setIsCardHovered(false)); @@ -359,11 +360,12 @@ function CustomReportsCard() { ) : ( @@ -396,32 +398,16 @@ export default function Overview() { - - {categorySpendingReportFeatureFlag && ( - - -
-
- - )} - - {customReportsFeatureFlag && ( - - -
-
- - )} + + {categorySpendingReportFeatureFlag && } + {customReportsFeatureFlag && } +
+ ); } diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx index 6d8f871a0f7..030cb4587ab 100644 --- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx @@ -184,7 +184,7 @@ function BarGraph({ } margin={{ top: 0, right: 0, left: 0, bottom: 0 }} > - } /> + {compact ? null : } />} } formatter={numberFormatterTooltip} @@ -199,7 +199,11 @@ function BarGraph({ .map((entry, index) => ( ))} diff --git a/packages/desktop-client/src/components/reports/spreadsheets/default-spreadsheet.tsx b/packages/desktop-client/src/components/reports/spreadsheets/default-spreadsheet.tsx index 1329b3d8d65..5e083435561 100644 --- a/packages/desktop-client/src/components/reports/spreadsheets/default-spreadsheet.tsx +++ b/packages/desktop-client/src/components/reports/spreadsheets/default-spreadsheet.tsx @@ -20,6 +20,7 @@ export default function createSpreadsheet( accounts, conditions = [], conditionsOp, + hidden, ) { let splitItem; let splitList; @@ -73,17 +74,27 @@ export default function createSpreadsheet( let [starting, balances] = await Promise.all([ runQuery( q('transactions') + .filter( + !hidden && { + $and: [ + { + 'account.offbudget': false, + 'category.hidden': false, + }, + ], + $or: [ + { + 'payee.transfer_acct.offbudget': true, + 'payee.transfer_acct': null, + }, + ], + }, + ) .filter({ - [conditionsOpKey]: filters, [splitLabel]: splt.id, - 'account.offbudget': false, - 'category.hidden': false, - date: { $lt: start + '-01' }, - $or: [ - { - 'payee.transfer_acct.offbudget': true, - 'payee.transfer_acct': null, - }, + $and: [ + { [conditionsOpKey]: filters }, + { date: { $lt: start + '-01' } }, ], }) .calculate({ $sum: '$amount' }), @@ -91,23 +102,29 @@ export default function createSpreadsheet( runQuery( q('transactions') - .filter({ - [conditionsOpKey]: [...filters], - }) + .filter( + !hidden && { + $and: [ + { + 'account.offbudget': false, + 'category.hidden': false, + }, + ], + $or: [ + { + 'payee.transfer_acct.offbudget': true, + 'payee.transfer_acct': null, + }, + ], + }, + ) .filter({ [splitLabel]: splt.id, - 'account.offbudget': false, - 'category.hidden': false, $and: [ + { [conditionsOpKey]: filters }, { date: { $gte: start + '-01' } }, { date: { $lte: end + '-31' } }, ], - $or: [ - { - 'payee.transfer_acct.offbudget': true, - 'payee.transfer_acct': null, - }, - ], }) .groupBy({ $month: '$date' }) .select([