Example #1
0
        protected static FR_L6SO_GPDfPC_1049 Execute(DbConnection Connection, DbTransaction Transaction, P_L6SO_GPDfPC_1049 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6SO_GPDfPC_1049();
            //Put your code here

            returnValue.Result           = new L6SO_GPDfPC_1049();
            returnValue.Result.BasicInfo = new L5SO_GSHfH_1040();

            //positions
            returnValue.Result.Positions = cls_Get_AllShippingPositions_for_PickingControlFlags_and_ShippingHeaderID.
                                           Invoke(Connection, Transaction, new P_L6SO_GASPfPCFaSH_1202 {
                ShippmentHeaderID = Parameter.ShipmentHeaderID
            }, securityTicket).Result;

            //basic info
            returnValue.Result.BasicInfo = cls_Get_ShippingHeader_for_HeaderID.
                                           Invoke(Connection, Transaction, new P_L5SO_GSHfH_1040 {
                HeaderID = Parameter.ShipmentHeaderID
            }, securityTicket).Result;

            //organizationunitid
            ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition       assignment      = new ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition();
            ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query assignmentQuery = new ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query();
            assignmentQuery.LOG_SHP_Shipment_Position_RefID = returnValue.Result.Positions.First().LOG_SHP_Shipment_PositionID;
            assignmentQuery.Tenant_RefID = securityTicket.TenantID;
            assignmentQuery.IsDeleted    = false;

            assignment = ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query.Search(Connection, Transaction, assignmentQuery).Single();

            returnValue.Result.OrganizationUnitID = assignment.CMN_BPT_CTM_OrganizationalUnit_RefID;



            return(returnValue);

            #endregion UserCode
        }
        protected static FR_L5SO_GSPwPaSfSH_1141_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5SO_GSPwPaSfSH_1141 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5SO_GSPwPaSfSH_1141_Array();

            #region Get Shipment Positions

            P_L2SH_GSPfToSH_1334 positionsGetParam = new P_L2SH_GSPfToSH_1334();
            positionsGetParam.ShipmentHeaderID = Parameter.ShippmentHeaderID;
            var shipmentPositions = cls_Get_ShipmentPositions_for_Tenant_or_ShipmentHeaderID.Invoke(Connection, Transaction, positionsGetParam, securityTicket).Result.ToList();

            #endregion

            if (shipmentPositions.Count() == 0)
            {
                returnValue.Result = new L5SO_GSPwPaSfSH_1141[0];
                return(returnValue);
            }

            #region Get Articles For ShipmentPositions

            P_L3AR_GAfAL_0942 articlesGetParam = new P_L3AR_GAfAL_0942();
            articlesGetParam.ProductID_List = shipmentPositions.Select(i => i.CMN_PRO_Product_RefID).Distinct().ToArray();

            var articles = cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, articlesGetParam, securityTicket).Result;

            #endregion

            #region Get Quantities on Shelf contents per product

            var articleIDs     = shipmentPositions.Select(x => x.CMN_PRO_Product_RefID).Distinct();
            var qntsPerProduct = new L3WH_GASCQfPL_1239[] { };
            if (articleIDs.Count() > 0)
            {
                var qntParam = new P_L3WH_GASCQfPL_1239 {
                    ProductIDList = articleIDs.ToArray()
                };
                qntsPerProduct = cls_Get_All_ShelfContent_Quantities_for_ProductListID.Invoke(Connection, Transaction, qntParam, securityTicket).Result;
            }

            #endregion

            #region Get ABDAPrices

            var abdaPricesParam = new P_L2PR_GPVfSC_1424()
            {
                SubscribedCatalogITL = EnumUtils.GetEnumDescription(EPublicCatalogs.ABDA)
            };

            var abdaPrices = cls_Get_PriceValues_for_SubscribedCatalogITL.Invoke(Connection, Transaction, abdaPricesParam, securityTicket).Result;

            #endregion

            #region cls_Get_AllGeneralAverageProcurementPrices_for_TenantID

            var avgProcPrice = cls_Get_AllGeneralAverageProcurementPrices_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result;

            #endregion

            List <L5SO_GSPwPaSfSH_1141> listOfPositionsWithPrices = new List <L5SO_GSPwPaSfSH_1141>();

            foreach (var position in shipmentPositions)
            {
                var quantity = qntsPerProduct.Where(i => i.Product_RefID == position.CMN_PRO_Product_RefID).SingleOrDefault();
                if (quantity == null)
                {
                    quantity = new L3WH_GASCQfPL_1239()
                    {
                        Product_RefID          = position.CMN_PRO_Product_RefID,
                        Sum_Quantity_Current   = 0,
                        Sum_R_ReservedQuantity = 0,
                        Sum_R_FreeQuantity     = 0
                    };
                }

                var tempPositionWithPrice = new L5SO_GSPwPaSfSH_1141();
                tempPositionWithPrice.ShipmentPositionID = position.LOG_SHP_Shipment_PositionID;

                var reservationSum = ORM_LOG_RSV_Reservation.Query.Search(Connection, Transaction, new ORM_LOG_RSV_Reservation.Query()
                {
                    LOG_SHP_Shipment_Position_RefID = position.LOG_SHP_Shipment_PositionID,
                    IsDeleted             = false,
                    IsReservationExecuted = false
                }).Sum(x => x.ReservedQuantity);

                var correspodingCustomerOrderPosition = new ORM_ORD_CUO_CustomerOrder_Position();

                var positionArticle = articles.Where(ar => ar.CMN_PRO_ProductID == position.CMN_PRO_Product_RefID).Single();
                tempPositionWithPrice.Product_Number    = positionArticle.Product_Number;
                tempPositionWithPrice.Product_Name      = positionArticle.Product_Name;
                tempPositionWithPrice.UnitAmount        = positionArticle.UnitAmount;
                tempPositionWithPrice.UnitIsoCode       = positionArticle.UnitIsoCode;
                tempPositionWithPrice.DossageFormName   = positionArticle.DossageFormName;
                tempPositionWithPrice.Producer          = positionArticle.ProducerName;
                tempPositionWithPrice.CMN_PRO_ProductID = positionArticle.CMN_PRO_ProductID;

                tempPositionWithPrice.ReservedQuantity  = reservationSum;
                tempPositionWithPrice.QuantityToShip    = position.QuantityToShip;
                tempPositionWithPrice.QuantityInStock   = quantity.Sum_Quantity_Current;
                tempPositionWithPrice.QuantityAvailable = quantity.Sum_R_FreeQuantity;

                tempPositionWithPrice.ABDAPrice  = abdaPrices.Where(i => i.CMN_PRO_Product_RefID == position.CMN_PRO_Product_RefID).Select(j => j.PriceAmount).SingleOrDefault();
                tempPositionWithPrice.SalesPrice = position.ShipmentPosition_ValueWithoutTax;
                tempPositionWithPrice.AverageProcurementPrice = avgProcPrice.Where(i => i.Product_RefID == position.CMN_PRO_Product_RefID).Select(j => j.PriceValue_Amount).SingleOrDefault();
                tempPositionWithPrice.ShipmentPosition_PricePerUnitValueWithoutTax = position.ShipmentPosition_PricePerUnitValueWithoutTax;

                #region Product Replacement Allowed

                var assignmentToCustomerOrderPositionQuery = new ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query();
                assignmentToCustomerOrderPositionQuery.LOG_SHP_Shipment_Position_RefID = position.LOG_SHP_Shipment_PositionID;
                assignmentToCustomerOrderPositionQuery.Tenant_RefID = securityTicket.TenantID;
                assignmentToCustomerOrderPositionQuery.IsDeleted    = false;
                var foundAssignment = ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query.
                                      Search(Connection, Transaction, assignmentToCustomerOrderPositionQuery).SingleOrDefault();

                if (foundAssignment != null)
                {
                    correspodingCustomerOrderPosition.Load(Connection, Transaction, foundAssignment.ORD_CUO_CustomerOrder_Position_RefID);
                    tempPositionWithPrice.IsProductReplacementAllowed = correspodingCustomerOrderPosition.IsProductReplacementAllowed;
                }
                else
                {
                    tempPositionWithPrice.IsProductReplacementAllowed = true;
                }

                #endregion

                listOfPositionsWithPrices.Add(tempPositionWithPrice);
            }

            returnValue.Result = listOfPositionsWithPrices.ToArray();

            return(returnValue);

            #endregion UserCode
        }
