Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

London-NonLondon Feature Branch #7263

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9f6d7a0
New migration file to create london_fees column/attribute in Claim mo…
AlexRyanShep Jul 2, 2024
a5b3f15
Create new step definitions and modify existing litigator tests to ch…
AlexRyanShep Jul 5, 2024
dba5019
Add new entries for london fees to en translation file
AlexRyanShep Jul 4, 2024
e38d462
Create new partial and render it in the case details _fields.html.ham…
AlexRyanShep Jul 4, 2024
e312ccd
Add london_fees to allowable params in ClaimsController, radiobuttons…
AlexRyanShep Jul 4, 2024
87b1565
Testing cleanup
AlexRyanShep Jul 15, 2024
a3bb525
Adding feature tests to check for London Fees on the claim summary pa…
AlexRyanShep Jul 16, 2024
8f04f71
Adding new row to Case Details summary form to show London Fee attribute
AlexRyanShep Jul 16, 2024
2cee46d
Refactoring to change london_fees to london_rates_apply
AlexRyanShep Jul 16, 2024
68cb2b6
New tests created for creation and validation of claims through the API
AlexRyanShep Jul 18, 2024
73c761d
Add london_rates_apply to API params
AlexRyanShep Jul 19, 2024
085bb42
Step valdation for london_rates_apply
AlexRyanShep Jul 24, 2024
481707d
API validation working for london_rates_apply
AlexRyanShep Aug 2, 2024
426162d
Step validation unit tests
AlexRyanShep Aug 2, 2024
af40195
Code review
AlexRyanShep Aug 8, 2024
ceacae2
Tests and Rubocop cleanup
AlexRyanShep Aug 2, 2024
3667f2a
London Rates tests refactored to shared examples
AlexRyanShep Aug 8, 2024
6edbfc9
New migration file to create london_fees column/attribute in Claim mo…
AlexRyanShep Jul 2, 2024
07623b3
Wording for review page null scenario amended
AlexRyanShep Aug 12, 2024
39ce1c3
Merge remote-tracking branch 'refs/remotes/origin/CTSKF-486-London-Fe…
AlexRyanShep Aug 20, 2024
cf607e1
Merge remote-tracking branch 'refs/remotes/origin/CTSKF-847-London-Fe…
AlexRyanShep Aug 20, 2024
89f3a79
New request spec for Prices controller
AlexRyanShep Aug 28, 2024
557805c
Implement london_rates_apply into Prices controller
AlexRyanShep Aug 28, 2024
f663b5d
Created feature tests for LGFS misc fees
AlexRyanShep Aug 28, 2024
15eacc8
Implement API call for LGFS MISC Fees
AlexRyanShep Aug 29, 2024
d56b838
Testing cleanup
AlexRyanShep Aug 29, 2024
64256b9
Code review
AlexRyanShep Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/external_users/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def claim_params
:case_type_id,
:case_stage_id,
:offence_id,
:london_rates_apply,
:travel_expense_additional_information,
:first_day_of_trial,
:estimated_trial_length,
Expand Down
1 change: 1 addition & 0 deletions app/controllers/external_users/fees/prices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def calculator_params
:claim_id,
:fee_type_id,
:advocate_category,
:london_rates_apply,
:ppe,
:pw,
:days,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module API
module CustomValidations
class OptionalBooleanValidation < Grape::Validations::Validators::Base
def validate_param!(attr_name, params)
london_rates_apply = params[attr_name]

raise ArgumentError unless london_rates_apply.nil? || london_rates_apply.in?([true, false])
rescue ArgumentError
raise Grape::Exceptions::Validation.new(params: [@scope.full_name(attr_name)],
message: 'must be true, false or nil')
end
end
end
end
1 change: 1 addition & 0 deletions app/interfaces/api/helpers/api_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module API
module Helpers
module APIHelper
require_relative '../custom_validations/standard_json_format'
require_relative '../custom_validations/optional_boolean_validation'
require_relative '../api_response'
require_relative '../error_response'

Expand Down
4 changes: 4 additions & 0 deletions app/interfaces/api/v1/claim_params_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ module ClaimParamsHelper
optional :supplier_number, type: String, desc: 'REQUIRED. The supplier number.'
optional :transfer_court_id, type: Integer, desc: 'OPTIONAL: The unique identifier for the transfer court.'
optional :transfer_case_number, type: String, desc: 'OPTIONAL: The case number or URN for the transfer court.'
optional :london_rates_apply,
type: Boolean,
desc: 'OPTIONAL: Whether the firm for the claim is based in a London borough or not',
optional_boolean_validation: true
end

