-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clawback wizard and functionality to change claim status
- Loading branch information
Showing
16 changed files
with
420 additions
and
8 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
app/controllers/claims/support/claims/request_clawback_controller.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,47 @@ | ||
class Claims::Support::Claims::RequestClawbackController < Claims::ApplicationController | ||
include WizardController | ||
before_action :skip_authorization | ||
before_action :set_claim | ||
before_action :set_wizard | ||
|
||
def new | ||
@wizard.reset_state | ||
redirect_to step_path(@wizard.first_step) | ||
end | ||
|
||
def edit; end | ||
|
||
def update | ||
if !@wizard.save_step | ||
render "edit" | ||
elsif @wizard.next_step.present? | ||
redirect_to step_path(@wizard.next_step) | ||
else | ||
@wizard.update_status | ||
@wizard.reset_state | ||
redirect_to index_path, flash: { | ||
heading: t(".success_heading"), | ||
} | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_claim | ||
@claim = Claims::Claim.find(params[:claim_id]) | ||
end | ||
|
||
def set_wizard | ||
state = session[state_key] ||= {} | ||
current_step = params[:step]&.to_sym | ||
@wizard = Claims::RequestClawbackWizard.new(claim: @claim, params:, state:, current_step:) | ||
end | ||
|
||
def step_path(step) | ||
request_clawback_claims_support_claims_clawbacks_path(state_key:, step:) | ||
end | ||
|
||
def index_path | ||
claims_support_claims_clawbacks_path | ||
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
14 changes: 14 additions & 0 deletions
14
app/views/claims/support/claims/request_clawback/edit.html.erb
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,14 @@ | ||
<%= render "claims/support/primary_navigation", current: :claims %> | ||
<%= content_for(:before_content) do %> | ||
<%= govuk_back_link(href: back_link_path) %> | ||
<% end %> | ||
|
||
<div class="govuk-width-container"> | ||
<span class="govuk-caption-l"><%= t(".caption", reference: @claim.reference) %></span> | ||
|
||
<%= render_wizard(@wizard) %> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t(".cancel"), claims_support_claims_clawbacks_path, no_visited_state: true) %> | ||
</p> | ||
</div> |
47 changes: 47 additions & 0 deletions
47
app/views/wizards/claims/request_clawback_wizard/_check_your_answers_step.html.erb
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,47 @@ | ||
<% content_for(:page_title) { sanitize t(".page_title", school_name: @claim.school_name, reference: @claim.reference) } %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_with(model: current_step, url: current_step_path, method: :put) do |f| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<h1 class="govuk-heading-l"><%= t(".title") %></h1> | ||
|
||
<%= govuk_summary_list do |summary_list| %> | ||
<% summary_list.with_row do |row| %> | ||
<% row.with_key(text: t(".hours")) %> | ||
<% row.with_value %> | ||
<% row.with_action(text: t(".change"), | ||
href: step_path(:clawback), | ||
visually_hidden_text: t(".hours"), | ||
classes: ["govuk-link--no-visited-state"]) %> | ||
<% end %> | ||
<% summary_list.with_row do |row| %> | ||
<% row.with_key(text: t(".rate")) %> | ||
<% row.with_value(text: humanized_money_with_symbol(@claim.school.region.funding_available_per_hour)) %> | ||
<% end %> | ||
<% summary_list.with_row do |row| %> | ||
<% row.with_key(text: t(".amount")) %> | ||
<% row.with_value %> | ||
<% end %> | ||
<% summary_list.with_row do |row| %> | ||
<% row.with_key(text: t(".reason")) %> | ||
<% row.with_value %> | ||
<% row.with_action(text: t(".change"), | ||
href: step_path(:clawback), | ||
visually_hidden_text: t(".reason"), | ||
classes: ["govuk-link--no-visited-state"]) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<div class="govuk-warning-text"> | ||
<span class="govuk-warning-text__icon" aria-hidden="true">!</span> | ||
<strong class="govuk-warning-text__text"><%= t(".warning") %></strong> | ||
</div> | ||
|
||
<%= f.submit t(".submit"), class: "govuk-button" %> | ||
|
||
</div> | ||
</div> | ||
|
||
<% end %> |
26 changes: 26 additions & 0 deletions
26
app/views/wizards/claims/request_clawback_wizard/_clawback_step.html.erb
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,26 @@ | ||
<% content_for(:page_title) { sanitize t(".page_title", school_name: @claim.school_name, reference: @claim.reference) } %> | ||
|
||
<%= form_with(model: current_step, url: current_step_path, method: :put) do |f| %> | ||
<%= f.govuk_error_summary %> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-l"><%= t(".title") %></h1> | ||
|
||
<div class="govuk-form-group"> | ||
<%= f.govuk_text_field :number_of_hours, | ||
width: 2, | ||
label: { text: t(".hours"), size: "s" }, | ||
hint: { text: t(".hours_hint") } %> | ||
</div> | ||
|
||
<div class="govuk-form-group"> | ||
<%= f.govuk_text_area :reason_for_clawback, | ||
width: "govuk-text-area", | ||
label: { text: t(".reason"), size: "s" }, | ||
hint: { text: t(".reason_hint") } %> | ||
</div> | ||
|
||
<%= f.govuk_submit t(".continue") %> | ||
</div> | ||
</div> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Claims | ||
class RequestClawbackWizard < BaseWizard | ||
attr_reader :claim | ||
|
||
def initialize(claim:, params:, state:, current_step: nil) | ||
@claim = claim | ||
super(state:, params:, current_step:) | ||
end | ||
|
||
def define_steps | ||
add_step(ClawbackStep) | ||
add_step(CheckYourAnswersStep) | ||
end | ||
|
||
def update_status | ||
@claim.status = :clawback_requested | ||
@claim.save! | ||
end | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
app/wizards/claims/request_clawback_wizard/check_your_answers_step.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,2 @@ | ||
class Claims::RequestClawbackWizard::CheckYourAnswersStep < BaseStep | ||
end |
10 changes: 10 additions & 0 deletions
10
app/wizards/claims/request_clawback_wizard/clawback_step.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,10 @@ | ||
class Claims::RequestClawbackWizard::ClawbackStep < BaseStep | ||
attribute :number_of_hours, :integer | ||
attribute :reason_for_clawback | ||
|
||
validates :number_of_hours, presence: true, numericality: { only_integer: true, less_than_or_equal_to: 40 } | ||
validates :reason_for_clawback, presence: true | ||
|
||
# TODO: Add methods for assigning attributes to relevant clawback fields on the claim model instance | ||
# TODO: Add tailored error messages to activerecord yml file when attributes are in use | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
en: | ||
claims: | ||
support: | ||
claims: | ||
request_clawback: | ||
update: | ||
success_heading: Clawback requested |
23 changes: 23 additions & 0 deletions
23
config/locales/en/wizards/claims/request_clawback_wizard.yml
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,23 @@ | ||
en: | ||
wizards: | ||
claims: | ||
request_clawback_wizard: | ||
clawback_step: | ||
page_title: Clawback details - %{school_name} - Claim %{reference} | ||
title: Clawback details | ||
hours: Number of hours to clawback | ||
hours_hint: Enter whole numbers up to a maximum of 40 hours | ||
reason: Reason for clawback | ||
reason_hint: Explain why the clawback is being requested. For example, include details of which mentor has received a deduction. | ||
continue: Continue | ||
description: Personal details | ||
check_your_answers_step: | ||
page_title: Check your answers - %{school_name} - Claim %{reference} | ||
title: Check your answers | ||
hours: Number of hours | ||
rate: Hourly rate | ||
amount: Clawback amount | ||
reason: Reason for clawback | ||
submit: Request clawback | ||
warning: We will show clawback details to the school. | ||
change: Change |
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.