Browse Source

refactor: improve readability

pull/2278/head
natdeanlewissoftwire 2 years ago
parent
commit
8f5ef04a7b
  1. 12
      app/models/lettings_log.rb
  2. 5
      app/models/log.rb
  3. 12
      app/models/sales_log.rb

12
app/models/lettings_log.rb

@ -846,10 +846,18 @@ private
end end
def should_process_uprn_change? def should_process_uprn_change?
uprn && startdate && (uprn_changed? || startdate_changed?) && collection_start_year_for_date(startdate) >= 2023 return unless uprn
return unless startdate
return unless collection_start_year_for_date(startdate) >= 2023
uprn_changed? || startdate_changed?
end end
def should_process_address_change? def should_process_address_change?
(address_selection || select_best_address_match) && startdate && ((address_selection_changed? || select_best_address_match) || startdate_changed?) && form.start_year_after_2024? return unless address_selection || select_best_address_match
return unless startdate
return unless form.start_year_after_2024?
address_selection_changed? || select_best_address_match || startdate_changed?
end end
end end

5
app/models/log.rb

@ -87,8 +87,8 @@ class Log < ApplicationRecord
if select_best_address_match if select_best_address_match
presenter = AddressDataPresenter.new(service.result.first) presenter = AddressDataPresenter.new(service.result.first)
os_good_match_threshold = 0.7 os_match_threshold_for_bulk_upload = 0.7
if presenter.match >= os_good_match_threshold if presenter.match >= os_match_threshold_for_bulk_upload
self.address_selection = 0 self.address_selection = 0
else else
return nil return nil
@ -127,7 +127,6 @@ class Log < ApplicationRecord
return @address_options if @address_options return @address_options if @address_options
if [address_line1_input, postcode_full_input].all?(&:present?) if [address_line1_input, postcode_full_input].all?(&:present?)
address_string = "#{address_line1_input}, , , #{postcode_full_input}"
service = AddressClient.new(address_string) service = AddressClient.new(address_string)
service.call service.call

12
app/models/sales_log.rb

@ -430,11 +430,19 @@ class SalesLog < Log
end end
def should_process_uprn_change? def should_process_uprn_change?
uprn && saledate && (uprn_changed? || saledate_changed?) && collection_start_year_for_date(saledate) >= 2023 return unless uprn
return unless saledate
return unless collection_start_year_for_date(saledate) >= 2023
uprn_changed? || saledate_changed?
end end
def should_process_address_change? def should_process_address_change?
(address_selection || select_best_address_match) && saledate && ((address_selection_changed? || select_best_address_match) || saledate_changed?) && form.start_year_after_2024? return unless address_selection || select_best_address_match
return unless saledate
return unless form.start_year_after_2024?
address_selection_changed? || select_best_address_match || saledate_changed?
end end
def value_with_discount def value_with_discount

Loading…
Cancel
Save