protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PO_CED_1410 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here List <Guid> positionsForCreating = new List <Guid>(); Guid headerID = new Guid(); var procurementHeader = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Header(); procurementHeader.Load(Connection, Transaction, Parameter.ProcurementHeaderID); if (procurementHeader == null) { throw new Exception("wrong procurment header!"); } #region Update Procurement Order var newProcurementOrderStatusID = CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Status.Query() { GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(EProcurementStatus.Ordered), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single().ORD_PRC_ProcurementOrder_StatusID; procurementHeader.Current_ProcurementOrderStatus_RefID = newProcurementOrderStatusID; procurementHeader.Save(Connection, Transaction); // Create procurement order status history var procurementOrderStatusHistory = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_StatusHistory(); procurementOrderStatusHistory.Tenant_RefID = securityTicket.TenantID; procurementOrderStatusHistory.ProcurementOrder_Header_RefID = procurementHeader.ORD_PRC_ProcurementOrder_HeaderID; procurementOrderStatusHistory.ProcurementOrder_Status_RefID = newProcurementOrderStatusID; procurementOrderStatusHistory.StatusHistoryComment = ""; procurementOrderStatusHistory.Save(Connection, Transaction); #endregion var procurementPositionsQuery = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position.Query(); procurementPositionsQuery.ProcurementOrder_Header_RefID = Parameter.ProcurementHeaderID; procurementPositionsQuery.Tenant_RefID = securityTicket.TenantID; procurementPositionsQuery.IsDeleted = false; var foundProcurementPositions = CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position.Query.Search(Connection, Transaction, procurementPositionsQuery).ToList(); //positionIDs var positionIDs = foundProcurementPositions.Select(x => x.ORD_PRC_ProcurementOrder_PositionID); //find expected delivery data if exist P_L5PO_GEDfPOP_1132 expDeliveryParam = new P_L5PO_GEDfPOP_1132(); expDeliveryParam.ProcurementOrderPositions = positionIDs.ToArray(); var expectedDeliveries = cls_Get_ExpectedDeliveries_for_ProcurementOrderPositions.Invoke(Connection, Transaction, expDeliveryParam, securityTicket).Result; CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_Header expectedDeliveryHeader = new CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_Header(); if (expectedDeliveries != null && expectedDeliveries.Length > 0) { expectedDeliveryHeader = new ORM_ORD_PRC_ExpectedDelivery_Header(); expectedDeliveryHeader.Load(Connection, Transaction, expectedDeliveries.First().ORD_PRC_ExpectedDelivery_HeaderID); expectedDeliveryHeader.ExpectedDeliveryDate = Parameter.ExpectedDeliveryDate; expectedDeliveryHeader.Save(Connection, Transaction); headerID = expectedDeliveryHeader.ORD_PRC_ExpectedDelivery_HeaderID; foreach (var item in expectedDeliveries) { if (!positionIDs.Contains(item.ORD_PRC_ProcurementOrder_Position_RefID)) { positionsForCreating.Add(item.ORD_PRC_ProcurementOrder_Position_RefID); } } } else { positionsForCreating.AddRange(positionIDs); //napraviti header expectedDeliveryHeader.ORD_PRC_ExpectedDelivery_HeaderID = Guid.NewGuid(); expectedDeliveryHeader.ExpectedDeliveryHeaderITL = expectedDeliveryHeader.ORD_PRC_ExpectedDelivery_HeaderID.ToString(); //finding global property matchin id from number ranges for expected delivery var expectedDeliveryNumberParam = new CL2_NumberRange.Complex.Retrieval.P_L2NR_GaIINfUA_1454(); expectedDeliveryNumberParam.GlobalStaticMatchingID = DLCore_DBCommons.Utils.EnumUtils. GetEnumDescription(DLCore_DBCommons.APODemand.ENumberRangeUsageAreaType.ExpectedDeliveryNumber); expectedDeliveryHeader.ExpectedDeliveryNumber = CL2_NumberRange.Complex.Retrieval.cls_Get_and_Increase_IncreasingNumber_for_UsageArea. Invoke(Connection, Transaction, expectedDeliveryNumberParam, securityTicket).Result.Current_IncreasingNumber; expectedDeliveryHeader.ExpectedDeliveryDate = Parameter.ExpectedDeliveryDate; expectedDeliveryHeader.LOG_WRH_Warehouse_RefID = Guid.Empty; expectedDeliveryHeader.IsDeleted = false; expectedDeliveryHeader.Tenant_RefID = securityTicket.TenantID; expectedDeliveryHeader.IsDeliveryOpen = true; expectedDeliveryHeader.IsDeliveryManuallyCreated = true; expectedDeliveryHeader.Save(Connection, Transaction); headerID = expectedDeliveryHeader.ORD_PRC_ExpectedDelivery_HeaderID; } #region Get receiptHeader or create it if don't exist var queryProcurement = new CL1_LOG_RCP.ORM_LOG_RCP_ReceiptHeader_2_ProcurementOrderHeader.Query() { ORD_PRO_ProcurementOrder_Header_RefID = Parameter.ProcurementHeaderID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }; var receiptToProcurementHeader = CL1_LOG_RCP.ORM_LOG_RCP_ReceiptHeader_2_ProcurementOrderHeader.Query.Search(Connection, Transaction, queryProcurement).SingleOrDefault(); var receiptHeader = new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Header(); Guid receiptHeaderID = Guid.Empty; if (receiptToProcurementHeader == null) { var incrNumberParam = new P_L2NR_GaIINfUA_1454() { GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.StockReceiptNumber) }; var receiptNumber = cls_Get_and_Increase_IncreasingNumber_for_UsageArea.Invoke(Connection, Transaction, incrNumberParam, securityTicket).Result.Current_IncreasingNumber; receiptHeader = new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Header(); receiptHeader.ReceiptNumber = receiptNumber; receiptHeader.ExpectedDeliveryHeader_RefID = expectedDeliveryHeader.ORD_PRC_ExpectedDelivery_HeaderID; receiptHeader.ProvidingSupplier_RefID = procurementHeader.ProcurementOrder_Supplier_RefID; receiptHeader.LOG_RCP_Receipt_HeaderID = Guid.NewGuid(); receiptHeader.Creation_Timestamp = DateTime.Now; receiptHeader.ReceiptHeaderITL = receiptHeader.LOG_RCP_Receipt_HeaderID.ToString(); receiptHeader.IsTakenIntoStock = false; receiptHeader.Tenant_RefID = securityTicket.TenantID; receiptHeader.Save(Connection, Transaction); receiptHeaderID = receiptHeader.LOG_RCP_Receipt_HeaderID; var receipt2sProcurementHeader = new CL1_LOG_RCP.ORM_LOG_RCP_ReceiptHeader_2_ProcurementOrderHeader(); receipt2sProcurementHeader.LOG_RCP_Receipt_Header_RefID = receiptHeaderID; receipt2sProcurementHeader.ORD_PRO_ProcurementOrder_Header_RefID = procurementHeader.ORD_PRC_ProcurementOrder_HeaderID; receipt2sProcurementHeader.Tenant_RefID = securityTicket.TenantID; receipt2sProcurementHeader.IsDeleted = false; receipt2sProcurementHeader.Creation_Timestamp = DateTime.Now; receipt2sProcurementHeader.Save(Connection, Transaction); } else { receiptHeaderID = receiptToProcurementHeader.LOG_RCP_Receipt_Header_RefID; } var receiptPositions = CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Position.Query.Search(Connection, Transaction, new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Position.Query { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Receipt_Header_RefID = receiptHeaderID }); #endregion foreach (var position in foundProcurementPositions) { #region Expected Delivery CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_Position deliveryPosition = new CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_Position(); deliveryPosition.ORD_PRC_ExpectedDelivery_PositionID = Guid.NewGuid(); deliveryPosition.AlreadyReceivedQuantityOfDelivery = 0; deliveryPosition.ExpectedDeliveryPositionITL = deliveryPosition.ORD_PRC_ExpectedDelivery_PositionID.ToString(); deliveryPosition.TotalExpectedQuantity = position.Position_Quantity; deliveryPosition.ORD_PRC_ExpectedDelivery_RefID = headerID; deliveryPosition.Tenant_RefID = securityTicket.TenantID; deliveryPosition.IsDeleted = false; deliveryPosition.Creation_Timestamp = DateTime.Now; deliveryPosition.Save(Connection, Transaction); CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_2_ProcurementOrderPosition assignment = new CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_2_ProcurementOrderPosition(); assignment.AssignmentID = Guid.NewGuid(); assignment.ORD_PRC_ProcurementOrder_Position_RefID = position.ORD_PRC_ProcurementOrder_PositionID; assignment.ORD_PRC_ExpectedDelivery_Position_RefID = deliveryPosition.ORD_PRC_ExpectedDelivery_PositionID; assignment.AssignedQuantityFromProcurementOrderPosition = position.Position_Quantity; assignment.Tenant_RefID = securityTicket.TenantID; assignment.IsDeleted = false; assignment.Creation_Timestamp = DateTime.Now; assignment.Save(Connection, Transaction); #endregion #region Receipt Positions var receiptPosition = new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Position(); if (receiptPositions.Count == 0) { // create new position receiptPosition.LOG_RCP_Receipt_PositionID = Guid.NewGuid(); receiptPosition.Creation_Timestamp = DateTime.Now; receiptPosition.Tenant_RefID = securityTicket.TenantID; receiptPosition.ReceiptPositionITL = receiptPosition.LOG_RCP_Receipt_PositionID.ToString(); receiptPosition.Receipt_Header_RefID = receiptHeaderID; receiptPosition.ReceiptPosition_Product_RefID = position.CMN_PRO_Product_RefID; receiptPosition.TotalQuantityFreeOfCharge = 0.0; receiptPosition.TotalQuantityTakenIntoStock = 0.0; receiptPosition.ExpectedPositionPrice = position.Position_ValuePerUnit; receiptPosition.Save(Connection, Transaction); var receiptPosition2procurementorderposition = new CL1_LOG_RCP.ORM_LOG_RCP_ReceiptPosition_2_ProcurementOrderPosition(); receiptPosition2procurementorderposition.AssignmentID = Guid.NewGuid(); receiptPosition2procurementorderposition.LOG_RCP_Receipt_Position_RefID = receiptPosition.LOG_RCP_Receipt_PositionID; receiptPosition2procurementorderposition.ORD_PRO_ProcurementOrder_Position_RefID = position.ORD_PRC_ProcurementOrder_PositionID; receiptPosition2procurementorderposition.Tenant_RefID = securityTicket.TenantID; receiptPosition2procurementorderposition.Creation_Timestamp = DateTime.Now; receiptPosition2procurementorderposition.IsDeleted = false; receiptPosition2procurementorderposition.Save(Connection, Transaction); } #endregion #region Quality Control Items var qualityControlItem = new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Position_QualityControlItem(); if (receiptPositions.Count == 0) { qualityControlItem.LOG_RCP_Receipt_Position_QualityControlItem = Guid.NewGuid(); qualityControlItem.ReceiptPositionCountedItemITL = qualityControlItem.LOG_RCP_Receipt_Position_QualityControlItem.ToString(); qualityControlItem.Creation_Timestamp = DateTime.Now; qualityControlItem.Tenant_RefID = securityTicket.TenantID; qualityControlItem.Receipt_Position_RefID = receiptPosition.LOG_RCP_Receipt_PositionID; } else { var query = new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Position_QualityControlItem.Query() { Receipt_Position_RefID = receiptPosition.LOG_RCP_Receipt_PositionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }; qualityControlItem = CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Position_QualityControlItem.Query.Search(Connection, Transaction, query).Single(); } //qualityControlItem.BatchNumber = position.Position_OrdinalNumber; //qualityControlItem.ExpiryDate = position.date qualityControlItem.Quantity = position.Position_Quantity; qualityControlItem.Save(Connection, Transaction); #endregion #region Forwarding Instruction var forwardingInstruction = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position_ForwardingInstruction(); if (receiptPositions.Count == 0) { #region Create new var businessParticipant = CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new CL1_CMN_BPT.ORM_CMN_BPT_BusinessParticipant.Query() { IfTenant_Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); forwardingInstruction.ORD_PRC_ProcurementOrder_Position_ForwardingInstructionID = Guid.NewGuid(); forwardingInstruction.Creation_Timestamp = DateTime.Now; forwardingInstruction.Tenant_RefID = securityTicket.TenantID; forwardingInstruction.ProcurementOrder_Position_RefID = position.ORD_PRC_ProcurementOrder_PositionID; forwardingInstruction.ForwardTo_BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID; #endregion } else { #region Load Existing var query = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position_ForwardingInstruction.Query() { ProcurementOrder_Position_RefID = position.ORD_PRC_ProcurementOrder_PositionID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }; forwardingInstruction = CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position_ForwardingInstruction.Query.Search(Connection, Transaction, query).Single(); #endregion } forwardingInstruction.QuantityToForward = position.Position_Quantity; forwardingInstruction.Save(Connection, Transaction); #endregion } //returning created expected delivery header id returnValue.Result = headerID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5SR_CEDfUP_1438 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); #region Save Header #region Expected Delivery Header var incrNumberParam = new P_L2NR_GaIINfUA_1454() { GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.ExpectedDeliveryNumber) }; var expectedDeliveryNumber = cls_Get_and_Increase_IncreasingNumber_for_UsageArea.Invoke(Connection, Transaction, incrNumberParam, securityTicket).Result.Current_IncreasingNumber; var expectedDeliveryHeader = new CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_Header(); expectedDeliveryHeader.ORD_PRC_ExpectedDelivery_HeaderID = Guid.NewGuid(); expectedDeliveryHeader.ExpectedDeliveryNumber = expectedDeliveryNumber; expectedDeliveryHeader.IsDeliveryOpen = true; expectedDeliveryHeader.IsDeliveryClosed = false; expectedDeliveryHeader.ExpectedDeliveryHeaderITL = expectedDeliveryHeader.ORD_PRC_ExpectedDelivery_HeaderID.ToString(); expectedDeliveryHeader.ExpectedDeliveryDate = Parameter.ExpectedDeliveryDate; expectedDeliveryHeader.Tenant_RefID = securityTicket.TenantID; expectedDeliveryHeader.Creation_Timestamp = DateTime.Now; expectedDeliveryHeader.Save(Connection, Transaction); #endregion #region Receipt Header var oldReceiptHeader = new ORM_LOG_RCP_Receipt_Header(); oldReceiptHeader.Load(Connection, Transaction, Parameter.ReceiptHeaderID); incrNumberParam = new P_L2NR_GaIINfUA_1454() { GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.StockReceiptNumber) }; var receiptNumber = cls_Get_and_Increase_IncreasingNumber_for_UsageArea.Invoke(Connection, Transaction, incrNumberParam, securityTicket).Result.Current_IncreasingNumber; var receiptHeader = new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Header(); receiptHeader.ReceiptNumber = receiptNumber; receiptHeader.LOG_RCP_Receipt_HeaderID = Guid.NewGuid(); receiptHeader.Creation_Timestamp = DateTime.Now; receiptHeader.Tenant_RefID = securityTicket.TenantID; receiptHeader.ReceiptHeaderITL = receiptHeader.LOG_RCP_Receipt_HeaderID.ToString(); receiptHeader.IsTakenIntoStock = false; receiptHeader.ProvidingSupplier_RefID = oldReceiptHeader.ProvidingSupplier_RefID; receiptHeader.ExpectedDeliveryHeader_RefID = expectedDeliveryHeader.ORD_PRC_ExpectedDelivery_HeaderID; receiptHeader.Save(Connection, Transaction); #endregion Receipt Header #region Procurement Order var oldReceiptToProcurement = ORM_LOG_RCP_ReceiptHeader_2_ProcurementOrderHeader.Query.Search(Connection, Transaction, new ORM_LOG_RCP_ReceiptHeader_2_ProcurementOrderHeader.Query() { LOG_RCP_Receipt_Header_RefID = Parameter.ReceiptHeaderID, IsDeleted = false }).First(); var receiptToProcurement = new CL1_LOG_RCP.ORM_LOG_RCP_ReceiptHeader_2_ProcurementOrderHeader(); receiptToProcurement.AssignmentID = Guid.NewGuid(); receiptToProcurement.Creation_Timestamp = DateTime.Now; receiptToProcurement.Tenant_RefID = securityTicket.TenantID; receiptToProcurement.LOG_RCP_Receipt_Header_RefID = receiptHeader.LOG_RCP_Receipt_HeaderID; receiptToProcurement.ORD_PRO_ProcurementOrder_Header_RefID = oldReceiptToProcurement.ORD_PRO_ProcurementOrder_Header_RefID; receiptToProcurement.Save(Connection, Transaction); #endregion #endregion #region Save Positions P_L5SR_GSRPfH_1544 param = new P_L5SR_GSRPfH_1544(); param.ReceiptHeaderID = Parameter.ReceiptHeaderID; var stockReceiptsPositions = cls_Get_StockReceiptsPositions_for_ReceiptHeaderID.Invoke(Connection, Transaction, param, securityTicket).Result; foreach (var positionParam in Parameter.ReceiptPositions) { var item = stockReceiptsPositions.Single(i => i.OrderPosition.LOG_RCP_Receipt_PositionID == positionParam.ReceipPositionID); #region Receipt Position var receiptPosition = new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Position(); receiptPosition.LOG_RCP_Receipt_PositionID = Guid.NewGuid(); receiptPosition.Receipt_Header_RefID = receiptHeader.LOG_RCP_Receipt_HeaderID; receiptPosition.ReceiptPosition_Product_RefID = item.OrderPosition.ReceiptPosition_Product_RefID; receiptPosition.TotalQuantityFreeOfCharge = 0.0; receiptPosition.TotalQuantityTakenIntoStock = 0.0; receiptPosition.ExpectedPositionPrice = item.OrderPosition.Receipt_ExpectedPositionPrice; receiptPosition.Creation_Timestamp = DateTime.Now; receiptPosition.Tenant_RefID = securityTicket.TenantID; receiptPosition.Save(Connection, Transaction); #endregion #region ReceiptPosition to ProcurementOrderPosition var receiptToProcurementPosition = new CL1_LOG_RCP.ORM_LOG_RCP_ReceiptPosition_2_ProcurementOrderPosition(); receiptToProcurementPosition.AssignmentID = Guid.NewGuid(); receiptToProcurementPosition.ORD_PRO_ProcurementOrder_Position_RefID = item.OrderPosition.ORD_PRC_ProcurementOrder_PositionID; receiptToProcurementPosition.LOG_RCP_Receipt_Position_RefID = receiptPosition.LOG_RCP_Receipt_PositionID; receiptToProcurementPosition.ReceivedQuantityFromProcurementOrderPosition = positionParam.ExpectedQuantity; receiptToProcurementPosition.Creation_Timestamp = DateTime.Now; receiptToProcurementPosition.Tenant_RefID = securityTicket.TenantID; receiptToProcurementPosition.Save(Connection, Transaction); #endregion #region Expected Delivery var expectedDeliveryPosition = new CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_Position(); expectedDeliveryPosition.ORD_PRC_ExpectedDelivery_PositionID = Guid.NewGuid(); expectedDeliveryPosition.ORD_PRC_ExpectedDelivery_RefID = receiptHeader.ExpectedDeliveryHeader_RefID; expectedDeliveryPosition.TotalExpectedQuantity = positionParam.ExpectedQuantity; expectedDeliveryPosition.Creation_Timestamp = DateTime.Now; expectedDeliveryPosition.Tenant_RefID = securityTicket.TenantID; expectedDeliveryPosition.Save(Connection, Transaction); var expectedDeliveryToProcurementOrderPosition = new CL1_ORD_PRC.ORM_ORD_PRC_ExpectedDelivery_2_ProcurementOrderPosition(); expectedDeliveryToProcurementOrderPosition.AssignmentID = Guid.NewGuid(); expectedDeliveryToProcurementOrderPosition.ORD_PRC_ExpectedDelivery_Position_RefID = expectedDeliveryPosition.ORD_PRC_ExpectedDelivery_PositionID; expectedDeliveryToProcurementOrderPosition.ORD_PRC_ProcurementOrder_Position_RefID = item.OrderPosition.ORD_PRC_ProcurementOrder_PositionID; expectedDeliveryToProcurementOrderPosition.AssignedQuantityFromProcurementOrderPosition = positionParam.ExpectedQuantity; expectedDeliveryToProcurementOrderPosition.Creation_Timestamp = DateTime.Now; expectedDeliveryToProcurementOrderPosition.Tenant_RefID = securityTicket.TenantID; expectedDeliveryToProcurementOrderPosition.Save(Connection, Transaction); #endregion #region Quality Control Items var oldQualityControlItem = ORM_LOG_RCP_Receipt_Position_QualityControlItem.Query.Search(Connection, Transaction, new ORM_LOG_RCP_Receipt_Position_QualityControlItem.Query() { Receipt_Position_RefID = item.OrderPosition.LOG_RCP_Receipt_PositionID, IsDeleted = false }).First(); var qualityControlItem = new CL1_LOG_RCP.ORM_LOG_RCP_Receipt_Position_QualityControlItem(); qualityControlItem.LOG_RCP_Receipt_Position_QualityControlItem = Guid.NewGuid(); qualityControlItem.ReceiptPositionCountedItemITL = qualityControlItem.LOG_RCP_Receipt_Position_QualityControlItem.ToString(); qualityControlItem.Receipt_Position_RefID = receiptPosition.LOG_RCP_Receipt_PositionID; qualityControlItem.BatchNumber = oldQualityControlItem.BatchNumber; qualityControlItem.ExpiryDate = oldQualityControlItem.ExpiryDate; qualityControlItem.Quantity = positionParam.ExpectedQuantity; qualityControlItem.Creation_Timestamp = DateTime.Now; qualityControlItem.Tenant_RefID = securityTicket.TenantID; qualityControlItem.Save(Connection, Transaction); #endregion #region Forwarding Instruction var oldForwardingInstruction = ORM_ORD_PRC_ProcurementOrder_Position_ForwardingInstruction.Query.Search(Connection, Transaction, new ORM_ORD_PRC_ProcurementOrder_Position_ForwardingInstruction.Query() { ProcurementOrder_Position_RefID = item.OrderPosition.ORD_PRC_ProcurementOrder_PositionID, IsDeleted = false }).First(); var forwardingInstruction = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position_ForwardingInstruction(); forwardingInstruction.ORD_PRC_ProcurementOrder_Position_ForwardingInstructionID = Guid.NewGuid(); forwardingInstruction.ProcurementOrder_Position_RefID = item.OrderPosition.ORD_PRC_ProcurementOrder_PositionID; forwardingInstruction.ForwardTo_BusinessParticipant_RefID = oldForwardingInstruction.ForwardTo_BusinessParticipant_RefID; forwardingInstruction.QuantityToForward = positionParam.ExpectedQuantity; forwardingInstruction.Creation_Timestamp = DateTime.Now; forwardingInstruction.Tenant_RefID = securityTicket.TenantID; forwardingInstruction.Save(Connection, Transaction); #endregion } #endregion return(returnValue); #endregion UserCode }