fiscali 2.2.1 → 2.3.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG +6 -0
- data/README.markdown +20 -23
- data/lib/rising_sun/fiscali.rb +12 -28
- data/lib/rising_sun/version.rb +1 -1
- data/spec/fiscali_spec.rb +38 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d186e022ab4c157c6bea6233b368582d8b60209
|
4
|
+
data.tar.gz: 26016d53cffee5d9fa33214d33522e4c087f13be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c74baca119cc86315439fe3d2051998a4aaf3f85f47e4b75364f947b98fe6da0e9f2ec4a08fd8e9216c447f7f0491fe983f982d4f661bdabd5605247a7c9cfa
|
7
|
+
data.tar.gz: 38b99fddf44dc254d770a61a750235ecb16761ec1acf48bcb51f87b2731a9d2e809eee679c61607fd3c1656fa560ec23bca0ab3eb90a8a31d11b94a54d2783b3
|
data/.travis.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
rvm:
|
2
|
-
- 1.
|
3
|
-
-
|
2
|
+
- 2.1.1
|
3
|
+
- 2.0.0
|
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
@@ -13,16 +13,11 @@ Fiscali provides ONE thing:
|
|
13
13
|
|
14
14
|
## Installing
|
15
15
|
|
16
|
-
# Install the gem (from gemcutter.org):
|
17
16
|
sudo gem install fiscali
|
18
17
|
|
19
18
|
## Using in your Rails project
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
config.gem "fiscali"
|
24
|
-
|
25
|
-
In newer Rails projects, include the gem in the Gemfile and run "bundle install" to install the gem.
|
20
|
+
In Rails projects, include the gem in the Gemfile and run "bundle install" to install the gem.
|
26
21
|
|
27
22
|
gem "fiscali"
|
28
23
|
|
@@ -75,7 +70,7 @@ By default, the Year Forward option is set to false, meaning the term FY 2008 sp
|
|
75
70
|
Date.fiscal_zone
|
76
71
|
=> nil
|
77
72
|
|
78
|
-
|
73
|
+
#### Year Forward (Assume Date.today is 1st May 2009 and the fy_start_month = 4)
|
79
74
|
|
80
75
|
Date.uses_forward_year?
|
81
76
|
=> false
|
@@ -144,9 +139,9 @@ Assume Date.today is 1st May 2009
|
|
144
139
|
##### financial_quarter -> Returns Q1, Q2, Q3, Q4 depending on where the date falls
|
145
140
|
|
146
141
|
Date.today.financial_quarter
|
147
|
-
=> Q1
|
142
|
+
=> Q1 2009
|
148
143
|
Date.today.beginning_of_year.financial_quarter
|
149
|
-
=> Q4
|
144
|
+
=> Q4 2009
|
150
145
|
|
151
146
|
##### financial_half -> Returns H1, H2 depending on where the date falls
|
152
147
|
|
@@ -165,12 +160,23 @@ Assume Date.today is 1st May 2009
|
|
165
160
|
Date.today.next_financial_half
|
166
161
|
=> 1st October 2009
|
167
162
|
|
168
|
-
##### beginning_of_financial_quarter -> Takes you to the beginning of the current financial quarter
|
163
|
+
##### beginning_of_financial_quarter -> Takes you to the beginning of a quarter in the current financial year (defaults to current quarter)
|
169
164
|
|
170
165
|
Date.today.beginning_of_financial_quarter
|
171
166
|
=> 1st April 2009
|
172
167
|
Date.today.beginning_of_year.beginning_of_financial_quarter
|
173
168
|
=> 1st Jan 2009
|
169
|
+
Date.today.beginning_of_financial_quarter(3)
|
170
|
+
=> 1st July 2009
|
171
|
+
|
172
|
+
##### end_of_financial_quarter -> Takes you to the end of a quarter in the current financial year (defaults to current quarter)
|
173
|
+
|
174
|
+
Date.today.end_of_financial_quarter
|
175
|
+
=> 30th June 2009
|
176
|
+
Date.today.beginning_of_year.end_of_financial_quarter
|
177
|
+
=> 31st March 2009
|
178
|
+
Date.today.end_of_financial_quarter(3)
|
179
|
+
=> 30th September 2009
|
174
180
|
|
175
181
|
##### beginning_of_financial_half -> Takes you to the beginning of the current financial half
|
176
182
|
|
@@ -196,17 +202,8 @@ Assume Date.today is 1st May 2009
|
|
196
202
|
|
197
203
|
## Contributors
|
198
204
|
|
199
|
-
@
|
200
|
-
@chiperific
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
205
|
+
* [@reed](https://github.com/reed)
|
206
|
+
* [@chiperific](https://github.com/chiperific)
|
207
|
+
* [@rshallit](https://github.com/rshallit)
|
208
|
+
* [@asanghi](https://github.com/asanghi)
|
212
209
|
|
data/lib/rising_sun/fiscali.rb
CHANGED
@@ -60,39 +60,18 @@ module RisingSun
|
|
60
60
|
|
61
61
|
def beginning_of_financial_year
|
62
62
|
year = self.class.uses_forward_year? ? financial_year - 1 : financial_year
|
63
|
-
change(:year => year, :month => start_month, :day => 1)
|
63
|
+
change(:year => year, :month => start_month, :day => 1).beginning_of_month
|
64
64
|
end
|
65
65
|
|
66
66
|
def end_of_financial_year
|
67
67
|
(beginning_of_financial_year + 1.year - 1.month).end_of_month
|
68
68
|
end
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
(1..4).each do |q|
|
71
|
+
define_method("beginning_of_financial_q#{q}"){ beginning_of_financial_quarter q }
|
72
|
+
define_method("end_of_financial_q#{q}"){ end_of_financial_quarter q }
|
73
73
|
end
|
74
74
|
|
75
|
-
def beginning_of_financial_q2
|
76
|
-
beginning_of_financial_year + 3.months
|
77
|
-
end
|
78
|
-
|
79
|
-
def end_of_financial_q2
|
80
|
-
end_of_financial_year - 6.months
|
81
|
-
end
|
82
|
-
|
83
|
-
def beginning_of_financial_q3
|
84
|
-
beginning_of_financial_year + 6.months
|
85
|
-
end
|
86
|
-
|
87
|
-
def end_of_financial_q3
|
88
|
-
end_of_financial_year - 3.months
|
89
|
-
end
|
90
|
-
|
91
|
-
def beginning_of_financial_q4
|
92
|
-
beginning_of_financial_year + 9.months
|
93
|
-
end
|
94
|
-
alias :end_of_financial_q4 :end_of_financial_year
|
95
|
-
|
96
75
|
alias :beginning_of_financial_h1 :beginning_of_financial_year
|
97
76
|
alias :end_of_financial_h1 :end_of_financial_q2
|
98
77
|
|
@@ -115,8 +94,14 @@ module RisingSun
|
|
115
94
|
beginning_of_financial_year.months_since(((months_between / 6).floor + 1) * 6)
|
116
95
|
end
|
117
96
|
|
118
|
-
def beginning_of_financial_quarter
|
119
|
-
|
97
|
+
def beginning_of_financial_quarter(quarter = nil)
|
98
|
+
quarter = (months_between / 3).floor + 1 unless quarter.in? 1..4
|
99
|
+
beginning_of_financial_year.advance(months: (quarter - 1) * 3).beginning_of_month
|
100
|
+
end
|
101
|
+
|
102
|
+
def end_of_financial_quarter(quarter = nil)
|
103
|
+
quarter = (months_between / 3).floor + 1 unless quarter.in? 1..4
|
104
|
+
beginning_of_financial_year.advance(months: quarter * 3 - 1).end_of_month
|
120
105
|
end
|
121
106
|
|
122
107
|
def beginning_of_financial_half
|
@@ -149,6 +134,5 @@ module RisingSun
|
|
149
134
|
def start_month
|
150
135
|
self.class.fy_start_month || FY_START_MONTH
|
151
136
|
end
|
152
|
-
|
153
137
|
end
|
154
138
|
end
|
data/lib/rising_sun/version.rb
CHANGED
data/spec/fiscali_spec.rb
CHANGED
@@ -54,8 +54,10 @@ describe "fiscali" do
|
|
54
54
|
|
55
55
|
context "should report correct date field" do
|
56
56
|
before(:each) do
|
57
|
+
Date.fiscal_zone = :india
|
57
58
|
@d = Date.new(2009,1,1)
|
58
59
|
end
|
60
|
+
|
59
61
|
it "should report correct financial year" do
|
60
62
|
@d.financial_year.should eql(2008)
|
61
63
|
end
|
@@ -81,6 +83,15 @@ describe "fiscali" do
|
|
81
83
|
@d.end_of_financial_q2.should eql(Date.new(2008,9,30))
|
82
84
|
@d.end_of_financial_q3.should eql(Date.new(2008,12,31))
|
83
85
|
@d.end_of_financial_q4.should eql(Date.new(2009,3,31))
|
86
|
+
|
87
|
+
Date.fiscal_zone = :us
|
88
|
+
|
89
|
+
@d.end_of_financial_h1.should eql(Date.new(2009,3,31))
|
90
|
+
@d.end_of_financial_h2.should eql(Date.new(2009,9,30))
|
91
|
+
@d.end_of_financial_q1.should eql(Date.new(2008,12,31))
|
92
|
+
@d.end_of_financial_q2.should eql(Date.new(2009,3,31))
|
93
|
+
@d.end_of_financial_q3.should eql(Date.new(2009,6,30))
|
94
|
+
@d.end_of_financial_q4.should eql(Date.new(2009,9,30))
|
84
95
|
end
|
85
96
|
|
86
97
|
it "should report financial quarters" do
|
@@ -116,6 +127,33 @@ describe "fiscali" do
|
|
116
127
|
|
117
128
|
end
|
118
129
|
|
130
|
+
context "should report correct timestamp" do
|
131
|
+
before(:each) do
|
132
|
+
Time.fiscal_zone = :india
|
133
|
+
@t = Time.new(2009,1,1,12,1,1)
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should report beginning of year/half/quarter with timestamp at beginning of day" do
|
137
|
+
@t.beginning_of_financial_year.should eql(Time.new(2008,4,1,0,0,0))
|
138
|
+
@t.beginning_of_financial_h1.should eql(Time.new(2008,4,1,0,0,0))
|
139
|
+
@t.beginning_of_financial_h2.should eql(Time.new(2008,10,1,0,0,0))
|
140
|
+
@t.beginning_of_financial_q1.should eql(Time.new(2008,4,1,0,0,0))
|
141
|
+
@t.beginning_of_financial_q2.should eql(Time.new(2008,7,1,0,0,0))
|
142
|
+
@t.beginning_of_financial_q3.should eql(Time.new(2008,10,1,0,0,0))
|
143
|
+
@t.beginning_of_financial_q4.should eql(Time.new(2009,1,1,0,0,0))
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should report end of year/half/quarter with timestamp at end of day" do
|
147
|
+
@t.end_of_financial_year.should eql(Time.new(2009,3,31).end_of_day)
|
148
|
+
@t.end_of_financial_h1.should eql(Time.new(2008,9,30).end_of_day)
|
149
|
+
@t.end_of_financial_h2.should eql(Time.new(2009,3,31).end_of_day)
|
150
|
+
@t.end_of_financial_q1.should eql(Time.new(2008,6,30).end_of_day)
|
151
|
+
@t.end_of_financial_q2.should eql(Time.new(2008,9,30).end_of_day)
|
152
|
+
@t.end_of_financial_q3.should eql(Time.new(2008,12,31).end_of_day)
|
153
|
+
@t.end_of_financial_q4.should eql(Time.new(2009,3,31).end_of_day)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
119
157
|
it "should not rely on app being single threaded" do
|
120
158
|
Date.fiscal_zone = :india
|
121
159
|
thread = Thread.new { Thread.current["my_fiscal_zone"] = Date.fiscal_zone }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiscali
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditya Sanghi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|