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

            List <Guid> productList   = new List <Guid>();
            var         paramArticles = new CL3_Articles.Atomic.Retrieval.P_L3AR_GAfT_0942
            {
                ActiveComponent                     = Parameter.ActiveComponent,
                ActiveComponentStartWith            = Parameter.ActiveComponentStartWith,
                CustomArticlesGroupGlobalPropertyID = Parameter.CustomArticlesGroupGlobalPropertyID,
                DosageFormQuery                     = Parameter.DosageFormQuery,
                GeneralQuery           = Parameter.GeneralQuery,
                IsAvailableForOrdering = Parameter.IsAvailableForOrdering,
                LanguageID             = Parameter.LanguageID,
                ProducerName           = Parameter.ProducerName,
                ProductID            = Parameter.ProductID,
                ProductNameStartWith = Parameter.ProductNameStartWith,
                PZNQuery             = Parameter.PZNQuery,
                UnitQuery            = Parameter.UnitQuery,
                IsDefaultStock       = Parameter.IsPartOfDefaultStock
            };

            List <L3AR_GAfT_0942> articles = cls_Get_Articles_for_Tenant.Invoke(Connection, Transaction, paramArticles, securityTicket).Result.ToList();

            foreach (var item in articles)
            {
                productList.Add(item.CMN_PRO_ProductID);
            }

            List <L3PR_GAwSPfT_1535> results = new List <L3PR_GAwSPfT_1535>();

            if (productList.Count > 0)
            {
                var paramPrices = new CL3_Price.Complex.Retrieval.P_L3PR_GSPfPIL_1645
                {
                    ProductIDList = productList.ToArray()
                };

                var prices = CL3_Price.Complex.Retrieval.cls_Get_StandardPrices_for_ProductIDList.Invoke(Connection, Transaction, paramPrices, securityTicket).Result.ToList();

                foreach (var articl in articles)
                {
                    var articlesWithPrices = new L3PR_GAwSPfT_1535();

                    articlesWithPrices.Article = articl;
                    articlesWithPrices.Prices  = prices.Where(x => x.ProductID == articl.CMN_PRO_ProductID).Single();
                    results.Add(articlesWithPrices);
                }
            }

            returnValue.Result = results.ToArray();
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_L3PR_GAwSPfAL_1021_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3PR_GAwSPfAL_1021 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L3PR_GAwSPfAL_1021_Array();
            //Put your code here

            List <Guid> productList   = new List <Guid>();
            var         paramArticles = new CL3_Articles.Atomic.Retrieval.P_L3AR_GAfAL_0942
            {
                ProductID_List = Parameter.ProductListParameter.ProductID_List
            };

            List <L3AR_GAfAL_0942> articles = cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, paramArticles, securityTicket).Result.ToList();

            foreach (var item in articles)
            {
                productList.Add(item.CMN_PRO_ProductID);
            }

            List <L3PR_GAwSPfAL_1021> results = new List <L3PR_GAwSPfAL_1021>();

            if (productList.Count > 0)
            {
                var paramPrices = new CL3_Price.Complex.Retrieval.P_L3PR_GSPfPIL_1645
                {
                    ProductIDList = productList.ToArray()
                };

                var prices = CL3_Price.Complex.Retrieval.cls_Get_StandardPrices_for_ProductIDList.Invoke(Connection, Transaction, paramPrices, securityTicket).Result.ToList();

                foreach (var articl in articles)
                {
                    var articlesWithPrices = new L3PR_GAwSPfAL_1021();

                    articlesWithPrices.Article = articl;
                    articlesWithPrices.Prices  = prices.Where(x => x.ProductID == articl.CMN_PRO_ProductID).Single();
                    results.Add(articlesWithPrices);
                }
            }

            returnValue.Result = results.ToArray();

            return(returnValue);

            #endregion UserCode
        }
