mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Fix budget navigation to allow selecting previous months
- Allow going back 2 years minimum even without entries - Update oldest_valid_budget_date to use min of entry date or 2 years ago - Add comprehensive tests for budget date validation - Fixes issue where users couldn't select prior budget months
This commit is contained in:
parent
32ec57146e
commit
527a6128b6
2 changed files with 92 additions and 1 deletions
|
@ -49,7 +49,10 @@ class Budget < ApplicationRecord
|
|||
|
||||
private
|
||||
def oldest_valid_budget_date(family)
|
||||
@oldest_valid_budget_date ||= family.oldest_entry_date.beginning_of_month
|
||||
# Allow going back to either the earliest entry date OR 2 years ago, whichever is earlier
|
||||
two_years_ago = 2.years.ago.beginning_of_month
|
||||
oldest_entry_date = family.oldest_entry_date.beginning_of_month
|
||||
[ two_years_ago, oldest_entry_date ].min
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue