* Add start date validations for merging orgs
* Add errors for merged orgs
* tests
* don't run validations unless the date exists
* Adjust the dates in validations
year_not_two_digits:Tenancy start year must be 2 digits
year_not_two_digits:Tenancy start year must be 2 digits
ten_years_after_void_date:"Enter a tenancy start date that is no more than 10 years after the void date"
ten_years_after_void_date:"Enter a tenancy start date that is no more than 10 years after the void date"
ten_years_after_mrc_date:"Enter a tenancy start date that is no more than 10 years after the major repairs completion date"
ten_years_after_mrc_date:"Enter a tenancy start date that is no more than 10 years after the major repairs completion date"
invalid_merged_organisations_start_date:
same_organisation:"Enter a date when the owning and managing organisation was active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}."
same_merge:"Enter a date when the owning and managing organisations were active. %{owning_organisation} and %{managing_organisation} became inactive on %{owning_organisation_merge_date} and were replaced by %{owning_absorbing_organisation}."
owning_organisation:"Enter a date when the owning organisation was active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}."
managing_organisation:"Enter a date when the managing organisation was active. %{managing_organisation} became inactive on %{managing_organisation_merge_date} and was replaced by %{managing_absorbing_organisation}."
different_merge:"Enter a date when the owning and managing organisations were active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}. %{managing_organisation} became inactive on %{managing_organisation_merge_date} and was replaced by %{managing_absorbing_organisation}."
invalid_absorbing_organisations_start_date:
same_organisation:"Enter a date when the owning and managing organisation was active. %{owning_organisation} became active on %{owning_organisation_available_from}."
owning_organisation:"Enter a date when the owning organisation was active. %{owning_organisation} became active on %{owning_organisation_available_from}."
managing_organisation:"Enter a date when the managing organisation was active. %{managing_organisation} became active on %{managing_organisation_available_from}."
different_organisations:"Enter a date when the owning and managing organisations were active. %{owning_organisation} became active on %{owning_organisation_active_from}, and %{managing_organisation} became active on %{managing_organisation_active_from}."
location:
location:
deactivated:
deactivated:
@ -273,9 +284,13 @@ en:
owning_organisation:
owning_organisation:
invalid:"Please select the owning organisation or managing organisation that you belong to"
invalid:"Please select the owning organisation or managing organisation that you belong to"
data_sharing_agreement_not_signed:"The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation."
data_sharing_agreement_not_signed:"The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation."
inactive_merged_organisation:"The owning organisation must be active on the tenancy start date. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}."
inactive_absorbing_organisation:"The owning organisation must be active on the tenancy start date. %{owning_organisation} became active on %{owning_organisation_available_from}."
managing_organisation:
managing_organisation:
invalid:"Please select the owning organisation or managing organisation that you belong to"
invalid:"Please select the owning organisation or managing organisation that you belong to"
data_sharing_agreement_not_signed:"The organisation must accept the Data Sharing Agreement before it can be selected as the managing organisation."
data_sharing_agreement_not_signed:"The organisation must accept the Data Sharing Agreement before it can be selected as the managing organisation."
inactive_merged_organisation:"The managing organisation must be active on the tenancy start date. %{managing_organisation} became inactive on %{managing_organisation_merge_date} and was replaced by %{managing_absorbing_organisation}."
inactive_absorbing_organisation:"The managing organisation must be active on the tenancy start date. %{managing_organisation} became active on %{managing_organisation_available_from}."
created_by:
created_by:
invalid:"Please select the owning organisation or managing organisation that you belong to"
invalid:"Please select the owning organisation or managing organisation that you belong to"
expect(record.errors["startdate"]).toinclude(match"Enter a date when the owning organisation was active. Merged org became inactive on 2 February 2023 and was replaced by Absorbing org.")
end
it"allows startate before organisation has been merged"do
expect(record.errors["startdate"]).toinclude(match"Enter a date when the owning organisation was active. Absorbing org became active on 1 February 2023.")
end
it"allows startate after absorbing organisation has been created"do
expect(record.errors["startdate"]).toinclude(match"Enter a date when the managing organisation was active. Merged org became inactive on 2 February 2023 and was replaced by Absorbing org.")
end
it"allows startate before organisation has been merged"do
expect(record.errors["startdate"]).toinclude(match"Enter a date when the managing organisation was active. Absorbing org became active on 1 February 2023.")
end
it"allows startate after absorbing organisation has been created"do
expect(record.errors["startdate"]).toinclude(match"Enter a date when the owning and managing organisation was active. Merged org became inactive on 2 February 2023 and was replaced by Absorbing org.")
end
it"allows startate before organisation has been merged"do
expect(record.errors["startdate"]).toinclude(match"Enter a date when the owning and managing organisation was active. Absorbing org became active on 1 February 2023.")
end
it"allows startate after absorbing organisation has been created"do
expect(record.errors["startdate"]).toinclude(match"Enter a date when the owning and managing organisations were active. Merged org 2 and Merged org became inactive on 2 February 2023 and were replaced by Absorbing org.")
end
it"allows startate before organisations have been merged"do
expect(record.errors["startdate"]).toinclude(match"Enter a date when the owning and managing organisations were active. Merged org 2 became inactive on 2 February 2023 and was replaced by Absorbing org 2. Merged org became inactive on 2 February 2023 and was replaced by Absorbing org.")
end
it"allows startate before organisations have been merged"do
expect(record.errors["startdate"]).toinclude(match"Enter a date when the owning and managing organisations were active. Absorbing org 2 became active on 1 February 2023, and Absorbing org became active on 1 February 2023.")
end
it"allows startate after absorbing organisation has been created"do
expect(record.errors["owning_organisation_id"]).toinclude(match"The owning organisation must be active on the tenancy start date. Merged org became inactive on 2 February 2023 and was replaced by Absorbing org.")
end
it"allows organisation before it has been merged"do
expect(record.errors["owning_organisation_id"]).toinclude(match"The owning organisation must be active on the tenancy start date. Absorbing org became active on 1 February 2023.")
end
it"allows absorbing organisation after it has been created"do
expect(record.errors["managing_organisation_id"]).toinclude(match"The managing organisation must be active on the tenancy start date. Merged org became inactive on 2 February 2023 and was replaced by Absorbing org.")
end
it"allows organisation before it has been merged"do
expect(record.errors["managing_organisation_id"]).toinclude(match"The managing organisation must be active on the tenancy start date. Absorbing org became active on 1 February 2023.")
end
it"allows absorbing organisation after it has been created"do