This commit is contained in:
@@ -287,12 +287,14 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get on hand inventory values in all warehouses for part id specified
|
||||
/// Get most recent Part inventory records in all warehouses for part id specified
|
||||
/// most recent is the latest "end" of the inventory chain containing the current balance as of the point in time this is fetched
|
||||
/// these values are required to make inventory adjustments
|
||||
/// </summary>
|
||||
/// <param name="partId"></param>
|
||||
/// <returns>Array of part on hand inventory levels by warehouse</returns>
|
||||
[HttpGet("on-hand-inventory/{partId}")]
|
||||
public async Task<IActionResult> GetPartOnHandInventory([FromRoute] long partId)
|
||||
/// <returns>List of part inventory records for each warehouse</returns>
|
||||
[HttpGet("latest-inventory/{partId}")]
|
||||
public async Task<IActionResult> GetLatestInventory([FromRoute] long partId)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -306,18 +308,16 @@ namespace AyaNova.Api.Controllers
|
||||
var allWhs = await ct.PartWarehouse.AsNoTracking().ToListAsync();
|
||||
|
||||
//iterate them and compile the last inventory for each warehouse for this part
|
||||
foreach(PartWarehouse pw in allWhs){
|
||||
|
||||
}
|
||||
|
||||
var LastEntry = await ct.PartInventory.OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.PartId == newDtObject.PartId && m.PartWarehouseId == newDtObject.PartWarehouseId);
|
||||
var o = await ct.PartStockLevel.AsNoTracking().Where(z => z.PartId == partId).OrderBy(z => z.PartWarehouseId).ToListAsync();
|
||||
foreach (PartStockLevel ps in o)
|
||||
List<PartInventory> ret = new List<PartInventory>();
|
||||
foreach (PartWarehouse pw in allWhs)
|
||||
{
|
||||
ps.PartWarehouseDisplay = await ct.PartWarehouse.AsNoTracking().Where(z => z.Id == ps.PartWarehouseId).Select(z => z.Name).FirstOrDefaultAsync();
|
||||
var LastEntry = await ct.PartInventory.AsNoTracking().OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.PartId == partId && m.PartWarehouseId == pw.Id);
|
||||
if (LastEntry != null)
|
||||
{
|
||||
ret.Add(LastEntry);
|
||||
}
|
||||
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
return Ok(ApiOkResponse.Response(ret));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user