Skip to content

Commit

Permalink
Add CoC Confirmation Decision to Route 11 (#866)
Browse files Browse the repository at this point in the history
* Add confirm success decision to match route 11

* script to destroy route 11 matches unless on production

* rubocop

* rubocop

* code review updates

* clean up match decision subway map

* Update app/views/matches/_current_step_info.haml

Co-authored-by: Elliot <[email protected]>

---------

Co-authored-by: Elliot <[email protected]>
  • Loading branch information
dtgreiner and eanders authored Oct 11, 2024
1 parent e55f149 commit 5f545bf
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 18 deletions.
1 change: 1 addition & 0 deletions app/models/concerns/route_eleven_decisions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ module RouteElevenDecisions
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'
has_decision :eleven_confirm_match_success_dnd_staff, decision_class_name: 'MatchDecisions::Eleven::ElevenConfirmMatchSuccessDndStaff', notification_class_name: 'Notifications::Eleven::ConfirmMatchSuccessDndStaff'
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
###
# Copyright 2016 - 2024 Green River Data Analysis, LLC
#
# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md
###

module MatchDecisions::Eleven
class ElevenConfirmMatchSuccessDndStaff < ::MatchDecisions::Base
include MatchDecisions::AcceptsDeclineReason
include MatchDecisions::RouteElevenDeclineReasons
include MatchDecisions::RouteElevenCancelReasons

def to_partial_path
'match_decisions/eleven/confirm_match_success_dnd_staff'
end

def statuses
{
pending: 'Pending',
confirmed: 'Confirmed',
declined: 'Declined',
canceled: 'Canceled',
back: 'Pending',
}
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 match success"
when :confirmed then "#{Translation.translate('CoC Eleven')} confirms match success"
when :rejected, :declined then "Match rejected by #{Translation.translate('CoC Eleven')}. Reason: #{decline_reason_name}"
when :canceled then canceled_status_label
when :back then backup_status_label
end
end

def started?
status&.to_sym == :confirmed
end

def step_name
"#{Translation.translate('CoC Eleven')} Review Match Success"
end

def actor_type
Translation.translate('CoC Eleven')
end

def contact_actor_type
:dnd_staff_contacts
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::ConfirmMatchSuccessDndStaff
end
end

def accessible_by? contact
contact&.user_can_reject_matches? || contact&.user_can_approve_matches?
end

def to_param
:eleven_confirm_match_success_dnd_staff
end

private def note_present_if_status_rejected
errors.add :note, 'Please note why the match is declined.' if note.blank? && status == 'rejected'
end

class StatusCallbacks < StatusCallbacks
def pending
end

def confirmed
Notifications::MatchSuccessConfirmed.create_for_match! match
match.succeeded!(user: user)
end

def declined
Notifications::MatchDeclined.create_for_match! match
match.rejected!
end

def canceled
Notifications::MatchCanceled.create_for_match! match
match.canceled!
end

def rejected
Notifications::MatchRejected.create_for_match! match
match.rejected!
end
end
private_constant :StatusCallbacks
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def pending

def accepted
Notifications::Eleven::HsaAcceptsClientSspNotification.create_for_match! match
match.succeeded!(user: user)
@decision.next_step.initialize_decision!
end

def declined
Expand Down
4 changes: 3 additions & 1 deletion app/models/match_routes/eleven.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def self.match_steps
{
'MatchDecisions::Eleven::ElevenHsaAcknowledgesReceipt' => 1,
'MatchDecisions::Eleven::ElevenHsaAcceptsClient' => 2,
'MatchDecisions::Eleven::ElevenConfirmMatchSuccessDndStaff' => 3,
}
end

Expand All @@ -26,6 +27,7 @@ def self.match_steps_for_reporting
'MatchDecisions::Eleven::ElevenHsaAcknowledgesReceipt' => 1,
'MatchDecisions::Eleven::ElevenHsaAcceptsClient' => 2,
'MatchDecisions::Eleven::ElevenConfirmHsaAcceptsClientDeclineDndStaff' => 3,
'MatchDecisions::Eleven::ElevenConfirmMatchSuccessDndStaff' => 4,
}
end

