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

Do no create annulation invoice when state is applied (#1550) #1614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions app/controllers/sac_cas/event/participations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ module SacCas::Event::ParticipationsController
after_summon :enqueue_invoice_job
after_assign :enqueue_confirmation_job # send_confirmation_email in core checks current_user_interested_in_mail? which should be irrelevant here
before_cancel :assert_participant_cancelable?
after_cancel :cancel_invoices
end

def cancel
cancel_invoices
entry.cancel_statement = params.dig(:event_participation, :cancel_statement)
entry.canceled_at = params.dig(:event_participation, :canceled_at) || Time.zone.today
entry.canceled_at = Time.zone.today if participant_cancels?
Expand Down Expand Up @@ -182,6 +182,6 @@ def cancel_invoices
Invoices::Abacus::CancelInvoiceJob.new(invoice).enqueue!
end

ExternalInvoice::CourseAnnulation.invoice!(entry)
ExternalInvoice::CourseAnnulation.invoice!(entry) unless entry.state == "applied"
end
end
9 changes: 9 additions & 0 deletions spec/controllers/event/participations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,15 @@
expect(invoice.state).to eq("draft")
expect(invoice.year).to eq(event.dates.first.start_at.year)
end

it "PUT#cancel does not create course annulation invoice when participation state is applied" do
participation.update!(price: 10, price_category: :price_regular)
participation.update_column(:state, :applied)

expect do
put :cancel, params: params.merge({event_participation: {canceled_at: 1.day.ago}})
end.not_to change { ExternalInvoice::CourseAnnulation.count }
end
end

describe "PUT#update" do
Expand Down
Loading