Skip to content

Commit

Permalink
[CPDLP-3968] Amend void declarations service to include ineligible st…
Browse files Browse the repository at this point in the history
…atement line items
  • Loading branch information
leandroalemao committed Jan 28, 2025
1 parent a32712d commit fac7347
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/services/void_participant_declaration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ def make_voided
attr_accessor :participant_declaration

def line_item
participant_declaration.statement_line_items.find_by(state: %w[eligible payable submitted])
participant_declaration.statement_line_items.find_by(state: %w[eligible payable ineligible])
end
end
28 changes: 26 additions & 2 deletions spec/services/void_participant_declaration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@
)
end

it "can be voided" do
let(:line_item) { participant_declaration.statement_line_items.first }

it "updates declaration and line item state to voided" do
subject.call
expect(participant_declaration.reload).to be_voided
expect(line_item.reload).to be_voided
end
end

Expand Down Expand Up @@ -110,14 +113,35 @@
let(:participant_declaration) do
create(
:ect_participant_declaration,
:payable,
:eligible,
cpd_lead_provider:,
participant_profile:,
)
end

let(:line_item) { participant_declaration.statement_line_items.first }

it "updates declaration and line item state to voided" do
subject.call
expect(participant_declaration.reload).to be_voided
expect(line_item.reload).to be_voided
end
end

context "when declaration is ineligible" do
let(:participant_declaration) do
create(
:ect_participant_declaration,
:ineligible,
cpd_lead_provider:,
participant_profile:,
)
end

let(:line_item) { participant_declaration.statement_line_items.first }

before { line_item.ineligible! }

it "updates declaration and line item state to voided" do
subject.call
expect(participant_declaration.reload).to be_voided
Expand Down

0 comments on commit fac7347

Please sign in to comment.