Class: Spree::Api::V2::Operator::RecalculateTicketsController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/operator/recalculate_tickets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/spree/api/v2/operator/recalculate_tickets_controller.rb', line 9

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