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);
|
DateTime parsedDate = DateTime.Parse(FormDate);
|
||||||
|
var thisMonthMovements = await _centralDbContext.ItemMovements
|
||||||
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
|
|
||||||
.Include(m => m.Item)
|
.Include(m => m.Item)
|
||||||
.Include(m => m.Item!.Product)
|
.Include(m => m.Item!.Product)
|
||||||
.Include(m => m.Item!.Department)
|
.Include(m => m.Item!.Department)
|
||||||
@ -179,19 +166,13 @@ namespace PSTW_CentralSystem.Controllers.API
|
|||||||
QuantityOut = m.Quantity??0,
|
QuantityOut = m.Quantity??0,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
//value from currentProductBalance - value from thisMonthMovements
|
||||||
//value from currentProductBalance - value from thisMonthMovementOut + value from thisMonthMovementIn
|
|
||||||
foreach (var item in currentProductBalance)
|
foreach (var item in currentProductBalance)
|
||||||
{
|
{
|
||||||
var movementIn = thisMonthMovementIn.FirstOrDefault(m => m.ProductName == item.ProductName);
|
var movement = thisMonthMovements.FirstOrDefault(m => m.ProductName == item.ProductName);
|
||||||
if (movementIn != null && item.Quantity > 0)
|
if (movement != null && item.Quantity > 0)
|
||||||
{
|
{
|
||||||
item.Quantity += movementIn.QuantityOut;
|
item.Quantity -= movement.QuantityOut;
|
||||||
}
|
|
||||||
var movementOut = thisMonthMovementOut.FirstOrDefault(m => m.ProductName == item.ProductName);
|
|
||||||
if (movementOut != null && item.Quantity > 0)
|
|
||||||
{
|
|
||||||
item.Quantity -= movementOut.QuantityOut;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Json(currentProductBalance);
|
return Json(currentProductBalance);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user