IkumaTadokoro / quitcost

「無職になったらいくらかかる?」を簡単に計算できるサービス
https://quitcost.herokuapp.com/
25 stars 2 forks source link

0割でAPIが落ちる #147

Closed IkumaTadokoro closed 2 years ago

IkumaTadokoro commented 2 years ago

概要

特定の条件下で0割が発生し、エラーになる

再現手順

以下のparam

age: "20"
employmentMonth: "2023/04"
postalCode: "270-1154"
retirementMonth: "2022/04"
salary: "5000000"
scheduledSalary: "5000000"
scheduledSocialInsurance: "735000"
simulationDate: "2022-03-05T13:23:55.361Z"
socialInsurance: "735000"

期待される振る舞い

No response

スクリーンショット

ActionView::Template::Error (divided by 0):
    1: json.simulation do
    2:   json.retirement_month @simulation.retirement_month
    3:   json.employment_month @simulation.employment_month
    4:   json.grand_total @simulation.grand_total
    5:   json.sub_total @simulation.sub_total
    6:   json.monthly_payment @simulation.monthly_payment
    7: end

app/models/concerns/local_tax_law.rb:23:in `/'
app/models/concerns/local_tax_law.rb:23:in `calc_installments'
app/models/simulation/insurance.rb:34:in `block in monthly_insurance'
app/models/simulation/insurance.rb:27:in `each'
app/models/simulation/insurance.rb:27:in `flat_map'
app/models/simulation/insurance.rb:27:in `monthly_insurance'
app/models/simulation/insurance.rb:19:in `call'
app/models/simulation/insurance.rb:7:in `call'
app/models/simulation.rb:41:in `insurance'
app/models/simulation.rb:22:in `monthly_payment'
app/models/simulation.rb:18:in `block in sub_total'
app/models/simulation.rb:18:in `sub_total'
app/models/simulation.rb:14:in `grand_total'
app/views/api/simulations/show.json.jbuilder:4
app/views/api/simulations/show.json.jbuilder:1

環境

No response

関連Issue

No response

IkumaTadokoro commented 2 years ago

千代田区にすると落ちない模様

IkumaTadokoro commented 2 years ago

現時点で判明している原因は2つ

  1. 国民健康保険の支払対象月が1月も登録されていないケース
  2. 対象の年度のレコードがなくてフォールバックする場合に、計算している年度と支払対象月の年度がずれて、支払対象の期日が取得できないケース