tax_jp 1.1.6 → 1.1.7

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: 16fa069e5fd7bbb50c521b0366430aa83a0a7a0f2c8eb1bc91b691dfcf34bd72
4
- data.tar.gz: f53602c28ca0e9bda338f359bd7ea63e5f90ab0d3e8dd6e6059051a9d7aefe54
3
+ metadata.gz: 1cf54a0a7ec52627b299f4691b601bf09b58a6b3de8edf92fa263c01162d5fbf
4
+ data.tar.gz: a55e1c0540f863e11c2cd74e1f7f3410d091dc5828e0188f19ad3afe8ac2b848
5
5
  SHA512:
6
- metadata.gz: b938a93996c29d76ce332a13ad9481686ab96dabc72fc3445dc379409fa5fa70771b0eb9578707619a7d45e2d32c6946915532b0d8c42cf7d9a05f59d673f89e
7
- data.tar.gz: 6dcb93eca7a1f92c3151dacd5df4ed77346f35057bb10c46d5d0bab98dc6dfc0f0468f00a85354b91678d0b66a07d4ee82befa7bc070995f98735118796efbf4
6
+ metadata.gz: 5fad3e3f6c0c7fcefce7d31c232336d0a3e5925b5f6b2ccce5829b31de2e36a29ceaf5b7f6cf3acb0b036fddbe3f64050da9c78f259f8e874397dd4daf8291f0
7
+ data.tar.gz: 0b35ed4fa326ab3069c05927f2666f81ce53e1ded5a16d2d1d8f30e6329ccbcdc13fa41cd6974858f4a7f63711307604c905e97162f6e4eb79ac1cc5701117b3
@@ -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,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.6'
2
+ VERSION = '1.1.7'
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.7
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: 2020-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bootstrap
@@ -187,7 +187,8 @@ files:
187
187
  - data/社会保険料/等級-20001001-20080831.tsv
188
188
  - data/社会保険料/等級-20080901-20160331.tsv
189
189
  - data/社会保険料/等級-20160401-20160930.tsv
190
- - data/社会保険料/等級-20161001-20991231.tsv
190
+ - data/社会保険料/等級-20161001-20200831.tsv
191
+ - data/社会保険料/等級-20200901-20991231.tsv
191
192
  - data/都道府県.yml
192
193
  - data/雇用保険料.db
193
194
  - lib/build_tasks/build.rake
@@ -240,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
241
  - !ruby/object:Gem::Version
241
242
  version: '0'
242
243
  requirements: []
243
- rubygems_version: 3.0.4
244
+ rubygems_version: 3.0.3
244
245
  signing_key:
245
246
  specification_version: 4
246
247
  summary: 税金計算ライブラリ