示例#1
0
        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);
            }
        }