public void Calculate_Product_Sell_Prices_And_Fees_With_Division_And_Multiplication_Percent_Amortized_And_Dollar_Amount_Fee() { var product = new Product() { ProductCost = 1, ProductAnnualSalesProjection = 100 }; product.Fees = new List<Fee>(); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Dollar_Amount), FeeDollarAmount = 1 }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Amortized), FeeAmortizedCharge = 100, FeeAmortizedType = MyExtensions.GetEnumDescription(AmortizedTypeList.Annual_Sales_Projection) }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Percent), FeePercent = 10, FeePercentType = MyExtensions.GetEnumDescription(PercentTypeList.Division) }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Percent), FeePercent = 10, FeePercentType = MyExtensions.GetEnumDescription(PercentTypeList.Multiplication) }); product.ProductSellPrices = new List<ProductSellPrice>(); product.ProductSellPrices.Add(new ProductSellPrice() { SellPriceName = "Employee", SellPriceMarginPercent = 50, SellPriceLevel = 1 }); product.ProductSellPrices.Add(new ProductSellPrice() { SellPriceName = "Retail", SellPriceMarginPercent = 50, SellPriceLevel = 2 }); foreach(var sellPrice in product.ProductSellPrices) { sellPrice.Fees = new List<Fee>(); if(sellPrice.SellPriceName == "Retail") { sellPrice.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Percent), FeePercent = 20, FeePercentType = MyExtensions.GetEnumDescription(PercentTypeList.Multiplication) }); } } var feeCalculator = new FeeCalculator(product); feeCalculator.ComputeNetCost(); Assert.AreEqual(3, product.ProductNetCost); feeCalculator.ComputeTotalCost(); // Created to get same value though division decimal value = ((decimal)3 / (decimal).9) * (decimal)1.1; value = feeCalculator.RoundNumberToDecimalPlace(value, 3); Assert.AreEqual(value, product.ProductTotalCost); // New Part of Test feeCalculator.ComputeSellPrices(false); foreach(var sellPrice in product.ProductSellPrices) { decimal sellPriceValue = value / (decimal)(.50); foreach(var fee in sellPrice.Fees) { if(fee.FeePercentType == MyExtensions.GetEnumDescription(PercentTypeList.Multiplication)) { sellPriceValue = sellPriceValue * (decimal)1.2; } else { sellPriceValue = sellPriceValue / (decimal).8; } } Assert.AreEqual(feeCalculator.RoundNumberToDecimalPlace(sellPriceValue, 3), sellPrice.SellPriceFinalAmount); } }
public void Calculate_Product_Total_Cost_With_Multiplication_And_Division_Percent_Amortized_And_Dollar_Amount_Fee() { var product = new Product() { ProductCost = 1, ProductAnnualSalesProjection = 100 }; product.Fees = new List<Fee>(); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Dollar_Amount), FeeDollarAmount = 1 }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Amortized), FeeAmortizedCharge = 100, FeeAmortizedType = MyExtensions.GetEnumDescription(AmortizedTypeList.Annual_Sales_Projection) }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Percent), FeePercent = 10, FeePercentType = MyExtensions.GetEnumDescription(PercentTypeList.Multiplication) }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Percent), FeePercent = 10, FeePercentType = MyExtensions.GetEnumDescription(PercentTypeList.Division) }); var feeCalculator = new FeeCalculator(product); feeCalculator.ComputeNetCost(); Assert.AreEqual(3, product.ProductNetCost); feeCalculator.ComputeTotalCost(); // Created to get same value though division decimal value = ((decimal)3 * (decimal)1.1) / (decimal).9; value = feeCalculator.RoundNumberToDecimalPlace(value, 3); Assert.AreEqual(value, product.ProductTotalCost); }
public void Calculate_Product_Total_Cost_With_Multiplication_Percent_Amortized_And_Dollar_Amount_Fee() { var product = new Product() { ProductCost = 1, ProductAnnualSalesProjection = 100 }; product.Fees = new List<Fee>(); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Dollar_Amount), FeeDollarAmount = 1 }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Amortized), FeeAmortizedCharge = 100, FeeAmortizedType = MyExtensions.GetEnumDescription(AmortizedTypeList.Annual_Sales_Projection) }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Percent), FeePercent = 10, FeePercentType = MyExtensions.GetEnumDescription(PercentTypeList.Multiplication)}); var feeCalculator = new FeeCalculator(product); feeCalculator.ComputeNetCost(); Assert.AreEqual(3, product.ProductNetCost); feeCalculator.ComputeTotalCost(); Assert.AreEqual((decimal?)3.3, product.ProductTotalCost); }
public void Calculate_Product_Sell_Price_With_Only_Dollar_Fees() { var product = new Product() { ProductCost = 1, ProductAnnualSalesProjection = 100 }; product.Fees = new List<Fee>(); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Dollar_Amount), FeeDollarAmount = 1 }); product.Fees.Add(new Fee() { FeeType = MyExtensions.GetEnumDescription(FeeTypeList.Amortized), FeeAmortizedCharge = 100, FeeAmortizedType = MyExtensions.GetEnumDescription(AmortizedTypeList.Annual_Sales_Projection) }); var feeCalculator = new FeeCalculator(product); feeCalculator.ComputeNetCost(); Assert.AreEqual(3, product.ProductNetCost); feeCalculator.ComputeTotalCost(); Assert.AreEqual(3, product.ProductTotalCost); }