Browse Source

CLDC-2795 Only update 2022 and 2023 logs (#1933)

* Only update 2022 and 2023 logs

* Add tests
pull/1934/head v0.3.58
kosiakkatrina 1 year ago committed by GitHub
parent
commit
6c88ddda93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      lib/tasks/confirm_charges_soft_validations.rake
  2. 30
      spec/lib/tasks/confirm_charges_soft_validations_spec.rb

8
lib/tasks/confirm_charges_soft_validations.rake

@ -1,6 +1,12 @@
desc "Confirms scharge, pscharge and supcharge soft validations for completed logs"
task confirm_charges_soft_validations: :environment do
LettingsLog.where(status: "completed").each do |log|
LettingsLog.where(status: "completed").filter_by_year(2022).each do |log|
log.update!(scharge_value_check: 0, values_updated_at: Time.zone.now) if log.scharge_value_check.blank? && log.scharge_over_soft_max?
log.update!(pscharge_value_check: 0, values_updated_at: Time.zone.now) if log.pscharge_value_check.blank? && log.pscharge_over_soft_max?
log.update!(supcharg_value_check: 0, values_updated_at: Time.zone.now) if log.supcharg_value_check.blank? && log.supcharg_over_soft_max?
end
LettingsLog.where(status: "completed").filter_by_year(2023).each do |log|
log.update!(scharge_value_check: 0, values_updated_at: Time.zone.now) if log.scharge_value_check.blank? && log.scharge_over_soft_max?
log.update!(pscharge_value_check: 0, values_updated_at: Time.zone.now) if log.pscharge_value_check.blank? && log.pscharge_over_soft_max?
log.update!(supcharg_value_check: 0, values_updated_at: Time.zone.now) if log.supcharg_value_check.blank? && log.supcharg_over_soft_max?

30
spec/lib/tasks/confirm_charges_soft_validations_spec.rb

@ -53,6 +53,16 @@ RSpec.describe "confirm_charges_soft_validations" do
expect(lettings_log.values_updated_at).to be_nil
end
it "does not confirm scharge value check for 2021 logs" do
lettings_log.scharge = 404
lettings_log.skip_update_status = true
lettings_log.startdate = Time.zone.local(2021, 4, 1)
lettings_log.save!(validate: false)
lettings_log.skip_update_status = nil
expect { task.invoke }.not_to change(lettings_log.reload, :scharge_value_check)
expect(lettings_log.values_updated_at).to be_nil
end
it "confirms pscharge value check for lettings logs with pscharge over soft max" do
lettings_log.pscharge = 204
lettings_log.skip_update_status = true
@ -92,6 +102,16 @@ RSpec.describe "confirm_charges_soft_validations" do
expect(lettings_log.values_updated_at).to be_nil
end
it "does not confirm pscharge value check for 2021 logs" do
lettings_log.pscharge = 204
lettings_log.skip_update_status = true
lettings_log.startdate = Time.zone.local(2021, 4, 1)
lettings_log.save!(validate: false)
lettings_log.skip_update_status = nil
expect { task.invoke }.not_to change(lettings_log.reload, :pscharge_value_check)
expect(lettings_log.values_updated_at).to be_nil
end
it "confirms supcharg value check for lettings logs with supcharg over soft max" do
lettings_log.supcharg = 204
lettings_log.skip_update_status = true
@ -130,6 +150,16 @@ RSpec.describe "confirm_charges_soft_validations" do
expect { task.invoke }.not_to change(lettings_log.reload, :supcharg_value_check)
expect(lettings_log.values_updated_at).to be_nil
end
it "does not confirm supcharg value check for 2021 logs" do
lettings_log.supcharg = 204
lettings_log.skip_update_status = true
lettings_log.startdate = Time.zone.local(2021, 4, 1)
lettings_log.save!(validate: false)
lettings_log.skip_update_status = nil
expect { task.invoke }.not_to change(lettings_log.reload, :supcharg_value_check)
expect(lettings_log.values_updated_at).to be_nil
end
end
end
end

Loading…
Cancel
Save