public void BigReceiptTest()
        {
            int[] ProdsToSell  = { 3, 4, 5, 7, 11, 15 };
            int[] AmountToSell = { 10, 5, 10, 30, 2, 1 };
            int[] StorageCount = { 0, 0, 0, 0, 0, 0 };
            int   prod_count   = ProdsToSell.Count();
            bool  Pass         = true;

            for (int i = 0; i < prod_count; i++)
            {
                Product Prod = SC.ProductDictionary[ProdsToSell[i]];
                if (!Prod.StorageWithAmount.ContainsKey(1))
                {
                    Prod.StorageWithAmount.TryAdd(1, 0);
                }
                StorageCount[i] = Prod.StorageWithAmount[1];
                POS.AddSaleTransaction(Prod, AmountToSell[i]);
            }
            POS.ExecuteReceipt(false);
            for (int i = 0; i < prod_count; i++)
            {
                Product Prod = SC.ProductDictionary[ProdsToSell[i]];
                if (!(Prod.StorageWithAmount[1] == (StorageCount[i] - AmountToSell[i])))
                {
                    Pass = false;;
                }
            }
            Assert.IsTrue(Pass);
        }
Exemple #2
0
        public void AddSaleTransactionTest()
        {
            StorageController SC   = new StorageController();
            POSController     POSC = new POSController(SC);

            POSC.StartPurchase();

            POSC.AddSaleTransaction(new TempProduct("Hello", 3.6M), 7);

            Assert.IsTrue((POSC.PlacerholderReceipt.Transactions.First().TotalPrice == 3.6M * 7));
        }
        public void TestStatistics(int ProductID, int Amount, PaymentMethod_Enum PaymentMethod, decimal PaidAmount)
        {
            DateTime Start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
            DateTime Stop  = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);;

            StatCon.RequestTodayReceipts();
            StatCon.CalculatePayments();
            StatCon.RequestStatistics(false, 0, false, 0, false, "", Start, Stop);
            StatCon.GenerateProductSalesAndTotalRevenue();
            decimal     Kontant_old   = Math.Round(StatCon.Payments[0], 2);
            decimal     Dankort_old   = Math.Round(StatCon.Payments[1], 2);
            decimal     MobilePay_old = Math.Round(StatCon.Payments[2], 2);
            BaseProduct TestProd      = SC.AllProductsDictionary[ProductID];

            POS.AddSaleTransaction(TestProd, Amount);
            Payment TestPay = new Payment(Receipt.GetNextID(), PaidAmount, PaymentMethod);

            POS.PlacerholderReceipt.Payments.Add(TestPay);
            POS.ExecuteReceipt(false);
            StatCon.RequestTodayReceipts();
            StatCon.CalculatePayments();
            StatCon.GenerateProductSalesAndTotalRevenue();
            decimal Kontant_new   = Math.Round(StatCon.Payments[0], 2);
            decimal Dankort_new   = Math.Round(StatCon.Payments[1], 2);
            decimal MobilePay_new = Math.Round(StatCon.Payments[2], 2);

            if (PaymentMethod == PaymentMethod_Enum.Cash)
            {
                Assert.IsTrue(Kontant_new == Kontant_old + TestPay.Amount && Dankort_old == Dankort_new && MobilePay_old == MobilePay_new);
            }
            else if (PaymentMethod == PaymentMethod_Enum.Card)
            {
                Assert.IsTrue((Kontant_new + (PaidAmount - (TestProd.SalePrice * Amount))) == Kontant_old && Dankort_new == Dankort_old + TestPay.Amount && MobilePay_old == MobilePay_new);
            }
            else if (PaymentMethod == PaymentMethod_Enum.MobilePay)
            {
                Assert.IsTrue(Kontant_new == Kontant_old && Dankort_old == Dankort_new && MobilePay_new == MobilePay_old + TestPay.Amount);
            }
        }
 private void btn_AddTempProduct_Click(object sender, RoutedEventArgs e)
 {
     if (decimal.TryParse(textbox_Price.Text, out price) && price > 0 && textbox_Description != null)
     {
         string description = textbox_Description.Text;
         price = decimal.Parse(textbox_Price.Text);
         int         amount  = int.Parse(textBox_ProductAmount.Text);
         TempProduct NewTemp = _storageController.CreateTempTempProduct(description, price, _tempID);
         _storageController.TempTempProductList.Add(NewTemp);
         _posController.AddSaleTransaction(NewTemp, amount);
         UpdateReceiptEventHandler?.Invoke(this, null);
         this.Close();
     }
     else
     {
         textbox_Description.BorderBrush = Brushes.Red;
         textbox_Price.BorderBrush       = Brushes.Red;
     }
 }