Exemple #3
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_CRR_1429 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            #region ArticlesAndPrices

            var productIDsParam = new List <Guid>();

            foreach (var proposalRequestPosition in Parameter.ProposalRequestPositions)
            {
                productIDsParam.Add(proposalRequestPosition.ProductID);
            }

            var productsParameter = new CL3_Articles.Atomic.Retrieval.P_L3AR_GAfAL_0942();
            productsParameter.ProductID_List = productIDsParam.Distinct().ToArray();

            var pricesParam = new CL3_Price.Complex.Retrieval.P_L3PR_GSPfPIL_1645();
            pricesParam.ProductIDList = productIDsParam.Distinct().ToArray();

            var products = new List <CL3_Articles.Atomic.Retrieval.L3AR_GAfAL_0942>();
            var prices   = new List <CL3_Price.Complex.Retrieval.L3PR_GSPfPIL_1645>();

            if (Parameter.ProposalRequestPositions.Length > 0)
            {
                prices   = CL3_Price.Complex.Retrieval.cls_Get_StandardPrices_for_ProductIDList.Invoke(Connection, Transaction, pricesParam, securityTicket).Result.ToList();
                products = CL3_Articles.Atomic.Retrieval.cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, productsParameter, securityTicket).Result.ToList();
            }

            #endregion

            var responseHeader = new CL1_ORD_PRC_RFP.ORM_ORD_PRC_RFP_SupplierProposalResponse_Header();
            responseHeader.ORD_PRC_RFP_SupplierProposalResponse_HeaderID = Guid.NewGuid();
            responseHeader.ProposalResponseHeaderITPL = Parameter.ProposalResponseHeaderITPL;
            responseHeader.OfferReceivedFrom_RegisteredBusinessParticipant_RefID = Parameter.OfferReceivedFrom_RegisteredBusinessParticipant_RefID;
            responseHeader.CreatedFor_RequestForProposal_Header_RefID            = Parameter.CreatedFor_RequestForProposal_Header_RefID;
            responseHeader.ValidThrough = Parameter.ValidThrough;
            responseHeader.Tenant_RefID = securityTicket.TenantID;

            responseHeader.Save(Connection, Transaction);

            foreach (var param in Parameter.ProposalRequestPositions)
            {
                #region RegisteredBusinessParticipantHistoryUpdate

                var potentialSupplier = new CL1_ORD_PRC_RFP.ORM_ORD_PRC_RFP_PotentialSupplier();

                var supplierForHistoryQuery = ORM_ORD_PRC_RFP_PotentialSupplier.Query.Search(Connection, Transaction,
                                                                                             new ORM_ORD_PRC_RFP_PotentialSupplier.Query
                {
                    RequestForProposal_Header_RefID = Parameter.CreatedFor_RequestForProposal_Header_RefID,
                    Tenant_RefID = securityTicket.TenantID
                }
                                                                                             ).First();

                //accepted request history
                var history = new CL1_ORD_PRC_RFP.ORM_ORD_PRC_RFP_PotentialSupplier_History();
                history.ORD_PRC_RFP_PotentialSupplier_HistoryID = Guid.NewGuid();
                history.ORD_PRC_RFP_PotentialSupplier_RefID     = supplierForHistoryQuery.ORD_PRC_RFP_PotentialSupplierID;
                history.IsEvent_ProposalResponse_Accepted       = true;
                history.Tenant_RefID = securityTicket.TenantID;
                history.Save(Connection, Transaction);

                #endregion

                var responsePosition = new CL1_ORD_PRC_RFP.ORM_ORD_PRC_RFP_SupplierProposalResponse_Position();

                var productPrice = prices.Single(pr => pr.ProductID == param.ProductID).SalesPrice;
                var productTax   = Convert.ToDecimal(products.Single(pr => pr.CMN_PRO_ProductID == param.ProductID).Taxes[0].TaxRate);

                responsePosition.ORD_PRC_RFP_SupplierProposalResponse_PositionID = Guid.NewGuid();
                responsePosition.PricePerUnit_WithoutTax              = productPrice;
                responsePosition.PricePerUnit_IncludingTax            = DLUtils_Common.Calculations.MoneyUtils.CalculateGrossPriceForTaxInPercent(productPrice, productTax);
                responsePosition.SupplierProposalResponseHeader_RefID = responseHeader.ORD_PRC_RFP_SupplierProposalResponse_HeaderID;
                responsePosition.ProposalResponsePositionITPL         = responsePosition.ORD_PRC_RFP_SupplierProposalResponse_PositionID.ToString();
                responsePosition.Quantity = param.Quantity;
                responsePosition.TotalPrice_IncludingTax = responseHeader.TotalPrice_IncludingTax;
                responsePosition.TotalPrice_WithoutTax   = responseHeader.TotalPrice_WithoutTax;
                responsePosition.CreatedFrom_RequestForProposal_Position_RefID = param.Created_From_RequestForProposal_Position_RefID;
                responsePosition.Tenant_RefID          = securityTicket.TenantID;
                responsePosition.CMN_PRO_Product_RefID = param.ProductID;
                responsePosition.Save(Connection, Transaction);
            }


            returnValue.Result = responseHeader.ORD_PRC_RFP_SupplierProposalResponse_HeaderID;
            return(returnValue);

            #endregion UserCode
        }
