Class: Kirico::DataRecord22257041
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Kirico::DataRecord22257041
- Defined in:
- lib/kirico/models/data_record22257041.rb
Constant Summary collapse
- DOC_CODE =
'22257041'- COVERED_MONTHS =
[:apr, :may, :jun].freeze
Instance Method Summary collapse
-
#income_average ⇒ Object
平均額を計算する.
-
#income_total(currency, goods) ⇒ Object
rubocop:enable all.
-
#initialize {|_self| ... } ⇒ DataRecord22257041
constructor
A new instance of DataRecord22257041.
-
#target_months ⇒ Object
算定対象月の配列を返却するs.
-
#to_csv ⇒ Object
rubocop:disable all.
Methods included from Helper
#define_code_mapper_method, #define_format_date_method, #define_in_k_method
Constructor Details
#initialize {|_self| ... } ⇒ DataRecord22257041
Returns a new instance of DataRecord22257041.
63 64 65 |
# File 'lib/kirico/models/data_record22257041.rb', line 63 def initialize yield(self) if block_given? end |
Instance Method Details
#income_average ⇒ Object
平均額を計算する
算定対象月の合計値を算定対象月数で割った値を返す。
ただし、
-
1 円未満は切り捨て
-
10,000,000 円以上は 9,999,999 を返す
-
算定対象月が存在しない場合は「0」を返す
132 133 134 135 136 137 138 139 |
# File 'lib/kirico/models/data_record22257041.rb', line 132 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) ⇒ Object
rubocop:enable all
119 120 121 122 |
# File 'lib/kirico/models/data_record22257041.rb', line 119 def income_total(currency, goods) total = currency.to_i + goods.to_i total < 10_000_000 ? total : 9_999_999 end |
#target_months ⇒ Object
算定対象月の配列を返却するs
-
一般の被保険者の場合17 日以上の月を対象とする
-
短時間労働者の場合11 日以上の月を対象とする
-
パートタイマーの場合17 日以上の月を対象とする。ただし、全ての算定基礎月の支払基礎日数が 17 日未満の場合は、15 日以上の月を対象とする。
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/kirico/models/data_record22257041.rb', line 153 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 ⇒ Object
rubocop:disable all
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/kirico/models/data_record22257041.rb', line 68 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, applied_at_month, 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 |