protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6IN_SCR_1430 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); var paramShelves = new CL5_APOLogistic_Inventory.Atomic.Retrieval.P_L5IN_GSCwQfIJP_1023(); paramShelves.ProcessID = Parameter.InventoryJob_Process_RefID; var shelves = CL5_APOLogistic_Inventory.Atomic.Retrieval.cls_Get_ShelfContent_with_Quantity_for_InventoryJob_ProcessID.Invoke(Connection, Transaction, paramShelves, securityTicket).Result; ORM_LOG_WRH_INJ_InventoryJob_CountingRun countingRun = new ORM_LOG_WRH_INJ_InventoryJob_CountingRun(); countingRun.Load(Connection, Transaction, Parameter.LOG_WRH_INJ_InventoryJob_CountingRunID); countingRun.IsCounting_Started = true; countingRun.Save(Connection, Transaction); ORM_LOG_WRH_INJ_InventoryJob_Process_ShelfContent processShelfContent = null; ORM_LOG_WRH_INJ_Process_ShelfContents_TrackingInstance processShelfContentsTrackingInstance = null; foreach (var itemShelfContentID in shelves.Select(x => x.LOG_WRH_Shelf_ContentID).Distinct()) { var shelfContent = shelves.Single(x => x.LOG_WRH_Shelf_ContentID == itemShelfContentID); ORM_LOG_WRH_Shelf_Content shelfContentOrm = new ORM_LOG_WRH_Shelf_Content(); shelfContentOrm.Load(Connection, Transaction, itemShelfContentID); shelfContentOrm.IsLocked = true; shelfContentOrm.Save(Connection, Transaction); processShelfContent = new ORM_LOG_WRH_INJ_InventoryJob_Process_ShelfContent(); processShelfContent.LOG_WRH_INJ_InventoryJob_Process_ShelfContentID = Guid.NewGuid(); processShelfContent.LOG_WRH_INJ_InventoryJob_Process_Shelf_RefID = shelfContent.LOG_WRH_INJ_InventoryJob_Process_ShelfID; processShelfContent.LOG_WRH_Shelf_Content_RefID = shelfContent.LOG_WRH_Shelf_ContentID; processShelfContent.ExpectedQuantityOnShelfContent = shelfContent.ShelfContent_Quantity; processShelfContent.Tenant_RefID = securityTicket.TenantID; processShelfContent.Creation_Timestamp = DateTime.Now; processShelfContent.Save(Connection, Transaction); foreach (var ti in shelves.Where(x => x.LOG_WRH_Shelf_ContentID == itemShelfContentID)) { processShelfContentsTrackingInstance = new ORM_LOG_WRH_INJ_Process_ShelfContents_TrackingInstance(); processShelfContentsTrackingInstance.ExpectedQuantityOnTrackingInstance = ti.TrackingInstance_Quantity; processShelfContentsTrackingInstance.LOG_ProductTrackingInstance_RefID = ti.LOG_ProductTrackingInstanceID; processShelfContentsTrackingInstance.LOG_WRH_INJ_Process_ShelfContents_TrackingInstanceID = Guid.NewGuid(); processShelfContentsTrackingInstance.LOG_WRH_INJ_InventoryJob_Process_ShelfContent_RefID = processShelfContent.LOG_WRH_INJ_InventoryJob_Process_ShelfContentID; processShelfContentsTrackingInstance.Tenant_RefID = securityTicket.TenantID; processShelfContentsTrackingInstance.Creation_Timestamp = DateTime.Now; processShelfContentsTrackingInstance.Save(Connection, Transaction); } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3SC_SSCA_1433 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here if (Parameter.StockItems.Count() > 0) { foreach (var item in Parameter.StockItems) { var shelfContent = new ORM_LOG_WRH_Shelf_Content(); shelfContent.Load(Connection, Transaction, item.ShelfContentID); if (shelfContent != null) { var oldQuantity = shelfContent.Quantity_Current; shelfContent.Quantity_Current = item.CountedQuantity; shelfContent.Save(Connection, Transaction); var shelfContentAdjustment = new ORM_LOG_WRH_Shelf_ContentAdjustment(); shelfContentAdjustment.LOG_WRH_Shelf_ContentAdjustmentID = Guid.NewGuid(); shelfContentAdjustment.ShelfContent_RefID = item.ShelfContentID; shelfContentAdjustment.QuantityChangedAmount = item.CountedQuantity - oldQuantity; shelfContentAdjustment.QuantityChangedDate = DateTime.Now; shelfContentAdjustment.IsManualCorrection = item.IsManualCorrection; shelfContentAdjustment.IfManualCorrection_InventoryChangeReason_RefID = item.InventoryChangeReason; shelfContentAdjustment.PerformedAt_Date = DateTime.Now; shelfContentAdjustment.PerformedBy_Account_RefID = securityTicket.AccountID; shelfContentAdjustment.Creation_Timestamp = DateTime.Now; shelfContentAdjustment.Tenant_RefID = securityTicket.TenantID; shelfContentAdjustment.Save(Connection, Transaction); ORM_LOG_WRH_Shelf_Content_AdjustmentHistory adjustmentHistory = new ORM_LOG_WRH_Shelf_Content_AdjustmentHistory(); adjustmentHistory.LOG_WRH_Shelf_Content_AdjustmentHistoryID = Guid.NewGuid(); adjustmentHistory.Shelf_Content_RefID = item.ShelfContentID; adjustmentHistory.ContentAdjustments_RefID = shelfContentAdjustment.LOG_WRH_Shelf_ContentAdjustmentID; adjustmentHistory.Tenant_RefID = securityTicket.TenantID; adjustmentHistory.Creation_Timestamp = DateTime.Now; adjustmentHistory.Save(Connection, Transaction); } } } return(returnValue); #endregion UserCode }
protected static FR_L6SO_FPC_1548 Execute(DbConnection Connection, DbTransaction Transaction, P_L6SO_FPC_1548 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6SO_FPC_1548(); returnValue.Result = new L6SO_FPC_1548(); #region Validation var isAllowedParam = new P_L6SO_IPCA_1039() { LOG_SHP_Shipment_HeaderID = Parameter.LOG_SHP_Shipment_HeaderID }; var validationResult = cls_Is_PickingControlAllowed.Invoke(Connection, Transaction, isAllowedParam, securityTicket).Result; if (!validationResult.IsPickingControlAllowed) { if (validationResult.IfPickingControlNotAllowed_ResetShipmentFlags) { var updateHeaderParam = new P_L3SO_USHSaDARfSH_1054() { ShipmentHeaderID = Parameter.LOG_SHP_Shipment_HeaderID }; var result = cls_Update_ShipmentHeaderStatus_and_DeleteActiveReservations_for_ShipmentHeaderID.Invoke(Connection, Transaction, updateHeaderParam, securityTicket).Result; if (result) { returnValue.Result.Status = EPickingControlStatus.Error_InconsistentData; } else { returnValue.Result.Status = EPickingControlStatus.Error_AlreadyFinished; } } else { returnValue.Result.Status = EPickingControlStatus.Error_AlreadyFinished; } return(returnValue); } #endregion #region GetAllShippingorderPositions var positions = ORM_LOG_SHP_Shipment_Position.Query.Search(Connection, Transaction, new ORM_LOG_SHP_Shipment_Position.Query() { LOG_SHP_Shipment_Header_RefID = Parameter.LOG_SHP_Shipment_HeaderID, IsDeleted = false }); #endregion foreach (var position in positions) { var reservations = ORM_LOG_RSV_Reservation.Query.Search(Connection, Transaction, new ORM_LOG_RSV_Reservation.Query() { LOG_SHP_Shipment_Position_RefID = position.LOG_SHP_Shipment_PositionID, IsReservationExecuted = false, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); #region Update Contents and positions foreach (var reservation in reservations) { reservation.IsReservationExecuted = true; reservation.Save(Connection, Transaction); #region Shelf Conent var shelfContent = new ORM_LOG_WRH_Shelf_Content(); shelfContent.Load(Connection, Transaction, reservation.LOG_WRH_Shelf_Content_RefID); shelfContent.Quantity_Current -= reservation.ReservedQuantity; shelfContent.Save(Connection, Transaction); #endregion #region Shelf Content Adjustments var contentAdjustment = new CL1_LOG_WRH.ORM_LOG_WRH_Shelf_ContentAdjustment(); contentAdjustment.LOG_WRH_Shelf_ContentAdjustmentID = Guid.NewGuid(); contentAdjustment.ShelfContent_RefID = shelfContent.LOG_WRH_Shelf_ContentID; contentAdjustment.QuantityChangedAmount = -reservation.ReservedQuantity;; contentAdjustment.QuantityChangedDate = DateTime.Now; contentAdjustment.IsInitialReceipt = false; contentAdjustment.IsInventoryJobCorrection = false; contentAdjustment.IsShipmentWithdrawal = false; contentAdjustment.IsManualCorrection = false; contentAdjustment.IsShipmentWithdrawal = true; contentAdjustment.IfShipmentWithdrawal_ShipmentPosition_RefID = reservation.LOG_SHP_Shipment_Position_RefID; contentAdjustment.PerformedBy_Account_RefID = securityTicket.AccountID; contentAdjustment.PerformedAt_Date = DateTime.Now; contentAdjustment.ContentAdjustmentComment = "Product is being moved from the shelf after picking control"; contentAdjustment.Tenant_RefID = securityTicket.TenantID; contentAdjustment.Creation_Timestamp = DateTime.Now; contentAdjustment.Save(Connection, Transaction); #endregion #region Reservation TrackingInstance var reservationTrackingInstance = ORM_LOG_RSV_Reservation_TrackingInstance.Query.Search(Connection, Transaction, new ORM_LOG_RSV_Reservation_TrackingInstance.Query() { LOG_RSV_Reservation_RefID = reservation.LOG_RSV_ReservationID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (reservationTrackingInstance != default(ORM_LOG_RSV_Reservation_TrackingInstance)) { var trackingInstance = new ORM_LOG_ProductTrackingInstance(); trackingInstance.Load(Connection, Transaction, reservationTrackingInstance.LOG_ProductTrackingInstance_RefID); trackingInstance.CurrentQuantityOnTrackingInstance -= reservationTrackingInstance.ReservedQuantityFromTrackingInstance; trackingInstance.R_FreeQuantity -= reservationTrackingInstance.ReservedQuantityFromTrackingInstance; trackingInstance.R_ReservedQuantity -= reservationTrackingInstance.ReservedQuantityFromTrackingInstance; trackingInstance.Save(Connection, Transaction); #region ORM_LOG_ProductTrackingInstance_HistoryEntry var trackingInstanceHistory = new CL1_LOG.ORM_LOG_ProductTrackingInstance_HistoryEntry(); trackingInstanceHistory.LOG_ProductTrackingInstance_HistoryEntryID = Guid.NewGuid(); trackingInstanceHistory.ProductTrackingInstance_RefID = trackingInstance.LOG_ProductTrackingInstanceID; trackingInstanceHistory.HistoryEntry_Text = "Products are being removed from the shelf after picking control finish"; trackingInstanceHistory.Creation_Timestamp = DateTime.Now; trackingInstanceHistory.Tenant_RefID = securityTicket.TenantID; trackingInstanceHistory.Save(Connection, Transaction); #endregion #region ORM_LOG_WRH_Shelf_ContentAdjustment_TrackingInstance var adjustment2tracking = new CL1_LOG_WRH.ORM_LOG_WRH_Shelf_ContentAdjustment_TrackingInstance(); adjustment2tracking.LOG_WRH_Shelf_ContentAdjustment_TrackingInstanceID = Guid.NewGuid(); adjustment2tracking.LOG_ProductTrackingInstance_RefID = trackingInstance.LOG_ProductTrackingInstanceID; adjustment2tracking.LOG_WRH_Shelf_ContentAdjustment_RefID = contentAdjustment.LOG_WRH_Shelf_ContentAdjustmentID; adjustment2tracking.QuantityChangedAmount = -reservation.ReservedQuantity; adjustment2tracking.Creation_Timestamp = DateTime.Now; adjustment2tracking.Tenant_RefID = securityTicket.TenantID; adjustment2tracking.Save(Connection, Transaction); #endregion } #endregion } #endregion } #region Change ShipmentOrderStatus Status var parameter = new P_L5SO_CSOS_1148(); parameter.LOG_SHP_Shipment_HeaderID = Parameter.LOG_SHP_Shipment_HeaderID; parameter.HasPickingFinished = true; parameter.IsShipped = true; cls_Change_ShippigOrderHeader_Status.Invoke(Connection, Transaction, parameter, securityTicket); #endregion returnValue.Result.Status = EPickingControlStatus.Finished; return(returnValue); #endregion UserCode }
protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5SG_SSCR_1048 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Bool(); //Put your code here foreach (var adjustment in Parameter.Adjustments) { var currentShelfContetnAdjustment = new ORM_LOG_WRH_Shelf_ContentAdjustment(); var currentshelfContent = new ORM_LOG_WRH_Shelf_Content(); var destinationShelfContent = new ORM_LOG_WRH_Shelf_Content(); var destinationShelf = new ORM_LOG_WRH_Shelf(); currentshelfContent.Load(Connection, Transaction, adjustment.ShelfContentID); currentShelfContetnAdjustment = ORM_LOG_WRH_Shelf_ContentAdjustment.Query.Search( Connection, Transaction, new ORM_LOG_WRH_Shelf_ContentAdjustment.Query() { ShelfContent_RefID = currentshelfContent.LOG_WRH_Shelf_ContentID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); destinationShelfContent.Tenant_RefID = securityTicket.TenantID; destinationShelfContent.Shelf_RefID = adjustment.DestinationShelf; destinationShelfContent.Product_RefID = adjustment.ProductID; destinationShelfContent.LOG_WRH_Shelf_ContentID = Guid.NewGuid(); var destinationShelfContentID = new FR_Guid(destinationShelfContent.Save(Connection, Transaction), destinationShelfContent.LOG_WRH_Shelf_ContentID).Result; var destinationShelfContentTrackingInstance = new ORM_LOG_ProductTrackingInstance(); var sourceShelfContentTrackingInstance = new ORM_LOG_ProductTrackingInstance(); if (adjustment.TrackingInstanceID != null && adjustment.TrackingInstanceID != Guid.Empty) { sourceShelfContentTrackingInstance.Load(Connection, Transaction, adjustment.TrackingInstanceID); destinationShelfContentTrackingInstance.ExpirationDate = sourceShelfContentTrackingInstance.ExpirationDate; destinationShelfContentTrackingInstance.BatchNumber = sourceShelfContentTrackingInstance.BatchNumber; destinationShelfContentTrackingInstance.Tenant_RefID = securityTicket.TenantID; destinationShelfContentTrackingInstance.TrackingCode = String.Empty; destinationShelfContentTrackingInstance.CMN_PRO_Product_RefID = adjustment.ProductID; destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID = Guid.NewGuid(); var destinationShelfContentTrackingInstanceID = new FR_Guid(destinationShelfContentTrackingInstance.Save(Connection, Transaction), destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID).Result; var historyEntry = new ORM_LOG_ProductTrackingInstance_HistoryEntry(); historyEntry.LOG_ProductTrackingInstance_HistoryEntryID = Guid.NewGuid(); historyEntry.ProductTrackingInstance_RefID = destinationShelfContentTrackingInstanceID; historyEntry.Tenant_RefID = securityTicket.TenantID; historyEntry.HistoryEntry_Text = "Transfered from other shelf content."; historyEntry.Save(Connection, Transaction); var assignment = new ORM_LOG_WRH_ShelfContent_2_TrackingInstance(); assignment.LOG_ProductTrackingInstance_RefID = destinationShelfContentTrackingInstanceID; assignment.LOG_WRH_Shelf_Content_RefID = destinationShelfContentID; assignment.Tenant_RefID = securityTicket.TenantID; assignment.AssignmentID = Guid.NewGuid(); var savedAssignment = new FR_Guid(assignment.Save(Connection, Transaction), assignment.AssignmentID); } else { destinationShelfContentTrackingInstance.Tenant_RefID = securityTicket.TenantID; destinationShelfContentTrackingInstance.CMN_PRO_Product_RefID = adjustment.ProductID; destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID = Guid.NewGuid(); var destinationShelfContentTrackingInstanceID = new FR_Guid(destinationShelfContentTrackingInstance.Save(Connection, Transaction), destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID).Result; var historyEntry = new ORM_LOG_ProductTrackingInstance_HistoryEntry(); historyEntry.LOG_ProductTrackingInstance_HistoryEntryID = Guid.NewGuid(); historyEntry.ProductTrackingInstance_RefID = destinationShelfContentTrackingInstanceID; historyEntry.Tenant_RefID = securityTicket.TenantID; historyEntry.HistoryEntry_Text = "Transfered from other shelf content."; historyEntry.Save(Connection, Transaction); } var sourceAdjustmentSaveParameter = new P_L3WH_SSCA_1732(); var adjustmentsList = new List <P_L3WH_SSCA_1732a>(); var sourceAdjustment = new P_L3WH_SSCA_1732a(); sourceAdjustment.AdjustedQuantity = currentshelfContent.Quantity_Current - adjustment.AdjustedQuantity; sourceAdjustment.ProductID = adjustment.ProductID; sourceAdjustment.ShelfContentID = adjustment.ShelfContentID; sourceAdjustment.TrackingInstanceID = sourceShelfContentTrackingInstance.LOG_ProductTrackingInstanceID; sourceAdjustment.IsManualCorrection = true; sourceAdjustment.IfManualCorrection_InventoryChangeReason_RefID = Guid.Empty; sourceAdjustment.IsRelocation = true; sourceAdjustment.RelocationAdjustmentID = Guid.NewGuid(); var destinationAdjustment = new P_L3WH_SSCA_1732a(); destinationAdjustment.AdjustedQuantity = destinationShelfContent.Quantity_Current + adjustment.AdjustedQuantity; destinationAdjustment.IsManualCorrection = true; destinationAdjustment.ProductID = adjustment.ProductID; destinationAdjustment.ShelfContentID = destinationShelfContent.LOG_WRH_Shelf_ContentID; destinationAdjustment.TrackingInstanceID = destinationShelfContentTrackingInstance.LOG_ProductTrackingInstanceID; destinationAdjustment.IfManualCorrection_InventoryChangeReason_RefID = Guid.Empty; destinationAdjustment.IsRelocation = true; destinationAdjustment.RelocationAdjustmentID = Guid.NewGuid(); sourceAdjustment.IfRelocation_CorrespondingAdjustment_RefID = destinationAdjustment.RelocationAdjustmentID; destinationAdjustment.IfRelocation_CorrespondingAdjustment_RefID = sourceAdjustment.RelocationAdjustmentID; adjustmentsList.Add(sourceAdjustment); adjustmentsList.Add(destinationAdjustment); sourceAdjustmentSaveParameter.Adjustments = adjustmentsList.ToArray(); var IsAdjustmentSaved = cls_Save_Shelf_ContentAdjustments.Invoke(Connection, Transaction, sourceAdjustmentSaveParameter, securityTicket).Result; } return(returnValue); #endregion UserCode }