Browse Source

Also log earnings and incfrew (#2248)

pull/2243/head^2 v0.4.17
kosiakkatrina 10 months ago committed by GitHub
parent
commit
364b19c184
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      lib/tasks/clear_invalidated_earnings.rake
  2. 2
      spec/lib/tasks/clear_invalidated_earnings_spec.rb

2
lib/tasks/clear_invalidated_earnings.rake

@ -3,7 +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})"
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}), earnings: #{lettings_log.earnings}, incfreq: #{lettings_log.incfreq}"
lettings_log.earnings = nil
lettings_log.incfreq = nil
lettings_log.save!(validate: false)

2
spec/lib/tasks/clear_invalidated_earnings_spec.rb

@ -32,7 +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})")
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}), earnings: 20, incfreq: 1")
task.invoke
lettings_log.reload

Loading…
Cancel
Save