|
|
@@ -5085,7 +5085,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
}
|
|
|
//数据库需要减少的PR集合
|
|
|
- CalcPrDel(prDelList, dbPurchaseList, ic_items, DBprmainList.Where(x=>x.state==1).ToList(), updatPrList, deletePrList);//只取新增状态的PR,可以做删除或者修改
|
|
|
+ CalcPrDel(prDelList, dbPurchaseList, ic_items, DBprmainList.Where(x=>x.state==1).ToList(), updatPrList, deletePrList, prmainlist);//只取新增状态的PR,可以做删除或者修改
|
|
|
new NLogHelper("AlignmentCalcList").WriteLog("AlignmentCalcList", JsonConvert.SerializeObject(AlignmentCalcList), _currentTenant.Id.ToString());
|
|
|
}
|
|
|
|
|
|
@@ -5199,7 +5199,7 @@ namespace Business.Replenishment
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
- public void CalcPrDel(List<AlignmentCalcDto> prDelList,List<srm_purchase> purchase,List<ic_item> ic_items, List<srm_pr_main> dbPrlist, List<srm_pr_main> updatPrList, List<srm_pr_main> deletePrList)
|
|
|
+ public void CalcPrDel(List<AlignmentCalcDto> prDelList,List<srm_purchase> purchase,List<ic_item> ic_items, List<srm_pr_main> dbPrlist, List<srm_pr_main> updatPrList, List<srm_pr_main> deletePrList,List<mo_srm_pr_main> prmainlist)
|
|
|
{
|
|
|
prDelList.ForEach(dto => {
|
|
|
var itemPurList = purchase.Where(x => x.number == dto.ItemNum).ToList();
|
|
|
@@ -5209,6 +5209,33 @@ namespace Business.Replenishment
|
|
|
itemPurList.ForEach(c => {
|
|
|
//当前供应商需减少数量
|
|
|
decimal qty = Math.Floor(Math.Abs(dto.DifferenceQty) * c.quota_rate.GetValueOrDefault() / 100);
|
|
|
+ var MoItemSupplierList = prmainlist.Where(x => x.icitem_id == icitem.Id && x.pr_purchaseid == c.supplier_id).OrderByDescending(f => f.pr_sarrive_date).ToList();
|
|
|
+ if (MoItemSupplierList.Any())
|
|
|
+ {
|
|
|
+ foreach (var moPr in MoItemSupplierList)
|
|
|
+ {
|
|
|
+ if (moPr.pr_aqty > qty)//一个PR够减
|
|
|
+ {
|
|
|
+ moPr.pr_aqty = moPr.pr_aqty - qty;
|
|
|
+ moPr.pr_rqty = moPr.pr_aqty;
|
|
|
+ moPr.pr_sqty = moPr.pr_aqty;
|
|
|
+ dto.updateQty += qty;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else if (moPr.pr_aqty == qty)//一个PR够减
|
|
|
+ {
|
|
|
+ dto.deleteQty += qty;
|
|
|
+ prmainlist.Remove(moPr);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dto.deleteQty += moPr.pr_aqty.GetValueOrDefault();
|
|
|
+ qty -= moPr.pr_aqty.GetValueOrDefault();
|
|
|
+ prmainlist.Remove(moPr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//当前物料当前供应商的在途采购申请
|
|
|
var itemSupplierList = dbPrlist.Where(x => x.icitem_id == icitem.Id && x.pr_purchaseid == c.supplier_id).OrderByDescending(f => f.pr_sarrive_date).ToList();
|
|
|
if (itemSupplierList.Any())
|