73 var streamIdentifiers =
79 ArgumentNullException.ThrowIfNull(
84 if (!streamIdentifiers.Add(
87 throw new InvalidOperationException(
88 $
"Closed-loop return-stream identifier '{stream.Id}' is duplicated.");
94 throw new InvalidOperationException(
95 $
"Closed-loop return stream '{stream.Id}' uses horizon {stream.PlanningHorizon}, expected {PlanningHorizon}.");
103 throw new InvalidOperationException(
104 $
"Closed-loop return stream '{stream.Id}' references unknown item '{stream.ItemId}'.");
108 distributionCenter =>
109 distributionCenter.Id ==
112 throw new InvalidOperationException(
113 $
"Closed-loop return stream '{stream.Id}' references unknown distribution center '{stream.DistributionCenterId}'.");
116 bool hasTargetInventory =
121 inventory.Warehouse.Kind ==
123 inventory.Warehouse.ReferenceId ==
126 if (!hasTargetInventory)
128 throw new InvalidOperationException(
129 $
"Closed-loop return stream '{stream.Id}' has no matching target inventory for recovered item '{stream.ItemId}'.");