|
|
|
|
@ -18,12 +18,16 @@ module Csv
|
|
|
|
|
.where.not(old_form_id: nil) |
|
|
|
|
.where.not(address_line1: nil) |
|
|
|
|
|
|
|
|
|
logs_with_wrong_uprn = @organisation.managed_lettings_logs |
|
|
|
|
.imported |
|
|
|
|
.filter_by_year(2023) |
|
|
|
|
.where(needstype: 1) |
|
|
|
|
.where.not(uprn: nil) |
|
|
|
|
.where("uprn = propcode OR uprn = tenancycode or town_or_city = 'Bristol'") |
|
|
|
|
logs_with_wrong_uprn = if JSON.parse(ENV["SKIP_UPRN_ISSUE_ORG_IDS"]).include?(@organisation.id) |
|
|
|
|
[] |
|
|
|
|
else |
|
|
|
|
@organisation.managed_lettings_logs |
|
|
|
|
.imported |
|
|
|
|
.filter_by_year(2023) |
|
|
|
|
.where(needstype: 1) |
|
|
|
|
.where.not(uprn: nil) |
|
|
|
|
.where("uprn = propcode OR uprn = tenancycode or town_or_city = 'Bristol'") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return if logs_with_missing_addresses.empty? && logs_with_missing_town_or_city.empty? && logs_with_wrong_uprn.empty? |
|
|
|
|
|
|
|
|
|
@ -100,12 +104,15 @@ module Csv
|
|
|
|
|
.where.not(old_form_id: nil) |
|
|
|
|
.where.not(address_line1: nil) |
|
|
|
|
|
|
|
|
|
logs_with_wrong_uprn = @organisation.sales_logs |
|
|
|
|
.imported |
|
|
|
|
.filter_by_year(2023) |
|
|
|
|
.where.not(uprn: nil) |
|
|
|
|
.where("uprn = purchid or town_or_city = 'Bristol'") |
|
|
|
|
|
|
|
|
|
logs_with_wrong_uprn = if JSON.parse(ENV["SKIP_UPRN_ISSUE_ORG_IDS"]).include?(@organisation.id) |
|
|
|
|
[] |
|
|
|
|
else |
|
|
|
|
@organisation.sales_logs |
|
|
|
|
.imported |
|
|
|
|
.filter_by_year(2023) |
|
|
|
|
.where.not(uprn: nil) |
|
|
|
|
.where("uprn = purchid or town_or_city = 'Bristol'") |
|
|
|
|
end |
|
|
|
|
return if logs_with_missing_addresses.empty? && logs_with_missing_town_or_city.empty? && logs_with_wrong_uprn.empty? |
|
|
|
|
|
|
|
|
|
CSV.generate(headers: true) do |csv| |
|
|
|
|
|