-
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.
Add fe approved failing pv task report
Adds the model to handle generating the reporting code for further education claims that have been approved but with a failing provider verification.
- Loading branch information
Showing
3 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
app/models/admin/reports/fe_approved_claims_with_failing_provider_verification.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,91 @@ | ||
module Admin | ||
module Reports | ||
class FeApprovedClaimsWithFailingProviderVerification | ||
HEADERS = [ | ||
"Claim reference", | ||
"Full name", | ||
"Claim amount", | ||
"Claim status", | ||
"Decision date", | ||
"Decision agent", | ||
"Contract of employment", | ||
"Teaching responsibilities", | ||
"First 5 years of teaching", | ||
"One full term", | ||
"Timetabled teaching hours", | ||
"Age range taught", | ||
"Subject", | ||
"Course", | ||
"2.5 hours weekly teaching", | ||
"Performance", | ||
"Disciplinary" | ||
] | ||
|
||
def as_csv | ||
[HEADERS, *scope.map(&ClaimPresenter.method(:new)).map(&:to_a)] | ||
end | ||
|
||
private | ||
|
||
def scope | ||
Claim | ||
.by_policy(Policies::FurtherEducationPayments) | ||
.approved | ||
.joins(:tasks) | ||
.merge(Task.where(name: "provider_verification", passed: false)) | ||
.includes(:eligibility, decisions: :created_by) | ||
end | ||
|
||
class ClaimPresenter | ||
include Admin::ClaimsHelper | ||
include ActionView::Helpers::NumberHelper | ||
|
||
def initialize(claim) | ||
@claim = claim | ||
end | ||
|
||
def to_a | ||
[ | ||
claim.reference, | ||
claim.full_name, | ||
number_to_currency(claim.award_amount, precision: 0), | ||
status(claim), | ||
approval_date, | ||
approval.created_by.full_name, | ||
present_assertion("contract_type"), | ||
present_assertion("teaching_responsibilities"), | ||
present_assertion("further_education_teaching_start_year"), | ||
present_assertion("taught_at_least_one_term"), | ||
present_assertion("teaching_hours_per_week"), | ||
present_assertion("half_teaching_hours"), | ||
present_assertion("subjects_taught"), | ||
"??", # FIXME RL: not sure what courses should be | ||
present_assertion("teaching_hours_per_week_next_term"), | ||
present_assertion("subject_to_formal_performance_action"), | ||
present_assertion("subject_to_disciplinary_action") | ||
] | ||
end | ||
|
||
private | ||
|
||
attr_reader :claim | ||
|
||
def approval_date | ||
I18n.l(approval.created_at.to_date, format: :day_month_year) | ||
end | ||
|
||
def approval | ||
@approval ||= claim.decisions.reject(&:undone).last | ||
end | ||
|
||
def present_assertion(name) | ||
case claim.eligibility.verification_assertion(name) | ||
when true then "Yes" | ||
when false then "No" | ||
else "N/A" # fixed and variable contracts have different assertions | ||
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
207 changes: 207 additions & 0 deletions
207
spec/models/admin/reports/fe_approved_claims_with_failing_provider_verification_spec.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,207 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Admin::Reports::FeApprovedClaimsWithFailingProviderVerification do | ||
around do |example| | ||
travel_to Date.new(2024, 11, 1) do | ||
example.run | ||
end | ||
end | ||
|
||
describe "as_csv" do | ||
it "returns a csv of approved fe claims with failing provider verification" do | ||
fe_claim_with_passing_provider_check = create( | ||
:claim, | ||
:approved, | ||
policy: Policies::FurtherEducationPayments | ||
) | ||
|
||
create( | ||
:task, | ||
:passed, | ||
name: "provider_verification", | ||
claim: fe_claim_with_passing_provider_check | ||
) | ||
|
||
fe_fixed_claim_with_failing_provider_check = create( | ||
:claim, | ||
:approved, | ||
policy: Policies::FurtherEducationPayments, | ||
first_name: "Elizabeth", | ||
surname: "Hoover", | ||
qa_required: true, | ||
eligibility_attributes: { | ||
award_amount: 2_000, | ||
contract_type: "permanent", | ||
verification: { | ||
assertions: [ | ||
{ | ||
name: "contract_type", | ||
outcome: true | ||
}, | ||
{ | ||
name: "teaching_responsibilities", | ||
outcome: true | ||
}, | ||
{ | ||
name: "further_education_teaching_start_year", | ||
outcome: true | ||
}, | ||
{ | ||
name: "teaching_hours_per_week", | ||
outcome: true | ||
}, | ||
{ | ||
name: "half_teaching_hours", | ||
outcome: false | ||
}, | ||
{ | ||
name: "subjects_taught", | ||
outcome: false | ||
}, | ||
{ | ||
name: "subject_to_formal_performance_action", | ||
outcome: true | ||
}, | ||
{ | ||
name: "subject_to_disciplinary_action", | ||
outcome: true | ||
} | ||
] | ||
} | ||
} | ||
) | ||
|
||
create( | ||
:task, | ||
:failed, | ||
name: "provider_verification", | ||
claim: fe_fixed_claim_with_failing_provider_check | ||
) | ||
|
||
fe_variable_claim_with_failing_provider_check = create( | ||
:claim, | ||
:approved, | ||
policy: Policies::FurtherEducationPayments, | ||
first_name: "Edna", | ||
surname: "Krabappel", | ||
eligibility_attributes: { | ||
award_amount: 3_000, | ||
contract_type: "variable_hours", | ||
verification: { | ||
assertions: [ | ||
{ | ||
name: "contract_type", | ||
outcome: true | ||
}, | ||
{ | ||
name: "teaching_responsibilities", | ||
outcome: true | ||
}, | ||
{ | ||
name: "further_education_teaching_start_year", | ||
outcome: true | ||
}, | ||
{ | ||
name: "taught_at_least_one_term", | ||
outcome: true | ||
}, | ||
{ | ||
name: "teaching_hours_per_week", | ||
outcome: true | ||
}, | ||
{ | ||
name: "half_teaching_hours", | ||
outcome: true | ||
}, | ||
{ | ||
name: "subjects_taught", | ||
outcome: true | ||
}, | ||
{ | ||
name: "teaching_hours_per_week_next_term", | ||
outcome: true | ||
}, | ||
{ | ||
name: "subject_to_formal_performance_action", | ||
outcome: true | ||
}, | ||
{ | ||
name: "subject_to_disciplinary_action", | ||
outcome: false | ||
} | ||
] | ||
} | ||
} | ||
) | ||
|
||
create( | ||
:task, | ||
:failed, | ||
name: "provider_verification", | ||
claim: fe_variable_claim_with_failing_provider_check | ||
) | ||
|
||
csv = described_class.new.as_csv | ||
|
||
expect(csv).to match_array([ | ||
[ | ||
"Claim reference", | ||
"Full name", | ||
"Claim amount", | ||
"Claim status", | ||
"Decision date", | ||
"Decision agent", | ||
"Contract of employment", | ||
"Teaching responsibilities", | ||
"First 5 years of teaching", | ||
"One full term", | ||
"Timetabled teaching hours", | ||
"Age range taught", | ||
"Subject", | ||
"Course", | ||
"2.5 hours weekly teaching", | ||
"Performance", | ||
"Disciplinary" | ||
], | ||
[ | ||
fe_fixed_claim_with_failing_provider_check.reference, | ||
"Elizabeth Hoover", | ||
"£2,000", | ||
"Approved awaiting QA", | ||
"01/11/2024", | ||
"Aaron Admin", | ||
"Yes", # contract of employment | ||
"Yes", # teaching responsibilities | ||
"Yes", # first 5 years of teaching | ||
"N/A", # one full term - not a question for fixed term contracts | ||
"Yes", # timetabled teaching hours | ||
"No", # age range taught | ||
"No", # subject | ||
"??", # course | ||
"N/A", # 2.5 hours weekly teaching | ||
"Yes", # performance | ||
"Yes" # disciplinary | ||
], | ||
[ | ||
fe_variable_claim_with_failing_provider_check.reference, | ||
"Edna Krabappel", | ||
"£3,000", | ||
"Approved awaiting payroll", | ||
"01/11/2024", | ||
"Aaron Admin", | ||
"Yes", # contract of employment | ||
"Yes", # teaching responsibilities | ||
"Yes", # first 5 years of teaching | ||
"Yes", # one full term | ||
"Yes", # timetabled teaching hours | ||
"Yes", # age range taught | ||
"Yes", # subject | ||
"??", # course | ||
"Yes", # 2.5 hours weekly teaching | ||
"Yes", # performance | ||
"No" # disciplinary | ||
] | ||
]) | ||
end | ||
end | ||
end |