Skip to content

Commit

Permalink
WIP #2129 fix calculate ticket flow
Browse files Browse the repository at this point in the history
  • Loading branch information
LengTech11 committed Dec 17, 2024
1 parent f17c557 commit fa71ad1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Spree
module Api
module V2
module Operator
class RecalculateTicketController < ::Spree::Api::V2::ResourceController
before_action :require_spree_current_user, only: :create
before_action :load_taxon, only: :create

def create
@taxons.each do |taxon|
taxon.products.each do |product|
product.classification_ids.each do |classification_id|
SpreeCmCommissioner::ConversionPreCalculator.call(product_taxon: Spree::Classification.find(classification_id))
end
end
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 @@ -487,6 +487,7 @@
resources :taxons, only: %i[show] do
resource :event_ticket_aggregators, only: %i[show]
resource :pie_chart_event_aggregators, only: %i[show]
resources :recalculate_ticket, only: [:create]
end
end
end
Expand Down

0 comments on commit fa71ad1

Please sign in to comment.