1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 03:55:20 +02:00

Added more periods (#1714)

This commit is contained in:
Nikhil Badyal 2025-01-27 23:33:15 +05:30 committed by GitHub
parent d2a7aef6ef
commit 2a202576f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 36 additions and 6 deletions

View file

@ -8,6 +8,18 @@ module AccountsHelper
days_apart = (end_date - start_date).to_i
# Handle specific cases
if start_date == Date.current.beginning_of_week && end_date == Date.current
return "Current Week to Date (CWD)"
elsif start_date == Date.current.beginning_of_month && end_date == Date.current
return "Current Month to Date (MTD)"
elsif start_date == Date.current.beginning_of_quarter && end_date == Date.current
return "Current Quarter to Date (CQD)"
elsif start_date == Date.current.beginning_of_year && end_date == Date.current
return "Current Year to Date (YTD)"
end
# Default cases
case days_apart
when 1
"vs. yesterday"
@ -15,6 +27,8 @@ module AccountsHelper
"vs. last week"
when 30, 31
"vs. last month"
when 90
"vs. last 3 months"
when 365, 366
"vs. last year"
else