diff --git a/app/models/form/lettings/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb index 78039facf..1924317c9 100644 --- a/app/models/form/lettings/questions/location_id.rb +++ b/app/models/form/lettings/questions/location_id.rb @@ -27,7 +27,7 @@ class Form::Lettings::Questions::LocationId < ::Form::Question def displayed_answer_options(lettings_log, _user = nil) return {} unless lettings_log.scheme - scheme_location_ids = lettings_log.scheme.locations.reject { |location| location.status_at(lettings_log.startdate || Time.zone.today) == :incomplete }.pluck(:id) + scheme_location_ids = lettings_log.scheme.locations.reject { |location| location.status == :incomplete }.pluck(:id) answer_options.select { |k, _v| scheme_location_ids.include?(k.to_i) } end diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 42dc65607..fa5d00320 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -166,9 +166,7 @@ class Scheme < ApplicationRecord end def appended_text - active_count = locations.count { |location| %i[active deactivating_soon].include?(location.status) } - inactive_count = locations.count { |location| !%i[active deactivating_soon].include?(location.status) } - "#{active_count} active #{'location'.pluralize(active_count)}, #{inactive_count} inactive #{'location'.pluralize(inactive_count)}" + "#{completed_locations_count} completed #{'location'.pluralize(completed_locations_count)}, #{incomplete_locations_count} incomplete #{'location'.pluralize(incomplete_locations_count)}" end def hint @@ -266,4 +264,8 @@ private def confirmed_locations_count locations.confirmed.size end + + def incomplete_locations_count + locations.count { |location| location.status == :incomplete } + end end diff --git a/app/models/validations/setup_validations.rb b/app/models/validations/setup_validations.rb index 0865ebae6..1c8788dee 100644 --- a/app/models/validations/setup_validations.rb +++ b/app/models/validations/setup_validations.rb @@ -20,6 +20,14 @@ module Validations::SetupValidations location_during_startdate_validation(record, :location_id) end + def validate_scheme_has_completed_locations_validation(record) + return unless record.scheme + + unless record.scheme.has_completed_locations? + record.errors.add :scheme_id, I18n.t("validations.scheme.no_completed_locations") + end + end + def validate_scheme(record) location_during_startdate_validation(record, :scheme_id) scheme_during_startdate_validation(record, :scheme_id) diff --git a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file.html.erb b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file.html.erb index e48a190f9..eb5c95adc 100644 --- a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file.html.erb +++ b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file.html.erb @@ -15,7 +15,7 @@
  • Download the <%= govuk_link_to "bulk lettings template", @form.template_path %>
  • Export the data from your housing management system, matching the template. <%= govuk_link_to "Find out more about exporting your data", guidance_bulk_upload_lettings_logs_path %>
  • If you cannot export it in this format, you may have to input it manually
  • -
  • You can not have a file with both general needs logs and supported housing logs. These must be in separate files
  • +
  • You cannot have a file with both general needs logs and supported housing logs. These must be in separate files
  • Check your data

    diff --git a/config/locales/en.yml b/config/locales/en.yml index 053929f46..c09eb9a3a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -446,6 +446,7 @@ en: during_deactivated_period: "The scheme is already deactivated during this date, please enter a different date" owning_organisation: does_not_own_stock: "Enter an organisation that owns housing stock" + no_completed_locations: "This scheme cannot be chosen as it has 0 completed locations" location: postcode_blank: "Enter a postcode"