diff --git a/Distribution/Features/Returns/ReturnService.cs b/Distribution/Features/Returns/ReturnService.cs index 731bc18..f747542 100644 --- a/Distribution/Features/Returns/ReturnService.cs +++ b/Distribution/Features/Returns/ReturnService.cs @@ -78,7 +78,9 @@ public class ReturnService( if (request.Items is null || request.Items.Count == 0) throw new InvalidOperationException("A return must have at least one line item."); - var sale = await saleRepo.GetByIdAsync(order.FK_SaleId) + if (order.FK_SaleId is null) + throw new InvalidOperationException("Sale not found for this order."); + var sale = await saleRepo.GetByIdAsync(order.FK_SaleId.Value) ?? throw new InvalidOperationException("Sale not found for this order."); if (sale.FK_RideId is null) throw new InvalidOperationException("A return can only be recorded for an order created during an active ride.");