Compare commits
No commits in common. "655f279d7aa7c6a405cae749c0d56e5f3cf64667" and "adef552b7989963e4828bf6b9713f0cf6c9ad951" have entirely different histories.
655f279d7a
...
adef552b79
@ -155,20 +155,7 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
}
|
||||
}
|
||||
DateTime parsedDate = DateTime.Parse(FormDate);
|
||||
|
||||
var thisMonthMovementIn = await _centralDbContext.ItemMovements
|
||||
.Include(m => m.Item)
|
||||
.Include(m => m.Item!.Product)
|
||||
.Include(m => m.Item!.Department)
|
||||
.Where(m => m.Date.Month == parsedDate.Month && m.Date.Year == parsedDate.Year && m.Item!.Department!.DepartmentCode == DeptId && (m.Action == "Stock In" || m.Action == "Register"))
|
||||
.Select(m => new
|
||||
{
|
||||
ProductName = m.Item!.Product!.ProductName,
|
||||
QuantityOut = m.Quantity??0,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var thisMonthMovementOut = await _centralDbContext.ItemMovements
|
||||
var thisMonthMovements = await _centralDbContext.ItemMovements
|
||||
.Include(m => m.Item)
|
||||
.Include(m => m.Item!.Product)
|
||||
.Include(m => m.Item!.Department)
|
||||
@ -179,19 +166,13 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
QuantityOut = m.Quantity??0,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
//value from currentProductBalance - value from thisMonthMovementOut + value from thisMonthMovementIn
|
||||
//value from currentProductBalance - value from thisMonthMovements
|
||||
foreach (var item in currentProductBalance)
|
||||
{
|
||||
var movementIn = thisMonthMovementIn.FirstOrDefault(m => m.ProductName == item.ProductName);
|
||||
if (movementIn != null && item.Quantity > 0)
|
||||
var movement = thisMonthMovements.FirstOrDefault(m => m.ProductName == item.ProductName);
|
||||
if (movement != null && item.Quantity > 0)
|
||||
{
|
||||
item.Quantity += movementIn.QuantityOut;
|
||||
}
|
||||
var movementOut = thisMonthMovementOut.FirstOrDefault(m => m.ProductName == item.ProductName);
|
||||
if (movementOut != null && item.Quantity > 0)
|
||||
{
|
||||
item.Quantity -= movementOut.QuantityOut;
|
||||
item.Quantity -= movement.QuantityOut;
|
||||
}
|
||||
}
|
||||
return Json(currentProductBalance);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user