From 5dcd20b7afd5af4589b0a1ce66cfbcdb9fd95823 Mon Sep 17 00:00:00 2001 From: Celso Pinto Date: Thu, 2 Nov 2023 18:42:07 +0000 Subject: [PATCH 1/4] fixed UK tax year boundary calculations --- Gemfile.lock | 35 ++++++++++++++++++++++------------- lib/fiscal/period.rb | 19 +++++++++++++++---- spec/fiscal_spec.rb | 16 ++++++++++++++++ 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fe36387..47f63a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,23 +1,33 @@ PATH remote: . specs: - fiscal (0.2.2) + fiscal (0.3.0) activesupport GEM remote: https://rubygems.org/ specs: - activesupport (6.0.3.1) + activesupport (7.1.1) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - concurrent-ruby (1.1.6) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + base64 (0.1.1) + bigdecimal (3.1.4) + concurrent-ruby (1.2.2) + connection_pool (2.4.1) diff-lcs (1.3) - i18n (1.8.2) + drb (2.1.1) + ruby2_keywords + i18n (1.14.1) concurrent-ruby (~> 1.0) - minitest (5.14.1) + minitest (5.20.0) + mutex_m (0.1.2) rake (13.0.1) rspec (3.9.0) rspec-core (~> 3.9.0) @@ -32,10 +42,9 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-support (3.9.3) - thread_safe (0.3.6) - tzinfo (1.2.7) - thread_safe (~> 0.1) - zeitwerk (2.3.0) + ruby2_keywords (0.0.5) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) PLATFORMS ruby diff --git a/lib/fiscal/period.rb b/lib/fiscal/period.rb index f6be72b..cf1fe78 100644 --- a/lib/fiscal/period.rb +++ b/lib/fiscal/period.rb @@ -121,15 +121,26 @@ def start_date(options = {}) i = options[:next] ? 0 : 1 # find the start year, if the fiscal year spans across multiple years - year = (@date.to_date - (start_month - 1).months).year + year = (@date.to_date - (start_month-1).months).year # months to offset, for half-year, quarter and month add = (index - i) * (months_in(type)) # construct the start date - Date.new(year, start_month, start_day) + add.months - end + possible_start_date = Date.new(year, start_month, start_day) + add.month + return possible_start_date unless type == :year + + # the previous code is really funny around boundaries like the day before the new tax year starts, etc. + # this now makes whatever adjustments are needed in order to get to the expected result without breaking any + # legacy code + if options[:next] + possible_start_date = Date.new(year, start_month, start_day) + possible_start_date = possible_start_date + 1.year if possible_start_date <= @date + else + possible_start_date = possible_start_date - 1.year if possible_start_date > @date + end + possible_start_date + end end - end diff --git a/spec/fiscal_spec.rb b/spec/fiscal_spec.rb index be0c667..8d3633a 100644 --- a/spec/fiscal_spec.rb +++ b/spec/fiscal_spec.rb @@ -22,6 +22,14 @@ Date.fiscal(date: '2014-01-10', country: :gb).year.start.should eql('2013-04-06'.to_date) end + it "returns '2013-04-06' as fiscal year start date of Great Britain for the date '2014-04-05'" do + Date.fiscal(date: '2014-04-05', country: :gb).year.start.should eql('2013-04-06'.to_date) + end + + it "returns '2014-04-05' as fiscal year end date of Great Britain for the date '2014-04-05'" do + Date.fiscal(date: '2014-04-05', country: :gb).year.end.should eql('2014-04-05'.to_date) + end + it "returns '2014-10-01' as fiscal quarter start date of US for the date '2014-11-11'" do Date.fiscal(date: '2014-11-11', country: :us).quarter.start.should eql('2014-10-01'.to_date) end @@ -46,4 +54,12 @@ Date.today.fiscal.year.start.should eql(Date.today.beginning_of_year) end + it "returns '2023-04-06' as fiscal year start date of Great Britain for the date '2023-04-06'" do + Date.fiscal(date: '2023-04-06', country: :gb).year.start.should eql('2023-04-06'.to_date) + end + + it "returns '2024-04-05' as fiscal year end date of Great Britain for the date '2023-04-06'" do + Date.fiscal(date: '2023-04-06', country: :gb).year.end.should eql('2024-04-05'.to_date) + end + end \ No newline at end of file From e7b0004d65449acc1a82cb769a8bebd0ec4d0ae9 Mon Sep 17 00:00:00 2001 From: Celso Pinto Date: Mon, 22 Jan 2024 12:42:00 +0000 Subject: [PATCH 2/4] git ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 888ea73..1abc0a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .bundle/* pkg/* *.gem +.idea From 58dc403a1ba8a3e31f83032117a833c18cbf11fd Mon Sep 17 00:00:00 2001 From: Celso Pinto Date: Mon, 22 Jan 2024 12:47:10 +0000 Subject: [PATCH 3/4] organised tests per country --- spec/fiscal_spec.rb | 102 +++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/spec/fiscal_spec.rb b/spec/fiscal_spec.rb index 8d3633a..57bd4f7 100644 --- a/spec/fiscal_spec.rb +++ b/spec/fiscal_spec.rb @@ -2,64 +2,80 @@ describe Fiscal do - it "returns current calendar year start date as fiscal year start, by default" do - Date.fiscal.year.start.should eql(Date.today.beginning_of_year) - end + context 'with India country' do + it "returns '2013-04-01' as fiscal year start date of India for the date '2013-10-10'" do + Date.fiscal(date: '2013-10-10', country: :in).year.start.should eql('2013-04-01'.to_date) + end - it "returns current calendar year end date as fiscal end start, by default" do - Date.fiscal.year.end.should eql(Date.today.end_of_year) - end + it "returns '2013-04-01' as fiscal year start date of India for the date '2014-01-10'" do + Date.fiscal(date: '2014-01-10', country: :in).year.start.should eql('2013-04-01'.to_date) + end - it "returns '2013-04-01' as fiscal year start date of India for the date '2013-10-10'" do - Date.fiscal(date: '2013-10-10', country: :in).year.start.should eql('2013-04-01'.to_date) - end + it "returns '2015-06-30' as first fiscal quarter end date of India for the date '2015-08-25'" do + Date.fiscal(date: '2015-08-25', country: :in).quarter(1).end.should eql('2015-06-30'.to_date) + end - it "returns '2013-04-01' as fiscal year start date of India for the date '2014-01-10'" do - Date.fiscal(date: '2014-01-10', country: :in).year.start.should eql('2013-04-01'.to_date) - end + it "returns '2015-04-30' as first fiscal month end date of India for the date '2015-08-25'" do + Date.fiscal(date: '2015-08-25', country: :in).month(1).end.should eql('2015-04-30'.to_date) + end - it "returns '2013-04-06' as fiscal year start date of Great Britain for the date '2014-01-10'" do - Date.fiscal(date: '2014-01-10', country: :gb).year.start.should eql('2013-04-06'.to_date) end - it "returns '2013-04-06' as fiscal year start date of Great Britain for the date '2014-04-05'" do - Date.fiscal(date: '2014-04-05', country: :gb).year.start.should eql('2013-04-06'.to_date) - end + context 'with USA country' do + it "returns '2014-10-01' as fiscal quarter start date of US for the date '2014-11-11'" do + Date.fiscal(date: '2014-11-11', country: :us).quarter.start.should eql('2014-10-01'.to_date) + end - it "returns '2014-04-05' as fiscal year end date of Great Britain for the date '2014-04-05'" do - Date.fiscal(date: '2014-04-05', country: :gb).year.end.should eql('2014-04-05'.to_date) + it "returns '2014-10-01' as first fiscal quarter start date of US for the date '2015-08-25'" do + Date.fiscal(date: '2015-08-25', country: :us).quarter(1).start.should eql('2014-10-01'.to_date) + end end - it "returns '2014-10-01' as fiscal quarter start date of US for the date '2014-11-11'" do - Date.fiscal(date: '2014-11-11', country: :us).quarter.start.should eql('2014-10-01'.to_date) - end + context 'with UK country' do + it "returns '2013-04-06' as fiscal year start date of Great Britain for the date '2014-01-10'" do + Date.fiscal(date: '2014-01-10', country: :gb).year.start.should eql('2013-04-06'.to_date) + end - it "returns '2014-10-01' as first fiscal quarter start date of US for the date '2015-08-25'" do - Date.fiscal(date: '2015-08-25', country: :us).quarter(1).start.should eql('2014-10-01'.to_date) - end + it "returns '2013-04-06' as fiscal year start date of Great Britain for the date '2014-04-05'" do + Date.fiscal(date: '2014-04-05', country: :gb).year.start.should eql('2013-04-06'.to_date) + end - it "returns '2015-06-30' as first fiscal quarter end date of India for the date '2015-08-25'" do - Date.fiscal(date: '2015-08-25', country: :in).quarter(1).end.should eql('2015-06-30'.to_date) - end + it "returns '2014-04-05' as fiscal year end date of Great Britain for the date '2014-04-05'" do + Date.fiscal(date: '2014-04-05', country: :gb).year.end.should eql('2014-04-05'.to_date) + end - it "returns '2015-04-30' as first fiscal month end date of India for the date '2015-08-25'" do - Date.fiscal(date: '2015-08-25', country: :in).month(1).end.should eql('2015-04-30'.to_date) - end + it "returns '2013-05-06' as second fiscal month start date of Great Britain for the date '2014-01-10'" do + Date.fiscal(date: '2014-01-10', country: :gb).month(2).start.should eql('2013-05-06'.to_date) + end - it "returns '2013-05-06' as second fiscal month start date of Great Britain for the date '2014-01-10'" do - Date.fiscal(date: '2014-01-10', country: :gb).month(2).start.should eql('2013-05-06'.to_date) - end + it "returns '2023-04-06' as fiscal year start date of Great Britain for the date '2023-04-06'" do + Date.fiscal(date: '2023-04-06', country: :gb).year.start.should eql('2023-04-06'.to_date) + end - it "returns current calendar year start date as fiscal year start, for today" do - Date.today.fiscal.year.start.should eql(Date.today.beginning_of_year) - end + it "returns '2024-04-05' as fiscal year end date of Great Britain for the date '2023-04-06'" do + Date.fiscal(date: '2023-04-06', country: :gb).year.end.should eql('2024-04-05'.to_date) + end - it "returns '2023-04-06' as fiscal year start date of Great Britain for the date '2023-04-06'" do - Date.fiscal(date: '2023-04-06', country: :gb).year.start.should eql('2023-04-06'.to_date) - end + it "returns '2024-04-06' as fiscal year end date of Great Britain for the date '2024-01-22'" do + Date.fiscal(date: '2024-01-22', country: :gb).year.end.should eql('2024-04-05'.to_date) + end - it "returns '2024-04-05' as fiscal year end date of Great Britain for the date '2023-04-06'" do - Date.fiscal(date: '2023-04-06', country: :gb).year.end.should eql('2024-04-05'.to_date) + it "returns '2023-04-06' as fiscal year start date of Great Britain for the date '2024-01-22'" do + Date.fiscal(date: '2024-01-22', country: :gb).year.start.should eql('2023-04-06'.to_date) + end end -end \ No newline at end of file + context 'with default country' do + it "returns current calendar year start date as fiscal year start, by default" do + Date.fiscal.year.start.should eql(Date.today.beginning_of_year) + end + + it "returns current calendar year end date as fiscal end start, by default" do + Date.fiscal.year.end.should eql(Date.today.end_of_year) + end + + it "returns current calendar year start date as fiscal year start, for today" do + Date.today.fiscal.year.start.should eql(Date.today.beginning_of_year) + end + end +end From 24884a75e59accd7529338ce2bbe71118d31737c Mon Sep 17 00:00:00 2001 From: Celso Pinto Date: Mon, 22 Jan 2024 12:48:09 +0000 Subject: [PATCH 4/4] tidied up with rubocop --- .rubocop.yml | 12 ++++++++ .rubocop_todo.yml | 70 +++++++++++++++++++++++++++++++++++++++++++ Gemfile | 2 ++ Rakefile | 4 ++- fiscal.gemspec | 31 +++++++++---------- lib/fiscal.rb | 6 ++-- lib/fiscal/base.rb | 6 ++-- lib/fiscal/config.rb | 11 ++++--- lib/fiscal/methods.rb | 4 +-- lib/fiscal/period.rb | 57 ++++++++++++++++++----------------- lib/fiscal/version.rb | 4 ++- spec/fiscal_spec.rb | 10 +++---- spec/spec_helper.rb | 4 ++- 13 files changed, 158 insertions(+), 63 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..b95f7a3 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,12 @@ +inherit_from: .rubocop_todo.yml + +# The behavior of RuboCop can be controlled via the .rubocop.yml +# configuration file. It makes it possible to enable/disable +# certain cops (checks) and to alter their behavior if they accept +# any parameters. The file can be placed either in your home +# directory or in some project directory. +# +# RuboCop will start looking for the configuration file in the directory +# where the inspected file is and continue its way up to the root directory. +# +# See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..bbc1a70 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,70 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2024-01-22 12:49:43 +0000 using RuboCop version 0.75.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +Metrics/AbcSize: + Max: 28 + +# Offense count: 1 +# Configuration parameters: CountComments, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Max: 59 + +# Offense count: 1 +Metrics/CyclomaticComplexity: + Max: 8 + +# Offense count: 3 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/MethodLength: + Max: 228 + +# Offense count: 1 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 230 + +# Offense count: 1 +Metrics/PerceivedComplexity: + Max: 9 + +# Offense count: 5 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'lib/fiscal/base.rb' + - 'lib/fiscal/config.rb' + - 'lib/fiscal/methods.rb' + - 'lib/fiscal/period.rb' + +# Offense count: 1 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'lib/fiscal/period.rb' + +# Offense count: 1 +# Configuration parameters: AllowIfModifier. +Style/IfInsideElse: + Exclude: + - 'lib/fiscal/period.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'lib/fiscal/period.rb' + +# Offense count: 39 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 200 diff --git a/Gemfile b/Gemfile index 235a819..536335a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' # Specify your gem's dependencies in fiscal.gemspec diff --git a/Rakefile b/Rakefile index 2995527..7398a90 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1,3 @@ -require "bundler/gem_tasks" +# frozen_string_literal: true + +require 'bundler/gem_tasks' diff --git a/fiscal.gemspec b/fiscal.gemspec index ed5af39..8ab86e4 100644 --- a/fiscal.gemspec +++ b/fiscal.gemspec @@ -1,26 +1,27 @@ -# coding: utf-8 -lib = File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'fiscal/version' Gem::Specification.new do |spec| - spec.name = "fiscal" + spec.name = 'fiscal' spec.version = Fiscal::VERSION - spec.authors = ["Geordee Naliyath"] - spec.email = ["geordee@gmail.com"] - spec.summary = %q{Get the fiscal period attributes for various countries} - spec.description = %q{The "fiscal" gem helps to retrieve the fiscal year, half year, quarter and month along with start and end dates for many countries.} - spec.homepage = "https://github.com/samyukti/fiscal" - spec.license = "MIT" + spec.authors = ['Geordee Naliyath'] + spec.email = ['geordee@gmail.com'] + spec.summary = 'Get the fiscal period attributes for various countries' + spec.description = 'The "fiscal" gem helps to retrieve the fiscal year, half year, quarter and month along with start and end dates for many countries.' + spec.homepage = 'https://github.com/samyukti/fiscal' + spec.license = 'MIT' - spec.files = `git ls-files`.split($/) + spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.add_dependency "activesupport" + spec.add_dependency 'activesupport' - spec.add_development_dependency "bundler", "~> 2.1" - spec.add_development_dependency "rake" - spec.add_development_dependency "rspec" + spec.add_development_dependency 'bundler', '~> 2.1' + spec.add_development_dependency 'rake' + spec.add_development_dependency 'rspec' end diff --git a/lib/fiscal.rb b/lib/fiscal.rb index a996059..e2289a0 100644 --- a/lib/fiscal.rb +++ b/lib/fiscal.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'date' require 'active_support' require 'active_support/core_ext' @@ -7,5 +9,5 @@ require 'fiscal/methods' require 'fiscal/base' -Date.send :include, Fiscal -Time.send :include, Fiscal +Date.include Fiscal +Time.include Fiscal diff --git a/lib/fiscal/base.rb b/lib/fiscal/base.rb index f6899c5..b166447 100644 --- a/lib/fiscal/base.rb +++ b/lib/fiscal/base.rb @@ -1,5 +1,6 @@ -module Fiscal +# frozen_string_literal: true +module Fiscal def self.included(base) base.extend ClassMethods end @@ -12,8 +13,7 @@ def fiscal(options = {}) def fiscal(options = {}) # default date from the date instance - options[:date] = options[:date] || Date.new(self.year, self.month, self.day) + options[:date] = options[:date] || Date.new(year, month, day) Fiscal.new(options) end - end diff --git a/lib/fiscal/config.rb b/lib/fiscal/config.rb index dedc810..314a017 100644 --- a/lib/fiscal/config.rb +++ b/lib/fiscal/config.rb @@ -1,5 +1,6 @@ -module Fiscal +# frozen_string_literal: true +module Fiscal module FiscalConfig def config # The World Factbook 2013-14. Washington, DC: Central Intelligence Agency, 2013 . @@ -8,7 +9,7 @@ def config # NOTE: ki, so are defaulted to 1, 1 # country, month, day - {nil: { mm: 1, dd: 1 }, + { nil: { mm: 1, dd: 1 }, ad: { mm: 1, dd: 1 }, ae: { mm: 1, dd: 1 }, af: { mm: 12, dd: 21 }, @@ -235,9 +236,7 @@ def config ye: { mm: 1, dd: 1 }, za: { mm: 4, dd: 1 }, zm: { mm: 1, dd: 1 }, - zw: { mm: 1, dd: 1 } - } + zw: { mm: 1, dd: 1 } } end end - -end \ No newline at end of file +end diff --git a/lib/fiscal/methods.rb b/lib/fiscal/methods.rb index a1f59c5..9431458 100644 --- a/lib/fiscal/methods.rb +++ b/lib/fiscal/methods.rb @@ -1,5 +1,6 @@ -module Fiscal +# frozen_string_literal: true +module Fiscal class Fiscal def initialize(options = {}) @date = options[:date] @@ -22,5 +23,4 @@ def month(index = nil) FiscalPeriod.new(date: @date, country: @country, type: :month, index: index) end end - end diff --git a/lib/fiscal/period.rb b/lib/fiscal/period.rb index cf1fe78..70d511e 100644 --- a/lib/fiscal/period.rb +++ b/lib/fiscal/period.rb @@ -1,26 +1,26 @@ -module Fiscal +# frozen_string_literal: true +module Fiscal class FiscalPeriod include FiscalConfig class FiscalError < StandardError; end def initialize(options = {}) - @type = (options[:type]) @date = (options[:date] || Date.today).to_date @country = (options[:country] || :nil).to_sym - if options[:index] - # user input - @index = options[:index].to_i - elsif @type == :year - # only 1 year in a fiscal year - @index = 1 - else - # if the user does not enter, compute the index - @index = number - end + @index = if options[:index] + # user input + options[:index].to_i + elsif @type == :year + # only 1 year in a fiscal year + 1 + else + # if the user does not enter, compute the index + number + end validate end @@ -28,16 +28,18 @@ def initialize(options = {}) def validate # date validation is handled by active support # country - raise(FiscalError, "`#{@country}` is not a recognized country") unless self.config()[@country] + unless config[@country] + raise(FiscalError, "`#{@country}` is not a recognized country") + end + # index valid_indexes = (1..(12 / months_in(type))) - raise(FiscalError, "`#{@index}` is not a valid index for `#{@type}`") unless valid_indexes.include?(@index) + unless valid_indexes.include?(@index) + raise(FiscalError, "`#{@index}` is not a valid index for `#{@type}`") + end end - def type - # return type, in case user decides to pass around the return object - @type - end + attr_reader :type def start # start date @@ -59,7 +61,7 @@ def number else # find the number of intervals from start of the year start = start_date(type: :year) - ((months_between(start, @date).to_f) / months_in(@type)).ceil + (months_between(start, @date).to_f / months_in(@type)).ceil end end @@ -93,13 +95,14 @@ def to_s number.to_s end - private + private + def start_month - self.config()[@country][:mm] + config[@country][:mm] end def start_day - self.config()[@country][:dd] + config[@country][:dd] end def months_between(from, to) @@ -107,7 +110,7 @@ def months_between(from, to) end def months_in(type) - {year: 12, half_year: 6, quarter: 3, month: 1}[type] + { year: 12, half_year: 6, quarter: 3, month: 1 }[type] end def start_date(options = {}) @@ -121,10 +124,10 @@ def start_date(options = {}) i = options[:next] ? 0 : 1 # find the start year, if the fiscal year spans across multiple years - year = (@date.to_date - (start_month-1).months).year + year = (@date.to_date - (start_month - 1).months).year # months to offset, for half-year, quarter and month - add = (index - i) * (months_in(type)) + add = (index - i) * months_in(type) # construct the start date possible_start_date = Date.new(year, start_month, start_day) + add.month @@ -135,9 +138,9 @@ def start_date(options = {}) # legacy code if options[:next] possible_start_date = Date.new(year, start_month, start_day) - possible_start_date = possible_start_date + 1.year if possible_start_date <= @date + possible_start_date += 1.year if possible_start_date <= @date else - possible_start_date = possible_start_date - 1.year if possible_start_date > @date + possible_start_date -= 1.year if possible_start_date > @date end possible_start_date diff --git a/lib/fiscal/version.rb b/lib/fiscal/version.rb index 96c3cea..c32d0b0 100644 --- a/lib/fiscal/version.rb +++ b/lib/fiscal/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Fiscal - VERSION = "0.3.0" + VERSION = '0.3.0' end diff --git a/spec/fiscal_spec.rb b/spec/fiscal_spec.rb index 57bd4f7..9d66a5a 100644 --- a/spec/fiscal_spec.rb +++ b/spec/fiscal_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' describe Fiscal do - context 'with India country' do it "returns '2013-04-01' as fiscal year start date of India for the date '2013-10-10'" do Date.fiscal(date: '2013-10-10', country: :in).year.start.should eql('2013-04-01'.to_date) @@ -18,7 +19,6 @@ it "returns '2015-04-30' as first fiscal month end date of India for the date '2015-08-25'" do Date.fiscal(date: '2015-08-25', country: :in).month(1).end.should eql('2015-04-30'.to_date) end - end context 'with USA country' do @@ -66,15 +66,15 @@ end context 'with default country' do - it "returns current calendar year start date as fiscal year start, by default" do + it 'returns current calendar year start date as fiscal year start, by default' do Date.fiscal.year.start.should eql(Date.today.beginning_of_year) end - it "returns current calendar year end date as fiscal end start, by default" do + it 'returns current calendar year end date as fiscal end start, by default' do Date.fiscal.year.end.should eql(Date.today.end_of_year) end - it "returns current calendar year start date as fiscal year start, for today" do + it 'returns current calendar year start date as fiscal year start, for today' do Date.today.fiscal.year.start.should eql(Date.today.beginning_of_year) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 596ab6b..9ce58a7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/setup' Bundler.setup @@ -5,4 +7,4 @@ RSpec.configure do |config| config.expect_with(:rspec) { |c| c.syntax = :should } -end \ No newline at end of file +end