tax_jp 1.1.6 → 1.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (17) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/tax_jp/social_insurances/index.html.erb +18 -5
  3. data/data//346/272/220/346/263/211/345/276/264/345/217/216/347/250/216//346/272/220/346/263/211/345/276/264/345/217/216/347/250/216/346/234/210/351/241/{215-20200101-20201231.tsv → 215-20200101-20211231.tsv} +0 -0
  4. data/data//346/272/220/346/263/211/345/276/264/345/217/216/347/250/216//346/272/220/346/263/211/345/276/264/345/217/216/347/250/216/350/263/236/344/270/{216-20200101-20201231.tsv → 216-20200101-20211231.tsv} +0 -0
  5. data/data//346/272/220/346/263/211/345/276/264/345/217/216/347/250/216/346/234/210/351/241/215.db +0 -0
  6. data/data//346/272/220/346/263/211/345/276/264/345/217/216/347/250/216/350/263/236/344/270/216.db +0 -0
  7. data/data//347/244/276/344/274/232/344/277/235/351/231/272/346/226/231.db +0 -0
  8. data/data//347/244/276/344/274/232/344/277/235/351/231/272/346/226/231//345/201/245/345/272/267/344/277/235/351/231/272-20210301-20220228.tsv +48 -0
  9. data/data//347/244/276/344/274/232/344/277/235/351/231/272/346/226/231//347/255/211/347/264/{232-20161001-20991231.tsv → 232-20161001-20200831.tsv} +0 -0
  10. data/data//347/244/276/344/274/232/344/277/235/351/231/272/346/226/231//347/255/211/347/264/232-20200901-20991231.tsv +51 -0
  11. data/lib/tax_jp/social_insurance.rb +22 -5
  12. data/lib/tax_jp/social_insurances/db_builder.rb +1 -9
  13. data/lib/tax_jp/social_insurances/health_insurance.rb +3 -1
  14. data/lib/tax_jp/social_insurances/welfare_pension.rb +4 -4
  15. data/lib/tax_jp/utils.rb +4 -2
  16. data/lib/tax_jp/version.rb +1 -1
  17. metadata +13 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16fa069e5fd7bbb50c521b0366430aa83a0a7a0f2c8eb1bc91b691dfcf34bd72
4
- data.tar.gz: f53602c28ca0e9bda338f359bd7ea63e5f90ab0d3e8dd6e6059051a9d7aefe54
3
+ metadata.gz: 91b3e81185d352f8074e37587f4d614d4212d02ec3a0b8841beda2ac7648ba55
4
+ data.tar.gz: 7cffccbde3108a384809f05e016098d24ca86343fb0c73a80c22d608857e5891
5
5
  SHA512:
6
- metadata.gz: b938a93996c29d76ce332a13ad9481686ab96dabc72fc3445dc379409fa5fa70771b0eb9578707619a7d45e2d32c6946915532b0d8c42cf7d9a05f59d673f89e
7
- data.tar.gz: 6dcb93eca7a1f92c3151dacd5df4ed77346f35057bb10c46d5d0bab98dc6dfc0f0468f00a85354b91678d0b66a07d4ee82befa7bc070995f98735118796efbf4
6
+ metadata.gz: c387eb573c8ee59d230cdc8c4ced099b9efa02972bafb96249738043cec7bbd2bf5050d83bf39ffaa997f2a2004afacb024cc438dd8396df615da6ee5330243d
7
+ data.tar.gz: 6f80fc2378b4ad9f79f94d3c4818f4fe609cb9bde2887f9b9889ca1b041a23c3f2855106b207a3ce3563df5214032b406a190dc772e26fb8d76ca09736acf240
@@ -48,7 +48,12 @@
48
48
  <tbody>
49
49
  <% @social_insurances.each do |si| %>
50
50
  <tr>
51
- <td class="text-center"><%= si.grade.grade %><%= "(#{si.grade.pension_grade})" if si.welfare_pension.general_amount > 0 %></td>
51
+ <% if [0, TaxJp::INTEGER_MAX].exclude?(si.grade.pension_grade) %>
52
+ <td class="text-center"><%= si.grade.grade %>(<%= si.grade.pension_grade %>)</td>
53
+ <% else %>
54
+ <td class="text-center"><%= si.grade.grade %></td>
55
+ <% end %>
56
+
52
57
  <td class="text-right"><%= si.grade.monthly_standard.to_s(:delimited) %></td>
53
58
  <td class="text-right"><%= si.grade.daily_standard.to_s(:delimited) %></td>
