public void PercentageDiscountIncludingVat()
		{
			IOC.IntegrationTest(); 
			var productInfo = DefaultFactoriesAndSharedFunctionality.CreateProductInfo(1000, 1, 10);
			var order = DefaultFactoriesAndSharedFunctionality.CreateIncompleteOrderInfo(productInfo);
			var discount = DefaultFactoriesAndSharedFunctionality.CreateDefaultOrderDiscountWithPercentage(50);
			IOC.OrderDiscountRepository.SetupFake(discount);
			order.OrderDiscountsFactory = () => IO.Container.Resolve<IOrderDiscountService>().GetApplicableDiscountsForOrder(order, order.Localization).ToList();
			order.ResetDiscounts();

			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);
		}
Esempio n. 2
0
 public SimplePrice(SimplePrice previous)
 {
     _localization = previous._localization;
     _source       = previous._source;
     _vat          = previous._vat;
     _discount     = previous._discount;
     _ranged       = previous._ranged;
 }
Esempio n. 3
0
		public SimplePrice(SimplePrice previous)
		{
			_localization = previous._localization;
			_source = previous._source;
			_vat = previous._vat;
			_discount = previous._discount;
			_ranged = previous._ranged;
		}
		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);
		}