kirico 1.0.4 → 1.1.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 +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 +32 -24
- data/kirico.gemspec +8 -15
- data/lib/kirico/config/locales/en.yml +9 -0
- data/lib/kirico/config/locales/ja.yml +106 -4
- data/lib/kirico/csv_generator.rb +1 -0
- data/lib/kirico/models/application_record.rb +2 -1
- data/lib/kirico/models/base_company_count.rb +1 -0
- data/lib/kirico/models/base_fd_management_record.rb +1 -0
- data/lib/kirico/models/company.rb +16 -6
- data/lib/kirico/models/company_count.rb +1 -0
- data/lib/kirico/models/company_identifier.rb +1 -0
- data/lib/kirico/models/data_identifier.rb +1 -0
- data/lib/kirico/models/data_record22187041.rb +4 -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 +7 -5
- data/lib/kirico/models/data_record2265700.rb +98 -0
- data/lib/kirico/models/fd_management_record.rb +5 -1
- data/lib/kirico/models/form.rb +5 -2
- data/lib/kirico/models/helper.rb +2 -0
- data/lib/kirico/models/mappers.yml +61 -0
- data/lib/kirico/models/sr_company_count.rb +2 -1
- data/lib/kirico/models/sr_fd_management_record.rb +3 -1
- data/lib/kirico/validators/charset_validator.rb +1 -1
- data/lib/kirico/validators/sjis_bytesize_validator.rb +10 -17
- data/lib/kirico/validators/space_divider_validator.rb +2 -3
- data/lib/kirico/version.rb +2 -1
- data/lib/kirico.rb +4 -0
- metadata +30 -111
- data/.ruby-version +0 -1
- data/Guardfile +0 -15
- data/circle.yml +0 -7
@@ -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
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# 算定基礎届データレコード
|
3
4
|
module Kirico
|
4
5
|
class DataRecord22257041 < ApplicationRecord
|
5
6
|
DOC_CODE = '22257041'
|
6
|
-
COVERED_MONTHS = [
|
7
|
+
COVERED_MONTHS = %i[apr may jun].freeze
|
7
8
|
|
8
9
|
attribute :area_code, String
|
9
10
|
attribute :office_code, String
|
@@ -36,12 +37,12 @@ module Kirico
|
|
36
37
|
define_in_k_method :old_monthly_standard_income_hel_ins, :old_monthly_standard_income_pns_ins
|
37
38
|
|
38
39
|
validates :area_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
39
|
-
validates :office_code, charset: { accept: [
|
40
|
+
validates :office_code, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..4 }
|
40
41
|
validates :ip_code, charset: { accept: [:numeric] }, sjis_bytesize: { in: 1..6 }
|
41
42
|
validates :applied_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
42
43
|
validates :ip_name_yomi, charset: { accept: [:katakana] }, sjis_bytesize: { in: 1..25 }, space_divider: { space: :half_width }
|
43
44
|
validates :ip_name, charset: { accept: [:all] }, sjis_bytesize: { in: 0..24 }, allow_blank: true, space_divider: { space: :full_width }
|
44
|
-
validates :gender_type, inclusion: { in: [
|
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] }
|
45
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
|
46
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
|
47
48
|
validates :old_applied_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
@@ -53,9 +54,9 @@ module Kirico
|
|
53
54
|
validates "#{month}_income_goods", numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }
|
54
55
|
end
|
55
56
|
validates :avg_adjustment, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
56
|
-
validates :ip_type, inclusion: { in: [
|
57
|
+
validates :ip_type, inclusion: { in: %i[ip_type_0 ip_type_1 ip_type_2] }
|
57
58
|
validates :retroacted_payment, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
58
|
-
validates :income_updated_type, inclusion: { in: [
|
59
|
+
validates :income_updated_type, inclusion: { in: %i[income_updated_type_0 income_updated_type_1] }, allow_blank: true
|
59
60
|
validates :income_diff_amount, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 9_999_999 }, allow_blank: true
|
60
61
|
validates :income_updated_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }, allow_blank: true
|
61
62
|
validates :memo, charset: { accept: [:all] }, sjis_bytesize: { in: 0..75 }, allow_blank: true
|
@@ -131,6 +132,7 @@ module Kirico
|
|
131
132
|
# - 算定対象月が存在しない場合は「0」を返す
|
132
133
|
def income_average
|
133
134
|
return 0 if target_months.empty?
|
135
|
+
|
134
136
|
total = target_months.map do |month|
|
135
137
|
send("#{month}_income_currency").to_i + send("#{month}_income_goods").to_i
|
136
138
|
end.inject(:+)
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# 賞与支払届データレコード
|
4
|
+
module Kirico
|
5
|
+
class DataRecord2265700 < ApplicationRecord
|
6
|
+
DOC_CODE = '2265700'
|
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 :bonus_payment_at, Date
|
16
|
+
attribute :payment_in_currency, Integer
|
17
|
+
attribute :payment_in_goods, Integer
|
18
|
+
attribute :my_number, String
|
19
|
+
attribute :area_code_of_basic_pension_number, String
|
20
|
+
attribute :serial_number_of_basic_pension_number, String
|
21
|
+
attribute :seventy_years_and_over, Integer
|
22
|
+
attribute :work_in_multiple_company, Integer
|
23
|
+
attribute :first_payment_day_of_multiple_payments_within_the_same_month, String
|
24
|
+
attribute :submit_only_seventy_years_and_over, Integer
|
25
|
+
|
26
|
+
define_format_date_method :birth_at, :bonus_payment_at
|
27
|
+
define_code_mapper_method :birth_at_era_nengo, :bonus_payment_at_era_nengo
|
28
|
+
|
29
|
+
validates :prefecture_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
30
|
+
validates :area_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
31
|
+
validates :office_code, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..4 }
|
32
|
+
validates :ip_code, charset: { accept: [:numeric] }, sjis_bytesize: { in: 1..6 }
|
33
|
+
validates :ip_name_yomi, charset: { accept: [:katakana] }, sjis_bytesize: { in: 1..25 }, space_divider: { space: :half_width }
|
34
|
+
validates :ip_name, charset: { accept: [:all] }, sjis_bytesize: { in: 0..24 }, allow_blank: true, space_divider: { space: :full_width }
|
35
|
+
validates :bonus_payment_at, timeliness: { on_or_after: -> { Date.new(1989, 1, 8) }, type: :date }
|
36
|
+
validates :payment_in_currency, numericality: { greater_than_or_equal_to: 0 }
|
37
|
+
validates :payment_in_goods, numericality: { greater_than_or_equal_to: 0 }
|
38
|
+
validates :my_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 12 }, allow_nil: true
|
39
|
+
validates :area_code_of_basic_pension_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 4 }, allow_nil: true
|
40
|
+
validates :serial_number_of_basic_pension_number, charset: { accept: [:numeric] }, sjis_bytesize: { is: 6 }, allow_nil: true
|
41
|
+
validates :seventy_years_and_over, inclusion: { in: [1] }, allow_nil: true
|
42
|
+
validates :work_in_multiple_company, inclusion: { in: [1] }, allow_nil: true
|
43
|
+
validates :first_payment_day_of_multiple_payments_within_the_same_month, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }, allow_nil: true
|
44
|
+
validates :submit_only_seventy_years_and_over, inclusion: { in: [1] }, allow_nil: true
|
45
|
+
validate :seventy_years_and_over_employee_need_to_input_my_number_or_basic_pension_number
|
46
|
+
|
47
|
+
def initialize
|
48
|
+
yield(self) if block_given?
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_csv
|
52
|
+
[
|
53
|
+
DOC_CODE,
|
54
|
+
prefecture_code,
|
55
|
+
area_code,
|
56
|
+
office_code,
|
57
|
+
ip_code,
|
58
|
+
ip_name_yomi,
|
59
|
+
ip_name,
|
60
|
+
mapped_birth_at_era_nengo,
|
61
|
+
fmt_era_ymd_birth_at,
|
62
|
+
mapped_bonus_payment_at_era_nengo,
|
63
|
+
fmt_era_ymd_bonus_payment_at,
|
64
|
+
adjusted_payment_in_currency,
|
65
|
+
adjusted_payment_in_goods,
|
66
|
+
bonus_total(payment_in_currency, payment_in_goods),
|
67
|
+
my_number,
|
68
|
+
area_code_of_basic_pension_number,
|
69
|
+
serial_number_of_basic_pension_number,
|
70
|
+
seventy_years_and_over,
|
71
|
+
work_in_multiple_company,
|
72
|
+
first_payment_day_of_multiple_payments_within_the_same_month,
|
73
|
+
submit_only_seventy_years_and_over
|
74
|
+
].map { |attr| attr.to_s.encode('CP932') }.join(',')
|
75
|
+
end
|
76
|
+
|
77
|
+
def bonus_total(currency, goods)
|
78
|
+
total = currency.to_i + goods.to_i
|
79
|
+
total >= 10_000_000 ? 9_999_000 : total.floor(-3)
|
80
|
+
end
|
81
|
+
|
82
|
+
def adjusted_payment_in_currency
|
83
|
+
payment_in_currency < 10_000_000 ? payment_in_currency : 9_999_999
|
84
|
+
end
|
85
|
+
|
86
|
+
def adjusted_payment_in_goods
|
87
|
+
payment_in_goods < 10_000_000 ? payment_in_goods : 9_999_999
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def seventy_years_and_over_employee_need_to_input_my_number_or_basic_pension_number
|
93
|
+
return if seventy_years_and_over.nil?
|
94
|
+
|
95
|
+
errors.add(:base, '70歳以上被用者の場合、マイナンバー、もしくは基礎年金番号の入力は必須です。') if my_number.nil? && area_code_of_basic_pension_number.nil? && serial_number_of_basic_pension_number.nil?
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'kirico/models/base_fd_management_record'
|
3
4
|
|
4
5
|
module Kirico
|
5
6
|
class FDManagementRecord < BaseFDManagementRecord
|
7
|
+
attribute :prefecture_code, String
|
6
8
|
attribute :area_code, String
|
7
9
|
attribute :office_code, String
|
8
10
|
|
11
|
+
validates :prefecture_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
9
12
|
validates :area_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 2 }
|
10
|
-
validates :office_code, charset: { accept: [
|
13
|
+
validates :office_code, charset: { accept: %i[numeric latin katakana] }, sjis_bytesize: { in: 1..4 }
|
11
14
|
|
12
15
|
def to_csv
|
13
16
|
[
|
17
|
+
prefecture_code,
|
14
18
|
area_code,
|
15
19
|
office_code,
|
16
20
|
fd_seq_number,
|
data/lib/kirico/models/form.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'virtus'
|
3
4
|
require 'active_model'
|
4
5
|
|
@@ -17,7 +18,7 @@ module Kirico
|
|
17
18
|
validates :fd, :company_count, :company, :records, presence: true
|
18
19
|
validate :validate_children
|
19
20
|
|
20
|
-
def initialize(fd:, company_count: Kirico::CompanyCount.new,
|
21
|
+
def initialize(fd:, company:, company_count: Kirico::CompanyCount.new, records: [])
|
21
22
|
@fd = fd
|
22
23
|
@company_count = company_count
|
23
24
|
@company = company
|
@@ -40,9 +41,10 @@ module Kirico
|
|
40
41
|
|
41
42
|
# 子のエラーを自身のエラーとして設定する
|
42
43
|
def validate_children
|
43
|
-
[
|
44
|
+
%i[fd company company_count].each do |attribute|
|
44
45
|
rec = send(attribute)
|
45
46
|
next if rec.nil? || rec.valid?
|
47
|
+
|
46
48
|
rec.errors.full_messages.each do |msg|
|
47
49
|
errors.add(attribute, msg)
|
48
50
|
end
|
@@ -51,6 +53,7 @@ module Kirico
|
|
51
53
|
# 2行以上存在する場合は、何行目でエラーが起きたのかを知りたい
|
52
54
|
records.each.with_index(1) do |rec, i|
|
53
55
|
next if rec.valid?
|
56
|
+
|
54
57
|
row = I18n.t('errors.row_counter', num: i) if records.length > 1
|
55
58
|
rec.errors.full_messages.each do |msg|
|
56
59
|
errors.add(:records, "#{row}#{msg}")
|
data/lib/kirico/models/helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'era_ja'
|
3
4
|
require 'active_support/core_ext/object'
|
4
5
|
require 'yaml'
|
@@ -103,6 +104,7 @@ module Kirico
|
|
103
104
|
define_method("mapped_#{attr_name}") do
|
104
105
|
value = send(attr_name)
|
105
106
|
return if value.nil?
|
107
|
+
|
106
108
|
class_name = self.class.name.underscore
|
107
109
|
@mappers ||= YAML.load_file(File.join(__dir__, 'mappers.yml'))
|
108
110
|
@mappers['mappers'][class_name.to_s].try(:[], attr_name.to_s).try(:[], value.to_s)
|
@@ -15,6 +15,23 @@ mappers:
|
|
15
15
|
T: 3
|
16
16
|
S: 5
|
17
17
|
H: 7
|
18
|
+
# 月額変更届
|
19
|
+
kirico/data_record2221700:
|
20
|
+
birth_at_era_nengo:
|
21
|
+
M: 1
|
22
|
+
T: 3
|
23
|
+
S: 5
|
24
|
+
H: 7
|
25
|
+
R: 9
|
26
|
+
applied_at_era_nengo:
|
27
|
+
H: 7
|
28
|
+
R: 9
|
29
|
+
old_applied_at_era_nengo:
|
30
|
+
H: 7
|
31
|
+
R: 9
|
32
|
+
income_updated_type:
|
33
|
+
income_updated_type_0: 1
|
34
|
+
income_updated_type_1: 2
|
18
35
|
# 算定基礎届
|
19
36
|
kirico/data_record22257041:
|
20
37
|
birth_at_era_nengo:
|
@@ -51,3 +68,47 @@ mappers:
|
|
51
68
|
income_updated_type:
|
52
69
|
income_updated_type_0: 0
|
53
70
|
income_updated_type_1: 1
|
71
|
+
# 2018年3月以降 算定基礎届
|
72
|
+
kirico/data_record2225700:
|
73
|
+
birth_at_era_nengo:
|
74
|
+
M: 1
|
75
|
+
T: 3
|
76
|
+
S: 5
|
77
|
+
H: 7
|
78
|
+
R: 9
|
79
|
+
applied_at_era_nengo:
|
80
|
+
M: 1
|
81
|
+
T: 3
|
82
|
+
S: 5
|
83
|
+
H: 7
|
84
|
+
R: 9
|
85
|
+
old_applied_at_era_nengo:
|
86
|
+
M: 1
|
87
|
+
T: 3
|
88
|
+
S: 5
|
89
|
+
H: 7
|
90
|
+
R: 9
|
91
|
+
income_updated_at_era_nengo:
|
92
|
+
M: 1
|
93
|
+
T: 3
|
94
|
+
S: 5
|
95
|
+
H: 7
|
96
|
+
R: 9
|
97
|
+
ip_type:
|
98
|
+
ip_type_0: 0
|
99
|
+
ip_type_1: 1
|
100
|
+
ip_type_2: 2
|
101
|
+
income_updated_type:
|
102
|
+
income_updated_type_0: 1
|
103
|
+
income_updated_type_1: 2
|
104
|
+
# 賞与支払届
|
105
|
+
kirico/data_record2265700:
|
106
|
+
birth_at_era_nengo:
|
107
|
+
M: 1
|
108
|
+
T: 3
|
109
|
+
S: 5
|
110
|
+
H: 7
|
111
|
+
R: 9
|
112
|
+
bonus_payment_at_era_nengo:
|
113
|
+
H: 7
|
114
|
+
R: 9
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'kirico/models/base_company_count'
|
3
4
|
|
4
5
|
# 社会保険労務士: 事業所数情報
|
@@ -8,7 +9,7 @@ module Kirico
|
|
8
9
|
|
9
10
|
attribute :name, String
|
10
11
|
|
11
|
-
validates :name, charset: { accept: [
|
12
|
+
validates :name, charset: { accept: %i[katakana kanji] }, sjis_bytesize: { in: 1..25 }, space_divider: { space: :both_width }
|
12
13
|
|
13
14
|
def to_csv
|
14
15
|
[name, COUNT].map { |attr| attr.to_s.encode('CP932') }.join(',')
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'kirico/models/base_fd_management_record'
|
3
4
|
|
4
5
|
# 社会保険労務士: FD 管理レコード
|
@@ -6,10 +7,11 @@ module Kirico
|
|
6
7
|
class SrFDManagementRecord < BaseFDManagementRecord
|
7
8
|
attribute :sr_code, String
|
8
9
|
|
9
|
-
validates :sr_code, charset: { accept: [:numeric] }, sjis_bytesize: { is:
|
10
|
+
validates :sr_code, charset: { accept: [:numeric] }, sjis_bytesize: { is: 8 }
|
10
11
|
|
11
12
|
def to_csv
|
12
13
|
[
|
14
|
+
'',
|
13
15
|
'',
|
14
16
|
sr_code,
|
15
17
|
fd_seq_number,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'active_model'
|
3
|
-
require 'active_model/validator'
|
4
4
|
|
5
5
|
# SJIS 換算の文字長を検証する
|
6
6
|
# SJIS 変換不可文字が設定された場合は 1 文字としてカウントする
|
@@ -11,22 +11,21 @@ require 'active_model/validator'
|
|
11
11
|
# 参考: https://github.com/rails/rails/blob/fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2/activemodel/lib/active_model/validations/length.rb
|
12
12
|
module Kirico
|
13
13
|
class SjisBytesizeValidator < ActiveModel::EachValidator
|
14
|
-
MESSAGES = { is: :
|
14
|
+
MESSAGES = { is: :wrong_length_in_bytes, minimum: :too_short_in_bytes, maximum: :too_long_in_bytes }.freeze
|
15
15
|
CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze
|
16
16
|
|
17
|
-
RESERVED_OPTIONS = [
|
17
|
+
RESERVED_OPTIONS = %i[minimum maximum within is too_short too_long]
|
18
18
|
|
19
19
|
def initialize(options)
|
20
|
-
range =
|
20
|
+
range = options.delete(:in) || options.delete(:within)
|
21
21
|
if range
|
22
22
|
raise ArgumentError, ':in and :within must be a Range' unless range.is_a?(Range)
|
23
|
+
|
23
24
|
options[:minimum] = range.min
|
24
25
|
options[:maximum] = range.max
|
25
26
|
end
|
26
27
|
|
27
|
-
if options[:allow_blank] == false && options[:minimum].nil? && options[:is].nil?
|
28
|
-
options[:minimum] = 1
|
29
|
-
end
|
28
|
+
options[:minimum] = 1 if options[:allow_blank] == false && options[:minimum].nil? && options[:is].nil?
|
30
29
|
|
31
30
|
super
|
32
31
|
end
|
@@ -34,16 +33,12 @@ module Kirico
|
|
34
33
|
def check_validity!
|
35
34
|
keys = CHECKS.keys & options.keys
|
36
35
|
|
37
|
-
if keys.empty?
|
38
|
-
raise ArgumentError, 'Range unspecified. Specify the :in, :within, :maximum, :minimum, or :is option.'
|
39
|
-
end
|
36
|
+
raise ArgumentError, 'Range unspecified. Specify the :in, :within, :maximum, :minimum, or :is option.' if keys.empty?
|
40
37
|
|
41
38
|
keys.each do |key|
|
42
39
|
value = options[key]
|
43
40
|
|
44
|
-
unless (value.is_a?(Integer) && value >= 0) || value == Float::INFINITY
|
45
|
-
raise ArgumentError, ":#{key} must be a nonnegative Integer or Infinity"
|
46
|
-
end
|
41
|
+
raise ArgumentError, ":#{key} must be a nonnegative Integer or Infinity" unless (value.is_a?(Integer) && value >= 0) || value == Float::INFINITY
|
47
42
|
end
|
48
43
|
end
|
49
44
|
|
@@ -56,16 +51,14 @@ module Kirico
|
|
56
51
|
check_value = options[key]
|
57
52
|
next unless check_value
|
58
53
|
|
59
|
-
if !value.nil? || skip_nil_check?(key)
|
60
|
-
next if value_length.send(validity_check, check_value)
|
61
|
-
end
|
54
|
+
next if (!value.nil? || skip_nil_check?(key)) && value_length.send(validity_check, check_value)
|
62
55
|
|
63
56
|
errors_options[:count] = check_value
|
64
57
|
|
65
58
|
default_message = options[MESSAGES[key]]
|
66
59
|
errors_options[:message] ||= default_message if default_message
|
67
60
|
|
68
|
-
record.errors.add(attribute, MESSAGES[key], errors_options)
|
61
|
+
record.errors.add(attribute, MESSAGES[key], **errors_options)
|
69
62
|
end
|
70
63
|
end
|
71
64
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'active_model'
|
3
|
-
require 'active_model/validator'
|
4
|
-
require 'active_model/validations/format'
|
5
4
|
|
6
5
|
# 文字種別を検証する
|
7
6
|
#
|
@@ -37,7 +36,7 @@ module Kirico
|
|
37
36
|
}.freeze
|
38
37
|
|
39
38
|
def check_validity!
|
40
|
-
raise ArgumentError, "Invalid space option #{space_option}. Specify the :full_width, half_width, or :both_width." unless CHECKS.
|
39
|
+
raise ArgumentError, "Invalid space option #{space_option}. Specify the :full_width, half_width, or :both_width." unless CHECKS.key?(space_option)
|
41
40
|
end
|
42
41
|
|
43
42
|
def validate_each(record, attribute, value)
|
data/lib/kirico/version.rb
CHANGED
data/lib/kirico.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'kirico/version'
|
3
4
|
require 'kirico/models/application_record'
|
4
5
|
require 'kirico/models/company_count'
|
@@ -7,6 +8,9 @@ require 'kirico/models/company'
|
|
7
8
|
require 'kirico/models/data_identifier'
|
8
9
|
require 'kirico/models/data_record22187041'
|
9
10
|
require 'kirico/models/data_record22257041'
|
11
|
+
require 'kirico/models/data_record2221700'
|
12
|
+
require 'kirico/models/data_record2225700'
|
13
|
+
require 'kirico/models/data_record2265700'
|
10
14
|
require 'kirico/models/fd_management_record'
|
11
15
|
require 'kirico/models/helper'
|
12
16
|
require 'kirico/models/form'
|