54
59
  <td class="text-right"><%= si.grade.salary_from.to_s(:delimited) %></td>
@@ -57,10 +62,18 @@
57
62
  <td class="text-right"><%= si.health_insurance.general_amount_half.to_s(:delimited) %></td>
58
63
  <td class="text-right"><%= si.health_insurance.general_amount_care.to_s(:delimited) %></td>
59
64
  <td class="text-right"><%= si.health_insurance.general_amount_care_half.to_s(:delimited) %></td>
60
- <td class="text-right"><%= number_to_currency(si.welfare_pension.general_amount, unit: '', precision: 2) if si.welfare_pension.general_amount > 0 %></td>
61
- <td class="text-right"><%= number_to_currency(si.welfare_pension.general_amount_half, unit: '', precision: 2) if si.welfare_pension.general_amount_half > 0 %></td>
62
- <td class="text-right"><%= number_to_currency(si.welfare_pension.particular_amount, unit: '', precision: 2) if si.welfare_pension.particular_amount > 0 %></td>
63
- <td class="text-right"><%= number_to_currency(si.welfare_pension.particular_amount_half, unit: '', precision: 2) if si.welfare_pension.particular_amount_half > 0 %></td>
65
+
66
+ <% if [0, TaxJp::INTEGER_MAX].exclude?(si.grade.pension_grade) %>
67
+ <td class="text-right"><%= number_to_currency(si.welfare_pension.general_amount, unit: '', precision: 2) if si.welfare_pension.general_amount > 0 %></td>
68
+ <td class="text-right"><%= number_to_currency(si.welfare_pension.general_amount_half, unit: '', precision: 2) if si.welfare_pension.general_amount_half > 0 %></td>
69
+ <td class="text-right"><%= number_to_currency(si.welfare_pension.particular_amount, unit: '', precision: 2) if si.welfare_pension.particular_amount > 0 %></td>
70
+ <td class="text-right"><%= number_to_currency(si.welfare_pension.particular_amount_half, unit: '', precision: 2) if si.welfare_pension.particular_amount_half > 0 %></td>
71
+ <% else %>
72
+ <td></td>
73
+ <td></td>
74
+ <td></td>
75
+ <td></td>
76
+ <% end %>
64
77
  </tr>
65
78
  <% end %>
66
79
  </tbody>
