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

close #2129 fix calculate ticket flow #2158

Merged
merged 1 commit into from
Dec 19, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Spree
module Api
module V2
module Operator
class RecalculateTicketsController < ::Spree::Api::V2::ResourceController
before_action :require_spree_current_user, only: :create
before_action :load_taxon, only: :create

def create
classification_ids = Spree::Classification.joins(:taxon)
.where(spree_taxons: { id: @taxons.pluck(:id) })
.pluck(:id)

classification_ids.each do |classification_id|
SpreeCmCommissioner::ConversionPreCalculator.call(product_taxon: Spree::Classification.find(classification_id))
end

render json: { message: 'Conversions recalculated successfully' }, status: :ok
end

private

def load_taxon
parent_taxon = Spree::Taxon.find(params[:taxon_id])
@taxons = parent_taxon.children
end
end
end
end
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@
resource :check_in_bulks, only: %i[index create]
resources :dashboard_crew_events, only: %i[index]
resources :event_qrs, only: [:show]
resources :recalculate_tickets, only: [:create]
resources :taxons, only: %i[show] do
resource :event_ticket_aggregators, only: %i[show]
resource :pie_chart_event_aggregators, only: %i[show]
Expand Down
Loading