Example #3
0
        protected static FR_L5PP_GSHwCOfPfT_1348_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5PP_GSHwCOfPfT_1348 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5PP_GSHwCOfPfT_1348_Array();

            //Put your code here
            List <L5PP_GSHwCOfPfT_1348> retVal = new List <L5PP_GSHwCOfPfT_1348>();
            returnValue.Result = retVal.ToArray();

            #region Retrieve Headers

            // get all headers
            P_L2SH_GSHfT_1527 shipmentHeadersParam = new P_L2SH_GSHfT_1527();
            shipmentHeadersParam.IsShipped                = false;
            shipmentHeadersParam.ShipmentNumber           = Parameter.ShipmentNumber;
            shipmentHeadersParam.ShipmentCreationDateFrom = Parameter.ShipmentCreationDateFrom;
            shipmentHeadersParam.ShipmentCreationDateTo   = Parameter.ShipmentCreationDateTo;
            var headersResult = cls_Get_ShippmentHeaders_for_TenantID.Invoke(Connection, Transaction, shipmentHeadersParam, securityTicket).Result;

            if (headersResult == null)
            {
                return(returnValue);
            }

            // filter headers
            List <L2SH_GSHfT_1527> headers     = new List <L2SH_GSHfT_1527>();
            List <L2SH_GSHfT_1527> tempHeaders = new List <L2SH_GSHfT_1527>();
            if (Parameter.HasPositionsPartiallyToPick)
            {
                // filtered by passed parameter option
                tempHeaders = headersResult.Where(i => i.IsPartiallyReadyForPicking && !i.IsManuallyCleared_ForPicking).ToList();
                // add not inserted shipment headers
                headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList());
            }

            if (Parameter.IsReadyForPicking)
            {
                // filtered by passed parameter option
                tempHeaders = headersResult.Where(i => i.IsReadyForPicking && !i.IsManuallyCleared_ForPicking).ToList();
                // add not inserted shipment headers
                headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList());
            }

            if (Parameter.IsInPickingProcess)
            {
                // filtered by passed parameter option
                tempHeaders = headersResult.Where(i => i.HasPickingStarted || i.HasPickingFinished || i.IsManuallyCleared_ForPicking).ToList();
                // add not inserted shipment headers
                headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList());
            }

            if (Parameter.NoPositionsFullyToPick)
            {
                // filtered by passed parameter option
                tempHeaders = headersResult.Where(i =>
                                                  !(i.IsPartiallyReadyForPicking && !i.IsManuallyCleared_ForPicking) &&
                                                  !(i.IsReadyForPicking && !i.IsManuallyCleared_ForPicking) &&
                                                  !(i.HasPickingStarted || i.HasPickingFinished || i.IsManuallyCleared_ForPicking)
                                                  ).ToList();
                // add not inserted shipment headers
                headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList());
            }

            #endregion

            L5PP_GSHwCOfPfT_1348 retValItem;
            foreach (var header in headers)
            {
                #region Getting data

                #region Shipment positions
                // get one shipment position for shipment header
                ORM_LOG_SHP_Shipment_Position.Query shipmentPositionsQuery = new ORM_LOG_SHP_Shipment_Position.Query();
                shipmentPositionsQuery.LOG_SHP_Shipment_Header_RefID = header.LOG_SHP_Shipment_HeaderID;
                shipmentPositionsQuery.Tenant_RefID = securityTicket.TenantID;
                shipmentPositionsQuery.IsDeleted    = false;
                List <ORM_LOG_SHP_Shipment_Position> shipmentPositions = ORM_LOG_SHP_Shipment_Position.Query.Search(Connection, Transaction, shipmentPositionsQuery);

                if (shipmentPositions == null || shipmentPositions.Count == 0)
                {
                    continue;
                }
                #endregion

                #region Customer order position for shipment position
                // get one customer order position for shipment position
                ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition customerOrder2ShipmentPosition = null;
                foreach (var shipmentPosition in shipmentPositions)
                {
                    ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query customerOrder2ShipmentPositionQuery = new ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query();
                    customerOrder2ShipmentPositionQuery.LOG_SHP_Shipment_Position_RefID = shipmentPosition.LOG_SHP_Shipment_PositionID;
                    customerOrder2ShipmentPositionQuery.Tenant_RefID = securityTicket.TenantID;
                    customerOrder2ShipmentPositionQuery.IsDeleted    = false;
                    customerOrder2ShipmentPosition =
                        ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query
                        .Search(Connection, Transaction, customerOrder2ShipmentPositionQuery).FirstOrDefault();

                    if (customerOrder2ShipmentPosition != null)
                    {
                        break;
                    }
                }

                if (customerOrder2ShipmentPosition == null)
                {
                    continue;
                }
                #endregion

                #region Customer order position
                ORM_ORD_CUO_CustomerOrder_Position orm_CustomerOrderPosition = new ORM_ORD_CUO_CustomerOrder_Position();
                var distributionOrderPosition = orm_CustomerOrderPosition.Load(Connection, Transaction, customerOrder2ShipmentPosition.ORD_CUO_CustomerOrder_Position_RefID);
                if (distributionOrderPosition.Status != FR_Status.Success || orm_CustomerOrderPosition.ORD_CUO_CustomerOrder_PositionID == Guid.Empty)
                {
                    continue;
                }
                #endregion

                #region Customer order header
                // get customer order header for customer order position
                ORM_ORD_CUO_CustomerOrder_Header.Query customerOrderHeaderQuery = new ORM_ORD_CUO_CustomerOrder_Header.Query();
                customerOrderHeaderQuery.ORD_CUO_CustomerOrder_HeaderID = orm_CustomerOrderPosition.CustomerOrder_Header_RefID;
                customerOrderHeaderQuery.Tenant_RefID = securityTicket.TenantID;
                customerOrderHeaderQuery.IsDeleted    = false;
                if (!String.IsNullOrEmpty(Parameter.CustomerOrderNumber))
                {
                    customerOrderHeaderQuery.CustomerOrder_Number = Parameter.CustomerOrderNumber;
                }

                ORM_ORD_CUO_CustomerOrder_Header customerOrderHeader = ORM_ORD_CUO_CustomerOrder_Header.Query.Search(Connection, Transaction, customerOrderHeaderQuery).FirstOrDefault();
                if (customerOrderHeader == null)
                {
                    continue;
                }

                // apply filter for customer order header
                if (Parameter.OrderDateFrom != null)
                {
                    if (customerOrderHeader.CustomerOrder_Date < Parameter.OrderDateFrom)
                    {
                        continue;
                    }
                }

                if (Parameter.OrderDateTo != null)
                {
                    if (customerOrderHeader.CustomerOrder_Date > Parameter.OrderDateTo)
                    {
                        continue;
                    }
                }
                #endregion

                #region Customer
                ORM_CMN_BPT_BusinessParticipant.Query bussinerParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query();
                bussinerParticipantQuery.CMN_BPT_BusinessParticipantID = customerOrderHeader.OrderingCustomer_BusinessParticipant_RefID;
                bussinerParticipantQuery.Tenant_RefID = securityTicket.TenantID;
                bussinerParticipantQuery.IsDeleted    = false;

                ORM_CMN_BPT_BusinessParticipant bussinerParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bussinerParticipantQuery).FirstOrDefault();

                if (bussinerParticipant == null)
                {
                    continue;
                }

                if (!String.IsNullOrEmpty(Parameter.Customer))
                {
                    if (!bussinerParticipant.DisplayName.ToUpper().Contains(Parameter.Customer.ToUpper()))
                    {
                        continue;
                    }
                }
                #endregion

                #endregion

                retValItem = new L5PP_GSHwCOfPfT_1348();
                retValItem.LOG_SHP_Shipment_HeaderID = header.LOG_SHP_Shipment_HeaderID;
                retValItem.ShipmentHeader_Number     = header.ShipmentHeader_Number;
                retValItem.IsShipped                    = header.IsShipped;
                retValItem.IsBilled                     = header.IsBilled;
                retValItem.IsReadyForPicking            = header.IsReadyForPicking;
                retValItem.IsPartiallyReadyForPicking   = header.IsPartiallyReadyForPicking;
                retValItem.HasPickingStarted            = header.HasPickingStarted;
                retValItem.HasPickingFinished           = header.HasPickingFinished;
                retValItem.IsManuallyCleared_ForPicking = header.IsManuallyCleared_ForPicking;
                retValItem.ShipmentCreationDate         = header.Creation_Timestamp;

                retValItem.ORD_CUO_CustomerOrder_HeaderID = customerOrderHeader.ORD_CUO_CustomerOrder_HeaderID;
                retValItem.CustomerOrderNumber            = customerOrderHeader.CustomerOrder_Number;
                retValItem.CustomerOrderDate = customerOrderHeader.CustomerOrder_Date;

                retValItem.Customer = bussinerParticipant.DisplayName;

                retVal.Add(retValItem);
            }

            retVal = retVal.Skip(Parameter.From).Take(Parameter.Size).ToList();

            returnValue.Result = retVal.ToArray();

            return(returnValue);

            #endregion UserCode
        }