Class: Edi::Amazon::ReturnsReportRmaMatch
- Inherits:
-
Object
- Object
- Edi::Amazon::ReturnsReportRmaMatch
- Defined in:
- app/services/edi/amazon/returns_report_rma_match.rb
Overview
Verifies that a Merchant RMA ID belongs to the reported Amazon order's
internal return lineage.
Most RMAs point directly at the Amazon order. A replacement order created
from an earlier RMA points back through +orders.rma_id+ instead, and can
itself acquire a later RMA. Walking that canonical chain accepts those
descendants without treating an unrelated order as a match.
Instance Method Summary collapse
-
#initialize(order:, rma:) ⇒ ReturnsReportRmaMatch
constructor
A new instance of ReturnsReportRmaMatch.
-
#verified? ⇒ Boolean
Whether the RMA belongs to the order or one of its RMA-generated replacement orders.
Constructor Details
#initialize(order:, rma:) ⇒ ReturnsReportRmaMatch
Returns a new instance of ReturnsReportRmaMatch.
14 15 16 17 |
# File 'app/services/edi/amazon/returns_report_rma_match.rb', line 14 def initialize(order:, rma:) @order = order @rma = rma end |
Instance Method Details
#verified? ⇒ Boolean
Returns whether the RMA belongs to the order or one of its
RMA-generated replacement orders.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/edi/amazon/returns_report_rma_match.rb', line 21 def verified? return false unless @order && @rma return true if @rma.original_order_id == @order.id current_order = @rma.original_order visited_order_ids = {} while current_order && !visited_order_ids[current_order.id] return true if current_order.id == @order.id visited_order_ids[current_order.id] = true current_order = current_order.rma&.original_order end false end |