//====================================================================================================== public BLL.InterfaceToBLL Calculate(BLL.InterfaceToBLL iBLL) { //get the mode of calculation TempResult gotResult = getModeAndGrossCounts(iBLL); KeyValuePair <decimal, string> priceAndReceipt; //----------------------------------------------------------- //evaluate the total price by calling the specific methods.. //----------------------------------------------------------- if (gotResult.Mode.Equals("Homogeneous")) { //returns a <Key,Value> pair. Key: price, Value: receipt priceAndReceipt = HomogeneousOrder.processResult(gotResult);//process order } else if (gotResult.Mode.Equals("Heterogeneous")) { //returns a <Key,Value> pair. Key: price, Value: receipt priceAndReceipt = HeterogeneousOrder.processResult(gotResult);//process order } else { //just for sanity check throw new Exception("Invalid value obtained! Error @ loc 184-194871-9."); } //----------------------------------------------------------- //evaluate the dicounted price here. //skipping for now... //.... //.. //----------------------------------------------------------- priceAndReceipt = applyDiscount(priceAndReceipt, gotResult, iBLL); //----------------------------------------------------------- var resultBLL = new BLL.InterfaceToBLL(); //----------------------------------------------------------- //do assignments... and return the computed price, receipt, and discount. resultBLL.Total_Count = gotResult.GrossTotal; resultBLL.Total_Price = priceAndReceipt.Key; resultBLL.Receipt = priceAndReceipt.Value; //When ready, assign discount here. //return the final result return(resultBLL); }
public int GetTotalCount(BLL.InterfaceToBLL iBLL) { //---------------------------------------- //Total Count //---------------------------------------- iBLL.Total_Count = 0; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_4_6_Gloss_Day; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_4_6_Gloss_Hour; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_4_6_Matte_Day; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_4_6_Matte_Hour; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_5_7_Gloss_Day; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_5_7_Gloss_Hour; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_5_7_Matte_Day; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_5_7_Matte_Hour; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_8_10_Gloss_Day; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_8_10_Gloss_Hour; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_8_10_Matte_Day; iBLL.Total_Count = iBLL.Total_Count + iBLL.Count_8_10_Matte_Hour; return(iBLL.Total_Count); }
//====================================================================================================== public TempResult getModeAndGrossCounts(BLL.InterfaceToBLL iBLL) { //This method throws exception: OrderGT100Error(message) var grossCount4x6 = iBLL.Count_4_6_Gloss_Day + iBLL.Count_4_6_Gloss_Hour + iBLL.Count_4_6_Matte_Day + iBLL.Count_4_6_Matte_Hour; var grossMatteCount4x6 = iBLL.Count_4_6_Matte_Day + iBLL.Count_4_6_Matte_Hour; var gross1HourCount4x6 = iBLL.Count_4_6_Gloss_Hour + iBLL.Count_4_6_Matte_Hour; var grossCount5x7 = iBLL.Count_5_7_Gloss_Day + iBLL.Count_5_7_Gloss_Hour + iBLL.Count_5_7_Matte_Day + iBLL.Count_5_7_Matte_Hour; var grossMatteCount5x7 = iBLL.Count_5_7_Matte_Day + iBLL.Count_5_7_Matte_Hour; var gross1HourCount5x7 = iBLL.Count_5_7_Gloss_Hour + iBLL.Count_5_7_Matte_Hour; var grossCount8x10 = iBLL.Count_8_10_Gloss_Day + iBLL.Count_8_10_Gloss_Hour + iBLL.Count_8_10_Matte_Day + iBLL.Count_8_10_Matte_Hour; var grossMatteCount8x10 = iBLL.Count_8_10_Matte_Day + iBLL.Count_8_10_Matte_Hour; var gross1HourCount8x10 = iBLL.Count_8_10_Gloss_Hour + iBLL.Count_8_10_Matte_Hour; var mode = ""; var size = ""; int grossHomogeneousCount = 101; //Begin the actual sorting process.. if (grossCount4x6 == 0 && grossCount5x7 == 0 && grossCount8x10 >= 0) { if (isTrulyHomogeneous(iBLL.Count_8_10_Gloss_Day, iBLL.Count_8_10_Gloss_Hour, iBLL.Count_8_10_Matte_Day, iBLL.Count_8_10_Matte_Hour)) { mode = "Homogeneous"; } else { mode = "Heterogeneous"; } grossHomogeneousCount = grossCount8x10; size = "8x10"; } else if (grossCount4x6 == 0 && grossCount8x10 == 0 && grossCount5x7 >= 0) { if (isTrulyHomogeneous(iBLL.Count_5_7_Gloss_Day, iBLL.Count_5_7_Gloss_Hour, iBLL.Count_5_7_Matte_Day, iBLL.Count_5_7_Matte_Hour)) { mode = "Homogeneous"; } else { mode = "Heterogeneous"; } size = "5x7"; grossHomogeneousCount = grossCount5x7; } else if (grossCount5x7 == 0 && grossCount8x10 == 0 && grossCount4x6 >= 0) { if (isTrulyHomogeneous(iBLL.Count_4_6_Gloss_Day, iBLL.Count_4_6_Gloss_Hour, iBLL.Count_4_6_Matte_Day, iBLL.Count_4_6_Matte_Hour)) { mode = "Homogeneous"; } else { mode = "Heterogeneous"; } grossHomogeneousCount = grossCount4x6; size = "4x6"; } else { //throw new Exception("Unable to determine a suited Mode and Size. Error@loc 109837428."); mode = "Heterogeneous"; grossHomogeneousCount = grossCount4x6 + grossCount5x7 + grossCount8x10; size = "Does Not Matter"; } //Check and see that the order is less than or equal to 100 if (grossHomogeneousCount > 100) { throw new OrderGT100Error("Total Homogeneous Gross Count >100!"); } else if (grossHomogeneousCount == 0) { throw new OrderLEQ0Error("Total Homogeneous Gross Count = 0 !"); } else if (grossHomogeneousCount < 0) { throw new Exception(" This is an internal application logic error. I shouldn't be here."); } else { Console.WriteLine("Proceeding with analysis. Gross Homogeneous Order Count: " + grossHomogeneousCount.ToString() + ".\n"); } TempResult toReturn; toReturn.GrossCount4x6 = grossCount4x6; toReturn.GrossCount5x7 = grossCount5x7; toReturn.GrossCount8x10 = grossCount8x10; toReturn.Gross1HourCount4x6 = gross1HourCount4x6; toReturn.Gross1HourCount5x7 = gross1HourCount5x7; toReturn.Gross1HourCount8x10 = gross1HourCount8x10; toReturn.GrossMatteCount4x6 = grossMatteCount4x6; toReturn.GrossMatteCount5x7 = grossMatteCount5x7; toReturn.GrossMatteCount8x10 = grossMatteCount8x10; toReturn.Mode = mode; toReturn.Size = size; toReturn.GrossTotal = grossHomogeneousCount; return(toReturn); }//end method getMode
/// <summary> /// Do analysis to determine mixed or unmixed and sub counts /// </summary> /// <param name="iBLL"></param> /// <returns></returns> private bool FirstPassAnalysis(BLL.InterfaceToBLL iBLL) { //---------------------------------------- //4x6 //---------------------------------------- if (iBLL.Count_4_6_Gloss_Day > 0) { countOfTypes++; countOfDayDelivery++; countTotal = countTotal + iBLL.Count_4_6_Gloss_Day; } if (iBLL.Count_4_6_Gloss_Hour > 0) { countOfTypes++; countOfHourDelivery++; countTotal = countTotal + iBLL.Count_4_6_Gloss_Hour; } if (iBLL.Count_4_6_Matte_Day > 0) { countOfTypes++; countOfDayDelivery++; countTotal = countTotal + iBLL.Count_4_6_Matte_Day; countOfMatt = countOfMatt + iBLL.Count_4_6_Matte_Day; } if (iBLL.Count_4_6_Matte_Hour > 0) { countOfTypes++; countOfHourDelivery++; countTotal = countTotal + iBLL.Count_4_6_Matte_Hour; countOfMatt = countOfMatt + iBLL.Count_4_6_Matte_Hour; } //---------------------------------------- //5x7 //---------------------------------------- if (iBLL.Count_5_7_Gloss_Day > 0) { countOfTypes++; countOfDayDelivery++; countTotal = countTotal + iBLL.Count_5_7_Gloss_Day; } if (iBLL.Count_5_7_Gloss_Hour > 0) { countOfTypes++; countOfHourDelivery++; countTotal = countTotal + iBLL.Count_5_7_Gloss_Hour; } if (iBLL.Count_5_7_Matte_Day > 0) { countOfTypes++; countOfDayDelivery++; countTotal = countTotal + iBLL.Count_5_7_Matte_Day; countOfMatt = countOfMatt + iBLL.Count_5_7_Matte_Day; } if (iBLL.Count_5_7_Matte_Hour > 0) { countOfTypes++; countOfHourDelivery++; countTotal = countTotal + iBLL.Count_5_7_Matte_Hour; countOfMatt = countOfMatt + iBLL.Count_5_7_Matte_Hour; } //---------------------------------------- //8x10 //---------------------------------------- if (iBLL.Count_8_10_Gloss_Day > 0) { countOfTypes++; countOfDayDelivery++; countTotal = countTotal + iBLL.Count_8_10_Gloss_Day; } if (iBLL.Count_8_10_Gloss_Hour > 0) { countOfTypes++; countOfHourDelivery++; countTotal = countTotal + iBLL.Count_8_10_Gloss_Hour; } if (iBLL.Count_8_10_Matte_Day > 0) { countOfTypes++; countOfDayDelivery++; countTotal = countTotal + iBLL.Count_8_10_Matte_Day; countOfMatt = countOfMatt + iBLL.Count_8_10_Matte_Day; } if (iBLL.Count_8_10_Matte_Hour > 0) { countOfTypes++; countOfHourDelivery++; countTotal = countTotal + iBLL.Count_8_10_Matte_Hour; countOfMatt = countOfMatt + iBLL.Count_8_10_Matte_Hour; } //double check if total count here matches the function to find total count. if (countTotal == this.GetTotalCount(iBLL)) { iBLL.Total_Count = this.GetTotalCount(iBLL); return(true); } else { return(false); } }
public BLL.InterfaceToBLL Calculate(BLL.InterfaceToBLL iBLL) { //init clear countOfTypes = 0; countOfHourDelivery = 0; countOfDayDelivery = 0; countOfMatt = 0; countTotal = 0; discountCodeUsed = false; //---------------------------------------- this.FirstPassAnalysis(iBLL); if (countOfTypes == 1) { iBLL.Receipt = iBLL.Receipt + "\n" + "-------------------------"; iBLL.Receipt = iBLL.Receipt + "\n" + "Order Is NON-Mixed "; iBLL.Receipt = iBLL.Receipt + "\n" + "Order Detail"; iBLL.Receipt = iBLL.Receipt + "\n" + "-------------------------"; } else if (countOfTypes > 1) { iBLL.Receipt = iBLL.Receipt + "\n" + "-------------------------"; iBLL.Receipt = iBLL.Receipt + "\n" + "Order Is Mixed "; iBLL.Receipt = iBLL.Receipt + "\n" + "Order Detail"; iBLL.Receipt = iBLL.Receipt + "\n" + "-------------------------"; } //---------------------------------------- //4x6 //---------------------------------------- if (iBLL.Count_4_6_Gloss_Day > 0) { price_per_temp = this.Get_4_6_PriceBracket(iBLL.Count_4_6_Gloss_Day, countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_4_6_Gloss_Day); iBLL.Price_4_6_Gloss_Day = (decimal)(price_per_temp * iBLL.Count_4_6_Gloss_Day); iBLL.Receipt = iBLL.Receipt + Format_Gloss("4x6 Gloss Next-Day Count: ", iBLL.Count_4_6_Gloss_Day, price_per_temp, subtotal_temp, iBLL.Price_4_6_Gloss_Day); } if (iBLL.Count_4_6_Gloss_Hour > 0) { price_per_temp = this.Get_4_6_PriceBracket(iBLL.Count_4_6_Gloss_Hour, countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_4_6_Gloss_Hour); iBLL.Price_4_6_Gloss_Hour = (decimal)(price_per_temp * iBLL.Count_4_6_Gloss_Hour); iBLL.Receipt = iBLL.Receipt + Format_Gloss("4x6 Gloss 1-Hour Count: ", iBLL.Count_4_6_Gloss_Hour, price_per_temp, subtotal_temp, iBLL.Price_4_6_Gloss_Hour); } if (iBLL.Count_4_6_Matte_Day > 0) { price_per_temp = this.Get_4_6_PriceBracket(iBLL.Count_4_6_Matte_Day, countOfTypes); upcharge_per_temp = this.Get_4_6_MattUpcharge(countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_4_6_Matte_Day); upchargeTotal_temp = (decimal)(upcharge_per_temp * iBLL.Count_4_6_Matte_Day); iBLL.Price_4_6_Matte_Day = subtotal_temp + upchargeTotal_temp; iBLL.Receipt = iBLL.Receipt + Format_Matte("4x6 Matte Next Day Count: ", iBLL.Count_4_6_Matte_Day, price_per_temp, upcharge_per_temp, subtotal_temp, upchargeTotal_temp, iBLL.Price_4_6_Matte_Day); } if (iBLL.Count_4_6_Matte_Hour > 0) { price_per_temp = this.Get_4_6_PriceBracket(iBLL.Count_4_6_Matte_Hour, countOfTypes); upcharge_per_temp = this.Get_4_6_MattUpcharge(countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_4_6_Matte_Hour); upchargeTotal_temp = (decimal)(upcharge_per_temp * iBLL.Count_4_6_Matte_Hour); iBLL.Price_4_6_Matte_Hour = subtotal_temp + upchargeTotal_temp; iBLL.Receipt = iBLL.Receipt + Format_Matte("4x6 Matte 1-Hour Count: ", iBLL.Count_4_6_Matte_Hour, price_per_temp, upcharge_per_temp, subtotal_temp, upchargeTotal_temp, iBLL.Price_4_6_Matte_Hour); } //---------------------------------------- //5x7 //---------------------------------------- if (iBLL.Count_5_7_Gloss_Day > 0) { price_per_temp = this.Get_5_7_PriceBracket(iBLL.Count_5_7_Gloss_Day, countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_5_7_Gloss_Day); iBLL.Price_5_7_Gloss_Day = (decimal)(price_per_temp * iBLL.Count_5_7_Gloss_Day); iBLL.Receipt = iBLL.Receipt + Format_Gloss("5x7 Gloss Next-Day Count: ", iBLL.Count_5_7_Gloss_Day, price_per_temp, subtotal_temp, iBLL.Price_5_7_Gloss_Day); } if (iBLL.Count_5_7_Gloss_Hour > 0) { price_per_temp = this.Get_5_7_PriceBracket(iBLL.Count_5_7_Gloss_Hour, countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_5_7_Gloss_Hour); iBLL.Price_5_7_Gloss_Hour = (decimal)(price_per_temp * iBLL.Count_5_7_Gloss_Hour); iBLL.Receipt = iBLL.Receipt + Format_Gloss("5x7 Gloss 1-Hour Count: ", iBLL.Count_5_7_Gloss_Hour, price_per_temp, subtotal_temp, iBLL.Price_5_7_Gloss_Hour); } if (iBLL.Count_5_7_Matte_Day > 0) { price_per_temp = this.Get_5_7_PriceBracket(iBLL.Count_5_7_Matte_Day, countOfTypes); upcharge_per_temp = this.Get_5_7_MattUpcharge(countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_5_7_Matte_Day); upchargeTotal_temp = (decimal)(upcharge_per_temp * iBLL.Count_5_7_Matte_Day); iBLL.Price_5_7_Matte_Day = subtotal_temp + upchargeTotal_temp; iBLL.Receipt = iBLL.Receipt + Format_Matte("5x7 Matte Next-Day Count: ", iBLL.Count_5_7_Matte_Day, price_per_temp, upcharge_per_temp, subtotal_temp, upchargeTotal_temp, iBLL.Price_5_7_Matte_Day); } if (iBLL.Count_5_7_Matte_Hour > 0) { price_per_temp = this.Get_5_7_PriceBracket(iBLL.Count_5_7_Matte_Hour, countOfTypes); upcharge_per_temp = this.Get_5_7_MattUpcharge(countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_5_7_Matte_Hour); upchargeTotal_temp = (decimal)(upcharge_per_temp * iBLL.Count_5_7_Matte_Hour); iBLL.Price_5_7_Matte_Hour = subtotal_temp + upchargeTotal_temp; iBLL.Receipt = iBLL.Receipt + Format_Matte("5x7 Matte 1-Hour Count: ", iBLL.Count_5_7_Matte_Hour, price_per_temp, upcharge_per_temp, subtotal_temp, upchargeTotal_temp, iBLL.Price_5_7_Matte_Hour); } //---------------------------------------- //8x10 //---------------------------------------- if (iBLL.Count_8_10_Gloss_Day > 0) { price_per_temp = this.Get_8_10_PriceBracket(iBLL.Count_8_10_Gloss_Day, countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_8_10_Gloss_Day); iBLL.Price_8_10_Gloss_Day = (decimal)(price_per_temp * iBLL.Count_8_10_Gloss_Day); iBLL.Receipt = iBLL.Receipt + Format_Gloss("8x10 Gloss Next-Day Count: ", iBLL.Count_8_10_Gloss_Day, price_per_temp, subtotal_temp, iBLL.Price_8_10_Gloss_Day); } if (iBLL.Count_8_10_Gloss_Hour > 0) { price_per_temp = this.Get_8_10_PriceBracket(iBLL.Count_8_10_Gloss_Hour, countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_8_10_Gloss_Hour); iBLL.Price_8_10_Gloss_Hour = (decimal)(price_per_temp * iBLL.Count_8_10_Gloss_Hour); iBLL.Receipt = iBLL.Receipt + Format_Gloss("8x10 Gloss 1-Hour Count: ", iBLL.Count_8_10_Gloss_Hour, price_per_temp, subtotal_temp, iBLL.Price_8_10_Gloss_Hour); } if (iBLL.Count_8_10_Matte_Day > 0) { price_per_temp = this.Get_8_10_PriceBracket(iBLL.Count_8_10_Matte_Day, countOfTypes); upcharge_per_temp = this.Get_8_10_MattUpcharge(countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_8_10_Matte_Day); upchargeTotal_temp = (decimal)(upcharge_per_temp * iBLL.Count_8_10_Matte_Day); iBLL.Price_8_10_Matte_Day = subtotal_temp + upchargeTotal_temp; iBLL.Receipt = iBLL.Receipt + Format_Matte("8x10 Matte Next-Day Count: ", iBLL.Count_8_10_Matte_Day, price_per_temp, upcharge_per_temp, subtotal_temp, upchargeTotal_temp, iBLL.Price_8_10_Matte_Day); } if (iBLL.Count_8_10_Matte_Hour > 0) { price_per_temp = this.Get_8_10_PriceBracket(iBLL.Count_8_10_Matte_Hour, countOfTypes); upcharge_per_temp = this.Get_8_10_MattUpcharge(countOfTypes); subtotal_temp = (decimal)(price_per_temp * iBLL.Count_8_10_Matte_Hour); upchargeTotal_temp = (decimal)(upcharge_per_temp * iBLL.Count_8_10_Matte_Hour); iBLL.Price_8_10_Matte_Hour = subtotal_temp + upchargeTotal_temp; iBLL.Receipt = iBLL.Receipt + Format_Matte("8x10 Matte 1-Hour Count: ", iBLL.Count_8_10_Matte_Hour, price_per_temp, upcharge_per_temp, subtotal_temp, upchargeTotal_temp, iBLL.Price_8_10_Matte_Hour); } //---------------------------------------- //Total Count //---------------------------------------- //iBLL.Total_Count = iBLL.G if (countTotal == this.GetTotalCount(iBLL)) { iBLL.Total_Count = this.GetTotalCount(iBLL); iBLL.Receipt = iBLL.Receipt + "\n" + "Total Count: " + iBLL.Total_Count; } else { iBLL.Receipt = iBLL.Receipt + "\n" + "Total Count: MISMATCH COUNT " + iBLL.Total_Count; } //---------------------------------------- //Total Price //---------------------------------------- iBLL.Total_Price = 0; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_4_6_Gloss_Day; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_4_6_Gloss_Hour; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_4_6_Matte_Day; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_4_6_Matte_Hour; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_5_7_Gloss_Day; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_5_7_Gloss_Hour; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_5_7_Matte_Day; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_5_7_Matte_Hour; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_8_10_Gloss_Day; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_8_10_Gloss_Hour; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_8_10_Matte_Day; iBLL.Total_Price = iBLL.Total_Price + iBLL.Price_8_10_Matte_Hour; iBLL.Receipt = iBLL.Receipt + "\n" + "Total Price Pre-Adjustments: " + iBLL.Total_Price; //---------------------------------------- // 1 hour next Day //---------------------------------------- iBLL.Receipt = iBLL.Receipt + "\n" + "--------------------"; iBLL.Receipt = iBLL.Receipt + "\n" + "Checking 1-Hour/Next-Day"; iBLL.Receipt = iBLL.Receipt + "\n" + "--------------------"; if (countOfHourDelivery > 0) { if (countOfTypes == 1) { if (countTotal <= 60) { iBLL.Total_Price = iBLL.Total_Price + 1; iBLL.Receipt = iBLL.Receipt + "\n" + "1-Hour <= 60 add 1$:: Total " + iBLL.Total_Price; } else if (countTotal > 60) { iBLL.Total_Price = iBLL.Total_Price + (Decimal)1.5; iBLL.Receipt = iBLL.Receipt + "\n" + "1-Hour >= 60 add 1.50$:: Total " + iBLL.Total_Price; } } else { if (countTotal <= 60) { iBLL.Total_Price = iBLL.Total_Price + 2; iBLL.Receipt = iBLL.Receipt + "\n" + "1-Hour <= 60 add 2$:: Total " + iBLL.Total_Price; } else if (countTotal > 60) { iBLL.Total_Price = iBLL.Total_Price + (Decimal)2.5; iBLL.Receipt = iBLL.Receipt + "\n" + "1-Hour >= 60 add 2.50$:: Total " + iBLL.Total_Price; } } } //---------------------------------------- //Discount Code //---------------------------------------- //iBLL.Total_Discount = (decimal).5; iBLL.Receipt = iBLL.Receipt + "\n" + "--------------------"; iBLL.Receipt = iBLL.Receipt + "\n" + "Checking Discounts"; iBLL.Receipt = iBLL.Receipt + "\n" + "--------------------"; Decimal tempTotalDiscountCode = 0; Decimal tempTotalOver35 = 0; if ((iBLL.Discount_Code == "N56M2") & (countOfTypes == 1) & (iBLL.Total_Count == 100)) { //iBLL.Total_Discount = (decimal)2.0; iBLL.Receipt = iBLL.Receipt + "\n" + "Discount $2: ";// +iBLL.Discount_Code; iBLL.Receipt = iBLL.Receipt + "\n" + "-------- Discount Code: " + iBLL.Discount_Code; iBLL.Receipt = iBLL.Receipt + "\n" + "-------- All Same Type: True"; iBLL.Receipt = iBLL.Receipt + "\n" + "-------- Count = 100: True:: " + iBLL.Total_Count; //iBLL.Total_Price = iBLL.Total_Price - 2; tempTotalDiscountCode = 2; // iBLL.Receipt = iBLL.Receipt + "\n" + "Potential Discount - 2$:: Total : " + iBLL.Total_Discount.ToString(); // iBLL.Receipt = iBLL.Receipt + "\n" + "Potential Discount - 2$:: Total : " + tempTotalDiscountCode.ToString(); iBLL.Receipt = iBLL.Receipt + "\n" + "Potential Discount from Code:: 2$"; //iBLL.Receipt = iBLL.Receipt + "\n" + "Total:: " + iBLL.Total_Price.ToString(); discountCodeUsed = true; } else if (iBLL.Discount_Code.Length > 0) { iBLL.Total_Discount = (decimal)0.0; iBLL.Receipt = iBLL.Receipt + "\n" + "INVALID Discount Code Requirements: " + iBLL.Discount_Code + " total : " + iBLL.Total_Discount.ToString(); discountCodeUsed = false; } // iBLL.Receipt = iBLL.Receipt + "\n" + "Discount Code: " + iBLL.Discount_Code + " total : " + iBLL.Total_Discount.ToString(); //---------------------------------------- //Discount > 35$ //---------------------------------------- // if ((discountCodeUsed == false) & (iBLL.Total_Price > 35)) if ((iBLL.Total_Price > (Decimal)35.0)) { upcharge_per_temp = iBLL.Total_Price * (Decimal).05; //iBLL.Total_Price = iBLL.Total_Price - upcharge_per_temp; tempTotalOver35 = upcharge_per_temp; iBLL.Receipt = iBLL.Receipt + "\n" + "Potential Discount > 35$, 5%: " + upcharge_per_temp;// +" Total: " + tempTotalOver35; //iBLL.Receipt = iBLL.Receipt + "\n" + "Total :: " + iBLL.Total_Price; } //--------------- //pick largest discount iBLL.Receipt = iBLL.Receipt + "\n" + "Picking Largest Discount"; if ((tempTotalDiscountCode > tempTotalOver35)) { iBLL.Total_Price = iBLL.Total_Price - tempTotalDiscountCode; iBLL.Receipt = iBLL.Receipt + "\n" + "Applying Discount Code Total: " + iBLL.Total_Price; } else if ((tempTotalOver35 > tempTotalDiscountCode)) { iBLL.Total_Price = iBLL.Total_Price - tempTotalOver35; iBLL.Receipt = iBLL.Receipt + "\n" + "Applying Discount 35$, 5%, Total: " + iBLL.Total_Price; } else { iBLL.Receipt = iBLL.Receipt + "\n" + "No Discount, Total: " + iBLL.Total_Price; } iBLL.Receipt = iBLL.Receipt + "\n" + "---------------------"; iBLL.Receipt = iBLL.Receipt + "\n" + "Total :: " + iBLL.Total_Price; iBLL.Receipt = iBLL.Receipt + "\n" + "---------------------"; iBLL.Total_Price = Math.Round(iBLL.Total_Price, 2, MidpointRounding.AwayFromZero); return(iBLL); }