A local-first personal finance app
fix report date dropdowns not including current period (#5981)
Matt Fiddaman9dd0284e31a4
diff --git a/packages/desktop-client/src/components/reports/reports/Calendar.tsx b/packages/desktop-client/src/components/reports/reports/Calendar.tsxindex ac63244721..248f18a338 100644--- a/packages/desktop-client/src/components/reports/reports/Calendar.tsx+++ b/packages/desktop-client/src/components/reports/reports/Calendar.tsx@@ -273,12 +273,17 @@ function CalendarInner({ widget, parameters }: CalendarInnerProps) {parseISO(fromDateRepr(earliestTransaction.date)),): currentMonth;- const latestMonth = latestTransaction+ const latestTransactionMonth = latestTransaction? monthUtils.monthFromDate(parseISO(fromDateRepr(latestTransaction.date)),): currentMonth;+ const latestMonth =+ latestTransactionMonth > currentMonth+ ? latestTransactionMonth+ : currentMonth;+// Make sure the month selects are at least populates with a// year's worth of months. We can undo this when we have fancier// date selects.diff --git a/packages/desktop-client/src/components/reports/reports/CashFlow.tsx b/packages/desktop-client/src/components/reports/reports/CashFlow.tsxindex 530a59cdaf..4a928dda90 100644--- a/packages/desktop-client/src/components/reports/reports/CashFlow.tsx+++ b/packages/desktop-client/src/components/reports/reports/CashFlow.tsx@@ -136,12 +136,18 @@ function CashFlowInner({ widget }: CashFlowInnerProps) {latestTransaction ? latestTransaction.date : monthUtils.currentDay(),);+ const currentMonth = monthUtils.currentMonth();const earliestMonth = earliestTransaction? monthUtils.monthFromDate(d.parseISO(earliestTransaction.date))- : monthUtils.currentMonth();- const latestMonth = latestTransaction+ : currentMonth;+ const latestTransactionMonth = latestTransaction? monthUtils.monthFromDate(d.parseISO(latestTransaction.date))- : monthUtils.currentMonth();+ : currentMonth;++ const latestMonth =+ latestTransactionMonth > currentMonth+ ? latestTransactionMonth+ : currentMonth;const allMonths = monthUtils.rangeInclusive(earliestMonth, latestMonth)diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsxindex eba1135bb0..066e9c9932 100644--- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx@@ -341,16 +341,28 @@ function CustomReportInner({ report: initialReport }: CustomReportInnerProps) {),);+ const currentInterval =+ interval === 'Weekly'+ ? monthUtils.currentWeek(firstDayOfWeekIdx)+ : interval === 'Daily'+ ? monthUtils.currentDay()+ : interval === 'Yearly'+ ? monthUtils.currentYear()+ : monthUtils.currentMonth();++ const maxInterval =+ latestInterval > currentInterval ? latestInterval : currentInterval;+const allIntervals =interval === 'Weekly'? monthUtils.weekRangeInclusive(earliestInterval,- latestInterval,+ maxInterval,firstDayOfWeekIdx,): monthUtils[ReportOptions.intervalRange.get(interval) || 'rangeInclusive'- ](earliestInterval, latestInterval);+ ](earliestInterval, maxInterval);const allIntervalsMap = allIntervals.map((inter: string) => ({diff --git a/packages/desktop-client/src/components/reports/reports/NetWorth.tsx b/packages/desktop-client/src/components/reports/reports/NetWorth.tsxindex 21c93b3ad9..228de29249 100644--- a/packages/desktop-client/src/components/reports/reports/NetWorth.tsx+++ b/packages/desktop-client/src/components/reports/reports/NetWorth.tsx@@ -141,12 +141,17 @@ function NetWorthInner({ widget }: NetWorthInnerProps) {d.parseISO(fromDateRepr(earliestTransaction.date)),): currentMonth;- const latestMonth = latestTransaction+ const latestTransactionMonth = latestTransaction? monthUtils.monthFromDate(d.parseISO(fromDateRepr(latestTransaction.date)),): currentMonth;+ const latestMonth =+ latestTransactionMonth > currentMonth+ ? latestTransactionMonth+ : currentMonth;+// Make sure the month selects are at least populates with a// year's worth of months. We can undo this when we have fancier// date selects.diff --git a/packages/desktop-client/src/components/reports/reports/Spending.tsx b/packages/desktop-client/src/components/reports/reports/Spending.tsxindex f795857be9..85ec631b1d 100644--- a/packages/desktop-client/src/components/reports/reports/Spending.tsx+++ b/packages/desktop-client/src/components/reports/reports/Spending.tsx@@ -107,10 +107,15 @@ function SpendingInternal({ widget }: SpendingInternalProps) {let earliestMonth = earliestTrans? monthUtils.monthFromDate(d.parseISO(fromDateRepr(earliestTrans.date))): currentMonth;- const latestMonth = latestTrans+ const latestTransactionMonth = latestTrans? monthUtils.monthFromDate(d.parseISO(fromDateRepr(latestTrans.date))): currentMonth;+ const latestMonth =+ latestTransactionMonth > currentMonth+ ? latestTransactionMonth+ : currentMonth;+// Make sure the month selects are at least populates with a// year's worth of months. We can undo this when we have fancier// date selects.diff --git a/packages/desktop-client/src/components/reports/reports/Summary.tsx b/packages/desktop-client/src/components/reports/reports/Summary.tsxindex 40765215fc..b0da3cc501 100644--- a/packages/desktop-client/src/components/reports/reports/Summary.tsx+++ b/packages/desktop-client/src/components/reports/reports/Summary.tsx@@ -179,12 +179,17 @@ function SummaryInner({ widget }: SummaryInnerProps) {parseISO(fromDateRepr(earliestTransaction.date)),): currentMonth;- const latestMonth = latestTransaction+ const latestTransactionMonth = latestTransaction? monthUtils.monthFromDate(parseISO(fromDateRepr(latestTransaction.date)),): currentMonth;+ const latestMonth =+ latestTransactionMonth > currentMonth+ ? latestTransactionMonth+ : currentMonth;+// Make sure the month selects are at least populates with a// year's worth of months. We can undo this when we have fancier// date selects.diff --git a/upcoming-release-notes/5981.md b/upcoming-release-notes/5981.mdnew file mode 100644index 0000000000..fec4f59e84--- /dev/null+++ b/upcoming-release-notes/5981.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [matt-fidd]+---++Fix report date dropdowns not including current period