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

Add all claim statuses and handle their display #1193

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions app/components/claim/status_tag_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 10 additions & 0 deletions app/models/claims/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions config/locales/en/components/claim/status_tag_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
90 changes: 89 additions & 1 deletion spec/components/claim/status_tag_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand All @@ -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

Expand Down
15 changes: 14 additions & 1 deletion spec/helpers/claims/claim_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions spec/models/claims/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down