params :legacy_agfs_params do
Expand Down
4 changes: 3 additions & 1 deletion app/services/claims/fee_calculator/calculate_price.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def setup(options)
@pages_of_prosecuting_evidence = options[:pages_of_prosecuting_evidence] || claim.prosecution_evidence
@quantity = options[:quantity] || 1
@current_page_fees = options[:fees].values
@london_rates_apply = claim.london_rates_apply
exclusions
rescue StandardError
raise Exceptions::InsufficientData
Expand Down Expand Up @@ -136,7 +137,8 @@ def fee_type_mappings
end

def fee_type_code_for(fee_type)
return 'LIT_FEE' if lgfs?
# For LGFS Misc Fees, use fee type mappings. For all other LGFS fees, return LIT_FEE
return 'LIT_FEE' if lgfs? & !fee_type.is_a?(Fee::MiscFeeType)
fee_type = case_uplift_parent if fee_type.case_uplift?
fee_type = defendant_uplift_parent if fee_type.defendant_uplift?
fee_type_mappings.all[fee_type&.unique_code&.to_sym][:bill_subtype]
Expand Down
7 changes: 5 additions & 2 deletions app/services/claims/fee_calculator/unit_price.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ def amount
end

def price_options
opts = {}
opts[:scenario] = scenario.id
opts = { scenario: scenario.id }
opts[:offence_class] = offence_class_or_default
opts[:advocate_type] = advocate_type
opts[:fee_type_code] = fee_type_code_for(fee_type)
opts[:limit_from] = limit_from
opts[:limit_to] = limit_to
opts[:unit] = unit
opts.keep_if { |_k, v| v.present? }
# Filter above will filter out false, which is a valid value for london_rates_apply
# Only send london_rates_apply to requests for Misc Fees where it is not nil
opts[:london_rates_apply] = @london_rates_apply if !@london_rates_apply.nil? && fee_type.is_a?(Fee::MiscFeeType)
opts
end

def unit_price
Expand Down
4 changes: 4 additions & 0 deletions app/validators/base_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def validate_boolean_presence(attribute, message)
add_error(attribute, message) if attr_nil?(attribute)
end

def validate_optional_boolean(attribute, message)
add_error(attribute, message) unless @record.__send__(attribute).in? [true, false, nil]
end

def validate_max_length(attribute, length, message)
add_error(attribute, message) if @record.__send__(attribute).to_s.size > length
end
Expand Down
5 changes: 5 additions & 0 deletions app/validators/claim/base_claim_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def validate_creator
validate_presence(:creator, 'blank') unless @record.errors.key?(:creator)
end

# optional, must be boolean if present
def validate_london_rates_apply
validate_optional_boolean(:london_rates_apply, :not_boolean_or_nil)
end

