/// <summary>
        /// Click event for cashButton. Opens cash payment screen when button is clicked.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Contains the event data.</param>
        void SelectCash(object sender, RoutedEventArgs e)
        {
            BleakwindBuffet.Data.CashDrawer cd = new BleakwindBuffet.Data.CashDrawer(currentOrder.Total);
            var cashScreen = new CashPaymentProcessing(currentOrder, cd);

            cashScreen.DataContext    = cd;
            fullComponentBorder.Child = cashScreen;
        }
예제 #2
0
 /// <summary>
 /// Finalizes the transaction, opens the CashDrawer, and sets the new amounts in the drawer.
 /// </summary>
 public void FinalizeTransaction()
 {
     CashDrawer.OpenDrawer();
     CashDrawer.Hundreds    += HundredsCustomer - HundredsChange;
     CashDrawer.Fifties     += FiftiesCustomer - FiftiesChange;
     CashDrawer.Twenties    += TwentiesCustomer - TwentiesChange;
     CashDrawer.Tens        += TensCustomer - TensChange;
     CashDrawer.Fives       += FivesCustomer - FivesChange;
     CashDrawer.Twos        += TwosCustomer - TwosChange;
     CashDrawer.Ones        += OnesCustomer - OnesChange;
     CashDrawer.Dollars     += DollarCoinsCustomer - DollarCoinsChange;
     CashDrawer.HalfDollars += HalfDollarsCustomer - HalfDollarsChange;
     CashDrawer.Quarters    += QuartersCustomer - QuartersChange;
     CashDrawer.Dimes       += DimesCustomer - DimesChange;
     CashDrawer.Nickels     += NickelsCustomer - NickelsChange;
     CashDrawer.Pennies     += PenniesCustomer - PenniesChange;
 }
예제 #3
0
 /// <summary>
 /// Updates cash register and prints receipt
 /// </summary>
 /// <param name="viewModel">current view model</param>
 /// <param name="payment">type of payment</param>
 /// <param name="orderDate">date in which order was created</param>
 public static void UpdateCashDrawerValues(CashDrawerViewModel viewModel, string payment, DateTime orderDate)
 {
     CashDrawer.OpenDrawer();
     AddTenured(viewModel);
     SubtractChange(viewModel);
     RecieptPrinter.PrintLine($"Order #{viewModel.order.Number}");
     RecieptPrinter.PrintLine($"{orderDate}");
     for (int i = 0; i < viewModel.order.Count; i++)
     {
         RecieptPrinter.PrintLine(viewModel.order[i].ToString());
         for (int j = 0; j < viewModel.order[i].SpecialInstructions.Count; j++)
         {
             RecieptPrinter.PrintLine($"\t {viewModel.order[i].SpecialInstructions[j]}");
         }
     }
     RecieptPrinter.PrintLine($"Subtotal: {viewModel.SubTotal}");
     RecieptPrinter.PrintLine($"Tax: {viewModel.Tax}");
     RecieptPrinter.PrintLine($"Total: {viewModel.Total}");
     RecieptPrinter.PrintLine($"{payment}");
     RecieptPrinter.PrintLine($"Change Due: {viewModel.ChangeOwed}"); //FIXME make sure using right prop here
     RecieptPrinter.CutTape();
 }
