コード例 #1
0
        public void TaxShouldBeCalculatedCorrectly(bool taxesEnabled, PriceLoadingMethod priceLoadingMethod,
            TaxCalculationMethod taxCalculationMethod,
            double basePrice, int quantity, double expected)
        {
            var pricingMethod =
                new ProductPricingMethodBuilder().TaxesEnabled(taxesEnabled)
                    .WithPriceLoadingMethod(priceLoadingMethod)
                    .WithTaxCalculationMethod(taxCalculationMethod).Build();
            var productVariant =
                new ProductVariantBuilder().WithBasePrice(Convert.ToDecimal(basePrice))
                    .WithTaxPercentage(TaxPercentage)
                    .Build();
            var cartItemData = new CartItemBuilder().WithItem(productVariant).WithQuantity(quantity).Build();

            pricingMethod.GetTax(cartItemData).Should().Be(Convert.ToDecimal(expected));
        }
        private void DiscountApplicationOnTaxIsCorrectForSingleRowPriced(double basePrice,
                                                                         PriceLoadingMethod priceLoadingMethod, DiscountOnPrices discountOnPrices,
                                                                         ApplyCustomerTax applyCustomerTax, double expected)
        {
            var pricingMethod =
                new ProductPricingMethodBuilder()
                .WithPriceLoadingMethod(priceLoadingMethod)
                .CalculateTaxOnRow()
                .WithDiscountOnPrices(discountOnPrices)
                .WithCustomerTaxApplication(applyCustomerTax)
                .Build();
            var productVariant =
                new ProductVariantBuilder().WithBasePrice(Convert.ToDecimal(basePrice))
                .WithTaxPercentage(TaxPercentage)
                .Build();
            var cartItemData = new CartItemBuilder().WithItem(productVariant).WithDiscountAmount(1).Build();

            pricingMethod.GetTax(cartItemData).Should().Be(Convert.ToDecimal(expected));
        }
コード例 #3
0
        private void DiscountApplicationOnTaxIsCorrectForIndividuallyPriced(double basePrice,
                                                                            PriceLoadingMethod priceLoadingMethod, DiscountOnPrices discountOnPrices,
                                                                            ApplyCustomerTax applyCustomerTax, double expected)
        {
            var pricingMethod =
                new ProductPricingMethodBuilder()
                .WithPriceLoadingMethod(priceLoadingMethod)
                .CalculateTaxOnIndividualItem()
                .WithDiscountOnPrices(discountOnPrices)
                .WithCustomerTaxApplication(applyCustomerTax)
                .Build();
            var productVariant =
                new ProductVariantBuilder().WithBasePrice(Convert.ToDecimal(basePrice))
                .WithTaxPercentage(TaxPercentage)
                .Build();
            var cartItemData = new CartItemBuilder().WithItem(productVariant).WithDiscountPercentage(10).Build();

            //check for various quantities - should be fine with individual item pricing to just multiply up
            for (int quantity = 1; quantity <= 10; quantity++)
            {
                cartItemData.Quantity = quantity;
                pricingMethod.GetTax(cartItemData).Should().Be(Convert.ToDecimal(expected * quantity));
            }
        }