luca-jp 0.15.0 → 0.16.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: 9ccff8e0a1ac15b855e0c104254c44817ec12f552b97af39e9f5c7179165f4c9
4
- data.tar.gz: c20d1a533a7dd27377fb0850673f8b4e1fb449225cfab44abf498262e4577c52
3
+ metadata.gz: ca379cda7bf415ef81ed4c7c72da443f1565f6b34e1bfad2e93c842aa71c011f
4
+ data.tar.gz: 8b5143397b416820bce2337169f4ff90b936bb712477b28bf3e5b2c457347471
5
5
  SHA512:
6
- metadata.gz: 5ce5fae3188a5b42b5829e5fc8cfe2e2c6c5fe4db8899c4835ea0a6bb830364e84096bc231884469d1ac6caff309123af11fc89ac8dc73c98df917a68bbc13a9
7
- data.tar.gz: 3ba9fc25ce665f4375343125211c19cfb4666436d7ff0398dea916747ba75012e59a54a2a10465f6be010f1cd90d18afdedd3583caf1cecd863c30771e0a9f3c
6
+ metadata.gz: 8e3812b030abf84a467eb10689c6dd9bd15b5265cbfcbf4ba2993a258b0c5a55454c276b69f95e23bdd07be93336d107d2de8360a4c6169559eded86eaecb502
7
+ data.tar.gz: 82f9f7fee16b38b1dbb63980a5a30e1ea9499bedb55608d93c3a759dd2e872df080e0c1a5ac3f776fa201cddc463c4af3fff88ccad3423311870a4591567c170
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Luca
4
4
  module Jp
5
- VERSION = '0.15.0'
5
+ VERSION = '0.16.0'
6
6
  end
7
7
  end
@@ -16,13 +16,15 @@ class LucaSalary::Jp < LucaSalary::Base
16
16
  __dir__
17
17
  end
18
18
 
19
- def calc_payment(profile)
19
+ def calc_payment(profile, date)
20
+ 配偶者控除 = profile.include?('spouse')
21
+ 扶養控除 = self.class.扶養控除対象者の数(profile['family'], Date.new(date.year, 12, 31))
20
22
  {}.tap do |h|
21
23
  select_code(profile, '1').each { |k, v| h[k] = v }
22
24
  h['201'] = @insurance.health_insurance_salary(insurance_rank(profile))
23
25
  h['202'] = @insurance.pension_salary(pension_rank(profile))
24
26
  tax_base = self.class.sum_code(h, '1', income_tax_exception) - h['201'] - h['202']
25
- h['203'] = JpNationalTax::IncomeTax.calc_kouran(tax_base, Date.today, true)
27
+ h['203'] = JpNationalTax::IncomeTax.calc_kouran(tax_base, Date.today, 配偶者控除, 扶養控除)
26
28
  h['211'] = resident_tax(profile)
27
29
  select_code(profile, '3').each { |k, v| h[k] = v }
28
30
  select_code(profile, '4').each { |k, v| h[k] = v }
@@ -31,13 +33,17 @@ class LucaSalary::Jp < LucaSalary::Base
31
33
  end
32
34
  end
33
35
 
34
- def self.year_total(payment, date)
36
+ def self.year_total(profile, payment, date)
37
+ raise '年末調整の対象となりません' if payment['1'] == 0
38
+
35
39
  payment.tap do |p|
36
40
  p['911'] = JpNationalTax::IncomeTax.basic_deduction(p['1'], date)
37
- p['916'] = partner_deduction(p['1'])
41
+ p['916'] = 配偶者控除の金額(p['1'], profile['spouse'], date)
42
+ p['917'] = 配偶者特別控除の金額(p['1'], profile['spouse'], date)
43
+ p['918'] = 扶養控除の金額(profile['family'], date)
38
44
  p['912'] = ['201', '202', '204', '205'].map{ |cd| p[cd] }.compact.sum
39
45
  p['901'] = JpNationalTax::IncomeTax.year_salary_taxable(p['1'], date)
40
- p['941'] = p['901'] - p['911'] - p['912'] - p['916']
46
+ p['941'] = p['901'] - ['911', '912', '916', '917', '918'].map{ |cd| p[cd] }.compact.sum
41
47
  p['961'] = JpNationalTax::IncomeTax.year_tax(p['941'], date)
42
48
  diff = p['961'] - p['203']
43
49
  if diff.positive?
@@ -54,18 +60,95 @@ class LucaSalary::Jp < LucaSalary::Base
54
60
  end
55
61
  end
56
62
 
