kirico 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/CODEOWNERS +37 -0
- data/.github/workflows/test.yml +39 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +9 -0
- data/.rubocop_todo.yml +48 -21
- data/CODE_OF_CONDUCT.md +86 -0
- data/Gemfile.lock +105 -0
- data/LICENSE.md +4 -4
- data/README.md +31 -23
- data/kirico.gemspec +8 -16
- data/lib/kirico/config/locales/ja.yml +103 -1
- data/lib/kirico/models/application_record.rb +1 -1
- data/lib/kirico/models/company.rb +15 -6
- data/lib/kirico/models/data_record22187041.rb +3 -3
- data/lib/kirico/models/data_record2221700.rb +175 -0
- data/lib/kirico/models/data_record2225700.rb +227 -0
- data/lib/kirico/models/data_record22257041.rb +6 -5
- data/lib/kirico/models/data_record2265700.rb +98 -0
- data/lib/kirico/models/fd_management_record.rb +4 -1
- data/lib/kirico/models/form.rb +4 -2
- data/lib/kirico/models/helper.rb +1 -0
- data/lib/kirico/models/mappers.yml +61 -0
- data/lib/kirico/models/sr_company_count.rb +1 -1
- data/lib/kirico/models/sr_fd_management_record.rb +2 -1
- data/lib/kirico/validators/charset_validator.rb +0 -1
- data/lib/kirico/validators/sjis_bytesize_validator.rb +8 -16
- data/lib/kirico/validators/space_divider_validator.rb +1 -3
- data/lib/kirico/version.rb +1 -1
- data/lib/kirico.rb +3 -0
- metadata +30 -111
- data/.ruby-version +0 -1
- data/Guardfile +0 -15
- data/circle.yml +0 -7
@@ -49,6 +49,43 @@ ja:
|
|
49
49
|
old_address_yomi: 変更前被保険者住所(カナ)
|
50
50
|
old_address: 変更前被保険者住所(漢字)
|
51
51
|
memo: 備考欄
|
52
|
+
# 月額変更届
|
53
|
+
kirico/data_record2221700:
|
54
|
+
prefecture_code: 都道府県コード
|
55
|
+
area_code: 群市区符号
|
56
|
+
office_code: 事業所記号
|
57
|
+
ip_code: 被保険者整理番号
|
58
|
+
ip_name_yomi: 被保険者氏名(カナ)
|
59
|
+
ip_name: 被保険者氏名(漢字)
|
60
|
+
birth_at: 生年月日
|
61
|
+
applied_at: 改定年月日
|
62
|
+
old_monthly_standard_income_hel_ins: 従前の標準報酬月額(健保)
|
63
|
+
old_monthly_standard_income_pns_ins: 従前の標準報酬月額(厚保)
|
64
|
+
old_applied_at: 従前の改定年
|
65
|
+
income_updated_at: 昇(降)給年月日
|
66
|
+
income_updated_type: 昇(降)給区分
|
67
|
+
retroacted_payment_at: 遡及支払月
|
68
|
+
retroacted_payment: 遡及支払額
|
69
|
+
before_3_month_days: 給与計算の基礎日数(前三ヶ月)
|
70
|
+
before_2_month_days: 給与計算の基礎日数(前二ヶ月)
|
71
|
+
before_1_month_days: 給与計算の基礎日数(前一ヶ月)
|
72
|
+
before_3_month_income_currency: 通貨によるものの額(前三ヶ月)
|
73
|
+
before_2_month_income_currency: 通貨によるものの額(前二ヶ月)
|
74
|
+
before_1_month_income_currency: 通貨によるものの額(前一ヶ月)
|
75
|
+
before_3_month_income_goods: 現物によるものの額(前三ヶ月)
|
76
|
+
before_2_month_income_goods: 現物によるものの額(前二ヶ月)
|
77
|
+
before_1_month_income_goods: 現物によるものの額(前一ヶ月)
|
78
|
+
avg_adjustment: 修正平均額
|
79
|
+
my_number: 個人番号
|
80
|
+
area_code_of_basic_pension_number: 基礎年金番号 課所符号
|
81
|
+
serial_number_of_basic_pension_number: 基礎年金番号 一連番号
|
82
|
+
seventy_years_and_over: 70歳以上被用者
|
83
|
+
work_in_multiple_company: 二以上勤務
|
84
|
+
short_time_worker: 短時間労働者(特定適用事業所等)
|
85
|
+
reason: 月額変更に該当することになった理由
|
86
|
+
change_only_hel_ins: 健康保険のみ月額変更
|
87
|
+
memo: 備考欄
|
88
|
+
submit_only_seventy_years_and_over: 70歳以上被用者届のみ提出
|
52
89
|
# 算定基礎届
|
53
90
|
kirico/data_record22257041:
|
54
91
|
area_code: 都市区符号
|
@@ -78,9 +115,71 @@ ja:
|
|
78
115
|
income_diff_amount: 昇(降)給差の月額
|
79
116
|
income_updated_at: 昇(降)給年月日
|
80
117
|
memo: 備考欄
|
118
|
+
# 2018年3月以降 算定基礎届
|
119
|
+
kirico/data_record2225700:
|
120
|
+
prefecture_code: 都道府県コード
|
121
|
+
area_code: 群市区符号
|
122
|
+
office_code: 事業所記号
|
123
|
+
ip_code: 被保険者整理番号
|
124
|
+
ip_name_yomi: 被保険者氏名(カナ)
|
125
|
+
ip_name: 被保険者氏名(漢字)
|
126
|
+
birth_at: 生年月日
|
127
|
+
applied_at: 適用年月日
|
128
|
+
old_monthly_standard_income_hel_ins: 従前の標準報酬月額(健保)
|
129
|
+
old_monthly_standard_income_pns_ins: 従前の標準報酬月額(厚保)
|
130
|
+
old_applied_at: 従前の改定年月日
|
131
|
+
apr_days: 支払基礎日数(4月)
|
132
|
+
may_days: 支払基礎日数(5月)
|
133
|
+
jun_days: 支払基礎日数(6月)
|
134
|
+
apr_income_currency: 通貨によるものの額(4月)
|
135
|
+
may_income_currency: 通貨によるものの額(5月)
|
136
|
+
jun_income_currency: 通貨によるものの額(6月)
|
137
|
+
apr_income_goods: 現物によるものの額(4月)
|
138
|
+
may_income_goods: 現物によるものの額(5月)
|
139
|
+
jun_income_goods: 現物によるものの額(6月)
|
140
|
+
avg_adjustment: 修正平均額
|
141
|
+
ip_type: 被保険者区分
|
142
|
+
income_updated_at: 昇(降)給年月日
|
143
|
+
income_updated_type: 昇(降)給区分
|
144
|
+
retroacted_payment_at: 遡及支払月
|
145
|
+
retroacted_payment: 遡及支払額
|
146
|
+
my_number: 個人番号
|
147
|
+
area_code_of_basic_pension_number: 基礎年金番号 課所符号
|
148
|
+
serial_number_of_basic_pension_number: 基礎年金番号 一連番号
|
149
|
+
seventy_years_and_over: 70歳以上被用者算定
|
150
|
+
seventy_years_old_months: 70歳以上被用者 算定基礎月
|
151
|
+
work_in_multiple_company: 二以上勤務
|
152
|
+
will_change_monthly_income: 月額変更予定
|
153
|
+
join_middle_of_month: 中途入社
|
154
|
+
leave_of_absence: 病休・育休・休職等
|
155
|
+
short_time_worker: 短時間労働者(特定適用事業所等)
|
156
|
+
part_time_worker: パート
|
157
|
+
annual_average_caluculation: 年間平均
|
158
|
+
memo: 備考欄
|
159
|
+
submit_only_seventy_years_and_over: 70歳以上被用者届のみ提出
|
160
|
+
# 賞与支払届
|
161
|
+
kirico/data_record2265700:
|
162
|
+
prefecture_code: 都道府県コード
|
163
|
+
area_code: 群市区符号
|
164
|
+
office_code: 事業所記号
|
165
|
+
ip_code: 被保険者整理番号
|
166
|
+
ip_name_yomi: 被保険者氏名(カナ)
|
167
|
+
ip_name: 被保険者氏名(漢字)
|
168
|
+
birth_at: 生年月日
|
169
|
+
bonus_payment_at: 賞与支払日
|
170
|
+
payment_in_currency: 通貨支給額
|
171
|
+
payment_in_goods: 現物支給額
|
172
|
+
my_number: 個人番号
|
173
|
+
area_code_of_basic_pension_number: 基礎年金番号 課所符号
|
174
|
+
serial_number_of_basic_pension_number: 基礎年金番号 一連番号
|
175
|
+
seventy_years_and_over: 70歳以上被用者算定
|
176
|
+
work_in_multiple_company: 二以上勤務
|
177
|
+
first_payment_day_of_multiple_payments_within_the_same_month: 同一月内の賞与合算 初回支払日
|
178
|
+
submit_only_seventy_years_and_over: 70歳以上被用者届のみ提出
|
81
179
|
kirico/company:
|
82
180
|
sr_name: 社会保険労務士氏名
|
83
181
|
count: 事業所数情報
|
182
|
+
prefecture_code: 都道府県コード
|
84
183
|
area_code: 都市区符号
|
85
184
|
office_code: 事業所記号
|
86
185
|
office_number: 事業所番号
|
@@ -89,8 +188,11 @@ ja:
|
|
89
188
|
address: 事業所所在地
|
90
189
|
name: 事業所名称
|
91
190
|
owner_name: 事業主氏名
|
92
|
-
|
191
|
+
tel_area_code: 電話番号 市外局番等
|
192
|
+
tel_city_code: 電話番号 市内局番等
|
193
|
+
tel_subscriber_number: 電話番号 加入者番号
|
93
194
|
kirico/fd_management_record:
|
195
|
+
prefecture_code: 都道府県コード
|
94
196
|
area_code: 都市区符号
|
95
197
|
office_code: 事業所記号
|
96
198
|
fd_seq_number: FD通番
|
@@ -8,6 +8,7 @@ module Kirico
|
|
8
8
|
include Virtus.model
|
9
9
|
include ActiveModel::Validations
|
10
10
|
|
11
|
+
attribute :prefecture_code, String
|
11
12
|
attribute :area_code, String
|
12
13
|
attribute :office_code, String
|
13
14
|
attribute :office_number, String
|
@@ -16,17 +17,22 @@ module Kirico
|
|
16
17
|
attribute :address, String
|
17
18
|
attribute :name, String
|
18
19
|
attribute :owner_name, String
|
19
|
-
attribute :
|
20
|
+
attribute :tel_area_code, String
|
21
|
+
attribute :tel_city_code, String
|
22
|
+
attribute :tel_subscriber_number, String
|
20
23
|
|
24
|
+
validates :prefecture_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
21
25
|
validates :area_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
22
|
-
validates :office_code, charset: { accept: %i
|
26
|
+
validates :office_code, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..4 }
|
23
27
|
validates :office_number, charset: { accept: [:numeric] }, sjis_bytesize: { in: 1..5 }
|
24
28
|
validates :zip_code1, charset: { accept: [:numeric] }, sjis_bytesize: { is: 3 }
|
25
29
|
validates :zip_code2, charset: { accept: [:numeric] }, sjis_bytesize: { is: 4 }
|
26
30
|
validates :address, charset: { accept: [:all] }, sjis_bytesize: { in: 1..75 }
|
27
|
-
validates :name, charset: { accept: %i
|
28
|
-
validates :owner_name, charset: { accept: %i
|
29
|
-
validates :
|
31
|
+
validates :name, charset: { accept: %i[katakana kanji] }, sjis_bytesize: { in: 1..50 }
|
32
|
+
validates :owner_name, charset: { accept: %i[katakana kanji] }, sjis_bytesize: { in: 1..25 }, space_divider: { space: :both_width }
|
33
|
+
validates :tel_area_code, charset: { accept: %i[latin numeric] }, sjis_bytesize: { in: 2..5 }
|
34
|
+
validates :tel_city_code, charset: { accept: %i[latin numeric] }, sjis_bytesize: { in: 1..4 }
|
35
|
+
validates :tel_subscriber_number, charset: { accept: %i[latin numeric] }, sjis_bytesize: { in: 4..5 }
|
30
36
|
|
31
37
|
def initialize
|
32
38
|
yield(self) if block_given?
|
@@ -34,6 +40,7 @@ module Kirico
|
|
34
40
|
|
35
41
|
def to_csv
|
36
42
|
[
|
43
|
+
prefecture_code,
|
37
44
|
area_code,
|
38
45
|
office_code,
|
39
46
|
office_number,
|
@@ -42,7 +49,9 @@ module Kirico
|
|
42
49
|
address,
|
43
50
|
name,
|
44
51
|
owner_name,
|
45
|
-
|
52
|
+
tel_area_code,
|
53
|
+
tel_city_code,
|
54
|
+
tel_subscriber_number
|
46
55
|
].map { |attr| attr.to_s.encode('CP932') }.join(',')
|
47
56
|
end
|
48
57
|
end
|
@@ -23,18 +23,18 @@ module Kirico
|
|
23
23
|
attribute :memo, String
|
24
24
|
|
25
25
|
validates :area_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
26
|
-
validates :office_code, charset: { accept: %i
|
26
|
+
validates :office_code, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..4 }
|
27
27
|
validates :ip_code, charset: { accept: [:numeric] }, sjis_bytesize: { in: 1..6 }
|
28
28
|
validates :basic_pension_number1, charset: { accept: [:numeric] }, sjis_bytesize: { is: 4 }, allow_blank: true
|
29
29
|
validates :basic_pension_number2, charset: { accept: [:numeric] }, sjis_bytesize: { is: 6 }, allow_blank: true
|
30
30
|
validates :zip_code1, charset: { accept: [:numeric] }, sjis_bytesize: { is: 3 }
|
31
31
|
validates :zip_code2, charset: { accept: [:numeric] }, sjis_bytesize: { is: 4 }
|
32
|
-
validates :new_address_yomi, charset: { accept: %i
|
32
|
+
validates :new_address_yomi, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..75 }
|
33
33
|
validates :new_address, charset: { accept: [:all] }, sjis_bytesize: { in: 0..74 }, allow_blank: true
|
34
34
|
validates :updated_at, timeliness: { on_or_before: :today, type: :date }
|
35
35
|
validates :ip_name_yomi, charset: { accept: [:katakana] }, sjis_bytesize: { in: 1..25 }, space_divider: { space: :half_width }
|
36
36
|
validates :ip_name, charset: { accept: [:all] }, sjis_bytesize: { in: 0..24 }, allow_blank: true, space_divider: { space: :full_width }
|
37
|
-
validates :old_address_yomi, charset: { accept: %i
|
37
|
+
validates :old_address_yomi, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..75 }
|
38
38
|
validates :old_address, charset: { accept: [:all] }, sjis_bytesize: { in: 0..74 }, allow_blank: true
|
39
39
|
validates :memo, charset: { accept: [:all] }, sjis_bytesize: { in: 0..75 }, allow_blank: true
|
40
40
|
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# 月額変更届・70歳以上被用者月額変更届データレコード
|
4
|
+
module Kirico
|
5
|
+
class DataRecord2221700 < ApplicationRecord
|
6
|
+
DOC_CODE = '2221700'
|
7
|
+
|
8
|
+
attribute :prefecture_code, String
|
9
|
+
attribute :area_code, String
|
10
|
+
attribute :office_code, String
|
11
|
+
attribute :ip_code, String
|
12
|
+
attribute :ip_name_yomi, String
|
13
|
+
attribute :ip_name, String
|
14
|
+
attribute :birth_at, Date
|
15
|
+
attribute :applied_at, Date
|
16
|
+
attribute :old_monthly_standard_income_hel_ins, Integer
|
17
|
+
attribute :old_monthly_standard_income_pns_ins, Integer
|
18
|
+
attribute :old_applied_at, Date
|
19
|
+
attribute :income_updated_at, Date
|
20
|
+
attribute :income_updated_type, Symbol
|
21
|
+
attribute :retroacted_payment_at, Date
|
22
|
+
attribute :retroacted_payment, Integer
|
23
|
+
[3, 2, 1].each do |month|
|
24
|
+
attribute "before_#{month}_month_days", String
|
25
|
+
attribute "before_#{month}_month_income_currency", String
|
26
|
+
attribute "before_#{month}_month_income_goods", String
|
27
|
+
end
|
28
|
+
attribute :avg_adjustment, Integer
|
29
|
+
attribute :my_number, String
|
30
|
+
attribute :area_code_of_basic_pension_number, String
|
31
|
+
attribute :serial_number_of_basic_pension_number, String
|
32
|
+
attribute :seventy_years_and_over, Integer
|
33
|
+
attribute :work_in_multiple_company, Integer
|
34
|
+
attribute :short_time_worker, Integer
|
35
|
+
attribute :reason, String
|
36
|
+
attribute :change_only_hel_ins, Integer
|
37
|
+
attribute :memo, String
|
38
|
+
attribute :submit_only_seventy_years_and_over, Integer
|
39
|
+
|
40
|
+
define_format_date_method :birth_at, :applied_at, :old_applied_at, :income_updated_at, :retroacted_payment_at
|
41
|
+
define_code_mapper_method :birth_at_era_nengo, :applied_at_era_nengo, :old_applied_at_era_nengo, :income_updated_type
|
42
|
+
define_in_k_method :old_monthly_standard_income_hel_ins, :old_monthly_standard_income_pns_ins
|
43
|
+
|
44
|
+
validates :prefecture_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
45
|
+
validates :area_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
46
|
+
validates :office_code, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..4 }
|
47
|
+
validates :ip_code, charset: { accept: [:numeric] }, sjis_bytesize: { in: 0..6 }, allow_blank: true
|
48
|
+
validates :ip_name_yomi, charset: { accept: [:katakana] }, sjis_bytesize: { in: 1..25 }, space_divider: { space: :half_width }
|
49
|
+
validates :ip_name, charset: { accept: [:all] }, sjis_bytesize: { in: 0..24 }, allow_blank: true, space_divider: { space: :full_width }
|
50
|
+
validates :applied_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
51
|
+
validates :old_monthly_standard_income_hel_ins, numericality: { greater_than_or_equal_to: 1_000, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
52
|
+
validates :old_monthly_standard_income_pns_ins, numericality: { greater_than_or_equal_to: 1_000, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
53
|
+
validates :old_applied_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
54
|
+
validates :income_updated_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }, allow_blank: true
|
55
|
+
validates :income_updated_type, inclusion: { in: %i[income_updated_type_0 income_updated_type_1] }, allow_blank: true
|
56
|
+
validates :retroacted_payment_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }, allow_blank: true
|
57
|
+
validates :retroacted_payment, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
58
|
+
[3, 2, 1].each do |month|
|
59
|
+
validates "before_#{month}_month_income_currency", numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }
|
60
|
+
validates "before_#{month}_month_income_goods", numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }
|
61
|
+
end
|
62
|
+
validates :avg_adjustment, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
63
|
+
validates :my_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 12 }, allow_nil: true
|
64
|
+
validates :area_code_of_basic_pension_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 4 }, allow_nil: true
|
65
|
+
validates :serial_number_of_basic_pension_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 6 }, allow_nil: true
|
66
|
+
validates :seventy_years_and_over, inclusion: { in: [1] }, allow_nil: true
|
67
|
+
validates :work_in_multiple_company, inclusion: { in: [1] }, allow_nil: true
|
68
|
+
validates :short_time_worker, inclusion: { in: [1] }, allow_nil: true
|
69
|
+
validates :reason, charset: { accept: [:all] }, sjis_bytesize: { in: 0..75 }
|
70
|
+
validates :change_only_hel_ins, inclusion: { in: [1] }, allow_nil: true
|
71
|
+
validates :memo, charset: { accept: [:all] }, sjis_bytesize: { in: 0..75 }, allow_nil: true
|
72
|
+
validates :submit_only_seventy_years_and_over, inclusion: { in: [1] }, allow_nil: true
|
73
|
+
|
74
|
+
validate :each_month_days_should_be_greater_than_or_equal_11_or_17
|
75
|
+
validate :seventy_years_and_over_employee_need_to_input_my_number_or_basic_pension_number
|
76
|
+
|
77
|
+
def initialize
|
78
|
+
yield(self) if block_given?
|
79
|
+
end
|
80
|
+
|
81
|
+
# rubocop:disable all
|
82
|
+
def to_csv
|
83
|
+
[
|
84
|
+
DOC_CODE,
|
85
|
+
prefecture_code,
|
86
|
+
area_code,
|
87
|
+
office_code,
|
88
|
+
ip_code,
|
89
|
+
ip_name_yomi,
|
90
|
+
ip_name,
|
91
|
+
mapped_birth_at_era_nengo,
|
92
|
+
fmt_era_ymd_birth_at,
|
93
|
+
mapped_applied_at_era_nengo,
|
94
|
+
applied_at_era_year,
|
95
|
+
applied_at_month,
|
96
|
+
old_monthly_standard_income_hel_ins.nil? ? nil : old_monthly_standard_income_hel_ins_in_k.to_s.rjust(4, '0'),
|
97
|
+
old_monthly_standard_income_pns_ins.nil? ? nil : old_monthly_standard_income_pns_ins_in_k.to_s.rjust(4, '0'),
|
98
|
+
mapped_old_applied_at_era_nengo,
|
99
|
+
old_applied_at_era_year,
|
100
|
+
old_applied_at_month,
|
101
|
+
income_updated_at.nil? ? nil : income_updated_at_month,
|
102
|
+
mapped_income_updated_type,
|
103
|
+
retroacted_payment_at.nil? ? nil : retroacted_payment_at_month,
|
104
|
+
retroacted_payment.nil? ? nil : retroacted_payment,
|
105
|
+
applied_at.prev_month(3).strftime('%m'),
|
106
|
+
applied_at.prev_month(2).strftime('%m'),
|
107
|
+
applied_at.prev_month(1).strftime('%m'),
|
108
|
+
before_3_month_days.to_s.rjust(2, '0'),
|
109
|
+
before_2_month_days.to_s.rjust(2, '0'),
|
110
|
+
before_1_month_days.to_s.rjust(2, '0'),
|
111
|
+
before_3_month_income_currency,
|
112
|
+
before_2_month_income_currency,
|
113
|
+
before_1_month_income_currency,
|
114
|
+
before_3_month_income_goods,
|
115
|
+
before_2_month_income_goods,
|
116
|
+
before_1_month_income_goods,
|
117
|
+
round_income(income_total(before_3_month_income_currency, before_3_month_income_goods)),
|
118
|
+
round_income(income_total(before_2_month_income_currency, before_2_month_income_goods)),
|
119
|
+
round_income(income_total(before_1_month_income_currency, before_1_month_income_goods)),
|
120
|
+
round_income(income_all_total),
|
121
|
+
round_income(income_average),
|
122
|
+
avg_adjustment.nil? ? nil : avg_adjustment,
|
123
|
+
my_number,
|
124
|
+
area_code_of_basic_pension_number,
|
125
|
+
serial_number_of_basic_pension_number,
|
126
|
+
seventy_years_and_over,
|
127
|
+
work_in_multiple_company,
|
128
|
+
short_time_worker,
|
129
|
+
reason,
|
130
|
+
change_only_hel_ins,
|
131
|
+
memo,
|
132
|
+
submit_only_seventy_years_and_over,
|
133
|
+
].map { |attr| attr.to_s.encode('CP932') }.join(',')
|
134
|
+
end
|
135
|
+
# rubocop:enable all
|
136
|
+
|
137
|
+
def income_total(currency, goods)
|
138
|
+
currency.to_i + goods.to_i
|
139
|
+
end
|
140
|
+
|
141
|
+
def income_all_total
|
142
|
+
[
|
143
|
+
income_total(before_3_month_income_currency, before_3_month_income_goods),
|
144
|
+
income_total(before_2_month_income_currency, before_2_month_income_goods),
|
145
|
+
income_total(before_1_month_income_currency, before_1_month_income_goods)
|
146
|
+
].sum
|
147
|
+
end
|
148
|
+
|
149
|
+
# 1 円未満は切り捨て
|
150
|
+
def income_average
|
151
|
+
income_all_total / 3
|
152
|
+
end
|
153
|
+
|
154
|
+
def round_income(income)
|
155
|
+
income < 10_000_000 ? income : 9_999_999
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
# 一般の被保険者(短時間労働者以外)の場合、17~31 日の範囲で設定する
|
161
|
+
# 短時間労働者(特定適用事業所のみ)の場合、11~31 日の範囲で設定する
|
162
|
+
def each_month_days_should_be_greater_than_or_equal_11_or_17
|
163
|
+
threshold = short_time_worker == 1 ? 11 : 17
|
164
|
+
[3, 2, 1].each do |month|
|
165
|
+
errors.add(:base, "前#{month}ヶ月の給与計算の基礎日数は、#{threshold}~31日の範囲で設定しなくてはいけません") unless threshold <= send(:"before_#{month}_month_days").to_i && send(:"before_#{month}_month_days").to_i <= 31
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def seventy_years_and_over_employee_need_to_input_my_number_or_basic_pension_number
|
170
|
+
return if seventy_years_and_over.nil?
|
171
|
+
|
172
|
+
errors.add(:base, '70歳以上被用者の場合、マイナンバー、もしくは基礎年金番号の入力は必須です。') if my_number.nil? && area_code_of_basic_pension_number.nil? && serial_number_of_basic_pension_number.nil?
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# 2018年3月以降の算定基礎届データレコード
|
4
|
+
module Kirico
|
5
|
+
class DataRecord2225700 < ApplicationRecord
|
6
|
+
DOC_CODE = '2225700'
|
7
|
+
COVERED_MONTHS = %i[apr may jun].freeze
|
8
|
+
|
9
|
+
attribute :prefecture_code, String
|
10
|
+
attribute :area_code, String
|
11
|
+
attribute :office_code, String
|
12
|
+
attribute :ip_code, String
|
13
|
+
attribute :ip_name_yomi, String
|
14
|
+
attribute :ip_name, String
|
15
|
+
attribute :birth_at, Date
|
16
|
+
attribute :applied_at, Date
|
17
|
+
attribute :old_monthly_standard_income_hel_ins, Integer
|
18
|
+
attribute :old_monthly_standard_income_pns_ins, Integer
|
19
|
+
attribute :old_applied_at, Date
|
20
|
+
attribute :income_updated_at, Date
|
21
|
+
attribute :income_updated_type, Symbol
|
22
|
+
attribute :retroacted_payment_at, Date
|
23
|
+
attribute :retroacted_payment, Integer
|
24
|
+
COVERED_MONTHS.each do |month|
|
25
|
+
attribute "#{month}_days", Integer
|
26
|
+
attribute "#{month}_income_currency", Integer
|
27
|
+
attribute "#{month}_income_goods", Integer
|
28
|
+
end
|
29
|
+
attribute :avg_adjustment, Integer
|
30
|
+
attribute :my_number, String
|
31
|
+
attribute :ip_type, Symbol
|
32
|
+
attribute :area_code_of_basic_pension_number, String
|
33
|
+
attribute :serial_number_of_basic_pension_number, String
|
34
|
+
attribute :seventy_years_and_over, Integer
|
35
|
+
attribute :seventy_years_old_months, String
|
36
|
+
attribute :work_in_multiple_company, Integer
|
37
|
+
attribute :will_change_monthly_income, Integer
|
38
|
+
attribute :join_middle_of_month, Integer
|
39
|
+
attribute :leave_of_absence, Integer
|
40
|
+
attribute :short_time_worker, Integer
|
41
|
+
attribute :part_time_worker, Integer
|
42
|
+
attribute :annual_average_caluculation, Integer
|
43
|
+
attribute :memo, String
|
44
|
+
attribute :submit_only_seventy_years_and_over, Integer
|
45
|
+
|
46
|
+
define_format_date_method :birth_at, :applied_at, :old_applied_at, :income_updated_at, :retroacted_payment_at
|
47
|
+
define_code_mapper_method :birth_at_era_nengo, :applied_at_era_nengo,
|
48
|
+
:old_applied_at_era_nengo, :income_updated_at_era_nengo,
|
49
|
+
:ip_type, :income_updated_type
|
50
|
+
define_in_k_method :old_monthly_standard_income_hel_ins, :old_monthly_standard_income_pns_ins
|
51
|
+
|
52
|
+
validates :prefecture_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
53
|
+
validates :area_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
54
|
+
validates :office_code, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..4 }
|
55
|
+
validates :ip_code, charset: { accept: [:numeric] }, sjis_bytesize: { in: 1..6 }, allow_blank: true
|
56
|
+
validates :ip_code, presence: true, if: proc { |record| record.seventy_years_and_over.nil? }
|
57
|
+
validates :ip_name_yomi, charset: { accept: [:katakana] }, sjis_bytesize: { in: 1..25 }, space_divider: { space: :half_width }
|
58
|
+
validates :ip_name, charset: { accept: [:all] }, sjis_bytesize: { in: 0..24 }, allow_blank: true, space_divider: { space: :full_width }
|
59
|
+
validates :applied_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
60
|
+
validates :old_monthly_standard_income_hel_ins, numericality: { greater_than_or_equal_to: 1_000, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
61
|
+
validates :old_monthly_standard_income_pns_ins, numericality: { greater_than_or_equal_to: 1_000, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
62
|
+
validates :old_applied_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
63
|
+
validates :apr_days, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 31 }
|
64
|
+
validates :may_days, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 31 }
|
65
|
+
validates :jun_days, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 31 }
|
66
|
+
COVERED_MONTHS.each do |month|
|
67
|
+
validates "#{month}_income_currency", numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }
|
68
|
+
validates "#{month}_income_goods", numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }
|
69
|
+
end
|
70
|
+
validates :avg_adjustment, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
71
|
+
validates :ip_type, inclusion: { in: %i[ip_type_0 ip_type_1 ip_type_2] }
|
72
|
+
validates :retroacted_payment, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
73
|
+
validates :retroacted_payment_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }, allow_blank: true
|
74
|
+
validates :income_updated_type, inclusion: { in: %i[income_updated_type_0 income_updated_type_1] }, allow_blank: true
|
75
|
+
validates :income_updated_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }, allow_blank: true
|
76
|
+
validates :my_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 12 }, allow_nil: true
|
77
|
+
validates :area_code_of_basic_pension_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 4 }, allow_nil: true
|
78
|
+
validates :serial_number_of_basic_pension_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 6 }, allow_nil: true
|
79
|
+
validates :seventy_years_and_over, inclusion: { in: [1] }, allow_nil: true
|
80
|
+
validates :seventy_years_old_months, charset: { accept: [:numeric] }, sjis_bytesize: { in: 2..4 }, allow_blank: true
|
81
|
+
validates :work_in_multiple_company, inclusion: { in: [1] }, allow_nil: true
|
82
|
+
validates :will_change_monthly_income, inclusion: { in: [1] }, allow_nil: true
|
83
|
+
validates :join_middle_of_month, inclusion: { in: [1] }, allow_nil: true
|
84
|
+
validates :leave_of_absence, inclusion: { in: [1] }, allow_nil: true
|
85
|
+
validates :short_time_worker, inclusion: { in: [1] }, allow_nil: true
|
86
|
+
validates :part_time_worker, inclusion: { in: [1] }, allow_nil: true
|
87
|
+
validates :annual_average_caluculation, inclusion: { in: [1] }, allow_nil: true
|
88
|
+
validates :memo, charset: { accept: [:all] }, sjis_bytesize: { in: 0..75 }
|
89
|
+
validates :submit_only_seventy_years_and_over, inclusion: { in: [1] }, allow_nil: true
|
90
|
+
validate :seventy_years_and_over_employee_need_to_input_my_number_or_basic_pension_number
|
91
|
+
|
92
|
+
def initialize
|
93
|
+
yield(self) if block_given?
|
94
|
+
end
|
95
|
+
|
96
|
+
# rubocop:disable all
|
97
|
+
def to_csv
|
98
|
+
[
|
99
|
+
DOC_CODE,
|
100
|
+
prefecture_code,
|
101
|
+
area_code,
|
102
|
+
office_code,
|
103
|
+
ip_code,
|
104
|
+
ip_name_yomi,
|
105
|
+
ip_name,
|
106
|
+
mapped_birth_at_era_nengo,
|
107
|
+
fmt_era_ymd_birth_at,
|
108
|
+
mapped_applied_at_era_nengo,
|
109
|
+
applied_at_era_year,
|
110
|
+
'09',
|
111
|
+
old_monthly_standard_income_hel_ins.nil? ? nil : old_monthly_standard_income_hel_ins_in_k.to_s.rjust(4, '0'),
|
112
|
+
old_monthly_standard_income_pns_ins.nil? ? nil : old_monthly_standard_income_pns_ins_in_k.to_s.rjust(4, '0'),
|
113
|
+
mapped_old_applied_at_era_nengo,
|
114
|
+
old_applied_at_era_year,
|
115
|
+
old_applied_at_month,
|
116
|
+
income_updated_at.nil? ? nil : income_updated_at_month,
|
117
|
+
mapped_income_updated_type,
|
118
|
+
retroacted_payment_at.nil? ? nil : retroacted_payment_at_month,
|
119
|
+
retroacted_payment.nil? ? nil : retroacted_payment.to_s.rjust(7, '0'),
|
120
|
+
'04',
|
121
|
+
'05',
|
122
|
+
'06',
|
123
|
+
apr_days.to_s.rjust(2, '0'),
|
124
|
+
may_days.to_s.rjust(2, '0'),
|
125
|
+
jun_days.to_s.rjust(2, '0'),
|
126
|
+
apr_income_currency.to_s.rjust(7, '0'),
|
127
|
+
may_income_currency.to_s.rjust(7, '0'),
|
128
|
+
jun_income_currency.to_s.rjust(7, '0'),
|
129
|
+
apr_income_goods.to_s.rjust(7, '0'),
|
130
|
+
may_income_goods.to_s.rjust(7, '0'),
|
131
|
+
jun_income_goods.to_s.rjust(7, '0'),
|
132
|
+
income_total(apr_income_currency, apr_income_goods).to_s.rjust(7, '0'),
|
133
|
+
income_total(may_income_currency, may_income_goods).to_s.rjust(7, '0'),
|
134
|
+
income_total(jun_income_currency, jun_income_goods).to_s.rjust(7, '0'),
|
135
|
+
income_all_total_with_round.to_s.rjust(7, '0'),
|
136
|
+
income_average.to_s.rjust(7, '0'),
|
137
|
+
avg_adjustment.nil? ? nil : avg_adjustment.to_s.rjust(7, '0'),
|
138
|
+
my_number,
|
139
|
+
area_code_of_basic_pension_number,
|
140
|
+
serial_number_of_basic_pension_number,
|
141
|
+
seventy_years_and_over,
|
142
|
+
seventy_years_old_months,
|
143
|
+
work_in_multiple_company,
|
144
|
+
will_change_monthly_income,
|
145
|
+
join_middle_of_month,
|
146
|
+
leave_of_absence,
|
147
|
+
short_time_worker,
|
148
|
+
part_time_worker,
|
149
|
+
annual_average_caluculation,
|
150
|
+
memo,
|
151
|
+
submit_only_seventy_years_and_over
|
152
|
+
].map { |attr| attr.to_s.encode('CP932') }.join(',')
|
153
|
+
end
|
154
|
+
# rubocop:enable all
|
155
|
+
|
156
|
+
def income_total(currency, goods)
|
157
|
+
total = currency.to_i + goods.to_i
|
158
|
+
total < 10_000_000 ? total : 9_999_999
|
159
|
+
end
|
160
|
+
|
161
|
+
# 総計を計算する
|
162
|
+
# 算定対象月の合計値を返す。
|
163
|
+
def income_all_total
|
164
|
+
return 0 if target_months.empty?
|
165
|
+
|
166
|
+
target_months.map do |month|
|
167
|
+
send("#{month}_income_currency").to_i + send("#{month}_income_goods").to_i
|
168
|
+
end.inject(:+)
|
169
|
+
end
|
170
|
+
|
171
|
+
# 総計を計算する
|
172
|
+
# CSVへ出力する際、10,000,000 円以上は 9,999,999 を返す
|
173
|
+
def income_all_total_with_round
|
174
|
+
total = income_all_total
|
175
|
+
total < 10_000_000 ? total : 9_999_999
|
176
|
+
end
|
177
|
+
|
178
|
+
# 平均額を計算する
|
179
|
+
#
|
180
|
+
# 算定対象月の合計値を算定対象月数で割った値を返す。
|
181
|
+
#
|
182
|
+
# ただし、
|
183
|
+
# - 1 円未満は切り捨て
|
184
|
+
# - 10,000,000 円以上は 9,999,999 を返す
|
185
|
+
# - 算定対象月が存在しない場合は「0」を返す
|
186
|
+
def income_average
|
187
|
+
return 0 if target_months.empty?
|
188
|
+
|
189
|
+
avg = income_all_total / target_months.length
|
190
|
+
avg < 10_000_000 ? avg : 9_999_999
|
191
|
+
end
|
192
|
+
|
193
|
+
# 算定対象月の配列を返却する
|
194
|
+
#
|
195
|
+
# 1. 一般の被保険者の場合
|
196
|
+
# 17 日以上の月を対象とする
|
197
|
+
#
|
198
|
+
# 2. 短時間労働者の場合
|
199
|
+
# 11 日以上の月を対象とする
|
200
|
+
#
|
201
|
+
# 3. パートタイマーの場合
|
202
|
+
# 17 日以上の月を対象とする。
|
203
|
+
# ただし、全ての算定基礎月の支払基礎日数が 17 日未満の場合は、
|
204
|
+
# 15 日以上の月を対象とする。
|
205
|
+
def target_months
|
206
|
+
threshold = case ip_type
|
207
|
+
when :ip_type_0
|
208
|
+
17
|
209
|
+
when :ip_type_1
|
210
|
+
COVERED_MONTHS.all? { |month| send("#{month}_days").to_i < 17 } ? 15 : 17
|
211
|
+
when :ip_type_2
|
212
|
+
11
|
213
|
+
else
|
214
|
+
17
|
215
|
+
end
|
216
|
+
COVERED_MONTHS.select { |month| threshold <= send("#{month}_days").to_i }
|
217
|
+
end
|
218
|
+
|
219
|
+
private
|
220
|
+
|
221
|
+
def seventy_years_and_over_employee_need_to_input_my_number_or_basic_pension_number
|
222
|
+
return if seventy_years_and_over.nil?
|
223
|
+
|
224
|
+
errors.add(:base, '70歳以上被用者の場合、マイナンバー、もしくは基礎年金番号の入力は必須です。') if my_number.nil? && area_code_of_basic_pension_number.nil? && serial_number_of_basic_pension_number.nil?
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
module Kirico
|
5
5
|
class DataRecord22257041 < ApplicationRecord
|
6
6
|
DOC_CODE = '22257041'
|
7
|
-
COVERED_MONTHS = %i
|
7
|
+
COVERED_MONTHS = %i[apr may jun].freeze
|
8
8
|
|
9
9
|
attribute :area_code, String
|
10
10
|
attribute :office_code, String
|
@@ -37,12 +37,12 @@ module Kirico
|
|
37
37
|
define_in_k_method :old_monthly_standard_income_hel_ins, :old_monthly_standard_income_pns_ins
|
38
38
|
|
39
39
|
validates :area_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
40
|
-
validates :office_code, charset: { accept: %i
|
40
|
+
validates :office_code, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..4 }
|
41
41
|
validates :ip_code, charset: { accept: [:numeric] }, sjis_bytesize: { in: 1..6 }
|
42
42
|
validates :applied_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
43
43
|
validates :ip_name_yomi, charset: { accept: [:katakana] }, sjis_bytesize: { in: 1..25 }, space_divider: { space: :half_width }
|
44
44
|
validates :ip_name, charset: { accept: [:all] }, sjis_bytesize: { in: 0..24 }, allow_blank: true, space_divider: { space: :full_width }
|
45
|
-
validates :gender_type, inclusion: { in: %i
|
45
|
+
validates :gender_type, inclusion: { in: %i[gender_type_1 gender_type_2 gender_type_3 gender_type_5 gender_type_6 gender_type_7] }
|
46
46
|
validates :old_monthly_standard_income_hel_ins, numericality: { greater_than_or_equal_to: 1_000, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
47
47
|
validates :old_monthly_standard_income_pns_ins, numericality: { greater_than_or_equal_to: 1_000, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
48
48
|
validates :old_applied_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
@@ -54,9 +54,9 @@ module Kirico
|
|
54
54
|
validates "#{month}_income_goods", numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }
|
55
55
|
end
|
56
56
|
validates :avg_adjustment, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
57
|
-
validates :ip_type, inclusion: { in: %i
|
57
|
+
validates :ip_type, inclusion: { in: %i[ip_type_0 ip_type_1 ip_type_2] }
|
58
58
|
validates :retroacted_payment, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
59
|
-
validates :income_updated_type, inclusion: { in: %i
|
59
|
+
validates :income_updated_type, inclusion: { in: %i[income_updated_type_0 income_updated_type_1] }, allow_blank: true
|
60
60
|
validates :income_diff_amount, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
61
61
|
validates :income_updated_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }, allow_blank: true
|
62
62
|
validates :memo, charset: { accept: [:all] }, sjis_bytesize: { in: 0..75 }, allow_blank: true
|
@@ -132,6 +132,7 @@ module Kirico
|
|
132
132
|
# - 算定対象月が存在しない場合は「0」を返す
|
133
133
|
def income_average
|
134
134
|
return 0 if target_months.empty?
|
135
|
+
|
135
136
|
total = target_months.map do |month|
|
136
137
|
send("#{month}_income_currency").to_i + send("#{month}_income_goods").to_i
|
137
138
|
end.inject(:+)
|