This commit is contained in:
@@ -209,8 +209,9 @@ namespace AyaNova.Biz
|
||||
//PM GENERATION
|
||||
await CoreJobPMGenerate.DoWorkAsync();
|
||||
|
||||
//PM INVENTORY CHECK
|
||||
await CoreJobPMInventoryCheck.DoWorkAsync();
|
||||
//PM INVENTORY CHECK
|
||||
if (AyaNova.Util.ServerGlobalBizSettings.Cache.UseInventory)
|
||||
await CoreJobPMInventoryCheck.DoWorkAsync();
|
||||
|
||||
//JOB SWEEPER / AND USER COUNT CHECK
|
||||
await CoreJobSweeper.DoWorkAsync();
|
||||
|
||||
@@ -4818,15 +4818,48 @@ namespace AyaNova.Biz
|
||||
//title = pm insufficient and id and object link to pm
|
||||
//message = list: part name, -xx (short quantity), no text if possible so no translate needed
|
||||
|
||||
//collect the parts on the pm
|
||||
List<PMRestockListItem> PartStockRequired = new List<PMRestockListItem>();
|
||||
foreach (PMItem pmi in p.Items)
|
||||
{
|
||||
foreach (PMItemPart pmp in pmi.Parts)
|
||||
{
|
||||
var CurrentInventory = await ct.PartInventory.AsNoTracking().OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.PartId == pmp.PartId && m.PartWarehouseId == pmp.PartWarehouseId);
|
||||
if (CurrentInventory.Balance < pmp.Quantity)
|
||||
{
|
||||
var i = new PMRestockListItem() { PartId = pmp.PartId, WarehouseId = pmp.PartWarehouseId, QuantityRequired = pmp.Quantity - (decimal)CurrentInventory.Balance };
|
||||
PartStockRequired.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (PartStockRequired.Count == 0) continue;
|
||||
|
||||
}
|
||||
//summarize and notify
|
||||
var sumList = PartStockRequired.GroupBy(x => new { x.WarehouseId, x.PartId })
|
||||
.OrderBy(g => g.Key.PartId)
|
||||
.ThenBy(g => g.Key.WarehouseId)
|
||||
.Select(cl => new PMRestockListItem() { PartId = cl.First().PartId, WarehouseId = cl.First().WarehouseId, QuantityRequired = cl.Sum(c => c.QuantityRequired) });
|
||||
|
||||
//ok, should have all summarized partid/warehouseid required combos, can now build output
|
||||
|
||||
|
||||
|
||||
}//each pmid
|
||||
|
||||
}//each subscriber
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class PMRestockListItem
|
||||
{
|
||||
public long PartId { get; set; }
|
||||
public long WarehouseId { get; set; }
|
||||
public decimal QuantityRequired { get; set; }
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Process generation of pms to workorders
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user