修复bug
This commit is contained in:
@@ -76,22 +76,41 @@ namespace WMS.Web.Domain.Entitys
|
||||
this.CreateTime = createTime;
|
||||
}
|
||||
/// <summary>
|
||||
/// 出库 反写 任务单
|
||||
/// 出库 反写 任务单(返回 这个物料下面的来源单号出了多少数量)
|
||||
/// </summary>
|
||||
/// <param name="materialId"></param>
|
||||
/// <param name="qty"></param>
|
||||
/// <returns></returns>
|
||||
public Result OutStock(int materialId, decimal qty)
|
||||
public Result<List<(string sourceBillNo, decimal qty)>> OutStock(int materialId, decimal qty)
|
||||
{
|
||||
if (this.Status == OutStockStatus.Already)
|
||||
return Result.ReFailure(ResultCodes.OutStockTaskAlready);
|
||||
return Result<List<(string sourceBillNo, decimal qty)>>.ReFailure(ResultCodes.OutStockTaskAlready);
|
||||
if (this.Status == OutStockStatus.Repeal)
|
||||
return Result.ReFailure(ResultCodes.OutStockTaskRepeal);
|
||||
return Result<List<(string sourceBillNo, decimal qty)>>.ReFailure(ResultCodes.OutStockTaskRepeal);
|
||||
|
||||
var detail = this.Details.FirstOrDefault(f => f.MaterialId == materialId);
|
||||
if (detail == null) return Result.ReFailure(ResultCodes.OrderNoData);
|
||||
if (detail == null) return Result<List<(string sourceBillNo, decimal qty)>>.ReFailure(ResultCodes.OrderNoData);
|
||||
if ((detail.AccruedQty - detail.RealityQty) < qty)
|
||||
return Result.ReFailure(ResultCodes.OutStockQtyError);
|
||||
return Result<List<(string sourceBillNo, decimal qty)>>.ReFailure(ResultCodes.OutStockQtyError);
|
||||
List<(string sourceBillNo, decimal qty)> resList = new List<(string sourceBillNo, decimal qty)>();
|
||||
var mQty = qty;
|
||||
foreach (var d in detail.ErpDetails)
|
||||
{
|
||||
if ((d.AccruedQty - d.RealityQty) >= mQty)
|
||||
{
|
||||
d.RealityQty += qty;
|
||||
resList.Add((d.SourceBillNo, mQty));
|
||||
break;//本次出库数量已经分配完毕 调出循环
|
||||
}
|
||||
else
|
||||
{
|
||||
//代表这一个来源单号对应的物料 能全部出掉,并且还有剩余 进行下一个来源单的出货
|
||||
var cQty = d.AccruedQty - d.RealityQty;//本次出货数量
|
||||
mQty -= cQty;
|
||||
d.RealityQty = d.AccruedQty;
|
||||
resList.Add((d.SourceBillNo, cQty));
|
||||
}
|
||||
}
|
||||
|
||||
if (detail.RealityQty <= 0)
|
||||
detail.OutStockBeginTime = DateTime.Now;
|
||||
@@ -106,7 +125,7 @@ namespace WMS.Web.Domain.Entitys
|
||||
else
|
||||
this.Status = OutStockStatus.Part;
|
||||
|
||||
return Result.ReSuccess();
|
||||
return Result<List<(string sourceBillNo, decimal qty)>>.ReSuccess(resList);
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成单据号
|
||||
@@ -171,10 +190,10 @@ namespace WMS.Web.Domain.Entitys
|
||||
foreach (var erpd in d.ErpDetails)
|
||||
{
|
||||
var cd = erpd.Clone();
|
||||
cd.Id = 0;cd.DetailId = 0;
|
||||
cd.Id = 0; cd.DetailId = 0;
|
||||
detail_new.ErpDetails.Add(cd);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
details_new.Add(d);
|
||||
|
||||
Reference in New Issue
Block a user