fiscal_year 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cf15774708a32e8499e3228288a15749adf62d98a7dc72ccc31e9cfc0b5b842
4
- data.tar.gz: 44dc1c5dc58d257bee352257abae21f5e02412d39d5aef76910ef34036a596bb
3
+ metadata.gz: 1468592d50121d359747c36cc467fac062fd25b0b50344668b612074133527d3
4
+ data.tar.gz: b5428700e7f8b6b256e33b854623d1079d5aa3b93ce8a1873a14c6c660b3e1fe
5
5
  SHA512:
6
- metadata.gz: 8e38a3d7c476be3d0e2889f608e73b52f04234553f2119fa665dc19143fb0fafadd6ef832dc4c42527096e7a402136992a4e2a4e5222109364522c32fca1de1a
7
- data.tar.gz: 591f594009aa1cfb7595a3c18720c8d7f88974a7510252f870f981d5518ef296ebdd2fb8b5eb8397bc040c263fc33d4ae0acd09cc76993c4f52731eac15dce36
6
+ metadata.gz: 9609eac23bd8fd86a94a7f218d1ed613ac6bc8b0b3f231ebdc0a9f90fe21653170eb996def584b6bd9cf448f9e8f4f8e78c0092fe505c542737cb7c329422711
7
+ data.tar.gz: 0b4f5c6f0ad8939f62964b72d0fbf10f7aab52108e9de956888b9f038a997d9f6aa458c63ee4e83990fb767157b61ab0fb2a6401b77bcb821355660c11b1f591
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.4.0] - 2023-06-15
2
+ - fix calculate logic of half year to date
3
+
1
4
  ## [0.3.0] - 2023-04-23
2
5
  - add rbs
3
6
  - fit to rbs
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ![build badge](https://github.com/TsubasaKawajiri/fiscal_year/actions/workflows/test.yml/badge.svg?branch=master)
2
- [![Gem Version](https://badge.fury.io/rb/fiscal_year.svg)](https://badge.fury.io/rb/fiscal_year)
2
+
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/39fdb48501c5f53235a9/maintainability)](https://codeclimate.com/github/TsubasaKawajiri/fiscal_year/maintainability)
4
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/39fdb48501c5f53235a9/test_coverage)](https://codeclimate.com/github/TsubasaKawajiri/fiscal_year/test_coverage)
5
5
 
@@ -34,13 +34,13 @@ module FiscalYear
34
34
 
35
35
  def range_by(date)
36
36
  year = date.year
37
- this_quater = months(date.month)
38
- last_year = cross_year_in_quarter?(this_quater) ? year + 1 : year
37
+ this_quarter = months(date.month)
38
+ last_year = cross_year_in_quarter?(this_quarter) ? year + 1 : year
39
39
 
40
- Date.parse("#{year}/#{this_quater.first}/01")..Date.parse("#{last_year}/#{this_quater.last}/01").end_of_month
40
+ Date.parse("#{year}/#{this_quarter.first}/01")..Date.parse("#{last_year}/#{this_quarter.last}/01").end_of_month
41
41
  end
42
42
 
43
- def quater_num(month)
43
+ def quarter_num(month)
44
44
  rindex = FiscalYear.quarters.rindex(months(month))
45
45
 
46
46
  rindex.nil? ? 0 : (rindex + 1)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiscalYear
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -34,7 +34,7 @@ module FiscalYear
34
34
  end
35
35
 
36
36
  # TODO: fit to Abc size
37
- def half_range_by(date) # rubocop:disable Metrics/AbcSize
37
+ def half_range_by(date) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
38
38
  year = date.year
39
39
  month = date.month
40
40
 
@@ -45,7 +45,14 @@ module FiscalYear
45
45
  end
46
46
 
47
47
  Date.parse(
48
- "#{FiscalYear::Half.cross_year_in_half?(Half.second) ? year - 1 : year}/#{Half.second.first}"
48
+ "#{
49
+ if FiscalYear::Half.cross_year_in_half?(Half.second) &&
50
+ FiscalYear.cross_year_month?(month)
51
+ year - 1
52
+ else
53
+ year
54
+ end
55
+ }/#{Half.second.first}"
49
56
  )..date.end_of_month.to_date
50
57
  end
51
58
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiscal_year
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsubasa Kawajiri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-23 00:00:00.000000000 Z
11
+ date: 2023-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport