From c3253db44ff3e63f49074530c321034fca1069ac Mon Sep 17 00:00:00 2001 From: Daniel Dye Date: Wed, 20 Nov 2024 21:42:14 +0000 Subject: [PATCH] Add all claim statuses and handle their display --- app/components/claim/status_tag_component.rb | 14 ++- app/models/claims/claim.rb | 10 +++ .../components/claim/status_tag_component.yml | 12 +++ ...all_claim_statuses_to_claim_status_enum.rb | 14 +++ db/schema.rb | 4 +- .../claim/status_tag_component_spec.rb | 90 ++++++++++++++++++- spec/helpers/claims/claim_helper_spec.rb | 15 +++- spec/models/claims/claim_spec.rb | 10 +++ 8 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20241120213146_add_all_claim_statuses_to_claim_status_enum.rb diff --git a/app/components/claim/status_tag_component.rb b/app/components/claim/status_tag_component.rb index 5d93841cf..d83065f5d 100644 --- a/app/components/claim/status_tag_component.rb +++ b/app/components/claim/status_tag_component.rb @@ -8,7 +8,7 @@ def initialize(claim:, classes: [], html_attributes: {}) end def call - govuk_tag(text: claim.status.humanize, colour:) + govuk_tag(text: t(".#{claim.status}"), colour:) end private @@ -26,7 +26,17 @@ def status_colours internal_draft: "grey", draft: "grey", submitted: "blue", - payment_in_progress: "light-blue", + payment_in_progress: "turquoise", + payment_information_requested: "light-blue", + payment_information_sent: "yellow", + paid: "green", + payment_not_approved: "red", + sampling_in_progress: "purple", + sampling_provider_not_approved: "pink", + sampling_not_approved: "pink", + clawback_requested: "orange", + clawback_in_progress: "orange", + clawback_complete: "red", }.with_indifferent_access end end diff --git a/app/models/claims/claim.rb b/app/models/claims/claim.rb index 963e8a71e..4a00eea1c 100644 --- a/app/models/claims/claim.rb +++ b/app/models/claims/claim.rb @@ -70,6 +70,16 @@ class Claims::Claim < ApplicationRecord draft: "draft", submitted: "submitted", payment_in_progress: "payment_in_progress", + payment_information_requested: "payment_information_requested", + payment_information_sent: "payment_information_sent", + paid: "paid", + payment_not_approved: "payment_not_approved", + sampling_in_progress: "sampling_in_progress", + sampling_provider_not_approved: "sampling_provider_not_approved", + sampling_not_approved: "sampling_not_approved", + clawback_requested: "clawback_requested", + clawback_in_progress: "clawback_in_progress", + clawback_complete: "clawback_complete", }, validate: true diff --git a/config/locales/en/components/claim/status_tag_component.yml b/config/locales/en/components/claim/status_tag_component.yml index f5ae939c5..86bee710d 100644 --- a/config/locales/en/components/claim/status_tag_component.yml +++ b/config/locales/en/components/claim/status_tag_component.yml @@ -2,5 +2,17 @@ en: components: claim: status_tag_component: + internal_draft: Internal draft draft: Draft submitted: Submitted + payment_in_progress: Payment in progress + payment_information_requested: Information requested + payment_information_sent: Information sent + paid: Paid + payment_not_approved: Payment not approved + sampling_in_progress: Sampling in progress + sampling_provider_not_approved: Provider not approved + sampling_not_approved: Claim not approved + clawback_requested: Clawback requested + clawback_in_progress: Clawback in progress + clawback_complete: Clawback complete diff --git a/db/migrate/20241120213146_add_all_claim_statuses_to_claim_status_enum.rb b/db/migrate/20241120213146_add_all_claim_statuses_to_claim_status_enum.rb new file mode 100644 index 000000000..d9e67e362 --- /dev/null +++ b/db/migrate/20241120213146_add_all_claim_statuses_to_claim_status_enum.rb @@ -0,0 +1,14 @@ +class AddAllClaimStatusesToClaimStatusEnum < ActiveRecord::Migration[7.2] + def change + add_enum_value :claim_status, "payment_information_requested" + add_enum_value :claim_status, "payment_information_sent" + add_enum_value :claim_status, "paid" + add_enum_value :claim_status, "payment_not_approved" + add_enum_value :claim_status, "sampling_in_progress" + add_enum_value :claim_status, "sampling_provider_not_approved" + add_enum_value :claim_status, "sampling_not_approved" + add_enum_value :claim_status, "clawback_requested" + add_enum_value :claim_status, "clawback_in_progress" + add_enum_value :claim_status, "clawback_complete" + end +end diff --git a/db/schema.rb b/db/schema.rb index 609541036..c03c89730 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,14 +10,14 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_10_16_120228) do +ActiveRecord::Schema[7.2].define(version: 2024_11_20_213146) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" enable_extension "plpgsql" # Custom types defined in this database. # Note that some types may not work with other database engines. Be careful if changing database. - create_enum "claim_status", ["internal_draft", "draft", "submitted", "payment_in_progress"] + create_enum "claim_status", ["internal_draft", "draft", "submitted", "payment_in_progress", "payment_information_requested", "payment_information_sent", "paid", "payment_not_approved", "sampling_in_progress", "sampling_provider_not_approved", "sampling_not_approved", "clawback_requested", "clawback_in_progress", "clawback_complete"] create_enum "mentor_training_type", ["refresher", "initial"] create_enum "placement_status", ["draft", "published"] create_enum "placement_year_group", ["nursery", "reception", "year_1", "year_2", "year_3", "year_4", "year_5", "year_6"] diff --git a/spec/components/claim/status_tag_component_spec.rb b/spec/components/claim/status_tag_component_spec.rb index e31d4cd91..174e165a4 100644 --- a/spec/components/claim/status_tag_component_spec.rb +++ b/spec/components/claim/status_tag_component_spec.rb @@ -7,6 +7,14 @@ render_inline(component) end + context "when the claim's status is 'internal_draft'" do + let(:claim) { build(:claim, status: :internal_draft) } + + it "renders a grey tag" do + expect(page).to have_css(".govuk-tag--grey", text: "Internal draft") + end + end + context "when the claim's status is 'draft'" do let(:claim) { build(:claim, status: :draft) } @@ -26,8 +34,88 @@ context "when the claim's status is 'payment_in_progress'" do let(:claim) { build(:claim, status: :payment_in_progress) } + it "renders a turquoise tag" do + expect(page).to have_css(".govuk-tag--turquoise", text: "Payment in progress") + end + end + + context "when the claim's status is 'payment_information_requested'" do + let(:claim) { build(:claim, status: :payment_information_requested) } + it "renders a light blue tag" do - expect(page).to have_css(".govuk-tag--light-blue", text: "Payment in progress") + expect(page).to have_css(".govuk-tag--light-blue", text: "Information requested") + end + end + + context "when the claim's status is 'payment_information_sent'" do + let(:claim) { build(:claim, status: :payment_information_sent) } + + it "renders a yellow tag" do + expect(page).to have_css(".govuk-tag--yellow", text: "Information sent") + end + end + + context "when the claim's status is 'paid'" do + let(:claim) { build(:claim, status: :paid) } + + it "renders a green tag" do + expect(page).to have_css(".govuk-tag--green", text: "Paid") + end + end + + context "when the claim's status is 'payment_not_approved'" do + let(:claim) { build(:claim, status: :payment_not_approved) } + + it "renders a red tag" do + expect(page).to have_css(".govuk-tag--red", text: "Payment not approved") + end + end + + context "when the claim's status is 'sampling_in_progress'" do + let(:claim) { build(:claim, status: :sampling_in_progress) } + + it "renders a purple tag" do + expect(page).to have_css(".govuk-tag--purple", text: "Sampling in progress") + end + end + + context "when the claim's status is 'sampling_provider_not_approved'" do + let(:claim) { build(:claim, status: :sampling_provider_not_approved) } + + it "renders a pink tag" do + expect(page).to have_css(".govuk-tag--pink", text: "Provider not approved") + end + end + + context "when the claim's status is 'sampling_not_approved'" do + let(:claim) { build(:claim, status: :sampling_not_approved) } + + it "renders a pink tag" do + expect(page).to have_css(".govuk-tag--pink", text: "Claim not approved") + end + end + + context "when the claim's status is 'clawback_requested'" do + let(:claim) { build(:claim, status: :clawback_requested) } + + it "renders a orange tag" do + expect(page).to have_css(".govuk-tag--orange", text: "Clawback requested") + end + end + + context "when the claim's status is 'clawback_in_progress'" do + let(:claim) { build(:claim, status: :clawback_in_progress) } + + it "renders a orange tag" do + expect(page).to have_css(".govuk-tag--orange", text: "Clawback in progress") + end + end + + context "when the claim's status is 'clawback_complete'" do + let(:claim) { build(:claim, status: :clawback_complete) } + + it "renders a red tag" do + expect(page).to have_css(".govuk-tag--red", text: "Clawback complete") end end diff --git a/spec/helpers/claims/claim_helper_spec.rb b/spec/helpers/claims/claim_helper_spec.rb index 83cd7f1df..fddd12704 100644 --- a/spec/helpers/claims/claim_helper_spec.rb +++ b/spec/helpers/claims/claim_helper_spec.rb @@ -3,7 +3,20 @@ RSpec.describe Claims::ClaimHelper do describe "#claim_statuses_for_selection" do it "returns an array of claims statuses, except draft statuses" do - expect(claim_statuses_for_selection).to contain_exactly("submitted", "payment_in_progress") + expect(claim_statuses_for_selection).to contain_exactly( + "submitted", + "payment_in_progress", + "payment_information_requested", + "payment_information_sent", + "paid", + "payment_not_approved", + "sampling_in_progress", + "sampling_provider_not_approved", + "sampling_not_approved", + "clawback_requested", + "clawback_in_progress", + "clawback_complete", + ) end end end diff --git a/spec/models/claims/claim_spec.rb b/spec/models/claims/claim_spec.rb index 8a5c78b31..f4db67ca7 100644 --- a/spec/models/claims/claim_spec.rb +++ b/spec/models/claims/claim_spec.rb @@ -96,6 +96,16 @@ draft: "draft", submitted: "submitted", payment_in_progress: "payment_in_progress", + payment_information_requested: "payment_information_requested", + payment_information_sent: "payment_information_sent", + paid: "paid", + payment_not_approved: "payment_not_approved", + sampling_in_progress: "sampling_in_progress", + sampling_provider_not_approved: "sampling_provider_not_approved", + sampling_not_approved: "sampling_not_approved", + clawback_requested: "clawback_requested", + clawback_in_progress: "clawback_in_progress", + clawback_complete: "clawback_complete", ) .backed_by_column_of_type(:enum) end