Skip to content

Commit

Permalink
Merge pull request #8092 from ministryofjustice/ctskf-1009-additional…
Browse files Browse the repository at this point in the history
…-prep-fee-warning

[CTSKF-1009] Add injection warning for Additional Prep Fees
  • Loading branch information
mpw5 authored Jan 27, 2025
2 parents 6f80847 + d622c57 commit 1dfa654
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 13 deletions.
9 changes: 9 additions & 0 deletions app/interfaces/api/entities/search_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SearchResult < BaseEntity
expose :agfs_hardship
expose :lgfs_hardship
expose :clar_fees_warning
expose :additional_prep_fee_warning
end

private
Expand Down Expand Up @@ -131,6 +132,14 @@ def cav_warning
(last_injection_attempt_succeeded && contains_conference_and_view).to_i
end

def clar_fees_warning
(last_injection_attempt_succeeded && contains_clar_fees).to_i
end

def additional_prep_fee_warning
(last_injection_attempt_succeeded && contains_additional_prep_fee).to_i
end

def supplementary
object.case_type.eql?('Supplementary').to_i
end
Expand Down
14 changes: 10 additions & 4 deletions app/interfaces/api/helpers/search_result_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ def last_injection_attempt_succeeded
object&.last_injection_succeeded || false
end

def clar_fees_warning
(last_injection_attempt_succeeded && contains_clar_fees).to_i
end

def contains_clar_fees
fees&.map do |fee|
[
Expand All @@ -111,6 +107,16 @@ def contains_clar_fees
].all?
end&.any?
end

def contains_additional_prep_fee
fees&.map do |fee|
[
fee[2].eql?('Fee::MiscFeeType'),
fee[1].eql?('Additional preparation fee'),
fee[0].to_i.positive?
].all?
end&.any?
end
end
end
end
4 changes: 4 additions & 0 deletions app/presenters/claim/base_claim_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ def has_clar_fees?
claim.fees.select { |f| f.fee_type.unique_code.in?(%w[MIPHC MIUMU MIUMO]) }.any? { |x| x.amount&.nonzero? }
end

def has_additional_prep_fee?
claim.fees.select { |f| f.fee_type.unique_code.eql?('MIAPF') }.any? { |x| x.amount&.nonzero? }
end