Exemple #4
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PO_AEDPtPO_1324 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();

            CL1_ORD_PRC.ORM_ORD_PRC_ExtraDemandProduct extraDemandProduct = null;

            foreach (var item in Parameter.ExtraDemandProductIDs)
            {
                extraDemandProduct = new CL1_ORD_PRC.ORM_ORD_PRC_ExtraDemandProduct();
                extraDemandProduct.Load(Connection, Transaction, item);

                #region Procurement Order Header

                var    pohSupplierParam = new P_L3PO_GAPOHfS_1412();
                string statusActive     = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EProcurementStatus.Active);
                pohSupplierParam.ActiveStatus_GlobalPropertyMatchingID = statusActive;
                pohSupplierParam.SupplierID = extraDemandProduct.Supplier_RefID;

                var procurementHeader = cls_Get_Active_ProcurementOrderHeader_for_SupplierID.Invoke(
                    Connection, Transaction, pohSupplierParam, securityTicket).Result.SingleOrDefault();

                Guid ProcurementOrderHeaderID = Guid.Empty;

                if (procurementHeader == null || procurementHeader.ORD_PRC_ProcurementOrder_HeaderID == Guid.Empty)
                {
                    // Create new procurement header
                    var pohParam = new P_L3PO_SPOH_0323();
                    pohParam.SupplierID             = extraDemandProduct.Supplier_RefID;
                    pohParam.GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.ProcurementOrderNumber);

                    ProcurementOrderHeaderID = cls_Save_ProcurementOrder_Header.Invoke(Connection, Transaction, pohParam, securityTicket).Result;
                }
                else
                {
                    ProcurementOrderHeaderID = procurementHeader.ORD_PRC_ProcurementOrder_HeaderID;
                }

                #endregion

                #region Create Procurement Order Position
                var priceParam = new CL3_Price.Complex.Retrieval.P_L3PR_GSPfPIL_1645
                {
                    ProductIDList = new Guid[] { extraDemandProduct.Product_RefID }
                };

                var price = CL3_Price.Complex.Retrieval.cls_Get_StandardPrices_for_ProductIDList.Invoke(Connection, Transaction, priceParam, securityTicket).Result.Single();

                var positionParam = new P_L3PO_SPOP_0331
                {
                    ORD_PRC_ProcurementOrder_HeaderID = ProcurementOrderHeaderID,
                    Positions = new P_L3PO_SPOP_0331a[]
                    {
                        new P_L3PO_SPOP_0331a
                        {
                            ORD_PRC_ProcurementOrder_PositionID = Guid.Empty,
                            IsDeleted         = false,
                            Position_Quantity = extraDemandProduct.RequestedQuantity,
                            PricePerUnit      = price.AverageProcurementPrice,
                            ProductID         = extraDemandProduct.Product_RefID
                        }
                    }
                };
                Guid[] result = cls_Save_ProcurementOrder_Positions.Invoke(Connection, Transaction, positionParam, securityTicket).Result;

                #region create cash discount
                //Create cash discount type for positions
                P_L5PO_GDVfHaDT_1607 param = new P_L5PO_GDVfHaDT_1607();
                param.DiscountType = EnumUtils.GetEnumDescription(EDiscountType.CashDiscount);
                param.HeaderID     = ProcurementOrderHeaderID;

                var discounts = cls_Get_DiscountValues_for_HeaderID_and_DiscountType.Invoke(Connection, Transaction, param, securityTicket).Result.ToList();

                if (discounts != null && discounts.Count > 0)
                {
                    P_L5PO_SCDfHoP_1117 newDiscountParam = new P_L5PO_SCDfHoP_1117();
                    newDiscountParam.DiscountValue = discounts.First().DiscountValue;
                    newDiscountParam.ProcurementOrderPositionIDList = result;

                    cls_Save_CashDiscount_for_Header_or_Position.Invoke(Connection, Transaction, newDiscountParam, securityTicket);
                }
                #endregion

                #endregion

                extraDemandProduct.ProcurementOrderPosition_RefID = result[0];

                extraDemandProduct.Save(Connection, Transaction);
            }

            return(returnValue);

            #endregion UserCode
        }