Class: Inventory::OrderInvoicedHandler
- Inherits:
-
ApplicationJob
- Object
- ApplicationJob
- Inventory::OrderInvoicedHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/inventory/order_invoiced_handler.rb
Overview
Releases inventory commits for line items that were never assigned to a
delivery when the parent order transitions to invoiced.
Subscribes to: Events::OrderInvoiced
WHY this exists: When an order has line items that are never assigned to
any delivery (back-ordered, removed from fulfillment), those commits are
invisible to the delivery-level uncommit path. This handler sweeps them
up after the order reaches its terminal invoiced state.
WHY async: Stock reservation release is not financially critical. The
daily ExpiredInventoryCommitsWorker serves as a safety net.
Instance Method Summary collapse
Instance Method Details
#perform(event) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/subscribers/inventory/order_invoiced_handler.rb', line 19 def perform(event) order = Order.find_by(id: event.data[:order_id]) return unless order order.uncommit_undelivered_line_items rescue StandardError => e ErrorReporting.error(e) raise end |