Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
class BulkUploadErrorRowComponent < ViewComponent::Base
|
|
|
|
attr_reader :bulk_upload_errors
|
|
|
|
|
|
|
|
def initialize(bulk_upload_errors:)
|
|
|
|
@bulk_upload_errors = sorted_errors(bulk_upload_errors)
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def row
|
|
|
|
bulk_upload_errors.first.row
|
|
|
|
end
|
|
|
|
|
|
|
|
def tenant_code
|
|
|
|
bulk_upload_errors.first.tenant_code
|
|
|
|
end
|
|
|
|
|
|
|
|
def purchaser_code
|
|
|
|
bulk_upload_errors.first.purchaser_code
|
|
|
|
end
|
|
|
|
|
|
|
|
def property_ref
|
|
|
|
bulk_upload_errors.first.property_ref
|
|
|
|
end
|
|
|
|
|
|
|
|
def question_for_field(field)
|
|
|
|
case bulk_upload.log_type
|
|
|
|
when "lettings"
|
|
|
|
BulkUpload::Lettings::Validator.question_for_field(field.to_sym)
|
|
|
|
when "sales"
|
|
|
|
BulkUpload::Sales::Validator.question_for_field(field.to_sym)
|
|
|
|
else
|
|
|
|
"Unknown question"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def bulk_upload
|
|
|
|
bulk_upload_errors.first.bulk_upload
|
|
|
|
end
|
|
|
|
|
|
|
|
def lettings?
|
|
|
|
bulk_upload.log_type == "lettings"
|
|
|
|
end
|
|
|
|
|
|
|
|
def sales?
|
|
|
|
bulk_upload.log_type == "sales"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def sorted_errors(errors)
|
|
|
|
errors.sort_by { |e| e.cell.rjust(3, "0") }
|
|
|
|
end
|
|
|
|
end
|