From ed9a32a7fba132c8006ac2bbd20510c26addf512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Thu, 21 Apr 2022 09:28:13 +0100 Subject: [PATCH] Correct weekly income calculation based on a given yearly income (#483) --- app/models/case_log.rb | 2 +- config/locales/en.yml | 4 ++-- spec/models/case_log_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index aa591d33d..9bbba8c46 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -100,7 +100,7 @@ class CaseLog < ApplicationRecord elsif net_income_is_monthly? ((earnings * 12) / 52.0).round(0) elsif net_income_is_yearly? - (earnings / 12.0).round(0) + (earnings / 52.0).round(0) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index ebd5762bc..076f547bf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -93,8 +93,8 @@ en: 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" earnings: - over_hard_max: "Net income cannot be greater than %{hard_max} given the tenant’s working situation" - under_hard_min: "Net income cannot be less than %{hard_min} 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} per week given the tenant’s working situation" freq_missing: "Select how often the household receives income" earnings_missing: "Enter how much income the household has in total" negative_currency: "Enter an amount above 0" diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index bcf132aa0..3633fba51 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -186,7 +186,7 @@ RSpec.describe CaseLog do it "calculates the correct weekly income from yearly income" do case_log.incfreq = 3 - expect(case_log.weekly_net_income).to eq(417) + expect(case_log.weekly_net_income).to eq(96) end end