Expand All @@ -41,7 +43,7 @@ def initial_decision
end

def success_decision
:eleven_hsa_accepts_client_decision
:eleven_confirm_match_success_dnd_staff_decision
end

def initial_contacts_for_match
Expand Down
23 changes: 23 additions & 0 deletions app/models/notifications/eleven/confirm_match_success_dnd_staff.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
###
# Copyright 2016 - 2024 Green River Data Analysis, LLC
#
# License detail: https://github.com/greenriver/boston-cas/blob/production/LICENSE.md
###

module Notifications::Eleven
class ConfirmMatchSuccessDndStaff < ::Notifications::Base
def self.create_for_match! match
match.dnd_staff_contacts.each do |contact|
create! match: match, recipient: contact
end
end

def decision
match.eleven_confirm_match_success_dnd_staff_decision
end

def event_label
"#{Translation.translate('CoC Eleven')} Staff notified of successful match and asked to give final confirmation."
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.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
.o-choose__choice{class: ('o-choose__choice--disabled' if [email protected]?)}
%header
.o-choose__title
.c-choice-icon.c-choice-icon--confirm.mr-4
%h3 Confirm Match
.o-choose__content
%p Confirming match success will complete the match and remove the client and voucher/unit from future matching.
= render 'match_decisions/continue_button', text: 'Confirm Match Success', icon: 'checkmark', button_attributes: { class: 'btn btn-success', data: {submit_param_name: 'decision[status]', submit_param_value: 'confirmed'}, disabled: !(@decision.editable?) }
= render 'match_decisions/decline_and_cancel_backup_actions', form: form
32 changes: 16 additions & 16 deletions app/views/matches/_current_step_info.haml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
.d-flex.mb-5.align-items-end.flex-wrap
- if @match.current_decision.present?
.d-flex.flex-column
.summary-readout.mb-3
.summary-readout--tile
%h3.h4 Current Step
%h1.h2
-if [email protected]_status[:name] == "In Progress"
= match.overall_status[:name]
-else
= @match.current_decision.step_name
.summary-readout--tile
%h3.h4 Assigned To
%h1.h2
= @match.current_decision.try(:actor_type) || 'N/A'
= render 'match_list_base/current_step', match: @match
- else
- if @match.current_decision.blank?
= render 'matches/restrictions_on_reopening'
.d-flex.mb-5.align-items-end.flex-wrap
.d-flex.flex-column
.summary-readout.mb-3
.summary-readout--tile
%h3.h4 Current Step
%h1.h2
-if @match.overall_status[:name] != "In Progress"
= @match.overall_status[:name]
-else
= @match.current_decision.step_name
.summary-readout--tile
%h3.h4 Assigned To
%h1.h2
= @match.current_decision&.try(:actor_type) || 'N/A'
= render 'match_list_base/current_step', match: @match
%div.ml-auto
- if @match.can_create_overall_note?(access_context.current_contact)
.btn-label.btn-label__primary
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Hello #{@contact.full_name},
\
= "The match now requires final approval from #{Translation.translate('CoC Eleven')} staff to complete."
\
Please review the details of the match and note final approval here:
#{notification_match_decision_url @notification, @match, @decision}
\
= render 'client_details'
\
= render 'location_details'
\
= render 'program_details'
\
\
\
\
= render 'email_footer'
5 changes: 5 additions & 0 deletions db/migrate/20241010194153_destroy_route_eleven_matches.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DestroyRouteElevenMatches < ActiveRecord::Migration[7.0]
def up
ClientOpportunityMatch.joins(:match_route).where(match_routes: { type: 'MatchRoutes::Eleven' }).destroy_all unless Rails.env.production?
end
end

0 comments on commit 5f545bf

Please sign in to comment.