def eligible_misc_fee_type_options_for_select
claim.eligible_misc_fee_types.map do |fee_type|
[
Expand Down
9 changes: 9 additions & 0 deletions app/views/warnings/_injection_warnings_summary.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@

%span.form-hint.govuk-error-summary__body
= t('shared.injection_errors.clar_fees_warning.message')

- if claim&.last_injection_attempt&.succeeded && claim.has_additional_prep_fee?
.js-callout-injection-warning
.warning-summary.govuk-error-summary{ role: 'group', 'aria-labelledby': 'warning-summary-heading', tabindex: '-1' }
%h2.govuk-heading-m.govuk-error-summary__title{ id: 'warning-summary-heading' }
= t('shared.injection_errors.additional_prep_fee_warning.header')

%span.form-hint.govuk-error-summary__body
= t('shared.injection_errors.additional_prep_fee_warning.message')
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ moj.Modules.AllocationDataTable = {
} else if (data.filter.cav_warning) {
$(row).addClass('injection-warning')
$('td', row).eq(0).wrapInner('<div class="warning-message-container"></div>')
$('td .warning-message-container', row).eq(0).append('<div class="warning-message">CAVs not injected</div>')
$('td .warning-message-container', row).eq(0).append('<div class="warning-message">Conference fees not injected</div>')
} else if (data.filter.clar_fees_warning) {
$(row).addClass('injection-warning')
$('td', row).eq(0).wrapInner('<div class="warning-message-container"></div>')
$('td .warning-message-container', row).eq(0).append('<div class="warning-message">CLAR fees not injected</div>')
$('td .warning-message-container', row).eq(0).append('<div class="warning-message">Paper heavy case or unused materials fees not injected</div>')
} else if (data.filter.additional_prep_fee_warning) {
$(row).addClass('injection-warning')
$('td', row).eq(0).wrapInner('<div class="warning-message-container"></div>')
$('td .warning-message-container', row).eq(0).append('<div class="warning-message">Additional prep fee not injected</div>')
}

return row
Expand Down
2 changes: 1 addition & 1 deletion app/webpack/stylesheets/components/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tr {
.warning-message {
position: absolute;
top: -$govuk-gutter;
width: 320px;
width: 500px;
color: govuk-colour("orange");
text-align: left;
}
Expand Down
9 changes: 6 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2115,11 +2115,14 @@ en:
error: Claim not injected
dismiss: Dismiss this message
cav_warning:
header: 'Warning: conferences and views were not injected'
header: 'Warning: Conferences and views were not injected'
message: 'The provider has claimed conferences and views on this claim, but they have not been injected into CCR. Enter them manually.'
clar_fees_warning:
header: 'Warning: CLAR fees were not injected'
message: 'The provider has claimed Criminal Legal Aid Review fees on this claim, but they have not been injected. Please enter them manually.'
header: 'Warning: Paper heavy case or unused materials fees were not injected'
message: 'The provider has claimed paper heavy case or unused materials fees on this claim, but they have not been injected. Enter them manually.'
additional_prep_fee_warning:
header: 'Warning: Additional preparation fee was not injected'
message: 'The provider has claimed an additional preparation fee on this claim, but it has not been injected. Enter it manually.'

message_controls:
attachment_label: Optionally attach a file
Expand Down
11 changes: 10 additions & 1 deletion spec/api/entities/search_result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
supplementary: 0,
agfs_hardship: 0,
lgfs_hardship: 0,
clar_fees_warning: 0
clar_fees_warning: 0,
additional_prep_fee_warning: 0
}
end

Expand Down Expand Up @@ -200,6 +201,14 @@
include_examples 'returns expected JSON filter values'
end

context 'when passed an advocate claims with an Additional Prep fee and without an injection attempt error' do
let(:claim) { OpenStruct.new('id' => '19932', 'uuid' => 'aec3900f-3e82-4c4f-a7cd-498ad45f11f8', 'scheme' => 'agfs', 'scheme_type' => 'Advocate', 'case_number' => 'T20200824', 'state' => 'submitted', 'court_name' => 'Newcastle', 'case_type' => 'Contempt', 'total' => '426.36', 'disk_evidence' => false, 'external_user' => 'Theodore Schumm', 'maat_references' => '2320144', 'defendants' => 'Junius Lesch', 'fees' => '0.0~Daily attendance fee (3 to 40)~Fee::BasicFeeType, 0.0~Daily attendance fee (41 to 50)~Fee::BasicFeeType, 0.0~Daily attendance fee (51+)~Fee::BasicFeeType, 0.0~Standard appearance fee~Fee::BasicFeeType, 0.0~Plea and case management hearing~Fee::BasicFeeType, 0.0~Conferences and views~Fee::BasicFeeType, 0.0~Number of defendants uplift~Fee::BasicFeeType, 0.0~Number of cases uplift~Fee::BasicFeeType, 0.0~Number of prosecution witnesses~Fee::BasicFeeType, 1.0~Basic fee~Fee::BasicFeeType, 1.0~Additional preparation fee~Fee::MiscFeeType', 'last_submitted_at' => '2020-08-01 09:33:30.932017', 'is_fixed_fee' => false, 'fee_type_code' => 'GRRAK', 'graduated_fee_types' => 'GRTRL,GRRTR,GRGLT,GRDIS,GRRAK,GRCBR', 'injection_errors' => '{"errors":[]}', 'last_injection_succeeded' => 'true') }

before { result.merge!(graduated_fees: 1, additional_prep_fee_warning: 1) }

include_examples 'returns expected JSON filter values'
end

context 'when passed an advocate interim/warrant claim' do
let(:claim) { OpenStruct.new('id' => '179818', 'uuid' => '887cbd94-3f48-4955-8646-918de4db3617', 'case_type' => 'Warrant', 'state' => 'submitted', 'total' => '667.33', 'fees' => '0.0~Warrant Fee~Fee::WarrantFeeType', 'last_submitted_at' => '07/12/2017 12:58:29', 'class_letter' => nil, 'is_fixed_fee' => nil, 'fee_type_code' => nil, 'graduated_fee_types' => 'GRTRL,GRRTR,GRGLT,GRDIS,GRRAK,GRCBR') }

Expand Down
16 changes: 14 additions & 2 deletions spec/javascripts/Modules.AllocationDataTable_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Modules.AllocationDataTable.js', function () {
}
}
const output = options.createdRow(row, data)
expect(output[0].outerHTML).toEqual('<tr class="govuk-table__row injection-warning"><td data-label="Select claim" class="govuk-table__cell"><div class="warning-message-container"><div class="warning-message">CAVs not injected</div></div></td></tr>')
expect(output[0].outerHTML).toEqual('<tr class="govuk-table__row injection-warning"><td data-label="Select claim" class="govuk-table__cell"><div class="warning-message-container"><div class="warning-message">Conference fees not injected</div></div></td></tr>')
})

