Browse Source

Correct weekly income calculation based on a given yearly income (#483)

pull/485/head
Stéphane Meny 3 years ago committed by GitHub
parent
commit
ed9a32a7fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/case_log.rb
  2. 4
      config/locales/en.yml
  3. 2
      spec/models/case_log_spec.rb

2
app/models/case_log.rb

@ -100,7 +100,7 @@ class CaseLog < ApplicationRecord
elsif net_income_is_monthly? elsif net_income_is_monthly?
((earnings * 12) / 52.0).round(0) ((earnings * 12) / 52.0).round(0)
elsif net_income_is_yearly? elsif net_income_is_yearly?
(earnings / 12.0).round(0) (earnings / 52.0).round(0)
end end
end end

4
config/locales/en.yml

@ -93,8 +93,8 @@ en:
benefits: benefits:
part_or_full_time: "Answer cannot be 'all' for income from Universal Credit, state pensions or benefits if the tenant or their partner works part-time or full-time" part_or_full_time: "Answer cannot be 'all' for income from Universal Credit, state pensions or benefits if the tenant or their partner works part-time or full-time"
earnings: earnings:
over_hard_max: "Net income cannot be greater than %{hard_max} given the tenant’s working situation" over_hard_max: "Net income cannot be greater than £%{hard_max} per week given the tenant’s working situation"
under_hard_min: "Net income cannot be less than %{hard_min} given the tenant’s working situation" under_hard_min: "Net income cannot be less than £%{hard_min} per week given the tenant’s working situation"
freq_missing: "Select how often the household receives income" freq_missing: "Select how often the household receives income"
earnings_missing: "Enter how much income the household has in total" earnings_missing: "Enter how much income the household has in total"
negative_currency: "Enter an amount above 0" negative_currency: "Enter an amount above 0"

2
spec/models/case_log_spec.rb

@ -186,7 +186,7 @@ RSpec.describe CaseLog do
it "calculates the correct weekly income from yearly income" do it "calculates the correct weekly income from yearly income" do
case_log.incfreq = 3 case_log.incfreq = 3
expect(case_log.weekly_net_income).to eq(417) expect(case_log.weekly_net_income).to eq(96)
end end
end end

Loading…
Cancel
Save