tax_jp 1.1.3 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (19) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/tax_jp/social_insurances/index.html.erb +18 -5
  3. data/data//345/212/264/345/203/215/344/277/235/351/231/272//351/233/207/347/224/250/344/277/235/351/231/272.tsv +1 -1
  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/346/234/210/351/241/{215-20200101-20201231.tsv → 215-20200101-20211231.tsv} +0 -0
  5. 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
  6. 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
  7. 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
  8. data/data//347/244/276/344/274/232/344/277/235/351/231/272/346/226/231.db +0 -0
  9. 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-20200301-20210228.tsv +48 -0
  10. data/data//347/244/276/344/274/232/344/277/235/351/231/272/346/226/231//345/216/232/347/224/237/345/271/264/351/207/221.tsv +7 -3
  11. 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
  12. 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
  13. data/data//351/233/207/347/224/250/344/277/235/351/231/272/346/226/231.db +0 -0
  14. data/lib/tax_jp/social_insurance.rb +22 -5
  15. data/lib/tax_jp/social_insurances/db_builder.rb +1 -9
  16. data/lib/tax_jp/social_insurances/welfare_pension.rb +1 -3
  17. data/lib/tax_jp/utils.rb +3 -1
  18. data/lib/tax_jp/version.rb +1 -1
  19. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 525fa9a1639ef44af3d8db2a3f10553e19bb063d36904d8f583d42209cc60261
4
- data.tar.gz: 0b82b1c64ebdc989db116d082754afe7f6fe75b3ada7d07e987a9c760854c22b
3
+ metadata.gz: dd42cdf824adc2cb4f4c91a48d794304a7601e1839190705460f8c97af1c8b4b
4
+ data.tar.gz: 3ea356a73500d999f57c62c0b31d5e4f45fcf5044c842f11cea92c4303f26b65
5
5
  SHA512:
6
- metadata.gz: 79e95cc0007490e1b15552f87b0d8a839f41a37c94b335f8fd9ed0f57aa66ac0e0d14e84e00922cc4f4c7fd245922596d8c1c9147b92b50a3b0cf2f15ac22dc1
7
- data.tar.gz: 2a4e7eb97a8c45a4df9ebc200c89e07f5b7fc4daa213630cb22ec963f8f6906284822b2b9e7033f43cd8b5d7a29dc0f86119930ab0b58e695b6d3f625f140eeb
6
+ metadata.gz: c8959d38726417a0610005b5c2fd21049b0701c0609325ffca216f3052689c7666dc0c77cd602e4f75b822c4cadacef39e45ce8f30a132cdf8587750a54386f0
7
+ data.tar.gz: ed2f8afa0d734d3001d715713f1f32157eacdd29d8e19dd094395897314dfd6ffcf53249e6b31e942be5e115263a3c3e9381154763cf6af166cad8e786fd911d
@@ -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>
@@ -4,4 +4,4 @@
4
4
  2010-04-01 2012-03-31 0.006 0.0095 0.007 0.0105 0.007 0.0115
5
5
  2012-04-01 2016-03-31 0.005 0.0085 0.006 0.0095 0.006 0.0105
6
6
  2016-04-01 2017-03-31 0.004 0.007 0.005 0.008 0.005 0.009
