public PriceBracket GetAllCustomerItemPriceBracket() { if (this.ShipTo != null) { PriceBracket priceBracket = new PriceBracket(); List <ERPPriceMatrixModel> lstpricematrix = new List <ERPPriceMatrixModel>(); var erpPricematrix = this.Product.CustomProperties.Where(p => p.Name.EqualsIgnoreCase("ERPPriceMatrix")).FirstOrDefault(); var defaultPriceList = this.ShipTo.CustomProperties.Where(p => p.Name.EqualsIgnoreCase("DefaultPriceList")).FirstOrDefault(); var priceDiscountCode = this.ShipTo.CustomProperties.Where(p => p.Name.EqualsIgnoreCase("PriceDiscountCode")).FirstOrDefault(); if (erpPricematrix != null && !string.IsNullOrEmpty(erpPricematrix.Value) && priceDiscountCode != null && !string.IsNullOrEmpty(priceDiscountCode.Value)) { if (erpPricematrix.Value.Contains("|") && erpPricematrix.Value.Split('|').Count() > 0) { var pricematrices = erpPricematrix.Value.Split('|'); foreach (var item in pricematrices) { var formattedstring = "{'" + item.Replace("=", "':'").Replace(",", "','") + "'}"; var lstitem = JsonConvert.DeserializeObject <ERPPriceMatrixModel>(formattedstring); if (lstitem != null && lstitem.CompanyNo.Equals(this.ShipTo.CustomerNumber[0].ToString())) { lstpricematrix.Add(lstitem); } } } if (lstpricematrix.Count > 0) { var matchedMatrix = lstpricematrix.Where(p => p.PriceDiscountCode.Equals(priceDiscountCode.Value)).FirstOrDefault(); if (matchedMatrix != null) { priceBracket.AdjustmentType = matchedMatrix.MarkupCode.EqualsIgnoreCase("$") ? "A" : "P"; string priceListNo = "1"; if (!string.IsNullOrEmpty(matchedMatrix.CustomerPriceList) && matchedMatrix.MarkupCode.EqualsIgnoreCase("D")) { if (matchedMatrix.CustomerPriceList.Equals("0") && defaultPriceList != null && !string.IsNullOrEmpty(defaultPriceList.Value)) { priceListNo = defaultPriceList.Value; } else { priceListNo = matchedMatrix.CustomerPriceList; } } priceBracket.PriceBasis = matchedMatrix.MarkupCode.EqualsIgnoreCase("$") ? "O" : "P" + priceListNo; // BUSA-568 : Pricing Issue - Acct # 80899 Gary Ackerman, DDS Starts var priceClass = this.Product.CustomProperties.Where(p => p.Name.EqualsIgnoreCase("PriceClass")).FirstOrDefault(); if (priceClass != null && priceClass.Value == "0") { priceBracket.Amount = 0; } else { priceBracket.Amount = Convert.ToDecimal(matchedMatrix.MarkupCode.EqualsIgnoreCase("$") ? matchedMatrix.Discount : "-" + matchedMatrix.Discount); } // BUSA-568 : Pricing Issue - Acct # 80899 Gary Ackerman, DDS Ends if (matchedMatrix.MarkupCode.EqualsIgnoreCase("D")) { var pricelist = this.Product.CustomProperties.Where(p => p.Name.EqualsIgnoreCase("Price" + priceListNo)).FirstOrDefault(); //BUSA-482 : Pricing Issue Defaut Price List PL4 Starts var defaultPriceListCust = this.ShipTo.CustomProperties.Where(p => p.Name.EqualsIgnoreCase("DefaultPriceList")).FirstOrDefault(); if (defaultPriceListCust != null) { if (!string.IsNullOrEmpty(defaultPriceListCust.Value)) { if (defaultPriceListCust.Value == "4") { var priceListAmt = GetPriceListAmount("P1"); decimal amt = 0; if (!string.IsNullOrEmpty(priceListAmt) && decimal.TryParse(priceListAmt, out amt)) { priceBracket.AdjustmentType = "A"; priceBracket.PriceBasis = "O"; priceBracket.Amount = amt; return(priceBracket); } } else { decimal altAmount = 0; if (pricelist != null && !string.IsNullOrEmpty(pricelist.Value) && decimal.TryParse(pricelist.Value, out altAmount)) { priceBracket.AltAmount = altAmount; } } } } //BUSA-482 : Pricing Issue Defaut Price List PL4 Ends else { decimal altAmount = 0; if (pricelist != null && !string.IsNullOrEmpty(pricelist.Value) && decimal.TryParse(pricelist.Value, out altAmount)) { priceBracket.AltAmount = altAmount; } } } return(priceBracket); } } } // BUSA-498 Uncommented for the condition i.e. customer price discount code is 0. Refer line # 317 for the condition. var priceListAmount = GetPriceListAmount("P1"); decimal amount = 0; if (!string.IsNullOrEmpty(priceListAmount) && decimal.TryParse(priceListAmount, out amount)) { priceBracket.AdjustmentType = "A"; priceBracket.PriceBasis = "O"; priceBracket.Amount = amount; return(priceBracket); } // BUSA-498 Ends } return(null); }
protected override IEnumerable <ProductPrice> GetProductPrice(IList <PriceMatrix> priceMatrixList, PricingServiceParameter pricingServiceParameter, PriceMatrix selectedPriceMatrix, bool regularPrice) { List <ProductPrice> productPriceList = new List <ProductPrice>(); List <PriceBracket> matrixBrackets = this.GetMatrixBrackets(selectedPriceMatrix); CurrencyDto currency = this.GetCurrency(selectedPriceMatrix.CurrencyCode); Decimal basePrice = this.GetBasePrice(pricingServiceParameter); foreach (PriceBracket priceBracket1 in matrixBrackets) { PriceData priceData1 = new PriceData(); priceData1.PricingServiceParameter = pricingServiceParameter; Product product = this.Product; priceData1.Product = product; Customer billTo = this.BillTo; priceData1.BillTo = billTo; Customer shipTo = GetSiteContextShipTo();//BUSA-42 : Duplicate Customers on Production. priceData1.ShipTo = shipTo; List <PriceBracket> priceBracketList = matrixBrackets; priceData1.MatrixBrackets = priceBracketList; PriceBracket priceBracket2 = priceBracket1; priceData1.PriceBracket = priceBracket2; if (selectedPriceMatrix.RecordType.EqualsIgnoreCase("Product")) { var priceBracket = GetAllCustomerItemPriceBracket(); if (priceBracket != null) { priceData1.PriceBracket.AdjustmentType = priceBracket.AdjustmentType; priceData1.PriceBracket.PriceBasis = priceBracket.PriceBasis; priceData1.PriceBracket.Amount = priceBracket.Amount; priceData1.PriceBracket.AltAmount = priceBracket.AltAmount; } } Decimal num = basePrice; priceData1.BasePrice = num; string calculationFlags = selectedPriceMatrix.CalculationFlags; priceData1.CalculationFlags = calculationFlags; if (selectedPriceMatrix.RecordType.EqualsIgnoreCase("Product")) { priceData1.TempBasis = priceData1.PriceBracket.AltAmount; } else { priceData1.TempBasis = this.GetTempBasisValue(priceBracket1.PriceBasis, priceMatrixList, pricingServiceParameter, regularPrice); } PriceData priceData = priceData1; IPriceCalculation priceCalculation = this.PriceCalculations.FirstOrDefault <IPriceCalculation>((Func <IPriceCalculation, bool>)(r => r.IsMatch(priceData))); if (priceCalculation != null) { ProductPrice productPrice = new ProductPrice(); productPrice.BreakQty = priceData.PriceBracket.BreakQty; if (regularPrice) { //Start:Revert BUSA 682 :The Base price of the product in ERP and the base price of the same product on the PDP are different.Revert BUSA: 696 Acct #78803:1076826 - Product (5011768U0) price differs in ERP and on the PDP. var price = GetPriceListAmount("P2"); productPrice.Price = !string.IsNullOrEmpty(price) ? Convert.ToDecimal(price) : this.GetBasePrice(pricingServiceParameter); //productPrice.Price = !string.IsNullOrEmpty(price) ? Convert.ToDecimal(price) : this.Product.BasicListPrice; //End:Revert BUSA 682 :The Base price of the product in ERP and the base price of the same product on the PDP are different.Revert BUSA: 696 Acct #78803:1076826 - Product (5011768U0) price differs in ERP and on the PDP. } else { productPrice.Price = priceCalculation.CalculatePrice(priceData); } productPrice.Price = this.ApplyProductMultiplier(pricingServiceParameter, productPrice.Price); productPrice.Price = selectedPriceMatrix.UnitOfMeasure == pricingServiceParameter.UnitOfMeasure || selectedPriceMatrix.UnitOfMeasure.IsBlank() && pricingServiceParameter.UnitOfMeasure == this.Product.UnitOfMeasure || priceBracket1.PriceBasis.Equals("CLM", StringComparison.OrdinalIgnoreCase) ? productPrice.Price : this.AdjustForUnitOfMeasure(pricingServiceParameter, productPrice.Price); productPrice.PriceDisplay = this.CurrencyFormatProvider.GetString(productPrice.Price, currency); productPriceList.Add(productPrice); } } return(productPriceList); }