コード例 #1
0
        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
        }
コード例 #2
0
        protected static FR_L5RS_CRSH_1332_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5RS_CRSH_1332 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5RS_CRSH_1332_Array();
            var results     = new List <L5RS_CRSH_1332>();

            var contentAdjustments      = new List <P_L3WH_SSCA_1732a>();
            var deleteReservationsParam = new List <P_L3SO_DARaUSHfPTIL_1159a>();

            foreach (var inputHeader in Parameter.ReturnShipmentHeaders)
            {
                #region Create New Shipment and ReturnShipment Headers

                var createShipmentandReturnShipmentHeaderParam = new P_L5RS_CSaRSH_0244()
                {
                    SupplierID = inputHeader.SupplierID
                };

                var resultHeadersCreation = cls_Create_Shipment_and_ReturnShipment_Header.Invoke(Connection, Transaction, createShipmentandReturnShipmentHeaderParam, securityTicket);
                if (resultHeadersCreation.Status != FR_Status.Success)
                {
                    returnValue.Status = FR_Status.Error_Internal;
                    returnValue.Result = null;
                    return(returnValue);
                }

                #endregion

                #region Create New Shipment and ReturnShipment Positions

                var positionsParam = new List <P_L5RS_CRSP_1405a>();

                foreach (var inputPosition in inputHeader.ReturnShipmentPositions)
                {
                    var position = new P_L5RS_CRSP_1405a();
                    position.ShipmentHeaderID       = resultHeadersCreation.Result.ShipmentHeaderID;
                    position.ReturnShipmentHeaderID = resultHeadersCreation.Result.ReturnShipmentHeaderID;

                    position.ProductID         = inputPosition.ProductID;
                    position.Quantity          = inputPosition.Quantity;;
                    position.PricePerUnit      = inputPosition.PricePerUnit;
                    position.ReturnPolicyID    = inputPosition.ReturnPolicyID;
                    position.ReceiptPositionID = inputPosition.ReceiptPositionID;

                    positionsParam.Add(position);
                }

                var createPositionsParam = new P_L5RS_CRSP_1405()
                {
                    Positions = positionsParam.ToArray()
                };

                var resultPositionsCreation = cls_Create_ReturnShipment_Positions.Invoke(Connection, Transaction, createPositionsParam, securityTicket);
                if (resultPositionsCreation.Status != FR_Status.Success)
                {
                    returnValue.Status = FR_Status.Error_Internal;
                    returnValue.Result = null;
                    return(returnValue);
                }

                #endregion

                #region Create New ContentAdjustments and DeleteReservatins parameters

                foreach (var inputPosition in inputHeader.ReturnShipmentPositions)
                {
                    var productTrackingInstance = new ORM_LOG_ProductTrackingInstance();
                    productTrackingInstance.Load(Connection, Transaction, inputPosition.ProductTrackingInstanceID);

                    var savedPosition = resultPositionsCreation.Result.Positions.Single(i => i.ProductID == inputPosition.ProductID && i.ReceiptPositionID == inputPosition.ReceiptPositionID);

                    var paramContentAdjustment = new P_L3WH_SSCA_1732a();
                    paramContentAdjustment.AdjustedQuantity   = productTrackingInstance.CurrentQuantityOnTrackingInstance - inputPosition.Quantity;
                    paramContentAdjustment.IsManualCorrection = true;
                    paramContentAdjustment.IfManualCorrection_InventoryChangeReason_RefID = inputPosition.ReturnPolicyID;
                    paramContentAdjustment.IsShipmentWithdrawal = true;
                    paramContentAdjustment.IfShipmentWithdrawal_ShipmentPosition_RefID = savedPosition.ShipmentPositionID;
                    paramContentAdjustment.ProductID          = inputPosition.ProductID;
                    paramContentAdjustment.ShelfContentID     = inputPosition.ShelfContentID;
                    paramContentAdjustment.TrackingInstanceID = inputPosition.ProductTrackingInstanceID;
                    contentAdjustments.Add(paramContentAdjustment);

                    deleteReservationsParam.Add(new P_L3SO_DARaUSHfPTIL_1159a()
                    {
                        ProductTrackingInstanceID           = inputPosition.ProductTrackingInstanceID,
                        RemovedQuantityFromTrackingInstance = inputPosition.Quantity,
                        CurrentQuantityOnTrackingInstance   = productTrackingInstance.CurrentQuantityOnTrackingInstance
                    });
                }

                #endregion

                var result = new L5RS_CRSH_1332()
                {
                    ShipmentHeaderNumber       = resultPositionsCreation.Result.ShipmentHeaderNumber,
                    ShipmentHeaderTotalValue   = resultPositionsCreation.Result.ShipmentHeaderTotalValue,
                    ShipmentHeaderSupplierName = resultPositionsCreation.Result.ShipmentHeaderSupplierName
                };
                results.Add(result);
            }

            #region ClearReservations

            var deleteResParam = new P_L3SO_DARaUSHfPTIL_1159()
            {
                TracknigInstances = deleteReservationsParam.ToArray()
            };

            cls_Delete_ActiveReservations_and_UpdateShipmentHeaders_for_ProductTrackingInstanceIDList.Invoke(Connection, Transaction, deleteResParam, securityTicket);

            #endregion

            #region Save ShelfContentAdjustments

            P_L3WH_SSCA_1732 paramContent = new P_L3WH_SSCA_1732();
            paramContent.Adjustments = contentAdjustments.ToArray();

            var resultContentAdjustments = cls_Save_Shelf_ContentAdjustments.Invoke(Connection, Transaction, paramContent, securityTicket);
            if (resultContentAdjustments.Status != FR_Status.Success || resultContentAdjustments.Result == false)
            {
                returnValue.Status = FR_Status.Error_Internal;
                returnValue.Result = null;
                return(returnValue);
            }

            #endregion

            returnValue.Status = FR_Status.Success;
            returnValue.Result = results.ToArray();

            return(returnValue);

            #endregion UserCode
        }
