From 442e9e2767949b69225a21dd7e324194a2a13e3f Mon Sep 17 00:00:00 2001 From: Dave G Date: Mon, 24 Jun 2024 08:44:26 -0400 Subject: [PATCH 1/5] Add Match Route Eleven as Clone of Provider Only Route --- app/controllers/concerns/decisions.rb | 2 +- app/mailers/notifications_mailer.rb | 1 + app/mailers/route_eleven_mailer_methods.rb | 60 +++++++ app/models/client_opportunity_match.rb | 3 + app/models/concerns/route_eleven_decisions.rb | 15 ++ ...rm_hsa_accepts_client_decline_dnd_staff.rb | 111 +++++++++++++ .../eleven/eleven_hsa_accepts_client.rb | 151 +++++++++++++++++ .../eleven/eleven_hsa_acknowledges_receipt.rb | 153 ++++++++++++++++++ app/models/match_routes/base.rb | 1 + app/models/match_routes/eleven.rb | 75 +++++++++ .../eleven/confirm_hsa_decline_dnd_staff.rb | 29 ++++ .../eleven/hsa_accepts_client.rb | 41 +++++ .../hsa_accepts_client_ssp_notification.rb | 33 ++++ .../eleven/hsa_decision_client.rb | 27 ++++ .../notifications/eleven/hsa_decision_hsp.rb | 27 ++++ .../eleven/hsa_decision_shelter_agency.rb | 29 ++++ .../notifications/eleven/hsa_decision_ssp.rb | 27 ++++ .../eleven/match_initiation_for_hsa.rb | 41 +++++ .../match_initiation_for_shelter_agency.rb | 33 ++++ .../eleven/match_initiation_for_ssp.rb | 34 ++++ app/models/translation.rb | 9 ++ ..._hsa_accepts_client_decline_dnd_staff.haml | 24 +++ .../_eleven_hsa_accepts_client.haml | 60 +++++++ .../_eleven_hsa_acknowledges_receipt.haml | 34 ++++ ...en_confirm_hsa_decline_dnd_staff.text.haml | 19 +++ .../eleven_hsa_accepts_client.text.haml | 15 ++ ..._accepts_client_ssp_notification.text.haml | 15 ++ .../eleven_hsa_decision_client.text.haml | 16 ++ .../eleven_hsa_decision_hsp.text.haml | 19 +++ ...even_hsa_decision_shelter_agency.text.haml | 19 +++ .../eleven_hsa_decision_ssp.text.haml | 19 +++ .../eleven_match_initiation_for_hsa.text.haml | 19 +++ ...ch_initiation_for_shelter_agency.text.haml | 17 ++ .../eleven_match_initiation_for_ssp.text.haml | 17 ++ .../hsa_decision_client.text.haml | 2 +- .../hsa_decision_hsp.text.haml | 2 +- .../hsa_decision_shelter_agency.text.haml | 2 +- .../hsa_decision_ssp.text.haml | 2 +- ...1125508_match_route_eleven_translations.rb | 25 +++ 39 files changed, 1223 insertions(+), 5 deletions(-) create mode 100644 app/mailers/route_eleven_mailer_methods.rb create mode 100644 app/models/concerns/route_eleven_decisions.rb create mode 100644 app/models/match_decisions/eleven/eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb create mode 100644 app/models/match_decisions/eleven/eleven_hsa_accepts_client.rb create mode 100644 app/models/match_decisions/eleven/eleven_hsa_acknowledges_receipt.rb create mode 100644 app/models/match_routes/eleven.rb create mode 100644 app/models/notifications/eleven/confirm_hsa_decline_dnd_staff.rb create mode 100644 app/models/notifications/eleven/hsa_accepts_client.rb create mode 100644 app/models/notifications/eleven/hsa_accepts_client_ssp_notification.rb create mode 100644 app/models/notifications/eleven/hsa_decision_client.rb create mode 100644 app/models/notifications/eleven/hsa_decision_hsp.rb create mode 100644 app/models/notifications/eleven/hsa_decision_shelter_agency.rb create mode 100644 app/models/notifications/eleven/hsa_decision_ssp.rb create mode 100644 app/models/notifications/eleven/match_initiation_for_hsa.rb create mode 100644 app/models/notifications/eleven/match_initiation_for_shelter_agency.rb create mode 100644 app/models/notifications/eleven/match_initiation_for_ssp.rb create mode 100644 app/views/match_decisions/_eleven_confirm_hsa_accepts_client_decline_dnd_staff.haml create mode 100644 app/views/match_decisions/_eleven_hsa_accepts_client.haml create mode 100644 app/views/match_decisions/_eleven_hsa_acknowledges_receipt.haml create mode 100644 app/views/notifications_mailer/eleven_confirm_hsa_decline_dnd_staff.text.haml create mode 100644 app/views/notifications_mailer/eleven_hsa_accepts_client.text.haml create mode 100644 app/views/notifications_mailer/eleven_hsa_accepts_client_ssp_notification.text.haml create mode 100644 app/views/notifications_mailer/eleven_hsa_decision_client.text.haml create mode 100644 app/views/notifications_mailer/eleven_hsa_decision_hsp.text.haml create mode 100644 app/views/notifications_mailer/eleven_hsa_decision_shelter_agency.text.haml create mode 100644 app/views/notifications_mailer/eleven_hsa_decision_ssp.text.haml create mode 100644 app/views/notifications_mailer/eleven_match_initiation_for_hsa.text.haml create mode 100644 app/views/notifications_mailer/eleven_match_initiation_for_shelter_agency.text.haml create mode 100644 app/views/notifications_mailer/eleven_match_initiation_for_ssp.text.haml create mode 100644 db/migrate/20240621125508_match_route_eleven_translations.rb diff --git a/app/controllers/concerns/decisions.rb b/app/controllers/concerns/decisions.rb index 3d649cc80..4f03a4cff 100644 --- a/app/controllers/concerns/decisions.rb +++ b/app/controllers/concerns/decisions.rb @@ -14,7 +14,7 @@ def can_recreate_this_decision? helper_method :can_recreate_this_decision? def hsa_can_resend_this_step? - ["MatchDecisions::ProviderOnly::HsaAcceptsClient"].include?(@decision&.type) && + ['MatchDecisions::ProviderOnly::HsaAcceptsClient', 'MatchDecisions::Eleven::ElevenHsaAcceptsClient'].include?(@decision&.type) && @match.contacts_editable_by_hsa && current_contact.in?(@match.housing_subsidy_admin_contacts) end diff --git a/app/mailers/notifications_mailer.rb b/app/mailers/notifications_mailer.rb index 213aa232f..f15cb9eff 100644 --- a/app/mailers/notifications_mailer.rb +++ b/app/mailers/notifications_mailer.rb @@ -19,6 +19,7 @@ class NotificationsMailer < DatabaseMailer include RouteEightMailerMethods include RouteNineMailerMethods include RouteTenMailerMethods + include RouteElevenMailerMethods def match_recommendation_dnd_staff(notification = nil) setup_instance_variables(notification) diff --git a/app/mailers/route_eleven_mailer_methods.rb b/app/mailers/route_eleven_mailer_methods.rb new file mode 100644 index 000000000..c828901ff --- /dev/null +++ b/app/mailers/route_eleven_mailer_methods.rb @@ -0,0 +1,60 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module RouteElevenMailerMethods + extend ActiveSupport::Concern + included do + def eleven_confirm_hsa_decline_dnd_staff(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: "Match Declined by #{Translation.translate('HSA Eleven')} - Requires Your Action") + end + + def eleven_hsa_accepts_client_ssp_notification(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: "Match accepted by #{Translation.translate('HSA Eleven')}") + end + + def eleven_hsa_accepts_client(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: 'Match ready for review - Requires Your Action') + end + + def eleven_hsa_decision_client(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: "Decision from #{Translation.translate('Housing Subsidy Administrator Eleven')}") + end + + def eleven_hsa_decision_hsp(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: "Decision from #{Translation.translate('Housing Subsidy Administrator Eleven')}") + end + + def eleven_hsa_decision_shelter_agency(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: "Decision from #{Translation.translate('Housing Subsidy Administrator Eleven')}") + end + + def eleven_hsa_decision_ssp(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: "Decision from #{Translation.translate('Housing Subsidy Administrator Eleven')}") + end + + def eleven_match_initiation_for_hsa(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: 'New Housing Recommendation - Requires Your Action') + end + + def eleven_match_initiation_for_shelter_agency(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: 'New Housing Recommendation') + end + + def eleven_match_initiation_for_ssp(notification = nil) + setup_instance_variables(notification) + mail(to: @contact.email, subject: 'New Housing Recommendation') + end + end +end diff --git a/app/models/client_opportunity_match.rb b/app/models/client_opportunity_match.rb index 70b915c21..c8a4a8ef5 100644 --- a/app/models/client_opportunity_match.rb +++ b/app/models/client_opportunity_match.rb @@ -83,6 +83,9 @@ def self.model_name # Match Route 10 include RouteTenDecisions + # Match Route 11 + include RouteElevenDecisions + has_many :referral_events, class_name: 'Warehouse::ReferralEvent', foreign_key: 'client_opportunity_match_id' has_one :active_referral_event, -> { where(referral_result: nil) }, class_name: 'Warehouse::ReferralEvent', foreign_key: 'client_opportunity_match_id' diff --git a/app/models/concerns/route_eleven_decisions.rb b/app/models/concerns/route_eleven_decisions.rb new file mode 100644 index 000000000..5490d045c --- /dev/null +++ b/app/models/concerns/route_eleven_decisions.rb @@ -0,0 +1,15 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module RouteElevenDecisions + extend ActiveSupport::Concern + + included do + has_decision :eleven_hsa_acknowledges_receipt, decision_class_name: 'MatchDecisions::Eleven::ElevenHsaAcknowledgesReceipt', notification_class_name: 'Notifications::Eleven::MatchInitiationForHsa' + has_decision :eleven_hsa_accepts_client, decision_class_name: 'MatchDecisions::Eleven::ElevenHsaAcceptsClient', notification_class_name: 'Notifications::Eleven::HsaAcceptsClient' + has_decision :eleven_confirm_hsa_accepts_client_decline_dnd_staff, decision_class_name: 'MatchDecisions::Eleven::ElevenConfirmHsaAcceptsClientDeclineDndStaff', notification_class_name: 'Notifications::ConfirmHousingSubsidyAdminDeclineDndStaff' + end +end diff --git a/app/models/match_decisions/eleven/eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb b/app/models/match_decisions/eleven/eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb new file mode 100644 index 000000000..e10a4ab80 --- /dev/null +++ b/app/models/match_decisions/eleven/eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb @@ -0,0 +1,111 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module MatchDecisions::Eleven + class ElevenConfirmHsaAcceptsClientDeclineDndStaff < ::MatchDecisions::Base + def to_partial_path + 'match_decisions/eleven_confirm_hsa_accepts_client_decline_dnd_staff' + end + + def statuses + { + pending: 'Pending', + decline_overridden: 'Decline Overridden', + decline_overridden_returned: 'Decline Overridden, Returned', + decline_confirmed: 'Decline Confirmed', + canceled: 'Canceled', + } + end + + def label + label_for_status status + end + + def label_for_status status + case status.to_sym + when :pending then "#{Translation.translate('CoC Eleven')} to confirm #{Translation.translate('Housing Subsidy Administrator Eleven')} decline" + when :decline_overridden then "#{Translation.translate('Housing Subsidy Administrator Eleven')} decline overridden by #{Translation.translate('CoC Eleven')}. Match successful" + when :decline_overridden_returned then "#{Translation.translate('Housing Subsidy Administrator Eleven')} decline overridden by #{Translation.translate('CoC Eleven')}. Match returned to #{Translation.translate('Housing Subsidy Administrator Eleven')}" + when :decline_confirmed then "Match rejected by #{Translation.translate('CoC Eleven')}" + when :canceled then canceled_status_label + end + end + + def step_name + "#{Translation.translate('CoC Eleven')} Reviews Match Declined by #{Translation.translate('HSA Eleven')}" + end + + def actor_type + Translation.translate('CoC Eleven') + end + + def contact_actor_type + nil + end + + def editable? + super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/ + end + + def initialize_decision! send_notifications: true + super(send_notifications: send_notifications) + update status: 'pending' + send_notifications_for_step if send_notifications + end + + def notifications_for_this_step + @notifications_for_this_step ||= [].tap do |m| + m << Notifications::Eleven::ConfirmHsaDeclineDndStaff + m << Notifications::Eleven::HsaDecisionClient + m << Notifications::Eleven::HsaDecisionSsp + m << Notifications::Eleven::HsaDecisionHsp + m << Notifications::Eleven::HsaDecisionShelterAgency + end + end + + def accessible_by? contact + contact.user_can_reject_matches? || contact.user_can_approve_matches? + end + + def show_client_match_attributes? + true + end + + class StatusCallbacks < StatusCallbacks + def pending + end + + def decline_overridden + match.succeeded!(user: user) + end + + def decline_overridden_returned + # Re-initialize the previous decision + match.eleven_hsa_accepts_client_decision.initialize_decision! + @decision.uninitialize_decision!(send_notifications: false) + end + + def decline_confirmed + match.rejected! + # TODO maybe rerun the matching engine for that vacancy and client + end + + def canceled + Notifications::MatchCanceled.create_for_match! match + match.canceled! + end + end + private_constant :StatusCallbacks + end + + def step_cancel_reasons + [ + 'Vacancy should not have been entered', + 'Vacancy filled by other client', + 'Other', + ] + end +end diff --git a/app/models/match_decisions/eleven/eleven_hsa_accepts_client.rb b/app/models/match_decisions/eleven/eleven_hsa_accepts_client.rb new file mode 100644 index 000000000..a21db07e6 --- /dev/null +++ b/app/models/match_decisions/eleven/eleven_hsa_accepts_client.rb @@ -0,0 +1,151 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module MatchDecisions::Eleven + class ElevenHsaAcceptsClient < ::MatchDecisions::Base + def to_partial_path + 'match_decisions/eleven_hsa_accepts_client' + end + include MatchDecisions::AcceptsDeclineReason + + attr_accessor :building_id + attr_accessor :unit_id + + # validate :note_present_if_status_declined + + def label + label_for_status status + end + + def label_for_status status + case status.to_sym + when :pending, :expiration_update then "#{Translation.translate('Housing Subsidy Administrator Eleven')} reviewing match" + when :accepted then "Match accepted by #{Translation.translate('Housing Subsidy Administrator Eleven')}" + when :declined then "Match declined by #{Translation.translate('Housing Subsidy Administrator Eleven')}. Reason: #{decline_reason_name}" + when :canceled then canceled_status_label + when :back then backup_status_label + end + end + + # if we've overridden this decision, indicate that (this is sent to the client) + def status_label + if match.eleven_confirm_hsa_accepts_client_decline_dnd_staff_decision.status == 'decline_overridden' + 'Approved' + else + statuses[status && status.to_sym] + end + end + + def step_name + Translation.translate('Client Agrees to Match') + end + + def actor_type + Translation.translate('HSA Eleven') + end + + def contact_actor_type + :housing_subsidy_admin_contacts + end + + def statuses + { + pending: 'Pending', + expiration_update: 'Pending', + accepted: 'Accepted', + declined: 'Declined', + canceled: 'Canceled', + back: 'Pending', + } + end + + def expires? + true + end + + def editable? + super && saved_status !~ /accepted|declined/ + end + + def initialize_decision! send_notifications: true + super(send_notifications: send_notifications) + update status: 'pending' + send_notifications_for_step if send_notifications + end + + def notifications_for_this_step + @notifications_for_this_step ||= [].tap do |m| + m << Notifications::Eleven::HsaAcceptsClient + end + end + + def notify_contact_of_action_taken_on_behalf_of contact: # rubocop:disable Lint/UnusedMethodArgument + Notifications::OnBehalfOf.create_for_match! match, contact_actor_type + end + + def accessible_by? contact + contact.user_can_act_on_behalf_of_match_contacts? || + contact.in?(match.housing_subsidy_admin_contacts) + end + + def show_client_match_attributes? + true + end + + class StatusCallbacks < StatusCallbacks + def pending + end + + def accepted + Notifications::Eleven::HsaAcceptsClientSspNotification.create_for_match! match + match.succeeded!(user: user) + end + + def declined + match.eleven_confirm_hsa_accepts_client_decline_dnd_staff_decision.initialize_decision! + end + + def canceled + Notifications::MatchCanceled.create_for_match! match + match.canceled! + end + + def expiration_update + end + end + private_constant :StatusCallbacks + + def step_decline_reasons(_contact) + [ + 'Household could not be located', + 'Ineligible for Housing Program', + 'Client refused offer', + 'Health and Safety', + 'Other', + ] + end + + def step_cancel_reasons + [ + 'Vacancy should not have been entered', + 'Vacancy filled by other client', + 'Other', + ] + end + + def whitelist_params_for_update params + super.merge params.require(:decision).permit( + :building_id, + :unit_id, + :shelter_expiration, + ) + end + + private def note_present_if_status_declined + errors.add :note, 'Please note why the match is declined.' if note.blank? && status == 'declined' + end + end +end diff --git a/app/models/match_decisions/eleven/eleven_hsa_acknowledges_receipt.rb b/app/models/match_decisions/eleven/eleven_hsa_acknowledges_receipt.rb new file mode 100644 index 000000000..f7d6e89eb --- /dev/null +++ b/app/models/match_decisions/eleven/eleven_hsa_acknowledges_receipt.rb @@ -0,0 +1,153 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module MatchDecisions::Eleven + class ElevenHsaAcknowledgesReceipt < ::MatchDecisions::Base + def to_partial_path + 'match_decisions/eleven_hsa_acknowledges_receipt' + end + + validate :cant_accept_if_match_closed + validate :cant_accept_if_client_has_related_active_match + validate :cant_accept_if_opportunity_has_related_active_match + validate :ensure_required_contacts_present_on_accept + validate :validate_cancel_reason + + def label_for_status status + case status.to_sym + when :pending, :expiration_update then "New Match Awaiting Acknowledgment by #{Translation.translate('HSA Eleven')}" + when :acknowledged then "Match acknowledged by #{Translation.translate('HSA Eleven')}. In review" + when :canceled then canceled_status_label + end + end + + def started? + status&.to_sym == :acknowledged + end + + def step_name + "New Match for #{Translation.translate('HSA Eleven')}" + end + + def actor_type + Translation.translate('HSA Eleven') + end + + def contact_actor_type + nil + end + + def statuses + { + pending: 'Pending', + expiration_update: 'Pending', + acknowledged: 'Acknowledged', + declined: 'Declined', + canceled: 'Canceled', + destroy: 'Destroy', + } + end + + def expires? + true + end + + def editable? + super && saved_status !~ /acknowledged/ + end + + def initialize_decision! send_notifications: true + super(send_notifications: send_notifications) + update status: :pending + send_notifications_for_step if send_notifications + end + + def accessible_by? contact + contact.user_can_act_on_behalf_of_match_contacts? || + contact.in?(match.housing_subsidy_admin_contacts) + end + + def notifications_for_this_step + @notifications_for_this_step ||= [].tap do |m| + m << Notifications::Eleven::MatchInitiationForHsa + m << Notifications::Eleven::MatchInitiationForShelterAgency + m << Notifications::Eleven::MatchInitiationForSsp + end + end + + class StatusCallbacks < StatusCallbacks + def pending + end + + def acknowledged + @decision.next_step.initialize_decision! + return unless !match.client.non_hmis? && match.client.remote_id.present? && Warehouse::Base.enabled? + + Warehouse::Client.find_by(id: match.client.remote_id)&.queue_history_pdf_generation + end + + def canceled + Notifications::MatchCanceled.create_for_match! match + match.canceled! + end + + def expiration_update + end + end + private_constant :StatusCallbacks + + def step_cancel_reasons + [ + 'Vacancy should not have been entered', + 'Vacancy filled by other client', + 'Match expired', + 'Other', + ] + end + + def whitelist_params_for_update params + super.merge params.require(:decision).permit( + :shelter_expiration, + ) + end + + private def save_will_accept? + saved_status == 'pending' && status == 'acknowledged' + end + + def cant_accept_if_match_closed + return unless save_will_accept? && match.closed + + errors.add :status, 'This match has already been closed.' + end + + def cant_accept_if_client_has_related_active_match + return unless save_will_accept? && match.client_related_matches.active.on_route(match_route).exists? && ! match_route.allow_multiple_active_matches + + errors.add :status, 'There is already another active match for this client' + end + + def cant_accept_if_opportunity_has_related_active_match + return unless save_will_accept? && match.opportunity_related_matches.active.any? && ! match_route.allow_multiple_active_matches + + errors.add :status, 'There is already another active match for this opportunity' + end + + private def ensure_required_contacts_present_on_accept + missing_contacts = [] + missing_contacts << "a #{Translation.translate('CoC Eleven')} Staff Contact" if save_will_accept? && match.dnd_staff_contacts.none? + missing_contacts << "a #{Translation.translate('Housing Subsidy Administrator Eleven')} Contact" if save_will_accept? && match.housing_subsidy_admin_contacts.none? + + errors.add :match_contacts, "needs #{missing_contacts.to_sentence}" if missing_contacts.any? + end + + private def validate_cancel_reason + errors.add :administrative_cancel_reason_id, 'please indicate the reason for canceling' if status == 'canceled' && administrative_cancel_reason_id.blank? + + errors.add :administrative_cancel_reason_other_explanation, "must be filled in if choosing 'Other'" if status == 'canceled' && administrative_cancel_reason&.other? && administrative_cancel_reason_other_explanation.blank? + end + end +end diff --git a/app/models/match_routes/base.rb b/app/models/match_routes/base.rb index 91b3d0a61..10e853e56 100644 --- a/app/models/match_routes/base.rb +++ b/app/models/match_routes/base.rb @@ -40,6 +40,7 @@ def self.all_routes MatchRoutes::Eight, MatchRoutes::Nine, MatchRoutes::Ten, + MatchRoutes::Eleven, ] end diff --git a/app/models/match_routes/eleven.rb b/app/models/match_routes/eleven.rb new file mode 100644 index 000000000..f2a92df15 --- /dev/null +++ b/app/models/match_routes/eleven.rb @@ -0,0 +1,75 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module MatchRoutes + class Eleven < Base + def title + Translation.translate('Match Route Eleven') + end + + def self.available_sub_types_for_search + match_steps_for_reporting.keys + end + + def self.match_steps + { + 'MatchDecisions::Eleven::ElevenHsaAcknowledgesReceipt' => 1, + 'MatchDecisions::Eleven::ElevenHsaAcceptsClient' => 2, + } + end + + def self.match_steps_for_reporting + { + 'MatchDecisions::Eleven::ElevenHsaAcknowledgesReceipt' => 1, + 'MatchDecisions::Eleven::ElevenHsaAcceptsClient' => 2, + 'MatchDecisions::Eleven::ElevenConfirmHsaAcceptsClientDeclineDndStaff' => 2, + } + end + + def required_contact_types + [ + 'dnd_staff', + 'housing_subsidy_admin', + ] + end + + def initial_decision + :eleven_hsa_acknowledges_receipt_decision + end + + def success_decision + :eleven_hsa_accepts_client_decision + end + + def initial_contacts_for_match + :housing_subsidy_admin_contacts + end + + def status_declined?(match) + [ + match.eleven_hsa_accepts_client_decision&.status == 'declined' && + match.eleven_confirm_hsa_accepts_client_decline_dnd_staff_decision&.status != 'decline_overridden', + ].any? + end + + def contact_label_for(contact_type) + case contact_type + when :dnd_staff_contacts + Translation.translate('CoC Eleven') + when :housing_subsidy_admin_contacts + Translation.translate('Housing Subsidy Administrator Eleven') + when :shelter_agency_contacts + Translation.translate('Shelter Agency Eleven') + when :ssp_contacts + Translation.translate('Stabilization Service Provider Eleven') + when :hsp_contacts + Translation.translate('Housing Search Provider Eleven') + else + super(contact_type) + end + end + end +end diff --git a/app/models/notifications/eleven/confirm_hsa_decline_dnd_staff.rb b/app/models/notifications/eleven/confirm_hsa_decline_dnd_staff.rb new file mode 100644 index 000000000..ac335ed3d --- /dev/null +++ b/app/models/notifications/eleven/confirm_hsa_decline_dnd_staff.rb @@ -0,0 +1,29 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class ConfirmHsaDeclineDndStaff < ::Notifications::Base + def self.create_for_match! match + match.dnd_staff_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def decision + match.eleven_confirm_hsa_accepts_client_decline_dnd_staff_decision + end + + def event_label + "#{Translation.translate('CoC Eleven')} notified of #{Translation.translate('Housing Subsidy Administrator Eleven')} decline. Confirmation pending." + end + end +end diff --git a/app/models/notifications/eleven/hsa_accepts_client.rb b/app/models/notifications/eleven/hsa_accepts_client.rb new file mode 100644 index 000000000..7890ab486 --- /dev/null +++ b/app/models/notifications/eleven/hsa_accepts_client.rb @@ -0,0 +1,41 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class HsaAcceptsClient < ::Notifications::Base + def self.create_for_match! match + match.housing_subsidy_admin_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "#{Translation.translate('Housing Subsidy Administrator Eleven')} reviews match with client" + end + + def show_client_info? + true + end + + def allows_registration? + true + end + + def registration_role + :housing_subsidy_admin + end + + def contacts_editable? + true + end + end +end diff --git a/app/models/notifications/eleven/hsa_accepts_client_ssp_notification.rb b/app/models/notifications/eleven/hsa_accepts_client_ssp_notification.rb new file mode 100644 index 000000000..985dadc17 --- /dev/null +++ b/app/models/notifications/eleven/hsa_accepts_client_ssp_notification.rb @@ -0,0 +1,33 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class HsaAcceptsClientSspNotification < ::Notifications::Base + def self.create_for_match! match + match.ssp_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "#{Translation.translate('SSP Eleven')} notified of #{Translation.translate('Housing Subsidy Administrator Eleven')} acceptance" + end + + def show_client_info? + true + end + + def allows_registration? + false + end + end +end diff --git a/app/models/notifications/eleven/hsa_decision_client.rb b/app/models/notifications/eleven/hsa_decision_client.rb new file mode 100644 index 000000000..2923585b7 --- /dev/null +++ b/app/models/notifications/eleven/hsa_decision_client.rb @@ -0,0 +1,27 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class HsaDecisionClient < ::Notifications::Base + # Notification sent to a client of a decision made by the housing subsidy administrator + + def self.create_for_match! match + match.client_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "Client sent notice of #{Translation.translate('Housing Subsidy Administrator Eleven')}'s decision." + end + end +end diff --git a/app/models/notifications/eleven/hsa_decision_hsp.rb b/app/models/notifications/eleven/hsa_decision_hsp.rb new file mode 100644 index 000000000..68dcc92c0 --- /dev/null +++ b/app/models/notifications/eleven/hsa_decision_hsp.rb @@ -0,0 +1,27 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class HsaDecisionHsp < ::Notifications::Base + # Notification sent to a client of a decision made by the housing subsidy administrator + + def self.create_for_match! match + match.hsp_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "#{Translation.translate('Housing Search Provider Eleven')} sent notice of #{Translation.translate('Housing Subsidy Administrator Eleven')}'s decision." + end + end +end diff --git a/app/models/notifications/eleven/hsa_decision_shelter_agency.rb b/app/models/notifications/eleven/hsa_decision_shelter_agency.rb new file mode 100644 index 000000000..d2f2cc073 --- /dev/null +++ b/app/models/notifications/eleven/hsa_decision_shelter_agency.rb @@ -0,0 +1,29 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class HsaDecisionShelterAgency < ::Notifications::Base + # Notification sent to DND staff of an approval decision made by the housing subsidy administrator + + # rejections are handled in a separate notification with a link to the opportunity to override. + + def self.create_for_match! match + match.shelter_agency_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "#{Translation.translate('Shelter Agency Eleven')} sent notice of #{Translation.translate('Housing Subsidy Administrator Eleven')}'s decision." + end + end +end diff --git a/app/models/notifications/eleven/hsa_decision_ssp.rb b/app/models/notifications/eleven/hsa_decision_ssp.rb new file mode 100644 index 000000000..01bdf9d54 --- /dev/null +++ b/app/models/notifications/eleven/hsa_decision_ssp.rb @@ -0,0 +1,27 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class HsaDecisionSsp < ::Notifications::Base + # Notification sent to a client of a decision made by the housing subsidy administrator + + def self.create_for_match! match + match.ssp_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "#{Translation.translate('Stabilization Services Provider Eleven')} sent notice of #{Translation.translate('Housing Subsidy Administrator Eleven')}'s decision." + end + end +end diff --git a/app/models/notifications/eleven/match_initiation_for_hsa.rb b/app/models/notifications/eleven/match_initiation_for_hsa.rb new file mode 100644 index 000000000..c0c784159 --- /dev/null +++ b/app/models/notifications/eleven/match_initiation_for_hsa.rb @@ -0,0 +1,41 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class MatchInitiationForHsa < ::Notifications::Base + def self.create_for_match! match + match.housing_subsidy_admin_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "#{Translation.translate('Housing Subsidy Administrator Eleven')} notified of match detail" + end + + def show_client_info? + true + end + + def allows_registration? + true + end + + def registration_role + :housing_subsidy_admin + end + + def contacts_editable? + true + end + end +end diff --git a/app/models/notifications/eleven/match_initiation_for_shelter_agency.rb b/app/models/notifications/eleven/match_initiation_for_shelter_agency.rb new file mode 100644 index 000000000..052f686fb --- /dev/null +++ b/app/models/notifications/eleven/match_initiation_for_shelter_agency.rb @@ -0,0 +1,33 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class MatchInitiationForShelterAgency < ::Notifications::Base + def self.create_for_match! match + match.shelter_agency_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "#{Translation.translate('Shelter Agency Eleven')} notified of match detail" + end + + def show_client_info? + true + end + + def allows_registration? + false + end + end +end diff --git a/app/models/notifications/eleven/match_initiation_for_ssp.rb b/app/models/notifications/eleven/match_initiation_for_ssp.rb new file mode 100644 index 000000000..76d80d4a2 --- /dev/null +++ b/app/models/notifications/eleven/match_initiation_for_ssp.rb @@ -0,0 +1,34 @@ +### +# Copyright 2016 - 2024 Green River Data Analysis, LLC +# +# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md +### + +module Notifications::Eleven + class MatchInitiationForSsp < ::Notifications::Base + def self.create_for_match! match + match.ssp_contacts.each do |contact| + create! match: match, recipient: contact + end + end + + def notification_type + # prefix used for finding relevant information in other objects + # e.g. mailer, match decisions + "eleven_#{self.class.to_s.demodulize.underscore}" + end + + def event_label + "#{Translation.translate('SSP Eleven')} notified of match detail" + end + + def show_client_info? + true + end + + def allows_registration? + false + end + + end +end diff --git a/app/models/translation.rb b/app/models/translation.rb index 7e7dc797d..a23b8acb7 100644 --- a/app/models/translation.rb +++ b/app/models/translation.rb @@ -90,6 +90,7 @@ def self.known_translations 'Client Screening', 'Client sent notice of criminal background hearing date.', 'CoC Six', + 'CoC Eleven', 'Confirm Match Success', 'Confirm Match Success Six', 'Criminal Background Hearing', @@ -138,6 +139,7 @@ def self.known_translations 'Housing Authority Eligible', 'Housing Search Provider', 'Housing Search Provider Eight', + 'Housing Search Provider Eleven', 'Housing Search Provider Nine', 'Housing Search Providers', 'Housing Search Worker', @@ -145,12 +147,14 @@ def self.known_translations 'Housing Subsidy Administrator', 'Housing Subsidy Administrator CORI Hearing', 'Housing Subsidy Administrator Eight', + 'Housing Subsidy Administrator Eleven', 'Housing Subsidy Administrator Nine', 'Housing Subsidy Administrator Six', 'Housing Subsidy Administrators', 'Housing Subsidy Administrator status update', 'HSA', 'HSA Eight', + 'HSA Eleven', 'HSA Complete Match', 'HSA Complete Match Six', 'HSA Nine', @@ -174,6 +178,7 @@ def self.known_translations 'Life-Time Sex Offender', 'Limited CAS Release', 'Match Route Eight', + 'Match Route Eleven', 'Match Route Five', 'Match Route Four', 'Match Route Nine', @@ -231,16 +236,20 @@ def self.known_translations 'Shelter Agency Contact', 'Shelter Agency Contacts', 'Shelter Agency Eight', + 'Shelter Agency Eleven', 'Shelter Agency Nine', 'Shelter Agency Six', 'shelter case manager', 'Should this tag be added to anyone with an assessment score?', 'SSP', + 'SSP Eleven', 'Stabilization Service Provider', 'Stabilization Service Provider Eight', + 'Stabilization Service Provider Eleven', 'Stabilization Service Provider Nine', 'Stabilization Service Providers', 'Stabilization Services Provider', + 'Stabilization Service Providers Eleven', 'Staff Decline', 'Strengths', 'Submit Client Application', diff --git a/app/views/match_decisions/_eleven_confirm_hsa_accepts_client_decline_dnd_staff.haml b/app/views/match_decisions/_eleven_confirm_hsa_accepts_client_decline_dnd_staff.haml new file mode 100644 index 000000000..052f1ef15 --- /dev/null +++ b/app/views/match_decisions/_eleven_confirm_hsa_accepts_client_decline_dnd_staff.haml @@ -0,0 +1,24 @@ +.match-decision.c-card.c-card--flush.card--block + .c-card__content + = simple_form_for @decision, url: access_context.match_decision_path(@match, @decision) do |form| + .o-pre-choose + .form-inputs + .row + .col-md-6 + = form.input :note, as: :text, input_html: {rows: 4, disabled: (!@decision.editable?)} + .o-choose.o-choose--flush + - if can_reject_matches? + .o-choose__choice + %header + .o-choose__title + .c-choice-icon.c-choice-icon--park + %h3 Park Client + .o-choose__content + = render 'match_decisions/park_client', form: form + .o-choose__choice{ class: ('o-choose__choice--100' unless can_reject_matches?)} + %header + .o-choose__title + .c-choice-icon.c-choice-icon--reject + %h3 Review Decline + .o-choose__content + = render 'match_decisions/decline_overrides', form: form diff --git a/app/views/match_decisions/_eleven_hsa_accepts_client.haml b/app/views/match_decisions/_eleven_hsa_accepts_client.haml new file mode 100644 index 000000000..21f90f078 --- /dev/null +++ b/app/views/match_decisions/_eleven_hsa_accepts_client.haml @@ -0,0 +1,60 @@ +.match-decision.c-card.c-card--flush.card--block + .c-card__content + = simple_form_for @decision, url: access_context.match_decision_path(@match, @decision) do |form| + = render 'match_decisions/shelter_agency_expiration', form: form + - if ! @match.shelter_expiration? || @match.shelter_expiration >= Date.current || can_reject_matches? + .o-pre-choose + %p After contacting the client and obtaining client consent to proceed and all necessary paperwork submit this form to indicate acceptance of the match for all parties. + = form.input :note, as: :text, input_html: {rows: 4, disabled: (!@decision.editable?)} + .o-choose.o-choose--flush + .o-choose__choice + %header + .o-choose__title + .c-choice-icon.c-choice-icon--confirm.mr-4 + %h3 Accept Match + .o-choose__content + - if has_unit? + %p + Please confirm the client's building and unit. + .form-inputs + .building-and-unit + = form.input :building_id, collection: Building.all, selected: default_building_id , label: 'Building', disabled: !@decision.editable?, input_html: {class: 'building', notification_id: notification_id} + = form.input :unit_id, collection: candidate_units, selected: default_unit_id, label: 'Unit', disabled: !@decision.editable?, + input_html: {class: 'unit', data: {dependent: true, url: '/buildings/:id/available_move_in_units.json', 'value-method' => :id, 'label-method' => :name, default_parent_id: default_building_id, default_value: default_unit_id, default_label: default_unit_name}} + %p + %i.icon-info + If accepted, all involved parties will be notified. + + = form.submit 'Accept Match', class: 'btn btn-success jAccept', data: {submit_param_name: 'decision[status]', submit_param_value: 'accepted'}, disabled: (!@decision.editable?) + + = render 'match_decisions/hsa_decline_and_cancel_backup_actions', form: form, action_message: 'If the match is declined, the DND will be informed of the decision.', include_other: true + += content_for :page_js do + :javascript + $('select').select2(); + $('.building-and-unit').on('change', '.building', function() { + var parent = this.id; + var id = this.value; + var notification_id = this.getAttribute('notification_id'); + var prefix = ''; + if(notification_id !== null) { + prefix = '/notifications/' + notification_id + '/'; + } + var $child = $('.unit'); + var value_method = $child.data('value-method'); + var label_method = $child.data('label-method'); + var url = prefix + $child.data('url').replace(':id', id); + $.get(url, function(data) { + // remove previous options + $child.children().remove(); + $.each(data, function(k,v){ + $child.append($(''); + // restore the original value if still available + $child.val($child.data('default-value')); + } + }, 'json'); + }); diff --git a/app/views/match_decisions/_eleven_hsa_acknowledges_receipt.haml b/app/views/match_decisions/_eleven_hsa_acknowledges_receipt.haml new file mode 100644 index 000000000..00c1046f3 --- /dev/null +++ b/app/views/match_decisions/_eleven_hsa_acknowledges_receipt.haml @@ -0,0 +1,34 @@ +.match-decision.c-card.c-card--flush.card--block + .c-card__content + = simple_form_for @decision, url: access_context.match_decision_path(@match, @decision) do |form| + = render 'match_decisions/shelter_agency_expiration', form: form + - if ! @match.shelter_expiration? || @match.shelter_expiration >= Date.current || can_reject_matches? + .o-choose.o-choose--flush + .o-choose__choice + %header + .o-choose__title + .c-choice-icon.c-choice-icon--confirm.mr-4 + %h3 Acknowledge Match + .o-choose__content + - if @decision.status.to_s.in?(['pending', 'expiration_update']) + %div{data: {acknowledge_href: access_context.match_decision_acknowledgment_path(@match, @decision)}} + = render 'match_decisions/continue_button', text: 'Acknowledge Receipt of Match Details', icon: 'checkmark', button_attributes: { class: 'btn btn-success', data: {submit_param_name: 'decision[status]', submit_param_value: 'acknowledged'}, disabled: !(@decision.editable?) } + - if can_reject_matches? + .o-choose__choice + %header.jMatchHeader + %ul.o-choose__nav.nav.jMatchActionNav + = render 'match_decisions/cancel_tab', active_tab: 'active' + = render 'match_decisions/park_tab' + = render 'match_decisions/destroy_tab' + .o-choose__content + .tab-content + - cancel_data = {submit_param_name: 'decision[status]', submit_param_value: 'canceled'} + = render 'match_decisions/cancel_tab_content', form: form, cancel_data: cancel_data, active_tab: 'active' + = render 'match_decisions/park_tab_content', form: form, cancel_data: cancel_data + = render 'match_decisions/destroy_tab_content', form: form + + = content_for :page_js do + :javascript + new App.Matches.ActionNav('.jMatchHeader') + + = render 'match_decisions/cancel_and_park_js' diff --git a/app/views/notifications_mailer/eleven_confirm_hsa_decline_dnd_staff.text.haml b/app/views/notifications_mailer/eleven_confirm_hsa_decline_dnd_staff.text.haml new file mode 100644 index 000000000..ebc55966c --- /dev/null +++ b/app/views/notifications_mailer/eleven_confirm_hsa_decline_dnd_staff.text.haml @@ -0,0 +1,19 @@ +Hello #{@contact.full_name}, +\ += "A #{Translation.translate('Housing Subsidy Administrator Eleven')} has declined a housing match." +\ += "The match now requires #{Translation.translate('CoC Eleven')} confirmation to fully close it and make the voucher or unit and client available for future matching." +\ +Please review details here and take action: +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_hsa_accepts_client.text.haml b/app/views/notifications_mailer/eleven_hsa_accepts_client.text.haml new file mode 100644 index 000000000..5f07e0e77 --- /dev/null +++ b/app/views/notifications_mailer/eleven_hsa_accepts_client.text.haml @@ -0,0 +1,15 @@ +Hello #{@contact.full_name}, +\ +The following match is ready for your review: +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_hsa_accepts_client_ssp_notification.text.haml b/app/views/notifications_mailer/eleven_hsa_accepts_client_ssp_notification.text.haml new file mode 100644 index 000000000..8b1785449 --- /dev/null +++ b/app/views/notifications_mailer/eleven_hsa_accepts_client_ssp_notification.text.haml @@ -0,0 +1,15 @@ +Hello #{@contact.full_name}, +\ += "The following match has been accepted by the #{Translation.translate('HSA Eleven')}:" +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_hsa_decision_client.text.haml b/app/views/notifications_mailer/eleven_hsa_decision_client.text.haml new file mode 100644 index 000000000..a01ff0c6e --- /dev/null +++ b/app/views/notifications_mailer/eleven_hsa_decision_client.text.haml @@ -0,0 +1,16 @@ +Hello #{@contact.full_name}, +\ += "A #{Translation.translate('Housing Subsidy Administrator Eleven')} has made a decision on a housing opportunity for which the client below applied." +\ +Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_hsa_decision_hsp.text.haml b/app/views/notifications_mailer/eleven_hsa_decision_hsp.text.haml new file mode 100644 index 000000000..52f3b9c1d --- /dev/null +++ b/app/views/notifications_mailer/eleven_hsa_decision_hsp.text.haml @@ -0,0 +1,19 @@ +Hello #{@contact.full_name}, +\ += "A #{Translation.translate('Housing Subsidy Administrator Eleven')} has made a decision on a housing opportunity for which the client below applied." +\ +Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} +\ +View details here: +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_hsa_decision_shelter_agency.text.haml b/app/views/notifications_mailer/eleven_hsa_decision_shelter_agency.text.haml new file mode 100644 index 000000000..52f3b9c1d --- /dev/null +++ b/app/views/notifications_mailer/eleven_hsa_decision_shelter_agency.text.haml @@ -0,0 +1,19 @@ +Hello #{@contact.full_name}, +\ += "A #{Translation.translate('Housing Subsidy Administrator Eleven')} has made a decision on a housing opportunity for which the client below applied." +\ +Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} +\ +View details here: +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_hsa_decision_ssp.text.haml b/app/views/notifications_mailer/eleven_hsa_decision_ssp.text.haml new file mode 100644 index 000000000..52f3b9c1d --- /dev/null +++ b/app/views/notifications_mailer/eleven_hsa_decision_ssp.text.haml @@ -0,0 +1,19 @@ +Hello #{@contact.full_name}, +\ += "A #{Translation.translate('Housing Subsidy Administrator Eleven')} has made a decision on a housing opportunity for which the client below applied." +\ +Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} +\ +View details here: +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_match_initiation_for_hsa.text.haml b/app/views/notifications_mailer/eleven_match_initiation_for_hsa.text.haml new file mode 100644 index 000000000..a6f596489 --- /dev/null +++ b/app/views/notifications_mailer/eleven_match_initiation_for_hsa.text.haml @@ -0,0 +1,19 @@ +Hello #{@contact.full_name}, +\ +The CAS has generated a new match recommendation. +\ +Please acknowledge receipt of this match and review the associated HSA contacts. +\ +Please review details: +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_match_initiation_for_shelter_agency.text.haml b/app/views/notifications_mailer/eleven_match_initiation_for_shelter_agency.text.haml new file mode 100644 index 000000000..0b2c6da86 --- /dev/null +++ b/app/views/notifications_mailer/eleven_match_initiation_for_shelter_agency.text.haml @@ -0,0 +1,17 @@ +Hello #{@contact.full_name}, +\ +The CAS has generated a new match recommendation. +\ +This match has not yet been reviewed by the #{Translation.translate('HSA Eleven')}: +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/eleven_match_initiation_for_ssp.text.haml b/app/views/notifications_mailer/eleven_match_initiation_for_ssp.text.haml new file mode 100644 index 000000000..0b2c6da86 --- /dev/null +++ b/app/views/notifications_mailer/eleven_match_initiation_for_ssp.text.haml @@ -0,0 +1,17 @@ +Hello #{@contact.full_name}, +\ +The CAS has generated a new match recommendation. +\ +This match has not yet been reviewed by the #{Translation.translate('HSA Eleven')}: +#{notification_match_url @notification, @match} +\ += render 'client_details' +\ += render 'location_details' +\ += render 'program_details' +\ +\ +\ +\ += render 'email_footer' diff --git a/app/views/notifications_mailer/hsa_decision_client.text.haml b/app/views/notifications_mailer/hsa_decision_client.text.haml index e2f098e01..f2dd24729 100644 --- a/app/views/notifications_mailer/hsa_decision_client.text.haml +++ b/app/views/notifications_mailer/hsa_decision_client.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ = "A #{Translation.translate('Housing Subsidy Administrator')} has made a decision on a housing opportunity for which the client below applied." \ -Decision: #{@match.hsa_accepts_client_decision.status_label} +Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} \ = render 'client_details' \ diff --git a/app/views/notifications_mailer/hsa_decision_hsp.text.haml b/app/views/notifications_mailer/hsa_decision_hsp.text.haml index 389f53344..576f4f76c 100644 --- a/app/views/notifications_mailer/hsa_decision_hsp.text.haml +++ b/app/views/notifications_mailer/hsa_decision_hsp.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ = "A #{Translation.translate('Housing Subsidy Administrator')} has made a decision on a housing opportunity for which the client below applied." \ -Decision: #{@match.hsa_accepts_client_decision.status_label} +Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} \ View details here: #{notification_match_url @notification, @match} diff --git a/app/views/notifications_mailer/hsa_decision_shelter_agency.text.haml b/app/views/notifications_mailer/hsa_decision_shelter_agency.text.haml index 389f53344..576f4f76c 100644 --- a/app/views/notifications_mailer/hsa_decision_shelter_agency.text.haml +++ b/app/views/notifications_mailer/hsa_decision_shelter_agency.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ = "A #{Translation.translate('Housing Subsidy Administrator')} has made a decision on a housing opportunity for which the client below applied." \ -Decision: #{@match.hsa_accepts_client_decision.status_label} +Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} \ View details here: #{notification_match_url @notification, @match} diff --git a/app/views/notifications_mailer/hsa_decision_ssp.text.haml b/app/views/notifications_mailer/hsa_decision_ssp.text.haml index 389f53344..576f4f76c 100644 --- a/app/views/notifications_mailer/hsa_decision_ssp.text.haml +++ b/app/views/notifications_mailer/hsa_decision_ssp.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ = "A #{Translation.translate('Housing Subsidy Administrator')} has made a decision on a housing opportunity for which the client below applied." \ -Decision: #{@match.hsa_accepts_client_decision.status_label} +Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} \ View details here: #{notification_match_url @notification, @match} diff --git a/db/migrate/20240621125508_match_route_eleven_translations.rb b/db/migrate/20240621125508_match_route_eleven_translations.rb new file mode 100644 index 000000000..e9f39c1fb --- /dev/null +++ b/db/migrate/20240621125508_match_route_eleven_translations.rb @@ -0,0 +1,25 @@ +class MatchRouteElevenTranslations < ActiveRecord::Migration[7.0] + def up + translations_eleven.each do |k, v| + Translation.create!( + key: k, + text: v, + ) + end + end + def down + Translation.where(key: translations_eleven.keys).destroy_all + end + private + def translations_eleven = { + 'Match Route Eleven' => 'Match Route Eleven', + 'SSP Eleven' => 'SSP', + 'Shelter Agency Eleven' => 'Shelter Agency', + 'HSA Eleven' => 'HSA', + 'Housing Search Provider Eleven' => 'Housing Search Provider', + 'Housing Subsidy Administrator Eleven' => 'Housing Subsidy Administrator', + 'Stabilization Service Provider Eleven' => 'Stabilization Services Provider', + 'Stabilization Services Provider Eleven' => 'Stabilization Services Provider', + 'CoC Eleven' => 'DND', + } +end From a82f1c5603689c19f041b61fc0c722c3b71f760f Mon Sep 17 00:00:00 2001 From: Dave G Date: Mon, 24 Jun 2024 08:53:47 -0400 Subject: [PATCH 2/5] rubocop errors --- app/models/notifications/eleven/match_initiation_for_ssp.rb | 1 - .../20240621125508_match_route_eleven_translations.rb | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/notifications/eleven/match_initiation_for_ssp.rb b/app/models/notifications/eleven/match_initiation_for_ssp.rb index 76d80d4a2..ae9236b07 100644 --- a/app/models/notifications/eleven/match_initiation_for_ssp.rb +++ b/app/models/notifications/eleven/match_initiation_for_ssp.rb @@ -29,6 +29,5 @@ def show_client_info? def allows_registration? false end - end end diff --git a/db/migrate/20240621125508_match_route_eleven_translations.rb b/db/migrate/20240621125508_match_route_eleven_translations.rb index e9f39c1fb..bcf50b380 100644 --- a/db/migrate/20240621125508_match_route_eleven_translations.rb +++ b/db/migrate/20240621125508_match_route_eleven_translations.rb @@ -7,12 +7,14 @@ def up ) end end + def down Translation.where(key: translations_eleven.keys).destroy_all end + private def translations_eleven = { - 'Match Route Eleven' => 'Match Route Eleven', + 'Match Route Eleven' => 'Match Route Eleven', 'SSP Eleven' => 'SSP', 'Shelter Agency Eleven' => 'Shelter Agency', 'HSA Eleven' => 'HSA', @@ -22,4 +24,4 @@ def translations_eleven = { 'Stabilization Services Provider Eleven' => 'Stabilization Services Provider', 'CoC Eleven' => 'DND', } -end +end \ No newline at end of file From 9d8cd98ce5f201a02fd18953647b2a5208639e0f Mon Sep 17 00:00:00 2001 From: Dave G Date: Mon, 24 Jun 2024 08:58:38 -0400 Subject: [PATCH 3/5] more rubocop fixes --- ...1125508_match_route_eleven_translations.rb | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/db/migrate/20240621125508_match_route_eleven_translations.rb b/db/migrate/20240621125508_match_route_eleven_translations.rb index bcf50b380..c6c8b38a4 100644 --- a/db/migrate/20240621125508_match_route_eleven_translations.rb +++ b/db/migrate/20240621125508_match_route_eleven_translations.rb @@ -6,22 +6,23 @@ def up text: v, ) end - end + end def down Translation.where(key: translations_eleven.keys).destroy_all end private - def translations_eleven = { - 'Match Route Eleven' => 'Match Route Eleven', - 'SSP Eleven' => 'SSP', - 'Shelter Agency Eleven' => 'Shelter Agency', - 'HSA Eleven' => 'HSA', - 'Housing Search Provider Eleven' => 'Housing Search Provider', - 'Housing Subsidy Administrator Eleven' => 'Housing Subsidy Administrator', - 'Stabilization Service Provider Eleven' => 'Stabilization Services Provider', - 'Stabilization Services Provider Eleven' => 'Stabilization Services Provider', - 'CoC Eleven' => 'DND', - } -end \ No newline at end of file + + def translations_eleven = { + 'Match Route Eleven' => 'Match Route Eleven', + 'SSP Eleven' => 'SSP', + 'Shelter Agency Eleven' => 'Shelter Agency', + 'HSA Eleven' => 'HSA', + 'Housing Search Provider Eleven' => 'Housing Search Provider', + 'Housing Subsidy Administrator Eleven' => 'Housing Subsidy Administrator', + 'Stabilization Service Provider Eleven' => 'Stabilization Services Provider', + 'Stabilization Services Provider Eleven' => 'Stabilization Services Provider', + 'CoC Eleven' => 'DND', + } +end From 4cc72089d139365b660f84cb9c30dc27b3b5044e Mon Sep 17 00:00:00 2001 From: Dave G Date: Mon, 24 Jun 2024 13:49:12 -0400 Subject: [PATCH 4/5] Updates from code review --- ...eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb | 6 +++--- .../match_decisions/eleven/eleven_hsa_accepts_client.rb | 4 ++-- .../eleven/eleven_hsa_acknowledges_receipt.rb | 8 ++++---- app/models/match_routes/eleven.rb | 2 +- .../_confirm_hsa_accepts_client_decline_dnd_staff.haml} | 0 .../_hsa_accepts_client.haml} | 0 .../_hsa_acknowledges_receipt.haml} | 0 .../eleven_match_initiation_for_hsa.text.haml | 2 +- .../notifications_mailer/hsa_decision_client.text.haml | 2 +- app/views/notifications_mailer/hsa_decision_hsp.text.haml | 2 +- .../hsa_decision_shelter_agency.text.haml | 2 +- app/views/notifications_mailer/hsa_decision_ssp.text.haml | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) rename app/views/match_decisions/{_eleven_confirm_hsa_accepts_client_decline_dnd_staff.haml => eleven/_confirm_hsa_accepts_client_decline_dnd_staff.haml} (100%) rename app/views/match_decisions/{_eleven_hsa_accepts_client.haml => eleven/_hsa_accepts_client.haml} (100%) rename app/views/match_decisions/{_eleven_hsa_acknowledges_receipt.haml => eleven/_hsa_acknowledges_receipt.haml} (100%) diff --git a/app/models/match_decisions/eleven/eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb b/app/models/match_decisions/eleven/eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb index e10a4ab80..d2fce0864 100644 --- a/app/models/match_decisions/eleven/eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb +++ b/app/models/match_decisions/eleven/eleven_confirm_hsa_accepts_client_decline_dnd_staff.rb @@ -7,7 +7,7 @@ module MatchDecisions::Eleven class ElevenConfirmHsaAcceptsClientDeclineDndStaff < ::MatchDecisions::Base def to_partial_path - 'match_decisions/eleven_confirm_hsa_accepts_client_decline_dnd_staff' + 'match_decisions/eleven/confirm_hsa_accepts_client_decline_dnd_staff' end def statuses @@ -67,7 +67,8 @@ def notifications_for_this_step end def accessible_by? contact - contact.user_can_reject_matches? || contact.user_can_approve_matches? + contact.user_can_reject_matches? || + contact.user_can_approve_matches? end def show_client_match_attributes? @@ -90,7 +91,6 @@ def decline_overridden_returned def decline_confirmed match.rejected! - # TODO maybe rerun the matching engine for that vacancy and client end def canceled diff --git a/app/models/match_decisions/eleven/eleven_hsa_accepts_client.rb b/app/models/match_decisions/eleven/eleven_hsa_accepts_client.rb index a21db07e6..2288d3478 100644 --- a/app/models/match_decisions/eleven/eleven_hsa_accepts_client.rb +++ b/app/models/match_decisions/eleven/eleven_hsa_accepts_client.rb @@ -7,7 +7,7 @@ module MatchDecisions::Eleven class ElevenHsaAcceptsClient < ::MatchDecisions::Base def to_partial_path - 'match_decisions/eleven_hsa_accepts_client' + 'match_decisions/eleven/hsa_accepts_client' end include MatchDecisions::AcceptsDeclineReason @@ -88,7 +88,7 @@ def notify_contact_of_action_taken_on_behalf_of contact: # rubocop:disable Lint/ def accessible_by? contact contact.user_can_act_on_behalf_of_match_contacts? || - contact.in?(match.housing_subsidy_admin_contacts) + contact.in?(match.send(contact_actor_type)) end def show_client_match_attributes? diff --git a/app/models/match_decisions/eleven/eleven_hsa_acknowledges_receipt.rb b/app/models/match_decisions/eleven/eleven_hsa_acknowledges_receipt.rb index f7d6e89eb..f0002b500 100644 --- a/app/models/match_decisions/eleven/eleven_hsa_acknowledges_receipt.rb +++ b/app/models/match_decisions/eleven/eleven_hsa_acknowledges_receipt.rb @@ -7,7 +7,7 @@ module MatchDecisions::Eleven class ElevenHsaAcknowledgesReceipt < ::MatchDecisions::Base def to_partial_path - 'match_decisions/eleven_hsa_acknowledges_receipt' + 'match_decisions/eleven/hsa_acknowledges_receipt' end validate :cant_accept_if_match_closed @@ -37,7 +37,7 @@ def actor_type end def contact_actor_type - nil + :housing_subsidy_admin_contacts end def statuses @@ -66,8 +66,8 @@ def initialize_decision! send_notifications: true end def accessible_by? contact - contact.user_can_act_on_behalf_of_match_contacts? || - contact.in?(match.housing_subsidy_admin_contacts) + contact.user_can_act_on_behalf_of_match_contacts? + contact.in?(match.send(contact_actor_type)) end def notifications_for_this_step diff --git a/app/models/match_routes/eleven.rb b/app/models/match_routes/eleven.rb index f2a92df15..ccc21d327 100644 --- a/app/models/match_routes/eleven.rb +++ b/app/models/match_routes/eleven.rb @@ -56,7 +56,7 @@ def status_declined?(match) end def contact_label_for(contact_type) - case contact_type + case contact_type&.to_sym when :dnd_staff_contacts Translation.translate('CoC Eleven') when :housing_subsidy_admin_contacts diff --git a/app/views/match_decisions/_eleven_confirm_hsa_accepts_client_decline_dnd_staff.haml b/app/views/match_decisions/eleven/_confirm_hsa_accepts_client_decline_dnd_staff.haml similarity index 100% rename from app/views/match_decisions/_eleven_confirm_hsa_accepts_client_decline_dnd_staff.haml rename to app/views/match_decisions/eleven/_confirm_hsa_accepts_client_decline_dnd_staff.haml diff --git a/app/views/match_decisions/_eleven_hsa_accepts_client.haml b/app/views/match_decisions/eleven/_hsa_accepts_client.haml similarity index 100% rename from app/views/match_decisions/_eleven_hsa_accepts_client.haml rename to app/views/match_decisions/eleven/_hsa_accepts_client.haml diff --git a/app/views/match_decisions/_eleven_hsa_acknowledges_receipt.haml b/app/views/match_decisions/eleven/_hsa_acknowledges_receipt.haml similarity index 100% rename from app/views/match_decisions/_eleven_hsa_acknowledges_receipt.haml rename to app/views/match_decisions/eleven/_hsa_acknowledges_receipt.haml diff --git a/app/views/notifications_mailer/eleven_match_initiation_for_hsa.text.haml b/app/views/notifications_mailer/eleven_match_initiation_for_hsa.text.haml index a6f596489..e7b5688e1 100644 --- a/app/views/notifications_mailer/eleven_match_initiation_for_hsa.text.haml +++ b/app/views/notifications_mailer/eleven_match_initiation_for_hsa.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ The CAS has generated a new match recommendation. \ -Please acknowledge receipt of this match and review the associated HSA contacts. +Please acknowledge receipt of this match and review the associated #{Translation.translate('HSA Eleven')} contacts. \ Please review details: #{notification_match_url @notification, @match} diff --git a/app/views/notifications_mailer/hsa_decision_client.text.haml b/app/views/notifications_mailer/hsa_decision_client.text.haml index f2dd24729..e2f098e01 100644 --- a/app/views/notifications_mailer/hsa_decision_client.text.haml +++ b/app/views/notifications_mailer/hsa_decision_client.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ = "A #{Translation.translate('Housing Subsidy Administrator')} has made a decision on a housing opportunity for which the client below applied." \ -Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} +Decision: #{@match.hsa_accepts_client_decision.status_label} \ = render 'client_details' \ diff --git a/app/views/notifications_mailer/hsa_decision_hsp.text.haml b/app/views/notifications_mailer/hsa_decision_hsp.text.haml index 576f4f76c..389f53344 100644 --- a/app/views/notifications_mailer/hsa_decision_hsp.text.haml +++ b/app/views/notifications_mailer/hsa_decision_hsp.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ = "A #{Translation.translate('Housing Subsidy Administrator')} has made a decision on a housing opportunity for which the client below applied." \ -Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} +Decision: #{@match.hsa_accepts_client_decision.status_label} \ View details here: #{notification_match_url @notification, @match} diff --git a/app/views/notifications_mailer/hsa_decision_shelter_agency.text.haml b/app/views/notifications_mailer/hsa_decision_shelter_agency.text.haml index 576f4f76c..389f53344 100644 --- a/app/views/notifications_mailer/hsa_decision_shelter_agency.text.haml +++ b/app/views/notifications_mailer/hsa_decision_shelter_agency.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ = "A #{Translation.translate('Housing Subsidy Administrator')} has made a decision on a housing opportunity for which the client below applied." \ -Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} +Decision: #{@match.hsa_accepts_client_decision.status_label} \ View details here: #{notification_match_url @notification, @match} diff --git a/app/views/notifications_mailer/hsa_decision_ssp.text.haml b/app/views/notifications_mailer/hsa_decision_ssp.text.haml index 576f4f76c..389f53344 100644 --- a/app/views/notifications_mailer/hsa_decision_ssp.text.haml +++ b/app/views/notifications_mailer/hsa_decision_ssp.text.haml @@ -2,7 +2,7 @@ Hello #{@contact.full_name}, \ = "A #{Translation.translate('Housing Subsidy Administrator')} has made a decision on a housing opportunity for which the client below applied." \ -Decision: #{@match.eleven_hsa_accepts_client_decision.status_label} +Decision: #{@match.hsa_accepts_client_decision.status_label} \ View details here: #{notification_match_url @notification, @match} From c238dad812069a1b0f86ff5e97b780f2388de01a Mon Sep 17 00:00:00 2001 From: Dave G Date: Mon, 24 Jun 2024 13:49:51 -0400 Subject: [PATCH 5/5] remove default translations --- ...1125508_match_route_eleven_translations.rb | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 db/migrate/20240621125508_match_route_eleven_translations.rb diff --git a/db/migrate/20240621125508_match_route_eleven_translations.rb b/db/migrate/20240621125508_match_route_eleven_translations.rb deleted file mode 100644 index c6c8b38a4..000000000 --- a/db/migrate/20240621125508_match_route_eleven_translations.rb +++ /dev/null @@ -1,28 +0,0 @@ -class MatchRouteElevenTranslations < ActiveRecord::Migration[7.0] - def up - translations_eleven.each do |k, v| - Translation.create!( - key: k, - text: v, - ) - end - end - - def down - Translation.where(key: translations_eleven.keys).destroy_all - end - - private - - def translations_eleven = { - 'Match Route Eleven' => 'Match Route Eleven', - 'SSP Eleven' => 'SSP', - 'Shelter Agency Eleven' => 'Shelter Agency', - 'HSA Eleven' => 'HSA', - 'Housing Search Provider Eleven' => 'Housing Search Provider', - 'Housing Subsidy Administrator Eleven' => 'Housing Subsidy Administrator', - 'Stabilization Service Provider Eleven' => 'Stabilization Services Provider', - 'Stabilization Services Provider Eleven' => 'Stabilization Services Provider', - 'CoC Eleven' => 'DND', - } -end