Browse Source

CLDC-4298: Ensure value must be a whole number (#3297)

* CLDC-4298: Update purchase price step for 2026

* CLDC-4298: Add a rake task to round value values

* fixup! CLDC-4298: Add a rake task to round value values

remove redundant query

update desc

remove unneeded comment
pull/3309/head
Samuel Young 4 days ago committed by GitHub
parent
commit
5806eb8d72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/form/sales/questions/purchase_price.rb
  2. 11
      lib/tasks/round_value_for_2026_sales_logs.rake

2
app/models/form/sales/questions/purchase_price.rb

@ -4,7 +4,7 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
@id = "value" @id = "value"
@type = "numeric" @type = "numeric"
@min = form.start_year_2026_or_later? ? 15_000 : 0 @min = form.start_year_2026_or_later? ? 15_000 : 0
@step = 0.01 @step = form.start_year_2026_or_later? ? 1 : 0.01 # 0.01 was a mistake that was fixed in 2026
@width = 5 @width = 5
@prefix = "£" @prefix = "£"
@ownership_sch = ownershipsch @ownership_sch = ownershipsch

11
lib/tasks/round_value_for_2026_sales_logs.rake

@ -0,0 +1,11 @@
desc "Rounds purchase price (the 'value' field) for sales logs in the database if not a whole number"
task round_value_for_2026_sales_logs: :environment do
logs = SalesLog.filter_by_year(2026).where("value % 1 != 0")
puts "Correcting #{logs.count} sales logs, #{logs.map(&:id)}"
logs.find_each do |log|
log.update(value: log.value.round)
end
puts "Done"
end
Loading…
Cancel
Save