it('...should have a `createdRow` callback defined for CLAR fee warnings', function () {
Expand All @@ -82,7 +82,19 @@ describe('Modules.AllocationDataTable.js', function () {
}
}
const output = options.createdRow(row, data)
expect(output[0].outerHTML).toEqual('<tr class="govuk-table__row injection-warning"><td data-label="Select claim" class="govuk-table__cell"><div class="warning-message-container"><div class="warning-message">CLAR fees not injected</div></div></td></tr>')
expect(output[0].outerHTML).toEqual('<tr class="govuk-table__row injection-warning"><td data-label="Select claim" class="govuk-table__cell"><div class="warning-message-container"><div class="warning-message">Paper heavy case or unused materials fees not injected</div></div></td></tr>')
})

it('...should have a `createdRow` callback defined for Additional Prep fee warnings', function () {
expect(options.createdRow).toBeDefined()
const row = $('<tr class="govuk-table__row injection-warning"><td data-label="Select claim" class="govuk-table__cell"></td></tr>')
const data = {
filter: {
additional_prep_fee_warning: 1
}
}
const output = options.createdRow(row, data)
expect(output[0].outerHTML).toEqual('<tr class="govuk-table__row injection-warning"><td data-label="Select claim" class="govuk-table__cell"><div class="warning-message-container"><div class="warning-message">Additional prep fee not injected</div></div></td></tr>')
})

it('...should have `processing`', function () {
Expand Down
46 changes: 46 additions & 0 deletions spec/views/case_workers/claims/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,52 @@
end
end

context 'fee injection warnings' do
before do
trial_claim
create(:injection_attempt, claim: @claim)
create(:misc_fee, fee_type:, claim: @claim, quantity: 1, amount: 100.00)
assign(:claim, @claim)
render
end

context 'with CLAR fees' do
let(:fee_type) { build(:misc_fee_type, :miumu) }

it 'displays an injection warning' do
expect(rendered).to have_css('div.js-callout-injection-warning')
end

it 'displays the expected text' do
expect(rendered).to have_text('Warning: Paper heavy case or unused materials fees were not injected')
end
end

context 'with CAV fees' do
let(:fee_type) { build(:misc_fee_type, :bacav) }

it 'displays an injection warning' do
expect(rendered).to have_css('div.js-callout-injection-warning')
end

it 'displays the expected text' do
expect(rendered).to have_text('Warning: Conferences and views were not injected')
end
end

context 'with Additional Prep fee' do
let(:fee_type) { build(:misc_fee_type, :miapf) }

it 'displays an injection warning' do
expect(rendered).to have_css('div.js-callout-injection-warning')
end

it 'displays the expected text' do
expect(rendered).to have_text('Warning: Additional preparation fee was not injected')
end
end
end

def certified_claim
eu = create(:external_user, :advocate, user: create(:user, first_name: 'Stepriponikas', last_name: 'Bonstart'))
@claim = create(:allocated_claim, external_user: eu)
Expand Down

0 comments on commit 1dfa654

Please sign in to comment.