Skip to content

A gem tells you what financial year is now, and also the date range of it.

License

Notifications You must be signed in to change notification settings

xuwupeng2000/financial_year

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FinancialYear

A gem tells you what financial year is it now, and also the date range of it

How to use it

PUT this in your Gemfile
gem 'financial_year', '~> 0.1.0'
  klass = FinancialYear::FinancialYear.config(
    start_month = 4,
    start_day = 1,
    end_month = 3,
    end_day = 31
  )

  financial_year = klass.for_year(2017)
  financial_year.financial_year_range
  # expect(instance.financial_year_range).to eq Date.new(2016, 4, 1)..Date.new(2017, 3, 31)

  financial_year.ytd_range
  # expect(instance.ytd_range).to eq Date.new(2017, 4, 1)..Date.today


  # Real life example
  today = Date.today

  start_last_year = today.month >= FinancialYear.start_month ? today.year - 1 : today.year - 2
  # Last financial year
  last_year = FinancialYear.for_year(start_last_year).financial_year_range

  # This on going financial year
  current_year_ytd = FinancialYear.for_year(start_last_year + 1).ytd_range

About

A gem tells you what financial year is now, and also the date range of it.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published