|
|
|
@ -1,10 +1,9 @@ |
|
|
|
desc "Rounds and value for sales logs in the database if they are not a whole number" |
|
|
|
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 |
|
|
|
task round_value_for_2026_sales_logs: :environment do |
|
|
|
ids = SalesLog.filter_by_year(2026).where("value % 1 != 0").pluck(:id) |
|
|
|
logs = SalesLog.filter_by_year(2026).where("value % 1 != 0") |
|
|
|
puts "Correcting #{ids.count} sales logs, #{ids}" |
|
|
|
puts "Correcting #{logs.count} sales logs, #{logs.map(&:id)}" |
|
|
|
|
|
|
|
|
|
|
|
# find all values of mortgage that are not a whole number |
|
|
|
logs.find_each do |log| |
|
|
|
SalesLog.filter_by_year(2026).where("value % 1 != 0").find_each do |log| |
|
|
|
|
|
|
|
log.update(value: log.value.round) |
|
|
|
log.update(value: log.value.round) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|