Class: Shipping::PackagingDiscrepancyHandler

Inherits:
ApplicationJob
  • Object
show all
Includes:
RailsEventStore::AsyncHandler
Defined in:
app/subscribers/shipping/packaging_discrepancy_handler.rb

Overview

Flags packaging discrepancies after invoicing for Heatwave-labeled shipments.

Subscribes to: Events::DeliveryInvoiced

WHY async: Discrepancy detection is background analysis that reads packing
records and flags mismatches for review. It has no customer-facing impact
and should not block or be blocked by insurance purchase or customs submission.

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'app/subscribers/shipping/packaging_discrepancy_handler.rb', line 14

def perform(event)
  delivery = Delivery.find_by(id: event.data[:delivery_id])
  return unless delivery
  return unless delivery.ship_labeled_via_heatwave?

  Shipping::ItemPackagingDiscrepancyCheck.new.process(delivery)
rescue StandardError => e
  ErrorReporting.error(e)
  raise
end