예제 #4
0
 /// <summary>
 /// Initializes the payment options screen for Bleakwind Buffet Point of Sale.
 /// </summary>
 /// <param name="currOrder">The current order that must be maintained.</param>
 public CashPaymentProcessing(Order currOrder, BleakwindBuffet.Data.CashDrawer currDrawer)
 {
     InitializeComponent();
     currentOrder  = currOrder;
     currentDrawer = currDrawer;
 }
        /// <summary>
        /// calculates change to go to customer
        /// </summary>
        /// <param name="total">total of order</param>
        public void CalculateChange(double total)
        {
            double payment = (InHundreds * 100.0) + (InFifties * 50) + (InTwenties * 20) + (InTens * 10) + (InFives * 5) + (InTwos * 2) + (InOnes * 1) + (InDollars * 1) +
                             (inHalfDollars * .5) + (InQuarters * .25) + (InDimes * .1) + (InNickels * .05) + (InPennies * .01); //payment made by customer
            double change = payment - total;                                                                                     //change due to the customer

            CashDrawer.OpenDrawer();                                                                                             //opens the cash drawer
            if (Hundreds > 0 && change >= 100)                                                                                   //checks if there are 100s and the change due is greater than 100
            {
                int count = (int)Math.Floor(change / 100);                                                                       //calculate 100s needed
                while (Hundreds > 0 && count >= Hundreds)                                                                        //loop while there are 100s & the qty of 100s needed is greater than qty of 100s
                {
                    change -= 100;
                    OutHundreds++;
                    Hundreds--;
                    count--;
                }
            }
            if (Fifties > 0 && change >= 50)              //checks if there are 50s and the change due is greater than 50
            {
                int count = (int)Math.Floor(change / 50); //calculate 50s needed
                while (Fifties > 0 && count >= Fifties)   //loop while there are 50s & qty need is greater than qty
                {
                    change -= 50;
                    OutFifties++;
                    OutFifties--;
                    count--;
                }
            }
            if (Twenties > 0 && change >= 20)             //checks if there are 20s and the change due is greater than 20
            {
                int count = (int)Math.Floor(change / 20); //calculate 20s needed
                while (Twenties > 0 && count >= Twenties) //loop while there are 20s & the qty of 20s needed is greater than qty of 20s
                {
                    change -= 20;
                    OutTwenties++;
                    Twenties--;
                    count--;
                }
            }
            if (Tens > 0 && change >= 10)                 //checks if there are 10s and the change due is greater than 10
            {
                int count = (int)Math.Floor(change / 10); //calculate 10s needed
                while (Tens > 0 && count >= Tens)         //loop while there are 10s & the qty of 10s needed is greater than qty of 10s
                {
                    change -= 10;
                    OutTens++;
                    Tens--;
                    count--;
                }
            }
            if (Fives > 0 && change >= 5)                //checks if there are 5s and the change due is greater than 5
            {
                int count = (int)Math.Floor(change / 5); //calculate 5s needed
                while (Fives > 0 && count >= Fives)      //loop while there are 5s & the qty of 5s needed is greater than qty of 5s
                {
                    change -= 5;
                    OutFives++;
                    Fives--;
                    count--;
                }
            }
            if (Twos > 0 && change >= 2)                 //checks if there are 2s and the change due is greater than 2
            {
                int count = (int)Math.Floor(change / 2); //calculate 2s needed
                while (Twos > 0 && count >= Twos)        //loop while there are 2s & the qty of 2s needed is greater than qty of 2s
                {
                    change -= 2;
                    OutTwos++;
                    Twos--;
                    count--;
                }
            }
            if (Ones > 0 && change >= 1)                 //checks if there are 1s and the change due is greater than 1
            {
                int count = (int)Math.Floor(change / 1); //calculate 1s needed
                while (Ones > 0 && count >= Ones)        //loop while there are 2s & the qty of 1s needed is greater than qty of 1s
                {
                    change -= 1;
                    OutOnes++;
                    Ones--;
                    count--;
                }
            }
            if (Dollars > 0 && change >= 1)              //checks if there are 1s and the change due is greater than 1
            {
                int count = (int)Math.Floor(change / 1); //calculate 1s needed
                while (Dollars > 0 && count >= Dollars)  //loop while there are 1s & the qty of 1s needed is greater than qty of 1s
                {
                    change -= 1;
                    OutDollars++;
                    Dollars--;
                    count--;
                }
            }
            if (HalfDollars > 0 && change >= .5)                //checks if there are .50s and the change due is greater than .5
            {
                int count = (int)Math.Floor(change / .5);       //calculate .5s needed
                while (HalfDollars > 0 && count >= HalfDollars) //loop while there are .5s & the qty of .5s needed is greater than qty of .5s
                {
                    change -= .5;
                    OutHalfDollars++;
                    HalfDollars--;
                    count--;
                }
            }
            if (Quarters > 0 && change >= .25)            //checks if there are quarters and the change due is greater than quarters
            {
                int count = (int)Math.Floor(change / .5); //calculate quarters needed
                while (Quarters > 0 && count >= Quarters) //loop while there are quarters & the qty of quarters needed is greater than qty of quarters
                {
                    change -= .25;
                    OutQuarters++;
                    Quarters--;
                    count--;
                }
            }
            if (Dimes > 0 && change >= .10)                //checks if there are dimes and the change due is greater than dimes
            {
                int count = (int)Math.Floor(change / .10); //calculate dimes needed
                while (Dimes > 0 && count >= Dimes)        //loop while there are dimes & the qty of dimes needed is greater than qty of dimes
                {
                    change -= .10;
                    OutDimes++;
                    Dimes--;
                    count--;
                }
            }
            if (Nickels > 0 && change >= .05)              //checks if there are nickels and the change due is greater than nickels
            {
                int count = (int)Math.Floor(change / .05); //calculate nickels needed
                while (Nickels > 0 && count >= Nickels)    //loop while there are nickels & the qty of nickels needed is greater than qty of nickels
                {
                    change -= .05;
                    OutNickels++;
                    Nickels--;
                    count--;
                }
            }
            if (Pennies > 0 && change >= .01)              //checks if there are pennies and the change due is greater than pennies
            {
                int count = (int)Math.Floor(change / .01); //calculate pennies needed
                while (Pennies > 0 && count >= Pennies)    //loop while there are pennies & the qty of pennies needed is greater than qty of pennies
                {
                    change -= .01;
                    OutPennies++;
                    Pennies--;
                    count--;
                }
            }
        }