From c37f7e701a89448b81a1b7913f5944957d18259c Mon Sep 17 00:00:00 2001 From: Felix Clack Date: Tue, 2 Jul 2024 09:59:26 +0100 Subject: [PATCH] Add a task for checking arrival date We want to confirm the date of entry provided is eligible for an IRP claim. --- app/models/claim_checking_tasks.rb | 3 ++- .../admin_tasks_presenter.rb | 6 +++++ app/models/task.rb | 1 + app/views/admin/tasks/arrival_date.html.erb | 25 +++++++++++++++++++ config/initializers/date_formats.rb | 1 + config/locales/en.yml | 4 +++ .../eligibilities.rb | 5 ++++ ...dmin_view_claim_feature_shared_examples.rb | 2 +- 8 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 app/views/admin/tasks/arrival_date.html.erb diff --git a/app/models/claim_checking_tasks.rb b/app/models/claim_checking_tasks.rb index f1725845fa..6cce65f32a 100644 --- a/app/models/claim_checking_tasks.rb +++ b/app/models/claim_checking_tasks.rb @@ -12,7 +12,7 @@ def initialize(claim) delegate :policy, to: :claim def applicable_task_names - return ["identity_confirmation", "visa"] if policy.international_relocation_payments? + return %w[identity_confirmation visa arrival_date] if policy.international_relocation_payments? @applicable_task_names ||= Task::NAMES.dup.tap do |task_names| task_names.delete("induction_confirmation") unless claim.policy == Policies::EarlyCareerPayments @@ -22,6 +22,7 @@ def applicable_task_names task_names.delete("matching_details") unless matching_claims.exists? task_names.delete("payroll_gender") unless claim.payroll_gender_missing? || task_names_for_claim.include?("payroll_gender") task_names.delete("visa") unless claim.policy.international_relocation_payments? + task_names.delete("arrival_date") unless claim.policy.international_relocation_payments? end end diff --git a/app/models/policies/international_relocation_payments/admin_tasks_presenter.rb b/app/models/policies/international_relocation_payments/admin_tasks_presenter.rb index 9e7f35fddd..0515388e16 100644 --- a/app/models/policies/international_relocation_payments/admin_tasks_presenter.rb +++ b/app/models/policies/international_relocation_payments/admin_tasks_presenter.rb @@ -9,6 +9,12 @@ def initialize(claim) @claim = claim end + def arrival_date + [ + ["Arrival date", eligibility.date_of_entry.to_fs(:govuk_date)] + ] + end + def identity_confirmation [ ["Nationality", eligibility.nationality], diff --git a/app/models/task.rb b/app/models/task.rb index b2d48af068..289eb29061 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -18,6 +18,7 @@ class Task < ApplicationRecord payroll_details matching_details payroll_gender + arrival_date visa ].freeze diff --git a/app/views/admin/tasks/arrival_date.html.erb b/app/views/admin/tasks/arrival_date.html.erb new file mode 100644 index 0000000000..1fbe12d7b3 --- /dev/null +++ b/app/views/admin/tasks/arrival_date.html.erb @@ -0,0 +1,25 @@ +<% content_for(:page_title) { page_title("Claim #{@claim.reference} arrival date check for #{@claim.policy.short_name}") } %> +<%= link_to "Back", admin_claim_tasks_path(claim_id: @claim.id), class: "govuk-back-link" %> +<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %> + +
+ <%= render "claim_summary", claim: @claim, heading: "Arrival date" %> + +
+

<%= @current_task_name.humanize %>

+
+ +
+ <%= render "admin/claims/answers", answers: @tasks_presenter.arrival_date %> +
+ +
+ <% if !@task.passed.nil? %> + <%= render "task_outcome", task: @task %> + <% else %> + <%= render "form", task_name: "arrival_date", claim: @claim %> + <% end %> + + <%= render partial: "admin/task_pagination" %> +
+
diff --git a/config/initializers/date_formats.rb b/config/initializers/date_formats.rb index f1d9822d94..b881d0c7e7 100644 --- a/config/initializers/date_formats.rb +++ b/config/initializers/date_formats.rb @@ -1 +1,2 @@ DateTime::DATE_FORMATS[:custom_ordinal] = lambda { |time| time.strftime("%A #{time.day.ordinalize} %B %Y") } +DateTime::DATE_FORMATS[:govuk_date] = lambda { |time| time.strftime("%d-%m-%Y") } diff --git a/config/locales/en.yml b/config/locales/en.yml index d989bfee03..98f52827ee 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -121,6 +121,7 @@ en: claim_route_with_tid: "Signed in with DfE Identity" passport_number: "Passport number" nationality: "Nationality" + arrival_date: "Date of entry" decision: created_at: "Created at" result: "Result" @@ -154,6 +155,7 @@ en: payroll_details: "Check bank/building society account details" census_subjects_taught: "Check eligible subjects are taught" visa: "Check visa" + arrival_date: "Check arrival date" undo_decision: approved: "Undo approval" rejected: "Undo rejection" @@ -783,6 +785,8 @@ en: title: "Did %{claim_full_name} submit the claim?" visa: title: "Is the claimant’s visa type eligible for a claim?" + arrival_date: + title: "Does the claimant’s arrival date match the above information from their claim?" further_education_payments: landing_page: Find out if you are eligible for any incentive payments for further education teachers diff --git a/spec/factories/policies/international_relocation_payments/eligibilities.rb b/spec/factories/policies/international_relocation_payments/eligibilities.rb index 305c19a952..8f33b3116a 100644 --- a/spec/factories/policies/international_relocation_payments/eligibilities.rb +++ b/spec/factories/policies/international_relocation_payments/eligibilities.rb @@ -6,6 +6,7 @@ end trait :eligible do + eligible_date_of_entry eligible_home_office eligible_school end @@ -13,5 +14,9 @@ trait :eligible_school do association :current_school, factory: :school end + + trait :eligible_date_of_entry do + date_of_entry { 1.year.ago } + end end end diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb index 60616d168c..01a85ea19e 100644 --- a/spec/support/admin_view_claim_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_feature_shared_examples.rb @@ -179,7 +179,7 @@ def expect_page_to_have_policy_sections(policy) when Policies::EarlyCareerPayments ["Identity confirmation", "Qualifications", "Induction confirmation", "Census subjects taught", "Employment", "Student loan plan", "Decision"] when Policies::InternationalRelocationPayments - ["Identity confirmation", "Visa", "Decision"] + ["Identity confirmation", "Visa", "Arrival date", "Decision"] else raise "Unimplemented policy: #{policy}" end