Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Merge pull request #925 from grrtt49/feature/future-budget

soky srm1d7c4158d431
diff --cc app/models/budget.rb
index 64fcdb73db,eee6a32547..b5bb8aa5e9
--- a/app/models/budget.rb
+++ b/app/models/budget.rb
@@@ -31,16 -29,17 +31,17 @@@ class Budget < ApplicationRecor
end
def budget_date_valid?(date, family:)
- if family.uses_custom_month_start?
- budget_start = family.custom_month_start_for(date)
- budget_start >= oldest_valid_budget_date(family) && budget_start <= family.custom_month_end_for(Date.current)
+ budget_start = if family.uses_custom_month_start?
+ family.custom_month_start_for(date)
else
- beginning_of_month = date.beginning_of_month
- beginning_of_month >= oldest_valid_budget_date(family) && beginning_of_month <= Date.current.end_of_month
+ date.beginning_of_month
end
+
+ budget_start >= oldest_valid_budget_date(family) &&
+ budget_start <= latest_valid_budget_start_date(family)
end
- def find_or_bootstrap(family, start_date:)
+ def find_or_bootstrap(family, start_date:, user: nil)
return nil unless budget_date_valid?(start_date, family: family)
Budget.transaction do