Class: Spree::PurchaseOrders::Create
- Defined in:
- app/workflows/spree/purchase_orders/create.rb
Overview
Drafts an order to a supplier. Nothing is on order yet and nothing touches availability — a draft is what the merchant is still deciding to buy.
Instance Attribute Summary collapse
-
#purchase_order ⇒ Object
readonly
The created order — hook handlers read it (nil while :validate runs).
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
#purchase_order ⇒ Object (readonly)
The created order — hook handlers read it (nil while :validate runs).
10 11 12 |
# File 'app/workflows/spree/purchase_orders/create.rb', line 10 def purchase_order @purchase_order end |
Instance Method Details
#perform(store:, supplier:, destination_location:, items: [], currency: nil, expected_at: nil, cancel_by: nil, reference: nil, notes: nil, metadata: nil, created_by: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/workflows/spree/purchase_orders/create.rb', line 27 def perform(store:, supplier:, destination_location:, items: [], currency: nil, expected_at: nil, cancel_by: nil, reference: nil, notes: nil, metadata: nil, created_by: nil) super step :build_purchase_order run_hooks :validate ApplicationRecord.transaction do step :save_purchase_order end run_hooks :after_create # The model's lifecycle events already emit `purchase_order.created`. success(purchase_order.reload) end |