tax_jp 0.5.2 → 0.5.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c8e52e6f79044209616f7921a3db5250a8f8f4224e2fd587fbddad30f7fa42d
|
4
|
+
data.tar.gz: 7adf190fa90f122387c5c9ede46bafd619a2f58f8e88027a009790778be73d18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edcd1ffb0bab205a6d892329488e438054177c446be121cbabbb1a4dcdf1c9d02400dd143ce23fb357f8e18661c9161f007cf6feac8e5f8cb7f0f5db3e677076
|
7
|
+
data.tar.gz: 72f22efea37271474f920a4ff4db992546cd82cc89e757676cd63bc77fd80656b5fda1088a1c040a5df8ba0a6746535d1754204d99ce23ed672475c60efdda04
|
@@ -66,7 +66,7 @@ module TaxJp
|
|
66
66
|
date = TaxJp::Utils.convert_to_date(date)
|
67
67
|
prefecture_code = convert_to_prefecture_code(prefecture)
|
68
68
|
|
69
|
-
with_database do |db|
|
69
|
+
TaxJp::Utils.with_database(DB_PATH) do |db|
|
70
70
|
sql, params = base_query(date, prefecture_code)
|
71
71
|
|
72
72
|
sql << 'where g.valid_from <= ? and g.valid_until >= ? '
|
@@ -87,7 +87,7 @@ module TaxJp
|
|
87
87
|
|
88
88
|
ret = nil
|
89
89
|
|
90
|
-
with_database do |db|
|
90
|
+
TaxJp::Utils.with_database(DB_PATH) do |db|
|
91
91
|
sql, params = base_query(date, prefecture_code)
|
92
92
|
|
93
93
|
sql << 'where g.valid_from <= ? and g.valid_until >= ? and g.salary_from <= ? and g.salary_to > ? '
|
@@ -105,7 +105,7 @@ module TaxJp
|
|
105
105
|
date = TaxJp::Utils.convert_to_date(date)
|
106
106
|
prefecture_code = convert_to_prefecture_code(prefecture)
|
107
107
|
|
108
|
-
with_database do |db|
|
108
|
+
TaxJp::Utils.with_database(DB_PATH) do |db|
|
109
109
|
sql, params = base_query(date, prefecture_code)
|
110
110
|
|
111
111
|
sql << 'where g.valid_from <= ? and g.valid_until >= ? and g.pension_grade = ? '
|
@@ -119,6 +119,41 @@ module TaxJp
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
+
def self.find_health_insurance_by_date_and_prefecture_and_salary(date, prefecture, salary)
|
123
|
+
date = TaxJp::Utils.convert_to_date(date)
|
124
|
+
prefecture_code = convert_to_prefecture_code(prefecture)
|
125
|
+
|
126
|
+
TaxJp::Utils.with_database(DB_PATH) do |db|
|
127
|
+
sql = 'select * from health_insurances '
|
128
|
+
sql << 'where valid_from <= ? and valid_until >= ? and (prefecture_code = ? or prefecture_code is null) '
|
129
|
+
params = [date, date, prefecture_code]
|
130
|
+
|
131
|
+
ret = nil
|
132
|
+
db.execute(sql, params) do |row|
|
133
|
+
ret = TaxJp::SocialInsurances::HealthInsurance.new(row)
|
134
|
+
ret.salary = salary
|
135
|
+
end
|
136
|
+
ret
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.find_welfare_pension_by_date_and_salary(date, salary)
|
141
|
+
date = TaxJp::Utils.convert_to_date(date)
|
142
|
+
|
143
|
+
TaxJp::Utils.with_database(DB_PATH) do |db|
|
144
|
+
sql = 'select * from welfare_pensions '
|
145
|
+
sql << 'where valid_from <= ? and valid_until >= ? '
|
146
|
+
params = [date, date]
|
147
|
+
|
148
|
+
ret = nil
|
149
|
+
db.execute(sql, params) do |row|
|
150
|
+
ret = TaxJp::SocialInsurances::WelfarePension.new(row)
|
151
|
+
ret.salary = salary
|
152
|
+
end
|
153
|
+
ret
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
122
157
|
def self.base_query(date, prefecture_code)
|
123
158
|
sql = 'select g.*, hi.*, wp.* from grades g '
|
124
159
|
sql << 'inner join health_insurances hi on (hi.valid_from <= ? and hi.valid_until >= ? and (hi.prefecture_code = ? or hi.prefecture_code is null)) '
|
@@ -130,16 +165,6 @@ module TaxJp
|
|
130
165
|
end
|
131
166
|
private_class_method :base_query
|
132
167
|
|
133
|
-
def self.with_database
|
134
|
-
db = SQLite3::Database.new(DB_PATH)
|
135
|
-
begin
|
136
|
-
yield db
|
137
|
-
ensure
|
138
|
-
db.close
|
139
|
-
end
|
140
|
-
end
|
141
|
-
private_class_method :with_database
|
142
|
-
|
143
168
|
end
|
144
169
|
|
145
170
|
end
|
@@ -5,20 +5,32 @@ class TaxJp::SocialInsurances::HealthInsurance
|
|
5
5
|
attr_reader :prefecture
|
6
6
|
attr_reader :general, :care
|
7
7
|
attr_reader :particular, :basic
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
|
9
|
+
attr_accessor :salary
|
10
|
+
|
11
|
+
def initialize(attrs)
|
12
|
+
if attrs.is_a?(Hash)
|
13
|
+
@grade = attrs[:grade]
|
14
|
+
@valid_from = attrs[:valid_from]
|
15
|
+
@valid_until = attrs[:valid_until]
|
16
|
+
@prefecture = attrs[:prefecture]
|
17
|
+
@general= attrs[:general]
|
18
|
+
@care = attrs[:care]
|
19
|
+
@particular= attrs[:particular]
|
20
|
+
@basic = attrs[:basic]
|
21
|
+
elsif attrs.is_a?(Array)
|
22
|
+
@valid_from = attrs[0]
|
23
|
+
@valid_until = attrs[1]
|
24
|
+
@prefecture = attrs[2]
|
25
|
+
@general= attrs[3]
|
26
|
+
@care = attrs[4]
|
27
|
+
@particular= attrs[5]
|
28
|
+
@basic = attrs[6]
|
29
|
+
end
|
18
30
|
end
|
19
31
|
|
20
32
|
def general_amount
|
21
|
-
(
|
33
|
+
(salary * general).round(1)
|
22
34
|
end
|
23
35
|
|
24
36
|
def general_amount_half
|
@@ -26,16 +38,21 @@ class TaxJp::SocialInsurances::HealthInsurance
|
|
26
38
|
end
|
27
39
|
|
28
40
|
def general_amount_care
|
29
|
-
(
|
41
|
+
(salary * (general + care)).round(1)
|
30
42
|
end
|
31
43
|
|
32
44
|
def general_amount_care_half
|
33
45
|
floor_amount(general_amount_care / 2)
|
34
46
|
end
|
35
47
|
|
48
|
+
def salary
|
49
|
+
@salary || monthly_standard
|
50
|
+
end
|
51
|
+
|
36
52
|
private
|
37
53
|
|
38
54
|
def monthly_standard
|
55
|
+
raise '等級が指定されていません' unless grade
|
39
56
|
grade.grade > 0 ? grade.monthly_standard : 0
|
40
57
|
end
|
41
58
|
|
@@ -5,17 +5,27 @@ class TaxJp::SocialInsurances::WelfarePension
|
|
5
5
|
attr_reader :general, :particular
|
6
6
|
attr_reader :child_support
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
attr_accessor :salary
|
9
|
+
|
10
|
+
def initialize(attrs)
|
11
|
+
if attrs.is_a?(Hash)
|
12
|
+
@grade = attrs[:grade]
|
13
|
+
@valid_from = attrs[:valid_from]
|
14
|
+
@valid_until = attrs[:valid_until]
|
15
|
+
@general= attrs[:general]
|
16
|
+
@particular= attrs[:particular]
|
17
|
+
@child_support = attrs[:child_support]
|
18
|
+
elsif attrs.is_a?(Array)
|
19
|
+
@valid_from = attrs[0]
|
20
|
+
@valid_until = attrs[1]
|
21
|
+
@general= attrs[2]
|
22
|
+
@particular= attrs[3]
|
23
|
+
@child_support = attrs[4]
|
24
|
+
end
|
15
25
|
end
|
16
26
|
|
17
27
|
def general_amount
|
18
|
-
(
|
28
|
+
(salary * general).round(2)
|
19
29
|
end
|
20
30
|
|
21
31
|
def general_amount_half
|
@@ -23,22 +33,28 @@ class TaxJp::SocialInsurances::WelfarePension
|
|
23
33
|
end
|
24
34
|
|
25
35
|
def particular_amount
|
26
|
-
(
|
36
|
+
(salary * particular).round(2)
|
27
37
|
end
|
28
38
|
|
29
39
|
def particular_amount_half
|
30
40
|
floor_amount(particular_amount / 2)
|
31
41
|
end
|
42
|
+
|
43
|
+
def salary
|
44
|
+
@salary || monthly_standard
|
45
|
+
end
|
32
46
|
|
33
47
|
private
|
34
48
|
|
35
49
|
def monthly_standard
|
50
|
+
raise '等級が指定されていません' unless grade
|
36
51
|
return 0 if grade.pension_grade == 0
|
37
52
|
return 0 if grade.pension_grade > 99
|
38
53
|
grade.monthly_standard
|
39
54
|
end
|
40
55
|
|
41
56
|
def daily_standard
|
57
|
+
raise '等級が指定されていません' unless grade
|
42
58
|
return 0 if grade.pension_grade == 0
|
43
59
|
return 0 if grade.pension_grade > 99
|
44
60
|
grade.daily_standard
|
data/lib/tax_jp/version.rb
CHANGED
@@ -58,14 +58,14 @@ module TaxJp
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def self.
|
61
|
+
def self.find_by_date_and_salary_and_dependant(date, salary, dependent)
|
62
62
|
date = date.strftime('%Y-%m-%d') if date.is_a?(Date)
|
63
63
|
dependent = dependent.to_i
|
64
64
|
|
65
65
|
TaxJp::Utils.with_database(DB_PATH) do |db|
|
66
66
|
sql = "select * from bonus_withheld_taxes "
|
67
67
|
sql << "where valid_from <= ? and valid_until >= ? "
|
68
|
-
sql << " and dependent_#{dependent}_salary_from
|
68
|
+
sql << " and dependent_#{dependent}_salary_from <= ? and dependent_#{dependent}_salary_to > ?"
|
69
69
|
|
70
70
|
ret = nil
|
71
71
|
db.execute(sql, [date, date, salary, salary]) do |row|
|
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: 0.5.
|
4
|
+
version: 0.5.3
|
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: 2018-12-
|
12
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bootstrap
|