@@ -0,0 +1,48 @@
1
+ 都道府県 一般保険料率(%) 介護保険料率(%) 特定保険料率(%) 基本保険料率(%)
2
+ 北海道 10.45 1.8 3.53 6.92
3
+ 青森県 9.96 1.8 3.53 6.43
4
+ 岩手県 9.74 1.8 3.53 6.21
5
+ 宮城県 10.01 1.8 3.53 6.48
6
+ 秋田県 10.16 1.8 3.53 6.63
7
+ 山形県 10.03 1.8 3.53 6.5
8
+ 福島県 9.64 1.8 3.53 6.11
9
+ 茨城県 9.74 1.8 3.53 6.21
10
+ 栃木県 9.87 1.8 3.53 6.34
11
+ 群馬県 9.66 1.8 3.53 6.13
12
+ 埼玉県 9.8 1.8 3.53 6.27
13
+ 千葉県 9.79 1.8 3.53 6.26
14
+ 東京都 9.84 1.8 3.53 6.31
15
+ 神奈川県 9.99 1.8 3.53 6.46
16
+ 新潟県 9.5 1.8 3.53 5.97
17
+ 富山県 9.59 1.8 3.53 6.06
18
+ 石川県 10.11 1.8 3.53 6.58
19
+ 福井県 9.98 1.8 3.53 6.45
20
+ 山梨県 9.79 1.8 3.53 6.26
21
+ 長野県 9.71 1.8 3.53 6.18
22
+ 岐阜県 9.83 1.8 3.53 6.3
23
+ 静岡県 9.72 1.8 3.53 6.19
24
+ 愛知県 9.91 1.8 3.53 6.38
25
+ 三重県 9.81 1.8 3.53 6.28
26
+ 滋賀県 9.78 1.8 3.53 6.25
27
+ 京都府 10.06 1.8 3.53 6.53
28
+ 大阪府 10.29 1.8 3.53 6.76
29
+ 兵庫県 10.24 1.8 3.53 6.71
30
+ 奈良県 10 1.8 3.53 6.47
31
+ 和歌山県 10.11 1.8 3.53 6.58
32
+ 鳥取県 9.97 1.8 3.53 6.44
33
+ 島根県 10.03 1.8 3.53 6.5
34
+ 岡山県 10.18 1.8 3.53 6.65
35
+ 広島県 10.04 1.8 3.53 6.51
36
+ 山口県 10.22 1.8 3.53 6.69
37
+ 徳島県 10.29 1.8 3.53 6.76
38
+ 香川県 10.28 1.8 3.53 6.75
39
+ 愛媛県 10.22 1.8 3.53 6.69
40
+ 高知県 10.17 1.8 3.53 6.64
41
+ 福岡県 10.22 1.8 3.53 6.69
42
+ 佐賀県 10.68 1.8 3.53 7.15
43
+ 長崎県 10.26 1.8 3.53 6.73
44
+ 熊本県 10.29 1.8 3.53 6.76
45
+ 大分県 10.3 1.8 3.53 6.77
46
+ 宮崎県 9.83 1.8 3.53 6.3
47
+ 鹿児島県 10.36 1.8 3.53 6.83
48
+ 沖縄県 9.95 1.8 3.53 6.42
@@ -0,0 +1,51 @@
1
+ 等級(健康保険) 等級(厚生年金) 標準報酬月額 標準報酬日額 報酬月額(以上) 報酬月額(未満)
2
+ 1 0 58000 1930 0 63000
3
+ 2 0 68000 2270 63000 73000
4
+ 3 0 78000 2600 73000 83000
5
+ 4 1 88000 2930 83000 93000
6
+ 5 2 98000 3270 93000 101000
7
+ 6 3 104000 3470 101000 107000
8
+ 7 4 110000 3670 107000 114000
9
+ 8 5 118000 3930 114000 122000
10
+ 9 6 126000 4200 122000 130000
11
+ 10 7 134000 4470 130000 138000
12
+ 11 8 142000 4730 138000 146000
13
+ 12 9 150000 5000 146000 155000
14
+ 13 10 160000 5330 155000 165000
15
+ 14 11 170000 5670 165000 175000
16
+ 15 12 180000 6000 175000 185000
17
+ 16 13 190000 6330 185000 195000
18
+ 17 14 200000 6670 195000 210000
19
+ 18 15 220000 7330 210000 230000
20
+ 19 16 240000 8000 230000 250000
21
+ 20 17 260000 8670 250000 270000
22
+ 21 18 280000 9330 270000 290000
23
+ 22 19 300000 10000 290000 310000
24
+ 23 20 320000 10670 310000 330000
25
+ 24 21 340000 11330 330000 350000
26
+ 25 22 360000 12000 350000 370000
27
+ 26 23 380000 12670 370000 395000
28
+ 27 24 410000 13670 395000 425000
29
+ 28 25 440000 14670 425000 455000
30
+ 29 26 470000 15670 455000 485000
31
+ 30 27 500000 16670 485000 515000
32
+ 31 28 530000 17670 515000 545000
33
+ 32 29 560000 18670 545000 575000
34
+ 33 30 590000 19670 575000 605000
35
+ 34 31 620000 20670 605000 635000
36
+ 35 32 650000 21670 635000 665000
37
+ 36 - 680000 22670 665000 695000
38
+ 37 - 710000 23670 695000 730000
39
+ 38 - 750000 25000 730000 770000
40
+ 39 - 790000 26330 770000 810000
41
+ 40 - 830000 27670 810000 855000
42
+ 41 - 880000 29330 855000 905000
43
+ 42 - 930000 31000 905000 955000
44
+ 43 - 980000 32670 955000 1005000
45
+ 44 - 1030000 34330 1005000 1055000
46
+ 45 - 1090000 36330 1055000 1115000
47
+ 46 - 1150000 38330 1115000 1175000
48
+ 47 - 1210000 40330 1175000 1235000
49
+ 48 - 1270000 42330 1235000 1295000
50
+ 49 - 1330000 44330 1295000 1355000
51
+ 50 - 1390000 46330 1355000 -
@@ -85,18 +85,19 @@ module TaxJp
85
85
  prefecture_code = convert_to_prefecture_code(prefecture)
86
86
  salary = salary.to_i
87
87
 
88
- ret = nil
89
-
90
88
  TaxJp::Utils.with_database(DB_PATH) do |db|
91
89
  sql, params = base_query(date, prefecture_code)
92
90
 
93
91
  sql << 'where g.valid_from <= ? and g.valid_until >= ? and g.salary_from <= ? and g.salary_to > ? '
94
92
  params += [date, date, salary, salary]
95
93
 
