Beispiel #1
0
        public IHttpActionResult GetPricing(string partnum)
        {
            InsiderEntity       insider = Insider.GetCurrentInsider();
            AvantePricingEntity pricing = Price.GetInsiderPrice(partnum, insider);
            ProdPricing         result  = new ProdPricing()
            {
                YourPrice = pricing.DealerPrice.GetPrice(),
                MSRP      = pricing.ListPrice.GetPrice()
            };

            return(Ok(result));
        }
Beispiel #2
0
        public static AvantePricingEntity GetInsiderPrice(string partnum, InsiderEntity insider, bool applyDiscounts = true)
        {
            if (insider.AccountNo == "")
            {
                return(null);                        // new PriceEntity() { value = NO_ACCESS };
            }
            AvantePricingEntity p = GetAvantePricing(partnum, insider, applyDiscounts);

            if (insider.IsMSRPOnly())
            {
                p.DealerPrice = CALL_PRICING;
            }
            if (insider.HasMsrpPricingException())
            {
                p.ListPrice = CALL_PRICING;
            }
            return(p);
        }
Beispiel #3
0
        private static AvantePricingEntity GetAvantePricing(string partnum, InsiderEntity insider, bool applyDiscounts)
        {
            AvantePricingEntity model = new AvantePricingEntity();

            Constants.CURRENCY_TYPE insiderCurrency = GetEnumCurrency(Functions.GetIntlPrefix(insider.PriceList));

            RBAccess oredback = new RBAccess();

            oredback.Command = "RPC_GetPricing_II";
            oredback.SetParameter(1, "");
            oredback.SetParameter(2, "");
            oredback.SetParameter(3, insider.GetBillToAccount());
            oredback.SetParameter(4, partnum);
            oredback.SetParameter(5, insider.PriceList);
            oredback.ClearFields();
            oredback.AddField("MktngDesc", "MktngDesc");
            oredback.AddField("WebEnabled", "WebEnabled");
            oredback.AddField("PriceCode", "PriceCode");
            oredback.AddField("CustPriceList", "CustPriceList");
            oredback.AddField("PartGroup", "PartGroup");
            oredback.AddField("DealerDisc", "DealerDisc");
            oredback.AddField("DealerDiscQtyBrk", "DealerDiscQtyBrk");
            oredback.AddField("DealerPrice", "DealerPrice");
            oredback.AddField("DealerQtyBrk", "DealerQtyBrk");
            oredback.AddField("ItemDisc", "ItemDisc");
            oredback.AddField("ItemDiscQtyBrk", "ItemDiscQtyBrk");
            oredback.AddField("ListPrice", "ListPrice");
            oredback.AddField("ListQtyBrk", "ListQtyBrk");
            oredback.AddField("Active", "AvanteActive");
            oredback.AddField("ProductPhase", "ProductPhase");
            oredback.AddField("ComponentPhase", "ComponentPhase");
            oredback.AddField("TakeOrderFlag", "TakeOrder");
            oredback.AddField("StopShipFlag", "StopShip");

            DataTable avante = oredback.GetDataTable("dlrprc");

            if (oredback.ErrorMessage != "")
            {
                return(null);
            }
            if (avante.Rows.Count == 0)
            {
                return(null);
            }

            DataRow data = avante.Rows[0];

            model.MktngDesc      = data["MktngDesc"].ToString();
            model.WebEnabled     = data["WebEnabled"].ToString() == "Y" ? true : false;
            model.AvanteActive   = data["AvanteActive"].ToString() == "Y" ? true : false;
            model.TakeOrderFlag  = data["TakeOrder"].ToString() == "Y" ? true : false;
            model.StopShip       = data["StopShip"].ToString() == "Y" ? true : false;
            model.ProductPhase   = GetEnumProductPhase(data["ProductPhase"].ToString());
            model.ComponentPhase = GetEnumComponentPhase(data["ComponentPhase"].ToString());
            model.PartGroup      = data["PartGroup"].ToString();
            model.PartGroup      = model.PartGroup.Substring(model.PartGroup.IndexOf('*'), model.PartGroup.IndexOf(']'));

            model.PriceList = insider.PriceList == "" ? data["CustPriceList"].ToString() : insider.PriceList;
            if (insider.HasMsrpPricingException())
            {
                model.ListPrice = CALL_PRICING;
            }
            else
            {
                string[] listPrices = data["ListPrice"].ToString().Split(RBAccess.VM);
                model.ListPrice = new PriceEntity()
                {
                    value = Decimal.Parse(listPrices[0]), currency = insiderCurrency
                };
            }

            decimal calcPrice;
            int     qtyBrk, lineItem = 1, prevQtyBrk = 0;
            string  qtyBrkDisplay;

            string[] dealerPrices = NO_ACCESS.ToString().Split(), dealerQtyBrks = NO_ACCESS.ToString().Split();
            if (!insider.HasMsrpPricingException())
            {
                dealerPrices  = data["DealerPrice"].ToString().Split(RBAccess.VM);
                dealerQtyBrks = data["DealerQtyBrk"].ToString().Split(RBAccess.VM);
            }

            // The original pricing.vb ran through the loop, but only
            // ever returned the first price item generated.
            // Let's process only the first item to begin with.
            int i = 0;

            //for (int i = 0; i < dealerPrices.Length; i++)
            //{
            calcPrice     = Decimal.Parse(dealerPrices[i]);
            qtyBrk        = Math.Min(int.Parse(dealerQtyBrks[i]), (int)NO_ACCESS); // CINTZERO
            qtyBrkDisplay = (prevQtyBrk + 1).ToString();
            if (dealerPrices.Length == lineItem)
            {
                qtyBrkDisplay += "+";
            }
            else
            {
                qtyBrkDisplay += "-" + qtyBrk.ToString();
            }

            if (applyDiscounts && PriceExtension.IsEligible(calcPrice))
            {
                int      lineItemBrk;
                decimal  lineItemPrice;
                string[] discounts, discountQtyBrks;

                // type 1 discount - line item
                if (data["ItemDisc"].ToString() != "")
                {
                    discounts       = data["ItemDisc"].ToString().Split(RBAccess.VM);
                    discountQtyBrks = data["ItemDiscQtyBrk"].ToString().Split(RBAccess.VM);

                    for (int j = 0; j < discounts.Length; j++)
                    {
                        lineItemPrice = decimal.Parse(discounts[j]);
                        lineItemBrk   = Math.Min(int.Parse(discountQtyBrks[j]), (int)NO_ACCESS);
                        if (qtyBrk <= lineItemBrk)
                        {
                            calcPrice += lineItemPrice;
                            break;
                        }
                    }
                }

                // type 4 discount - overall percentage
                if (data["DealerDisc"].ToString() != "")
                {
                    discounts       = data["DealerDisc"].ToString().Split(RBAccess.VM);
                    discountQtyBrks = data["DealerDisc"].ToString().Split(RBAccess.VM);
                    for (int j = 0; j < discounts.Length; j++)
                    {
                        lineItemPrice = decimal.Parse(discounts[j]);
                        lineItemBrk   = Math.Min(int.Parse(discountQtyBrks[j]), (int)NO_ACCESS);
                        if (qtyBrk <= lineItemBrk)
                        {
                            calcPrice *= (1 + (lineItemPrice / 100));
                            break;
                        }
                    }
                }
                model.DealerPrice = new PriceEntity()
                {
                    value = calcPrice, currency = insiderCurrency
                };
            }
            //}
            return(model);
        }