Class: Spree::Exchanges::Create
- Includes:
- Refunds::TaxCredit, Returns::ReturnableQuantity
- Defined in:
- app/workflows/spree/exchanges/create.rb
Overview
Opens an exchange request: items coming back, and what should go out in their place.
Instance Attribute Summary collapse
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
Instance Method Summary collapse
Methods inherited from Workflow
#call, define_argument_readers, #errors, #halt!, hooks, inherited, model_name, #read_attribute_for_validation, #reject!, workflow_key
Methods included from ServiceModule::Base
Methods included from Workflow::ControlFlow
Instance Attribute Details
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
11 12 13 |
# File 'app/workflows/spree/exchanges/create.rb', line 11 def exchange @exchange end |
Instance Method Details
#perform(order:, items:, stock_location: nil, reason: nil, memo: nil, created_by: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/workflows/spree/exchanges/create.rb', line 19 def perform(order:, items:, stock_location: nil, reason: nil, memo: nil, created_by: nil) super step :ensure_exchangeable step :normalize_items run_hooks :validate ApplicationRecord.transaction do step :build_exchange step :calculate_tax end run_hooks :after_create exchange.publish_event('exchange.requested') success(exchange.reload) end |