7
- 2017-04-01 2020-03-31 0.003 0.006 0.004 0.007 0.004 0.008
7
+ 2017-04-01 2021-03-31 0.003 0.006 0.004 0.007 0.004 0.008
@@ -0,0 +1,48 @@
1
+ 都道府県 一般保険料率(%) 介護保険料率(%) 特定保険料率(%) 基本保険料率(%)
2
+ 北海道 10.41 1.79 3.43 6.98
3
+ 青森県 9.88 1.79 3.43 6.45
4
+ 岩手県 9.77 1.79 3.43 6.34
5
+ 宮城県 10.06 1.79 3.43 6.63
6
+ 秋田県 10.25 1.79 3.43 6.82
7
+ 山形県 10.05 1.79 3.43 6.62
8
+ 福島県 9.71 1.79 3.43 6.28
9
+ 茨城県 9.77 1.79 3.43 6.34
10
+ 栃木県 9.88 1.79 3.43 6.45
11
+ 群馬県 9.77 1.79 3.43 6.34
12
+ 埼玉県 9.81 1.79 3.43 6.38
13
+ 千葉県 9.75 1.79 3.43 6.32
14
+ 東京都 9.87 1.79 3.43 6.44
15
+ 神奈川県 9.93 1.79 3.43 6.5
16
+ 新潟県 9.58 1.79 3.43 6.15
17
+ 富山県 9.59 1.79 3.43 6.16
18
+ 石川県 10.01 1.79 3.43 6.58
19
+ 福井県 9.95 1.79 3.43 6.52
20
+ 山梨県 9.81 1.79 3.43 6.38
21
+ 長野県 9.7 1.79 3.43 6.27
22
+ 岐阜県 9.92 1.79 3.43 6.49
23
+ 静岡県 9.73 1.79 3.43 6.3
24
+ 愛知県 9.88 1.79 3.43 6.45
25
+ 三重県 9.77 1.79 3.43 6.34
26
+ 滋賀県 9.79 1.79 3.43 6.36
27
+ 京都府 10.03 1.79 3.43 6.6
28
+ 大阪府 10.22 1.79 3.43 6.79
29
+ 兵庫県 10.14 1.79 3.43 6.71
30
+ 奈良県 10.14 1.79 3.43 6.71
31
+ 和歌山県 10.14 1.79 3.43 6.71
32
+ 鳥取県 9.99 1.79 3.43 6.56
33
+ 島根県 10.15 1.79 3.43 6.72
34
+ 岡山県 10.17 1.79 3.43 6.74
35
+ 広島県 10.01 1.79 3.43 6.58
36
+ 山口県 10.2 1.79 3.43 6.77
37
+ 徳島県 10.28 1.79 3.43 6.85
38
+ 香川県 10.34 1.79 3.43 6.91
39
+ 愛媛県 10.07 1.79 3.43 6.64
40
+ 高知県 10.3 1.79 3.43 6.87
41
+ 福岡県 10.32 1.79 3.43 6.89
42
+ 佐賀県 10.73 1.79 3.43 7.3
43
+ 長崎県 10.22 1.79 3.43 6.79
44
+ 熊本県 10.33 1.79 3.43 6.9
45
+ 大分県 10.17 1.79 3.43 6.74
46
+ 宮崎県 9.91 1.79 3.43 6.48
47
+ 鹿児島県 10.25 1.79 3.43 6.82
48
+ 沖縄県 9.97 1.79 3.43 6.54
@@ -8,6 +8,10 @@
8
8
  2012-09-01 2013-08-31 16.766 17.192 0.15
9
9
  2013-09-01 2014-08-31 17.12 17.4 0.15
10
10
  2014-09-01 2015-08-31 17.474 17.688 0.15
11
- 2015-09-01 2016-08-31 17.828 17.936 0.15
12
- 2016-09-01 2017-08-31 18.182 18.184 0.15
13
- 2017-09-01 2099-12-31 18.3 18.3 0.15
11
+ 2015-09-01 2016-03-31 17.828 17.936 0.15
12
+ 2016-04-01 2016-08-31 17.828 17.936 0.2
13
+ 2016-09-01 2017-08-31 18.182 18.184 0.2
14
+ 2017-09-01 2018-03-31 18.3 18.3 0.23
15
+ 2018-04-01 2019-03-31 18.3 18.3 0.29
16
+ 2019-04-01 2020-03-31 18.3 18.3 0.34
17
+ 2020-04-01 2099-12-31 18.3 18.3 0.36
@@ -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')
@@ -1,10 +1,10 @@
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
 
7
+ attr_accessor :grade
8
8
  attr_accessor :salary
9
9
 
10
10
  def initialize(attrs)
@@ -49,14 +49,12 @@ class TaxJp::SocialInsurances::WelfarePension
49
49
  def monthly_standard
50
50
  raise '等級が指定されていません' unless grade
51
51
  return 0 if grade.pension_grade == 0
52
- return 0 if grade.pension_grade > 99
53
52
  grade.monthly_standard
54
53
  end
55
54
 
56
55
  def daily_standard
57
56
  raise '等級が指定されていません' unless grade
58
57
  return 0 if grade.pension_grade == 0
59
- return 0 if grade.pension_grade > 99
60
58
  grade.daily_standard
61
59
  end
62
60
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module TaxJp
2
- VERSION = '1.1.3'
2
+ VERSION = '1.1.8'
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.3
4
+ version: 1.1.8
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-01-05 00:00:00.000000000 Z
12
+ date: 2021-01-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bootstrap
@@ -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
@@ -181,12 +181,14 @@ files:
181
181
  - data/社会保険料/健康保険-20170301-20180228.tsv
182
182
  - data/社会保険料/健康保険-20180301-20190228.tsv
183
183
  - data/社会保険料/健康保険-20190301-20200229.tsv
184
+ - data/社会保険料/健康保険-20200301-20210228.tsv
184
185
  - data/社会保険料/厚生年金.tsv
185
186
  - data/社会保険料/旧健康保険.tsv
186
187
  - data/社会保険料/等級-20001001-20080831.tsv
187
188
  - data/社会保険料/等級-20080901-20160331.tsv
188
189
  - data/社会保険料/等級-20160401-20160930.tsv
189
- - data/社会保険料/等級-20161001-20991231.tsv
190
+ - data/社会保険料/等級-20161001-20200831.tsv
191
+ - data/社会保険料/等級-20200901-20991231.tsv
190
192
  - data/都道府県.yml
191
193
  - data/雇用保険料.db
192
194
  - lib/build_tasks/build.rake