Class: Edi::ResellerInventory::Orchestrator

Inherits:
BaseOrchestrator show all
Defined in:
app/services/edi/reseller_inventory/orchestrator.rb

Overview

Each reseller inventory feed is a partner here — the static Amazon/Walmart
config pattern — replacing the legacy per-customer Feed rows. Generation →
email → log → retry all run through EdiCommunicationLog.

Config snapshotted from the live feeds rows (2026-06-19, prod-authoritative
via reseller_inventory:extract); the matching Feed rows are deactivated in
the same cutover (see the DeactivateLegacyReseller* migration) so there's no
double-send. Parity was verified 32/32 byte-identical (reseller_inventory:parity).

Runs on the hourly EdiInventoryFlowWorker; #due_now? gates each partner to
its daily / weekly (by weekday) schedule. To add/change a reseller, edit
RESELLERS (recipients are also editable on the customer record's contacts).

Constant Summary collapse

DEFAULTS =

Shared across every reseller feed. inventory_feed_only keeps these partners
OUT of customer_id-based orchestrator routing (orders / RMA / returns /
invoices): this is a push-only inventory feed, and some reseller customer_ids
collide with real EDI partners (Zoro → MftGateway, Home Depot Canada →
Commercehub) which must keep winning that lookup — see BaseOrchestrator
#build_customer_id_to_partner_key_map.

{ active: true, inventory_feed_only: true, sender_email: 'orders@warmlyyours.com', cc_email: 'orders@warmlyyours.com' }.freeze
RESELLERS =

Per-reseller config. inventory_weekday (0=Sun..6=Sat) only on weekly feeds.

{
  unbeatablesale_com:             { customer_id: 181_766,    inventory_template: :code_sku_units, inventory_schedule: :daily,  recipient_emails: %w[bo@unbeatablesale.com] },
  vintage_tub_and_bath:           { customer_id: 124_059,    inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 4, recipient_emails: %w[bretto@vintagetub.com] },
  faucettownusa_com:              { customer_id: 187_857,    inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[elena@faucettownusa.com sales@faucettownusa.com] },
  zuri_furniture_llc:             { customer_id: 2_609_670,  inventory_template: :sku_units,      inventory_schedule: :daily,  recipient_emails: %w[buying@zurifurniture.com] },
  westsidewholesale_com:          { customer_id: 182_027,    inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[fulfillment@westsidewholesale.com] },
  onlytowelwarmers_com:           { customer_id: 943_251,    inventory_template: :sku_units_upc,  inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[michael@onlytowelwarmers.com] },
  mor_electric_heating_assoc_inc: { customer_id: 124_523,    inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[sales@morelectricheating.com terry@morelectric.com] },
  air_n_water_com:                { customer_id: 181_744,    inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[inventory@air-n-water.com] },
  bedbath_world_llc: {
    customer_id: 167_497, inventory_template: :sku_units, inventory_schedule: :weekly, inventory_weekday: 3,
    recipient_emails: %w[customerservice@bedbathworld.com ordermanager@bedbathworld.com tracking@bedbathworld.com]
  },
  protherm_industries_inc:        { customer_id: 2_721_265,  inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[protherm@comcast.net] },
  comforthouse_com:               { customer_id: 163_410,    inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 6, recipient_emails: %w[comforthousefeeds@gmail.com vendor@comforthouse.com] },
  blue_bath:                      { customer_id: 407_645,    inventory_template: :sku_units,      inventory_schedule: :daily,  recipient_emails: %w[inventory@bluebath.com] },
  sports_imports_llc:             { customer_id: 50_712,     inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[aga@sportsimportsllc.com] },
  builderdepot_com:               { customer_id: 124_587,    inventory_template: :sku_units,      inventory_schedule: :daily,  recipient_emails: %w[operations@builderdepot.com] },
  houseneeds_com:                 { customer_id: 134_341,    inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[ship@houseneeds.com] },
  supremekitchenbath_com:         { customer_id: 163_539,    inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[info@supremekitchenbath.com] },
  big_frog_supply:                { customer_id: 2_737_088,  inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 0, recipient_emails: %w[1b9cdeaae2b1a0840e45e78019510d6c@inbox.duoplane.com] },
  lush_living:                    { customer_id: 3_691_287,  inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 5, recipient_emails: %w[sales@liveitlush.com] },
  luxury_freestanding_tubs:       { customer_id: 6_256_006,  inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 5, recipient_emails: %w[gaetan@luxuryfreestandingtubs.com info@luxuryfreestandingtubs.com] },
  factorypure_com:                { customer_id: 6_909_496,  inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[procurement@factorypure.com sales@factorypure.com] },
  kitchen_and_bath_authority:     { customer_id: 6_771_721,  inventory_template: :sku_units,      inventory_schedule: :daily,  recipient_emails: %w[inventory@kbauthority.com] },
  bathcollective_com:             { customer_id: 7_221_771,  inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[support@bathcollective.com] },
  sunflaresaunas_com:             { customer_id: 9_888_207,  inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 5, recipient_emails: %w[dj@sunflaresaunas.com office@sunflaresaunas.com] },
  five_star_retail_brands_llc:    { customer_id: 18_517_275, inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[ricardonovey@usbathstore.com] },
  whole9yards_usa_llc:            { customer_id: 19_073_872, inventory_template: :sku_units,      inventory_schedule: :daily,  recipient_emails: %w[inventory@kartit.us] },
  zoro:                           { customer_id: 17_765_581, inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[aditya.apte@zoro.com] },
  home_reno_direct:               { customer_id: 3_017_664,  inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[renozcentre1651496969@in.stock-sync.com] },
  faucetgennie_inc:               { customer_id: 20_839_154, inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[business@faucetgennie.com] },
  home_depot_canada:              { customer_id: 10_358,     inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[splante82@gmail.com] },
  renoz_com:                      { customer_id: 21_583_650, inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 6, recipient_emails: %w[renoz-usa1671115643@in.stock-sync.com] },
  west_beverly_bath:              { customer_id: 22_903_989, inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[sales@westbeverlybath.com steffi@westbeverlybath.com] },
  supremesaunas_com:              { customer_id: 23_056_603, inventory_template: :sku_units,      inventory_schedule: :weekly, inventory_weekday: 3, recipient_emails: %w[info@supremesaunas.com] }
}.freeze
LEGACY_FEED_IDS =

The legacy Feed ids these partners replace — deactivated at cutover.

[15, 16, 17, 18, 19, 21, 22, 23, 27, 33, 34, 37, 39, 42, 43, 44, 50, 61, 66, 70, 72, 73, 77, 84, 85, 86, 88, 89, 92, 94, 128, 129].freeze

Constants inherited from BaseOrchestrator

BaseOrchestrator::DEFAULT_PENDING_DISCONTINUE_LIFETIME, BaseOrchestrator::ORCHESTRATORS, BaseOrchestrator::RECOMMENDED_EXECUTE_FLOW_EVERY_X_HOUR

Instance Attribute Summary

Attributes inherited from BaseOrchestrator

#config, #logger, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseOrchestrator

all_orchestrators_class, build, build_customer_id_to_partner_key_map, cached_build, cached_orchestrators, catalog_id_to_pending_discontinue_lifetime, catalog_ids_edi_enabled, #confirm_outbound_processing?, #customer, #customer_catalog, customer_id_to_partner_key_map, #customer_ids, customer_ids_edi_enabled, customer_ids_with_invoice_message_enabled, #customers, execute_discontinue_flow, execute_flow, execute_inventory_flow, execute_listing_message_feed_flow, execute_order_flow, #execute_order_flow, execute_price_flow, #execute_price_flow, execute_product_data_flow, #execute_product_data_flow, #ignore_back_orders, #initialize, #inventory_message_enabled?, orchestrator_for_customer_id, orchestrators, #pending_discontinue_lifetime, #price_message_enabled?, #product_data_enabled?, #return_notification_message_enabled?, #should_execute_flow?, #should_execute_order_flow?, #should_execute_product_data_flow?, #test_mode?

Constructor Details

This class inherits a constructor from Edi::BaseOrchestrator

Class Method Details

.partnersObject



67
68
69
70
71
72
# File 'app/services/edi/reseller_inventory/orchestrator.rb', line 67

def self.partners
  # deep_dup so a consumer that mutates a partner's config (e.g. its
  # recipient_emails array) can't leak back into the RESELLERS / DEFAULTS
  # constants that back every other partner.
  RESELLERS.to_h { |key, cfg| [key, DEFAULTS.merge(cfg, partner: key).deep_dup] }
end

Instance Method Details

#execute_inventory_flowObject



74
75
76
77
78
79
# File 'app/services/edi/reseller_inventory/orchestrator.rb', line 74

def execute_inventory_flow
  return unless active && due_now?

  inventory_processor.process
  inventory_sender.process
end

#inventory_processorObject



81
82
83
# File 'app/services/edi/reseller_inventory/orchestrator.rb', line 81

def inventory_processor
  Edi::ResellerInventory::InventoryProcessor.new(self, options)
end

#inventory_senderObject



85
86
87
# File 'app/services/edi/reseller_inventory/orchestrator.rb', line 85

def inventory_sender
  Edi::ResellerInventory::Sender.new(self, options)
end