# object must be present
def validate_case_type_id
validate_belongs_to_object_presence(:case_type, :blank)
Expand Down
1 change: 1 addition & 0 deletions app/validators/claim/interim_claim_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def self.fields_for_steps
case_type_id
court_id
case_number
london_rates_apply
case_transferred_from_another_court
transfer_court_id
transfer_case_number
Expand Down
1 change: 1 addition & 0 deletions app/validators/claim/litigator_claim_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def self.fields_for_steps
case_details: %i[
case_type_id
court_id
london_rates_apply
case_number
case_transferred_from_another_court
transfer_court_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def self.fields_for_steps
case_stage_id
court_id
case_number
london_rates_apply
case_transferred_from_another_court
transfer_court_id
transfer_case_number
Expand Down
1 change: 1 addition & 0 deletions app/validators/claim/transfer_claim_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def self.fields_for_steps
case_details: %i[
court_id
case_number
london_rates_apply
case_transferred_from_another_court
transfer_court_id
transfer_case_number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
label: { text: t('common.external_user.providers_ref') },
width: 'one-half'

- if @claim.lgfs?
= render partial: 'external_users/claims/case_details/london_rates', locals: { f: f }

- if @claim.requires_case_type?
= render partial: 'external_users/claims/case_details/case_type_fields', locals: { f: f }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.london-rates{ id: 'london-rates' }
= f.govuk_radio_buttons_fieldset :london_rates_apply, legend: { size: 'm', text: t('.london_rates_title') }, hint: { text: t('.london_rates_hint') } do
= f.govuk_radio_button :london_rates_apply, true, label: { text: t('global_yes') }
= f.govuk_radio_button :london_rates_apply, false, label: { text: t('global_no') }

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
.unique-id-small
= claim.unique_id

- if claim.lgfs?
= govuk_summary_list_row_collection( t('external_users.claims.case_details.london_rates.london_rates') ) do
= t("external_users.claims.case_details.london_rates.london_rates_#{claim.london_rates_apply}")

- if claim.transfer_court.present?
= govuk_summary_list_row_collection( t('common.transfer_court') ) { claim.transfer_court.name if claim.transfer_court }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
.form-section.misc-fee-group.nested-fields.js-block.fx-do-init.fx-fee-group.fx-numberedList-item{ data: { 'type': 'miscFees', autovat: @claim.apply_vat? ? 'true' : 'false' } }
- fee = present(f.object)
- claim = present(f.object.claim)

.form-section.misc-fee-group.nested-fields.js-block.fx-do-init.fx-fee-group.fx-numberedList-item{ data: { 'type': 'miscFees', autovat: @claim.apply_vat? ? 'true' : 'false', 'block-type': 'FeeBlockCalculator' } }

= f.govuk_fieldset legend: { text: t('.misc_fee_html') } do

= link_to_remove_association f, wrapper_class: 'misc-fee-group', class: 'govuk-link govuk-!-display-none fx-numberedList-action' do
= t('common.remove_html', context: t('.misc_fee'))

= f.govuk_radio_buttons_fieldset(:fee_type_id, form_group: {class: 'fee-type'}, legend: { size: 's', text: t('.fee_type') }) do
- present_collection(@claim.eligible_misc_fee_types).each do |misc_fee_type|
= f.govuk_radio_button :fee_type_id,
misc_fee_type.id,
label: { text: misc_fee_type.description },
'data-unique-code': misc_fee_type.unique_code do
- if misc_fee_type.unique_code.eql?('MIUMO')
= render 'warnings/unused_material_over_3_hours'

= f.govuk_number_field :amount,
label: { text: t('.net_amount_html', context: t('.misc_fee')) },
class: 'total fee-rate',
= f.govuk_collection_select :fee_type_id,
claim.eligible_misc_fee_type_options_for_select.map{ |ft| [ft.first, ft.second, { 'data-unique-code': ft.third[:data][:unique_code] }] },
:second,
:first,
class: 'js-misc-fee-type js-fee-type js-fee-calculator-fee-type fx-misc-fee-calculation',
form_group: { class: 'fee-type fx-autocomplete-wrapper cc-fee-type' },
label: { text: t('.fee_type_html', context: t('.misc_fee')), size: 's' },
options: { include_blank: '' }

.form-group.fx-unused-materials-warning.js-hidden
= render 'warnings/unused_material_over_3_hours'

=f.govuk_number_field :quantity,
class: 'quantity fee-quantity js-fee-quantity js-fee-calculator-quantity',
form_group: { class: 'quantity_wrapper' },
hint: { text: t('.quantity_hint'), hidden: true },
label: { text: t('.quantity_html', context: t('.misc_fee')), size: 's' },
value: fee.quantity,
width: 5

=f.govuk_number_field :rate,
class: 'rate fee-rate js-fee-calculator-rate',
form_group: { class: 'js-unit-price-effectee calculated-unit-fee' },
label: { text: t('.rate_html', context: t('.misc_fee')), size: 's' },
prefix_text: '£',
value: number_with_precision(f.object.amount, precision: 2),
width: 'one-quarter'
readonly: f.object.price_calculated?,
value: number_with_precision(f.object.rate, precision: 2),
width: 5

= f.govuk_text_field :price_calculated,
form_group: { class: 'js-fee-calculator-success' },
label: { hidden: true },
type: 'hidden',
value: f.object.price_calculated?

.fee-calc-help-wrapper.hidden
= govuk_detail t('.help_how_we_calculate_rate_title') do
= t('.help_how_we_calculate_rate_body')

= govuk_summary_list_no_border do
= govuk_summary_list_row do
= govuk_summary_list_key do
= t('.net_amount')

= govuk_summary_list_value(class: 'fee-net-amount currency-indicator total') do
= fee.amount || number_to_currency(0)
4 changes: 4 additions & 0 deletions app/views/shared/_claim.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
%span.unique-id-small
= claim.unique_id

- if claim.lgfs?
= govuk_summary_list_row_collection( t('external_users.claims.case_details.london_rates.london_rates') ) do
= t("external_users.claims.case_details.london_rates.london_rates_#{claim.london_rates_apply}")

- if claim.transfer_court.present?
= govuk_summary_list_row_collection(t('common.transfer_court')) do
= claim.transfer_court.name
Expand Down
15 changes: 15 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,13 @@ en:
offence_class: 'Offence class'
offence_category: 'Offence category'
select_category: 'Please select'
london_rates:
london_rates: "London fee rates"
london_rates_true: "This claim qualifies for London fee rates"
london_rates_false: "This claim does not qualify for London fee rates"
london_rates_: "This information has not been provided"
london_rates_title: "Is the firm based in a London borough?"
london_rates_hint: "We need to know this to check the correct rates have been used in your application"
offence_select:
offence_class: 'Offence class'
select_offence_class: 'Please select'
Expand Down Expand Up @@ -1527,14 +1534,22 @@ en:
or <a href="https://www.gov.uk/government/publications/lf1-claim-litigator-fees" class="govuk-link" rel="noreferrer noopener" target="_blank">unused materials (over 3 hours) form <span class="govuk-visually-hidden">(opens in new tab)</span></a>
and attach to the claim.
misc_fee_fields:
quantity: *quantity
quantity_hint: Enter a quantity
quantity_html: Quantity <span class="govuk-visually-hidden">for %{context} <span class="fx-numberedList-number"></span></span>
rate: Rate
rate_html: Rate <span class="govuk-visually-hidden">in pounds for %{context} <span class="fx-numberedList-number"></span></span>
misc_fee: *miscellaneous_fee
misc_fee_html: 'Miscellaneous fees <span class="fx-numberedList-number"></span>'
fee_type: *fee_type
case_numbers: *case_numbers
fee_type_html: Type of fee <span class="govuk-visually-hidden">for %{context} <span class="fx-numberedList-number"></span></span>
type_of_fee_html: '%{context} <span class="govuk-visually-hidden">for miscellaneous fee <span class="fx-numberedList-number"></span></span>'
net_amount: *net_amount
net_amount_html: Net amount <span class="govuk-visually-hidden">in pounds for %{context} <span class="fx-numberedList-number"></span></span>
remove: "Remove"
help_how_we_calculate_rate_title: *how_is_this_calculated_help
help_how_we_calculate_rate_body: We calculate the rate based upon the fee scheme and fee_type.
summary:
header: *miscellaneous_fees
financial_summary:
Expand Down
9 changes: 8 additions & 1 deletion config/locales/en/error_messages/claim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ supplier_number:
short: _
api: Supplier number is unknown

london_rates_apply:
_seq: 6
not_boolean_or_nil:
long: Choose True or False to indicate if your firm is based inside a London Borough
short: _
api: london_rates_apply is not in an acceptable format - choose true, false or nil

external_user_id:
_seq: 10
choose_an_advocate:
Expand Down Expand Up @@ -1061,7 +1068,7 @@ misc_fee:
enter_a_valid_quantity_(1)_for_additional_preparation_hearing:
long: 'Enter a valid quantity (1) for additional preparation hearing'
short: _
api: Enter a valid quantity (1) for additional preparation hearing
api: Enter a valid quantity (1) for additional preparation hearing
the_amount_for_the_miscellaneous_fee_exceeds_the_limit:
long: The amount for the miscellaneous fee exceeds the limit
short: _
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en/models/claim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ en:
invalid: Enter a valid legal aid transfer date
invalid_date: Enter a valid legal aid transfer date
present: The date legal aid was transferred is not allowed
london_rates_apply:
not_boolean_or_nil: london_rates_apply is not in an acceptable format - choose true, false or nil
main_hearing_date:
check_not_too_far_in_past: Main hearing date cannot be too far in the past
misc_fees:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddLondonFeesAttributeToClaims < ActiveRecord::Migration[7.0]
def change
add_column :claims, :london_fees, :boolean, null: true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddLondonRatesApplyAttributeToClaims < ActiveRecord::Migration[7.0]
def change
add_column :claims, :london_rates_apply, :boolean, null: true
end
end
Loading