96
- ret = nil
97
- db.execute(sql, params) do |row|
98
- ret = TaxJp::SocialInsurance.new(row)
94
+ row = db.execute(sql, params).first
95
+ ret = TaxJp::SocialInsurance.new(row)
96
+
97
+ if ret.welfare_pension.grade.pension_grade == TaxJp::INTEGER_MAX
98
+ ret.welfare_pension.grade = find_max_pension_grade_by_date(date)
99
99
  end
100
+
100
101
  ret
101
102
  end
102
103
  end
@@ -137,6 +138,22 @@ module TaxJp
137
138
  end
138
139
  end
139
140
 
141
+ def self.find_max_pension_grade_by_date(date)
142
+ date = TaxJp::Utils.convert_to_date(date)
143
+
144
+ TaxJp::Utils.with_database(DB_PATH, results_as_hash: true) do |db|
145
+ sql = 'select * from grades '
146
+ sql << 'where valid_from <= ? and valid_until >= ? and pension_grade = ( '
147
+ sql << ' select max(pension_grade) from grades '
148
+ sql << ' where valid_from <= ? and valid_until >= ? and pension_grade < ? '
149
+ sql << ') '
150
+ params = [date, date, date, date, TaxJp::INTEGER_MAX]
151
+
152
+ row = db.execute(sql, params).first.with_indifferent_access
153
+ TaxJp::SocialInsurances::Grade.new(row)
154
+ end
155
+ end
156
+
140
157
  def self.find_welfare_pension_by_date_and_salary(date, salary)
141
158
  date = TaxJp::Utils.convert_to_date(date)
142
159
 
@@ -14,7 +14,7 @@ class TaxJp::SocialInsurances::DbBuilder < TaxJp::DbBuilder
14
14
 
15
15
  CSV.foreach(filename, :col_sep => "\t") do |row|
16
16
  next if row[0].to_i == 0 and row[1].to_i == 0
17
- db.execute(insert_sql_grade, [valid_from, valid_until] + row.map{|col| normalize_amount(col)})
17
+ db.execute(insert_sql_grade, [valid_from, valid_until] + row.map{|col| TaxJp::Utils.normalize_amount(col)})
18
18
  end
19
19
  end
20
20
 
@@ -105,14 +105,6 @@ class TaxJp::SocialInsurances::DbBuilder < TaxJp::DbBuilder
105
105
  ret
106
106
  end
107
107
 
108
- def normalize_amount(amount, options = {})
109
- if amount.to_s == '-'
110
- ret = 2147483647
111
- else
112
- ret = amount.to_s.gsub(',', '').to_i
113
- end
114
- end
115
-
116
108
  def filename_to_date(filename)
117
109
  title, valid_from, valid_until = File.basename(filename).split('.').first.split('-')
118
110
  valid_from = Date.strptime(valid_from, '%Y%m%d')
@@ -6,9 +6,11 @@ class TaxJp::SocialInsurances::HealthInsurance
6
6
  attr_reader :general, :care
7
7
  attr_reader :particular, :basic
8
8
 
9
- attr_accessor :salary
9
+ attr_writer :salary
10
10
 
11
11
  def initialize(attrs)
12
+ @salary = nil
13
+
12
14
  if attrs.is_a?(Hash)
13
15
  @grade = attrs[:grade]
14
16
  @valid_from = attrs[:valid_from]
@@ -1,13 +1,15 @@
1
1
  # 厚生年金
2
2
  class TaxJp::SocialInsurances::WelfarePension
3
- attr_reader :grade
4
3
  attr_reader :valid_from, :valid_until
5
4
  attr_reader :general, :particular
6
5
  attr_reader :child_support
7
6
 
8
- attr_accessor :salary
7
+ attr_accessor :grade
8
+ attr_writer :salary
9
9
 
10
10
  def initialize(attrs)
11
+ @salary = nil
12
+
11
13
  if attrs.is_a?(Hash)
12
14
  @grade = attrs[:grade]
13
15
  @valid_from = attrs[:valid_from]
@@ -49,14 +51,12 @@ class TaxJp::SocialInsurances::WelfarePension
49
51
  def monthly_standard
50
52
  raise '等級が指定されていません' unless grade
51
53
  return 0 if grade.pension_grade == 0
52
- return 0 if grade.pension_grade > 99
53
54
  grade.monthly_standard
54
55
  end
55
56
 
56
57
  def daily_standard
57
58
  raise '等級が指定されていません' unless grade
58
59
  return 0 if grade.pension_grade == 0
