Пример #1
0
        public Product(int id, string name, string countryId, double singlePrice, int quantity, VatTaxCalculator vatTaxCalculator)
        {
            Id = id;
            Name = name;
            CountryId = countryId;
            SinglePrice = singlePrice;
            Quantity = quantity;

            SinglePriceWithTax = SinglePrice + vatTaxCalculator.CalculateTax(CountryId, SinglePrice);
        }
Пример #2
0
        private static ShopInventory.ShopInventory GetInventory()
        {
            var taxes = new CountryVatTax[]
            {
                new CountryVatTax("BG", 0.2, true),
                new CountryVatTax("GB", 0.3, false),
                new CountryVatTax("US", 0.4, false),
                new CountryVatTax("ISIS", 10, false),
                new CountryVatTax("ZAMUNDA", 0, false)
            };

            var calculator = new VatTaxCalculator(taxes);

            var products = new Product[]
            {
                new Product(1, "BG Apples", "BG", 2, 10, calculator),
                new Product(2, "BG Pears", "BG", 3, 15, calculator),
                new Product(3, "GB Apples", "GB", 5, 10, calculator),
                new Product(4, "ISIS Apples", "ISIS", 100, 10, calculator),
                new Product(5, "ZAMUNDA Apples", "ZAMUNDA", 0, 99999, calculator)
            };

            return new ShopInventory.ShopInventory(products);
        }
Пример #3
0
        public Product(int id, string name, string countryId, double singlePrice, int quantity, VatTaxCalculator vatTaxCalculator)
        {
            Id          = id;
            Name        = name;
            CountryId   = countryId;
            SinglePrice = singlePrice;
            Quantity    = quantity;

            SinglePriceWithTax = SinglePrice + vatTaxCalculator.CalculateTax(CountryId, SinglePrice);
        }