public void OrderWithManyItemsHadRelativelyLargeDeviationWhenCalculatingVatOverPartsInsteadOfOverTotal()
        {
            IOC.IntegrationTest();
            IOC.SettingsService.InclVat();
            IOC.VatCalculationStrategy.OverTotal();

            var productInfo1 = DefaultFactoriesAndSharedFunctionality.CreateProductInfo(7500, 2, 21m);
            var productInfo2 = DefaultFactoriesAndSharedFunctionality.CreateProductInfo(200, 25, 21m);
            var productInfo3 = DefaultFactoriesAndSharedFunctionality.CreateProductInfo(200, 50, 21m);
            var productInfo4 = DefaultFactoriesAndSharedFunctionality.CreateProductInfo(200, 50, 21m);
            var productInfo5 = DefaultFactoriesAndSharedFunctionality.CreateProductInfo(200, 25, 21m);
            var order        = DefaultFactoriesAndSharedFunctionality.CreateIncompleteOrderInfo(productInfo1, productInfo2, productInfo3, productInfo4, productInfo5);

            var directlyCalculatedVat = VatCalculator.VatAmountFromWithVat(45000, 21m);

            Assert.AreEqual(7810, directlyCalculatedVat);

            Assert.AreEqual(7810, order.VatTotalInCents);

            Assert.AreEqual(45000, order.GrandtotalInCents);

            Assert.AreEqual(45000 - 7810, order.SubtotalInCents);

            Console.WriteLine(directlyCalculatedVat);
            Console.WriteLine(order.VatTotalInCents);
            Console.WriteLine(order.GrandtotalInCents);


            // todo: this might be a concern:
            // var orderNewDiscount = order.DiscountAmountWithVatInCents;
            // Assert.AreEqual(x, orderNewDiscount); where x should not be 0 but orderNewDiscount is 0
        }
Beispiel #2
0
        public void AmountDiscountIncludingVat()
        {
            IOC.IntegrationTest();
            var productInfo = DefaultFactoriesAndSharedFunctionality.CreateProductInfo(1000, 1, 10);
            var order       = DefaultFactoriesAndSharedFunctionality.CreateIncompleteOrderInfo(productInfo);
            var discount    = DefaultFactoriesAndSharedFunctionality.CreateDefaultOrderDiscountWithAmount(500, DiscountOrderCondition.None, 0);

            IOC.OrderDiscountRepository.SetupFake(discount);
            order.OrderDiscountsFactory = () => IO.Container.Resolve <IOrderDiscountService>().GetApplicableDiscountsForOrder(order, order.Localization).ToList();
            order.ResetDiscounts();

            var absoluteDiscountAmount    = 500;
            var AverageOrderVatPercentage = 10m;
            var vatAmountFromWithVat      = VatCalculator.VatAmountFromWithVat(absoluteDiscountAmount, AverageOrderVatPercentage);

            //var vatAmountFromWithoutVat = VatCalculator.VatAmountFromWithoutVat(absoluteDiscountAmount, AverageOrderVatPercentage);
            Assert.AreEqual(45, vatAmountFromWithVat);

            // berekende discount vat = 45,45454545..
            // correct zou zijn 500 - 454 = 46 (zie hieronder)

            // full amount: 909
            // discounted amount: 455
            // discount: 909 - 455 = 454
            //  'discount vat': 500 - 454 = 46

            Assert.AreEqual(1000, order.GetAmount(true, false, true));
            Assert.AreEqual(909, order.GetAmount(false, false, true));
            Assert.AreEqual(500, order.GetAmount(true, true, true));
            Assert.AreEqual(455, order.GetAmount(false, true, true));

            var price = new SimplePrice(order, order.Localization);

            Assert.AreEqual(1000, price.BeforeDiscount.WithVat.ValueInCents);
            Assert.AreEqual(909, price.BeforeDiscount.WithoutVat.ValueInCents);
            Assert.AreEqual(91, price.BeforeDiscount.Vat.ValueInCents);
            Assert.AreEqual(500, price.WithVat.ValueInCents);
            Assert.AreEqual(455, price.WithoutVat.ValueInCents);
            Assert.AreEqual(45, price.Vat.ValueInCents);

            Assert.AreEqual(500, price.Discount.WithVat.ValueInCents);
            Assert.AreEqual(454, price.Discount.WithoutVat.ValueInCents);
        }
Beispiel #3
0
 public void VatAmountFromWithVat(int amountWithVat, int vatAmount)
 {
     Assert.AreEqual(vatAmount, VatCalculator.VatAmountFromWithVat(amountWithVat, 19));
 }