59
- return 0 if grade.pension_grade > 99
60
60
  grade.daily_standard
61
61
  end
62
62
 
data/lib/tax_jp/utils.rb CHANGED
@@ -27,8 +27,10 @@ module TaxJp
27
27
  File.write(dest, ERB.new(File.read(src), 0, '-').result)
28
28
  end
29
29
 
30
- def with_database(db_path)
30
+ def with_database(db_path, results_as_hash: false)
31
31
  db = SQLite3::Database.new(db_path)
32
+ db.results_as_hash = results_as_hash
33
+
32
34
  begin
33
35
  yield db
34
36
  ensure
@@ -67,7 +69,7 @@ module TaxJp
67
69
  end
68
70
 
69
71
  def filename_to_date(filename)
70
- title, valid_from, valid_until = File.basename(filename).split('.').first.split('-')
72
+ _, valid_from, valid_until = File.basename(filename).split('.').first.split('-')
71
73
  valid_from = Date.strptime(valid_from, '%Y%m%d')
72
74
  valid_until = Date.strptime(valid_until, '%Y%m%d')
73
75
  [valid_from.strftime('%Y-%m-%d'), valid_until.strftime('%Y-%m-%d')]
@@ -1,3 +1,3 @@
1
1
  module TaxJp
2
- VERSION = '1.1.6'
2
+ VERSION = '1.1.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tax_jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichylinux
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-03 00:00:00.000000000 Z
12
+ date: 2021-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bootstrap
@@ -65,14 +65,14 @@ dependencies:
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 4.3.3
68
+ version: '4.4'
69
69
  type: :runtime
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 4.3.3
75
+ version: '4.4'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: rails
78
78
  requirement: !ruby/object:Gem::Requirement
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.3.6
96
+ version: '1.3'
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.3.6
103
+ version: '1.3'
104
104
  description: 税金計算ライブラリ
105
105
  email:
106
106
  - ichylinux@gmail.com
@@ -161,9 +161,9 @@ files:
161
161
  - data/源泉徴収税/源泉徴収税月額-20130101-20151231.tsv
162
162
  - data/源泉徴収税/源泉徴収税月額-20160101-20161231.tsv
163
163
  - data/源泉徴収税/源泉徴収税月額-20170101-20191231.tsv
164
- - data/源泉徴収税/源泉徴収税月額-20200101-20201231.tsv
164
+ - data/源泉徴収税/源泉徴収税月額-20200101-20211231.tsv
165
165
  - data/源泉徴収税/源泉徴収税賞与-20180101-20191231.tsv
166
- - data/源泉徴収税/源泉徴収税賞与-20200101-20201231.tsv
166
+ - data/源泉徴収税/源泉徴収税賞与-20200101-20211231.tsv
167
167
  - data/源泉徴収税月額.db
168
168
  - data/源泉徴収税賞与.db
169
169
  - data/社会保険料.db
@@ -182,12 +182,14 @@ files:
182
182
  - data/社会保険料/健康保険-20180301-20190228.tsv
183
183
  - data/社会保険料/健康保険-20190301-20200229.tsv
184
184
  - data/社会保険料/健康保険-20200301-20210228.tsv
185
+ - data/社会保険料/健康保険-20210301-20220228.tsv
185
186
  - data/社会保険料/厚生年金.tsv
186
187
  - data/社会保険料/旧健康保険.tsv
187
188
  - data/社会保険料/等級-20001001-20080831.tsv
188
189
  - data/社会保険料/等級-20080901-20160331.tsv
189
190
  - data/社会保険料/等級-20160401-20160930.tsv
190
- - data/社会保険料/等級-20161001-20991231.tsv
191
+ - data/社会保険料/等級-20161001-20200831.tsv
192
+ - data/社会保険料/等級-20200901-20991231.tsv
191
193
  - data/都道府県.yml
192
194
  - data/雇用保険料.db
193
195
  - lib/build_tasks/build.rake
@@ -233,14 +235,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
235
  requirements:
234
236
  - - "~>"
235
237
  - !ruby/object:Gem::Version
236
- version: '2.4'
238
+ version: '2.5'
237
239
  required_rubygems_version: !ruby/object:Gem::Requirement
238
240
  requirements:
239
241
  - - ">="
240
242
  - !ruby/object:Gem::Version
241
243
  version: '0'
242
244
  requirements: []
243
- rubygems_version: 3.0.4
245
+ rubygems_version: 3.1.4
244
246
  signing_key:
245
247
  specification_version: 4
246
248
  summary: 税金計算ライブラリ