class Kirico::DataRecord22257041
Constants
- COVERED_MONTHS
- DOC_CODE
Public Class Methods
new() { |self| ... }
click to toggle source
# File lib/kirico/models/data_record22257041.rb, line 64 def initialize yield(self) if block_given? end
Public Instance Methods
income_average()
click to toggle source
平均額を計算する
算定対象月の合計値を算定対象月数で割った値を返す。
ただし、
-
1 円未満は切り捨て
-
10,000,000 円以上は 9,999,999 を返す
-
算定対象月が存在しない場合は「0」を返す
# File lib/kirico/models/data_record22257041.rb, line 133 def income_average return 0 if target_months.empty? total = target_months.map do |month| send("#{month}_income_currency").to_i + send("#{month}_income_goods").to_i end.inject(:+) avg = total / target_months.length avg < 10_000_000 ? avg : 9_999_999 end
income_total(currency, goods)
click to toggle source
rubocop:enable all
# File lib/kirico/models/data_record22257041.rb, line 120 def income_total(currency, goods) total = currency.to_i + goods.to_i total < 10_000_000 ? total : 9_999_999 end
target_months()
click to toggle source
算定対象月の配列を返却する
-
一般の被保険者の場合 17 日以上の月を対象とする
-
短時間労働者の場合 11 日以上の月を対象とする
-
パートタイマーの場合 17 日以上の月を対象とする。 ただし、全ての算定基礎月の支払基礎日数が 17 日未満の場合は、 15 日以上の月を対象とする。
# File lib/kirico/models/data_record22257041.rb, line 154 def target_months threshold = case ip_type when :ip_type_0 17 when :ip_type_1 COVERED_MONTHS.all? { |month| send("#{month}_days").to_i < 17 } ? 15 : 17 when :ip_type_2 11 else 17 end COVERED_MONTHS.select { |month| threshold <= send("#{month}_days").to_i } end
to_csv()
click to toggle source
rubocop:disable all
# File lib/kirico/models/data_record22257041.rb, line 69 def to_csv [ DOC_CODE, area_code, office_code, ip_code, mapped_birth_at_era_nengo, fmt_era_ymd_birth_at, '', mapped_applied_at_era_nengo, applied_at_era_year, '09', ip_name_yomi, ip_name, mapped_gender_type, old_monthly_standard_income_hel_ins.nil? ? nil : old_monthly_standard_income_hel_ins_in_k.to_s.rjust(4, '0'), old_monthly_standard_income_pns_ins.nil? ? nil : old_monthly_standard_income_pns_ins_in_k.to_s.rjust(4, '0'), mapped_old_applied_at_era_nengo, old_applied_at_era_year, old_applied_at_month, '04', '05', '06', apr_days.to_s.rjust(2, '0'), may_days.to_s.rjust(2, '0'), jun_days.to_s.rjust(2, '0'), apr_income_currency.to_s.rjust(7, '0'), may_income_currency.to_s.rjust(7, '0'), jun_income_currency.to_s.rjust(7, '0'), apr_income_goods.to_s.rjust(7, '0'), may_income_goods.to_s.rjust(7, '0'), jun_income_goods.to_s.rjust(7, '0'), income_total(apr_income_currency, apr_income_goods).to_s.rjust(7, '0'), income_total(may_income_currency, may_income_goods).to_s.rjust(7, '0'), income_total(jun_income_currency, jun_income_goods).to_s.rjust(7, '0'), income_average.to_s.rjust(7, '0'), avg_adjustment.nil? ? nil : avg_adjustment.to_s.rjust(7, '0'), mapped_ip_type, '', '', '', retroacted_payment.nil? ? nil : retroacted_payment.to_s.rjust(7, '0'), mapped_income_updated_type, income_diff_amount.nil? ? nil : income_diff_amount.to_s.rjust(7, '0'), income_updated_at.nil? ? nil : income_updated_at_era_year, income_updated_at.nil? ? nil : income_updated_at_month, memo ].map { |attr| attr.to_s.encode('CP932') }.join(',') end