Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Use date comparisons for interval thresholds (#1923)

Mark Hendriksen0497b1d7c184
diff --git a/app/models/period.rb b/app/models/period.rb
index 6d7a98d83c..b4857daee4 100644
--- a/app/models/period.rb
+++ b/app/models/period.rb
@@ -169,9 +169,9 @@ class Period
end
def interval
- if days > 1825 # 5 years
+ if end_date > start_date.advance(years: 5) # more than 5 calendar years → monthly
"1 month"
- elsif days > 366
+ elsif end_date > start_date.advance(years: 1) # more than 1 calendar year → weekly
"1 week"
else
"1 day"