Skip to content

Commit

Permalink
Merge branch 'master' into LUPEYALPHA-1062-already-submitted-claim
Browse files Browse the repository at this point in the history
  • Loading branch information
vacabor authored Oct 10, 2024
2 parents 227b5be + 471cda0 commit 516b400
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/payroll_runs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def index
end

def new
@claims = Claim.payrollable
@claims = Claim.payrollable.order(submitted_at: :asc)

# Due to limitations with the current payroll software we need a temporary
# cap on the number of claims that can enter payroll, especially expecting
Expand Down
9 changes: 7 additions & 2 deletions app/forms/admin/claims_filter_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def claims
Claim.approved.awaiting_qa
when "approved_awaiting_payroll"
approved_awaiting_payroll
when "automatically_approved"
Claim.current_academic_year.auto_approved
when "automatically_approved_awaiting_payroll"
Claim.current_academic_year.payrollable.auto_approved
when "rejected"
Expand All @@ -57,7 +59,7 @@ def claims
when "failed_bank_validation"
Claim.includes(:decisions).failed_bank_validation.awaiting_decision
when "awaiting_provider_verification"
Claim.by_policy(Policies::FurtherEducationPayments).awaiting_further_education_provider_verification
Claim.by_policy(Policies::FurtherEducationPayments).awaiting_further_education_provider_verification.awaiting_decision
else
Claim.includes(:decisions).not_held.awaiting_decision.not_awaiting_further_education_provider_verification
end
Expand All @@ -66,9 +68,11 @@ def claims
@claims = @claims.by_claims_team_member(selected_team_member, status) if selected_team_member
@claims = @claims.unassigned if unassigned?

@claims = Claim.where(id: @claims.select("DISTINCT ON (claims.id) claims.id"))

@claims = @claims.includes(:tasks, eligibility: [:claim_school, :current_school])
@claims = @claims.order(:submitted_at)

@claims = @claims.order(:submitted_at)
@claims
end

Expand All @@ -92,6 +96,7 @@ def status_select_options
["Awaiting decision - failed bank details", "failed_bank_validation"],
["Approved awaiting QA", "approved_awaiting_qa"],
["Approved awaiting payroll", "approved_awaiting_payroll"],
["Automatically approved", "automatically_approved"],
["Automatically approved awaiting payroll", "automatically_approved_awaiting_payroll"],
["Approved", "approved"],
["Rejected", "rejected"]
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/admin/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ def claim_summary_heading(claim)
end

def status(claim)
if claim.awaiting_provider_verification?
"Awaiting provider verification"
elsif claim.all_payrolled?
if claim.all_payrolled?
"Payrolled"
elsif claim.latest_decision&.approved? && claim.awaiting_qa? && !claim.held?
"Approved awaiting QA"
elsif claim.latest_decision&.approved?
"Approved awaiting payroll"
elsif claim.latest_decision&.rejected?
"Rejected"
elsif claim.awaiting_provider_verification?
"Awaiting provider verification"
elsif claim.held?
"Awaiting decision - on hold"
else
Expand Down
2 changes: 1 addition & 1 deletion app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Claim < ApplicationRecord

delegate :award_amount, to: :eligibility

scope :payrollable, -> { approved.not_awaiting_qa.left_joins(:payments).where(payments: nil).order(submitted_at: :asc) }
scope :payrollable, -> { approved.not_awaiting_qa.left_joins(:payments).where(payments: nil) }
scope :not_awaiting_qa, -> { approved.where("qa_required = false OR (qa_required = true AND qa_completed_at IS NOT NULL)") }
scope :awaiting_qa, -> { approved.qa_required.where(qa_completed_at: nil) }
scope :qa_required, -> { where(qa_required: true) }
Expand Down
3 changes: 1 addition & 2 deletions app/models/policies/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ module FurtherEducationPayments
# NOOP as PERSONAL_DATA_ATTRIBUTES_TO_RETAIN_FOR_EXTENDED_PERIOD is empty
EXTENDED_PERIOD_END_DATE = ->(start_of_academic_year) {}

# TODO: This is needed once the reply-to email address has been added to Gov Notify
def notify_reply_to_id
nil
"89939786-7078-4267-b197-ee505dfad8ae"
end

