diff --git a/app/models/form/sales/questions/age1.rb b/app/models/form/sales/questions/age1.rb index d32083b53..0ae3bf682 100644 --- a/app/models/form/sales/questions/age1.rb +++ b/app/models/form/sales/questions/age1.rb @@ -19,6 +19,7 @@ class Form::Sales::Questions::Age1 < ::Form::Question @check_answers_card_number = 1 @min = 16 @max = 110 + @step = 1 @question_number = 20 end end diff --git a/app/models/form/sales/questions/age2.rb b/app/models/form/sales/questions/age2.rb index c0dc567a1..c003eb02e 100644 --- a/app/models/form/sales/questions/age2.rb +++ b/app/models/form/sales/questions/age2.rb @@ -13,6 +13,7 @@ class Form::Sales::Questions::Age2 < ::Form::Question @check_answers_card_number = 2 @max = 110 @min = 0 + @step = 1 @question_number = 28 end end diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb index fb6c0e563..784bb56a1 100644 --- a/app/models/form/sales/questions/deposit_amount.rb +++ b/app/models/form/sales/questions/deposit_amount.rb @@ -6,8 +6,9 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question @header = "How much cash deposit was paid on the property?" @type = "numeric" @min = 0 - @width = 5 @max = 999_999 + @step = 1 + @width = 5 @prefix = "£" @hint_text = "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage" @derived = true diff --git a/app/models/form/sales/questions/deposit_discount.rb b/app/models/form/sales/questions/deposit_discount.rb index 577da5a91..ae6521392 100644 --- a/app/models/form/sales/questions/deposit_discount.rb +++ b/app/models/form/sales/questions/deposit_discount.rb @@ -7,6 +7,7 @@ class Form::Sales::Questions::DepositDiscount < ::Form::Question @type = "numeric" @min = 0 @max = 999_999 + @step = 1 @width = 5 @prefix = "£" @hint_text = "Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme" diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb index 8c5cf7132..ee39b8916 100644 --- a/app/models/form/sales/questions/discount.rb +++ b/app/models/form/sales/questions/discount.rb @@ -7,6 +7,7 @@ class Form::Sales::Questions::Discount < ::Form::Question @type = "numeric" @min = 0 @max = 100 + @step = 1 @width = 5 @suffix = "%" @hint_text = "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB)

