出库时物料状态控制,采购订单收货单到货数量调整、报表调整

This commit is contained in:
2024-10-12 17:09:59 +08:00
parent 20ff2d213a
commit 8c047af86e
13 changed files with 318 additions and 212 deletions

View File

@@ -40,6 +40,7 @@ using JNPF.VisualDev.Entitys;
using Tnb.BasicData.Interfaces;
using JNPF.Common.Enums;
using System.Reflection;
using Aop.Api.Domain;
namespace Tnb.WarehouseMgr
{
@@ -192,6 +193,26 @@ namespace Tnb.WarehouseMgr
List<WmsPurchaseD> dList = await _db.Queryable<WmsPurchaseD>().Where(x=>x.bill_id==purchaseDs.First().bill_id).OrderBy(x=>x.id).ToListAsync();
List<WmsPurchaseOrderD> wmsPurchaseOrderDs = await _db.Queryable<WmsPurchaseOrderD>().Where(r => dList.Select(x => x.erp_purchase_order_d_pk).Contains(r.erp_line_pk)).OrderBy(x => x.id).ToListAsync();
foreach (var item in dList)
{
decimal purchase_arriveqty = input.details.Where(r => r.id == item.id).ToList()[0].purchase_arriveqty;
item.purchase_prqty += purchase_arriveqty;
if (item.purchase_prqty > item.purchase_qty)
{
throw Oops.Bah($"采购收货单明细行物料{item.material_code} 批次{item.code_batch} 到货数量不能超过采购数量!");
}
WmsPurchaseOrderD wmsPurchaseOrderD = wmsPurchaseOrderDs.Where(r => r.erp_line_pk == item.erp_purchase_order_d_pk).ToList()[0];
wmsPurchaseOrderD.actual_quantity += purchase_arriveqty;
if (wmsPurchaseOrderD.actual_quantity > wmsPurchaseOrderD.purchase_quantity)
{
throw Oops.Bah($"采购订单明细行物料{wmsPurchaseOrderD.matcode} 批次{wmsPurchaseOrderD.code_batch} 到货数量不能超过采购数量!");
}
}
await _db.Updateable(dList).UpdateColumns(r => r.purchase_prqty).ExecuteCommandAsync();
await _db.Updateable(wmsPurchaseOrderDs).UpdateColumns(r => r.actual_quantity).ExecuteCommandAsync();
List<String> materialIds = purchaseDs.Select(x=>x.material_id).Distinct().ToList();
List<String> unitCodes = purchaseDs.Select(x => x.unit_id).Distinct().ToList();
List<DictionaryDataEntity> unitDatas = await _db.Queryable<DictionaryTypeEntity>()