fix: Implement product lookup in RecordLoss method to accurately reduce inventory on loss
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m50s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m50s
This commit is contained in:
@@ -222,10 +222,35 @@ public class InventoryService : InventoryContract.InventoryContractBase
|
|||||||
throw new RpcException(new Status(StatusCode.Unimplemented, "ProcessReturn requires product lookup - not yet implemented"));
|
throw new RpcException(new Status(StatusCode.Unimplemented, "ProcessReturn requires product lookup - not yet implemented"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<Empty> RecordLoss(RecordLossRequest request, ServerCallContext context)
|
public override async Task<Empty> RecordLoss(RecordLossRequest request, ServerCallContext context)
|
||||||
{
|
{
|
||||||
// TODO: Implement with product lookup
|
// Lookup InventoryItem by ProductId + ProductType
|
||||||
throw new RpcException(new Status(StatusCode.Unimplemented, "RecordLoss requires product lookup - not yet implemented"));
|
var inventoryItem = await _mediator.Send(
|
||||||
|
new GetInventoryByProductQuery
|
||||||
|
{
|
||||||
|
ProductId = request.ProductId,
|
||||||
|
ProductType = (Domain.Enums.ProductType)request.ProductType
|
||||||
|
},
|
||||||
|
context.CancellationToken);
|
||||||
|
|
||||||
|
if (inventoryItem == null)
|
||||||
|
{
|
||||||
|
throw new RpcException(new Status(StatusCode.NotFound,
|
||||||
|
$"Inventory item not found for ProductId={request.ProductId}, ProductType={request.ProductType}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute ReduceInventoryCommand to record the loss
|
||||||
|
await _mediator.Send(
|
||||||
|
new ReduceInventoryCommand
|
||||||
|
{
|
||||||
|
Id = inventoryItem.Id,
|
||||||
|
Quantity = request.Quantity,
|
||||||
|
FromReserved = false,
|
||||||
|
ReferenceNumber = request.ReferenceNumber ?? $"LOSS-{DateTime.UtcNow:yyyyMMddHHmmss}"
|
||||||
|
},
|
||||||
|
context.CancellationToken);
|
||||||
|
|
||||||
|
return new Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Bulk Operations ==========
|
// ========== Bulk Operations ==========
|
||||||
|
|||||||
Reference in New Issue
Block a user