From 79ced8f7a2562587b533d6cb658a7023dbff6cd1 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:55:48 +0000 Subject: [PATCH] Log updated records (#2245) --- lib/tasks/clear_invalidated_earnings.rake | 1 + spec/lib/tasks/clear_invalidated_earnings_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tasks/clear_invalidated_earnings.rake b/lib/tasks/clear_invalidated_earnings.rake index 74dbd1aca..b474a675a 100644 --- a/lib/tasks/clear_invalidated_earnings.rake +++ b/lib/tasks/clear_invalidated_earnings.rake @@ -3,6 +3,7 @@ task clear_invalidated_earnings: :environment do LettingsLog.filter_by_year(2023).find_each do |lettings_log| lettings_log.validate_net_income(lettings_log) if lettings_log.errors[:earnings].present? + Rails.logger.info "Clearing earnings for lettings log #{lettings_log.id}, owning_organisation_id: #{lettings_log.owning_organisation_id}, managing_organisation_id: #{lettings_log.managing_organisation_id}, startdate: #{lettings_log.startdate.to_date}, tenancy reference: #{lettings_log.tenancycode}, property reference: #{lettings_log.propcode}, created_by: #{lettings_log.created_by.email}(#{lettings_log.created_by_id})" lettings_log.earnings = nil lettings_log.incfreq = nil lettings_log.save!(validate: false) diff --git a/spec/lib/tasks/clear_invalidated_earnings_spec.rb b/spec/lib/tasks/clear_invalidated_earnings_spec.rb index 19e5d8f88..b7cd617ff 100644 --- a/spec/lib/tasks/clear_invalidated_earnings_spec.rb +++ b/spec/lib/tasks/clear_invalidated_earnings_spec.rb @@ -15,7 +15,7 @@ RSpec.describe "clear_invalidated_earnings" do context "when the rake task is run" do context "and there are 2023 logs with invalid earnings" do let(:user) { create(:user) } - let!(:lettings_log) { create(:lettings_log, :completed, created_by: user, voiddate: nil, mrcdate: nil) } + let!(:lettings_log) { create(:lettings_log, :completed, created_by: user, voiddate: nil, mrcdate: nil, tenancycode: "123", propcode: "321") } before do lettings_log.startdate = Time.zone.local(2023, 4, 4) @@ -32,6 +32,7 @@ RSpec.describe "clear_invalidated_earnings" do expect(lettings_log.earnings).to eq(20) expect(lettings_log.hhmemb).to eq(1) expect(lettings_log.ecstat1).to eq(1) + expect(Rails.logger).to receive(:info).with("Clearing earnings for lettings log #{lettings_log.id}, owning_organisation_id: #{lettings_log.owning_organisation_id}, managing_organisation_id: #{lettings_log.managing_organisation_id}, startdate: 2023-04-04, tenancy reference: 123, property reference: 321, created_by: #{user.email}(#{user.id})") task.invoke lettings_log.reload