-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds approved claims failing qualification tasks
One gotcha that we might need to deal with in this report is the `dqt_teacher_status`. When the qualification claim verifier runs is uses the dqt record to set some notes on the claim. If the claim has a populated `dqt_teacher_status` field it uses that to build the dqt teacher record object, if not the status is fetched from the api, however this information from the api is not persisted to the claim. When generating the report we don't want to hit the dqt api for potentially many claims, so if we're missing this dqt status we don't include it in the report. Checking the current academic year's claims there don't seem to be any claims that would be returned from this report that are missing their `dqt_teacher_status`. If missing `dqt_teacher_status` in this report is causing issues for the ops team, we could consider parsing the claim notes to get this information.
- Loading branch information
Showing
5 changed files
with
454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
app/models/admin/reports/approved_claims_failing_qualification_task.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
module Admin | ||
module Reports | ||
class ApprovedClaimsFailingQualificationTask | ||
HEADERS = [ | ||
"Claim reference", | ||
"Teacher reference number", | ||
"Policy", | ||
"Status", | ||
"Decision date", | ||
"Decision agent", | ||
"Qualification", | ||
"ITT start year", | ||
"ITT subject", | ||
"ITT subjects", | ||
"ITT start date", | ||
"QTS award date", | ||
"Qualification name" | ||
] | ||
|
||
def filename | ||
"approved_claims_failing_qualification_task" | ||
end | ||
|
||
def to_csv | ||
CSV.generate( | ||
row_sep: "\r\n", | ||
write_headers: true, | ||
headers: HEADERS | ||
) do |csv| | ||
rows.each { |row| csv << row } | ||
end | ||
end | ||
|
||
private | ||
|
||
def rows | ||
scope.map(&ClaimPresenter.method(:new)).map(&:to_a) | ||
end | ||
|
||
def scope | ||
Claim | ||
.approved | ||
.where(academic_year: AcademicYear.current) | ||
.joins(:tasks) | ||
.merge(Task.where(name: "qualifications", passed: false)) | ||
.includes(:eligibility, decisions: :created_by) | ||
end | ||
|
||
class ClaimPresenter | ||
include Admin::ClaimsHelper | ||
|
||
def initialize(claim) | ||
@claim = claim | ||
end | ||
|
||
def to_a | ||
[ | ||
claim.reference, | ||
claim.eligibility.teacher_reference_number, | ||
I18n.t("#{claim.policy.locale_key}.policy_acronym"), | ||
status(claim), | ||
I18n.l(approval.created_at.to_date, format: :day_month_year), | ||
approval.created_by.full_name, | ||
qualification, | ||
itt_academic_year&.to_s, | ||
eligible_itt_subject, | ||
dqt_teacher_record.itt_subjects.join(", "), | ||
I18n.l(dqt_teacher_record.itt_start_date, format: :day_month_year), | ||
I18n.l(dqt_teacher_record.qts_award_date, format: :day_month_year), | ||
dqt_teacher_record.qualification_name | ||
] | ||
end | ||
|
||
private | ||
|
||
attr_reader :claim | ||
|
||
def approval | ||
@approval ||= claim.decisions.reject(&:undone).last | ||
end | ||
|
||
# StudentLoans doesn't have an eligible_itt_subject | ||
def eligible_itt_subject | ||
claim.eligibility.try(:eligible_itt_subject) | ||
end | ||
|
||
# StudentLoans doesn't have an itt_academic_year | ||
def itt_academic_year | ||
claim.eligibility.try(:itt_academic_year) | ||
end | ||
|
||
# StudentLoans doesn't have a qualification | ||
def qualification | ||
claim.eligibility.try(:qualification) | ||
end | ||
|
||
def itt_subjects | ||
dqt_teacher_record&.itt_subjects | ||
end | ||
|
||
def itt_start_date | ||
dqt_teacher_record&.itt_start_date | ||
end | ||
|
||
def qts_award_date | ||
dqt_teacher_record&.qts_award_date | ||
end | ||
|
||
def qualification_name | ||
dqt_teacher_record&.qualification_name | ||
end | ||
|
||
def dqt_teacher_record | ||
@dqt_teacher_record ||= if claim.has_dqt_record? | ||
Dqt::Teacher.new(claim.dqt_teacher_status) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.