fiscali 1.2.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,5 +1,17 @@
1
- *.sw?
2
- .DS_Store
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
3
9
  coverage
4
- rdoc
10
+ doc/
11
+ lib/bundler/man
5
12
  pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
data/README.markdown CHANGED
@@ -13,14 +13,18 @@ Fiscali provides ONE thing:
13
13
 
14
14
  ## Installing
15
15
 
16
- # Install the gem:
17
- sudo gem install asanghi-fiscali
16
+ # Install the gem (from gemcutter.org):
17
+ sudo gem install fiscali
18
18
 
19
19
  ## Using in your Rails project
20
20
 
21
21
  It's easy to get up and running. Update your config/environment.rb file with this gem
22
22
 
23
- config.gem "asanghi-fiscali", :lib => 'fiscali', :sources => 'http://gems.github.com'
23
+ config.gem "fiscali"
24
+
25
+ In newer Rails projects, include the gem in the Gemfile and run "bundle install" to install the gem.
26
+
27
+ gem "fiscali"
24
28
 
25
29
  Next step is to provide your Date/Time class your start zone. Stick this in an initializer file. (If you didnt understand that, put it in $ENV[RAILS_ROOT]/config/initializers/fiscali.rb)
26
30
 
data/Rakefile CHANGED
@@ -1,57 +1,7 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
3
4
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "fiscali"
8
- gem.summary = %Q{Fiscal Year Date Functions}
9
- gem.email = "aditya.sanghi@risingsunbilling.com"
10
- gem.homepage = "http://asanghi.github.com/fiscali"
11
- gem.authors = ["Aditya Sanghi"]
12
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
- gem.add_dependency('activesupport')
14
- end
15
-
16
- rescue LoadError
17
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
- end
19
-
20
- require 'rake/testtask'
21
- Rake::TestTask.new(:test) do |test|
22
- test.libs << 'lib' << 'test'
23
- test.pattern = 'test/**/*_test.rb'
24
- test.verbose = true
25
- end
26
-
27
- begin
28
- require 'rcov/rcovtask'
29
- Rcov::RcovTask.new do |test|
30
- test.libs << 'test'
31
- test.pattern = 'test/**/*_test.rb'
32
- test.verbose = true
33
- end
34
- rescue LoadError
35
- task :rcov do
36
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
- end
38
- end
39
-
40
-
41
- task :default => :test
42
-
43
- require 'rake/rdoctask'
44
- Rake::RDocTask.new do |rdoc|
45
- if File.exist?('VERSION.yml')
46
- config = YAML.load(File.read('VERSION.yml'))
47
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
48
- else
49
- version = ""
50
- end
51
-
52
- rdoc.rdoc_dir = 'rdoc'
53
- rdoc.title = "fiscali #{version}"
54
- rdoc.rdoc_files.include('README*')
55
- rdoc.rdoc_files.include('lib/**/*.rb')
56
- end
5
+ RSpec::Core::RakeTask.new(:spec)
57
6
 
7
+ task :default => :spec
data/fiscali.gemspec CHANGED
@@ -1,51 +1,23 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rising_sun/version', __FILE__)
2
3
 