57
- def self.partner_deduction(income)
58
- if income <= 9_000_000
59
- 380_000
60
- elsif income <= 9_500_000
61
- 260_000
62
- elsif income <= 10_000_000
63
- 130_000
63
+ def self.配偶者控除の金額(income, spouse, date)
64
+ puts spouse
65
+ return nil if spouse.nil?
66
+
67
+ puts spouse
68
+ spouse_salary = JpNationalTax::IncomeTax.year_salary_taxable(spouse['income'][date.year.to_s] || 0, date)
69
+ return 0 if spouse_salary > 480_000
70
+
71
+ salary = JpNationalTax::IncomeTax.year_salary_taxable(income || 0, date)
72
+ birth_date = spouse['birth_date'] || date
73
+ if salary <= 9_000_000
74
+ birth_date <= date.prev_year(70) ? 480_000 : 380_000
75
+ elsif salary <= 9_500_000
76
+ birth_date <= date.prev_year(70) ? 320_000 : 260_000
77
+ elsif salary <= 10_000_000
78
+ birth_date <= date.prev_year(70) ? 160_000 : 130_000
64
79
  else
65
80
  0
66
81
  end
67
82
  end
68
83
 
84
+ def self.配偶者特別控除の金額(income, spouse, date)
85
+ return nil if spouse.nil?
86
+
87
+ salary = JpNationalTax::IncomeTax.year_salary_taxable(income || 0, date)
88
+ return 0 if salary > 10_000_000
89
+
90
+ spouse_salary = JpNationalTax::IncomeTax.year_salary_taxable(spouse['income'][date.year.to_s] || 0, date)
91
+ return 0 if spouse_salary <= 480_000
92
+ return 0 if spouse_salary > 1_330_000
93
+
94
+ if salary <= 9_000_000
95
+ return 380_000 if spouse_salary <= 950_000
96
+ return 360_000 if spouse_salary <= 1_000_000
97
+ return 310_000 if spouse_salary <= 1_050_000
98
+ return 260_000 if spouse_salary <= 1_100_000
99
+ return 210_000 if spouse_salary <= 1_150_000
100
+ return 160_000 if spouse_salary <= 1_200_000
101
+ return 110_000 if spouse_salary <= 1_250_000
102
+ return 60_000 if spouse_salary <= 1_300_000
103
+ return 30_000
104
+ elsif salary <= 9_500_000
105
+ return 260_000 if spouse_salary <= 950_000
106
+ return 240_000 if spouse_salary <= 1_000_000
107
+ return 210_000 if spouse_salary <= 1_050_000
108
+ return 180_000 if spouse_salary <= 1_100_000
109
+ return 140_000 if spouse_salary <= 1_150_000
110
+ return 110_000 if spouse_salary <= 1_200_000
111
+ return 80_000 if spouse_salary <= 1_250_000
112
+ return 40_000 if spouse_salary <= 1_300_000
113
+ return 20_000
114
+ else
115
+ return 130_000 if spouse_salary <= 950_000
116
+ return 120_000 if spouse_salary <= 1_000_000
117
+ return 110_000 if spouse_salary <= 1_050_000
118
+ return 90_000 if spouse_salary <= 1_100_000
119
+ return 70_000 if spouse_salary <= 1_150_000
120
+ return 60_000 if spouse_salary <= 1_200_000
121
+ return 40_000 if spouse_salary <= 1_250_000
122
+ return 20_000 if spouse_salary <= 1_300_000
123
+ return 10_000
124
+ end
125
+ end
126
+
127
+ def self.扶養控除の金額(family, date)
128
+ return if family.nil?
129
+
130
+ family.map { |person| 各家族の扶養控除の額(person, date) }.sum
131
+ end
132
+
133
+ def self.各家族の扶養控除の額(person, date)
134
+ birth_date = person['birth_date']
135
+ return 0 if birth_date.nil?
136
+
137
+ if birth_date > date.prev_year(16)
138
+ 0
139
+ elsif birth_date <= date.prev_year(70)
140
+ person['live_with'] ? 580_000 : 480_000 # 老人扶養親族
141
+ elsif birth_date <= date.prev_year(19) and birth_date > date.prev_year(23)
142
+ 630_000 # 特定扶養親族
143
+ else
144
+ 380_000
145
+ end
146
+ end
147
+
148
+ def self.扶養控除対象者の数(family, date)
149
+ family.map { |person| 各家族の扶養控除の額(person, date) > 0 ? 1 : 0 }.sum
150
+ end
151
+
69
152
  def income_tax_exception
70
153
  %w[116 118 119 11A 11B]
71
154
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luca-jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-19 00:00:00.000000000 Z
11
+ date: 2024-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lucabook
@@ -174,7 +174,7 @@ metadata:
174
174
  homepage_uri: https://github.com/chumaltd/luca-jp
175
175
  source_code_uri: https://github.com/chumaltd/luca-jp
176
176
  changelog_uri: https://github.com/chumaltd/luca-jp/CHANGELOG.md
177
- post_install_message:
177
+ post_install_message:
178
178
  rdoc_options: []
179
179
  require_paths:
180
180
  - lib
@@ -189,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 3.3.5
193
- signing_key:
192
+ rubygems_version: 3.4.10
193
+ signing_key:
194
194
  specification_version: 4
195
195
  summary: JP tax extension for Luca
196
196
  test_files: []