コード例 #3
0
        protected static FR_L5RS_SRSHaP_0807_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5RS_SRSHaP_0807 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue             = new FR_L5RS_SRSHaP_0807_Array();
            var results                 = new List <L5RS_SRSHaP_0807>();
            var contentAdjustments      = new List <P_L3WH_SSCA_1732a>();
            var deleteReservationsParam = new List <P_L3SO_DARaUSHfPTIL_1159a>();

            foreach (var returnShipment in Parameter.ReturnShipments)
            {
                #region Create New Shipment and ReturnShipment Headers
                var resultHeadersCreation = new FR_L5RS_CSaRSH_0244();
                if (returnShipment.CreateNewHeader)
                {
                    resultHeadersCreation = cls_Create_Shipment_and_ReturnShipment_Header.Invoke(
                        Connection,
                        Transaction,
                        returnShipment.ShipmentHeader,
                        securityTicket);
                    if (resultHeadersCreation.Status != FR_Status.Success)
                    {
                        returnValue.Status = FR_Status.Error_Internal;
                        returnValue.Result = null;
                        return(returnValue);
                    }
                }
                #endregion

                #region Create New Shipment and ReturnShipment Positions
                var resultPositionsCreation = new FR_L5RS_CSaRSPfH_0449();
                if (returnShipment.CreateNewHeader)
                {
                    foreach (var position in returnShipment.ShipmentPositions.Positions)
                    {
                        position.ShipmentHeaderID       = resultHeadersCreation.Result.ShipmentHeaderID;
                        position.ReturnShipmentHeaderID = resultHeadersCreation.Result.ReturnShipmentHeaderID;

                        #region Fetch ReturnPolicyID if needed
                        if (position.ReturnPolicyId == Guid.Empty)
                        {
                            var returnPolicy = ORM_LOG_RET_ReturnPolicy.Query.Search(Connection, Transaction,
                                                                                     new ORM_LOG_RET_ReturnPolicy.Query()
                            {
                                IsDeleted                = false,
                                Tenant_RefID             = securityTicket.TenantID,
                                GlobalPropertyMatchingID = position.ReturnPolicyGlobalPropertyMatchingId
                            }).FirstOrDefault();
                            if (returnPolicy != null)
                            {
                                position.ReturnPolicyId = returnPolicy.LOG_RET_ReturnPolicyID;
                            }
                        }
                        #endregion
                    }
                }
                resultPositionsCreation = cls_Create_Shipment_and_ReturnShipment_Positions_for_HeaderID.Invoke(
                    Connection,
                    Transaction,
                    returnShipment.ShipmentPositions,
                    securityTicket);
                if (resultPositionsCreation.Status != FR_Status.Success)
                {
                    returnValue.Status = FR_Status.Error_Internal;
                    returnValue.Result = null;
                    return(returnValue);
                }
                #endregion

                #region Create New ContentAdjustments parameter

                foreach (var item in returnShipment.ShipmentPositions.Positions)
                {
                    var productTrackingInstance = new ORM_LOG_ProductTrackingInstance();
                    productTrackingInstance.Load(
                        Connection,
                        Transaction,
                        (Guid)item.ProductTrackingInstance);

                    var paramContentAdjustment = new P_L3WH_SSCA_1732a();
                    paramContentAdjustment.AdjustedQuantity   = productTrackingInstance.CurrentQuantityOnTrackingInstance - item.Quantity;
                    paramContentAdjustment.IsManualCorrection = true;
                    paramContentAdjustment.IfManualCorrection_InventoryChangeReason_RefID = item.ReturnPolicyId;
                    paramContentAdjustment.IsShipmentWithdrawal = true;
                    paramContentAdjustment.IfShipmentWithdrawal_ShipmentPosition_RefID = item.ShipmentPositionID;
                    paramContentAdjustment.ProductID          = item.ProductId;
                    paramContentAdjustment.ShelfContentID     = item.ShelfContentID;
                    paramContentAdjustment.TrackingInstanceID = item.ProductTrackingInstance ?? Guid.Empty;
                    contentAdjustments.Add(paramContentAdjustment);

                    deleteReservationsParam.Add(new P_L3SO_DARaUSHfPTIL_1159a()
                    {
                        ProductTrackingInstanceID           = (Guid)item.ProductTrackingInstance,
                        RemovedQuantityFromTrackingInstance = item.Quantity,
                        CurrentQuantityOnTrackingInstance   = productTrackingInstance.CurrentQuantityOnTrackingInstance
                    });
                }

                #endregion

                var result = new L5RS_SRSHaP_0807()
                {
                    ShipmentHeaderID           = returnShipment.ShipmentPositions.Positions[0].ShipmentHeaderID,
                    ShipmentHeaderNumber       = resultPositionsCreation.Result.ShipmentHeaderNumber,
                    ShipmentHeaderTotalValue   = resultPositionsCreation.Result.ShipmentHeaderTotalValue,
                    ReturnShipmentHeaderID     = returnShipment.ShipmentPositions.Positions[0].ReturnShipmentHeaderID,
                    ShipmentHeaderSupplierName = resultPositionsCreation.Result.ShipmentHeaderSupplierName,
                    ShipmentPositionIDs        = resultPositionsCreation.Result.ShipmentPositionIDs,
                    ReturnShipmentPositionIDs  = resultPositionsCreation.Result.ReturnShipmentPositionIDs
                };
                results.Add(result);
            }

            #region ClearReservations

            var deleteResParam = new P_L3SO_DARaUSHfPTIL_1159()
            {
                TracknigInstances = deleteReservationsParam.ToArray()
            };

            cls_Delete_ActiveReservations_and_UpdateShipmentHeaders_for_ProductTrackingInstanceIDList.Invoke(Connection, Transaction, deleteResParam, securityTicket);

            #endregion

            #region Save ShelfContentAdjustments

            P_L3WH_SSCA_1732 paramContent = new P_L3WH_SSCA_1732();
            paramContent.Adjustments = contentAdjustments.ToArray();

            var resultContentAdjustments = cls_Save_Shelf_ContentAdjustments.Invoke(Connection, Transaction, paramContent, securityTicket);
            if (resultContentAdjustments.Status != FR_Status.Success || resultContentAdjustments.Result == false)
            {
                returnValue.Status = FR_Status.Error_Internal;
                returnValue.Result = null;
                return(returnValue);
            }

            #endregion

            returnValue.Status = FR_Status.Success;
            returnValue.Result = results.ToArray();

            return(returnValue);

            #endregion UserCode
        }