fiscali 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/rising_sun/fiscali.rb +16 -3
- data/lib/rising_sun/version.rb +1 -1
- data/spec/fiscali_spec.rb +34 -0
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OGNlMGI0MzJkMTRiYWRkYWVjOTQ3YWU5NmFlNmIyMjkyMzMwZGFjNg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 668e7b14a08a01a3a0ccd9ade61bbfa89d8230ef
|
4
|
+
data.tar.gz: c3f349a09a79887b01faeaa00b004249d9574fff
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OTRmZGVlZGE1MzNjMDE1ODgyOGEwZmQ1MThhOTZjMmU2NTlmMTM0NDMzMjYy
|
11
|
-
ZTZhN2ExZDVlM2E5MTAxMmFmN2U1MDZhNmFjNjZjZjFjY2JmMTA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
M2QwNGE2Y2JkZjU0ZWMzODJhZDI0YzViMjQ5N2EwYWQyYTNmZjcwODRjODJi
|
14
|
-
MjE1NjI1Y2QzZGQ3YmFlZmVhNGMwMTg0NzNkNjJiMDJmZjVjZDBmMGY0YTU5
|
15
|
-
YTEyMGExY2Y5Y2I1NGZjYzQ3YTM5YWE5MTM3MjlkMTM3MTNjNDI=
|
6
|
+
metadata.gz: 2ff65d864bce592b41bc12e17e1ebd2550d096bb403ddd32631237416019fc9f6f4992b9e408ba7475cb00db65705a3ae4193b7aed6185b03e4060d3890df2bb
|
7
|
+
data.tar.gz: ab80fa725440ab431b915cf49efda63491abdcbffcb0db72261b7e905794012b41c70839b4bd5f5ede15eae5d13e5a5fbfce46799c5b552fa6a6e8660451e2b8
|
data/lib/rising_sun/fiscali.rb
CHANGED
@@ -51,7 +51,9 @@ module RisingSun
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def financial_year
|
54
|
-
if
|
54
|
+
if january_start_month?
|
55
|
+
self.year
|
56
|
+
elsif self.class.uses_forward_year?
|
55
57
|
self.month < start_month ? self.year : self.year + 1
|
56
58
|
else
|
57
59
|
self.month < start_month ? self.year - 1 : self.year
|
@@ -59,8 +61,7 @@ module RisingSun
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def beginning_of_financial_year
|
62
|
-
year
|
63
|
-
change(:year => year, :month => start_month, :day => 1).beginning_of_month
|
64
|
+
change(:year => year_of_financial_year_beginning, :month => start_month).beginning_of_month
|
64
65
|
end
|
65
66
|
|
66
67
|
def end_of_financial_year
|
@@ -126,6 +127,18 @@ module RisingSun
|
|
126
127
|
|
127
128
|
private
|
128
129
|
|
130
|
+
def year_of_financial_year_beginning
|
131
|
+
if self.class.uses_forward_year? && !january_start_month?
|
132
|
+
financial_year - 1
|
133
|
+
else
|
134
|
+
financial_year
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def january_start_month?
|
139
|
+
start_month == 1
|
140
|
+
end
|
141
|
+
|
129
142
|
def months_between
|
130
143
|
soy = self.beginning_of_financial_year
|
131
144
|
(self.month - soy.month) + 12 * (self.year - soy.year)
|
data/lib/rising_sun/version.rb
CHANGED
data/spec/fiscali_spec.rb
CHANGED
@@ -160,4 +160,38 @@ describe "fiscali" do
|
|
160
160
|
thread.join
|
161
161
|
expect(thread['my_fiscal_zone']).to eql(:india)
|
162
162
|
end
|
163
|
+
|
164
|
+
context "when the start month is January" do
|
165
|
+
around :each do |example|
|
166
|
+
old_fy_start_month = Date.fy_start_month
|
167
|
+
Date.fy_start_month = 1
|
168
|
+
@date = Date.new(2014, 1, 1)
|
169
|
+
example.run
|
170
|
+
Date.fy_start_month = old_fy_start_month
|
171
|
+
end
|
172
|
+
|
173
|
+
it "returns the date's year as the financial year" do
|
174
|
+
expect(@date.financial_year).to eql(2014)
|
175
|
+
end
|
176
|
+
|
177
|
+
context "when using forward year" do
|
178
|
+
around :each do |example|
|
179
|
+
Date.use_forward_year!
|
180
|
+
example.run
|
181
|
+
Date.reset_forward_year!
|
182
|
+
end
|
183
|
+
|
184
|
+
it "returns the date's year as the financial year" do
|
185
|
+
expect(@date.financial_year).to eql(2014)
|
186
|
+
end
|
187
|
+
|
188
|
+
it "returns the date itself as the beginning_of_financial_year" do
|
189
|
+
expect(@date.beginning_of_financial_year).to eql(@date)
|
190
|
+
end
|
191
|
+
|
192
|
+
it "returns the date itself as the end_of_financial_year" do
|
193
|
+
expect(@date.end_of_financial_year).to eql(Date.new(2014, 12, 31))
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
163
197
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiscali
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditya Sanghi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.3'
|
55
55
|
description: Fiscal Year Date Functions
|
@@ -59,9 +59,9 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .document
|
63
|
-
- .gitignore
|
64
|
-
- .travis.yml
|
62
|
+
- ".document"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
65
|
- CHANGELOG
|
66
66
|
- Gemfile
|
67
67
|
- LICENSE
|
@@ -84,17 +84,17 @@ require_paths:
|
|
84
84
|
- lib
|
85
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.4.
|
97
|
+
rubygems_version: 2.4.5.1
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Fiscal Year Date Functions
|