//===============================================================================================
 public static KeyValuePair <decimal, string> processResult(TempResult got)
 {
     return(calculateTotalPrice(
                got.GrossCount4x6, got.GrossMatteCount4x6, got.Gross1HourCount4x6,
                got.GrossCount5x7, got.GrossMatteCount5x7, got.Gross1HourCount5x7,
                got.GrossCount8x10, got.GrossMatteCount8x10, got.Gross1HourCount8x10));
 }
        //======================================================================================================
        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);
        }
예제 #3
0
        //======================================================================================================
        public static KeyValuePair <decimal, string> processResult(TempResult gotResult)
        {
            //declare some local variables
            decimal rateLEQ50           = 0.0M;
            decimal rateLEQ75           = 0.0M;
            decimal rateLEQ100          = 0.0M;
            decimal pricePerMatteFinish = 0.0M;
            decimal price1HourLEQ60     = 0.0M;
            decimal price1HourGT60      = 0.0M;


            int countTotal = 0;
            int countMatte = 0;
            int count1Hour = 0;


            //end local var declarations

            //-----------------------------------------------------------
            //initialize local var based on mode.
            //-----------------------------------------------------------
            if (gotResult.Size.Equals("4x6"))
            {
                rateLEQ50           = 0.14M;
                rateLEQ75           = 0.12M;
                rateLEQ100          = 0.10M;
                pricePerMatteFinish = 0.02M;

                countMatte = gotResult.GrossMatteCount4x6;
                count1Hour = gotResult.Gross1HourCount4x6;
                countTotal = gotResult.GrossCount4x6;
            }
            else if (gotResult.Size.Equals("5x7"))
            {
                rateLEQ50           = 0.34M;
                rateLEQ75           = 0.31M;
                rateLEQ100          = 0.28M;
                pricePerMatteFinish = 0.03M;

                countMatte = gotResult.GrossMatteCount5x7;
                count1Hour = gotResult.Gross1HourCount5x7;
                countTotal = gotResult.GrossCount5x7;
            }
            else if (gotResult.Size.Equals("8x10"))
            {
                rateLEQ50           = 0.68M;
                rateLEQ75           = 0.64M;
                rateLEQ100          = 0.60M;
                pricePerMatteFinish = 0.04M;

                countMatte = gotResult.GrossMatteCount8x10;
                count1Hour = gotResult.Gross1HourCount8x10;

                countTotal = gotResult.GrossCount8x10;
            } //end if (mode.equals(...))

            //set rates for 1 hour processing
            price1HourLEQ60 = 1.0M;
            price1HourGT60  = 1.50M;

            var priceAndReceipt = HomogeneousOrder.calculateTotalPrice(
                countTotal, countMatte, count1Hour,
                rateLEQ50, rateLEQ75, rateLEQ100,
                pricePerMatteFinish, price1HourLEQ60, price1HourGT60);

            return(priceAndReceipt);
        }
        //======================================================================================================
        public KeyValuePair <decimal, string> applyDiscount(KeyValuePair <decimal, string> tempResult, TempResult got, InterfaceToBLL iBLL)
        {
            Decimal upcharge_per_temp;

            iBLL.Receipt     = tempResult.Value;
            iBLL.Total_Price = tempResult.Key;
            Decimal tempTotalDiscountCode = 0;
            Decimal tempTotalOver35       = 0;

            //----------------------------------------
            //Discount Code
            //----------------------------------------
            //iBLL.Total_Discount = (decimal).5;

            iBLL.Receipt = iBLL.Receipt + "\n" + "----------------------";
            iBLL.Receipt = iBLL.Receipt + "\n" + "Checking For Discounts";
            iBLL.Receipt = iBLL.Receipt + "\n" + "----------------------";


            // check code conditions
            // charect discount code
            // homogenous order
            // max count 100 is required.

            // James - Bug-7 - convert to upper case
            iBLL.Discount_Code = iBLL.Discount_Code.ToUpper();  //james Bug-7

            if ((iBLL.Discount_Code == "N56M2") & (got.Mode == "Homogeneous") & (got.GrossTotal == 100))
            {
                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:: " + got.GrossTotal;
                tempTotalDiscountCode = 2;
                iBLL.Receipt          = iBLL.Receipt + "\n" + "Potential Discount from Code::    2$";
            }
            else if (iBLL.Discount_Code.Length > 0)
            {
                iBLL.Receipt = iBLL.Receipt + "\n" + "---INVALID Discount Code Requirements--- ";// +iBLL.Discount_Code + " total : " + iBLL.Total_Discount.ToString();
                if (iBLL.Discount_Code != "N56M2")
                {
                    iBLL.Receipt = iBLL.Receipt + "\n" + "INVALID Discount Code Requirements:  Invalid Code:: ((" + iBLL.Discount_Code + "))";
                }
                if (got.Mode != "Homogeneous")
                {
                    iBLL.Receipt = iBLL.Receipt + "\n" + "INVALID Discount Code Requirements:  Not Homogeneous Order";
                }
                if (got.GrossTotal < 100)
                {
                    iBLL.Receipt = iBLL.Receipt + "\n" + "INVALID Discount Code Requirements:  Not 100 Count:  " + got.GrossTotal.ToString();
                }
                //iBLL.Total_Discount = (decimal)0.0;
                //iBLL.Receipt = iBLL.Receipt + "\n" + "INVALID Discount Code Requirements: " + iBLL.Discount_Code + " total : " + iBLL.Total_Discount.ToString();
            }



            //----------------------------------------
            //Discount > 35$
            // check if the 35$ discount applies
            //----------------------------------------

            if ((iBLL.Total_Price > (Decimal)34.0))
            {
                upcharge_per_temp = iBLL.Total_Price * (Decimal).05;
                tempTotalOver35   = upcharge_per_temp;
                iBLL.Receipt      = iBLL.Receipt + "\n" + "Potential Discount > 35$, 5%:: " + upcharge_per_temp;// +"  Total: " + tempTotalOver35;
            }


            //---------------
            //pick largest discount
            //between the two options

            iBLL.Receipt = iBLL.Receipt + "\n" + "---Picking Largest Discount---";


            if ((tempTotalDiscountCode == 0) && (tempTotalOver35 == 0))
            {
                iBLL.Total_Price = Math.Round(iBLL.Total_Price, 2, MidpointRounding.AwayFromZero);
                iBLL.Receipt     = iBLL.Receipt + "\n" + "No Discount, Total: " + iBLL.Total_Price;
            }
            else if ((tempTotalDiscountCode > tempTotalOver35))
            {
                iBLL.Total_Price = iBLL.Total_Price - tempTotalDiscountCode;
                iBLL.Total_Price = Math.Round(iBLL.Total_Price, 2, MidpointRounding.AwayFromZero);
                iBLL.Receipt     = iBLL.Receipt + "\n" + "Applying Discount Code Discount: " + tempTotalDiscountCode + " Total Price: " + iBLL.Total_Price;
            }
            else if ((tempTotalOver35 >= tempTotalDiscountCode))
            {
                iBLL.Total_Price = iBLL.Total_Price - tempTotalOver35;
                iBLL.Total_Price = Math.Round(iBLL.Total_Price, 2, MidpointRounding.AwayFromZero);
                iBLL.Receipt     = iBLL.Receipt + "\n" + "Applying Discount 35$, 5%, Discount: " + tempTotalOver35 + " Total Price: " + iBLL.Total_Price;
            }
            else
            {
//                iBLL.Receipt = iBLL.Receipt + "\n" + "No Discount, Total: " + iBLL.Total_Price;
                iBLL.Receipt = iBLL.Receipt + "\n" + "wut";
            }

            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(new KeyValuePair <decimal, string>(iBLL.Total_Price, iBLL.Receipt));
        }