3
- Gem::Specification.new do |s|
4
- s.name = %q{fiscali}
5
- s.version = "1.2.5"
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "fiscali"
6
+ gem.version = RisingSun::Fiscali::VERSION
7
+ gem.authors = ["Aditya Sanghi"]
8
+ gem.email = ["asanghi@me.com"]
9
+ gem.description = %q{Fiscal Year Date Functions}
10
+ gem.summary = %q{Fiscal Year Date Functions}
11
+ gem.homepage = "https://github.com/asanghi/fiscali"
6
12
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Aditya Sanghi"]
9
- s.date = %q{2009-08-07}
10
- s.email = %q{aditya.sanghi@risingsunbilling.com}
11
- s.extra_rdoc_files = [
12
- "LICENSE",
13
- "README.markdown"
14
- ]
15
- s.files = [
16
- ".document",
17
- ".gitignore",
18
- "LICENSE",
19
- "README.markdown",
20
- "Rakefile",
21
- "VERSION",
22
- "fiscali.gemspec",
23
- "install.rb",
24
- "lib/fiscali.rb",
25
- "lib/rising_sun/fiscali.rb",
26
- "test/fiscali_test.rb",
27
- "test/test_helper.rb"
28
- ]
29
- s.homepage = %q{http://asanghi.github.com/fiscali}
30
- s.rdoc_options = ["--charset=UTF-8"]
31
- s.require_paths = ["lib"]
32
- s.rubygems_version = %q{1.3.5}
33
- s.summary = %q{Fiscal Year Date Functions}
34
- s.test_files = [
35
- "test/fiscali_test.rb",
36
- "test/test_helper.rb"
37
- ]
13
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ gem.require_paths = ["lib"]
38
17
 
39
- if s.respond_to? :specification_version then
40
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
- s.specification_version = 3
18
+ gem.add_dependency 'activesupport'
42
19
 
43
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
45
- else
46
- s.add_dependency(%q<activesupport>, [">= 0"])
47
- end
48
- else
49
- s.add_dependency(%q<activesupport>, [">= 0"])
50
- end
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec', '~> 2.8'
51
22
  end
23
+
data/lib/fiscali.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'date'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
1
4
  require 'rising_sun/fiscali'
2
5
  Date.send(:include, RisingSun::Fiscali)
3
6
  Time.send(:include, RisingSun::Fiscali)
@@ -2,36 +2,34 @@ module RisingSun
2
2
  module Fiscali
3
3
  def self.included(base)
4
4
  base.extend ClassMethods
5
- unless included_modules.include? InstanceMethods
6
- base.send(:include, InstanceMethods)
7
- end
8
5
  end
9
-
6
+
10
7
  FISCAL_ZONE = {:india => 4, :uk => 4, :us => 10, :pakistan => 7,
11
8
  :australia => 7, :ireland => 1, :nz => 7, :japan => 4}
12
9
  FY_START_MONTH = 1
13
-
10
+
14
11
  module ClassMethods
12
+
15
13
  def fiscal_zone=(zone)
16
- write_inheritable_attribute(:start_month, FISCAL_ZONE[zone] || FY_START_MONTH)
17
- write_inheritable_attribute(:zone,zone)
14
+ Thread.current[:fiscali_start_month] = FISCAL_ZONE[zone] || FY_START_MONTH
15
+ Thread.current[:fiscali_zone] = zone
18
16
  end
19
17
 
20
18
  def fy_start_month
21
- read_inheritable_attribute(:start_month) || FY_START_MONTH
19
+ Thread.current[:fiscali_start_month] || FY_START_MONTH
22
20
  end
23
21
 
24
22
  def fiscal_zone
25
- read_inheritable_attribute(:zone)
23
+ Thread.current[:fiscali_zone]
26
24
  end
27
25
 
28
26
  def fy_start_month=(month)
29
- write_inheritable_attribute(:zone, nil)
30
- write_inheritable_attribute(:start_month,month)
27
+ Thread.current[:fiscali_zone] = nil
28
+ Thread.current[:fiscali_start_month] = month
31
29
  end
32
30
 
33
31
  def financial_year_start(year=Date.today.year)
34
- Date.new(year,fy_start_month,1)
32
+ new(year,fy_start_month,1)
35
33
  end
36
34
 
37
35
  def financial_months
@@ -40,102 +38,99 @@ module RisingSun
40
38
 
41
39
  end
42
40
 
43
- module InstanceMethods
44
- def financial_year
45
- self.month < start_month ? self.year - 1 : self.year
46
- end
41
+ def financial_year
42
+ self.month < start_month ? self.year - 1 : self.year
43
+ end
47
44
 
48
- def beginning_of_financial_year
49
- change(:year => financial_year, :month => start_month, :day => 1)
50
- end
45
+ def beginning_of_financial_year
46
+ change(:year => financial_year, :month => start_month, :day => 1)
47
+ end
51
48
 
52
- def end_of_financial_year
53
- (beginning_of_financial_year + 1.year - 1.month).end_of_month
54
- end
49
+ def end_of_financial_year
50
+ (beginning_of_financial_year + 1.year - 1.month).end_of_month
51
+ end
55
52
 
56
- alias :beginning_of_financial_q1 :beginning_of_financial_year
57
- def end_of_financial_q1
58
- end_of_financial_year - 9.months
59
- end
53
+ alias :beginning_of_financial_q1 :beginning_of_financial_year
54
+ def end_of_financial_q1
55
+ end_of_financial_year - 9.months
56
+ end
60
57
 
61
- def beginning_of_financial_q2
62
- beginning_of_financial_year + 3.months
63
- end
58
+ def beginning_of_financial_q2
59
+ beginning_of_financial_year + 3.months
60
+ end
64
61
 
65
- def end_of_financial_q2
66
- end_of_financial_year - 6.months
67
- end
62
+ def end_of_financial_q2
63
+ end_of_financial_year - 6.months
64
+ end
68
65
 
69
- def beginning_of_financial_q3
70
- beginning_of_financial_year + 6.months
71
- end
66
+ def beginning_of_financial_q3
67
+ beginning_of_financial_year + 6.months
68
+ end
72
69
 
73
- def end_of_financial_q3
74
- end_of_financial_year - 3.months
75
- end
70
+ def end_of_financial_q3
71
+ end_of_financial_year - 3.months
72
+ end
76
73
 
77
- def beginning_of_financial_q4
78
- beginning_of_financial_year + 9.months
79
- end
80
- alias :end_of_financial_q4 :end_of_financial_year
74
+ def beginning_of_financial_q4
75
+ beginning_of_financial_year + 9.months
76
+ end
77
+ alias :end_of_financial_q4 :end_of_financial_year
81
78
 
82
- alias :beginning_of_financial_h1 :beginning_of_financial_year
83
- alias :end_of_financial_h1 :end_of_financial_q2
79
+ alias :beginning_of_financial_h1 :beginning_of_financial_year
80
+ alias :end_of_financial_h1 :end_of_financial_q2
84
81
 
85
- alias :beginning_of_financial_h2 :beginning_of_financial_q3
86
- alias :end_of_financial_h2 :end_of_financial_year
82
+ alias :beginning_of_financial_h2 :beginning_of_financial_q3
83
+ alias :end_of_financial_h2 :end_of_financial_year
87
84
 
88
- def financial_quarter
89
- "Q#{( months_between / 3 ).floor + 1} #{financial_year}"
90
- end
85
+ def financial_quarter
86
+ "Q#{( months_between / 3 ).floor + 1} #{financial_year}"
87
+ end
91
88
 
92
- def financial_half
93
- "H#{( months_between / 6 ).floor + 1} #{financial_year}"
94
- end
89
+ def financial_half
90
+ "H#{( months_between / 6 ).floor + 1} #{financial_year}"
91
+ end
95
92
 
96
- def next_financial_quarter
97
- beginning_of_financial_year.months_since(((months_between / 3).floor + 1 ) * 3)
98
- end
93
+ def next_financial_quarter
94
+ beginning_of_financial_year.months_since(((months_between / 3).floor + 1 ) * 3)
95
+ end
99
96
 
100
- def next_financial_half
101
- beginning_of_financial_year.months_since(((months_between / 6).floor + 1) * 6)
102
- end
97
+ def next_financial_half
98
+ beginning_of_financial_year.months_since(((months_between / 6).floor + 1) * 6)
99
+ end
103
100
 
104
- def beginning_of_financial_quarter
105
- beginning_of_financial_year.months_since(((months_between / 3).floor) * 3)
106
- end
101
+ def beginning_of_financial_quarter
102
+ beginning_of_financial_year.months_since(((months_between / 3).floor) * 3)
103
+ end
107
104
 
108
- def beginning_of_financial_half
109
- beginning_of_financial_year.months_since(((months_between / 6).floor) * 6)
110
- end
105
+ def beginning_of_financial_half
106
+ beginning_of_financial_year.months_since(((months_between / 6).floor) * 6)
107
+ end
111
108
 
112
- def previous_financial_quarter
113
- beginning_of_financial_quarter.months_ago(3)
114
- end
109
+ def previous_financial_quarter
110
+ beginning_of_financial_quarter.months_ago(3)
111
+ end
115
112
 
116
- def previous_financial_half
117
- beginning_of_financial_half.months_ago(6)
118
- end
113
+ def previous_financial_half
114
+ beginning_of_financial_half.months_ago(6)
115
+ end
119
116
 
120
- def financial_month_of(month)
121
- if month < start_month
122
- Date.new(year+1,month,1)
123
- else
124
- Date.new(year,month,1)
125
- end
117
+ def financial_month_of(month)
118
+ if month < start_month
119
+ Date.new(year+1,month,1)
120
+ else
121
+ Date.new(year,month,1)
126
122
  end
123
+ end
127
124
 
128
- private
129
-
130
- def months_between
131
- soy = self.beginning_of_financial_year
132
- (self.month - soy.month) + 12 * (self.year - soy.year)
133
- end
125
+ private
134
126
 
135
- def start_month
136
- self.class.read_inheritable_attribute(:start_month) || FY_START_MONTH
137
- end
127
+ def months_between
128
+ soy = self.beginning_of_financial_year
129
+ (self.month - soy.month) + 12 * (self.year - soy.year)
130
+ end
138
131
 
132
+ def start_month
133
+ self.class.fy_start_month || FY_START_MONTH
139
134
  end
140
135
 
141
136
  end
@@ -0,0 +1,5 @@
1
+ module RisingSun
2
+ module Fiscali
3
+ VERSION = "2.0.0"
4
+ end
5
+ end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe "fiscali" do
4
+ it "should be possible to read fiscal zone" do
5
+ Date.fiscal_zone.should be_nil
6
+ end
7
+
8
+ it "should be possible to write fiscal zone" do
9
+ Date.fiscal_zone = :india
10
+ Date.fiscal_zone.should eql(:india)
11
+ end
12
+
13
+ it "should be possible to read fiscal start month" do
14
+ Date.fy_start_month = 2
15
+ Date.fy_start_month.should eql(2)
16
+ end
17
+
18
+ it "should report financial year start" do
19
+ Date.fiscal_zone = :india
20
+ this_year = Date.today.year
21
+ Date.financial_year_start.should eql(Date.new(this_year,4,1))
22
+
23
+ Date.financial_year_start(2009).should eql(Date.new(2009,4,1))
24
+ end
25
+
26
+ context "should report correct date field" do
27
+ before(:each) do
28
+ @d = Date.new(2009,1,1)
29
+ end
30
+ it "should report correct financial year" do
31
+ @d.financial_year.should eql(2008)
32
+ end
33
+
34
+ it "should report correct beginning and of financial year" do
35
+ @d.beginning_of_financial_year.should eql(Date.new(2008,4,1))
36
+ @d.end_of_financial_year.should eql(Date.new(2009,3,31))
37
+ end
38
+
39
+ it "should report correct beginning of financial halves and quarters" do
40
+ @d.beginning_of_financial_h1.should eql(Date.new(2008,4,1))
41
+ @d.beginning_of_financial_h2.should eql(Date.new(2008,10,1))
42
+ @d.beginning_of_financial_q1.should eql(Date.new(2008,4,1))
43
+ @d.beginning_of_financial_q2.should eql(Date.new(2008,7,1))
44
+ @d.beginning_of_financial_q3.should eql(Date.new(2008,10,1))
45
+ @d.beginning_of_financial_q4.should eql(Date.new(2009,1,1))
46
+ end
47
+
48
+ it "should report correct end of financial halves and quarters" do
49
+ @d.end_of_financial_h1.should eql(Date.new(2008,9,30))
50
+ @d.end_of_financial_h2.should eql(Date.new(2009,3,31))
51
+ @d.end_of_financial_q1.should eql(Date.new(2008,6,30))
52
+ @d.end_of_financial_q2.should eql(Date.new(2008,9,30))
53
+ @d.end_of_financial_q3.should eql(Date.new(2008,12,31))
54
+ @d.end_of_financial_q4.should eql(Date.new(2009,3,31))
55
+ end
56
+
57
+ it "should report financial quarters" do
58
+ @d.financial_quarter.should eql('Q4 2008')
59
+ end
60
+
61
+ it "should report financial half" do
62
+ @d.financial_half.should eql('H2 2008')
63
+ Date.new(2009,11,30).financial_half.should eql("H2 2009")
64
+ end
65
+
66
+ it "should report next half and quarter" do
67
+ @d.next_financial_half.should eql(Date.new(2009,4,1))
68
+ Date.new(2009,6,1).next_financial_half.should eql(Date.new(2009,10,1))
69
+
70
+ @d.next_financial_quarter.should eql(Date.new(2009,4,1))
71
+ Date.new(2009,10,30).next_financial_quarter.should eql(Date.new(2010,1,1))
72
+ end
73
+
74
+ it "should report beginning of financial half and quarter" do
75
+ @d.beginning_of_financial_half.should eql(Date.new(2008,10,1))
76
+ @d.beginning_of_financial_quarter.should eql(Date.new(2009,1,1))
77
+ Date.new(2009,6,1).beginning_of_financial_half.should eql(Date.new(2009,4,1))
78
+ Date.new(2009,10,30).beginning_of_financial_quarter.should eql(Date.new(2009,10,1))
79
+ end
80
+
81
+ it "should report previous financial half and quarter" do
82
+ @d.previous_financial_half.should eql(Date.new(2008,4,1))
83
+ @d.previous_financial_quarter.should eql(Date.new(2008,10,1))
84
+ Date.new(2009,6,1).previous_financial_half.should eql(Date.new(2008,10,1))
85
+ Date.new(2009,10,30).previous_financial_quarter.should eql(Date.new(2009,7,1))
86
+ end
87
+
88
+ end
89
+
90
+ end
@@ -0,0 +1,5 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'rspec'
4
+ require 'fiscali'
5
+
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiscali
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Aditya Sanghi
@@ -9,69 +15,109 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-08-07 00:00:00 +05:30
13
- default_executable:
18
+ date: 2012-02-15 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: activesupport
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
17
32
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
20
39
  requirements:
21
40
  - - ">="
22
41
  - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
23
45
  version: "0"
24
- version:
25
- description:
26
- email: aditya.sanghi@risingsunbilling.com
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ hash: 19
57
+ segments:
58
+ - 2
59
+ - 8
60
+ version: "2.8"
61
+ type: :development
62
+ version_requirements: *id003
63
+ description: Fiscal Year Date Functions
64
+ email:
65
+ - asanghi@me.com
27
66
  executables: []
28
67
 
29
68
  extensions: []
30
69
 
31
- extra_rdoc_files:
32
- - LICENSE
33
- - README.markdown
70
+ extra_rdoc_files: []
71
+
34
72
  files:
35
73
  - .document
36
74
  - .gitignore
75
+ - .travis.yml
76
+ - Gemfile
37
77
  - LICENSE
38
78
  - README.markdown
39
79
  - Rakefile
40
- - VERSION
41
80
  - fiscali.gemspec
42
81
  - install.rb
43
82
  - lib/fiscali.rb
44
83
  - lib/rising_sun/fiscali.rb
45
- - test/fiscali_test.rb
46
- - test/test_helper.rb
47
- has_rdoc: true
48
- homepage: http://asanghi.github.com/fiscali
84
+ - lib/rising_sun/version.rb
85
+ - spec/fiscali_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: https://github.com/asanghi/fiscali
49
88
  licenses: []
50
89
 
51
90
  post_install_message:
52
- rdoc_options:
53
- - --charset=UTF-8
91
+ rdoc_options: []
92
+
54
93
  require_paths:
55
94
  - lib
56
95
  required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
57
97
  requirements:
58
98
  - - ">="
59
99
  - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
60
103
  version: "0"
61
- version:
62
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
63
106
  requirements:
64
107
  - - ">="
65
108
  - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
66
112
  version: "0"
67
- version:
68
113
  requirements: []
69
114
 
70
115
  rubyforge_project:
71
- rubygems_version: 1.3.5
116
+ rubygems_version: 1.8.11
72
117
  signing_key:
73
118
  specification_version: 3
74
119
  summary: Fiscal Year Date Functions
75
120
  test_files:
76
- - test/fiscali_test.rb
77
- - test/test_helper.rb
121
+ - spec/fiscali_spec.rb
122
+ - spec/spec_helper.rb
123
+ has_rdoc:
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.2.5
data/test/fiscali_test.rb DELETED
@@ -1,62 +0,0 @@
1
- require 'test_helper'
2
-
3
- class FiscaliTest < ActiveSupport::TestCase
4
- test "date test" do
5
- Date.fiscal_zone = :india
6
- assert_equal(Date.fiscal_zone,:india)
7
- assert_equal(Date.fy_start_month,4)
8
- Date.fy_start_month = 2
9
- assert_equal(Date.fy_start_month,2)
10
-
11
- Date.fiscal_zone = :india
12
-
13
- d = Date.financial_year_start(2009)
14
- assert_equal(d,Date.new(2009,4,1),'Financial Year start not correct')
15
-
16
- d = Date.new(2009,1,1)
17
- assert_equal(d.financial_year,2008,'Financial Year is not correct')
18
- assert_equal(d.beginning_of_financial_year,Date.new(2008,4,1),'Beginning of FY is not correct')
19
- assert_equal(d.beginning_of_financial_h1,Date.new(2008,4,1),'Beginning of h1 is not correct')
20
- assert_equal(d.beginning_of_financial_h2,Date.new(2008,10,1),'Beginning of h2 is not correct')
21
- assert_equal(d.beginning_of_financial_q1,Date.new(2008,4,1),'Beginning of q1 is not correct')
22
- assert_equal(d.beginning_of_financial_q2,Date.new(2008,7,1),'Beginning of q2 is not correct')
23
- assert_equal(d.beginning_of_financial_q3,Date.new(2008,10,1),'Beginning of q3 is not correct')
24
- assert_equal(d.beginning_of_financial_q4,Date.new(2009,1,1),'Beginning of q4 is not correct')
25
-
26
- assert_equal(d.end_of_financial_year,Date.new(2009,3,31),'End of FY is not correct')
27
- assert_equal(d.end_of_financial_h1,Date.new(2008,9,30),'End of h1 is not correct')
28
- assert_equal(d.end_of_financial_h2,Date.new(2009,3,31),'End of h2 is not correct')
29
- assert_equal(d.end_of_financial_q1,Date.new(2008,6,30),'End of q1 is not correct')
30
- assert_equal(d.end_of_financial_q2,Date.new(2008,9,30),'End of q2 is not correct')
31
- assert_equal(d.end_of_financial_q3,Date.new(2008,12,31),'End of q3 is not correct')
32
- assert_equal(d.end_of_financial_q4,Date.new(2009,3,31),'End of q4 is not correct')
33
-
34
- assert_equal(d.financial_quarter,'Q4 2008','Financial Quarter is not correct')
35
- assert_equal(Date.new(2008,4,1).financial_quarter,'Q1 2008','Financial Quarter is not correct')
36
- assert_equal(d.financial_half,'H2 2008','Financial Half is not correct')
37
- assert_equal(Date.new(2009,11,30).financial_half,'H2 2009','Financial Half is not correct')
38
-
39
- assert_equal(d.next_financial_half,Date.new(2009,4,1),'Next Financial Half is not correct')
40
- assert_equal(d.next_financial_quarter,Date.new(2009,4,1),'Next Financial Quarter is not correct')
41
- assert_equal(Date.new(2009,6,1).next_financial_half,Date.new(2009,10,1), 'Next Financial Half is not correct')
42
- assert_equal(Date.new(2009,10,30).next_financial_quarter,Date.new(2010,1,1),'Next Financial Quarter is not correct')
43
-
44
- assert_equal(d.beginning_of_financial_half,
45
- Date.new(2008,10,1),'Beginning of Financial Half is not correct')
46
- assert_equal(d.beginning_of_financial_quarter,
47
- Date.new(2009,1,1),'Beginning of Financial Quarter is not correct')
48
- assert_equal(Date.new(2009,6,1).beginning_of_financial_half,
49
- Date.new(2009,4,1), 'Beginning of Financial Half is not correct')
50
- assert_equal(Date.new(2009,10,30).beginning_of_financial_quarter,
51
- Date.new(2009,10,1),'Beginning of Financial Quarter is not correct')
52
-
53
- assert_equal(d.previous_financial_half,
54
- Date.new(2008,4,1),'Previous Financial Half is not correct')
55
- assert_equal(d.previous_financial_quarter,
56
- Date.new(2008,10,1),'Previous Financial Quarter is not correct')
57
- assert_equal(Date.new(2009,6,1).previous_financial_half,
58
- Date.new(2008,10,1), 'Previous Financial Half is not correct')
59
- assert_equal(Date.new(2009,10,30).previous_financial_quarter,
60
- Date.new(2009,7,1),'Previous Financial Quarter is not correct')
61
- end
62
- end
data/test/test_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_support/test_case'