def verification_due_date_for_claim(claim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def qualifications
end

def employment
[]
[
["Current provider", display_school(claim.eligibility.current_school)]
]
end

def identity_confirmation
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,8 @@ en:
claimant_answers:
true: "Yes"
false: "No"
employment:
title: Does the claimant’s place of work match the above information on their claim?
forms:
ineligible:
courses:
Expand Down
12 changes: 12 additions & 0 deletions spec/factories/claims.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
claim.academic_year = claim_academic_year unless claim.academic_year_before_type_cast
end

trait :current_academic_year do
academic_year { AcademicYear.current }
end

trait :with_onelogin_idv_data do
identity_confirmed_with_onelogin { true }
onelogin_uid { SecureRandom.uuid }
Expand Down Expand Up @@ -309,6 +313,14 @@
end
end

trait :awaiting_provider_verification do
eligibility_trait { :not_verified }

after(:create) do |claim, _|
create(:note, claim:, label: "provider_verification")
end
end

trait :with_dqt_teacher_status do
dqt_teacher_status do
{
Expand Down
100 changes: 100 additions & 0 deletions spec/forms/admin/claims_filter_form_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
require "rails_helper"

RSpec.describe Admin::ClaimsFilterForm, type: :model do
describe "#claims" do
context "when rejected whilst awaiting provider verification" do
let!(:claim) do
create(
:claim,
:rejected,
:awaiting_provider_verification,
policy: Policies::FurtherEducationPayments
)
end

let(:session) { {} }
let(:filters) { {status: "awaiting_provider_verification"} }

subject { described_class.new(filters:, session:) }

it "filtering by status awaiting provider verification excludes them" do
expect(subject.claims).not_to include(claim)
end
end

context "when the status is awaiting_provider_verification" do
it "returns the expected claims" do
claim_awaiting_provider_verification_1 = build(
:claim,
:submitted
)

create(
:further_education_payments_eligibility,
claim: claim_awaiting_provider_verification_1,
flagged_as_duplicate: false
)

claim_awaiting_provider_verification_2 = build(
:claim,
:submitted
)

create(
:further_education_payments_eligibility,
claim: claim_awaiting_provider_verification_2,
flagged_as_duplicate: true
)

create(
:note,
claim: claim_awaiting_provider_verification_2,
label: "provider_verification"
)

create(
:note,
claim: claim_awaiting_provider_verification_2,
label: "provider_verification"
)

_claim_not_awating_provider_verification = build(:claim, :submitted)

create(
:further_education_payments_eligibility,
:verified
)

form = described_class.new(
session: {},
filters: {
status: "awaiting_provider_verification"
}
)

expect(form.claims).to match_array(
[
claim_awaiting_provider_verification_1,
claim_awaiting_provider_verification_2
]
)
end
end

context "filtering for unassigned + auto approved claims" do
subject { described_class.new(session:, filters: {team_member:, status:}) }

let(:team_member) { "unassigned" }
let(:status) { "automatically_approved" }
let(:session) { {} }

before do
create(:claim, :submitted, :auto_approved, :current_academic_year)
end

it "works" do
expect(subject.claims.count).to eql(1)
end
end
end
end
17 changes: 17 additions & 0 deletions spec/helpers/admin/claims_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,23 @@
end
end
end

context "rejected claim whilst awaiting provider verification" do
let!(:claim) do
create(
:claim,
:rejected,
:awaiting_provider_verification,
policy: Policies::FurtherEducationPayments
)
end

it "returns rejected" do
freeze_time do
expect(status(claim)).to eql "Rejected"
end
end
end
end

describe "#index_status_filter" do
Expand Down
20 changes: 20 additions & 0 deletions spec/models/further_education_payments_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require "rails_helper"

RSpec.describe Policies::FurtherEducationPayments, type: :model do
it { is_expected.to include(BasePolicy) }

it do
expect(subject::VERIFIERS).to eq([
AutomatedChecks::ClaimVerifiers::Identity,
AutomatedChecks::ClaimVerifiers::ProviderVerification,
AutomatedChecks::ClaimVerifiers::Employment,
AutomatedChecks::ClaimVerifiers::StudentLoanPlan
])
end

specify {
expect(subject).to have_attributes(
notify_reply_to_id: "89939786-7078-4267-b197-ee505dfad8ae"
)
}
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "rails_helper"

RSpec.describe Policies::FurtherEducationPayments::AdminTasksPresenter do
describe "#employment" do
let(:claim) { create(:claim, :submitted) }

subject { described_class.new(claim) }

it "displays answer with link" do
expect(subject.employment[0][0]).to eql("Current provider")
expect(subject.employment[0][1]).to include("href")
expect(subject.employment[0][1]).to include(claim.school.dfe_number)
end
end
end

0 comments on commit 516b400

Please sign in to comment.