Skip to content

Commit

Permalink
Show send consent document task in all qualifications
Browse files Browse the repository at this point in the history
If there are more than two qualifications that are signed we need to
show the send consent document task to all qualifications.
  • Loading branch information
thomasleese committed Feb 21, 2024
1 parent d4acafb commit 64cb866
Showing 1 changed file with 37 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def all_task_items
if generate_consent_document_in_all_qualifications?
generate_consent_document_task_item
end,
if send_consent_document_in_all_qualifications?
send_consent_document_task_item
end,
].compact

if show_individual_task_items?
Expand Down Expand Up @@ -102,40 +105,55 @@ def unsigned_consent_method_task_items(_qualification_request)
end
end

def signed_consent_method_task_items(qualification_request)
document_uploaded =
qualification_request.unsigned_consent_document.completed?
def send_consent_document_in_all_qualifications?
all_consent_methods_selected? &&
qualification_requests.consent_method_signed.count >= 2
end

def send_consent_document_task_item
{
name: "Send consent document to applicant",
link: "#",
status:
if qualification_requests.map(&:unsigned_consent_document).all?(
&:completed?
)
if qualification_requests.all(&:consent_requested?)
"completed"
else
"not_started"
end
else
"cannot_start"
end,
}
end

def signed_consent_method_task_items(qualification_request)
[
{
name: "Upload consent document",
link: "#",
status: document_uploaded ? "completed" : "not_started",
},
{
name: "Send consent document to applicant",
link: "#",
status:
if document_uploaded
if qualification_request.consent_requested?
(
if qualification_request.unsigned_consent_document.completed?
"completed"
else
"not_started"
end
else
"cannot_start"
end,
),
},
unless send_consent_document_in_all_qualifications?
send_consent_document_task_item
end,
{
name: "Record applicant response",
link: "#",
status:
if document_uploaded
if qualification_request.consent_received?
"completed"
else
"not_started"
end
if qualification_request.consent_received?
"completed"
elsif qualification_request.consent_requested?
"not_started"
else
"cannot_start"
end,
Expand Down

0 comments on commit 64cb866

Please sign in to comment.