Class: Edi::Houzz::ConfirmMessageProcessor
- Inherits:
-
BaseEdiService
- Object
- BaseService
- BaseEdiService
- Edi::Houzz::ConfirmMessageProcessor
- Defined in:
- app/services/edi/houzz/confirm_message_processor.rb
Constant Summary collapse
- CONTAINER_MAP =
{ carton: 'CTN', pallet: 'PLT' }
Constants included from AddressAbbreviator
AddressAbbreviator::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseEdiService
Instance Method Summary collapse
- #acknowledge_order(order, options = {}) ⇒ Object
- #auto_cancel_order(order, order_hash, reason_code, _bad_vendor_skus = nil, _bad_merchant_skus = nil) ⇒ Object
- #back_order(order) ⇒ Object
-
#build_back_order_message_from_order(order) ⇒ Object
Here we build an acknowledge message (for order backorder).
-
#build_cancel_message_from_order(order) ⇒ Object
The valid cancel codes are: 1 => "Item out of stock", 5 => "Other".
-
#build_cancel_message_from_order_hash(order, order_hash, _reason_code) ⇒ Object
Here we build an acknowledge message (for order cancel).
-
#build_confirm_message_from_invoice(invoice) ⇒ Object
3451-1223-4987-0908 Ship UPS Ground 1Z9R408W0328744215 .
- #cancel_order(order) ⇒ Object
- #confirm_invoice(invoice) ⇒ Object
- #get_order_line_items(order) ⇒ Object
-
#process(confirm_message, category, order = nil) ⇒ Object
Picks up the edi communication log in the queue ready to process, generate acknowledgements/shipments.
Methods inherited from BaseEdiService
#duplicate_po_already_notified?, #initialize, #mark_duplicate_po_as_notified, #report_order_creation_issues, #safe_process_edi_communication_log
Methods included from AddressAbbreviator
#abbreviate_street, #collect_street_originals, #record_address_abbreviation_notes
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from Edi::BaseEdiService
Instance Method Details
#acknowledge_order(order, options = {}) ⇒ Object
14 15 16 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 14 def acknowledge_order(order, = {}) # do nothing for Houzz end |
#auto_cancel_order(order, order_hash, reason_code, _bad_vendor_skus = nil, _bad_merchant_skus = nil) ⇒ Object
23 24 25 26 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 23 def auto_cancel_order(order, order_hash, reason_code, _bad_vendor_skus = nil, _bad_merchant_skus = nil) m = (order, order_hash, reason_code) process(m, :order_acknowledge, order) end |
#back_order(order) ⇒ Object
28 29 30 31 32 33 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 28 def back_order(order) return if orchestrator.ignore_back_orders m = (order) process(m, :order_acknowledge, order) end |
#build_back_order_message_from_order(order) ⇒ Object
Here we build an acknowledge message (for order backorder). Send only from what's required:
81 82 83 84 85 86 87 88 89 90 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 81 def (order) { UpdateOrderRequest: { OrderId: order.edi_po_number, Action: 'Cancel', Comments: "Expected availability: #{order.get_scheduled_ship_date_time.strftime('%m/%d/%Y')}", CancelCode: 1 } } end |
#build_cancel_message_from_order(order) ⇒ Object
The valid cancel codes are:
1 => "Item out of stock", 5 => "Other"
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 52 def (order) msg = { UpdateOrderRequest: { OrderId: order.edi_po_number, Action: 'Cancel', CancelCode: 5 } } if order.crm_back_order? msg['CancelCode'] = 1 msg['Comments'] = "Expected availability: #{order.get_scheduled_ship_date_time.strftime('%m/%d/%Y')}" end msg end |
#build_cancel_message_from_order_hash(order, order_hash, _reason_code) ⇒ Object
Here we build an acknowledge message (for order cancel). Send only from what's required:
69 70 71 72 73 74 75 76 77 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 69 def (order, order_hash, _reason_code) { UpdateOrderRequest: { OrderId: order.edi_po_number || order_hash[:OrderId], Action: 'Cancel', CancelCode: 5 } } end |
#build_confirm_message_from_invoice(invoice) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 101 def (invoice) order = invoice.order # this is an alias to building a shipment message { UpdateOrderRequest: { OrderId: order.edi_po_number || order_hash[:OrderId], Action: 'Ship', ShippingMethod: invoice.delivery&.shipping_option&.description, TrackingNumber: invoice.delivery&.master_tracking_number || invoice.delivery&.carrier_bol } } end |
#cancel_order(order) ⇒ Object
18 19 20 21 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 18 def cancel_order(order) m = (order) process(m, :order_acknowledge, order) end |
#confirm_invoice(invoice) ⇒ Object
35 36 37 38 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 35 def confirm_invoice(invoice) m = (invoice) process(m, :order_confirm, invoice.order) end |
#get_order_line_items(order) ⇒ Object
10 11 12 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 10 def get_order_line_items(order) order.line_items.where.not(edi_line_number: nil).order(:edi_line_number).goods end |
#process(confirm_message, category, order = nil) ⇒ Object
Picks up the edi communication log in the queue ready to process, generate acknowledgements/shipments
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'app/services/edi/houzz/confirm_message_processor.rb', line 116 def process(, category, order = nil) edi_log = nil EdiCommunicationLog.transaction do edi_log = EdiCommunicationLog.create! partner: orchestrator.partner, category: category, data: .to_json, data_type: 'json', file_info: { lines_confirmed: ([:AckLines] || [:ShipmentLines] || 1).size }, transmit_datetime: Time.current end edi_log.edi_documents.create!(order: order) if order.present? edi_log end |