diff --git a/app/models/form/sales/questions/equity.rb b/app/models/form/sales/questions/equity.rb index 0119fea69..4db09a31f 100644 --- a/app/models/form/sales/questions/equity.rb +++ b/app/models/form/sales/questions/equity.rb @@ -7,6 +7,7 @@ class Form::Sales::Questions::Equity < ::Form::Question @type = "numeric" @min = 0 @max = 100 + @step = 1 @width = 5 @suffix = "%" @hint_text = "Enter the amount of initial equity held by the purchaser (for example, 25% or 50%)" diff --git a/app/models/form/sales/questions/grant.rb b/app/models/form/sales/questions/grant.rb index 9b0fd3091..e113be536 100644 --- a/app/models/form/sales/questions/grant.rb +++ b/app/models/form/sales/questions/grant.rb @@ -7,6 +7,7 @@ class Form::Sales::Questions::Grant < ::Form::Question @type = "numeric" @min = 0 @max = 999_999 + @step = 1 @width = 5 @prefix = "£" @hint_text = "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy" diff --git a/app/models/form/sales/questions/leasehold_charges.rb b/app/models/form/sales/questions/leasehold_charges.rb index 22ed7246e..34cc25a3d 100644 --- a/app/models/form/sales/questions/leasehold_charges.rb +++ b/app/models/form/sales/questions/leasehold_charges.rb @@ -5,7 +5,12 @@ class Form::Sales::Questions::LeaseholdCharges < ::Form::Question @check_answer_label = "Monthly leasehold charges" @header = "Enter the total monthly charge" @type = "numeric" +<<<<<<< HEAD @min = 1 +======= + @min = 0 + @step = 0.01 +>>>>>>> a59c771e (add or alter step on numeric questions in sales, amend one test given step changes) @width = 5 @prefix = "£" @ownershipsch = ownershipsch diff --git a/app/models/form/sales/questions/monthly_rent.rb b/app/models/form/sales/questions/monthly_rent.rb index 2a28bc691..75c4a7ce5 100644 --- a/app/models/form/sales/questions/monthly_rent.rb +++ b/app/models/form/sales/questions/monthly_rent.rb @@ -6,6 +6,7 @@ class Form::Sales::Questions::MonthlyRent < ::Form::Question @header = "What is the basic monthly rent?" @type = "numeric" @min = 0 + @step = 0.01 @width = 5 @prefix = "£" @hint_text = "Amount paid before any charges" diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb index 9b199b2aa..ce4b548e1 100644 --- a/app/models/form/sales/questions/mortgage_amount.rb +++ b/app/models/form/sales/questions/mortgage_amount.rb @@ -6,6 +6,7 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question @header = "What is the mortgage amount?" @type = "numeric" @min = 1 + @step = 1 @width = 5 @prefix = "£" @hint_text = "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound." diff --git a/app/models/form/sales/questions/number_of_others_in_property.rb b/app/models/form/sales/questions/number_of_others_in_property.rb index 556ddf837..450b12eb0 100644 --- a/app/models/form/sales/questions/number_of_others_in_property.rb +++ b/app/models/form/sales/questions/number_of_others_in_property.rb @@ -9,6 +9,7 @@ class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question @width = 2 @min = 0 @max = 15 + @step = 1 @question_number = 35 end diff --git a/app/models/form/sales/questions/previous_bedrooms.rb b/app/models/form/sales/questions/previous_bedrooms.rb index d9f9aaddb..8f36a8485 100644 --- a/app/models/form/sales/questions/previous_bedrooms.rb +++ b/app/models/form/sales/questions/previous_bedrooms.rb @@ -8,6 +8,7 @@ class Form::Sales::Questions::PreviousBedrooms < ::Form::Question @width = 5 @min = 1 @max = 6 + @step = 1 @hint_text = "For bedsits enter 1" @question_number = 85 end diff --git a/app/models/form/sales/questions/property_number_of_bedrooms.rb b/app/models/form/sales/questions/property_number_of_bedrooms.rb index 9dbdbf3e8..b37253244 100644 --- a/app/models/form/sales/questions/property_number_of_bedrooms.rb +++ b/app/models/form/sales/questions/property_number_of_bedrooms.rb @@ -9,6 +9,7 @@ class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question @width = 10 @min = 1 @max = 9 + @step = 1 @question_number = 11 end end diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb index c98a39ef3..f88938777 100644 --- a/app/models/form/sales/questions/purchase_price.rb +++ b/app/models/form/sales/questions/purchase_price.rb @@ -6,6 +6,7 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question @header = "What is the full purchase price?" @type = "numeric" @min = 0 + @step = 0.01 @width = 5 @prefix = "£" @hint_text = "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount" diff --git a/app/models/form/sales/questions/savings.rb b/app/models/form/sales/questions/savings.rb index 086a0ec8d..82ed8f6c9 100644 --- a/app/models/form/sales/questions/savings.rb +++ b/app/models/form/sales/questions/savings.rb @@ -7,7 +7,7 @@ class Form::Sales::Questions::Savings < ::Form::Question @type = "numeric" @width = 5 @prefix = "£" - @step = 1 + @step = 10 @min = 0 @question_number = 72 end diff --git a/app/models/form/sales/questions/staircase_bought.rb b/app/models/form/sales/questions/staircase_bought.rb index 9e54e92d3..dfdb273f5 100644 --- a/app/models/form/sales/questions/staircase_bought.rb +++ b/app/models/form/sales/questions/staircase_bought.rb @@ -8,6 +8,7 @@ class Form::Sales::Questions::StaircaseBought < ::Form::Question @width = 5 @min = 0 @max = 100 + @step = 1 @suffix = "%" @question_number = 77 end diff --git a/app/models/form/sales/questions/staircase_owned.rb b/app/models/form/sales/questions/staircase_owned.rb index b8d5a65ec..2b4d89861 100644 --- a/app/models/form/sales/questions/staircase_owned.rb +++ b/app/models/form/sales/questions/staircase_owned.rb @@ -8,6 +8,7 @@ class Form::Sales::Questions::StaircaseOwned < ::Form::Question @width = 5 @min = 0 @max = 100 + @step = 1 @suffix = "%" @question_number = 78 end diff --git a/app/models/form/sales/questions/value.rb b/app/models/form/sales/questions/value.rb index 4736f37af..d349a99df 100644 --- a/app/models/form/sales/questions/value.rb +++ b/app/models/form/sales/questions/value.rb @@ -6,6 +6,7 @@ class Form::Sales::Questions::Value < ::Form::Question @header = "What was the full purchase price?" @type = "numeric" @min = 0 + @step = 1 @width = 5 @prefix = "£" @hint_text = "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)" diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb index 4c22665db..99be14509 100644 --- a/app/models/validations/shared_validations.rb +++ b/app/models/validations/shared_validations.rb @@ -60,7 +60,7 @@ module Validations::SharedValidations if user_input.is_a?(String) && user_input.include?("e") record.errors.add question.id.to_sym, I18n.t("validations.numeric.normal_format") end - end + end end def validate_property_postcode(record) diff --git a/spec/models/validations/shared_validations_spec.rb b/spec/models/validations/shared_validations_spec.rb index 1a5bd69e6..2c985ad83 100644 --- a/spec/models/validations/shared_validations_spec.rb +++ b/spec/models/validations/shared_validations_spec.rb @@ -145,13 +145,13 @@ RSpec.describe Validations::SharedValidations do context "when validating a question with a step of 0.01" do it "adds an error if input has more than 2 decimal places" do - sales_log.deposit = 630.7418 + sales_log.mscharge = 30.7418 shared_validator.validate_numeric_step(sales_log) - expect(sales_log.errors[:deposit]).to include I18n.t("validations.numeric.nearest_penny", field: "Cash deposit") + expect(sales_log.errors[:mscharge]).to include I18n.t("validations.numeric.nearest_penny", field: "Monthly leasehold charges") end it "does not add an error if input has 2 or fewer decimal places" do - sales_log.deposit = 630.74 + sales_log.mscharge = 30.74 shared_validator.validate_numeric_step(sales_log) expect(sales_log.errors).to be_empty end