public void RecordLocationTransaction(OrderLocationTransaction orderLocationTransaction, InventoryTransaction inventoryTransaction, Receipt receipt, User user) { LocationTransaction locationTransaction = GenerateOrderLocationTransaction(orderLocationTransaction, orderLocationTransaction.Location, user); if (inventoryTransaction.Hu != null) { locationTransaction.HuId = inventoryTransaction.Hu.HuId; locationTransaction.LotNo = inventoryTransaction.Hu.LotNo; } if (locationTransaction.LotNo == null || locationTransaction.LotNo == string.Empty) { locationTransaction.LotNo = inventoryTransaction.LotNo; } locationTransaction.BatchNo = inventoryTransaction.LocationLotDetailId; locationTransaction.ReceiptNo = receipt.ReceiptNo; locationTransaction.IpNo = receipt.ReferenceIpNo; locationTransaction.Qty = inventoryTransaction.Qty; locationTransaction.EffectiveDate = DateTime.Parse(receipt.CreateDate.ToString("yyyy-MM-dd")); if (orderLocationTransaction.OrderDetail.OrderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER) { OrderLocationTransaction outOrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderLocationTransaction.OrderDetail.Id, BusinessConstants.IO_TYPE_OUT)[0]; locationTransaction.RefLocation = outOrderLocationTransaction.Location.Code; locationTransaction.RefLocationName = outOrderLocationTransaction.Location.Name; } this.CreateLocationTransaction(locationTransaction); }
public IList<ReceiptDetail> CreateReceiptDetail(Receipt receipt, OrderLocationTransaction inOrderLocationTransaction, IList<Hu> huList) { IList<ReceiptDetail> receiptDetailList = new List<ReceiptDetail>(); foreach (Hu hu in huList) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.Receipt = receipt; receiptDetail.OrderLocationTransaction = inOrderLocationTransaction; receiptDetail.HuId = hu.HuId; receiptDetail.LotNo = hu.LotNo; //����hu����������ж�����Ʒ���Ǵ�Ʒ if (hu.QualityLevel == BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1) { //�ȳ�Hu.UnitQtyתΪ������λ���ڳ�outOrderLocationTransaction.UnitQtyתΪ������λ�� receiptDetail.ReceivedQty = hu.Qty * hu.UnitQty / inOrderLocationTransaction.UnitQty; } else if (hu.QualityLevel == BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_2) { receiptDetail.RejectedQty = hu.Qty * hu.UnitQty / inOrderLocationTransaction.UnitQty; } else { throw new TechnicalException("hu quality level:" + hu.QualityLevel + " not valided"); } this.CreateReceiptDetail(receiptDetail); receiptDetailList.Add(receiptDetail); receipt.AddReceiptDetail(receiptDetail); } return receiptDetailList; }
//��������� public static void CalculateQtyToReceive(Receipt receipt) { if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { bool isASN = false; if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) isASN = true; foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { if (!isASN) { receiptDetail.ShippedQty = receiptDetail.OrderLocationTransaction.OrderDetail.RemainShippedQty; } receiptDetail.ReceivedQty = receiptDetail.ShippedQty; } } }
public override void CreateReceipt(Receipt receipt) { #region 在Receipt上记录参考Asn,为字串 string ipNo = null; if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { if (ipNo == null) { ipNo = inProcessLocation.IpNo; } else { ipNo += ", " + inProcessLocation.IpNo; } } } receipt.ReferenceIpNo = ipNo; #endregion this.entityDao.CreateReceipt(receipt); #region 保存收货和发货关系 if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { ReceiptInProcessLocation receiptInProcessLocation = new ReceiptInProcessLocation(); receiptInProcessLocation.InProcessLocation = inProcessLocation; receiptInProcessLocation.Receipt = receipt; this.receiptInProcessLocationMgrE.CreateReceiptInProcessLocation(receiptInProcessLocation); } } #endregion }
public void CreateReceipt(Receipt receipt, User user, bool isOddCreateHu) { log.Debug("Start create receipt"); #region �������еķ�����ջ�����ӡģ�壬�ջ����촦��ѡ�� string orderType = null; Party partyFrom = null; Party partyTo = null; ShipAddress shipFrom = null; ShipAddress shipTo = null; string dockDescription = null; string receiptTemplate = null; string huTemplate = null; string grGapTo = null; IList<InProcessLocationDetail> inProcessLocationDetailList = new List<InProcessLocationDetail>(); if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { InProcessLocation currentIp = inProcessLocationMgr.LoadInProcessLocation(inProcessLocation.IpNo); if (currentIp.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE) { throw new BusinessErrorException("InProcessLocation.Error.StatusErrorWhenReceive", currentIp.Status, currentIp.IpNo); } if (orderType == null) { orderType = inProcessLocation.OrderType; } //�ж�OrderHead��PartyFrom�Ƿ�һ�� if (partyFrom == null) { partyFrom = inProcessLocation.PartyFrom; } else if (inProcessLocation.PartyFrom.Code != partyFrom.Code) { throw new BusinessErrorException("Order.Error.ReceiveOrder.PartyFromNotEqual"); } //�ж�OrderHead��PartyFrom�Ƿ�һ�� if (partyTo == null) { partyTo = inProcessLocation.PartyTo; } else if (inProcessLocation.PartyTo.Code != partyTo.Code) { throw new BusinessErrorException("Order.Error.ReceiveOrder.PartyToNotEqual"); } //�ж�OrderHead��ShipFrom�Ƿ�һ�� if (shipFrom == null) { shipFrom = inProcessLocation.ShipFrom; } else if (!AddressHelper.IsAddressEqual(inProcessLocation.ShipFrom, shipFrom)) { throw new BusinessErrorException("Order.Error.ReceiveOrder.ShipFromNotEqual"); } //�ж�OrderHead��ShipTo�Ƿ�һ�� if (shipTo == null) { shipTo = inProcessLocation.ShipTo; } else if (!AddressHelper.IsAddressEqual(inProcessLocation.ShipTo, shipTo)) { throw new BusinessErrorException("Order.Error.ReceiveOrder.ShipToNotEqual"); } if (dockDescription == null) { dockDescription = inProcessLocation.DockDescription; } else if (inProcessLocation.DockDescription != dockDescription) { throw new BusinessErrorException("Order.Error.ReceiveOrder.DockDescriptionNotEqual"); } //�ж��ջ�����ӡģ���Ƿ�һ�� if (receiptTemplate == null) { receiptTemplate = inProcessLocation.ReceiptTemplate; } else { if (inProcessLocation.ReceiptTemplate != null && inProcessLocation.ReceiptTemplate != receiptTemplate) { throw new BusinessErrorException("Order.Error.ReceiveOrder.ReceiptTemplateNotEqual"); } } //�ж������ӡģ���Ƿ�һ�� if (huTemplate == null) { huTemplate = inProcessLocation.HuTemplate; } else { if (inProcessLocation.HuTemplate != null && inProcessLocation.HuTemplate != huTemplate) { throw new BusinessErrorException("Order.Error.ReceiveOrder.HuTemplateNotEqual"); } } #region �����ջ����촦��ѡ�� if (grGapTo == null) { grGapTo = inProcessLocation.GoodsReceiptGapTo; } else { if (inProcessLocation.GoodsReceiptGapTo != null && inProcessLocation.GoodsReceiptGapTo != grGapTo) { throw new BusinessErrorException("Order.Error.ReceiveOrder.GoodsReceiptGapToNotEqual"); } } #endregion IListHelper.AddRange<InProcessLocationDetail>( inProcessLocationDetailList, this.inProcessLocationDetailMgr.GetInProcessLocationDetail(inProcessLocation)); } } #endregion IList<ReceiptDetail> targetReceiptDetailList = receipt.ReceiptDetails; receipt.ReceiptDetails = null; //���Asn��ϸ���Ժ���� #region �����ջ���Head receipt.ReceiptNo = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_RECEIPT); receipt.OrderType = orderType; receipt.CreateDate = DateTime.Now; receipt.CreateUser = user; receipt.PartyFrom = partyFrom; receipt.PartyTo = partyTo; receipt.ShipFrom = shipFrom; receipt.ShipTo = shipTo; receipt.DockDescription = dockDescription; receipt.ReceiptTemplate = receiptTemplate; receipt.IsPrinted = false; receipt.NeedPrint = false; if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { if (inProcessLocation.NeedPrintReceipt) { receipt.NeedPrint = true; break; } } } this.CreateReceipt(receipt); log.Debug("Create receipt " + receipt.ReceiptNo + " head successful"); #endregion #region HU����/������/�����ջ���ϸ log.Debug("Start create receipt detail"); IList<LocationLotDetail> inspectLocationLotDetailList = new List<LocationLotDetail>(); foreach (ReceiptDetail receiptDetail in targetReceiptDetailList) { OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; if (orderHead.CreateHuOption == BusinessConstants.CODE_MASTER_CREATE_HU_OPTION_VALUE_GR && receiptDetail.HuId == null) //�����������Ϊ�ջ�ʱ����Hu�������ջ�ʱ�Ѿ�ɨ���Hu�ˣ�����ɨ�账�� { #region �ջ�ʱ����Hu log.Debug("Create receipt detail with generate barcode."); #region ���������ջ�+ʣ����ͷ����Hu decimal oddQty = 0; if (!isOddCreateHu && orderDetail.HuLotSize.HasValue && orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) //ֻ������֧����ͷ { #region ����ʣ����ͷ + �����ջ����Ƿ��ܹ�����Hu Hu oddHu = this.CreateHuFromOdd(receiptDetail, user); if (oddHu != null) { log.Debug("Generate barcode using odd qty."); //�����ͷ������Hu�������ջ�����ۼ� #region ����Hu IList<Hu> oddHuList = new List<Hu>(); oddHuList.Add(oddHu); IList<ReceiptDetail> oddReceiptDetailList = this.receiptDetailMgr.CreateReceiptDetail(receipt, orderLocationTransaction, oddHuList); log.Debug("Generate odd barcode successful."); #endregion #region ��� IList<InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(oddReceiptDetailList[0], user, receiptDetail.PutAwayBinCode); log.Debug("odd Inventory in successful."); #endregion #region �Ƿ���� if (orderDetail.NeedInspection && orderHead.NeedInspection && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); locationLotDetail.CurrentInspectQty = locationLotDetail.Qty; inspectLocationLotDetailList.Add(locationLotDetail); } } #endregion } #endregion oddQty = receiptDetail.ReceivedQty.HasValue && orderDetail.HuLotSize.HasValue ? receiptDetail.ReceivedQty.Value % orderDetail.HuLotSize.Value : 0; //�ջ���ͷ�� log.Debug("Receive odd qty is " + oddQty); receiptDetail.ReceivedQty = receiptDetail.ReceivedQty.Value - oddQty; //�ջ��������� } #endregion #region ����װ/��ͷ����Hu���� if (receiptDetail.ReceivedQty.HasValue || receiptDetail.RejectedQty.HasValue || receiptDetail.ScrapQty.HasValue) { //����Hu IList<Hu> huList = this.huMgr.CreateHu(receiptDetail, user); log.Debug("Create barcode successful."); //�����ջ��� IList<ReceiptDetail> receiptDetailList = this.receiptDetailMgr.CreateReceiptDetail(receipt, orderLocationTransaction, huList); log.Debug("Create receipt detail successful."); #region ������д�Ʒ���߷�Ʒ�ջ�����ӵ��ջ��б� if ((receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty > 0) || (receiptDetail.ScrapQty.HasValue && receiptDetail.ScrapQty > 0)) { ReceiptDetail rejAndScrapReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, rejAndScrapReceiptDetail); rejAndScrapReceiptDetail.ReceivedQty = null; rejAndScrapReceiptDetail.PutAwayBinCode = null; rejAndScrapReceiptDetail.Receipt = receipt; this.receiptDetailMgr.CreateReceiptDetail(rejAndScrapReceiptDetail); receiptDetailList.Add(rejAndScrapReceiptDetail); receipt.AddReceiptDetail(rejAndScrapReceiptDetail); } #endregion foreach (ReceiptDetail huReceiptDetail in receiptDetailList) { #region ƥ��ReceiptDetail��InProcessLocationDetail��Copy�����Ϣ if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { IList<InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList); if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count > 0) { if (matchInProcessLocationDetailList.Count > 1) { //ֻ�е�ASN�а������룬�������ջ������ջ���������п��ܷ������������ //��̬����ô�ɡ� log.Error("ֻ�е�ASN�а������룬�������ջ������ջ���������п��ܷ������������"); throw new BusinessErrorException("���DZ�̬����ô���á�"); } //����ҵ�ƥ���ֻ������һ�� huReceiptDetail.PlannedBill = matchInProcessLocationDetailList[0].PlannedBill; huReceiptDetail.IsConsignment = matchInProcessLocationDetailList[0].IsConsignment; huReceiptDetail.ShippedQty = matchInProcessLocationDetailList[0].Qty; this.receiptDetailMgr.UpdateReceiptDetail(huReceiptDetail); } //�ջ�����HU������PlannedAmount��todo���������� huReceiptDetail.PlannedAmount = receiptDetail.PlannedAmount / receiptDetail.ReceivedQty.Value * huReceiptDetail.ReceivedQty.Value; } #endregion #region ��� IList<InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(huReceiptDetail, user, receiptDetail.PutAwayBinCode); log.Debug("Inventory in successful."); #endregion #region �Ƿ���� if (orderDetail.NeedInspection && orderHead.NeedInspection && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML && huReceiptDetail.ReceivedQty.HasValue && huReceiptDetail.ReceivedQty > 0) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { if (inventoryTransaction.Location.Code != BusinessConstants.SYSTEM_LOCATION_REJECT) { LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); locationLotDetail.CurrentInspectQty = inventoryTransaction.Qty; inspectLocationLotDetailList.Add(locationLotDetail); } } } #endregion } } #endregion #region ����ʣ����ͷ���� if (oddQty > 0) { log.Debug("Start handle odd qty."); ReceiptDetail oddReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, oddReceiptDetail); oddReceiptDetail.ReceivedQty = oddQty; oddReceiptDetail.RejectedQty = 0; oddReceiptDetail.ScrapQty = 0; #region ��ͷ��� oddReceiptDetail.Receipt = receipt; IList<InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(oddReceiptDetail, user, receiptDetail.PutAwayBinCode); #endregion #region ��ͷ�����ջ���ϸ this.receiptDetailMgr.CreateReceiptDetail(oddReceiptDetail); receipt.AddReceiptDetail(oddReceiptDetail); #endregion #region ����HuOdd LocationLotDetail locationLotDetail = locationLotDetailMgr.LoadLocationLotDetail(inventoryTransactionList[0].LocationLotDetailId); this.huOddMgr.CreateHuOdd(oddReceiptDetail, locationLotDetail, user); #endregion log.Debug("End handle odd qty."); } #endregion #endregion } else { #region �ջ�ʱ������Hu log.Debug("Create receipt detail with no generate barcode."); #region ����Hu�ϵ�OrderNo��ReceiptNo��AntiResloveHu if (receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty) { Hu hu = this.huMgr.LoadHu(receiptDetail.HuId); bool isUpdated = false; if (hu.OrderNo == null || hu.ReceiptNo == null) { if (hu.OrderNo == null) { log.Debug("Update hu OrderNo " + orderHead.OrderNo + "."); hu.OrderNo = orderHead.OrderNo; } if (hu.ReceiptNo == null) { log.Debug("Update hu ReceiptNo " + receipt.ReceiptNo + "."); hu.ReceiptNo = receipt.ReceiptNo; } isUpdated = true; } if (hu.AntiResolveHu == null && orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { hu.AntiResolveHu = orderHead.AntiResolveHu; isUpdated = true; } if (isUpdated) { this.huMgr.UpdateHu(hu); } } #endregion IList<ReceiptDetail> noCreateHuReceiptDetailList = new List<ReceiptDetail>(); #region ƥ��ReceiptDetail��InProcessLocationDetail��Copy�����Ϣ log.Debug("Start match ReceiptDetail and InProcessLocationDetail."); if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION && orderHead.SubType != BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ) //�ջ������Ѿ�ƥ���InProcessLocationDetail������Ҫ��ƥ�� { IList<InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList); log.Debug("Find matched InProcessLocationDetailList, count = " + matchInProcessLocationDetailList != null ? matchInProcessLocationDetailList.Count : 0); if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count == 1) { //һ���ջ���Ӧһ�η����� log.Debug("one ipdet vs one receiptdet."); receiptDetail.PlannedBill = matchInProcessLocationDetailList[0].PlannedBill; receiptDetail.IsConsignment = matchInProcessLocationDetailList[0].IsConsignment; if (matchInProcessLocationDetailList[0].InProcessLocation.Type == BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_GAP) { receiptDetail.ShippedQty = 0 - matchInProcessLocationDetailList[0].Qty; } else { receiptDetail.ShippedQty = matchInProcessLocationDetailList[0].Qty; } receiptDetail.ReceivedInProcessLocationDetail = matchInProcessLocationDetailList[0]; noCreateHuReceiptDetailList.Add(receiptDetail); } else if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count > 1) { //һ���ջ���Ӧ��η����� //�磺���������룬�ջ��������� log.Debug("multi ipdet vs one receiptdet."); decimal totalRecQty = receiptDetail.ReceivedQty.Value; InProcessLocationDetail lastInProcessLocationDetail = null; log.Debug("Start Fetch matched InProcessLocationDetailList."); foreach (InProcessLocationDetail inProcessLocationDetail in matchInProcessLocationDetailList) { lastInProcessLocationDetail = inProcessLocationDetail; //��¼���һ�η������û�ж�Ӧ�������ջ���ʹ�� if (inProcessLocationDetail.ReceivedQty.HasValue && Math.Abs(inProcessLocationDetail.ReceivedQty.Value) >= Math.Abs(inProcessLocationDetail.Qty)) { continue; } if (Math.Abs(totalRecQty) > 0) { log.Debug("Start cloned ReceiptDetail."); ReceiptDetail clonedReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail); log.Debug("End cloned ReceiptDetail."); clonedReceiptDetail.PlannedBill = inProcessLocationDetail.PlannedBill; clonedReceiptDetail.IsConsignment = inProcessLocationDetail.IsConsignment; #region if (matchInProcessLocationDetailList[0].InProcessLocation.Type == BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_GAP) { inProcessLocationDetail.Qty = 0 - inProcessLocationDetail.Qty; } #endregion if (Math.Abs(totalRecQty) > Math.Abs(inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero))) { clonedReceiptDetail.ReceivedQty = inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero); clonedReceiptDetail.ShippedQty = inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero); totalRecQty -= inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero); } else { clonedReceiptDetail.ReceivedQty = totalRecQty; clonedReceiptDetail.ShippedQty = totalRecQty; totalRecQty = 0; } //��Ϊȥ������������¼�Ѿ�ƥ��ķ����������촦���ʱ��ƥ��������������졣 clonedReceiptDetail.ReceivedInProcessLocationDetail = inProcessLocationDetail; noCreateHuReceiptDetailList.Add(clonedReceiptDetail); } else { break; } } log.Debug("End Fetch matched InProcessLocationDetailList."); //���գ�û���ҵ���Ӧ�ķ����ֻ��¼�ջ�������������0 if (Math.Abs(totalRecQty) > 0) { ReceiptDetail clonedReceiptDetail = new ReceiptDetail(); CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail); clonedReceiptDetail.ShippedQty = 0; clonedReceiptDetail.ReceivedQty = totalRecQty; clonedReceiptDetail.ReceivedInProcessLocationDetail = lastInProcessLocationDetail; noCreateHuReceiptDetailList.Add(clonedReceiptDetail); } } else { noCreateHuReceiptDetailList.Add(receiptDetail); } } else { noCreateHuReceiptDetailList.Add(receiptDetail); } log.Debug("End match ReceiptDetail and InProcessLocationDetail."); #endregion foreach (ReceiptDetail noCreateHuReceiptDetail in noCreateHuReceiptDetailList) { noCreateHuReceiptDetail.Receipt = receipt; if (noCreateHuReceiptDetail.ReceivedQty != 0) { #region ��� log.Debug("Start Inventory In."); IList<InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(noCreateHuReceiptDetail, user, noCreateHuReceiptDetail.PutAwayBinCode); log.Debug("End Inventory In."); #endregion #region �Ƿ���� if (orderDetail.NeedInspection && orderHead.NeedInspection && inventoryTransactionList != null && inventoryTransactionList.Count > 0 && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { if (inventoryTransaction.Location.Code != BusinessConstants.SYSTEM_LOCATION_REJECT) { LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId); locationLotDetail.CurrentInspectQty = inventoryTransaction.Qty; inspectLocationLotDetailList.Add(locationLotDetail); } } } #endregion } #region �����ջ���ϸ log.Debug("Start Create Receipt Detail."); this.receiptDetailMgr.CreateReceiptDetail(noCreateHuReceiptDetail); receipt.AddReceiptDetail(noCreateHuReceiptDetail); log.Debug("End Create Receipt Detail."); #endregion } #endregion } } #endregion #region ���� if (inspectLocationLotDetailList.Count > 0) { //����û��Hu�ģ�����ջ�ʱ�Ѿ��س��˸�����棬Ҳ���ǿ�������ʹ�����������һ�¿��ܻ������� //����ipno��receiptno��isseperated�ֶ� this.inspectOrderMgr.CreateInspectOrder(inspectLocationLotDetailList, user, receipt.InProcessLocations[0].IpNo, receipt.ReceiptNo, false); } #endregion //#region ƥ���ջ���������Ҳ��� //IList<InProcessLocationDetail> gapInProcessLocationDetailList = new List<InProcessLocationDetail>(); //#region �����ƥ�� //foreach (InProcessLocationDetail inProcessLocationDetail in inProcessLocationDetailList) //{ // if (inProcessLocationDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type // != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) //������ʱ��֧�ֲ��� // { // decimal receivedQty = 0; //��������ۼ��ջ��� // //һ����������ܶ�Ӧ�����ջ��� // foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) // { // //ƥ���ջ���ͷ����� // if (receiptDetail.ReceivedInProcessLocationDetail != null) // { // //�����Ѿ�ƥ��ģ�ֱ�Ӱ�������ƥ�� // if (receiptDetail.ReceivedInProcessLocationDetail.Id == inProcessLocationDetail.Id) // { // if (receiptDetail.ReceivedQty.HasValue) // { // receivedQty += receiptDetail.ReceivedQty.Value; // } // } // } // else if (OrderHelper.IsInProcessLocationDetailMatchReceiptDetail( // inProcessLocationDetail, receiptDetail)) // { // if (receiptDetail.ReceivedQty.HasValue) // { // receivedQty += receiptDetail.ReceivedQty.Value; // } // } // } // if (receivedQty != inProcessLocationDetail.Qty) // { // #region �ջ������ͷ���������ƥ�䣬��¼���� // InProcessLocationDetail gapInProcessLocationDetail = new InProcessLocationDetail(); // gapInProcessLocationDetail.Qty = receivedQty - inProcessLocationDetail.Qty; // gapInProcessLocationDetail.OrderLocationTransaction = inProcessLocationDetail.OrderLocationTransaction; // //gapInProcessLocationDetail.HuId = inProcessLocationDetail.HuId; // gapInProcessLocationDetail.LotNo = inProcessLocationDetail.LotNo; // gapInProcessLocationDetail.IsConsignment = inProcessLocationDetail.IsConsignment; // gapInProcessLocationDetail.PlannedBill = inProcessLocationDetail.PlannedBill; // gapInProcessLocationDetailList.Add(gapInProcessLocationDetail); // #endregion // } // } //} //#endregion //#region �ջ��ƥ�� //foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) //{ // if (receiptDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type // != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) //������ʱ��֧�ֲ��� // { // IList<InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList); // if (matchInProcessLocationDetailList == null || matchInProcessLocationDetailList.Count == 0) // { // OrderLocationTransaction outOrderLocationTransaction = // this.orderLocationTransactionMgr.GetOrderLocationTransaction(receiptDetail.OrderLocationTransaction.OrderDetail, BusinessConstants.IO_TYPE_OUT)[0]; // #region û���ҵ����ջ����Ӧ�ķ����� // InProcessLocationDetail gapInProcessLocationDetail = new InProcessLocationDetail(); // gapInProcessLocationDetail.Qty = receiptDetail.ReceivedQty.Value; // gapInProcessLocationDetail.OrderLocationTransaction = outOrderLocationTransaction; // //gapInProcessLocationDetail.HuId = receiptDetail.HuId; // gapInProcessLocationDetail.LotNo = receiptDetail.LotNo; // gapInProcessLocationDetail.IsConsignment = receiptDetail.IsConsignment; // gapInProcessLocationDetail.PlannedBill = receiptDetail.PlannedBill; // gapInProcessLocationDetailList.Add(gapInProcessLocationDetail); // #endregion // } // } //} //#endregion //#endregion #region �ر�InProcessLocation if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { if (inProcessLocation.IsAsnUniqueReceipt) { //��֧�ֶ���ջ�ֱ�ӹر� this.inProcessLocationMgr.CloseInProcessLocation(inProcessLocation, user); } else { this.inProcessLocationMgr.TryCloseInProcessLocation(inProcessLocation, user); } //transportationOrderMgr.TryCompleteTransportationOrder(inProcessLocation, user); } } #endregion }
public void CreateReceipt(Receipt receipt, User user) { CreateReceipt(receipt, user, true); }
public virtual void UpdateReceipt(Receipt entity) { entityDao.UpdateReceipt(entity); }
public virtual void CreateReceipt(Receipt entity) { entityDao.CreateReceipt(entity); }
public virtual void ReceiveWo(IList<DssImportHistory> list, OrderDetail orderDetail, Receipt receipt) { try { IList<Hu> huList = this.ResolveAndCreateHu(list, orderDetail); this.orderManager.ReceiveOrder(receipt, this.userMgr.GetMonitorUser()); this.dssImportHistoryMgr.UpdateDssImportHistory(list, false); } catch (Exception ex) { foreach (var dssImportHistory in list) { dssImportHistory.Memo = ex.Message; dssImportHistory.ErrorCount++; } this.dssImportHistoryMgr.UpdateDssImportHistory(list); } }
public Receipt ReceiveOrder(Receipt receipt, string userCode) { return ReceiveOrder(receipt, this.userMgrE.CheckAndLoadUser(userCode), null, true, true); }
//重置收货数 public static void ClearReceivedQty(Receipt receipt) { if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { receiptDetail.ReceivedQty = 0; } } }
public Receipt ReceiveOrder(Receipt receipt, User user) { return ReceiveOrder(receipt, user, null, true, true); }
public Receipt ReceiveOrder(IList<ReceiptDetail> receiptDetailList, User user, InProcessLocation inProcessLocation, string externalReceiptNo, IList<WorkingHours> workingHoursList, bool createIp, bool isOddCreateHu) { if (receiptDetailList != null && receiptDetailList.Count > 0) { Receipt receipt = new Receipt(); if (inProcessLocation != null) { receipt.AddInProcessLocation(inProcessLocation); } receipt.ExternalReceiptNo = externalReceiptNo; foreach (ReceiptDetail receiptDetail in receiptDetailList) { receiptDetail.Receipt = receipt; receipt.AddReceiptDetail(receiptDetail); } return ReceiveOrder(receipt, user, workingHoursList, createIp, isOddCreateHu); } else { throw new BusinessErrorException("OrderDetail.Error.OrderDetailReceiveEmpty"); } }
public Receipt ReceiveOrder(IList<ReceiptDetail> receiptDetailList, User user, InProcessLocation inProcessLocation, string externalReceiptNo) { if (receiptDetailList != null && receiptDetailList.Count > 0) { Receipt receipt = new Receipt(); if (inProcessLocation != null) { receipt.AddInProcessLocation(inProcessLocation); } receipt.ExternalReceiptNo = externalReceiptNo; foreach (ReceiptDetail receiptDetail in receiptDetailList) { receiptDetail.Receipt = receipt; receipt.AddReceiptDetail(receiptDetail); } return ReceiveOrder(receipt, user, null, true, true); } else { throw new BusinessErrorException("OrderDetail.Error.OrderDetailReceiveEmpty"); } }
public Receipt ReceiveOrder(IList<ReceiptDetail> receiptDetailList, User user) { if (receiptDetailList != null && receiptDetailList.Count > 0) { Receipt receipt = new Receipt(); foreach (ReceiptDetail receiptDetail in receiptDetailList) { receiptDetail.Receipt = receipt; receipt.AddReceiptDetail(receiptDetail); } return ReceiveOrder(receipt, user, null, true, true); } else { throw new BusinessErrorException("OrderDetail.Error.OrderDetailReceiveEmpty"); } }
public Receipt ReceiveOrder(Receipt receipt, string userCode, IList<WorkingHours> workingHoursList, bool createIp, bool isOddCreateHu) { return ReceiveOrder(receipt, this.userMgrE.CheckAndLoadUser(userCode), workingHoursList, createIp, isOddCreateHu); }
public Receipt ReceiveOrder(Receipt receipt, string userCode, IList<WorkingHours> workingHoursList) { return ReceiveOrder(receipt, this.userMgrE.CheckAndLoadUser(userCode), workingHoursList, true, true); }
private void CheckReceiptOperationAuthrize(Receipt receipt, User user) { if (receipt == null) { throw new BusinessErrorException("MasterData.Receipt.NotExit"); } //bool partyFromAuthrized = false; bool partyToAuthrized = false; foreach (Permission permission in user.Permissions) { //if (permission.Code == receipt.PartyFrom.Code) //{ // partyFromAuthrized = true; //} if (permission.Code == receipt.PartyTo.Code) { partyToAuthrized = true; break; } //if (partyFromAuthrized && partyToAuthrized) //{ // break; //} } //if (!(partyFromAuthrized && partyToAuthrized)) if (!partyToAuthrized) { //û�и�asn�IJ���Ȩ�� throw new BusinessErrorException("Receipt.Error.NoAuthrization", receipt.ReceiptNo); } }
public Receipt ReceiveOrder(Receipt receipt, User user, IList<WorkingHours> workingHoursList) { return ReceiveOrder(receipt, user, workingHoursList, true, true); }
public IList<InventoryTransaction> InventoryIn(Receipt receipt, User user) { if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { IList<InventoryTransaction> resultInventoryTransactionList = new List<InventoryTransaction>(); foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { IList<InventoryTransaction> inventoryTransactionList = InventoryIn(receiptDetail, user); IListHelper.AddRange<InventoryTransaction>(resultInventoryTransactionList, inventoryTransactionList); } return resultInventoryTransactionList; } return null; }
public virtual void ProcessSingleFile(string inboundDirectoryName, string inboundFileName) { log.Info("Start inbound file " + inboundFileName); FlatFileReader reader = new FlatFileReader(inboundFileName, Encoding.ASCII, "\t"); try { OrderHead orderHead = null; OrderDetail orderDetail = null; string shiftCode = string.Empty; Hu hu = null; string[] fields = reader.ReadLine(); while (fields != null) { string prodLine = fields[0]; string itemCode = fields[1]; string huId = fields[2]; decimal qty = decimal.Parse(fields[3]); string itemHuId = fields[4]; string onlineDate = fields[5]; string onlineTime = fields[6]; string offlineDate = fields[7]; string offlineTime = fields[8]; string customerCode = fields[9]; string customerLoc = fields[10]; if (orderHead == null) { #region 查找工单 shiftCode = BarcodeHelper.GetShiftCode(huId); DetachedCriteria criteria = DetachedCriteria.For<OrderHead>(); criteria.CreateAlias("Flow", "f"); //criteria.CreateAlias("Shift", "s"); criteria.Add(Expression.Like("f.Code", prodLine, MatchMode.End)); criteria.Add(Expression.Eq("s.Code", shiftCode)); criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)); criteria.AddOrder(Order.Asc("StartTime")); IList<OrderHead> orderHeadList = this.criteriaMgrE.FindAll<OrderHead>(criteria); #endregion if (orderHeadList != null && orderHeadList.Count > 0) { foreach(OrderHead targetOrderHead in orderHeadList) { orderHead = targetOrderHead; #region 查找工单明细 IList<OrderDetail> orderDetailList = orderHead.OrderDetails; foreach (OrderDetail targetOrderDetail in orderDetailList) { if (targetOrderDetail.Item.Code == itemCode) { log.Info("Find match wo " + orderHead.OrderNo); orderDetail = targetOrderDetail; orderDetail.CurrentReceiveQty = qty; break; } } #endregion if (orderDetail != null) { break; } } } else { throw new BusinessErrorException("No active wo find for prodline + " + prodLine + ", shift " + shiftCode); } if (orderDetail != null) { #region 创建外包装条码 if (this.huMgrE.LoadHu(huId) == null) { log.Info("Insert hu " + huId + " into database."); hu = ResolveAndCreateHu(huId, orderDetail, qty); orderDetail.HuId = hu.HuId; Receipt receipt = new Receipt(); ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; receiptDetail.HuId = hu.HuId; receiptDetail.ReceivedQty = qty; receiptDetail.Receipt = receipt; #region 找Out的OrderLocTrans,填充MaterialFulshBack IList<OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { MaterialFlushBack material = new MaterialFlushBack(); material.OrderLocationTransaction = orderLocTrans; if (orderLocTrans.UnitQty != 0) { material.Qty = qty; } receiptDetail.AddMaterialFlushBack(material); } #endregion receipt.AddReceiptDetail(receiptDetail); this.orderManager.ReceiveOrder(receipt, this.userMgrE.GetMonitorUser()); } else { throw new BusinessErrorException("Hu " + huId + " already exist in database."); } #endregion } else { throw new BusinessErrorException("No item found for item code " + itemCode + " for prodline + " + prodLine + ", shift " + shiftCode); } } #region 创建内包装条码 if (this.huMgrE.LoadHu(itemHuId) == null) { log.Info("Insert hu " + itemHuId + " into database."); CreateItemHu(itemHuId, orderDetail, hu.LotNo, hu.ManufactureDate); } else { throw new BusinessErrorException("Hu " + itemHuId + " already exist in database."); } #endregion fields = reader.ReadLine(); } } finally { reader.Dispose(); } }
public Receipt ReceiveOrder(Receipt receipt, User user, IList<WorkingHours> workingHoursList, bool createIp) { return ReceiveOrder(receipt, user, workingHoursList, createIp, true); }
private ReceiptNote Receipt2ReceiptNote(Receipt receipt) { ReceiptNote receiptNote = new ReceiptNote(); receiptNote.OrderNo = receipt.ReceiptNo; receiptNote.CreateDate = receipt.CreateDate; receiptNote.CreateUser = receipt.CreateUser == null ? string.Empty : receipt.CreateUser.Code; receiptNote.Status = "Close"; return receiptNote; }
public Receipt ReceiveOrder(Receipt receipt, User user, IList<WorkingHours> workingHoursList, bool createIp, bool isOddCreateHu) { #region 变量定义 IDictionary<string, OrderHead> cachedOrderHead = new Dictionary<string, OrderHead>(); //缓存用到的OrderHead DateTime dateTimeNow = DateTime.Now; #endregion #region 判断全0收货 if (receipt != null && receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { //判断全0收货 IList<ReceiptDetail> nonZeroReceiptDetailList = new List<ReceiptDetail>(); foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { if (!receiptDetail.ReceivedQty.HasValue) { receiptDetail.ReceivedQty = 0; } if (!receiptDetail.RejectedQty.HasValue) { receiptDetail.RejectedQty = 0; } if (!receiptDetail.ScrapQty.HasValue) { receiptDetail.ScrapQty = 0; } if (receiptDetail.ReceivedQty.Value != 0 || receiptDetail.RejectedQty.Value != 0 || receiptDetail.ScrapQty.Value != 0) { nonZeroReceiptDetailList.Add(receiptDetail); } } if (nonZeroReceiptDetailList.Count == 0) { throw new BusinessErrorException("OrderDetail.Error.OrderDetailReceiveEmpty"); } receipt.ReceiptDetails = nonZeroReceiptDetailList; } else { throw new BusinessErrorException("OrderDetail.Error.OrderDetailReceiveEmpty"); } #endregion #region 为未发货就收货创建ASN if ((receipt.InProcessLocations == null || receipt.InProcessLocations.Count == 0) && createIp) { InProcessLocation inProcessLocation = new InProcessLocation(); #region 循环收货列表,并添加到发货列表中 foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; if (receiptDetail.MaterialFlushBack != null && receiptDetail.MaterialFlushBack.Count > 0) { #region 根据物料回冲创建ASN,只适应生产,其它情况没有测试 foreach (MaterialFlushBack materialFlushBack in receiptDetail.MaterialFlushBack) { InProcessLocationDetail inProcessLocationDetail = new InProcessLocationDetail(); inProcessLocationDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.LoadOrderLocationTransaction(materialFlushBack.OrderLocationTransaction.Id); inProcessLocationDetail.HuId = materialFlushBack.HuId; inProcessLocationDetail.LotNo = materialFlushBack.LotNo; inProcessLocationDetail.Qty = materialFlushBack.Qty; inProcessLocationDetail.InProcessLocation = inProcessLocation; inProcessLocation.AddInProcessLocationDetail(inProcessLocationDetail); } #endregion } else { #region 根据out的OrderLocationTransaction自动创建ASN IList<OrderLocationTransaction> orderLocationTransactionList = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (OrderLocationTransaction orderLocTrans in orderLocationTransactionList) { #region 直接Copy收货项至发货项 InProcessLocationDetail inProcessLocationDetail = new InProcessLocationDetail(); if (orderHead.IsShipScanHu) { //只有发货扫描条码才复制条码信息 inProcessLocationDetail.HuId = receiptDetail.HuId; inProcessLocationDetail.LotNo = receiptDetail.LotNo; } inProcessLocationDetail.OrderLocationTransaction = orderLocTrans; inProcessLocationDetail.Qty = receiptDetail.ReceivedQty.Value + receiptDetail.RejectedQty.Value + receiptDetail.ScrapQty.Value; inProcessLocationDetail.InProcessLocation = inProcessLocation; inProcessLocation.AddInProcessLocationDetail(inProcessLocationDetail); #endregion } #endregion } } #endregion #region 发货 DoShipOrder(inProcessLocation, user, true); receipt.AddInProcessLocation(inProcessLocation); #endregion } #endregion #region 更新订单信息 EntityPreference entityPreference = this.entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_NO_PRICE_LIST_RECEIPT); string taxCode = entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_TAX_RATE).Value; foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { OrderLocationTransaction orderLocationTransaction = this.orderLocationTransactionMgrE.LoadOrderLocationTransaction(receiptDetail.OrderLocationTransaction.Id); receiptDetail.OrderLocationTransaction = orderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; #region 判断OrderHead状态并缓存 if (!cachedOrderHead.ContainsKey(orderHead.OrderNo)) { //检查权限 //if (!OrderHelper.CheckOrderOperationAuthrize(orderHead, user, BusinessConstants.ORDER_OPERATION_RECEIVE_ORDER)) //{ // throw new BusinessErrorException("Order.Error.NoReceivePermission", orderHead.OrderNo); //} //判断OrderHead状态,只要有ASN就都可以收货 if (!(orderHead.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS || orderHead.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_COMPLETE || orderHead.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE)) { throw new BusinessErrorException("Order.Error.StatusErrorWhenReceive", orderHead.Status, orderHead.OrderNo); } //缓存OrderHead cachedOrderHead.Add(orderHead.OrderNo, orderHead); } #endregion #region 整包装收货判断,快速的不考虑 if (orderHead.FulfillUnitCount && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML && !(orderHead.IsAutoRelease && orderHead.IsAutoStart)) { if (receiptDetail.ReceivedQty % orderDetail.UnitCount != 0) { //不是整包装 throw new BusinessErrorException("Order.Error.NotFulfillUnitCountGrGi", orderDetail.Item.Code); } } #endregion #region 是否过量收货判断 if (orderDetail.OrderHead.SubType != BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ) { EntityPreference allowExceedentityPreference = this.entityPreferenceMgrE.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_ALLOW_EXCEED_GI_GR); bool allowExceedGiGR = bool.Parse(allowExceedentityPreference.Value); //企业属性,允许过量发货和收货 //检查Received(已收数)不能大于等于OrderedQty(订单数) //if (!(orderHead.AllowExceed && allowExceedGiGR) && orderDetail.ReceivedQty.HasValue) //{ // if ((orderDetail.OrderedQty > 0 && orderDetail.ReceivedQty.Value >= orderDetail.OrderedQty) // || (orderDetail.OrderedQty < 0 && orderDetail.ReceivedQty.Value <= orderDetail.OrderedQty)) // { // throw new BusinessErrorException("Order.Error.ReceiveExcceed", orderHead.OrderNo, orderDetail.Item.Code); // } //} if (!(orderHead.AllowExceed && allowExceedGiGR)) //不允许过量收货 { //检查AccumulateQty(已收数) + CurrentReceiveQty(本次收货数)不能大于OrderedQty(订单数) orderDetail.ReceivedQty = orderDetail.ReceivedQty.HasValue ? orderDetail.ReceivedQty.Value : 0; if ((orderDetail.OrderedQty > 0 && orderDetail.ReceivedQty + receiptDetail.ReceivedQty > orderDetail.OrderedQty) || (orderDetail.OrderedQty < 0 && orderDetail.ReceivedQty + receiptDetail.ReceivedQty < orderDetail.OrderedQty)) { throw new BusinessErrorException("Order.Error.ReceiveExcceed", orderHead.OrderNo, orderDetail.Item.Code); } } } #endregion #region 采购收货是否有价格单判断 if ((orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING) && !bool.Parse(entityPreference.Value)) { if (orderDetail.UnitPrice == Decimal.Zero) { //重新查找一次价格 PriceListDetail priceListDetail = priceListDetailMgrE.GetLastestPriceListDetail( orderDetail.DefaultPriceList, orderDetail.Item, orderHead.StartTime, orderHead.Currency, orderDetail.Uom); if (priceListDetail != null) { orderDetail.UnitPrice = priceListDetail.UnitPrice; orderDetail.IsProvisionalEstimate = priceListDetail.IsProvisionalEstimate; orderDetail.IsIncludeTax = priceListDetail.IsIncludeTax; orderDetail.TaxCode = taxCode; //priceListDetail.TaxCode; } else { throw new BusinessErrorException("Order.Error.NoPriceListReceipt", orderDetail.Item.Code); } } } #endregion #region 计算PlannedAmount,用ReceiptDetail缓存本次收货产生的PlannedAmount金额,在创建PlannedBill时使用 if (!orderDetail.ReceivedQty.HasValue) { orderDetail.ReceivedQty = 0; } if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION) { CalculatePlannedAmount(orderDetail, receiptDetail, orderDetail.IncludeTaxTotalPrice); } #endregion #region 记录OrderDetail的累计收货量 orderDetail.ReceivedQty += receiptDetail.ReceivedQty.Value; orderDetail.RejectedQty = receiptDetail.RejectedQty.Value + (orderDetail.RejectedQty == null ? 0 : orderDetail.RejectedQty); orderDetail.ScrapQty = receiptDetail.ScrapQty.Value + (orderDetail.ScrapQty == null ? 0 : orderDetail.ScrapQty); this.orderDetailMgrE.UpdateOrderDetail(orderDetail); #endregion #region 记录OrderLocationTransaction的累计收货量 #region 成品 if (!orderLocationTransaction.AccumulateQty.HasValue) { orderLocationTransaction.AccumulateQty = 0; } orderLocationTransaction.AccumulateQty += receiptDetail.ReceivedQty.Value * orderLocationTransaction.UnitQty; #endregion #region 次品 if (!orderLocationTransaction.AccumulateRejectQty.HasValue) { orderLocationTransaction.AccumulateRejectQty = 0; } orderLocationTransaction.AccumulateRejectQty += receiptDetail.RejectedQty.Value * orderLocationTransaction.UnitQty; #endregion #region 废品 if (!orderLocationTransaction.AccumulateScrapQty.HasValue) { orderLocationTransaction.AccumulateScrapQty = 0; } orderLocationTransaction.AccumulateScrapQty += receiptDetail.ScrapQty.Value * orderLocationTransaction.UnitQty; #endregion this.orderLocationTransactionMgrE.UpdateOrderLocationTransaction(orderLocationTransaction); #endregion } #endregion #region 创建收货单 this.receiptMgrE.CreateReceipt(receipt, user, isOddCreateHu); #endregion #region 记录工时 if (workingHoursList != null) { foreach (WorkingHours workingHours in workingHoursList) { workingHours.Receipt = receipt; workingHours.LastModifyDate = DateTime.Now; workingHours.LastModifyUser = user; this.workingHoursMgrE.CreateWorkingHours(workingHours); } } #endregion #region 更新订单头信息 foreach (OrderHead orderHead in cachedOrderHead.Values) { orderHead.LastModifyUser = user; orderHead.LastModifyDate = dateTimeNow; this.orderHeadMgrE.UpdateOrderHead(orderHead); if (!orderHead.AllowRepeatlyExceed) { TryCompleteOrder(orderHead, user); } } #endregion #region 处理委外加工 foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; Flow flow = this.flowMgrE.LoadFlow(orderHead.Flow); if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING) { Flow productionFlow = this.flowMgrE.LoadFlow(flow.ReferenceFlow, true); OrderHead productionOrderHead = this.TransferFlow2Order(productionFlow, false); foreach (FlowDetail productionFlowDetail in productionFlow.FlowDetails) { if (productionFlowDetail.DefaultLocationTo != null && receiptDetail.OrderLocationTransaction.Location.Code //目的库位相同 == productionFlowDetail.DefaultLocationTo.Code && receiptDetail.OrderLocationTransaction.Item.Code == productionFlowDetail.Item.Code) { OrderDetail productionOrderDetail = this.orderDetailMgrE.TransferFlowDetail2OrderDetail(productionFlowDetail); #region 合并相同的productionOrderDetail bool findMatch = false; if (productionOrderHead.OrderDetails != null && productionOrderHead.OrderDetails.Count > 0) { foreach (OrderDetail addProductionOrderDetail in productionOrderHead.OrderDetails) { if (productionOrderDetail.Item.Code == addProductionOrderDetail.Item.Code && productionOrderDetail.Uom.Code == addProductionOrderDetail.Uom.Code && productionOrderDetail.UnitCount == addProductionOrderDetail.UnitCount && LocationHelper.IsLocationEqual(productionOrderDetail.DefaultLocationFrom, addProductionOrderDetail.DefaultLocationFrom) && LocationHelper.IsLocationEqual(productionOrderDetail.DefaultLocationTo, addProductionOrderDetail.DefaultLocationTo)) { decimal addQty = receiptDetail.ReceivedQty.Value; if (addProductionOrderDetail.Uom.Code != orderDetail.Uom.Code) { addProductionOrderDetail.OrderedQty += this.uomConversionMgrE.ConvertUomQty(addProductionOrderDetail.Item, orderDetail.Uom, addQty, productionOrderDetail.Uom); } else { addProductionOrderDetail.OrderedQty += addQty; } findMatch = true; } } } #endregion if (!findMatch) { productionOrderDetail.OrderHead = productionOrderHead; productionOrderDetail.OrderedQty = receiptDetail.ReceivedQty.Value; if (productionOrderDetail.Uom.Code != orderDetail.Uom.Code) { productionOrderDetail.OrderedQty = this.uomConversionMgrE.ConvertUomQty(productionOrderDetail.Item, orderDetail.Uom, receiptDetail.ReceivedQty.Value, productionOrderDetail.Uom); } productionOrderHead.AddOrderDetail(productionOrderDetail); } } } if (productionOrderHead.OrderDetails != null && productionOrderHead.OrderDetails.Count > 0) { productionOrderHead.IsAutoRelease = true; productionOrderHead.IsAutoStart = true; productionOrderHead.IsAutoShip = true; productionOrderHead.IsAutoReceive = true; productionOrderHead.StartLatency = 0; productionOrderHead.CompleteLatency = 0; productionOrderHead.StartTime = orderHead.StartTime; productionOrderHead.WindowTime = orderHead.WindowTime; productionOrderHead.ReferenceOrderNo = orderHead.OrderNo; productionOrderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL; productionOrderHead.IsSubcontract = true; this.CreateOrder(productionOrderHead, user); } } } #endregion #region 处理路线绑定 foreach (OrderHead orderHead in cachedOrderHead.Values) { this.CreateBindingOrder(orderHead, user, BusinessConstants.CODE_MASTER_BINDING_TYPE_VALUE_RECEIVE_ASYN, BusinessConstants.CODE_MASTER_BINDING_TYPE_VALUE_RECEIVE_SYN); } #endregion return receipt; }
private Receipt BuildReceipt(OrderLocationTransaction orderLocationTransaction, IList<DssImportHistory> dssImportHistoryList) { if (orderLocationTransaction == null || dssImportHistoryList == null || dssImportHistoryList.Count == 0) return null; Receipt receipt = new Receipt(); IList<OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgr.GetOrderLocationTransaction(orderLocationTransaction.OrderDetail.Id, BusinessConstants.IO_TYPE_OUT); foreach (var dssImportHistory in dssImportHistoryList) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.Receipt = receipt; receiptDetail.OrderLocationTransaction = orderLocationTransaction; receiptDetail.HuId = dssImportHistory.HuId; receiptDetail.ReceivedQty = dssImportHistory.Qty; #region 找Out的OrderLocTrans,填充MaterialFlushBack foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { MaterialFlushBack material = new MaterialFlushBack(); material.OrderLocationTransaction = orderLocTrans; if (orderLocTrans.UnitQty != 0) { material.Qty = dssImportHistory.Qty; } receiptDetail.AddMaterialFlushBack(material); } #endregion receipt.AddReceiptDetail(receiptDetail); } return receipt; }
public Receipt ConvertOrderDetailToReceipt(IList<OrderDetail> orderDetailList) { Receipt receipt = new Receipt(); if (orderDetailList != null && orderDetailList.Count > 0) { foreach (OrderDetail orderDetail in orderDetailList) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; if (orderDetail.OrderHead.IsReceiptScanHu) //只有收货扫描条码赋值 { receiptDetail.HuId = orderDetail.HuId; } //receiptDetail.ShippedQty = orderDetail.RemainShippedQty; ShippedQty都是后台赋值的,从InProcessLocationDetail中取值 //receiptDetail.ReceivedQty = receiptDetail.ShippedQty; receiptDetail.ReceivedQty = orderDetail.RemainShippedQty; receiptDetail.Receipt = receipt; //if (receiptDetail.ShippedQty != 0)//过滤已收满数量 if (receiptDetail.ReceivedQty != 0)//过滤已收满数量 receipt.AddReceiptDetail(receiptDetail); } } return receipt; }
public virtual void DeleteReceipt(Receipt entity) { entityDao.DeleteReceipt(entity); }
public Receipt ConvertInProcessLocationToReceipt(InProcessLocation inProcessLocation, IDictionary<string, string> huIdStorageBinDic, string externalOrderNo) { Receipt receipt = new Receipt(); receipt.ExternalReceiptNo = externalOrderNo; receipt.AddInProcessLocation(inProcessLocation); if (inProcessLocation.InProcessLocationDetails != null && inProcessLocation.InProcessLocationDetails.Count > 0) { foreach (InProcessLocationDetail inProcessLocationDetail in inProcessLocation.InProcessLocationDetails) { OrderLocationTransaction orderLocationTransaction = inProcessLocationDetail.OrderLocationTransaction; OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; OrderLocationTransaction inOrderLocationTransaction = this.orderLocationTransactionMgrE.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0]; bool isMerge = false; if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0 && !inProcessLocation.IsReceiptScanHu) { //如果收货不扫描条码,收货项需要根据发货项进行合并 foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails) { if (inOrderLocationTransaction.Id == receiptDetail.OrderLocationTransaction.Id) { //if (inProcessLocationDetail.IsConsignment == receiptDetail.IsConsignment // && inProcessLocationDetail.PlannedBill == receiptDetail.PlannedBill) { // throw new BusinessErrorException("寄售库存,不能按按数量进行收货。"); //} isMerge = true; receiptDetail.ShippedQty += inProcessLocationDetail.Qty; receiptDetail.ReceivedQty += inProcessLocationDetail.Qty; break; } } } if (!isMerge) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = inOrderLocationTransaction; receiptDetail.Id = inProcessLocationDetail.Id; receiptDetail.ShippedQty = inProcessLocationDetail.Qty; receiptDetail.ReceivedQty = inProcessLocationDetail.Qty; if (inProcessLocation.IsReceiptScanHu) //只有按条码收货才Copy条码信息 { receiptDetail.HuId = inProcessLocationDetail.HuId; receiptDetail.LotNo = inProcessLocationDetail.LotNo; //上架库位赋值 if (inOrderLocationTransaction.OrderDetail.OrderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML && huIdStorageBinDic != null && receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty && huIdStorageBinDic.ContainsKey(receiptDetail.HuId.Trim())) { receiptDetail.PutAwayBinCode = huIdStorageBinDic[receiptDetail.HuId.Trim()]; } } receiptDetail.IsConsignment = inProcessLocationDetail.IsConsignment; receiptDetail.PlannedBill = inProcessLocationDetail.PlannedBill; receiptDetail.Receipt = receipt; if (receiptDetail.ShippedQty != 0)//过滤已收满数量 { receipt.AddReceiptDetail(receiptDetail); } } } } return receipt; }
/* * 填充报表头 * * Param pageIndex 页号 * Param orderHead 订单头对象 * Param orderDetails 订单明细对象 */ private void FillHead(Receipt Receipt) { string receiptCode = Utility.BarcodeHelper.GetBarcodeStr(Receipt.ReceiptNo, this.barCodeFontName); //收货单号: this.SetRowCell(2, 5, receiptCode); //收货单号: this.SetRowCell(3, 5, Receipt.ReceiptNo); //外部单据号: this.SetRowCell(4, 1, Receipt.ExternalReceiptNo); //ASN号: this.SetRowCell(4, 5, Receipt.ReferenceIpNo); //供应商代码: this.SetRowCell(5, 1, Receipt.PartyFrom.Code); //供应商名称: this.SetRowCell(6, 1, Receipt.PartyFrom.Name); //承运商: //this.SetRowCell(6, 1, ); //收货日期: this.SetRowCell(5, 5, Receipt.CreateDate.ToString("yyyy-MM-dd HH:mm")); //收货部门: this.SetRowCell(6, 5, Receipt.PartyTo.Code + " [" + Receipt.PartyTo.Name + "]"); //收货地点: this.SetRowCell(7, 5, Receipt.DockDescription); //实际收货时间: this.SetRowCell(36, 1, Receipt.CreateDate.ToString()); //收货人签字: this.SetRowCell(36, 4, Receipt.CreateUser.Name); }
public override void CreateReceipt(Receipt receipt) { #region ��Receipt�ϼ�¼�ο�Asn��Ϊ�ִ� string ipNo = null; if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { if (ipNo == null) { ipNo = inProcessLocation.IpNo; } else { ipNo += ", " + inProcessLocation.IpNo; } } } receipt.ReferenceIpNo = ipNo; #endregion this.entityDao.CreateReceipt(receipt); #region �����ջ��ͷ�����ϵ if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0) { foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations) { ReceiptInProcessLocation receiptInProcessLocation = new ReceiptInProcessLocation(); receiptInProcessLocation.InProcessLocation = inProcessLocation; receiptInProcessLocation.Receipt = receipt; this.receiptInProcessLocationMgr.CreateReceiptInProcessLocation(receiptInProcessLocation); } } #endregion }