Ejemplo n.º 1
0
 public TaxValue(TaxTemplate taxTemplate)
 {
     TaxRate = taxTemplate.Rate;
     TaxTemplateId = taxTemplate.Id;
     TaxTemplateName = taxTemplate.Name;
     TaxTempleteAccountTransactionTypeId = taxTemplate.AccountTransactionType.Id;
 }
Ejemplo n.º 2
0
        public void CanHandleTax()
        {
            var taxTemplate = new TaxTemplate { Name = "Tax", Rate = 10, AccountTransactionType = AccountTransactionType.Default };
            var taxTemplates = new List<TaxTemplate> { taxTemplate };

            var tost = new MenuItem("Tost") { Id = 1 };
            var hamburger = new MenuItem("Hamburger") { Id = 2 };
            var ticket = TicketBuilder.Create(TicketType.Default, Department.Default).Build();

            var order = ticket.AddOrder(AccountTransactionType.Default, Department.Default, "Emre", tost, taxTemplates, new MenuItemPortion { Price = 5, Name = "Adet" }, "", null);

            order.Quantity = 2;
            order.PortionCount = 2;
            ticket.AddOrder(AccountTransactionType.Default, Department.Default, "Emre", tost, taxTemplates, new MenuItemPortion { Price = 5, Name = "Adet" }, "", null);
            ticket.AddOrder(AccountTransactionType.Default, Department.Default, "Emre", hamburger, taxTemplates, new MenuItemPortion { Price = 7, Name = "Adet" }, "", null);
            ticket.AddOrder(AccountTransactionType.Default, Department.Default, "Emre", hamburger, taxTemplates, new MenuItemPortion { Price = 6, Name = "Adet" }, "", null);
            ticket.AddCalculation(new CalculationType() { AccountTransactionType = AccountTransactionType.Default, DecreaseAmount = true }, 10);
            ticket.Recalculate();

            var orderSelector = new OrderSelector();
            orderSelector.UpdateTicket(ticket);
            Assert.AreEqual(ticket.GetSum(), orderSelector.Selectors.Sum(x => x.TotalPrice));

            ticket.TaxIncluded = true;
            orderSelector = new OrderSelector();
            orderSelector.UpdateTicket(ticket);
            Assert.AreEqual(ticket.GetSum(), orderSelector.Selectors.Sum(x => x.TotalPrice));

        }        
Ejemplo n.º 3
0
 public void UpdateTax(TaxTemplate taxTemplate)
 {
     Orders.ToList().ForEach(x => x.UpdateTaxTemplate(taxTemplate));
 }
Ejemplo n.º 4
0
        public void Setup()
        {
            Pizza = CreateMenuItem(1, "Pizza", 10);
            Cola = CreateMenuItem(2, "Cola", 5);
            Beer = CreateMenuItem(3, "Beer", 10);

            var saleAccountType = new AccountType { Name = "Sales Accounts", Id = 1 };
            var taxAccountType = new AccountType { Name = "Tax Accounts", Id = 2 };
            var receivableAccountType = new AccountType { Name = "Receivable Accounts", Id = 3 };
            var discountAccountType = new AccountType { Name = "Discount Accounts", Id = 4 };
            var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = "Sales", Id = 1 };
            ReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = "Receivables", Id = 2 };
            var stateTaxAccount = new Account { AccountTypeId = taxAccountType.Id, Name = "State Tax", Id = 3 };
            var localTaxAccount = new Account { AccountTypeId = taxAccountType.Id, Name = "Local Tax", Id = 4 };
            var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = "Discount", Id = 5 };

            var saleTransactionType = new AccountTransactionType
            {
                Id = 1,
                Name = "Sale Transaction",
                SourceAccountTypeId = saleAccountType.Id,
                TargetAccountTypeId = receivableAccountType.Id,
                DefaultSourceAccountId = defaultSaleAccount.Id,
                DefaultTargetAccountId = ReceivableAccount.Id
            };

            var localTaxTransactionType = new AccountTransactionType
            {
                Id = 2,
                Name = "Local Tax Transaction",
                SourceAccountTypeId = taxAccountType.Id,
                TargetAccountTypeId = receivableAccountType.Id,
                DefaultSourceAccountId = localTaxAccount.Id,
                DefaultTargetAccountId = ReceivableAccount.Id
            };

            var stateTaxTransactionType = new AccountTransactionType
            {
                Id = 3,
                Name = "State Tax Transaction",
                SourceAccountTypeId = taxAccountType.Id,
                TargetAccountTypeId = receivableAccountType.Id,
                DefaultSourceAccountId = stateTaxAccount.Id,
                DefaultTargetAccountId = ReceivableAccount.Id
            };

            DiscountTransactionType = new AccountTransactionType
            {
                Id = 4,
                Name = "Discount Transaction",
                SourceAccountTypeId = receivableAccountType.Id,
                TargetAccountTypeId = discountAccountType.Id,
                DefaultSourceAccountId = ReceivableAccount.Id,
                DefaultTargetAccountId = defaultDiscountAccount.Id
            };

            var stateTax = new TaxTemplate { Name = "State Tax", Rate = 25, Id = 1 };
            stateTax.TaxTemplateMaps.Add(new TaxTemplateMap());
            stateTax.AccountTransactionType = stateTaxTransactionType;

            var localTax = new TaxTemplate { Name = "Local Tax", Rate = 3, Id = 2 };
            localTax.TaxTemplateMaps.Add(new TaxTemplateMap { MenuItemId = Cola.Id });
            localTax.TaxTemplateMaps.Add(new TaxTemplateMap { MenuItemId = Beer.Id });
            localTax.AccountTransactionType = localTaxTransactionType;

            TaxTemplates = new List<TaxTemplate> { stateTax, localTax };

            TicketType = new TicketType { SaleTransactionType = saleTransactionType, TaxIncluded = true };
        }
Ejemplo n.º 5
0
 public void UpdateTaxTemplate(TaxTemplate taxTemplate)
 {
     TaxRate = taxTemplate.Rate;
     TaxTemplateId = taxTemplate.Id;
     TaxTemplateName = taxTemplate.Name;
     TaxIncluded = taxTemplate.TaxIncluded;
     UpdatePrice(Price, PriceTag);
 }
Ejemplo n.º 6
0
        public void UpdatePortion(MenuItemPortion portion, string priceTag, TaxTemplate taxTemplate)
        {
            PortionName = portion.Name;

            if (taxTemplate != null)
            {
                TaxRate = taxTemplate.Rate;
                TaxIncluded = taxTemplate.TaxIncluded;
                TaxTemplateId = taxTemplate.Id;
                TaxTemplateName = taxTemplate.Name;
                TaxTempleteAccountTransactionTypeId = taxTemplate.AccountTransactionType.Id;
            }

            if (!string.IsNullOrEmpty(priceTag))
            {
                string tag = priceTag;
                var price = portion.Prices.SingleOrDefault(x => x.PriceTag == tag);
                if (price != null && price.Price > 0)
                {
                    UpdatePrice(price.Price, price.PriceTag);
                }
                else priceTag = "";
            }

            if (string.IsNullOrEmpty(priceTag))
            {
                UpdatePrice(portion.Price, "");
            }

            foreach (var orderTagValue in OrderTagValues)
            {
                orderTagValue.PortionName = portion.Name;
            }
        }
Ejemplo n.º 7
0
 public void UpdatePortion(MenuItemPortion portion, string priceTag, TaxTemplate taxTemplate)
 {
     _model.UpdatePortion(portion, priceTag, taxTemplate);
     RaisePropertyChanged(() => Description);
     RaisePropertyChanged(() => TotalPrice);
 }
Ejemplo n.º 8
0
 public OrderBuilderTestContext With18PTaxTemplate()
 {
     TaxTemplate = new TaxTemplate
                      {
                          Id = 8,
                          Name = "%18 Tax",
                          Rate = 18,
                          AccountTransactionType = AccountTransactionType.Default
                      };
     return this;
 }
Ejemplo n.º 9
0
        public void CanCalculateSampleCase1()
        {
            // http://forum2.sambapos.com/index.php/topic,1481.0.html

            var percent8Tax = new TaxTemplate { Name = "% 8 Tax", Rate = 8, AccountTransactionType = new AccountTransactionType() { Id = 2 }, Rounding = 0 };
            var percent18Tax = new TaxTemplate { Name = "% 18 Tax", Rate = 18, AccountTransactionType = new AccountTransactionType() { Id = 3 }, Rounding = 0 };
            var tax8 = new List<TaxTemplate> { percent8Tax };
            var tax18 = new List<TaxTemplate> { percent18Tax };
            var ticket = Ticket.Create(Department.Default, TicketType, 1, null);
            ticket.TaxIncluded = true;
            AddOrderToTicket(ticket, tax8, 6, 16);
            Assert.AreEqual(96, ticket.GetSum());
            Assert.AreEqual(7.11, ticket.GetTaxTotal());
            AddOrderToTicket(ticket, tax8, 10, 3);
            AddOrderToTicket(ticket, tax8, 10, 3);
            AddOrderToTicket(ticket, tax8, 3, 10);
            AddOrderToTicket(ticket, tax18, 9, 1);
            AddOrderToTicket(ticket, tax8, 7, 1);
            AddOrderToTicket(ticket, tax8, 18, 3);
            AddOrderToTicket(ticket, tax8, 5, 2);
            AddOrderToTicket(ticket, tax8, 5, 2);
            AddOrderToTicket(ticket, tax8, 28, 3);
            AddOrderToTicket(ticket, tax8, 32, 3);
            AddOrderToTicket(ticket, tax8, 10, 2);
            AddOrderToTicket(ticket, tax8, 10, 2);
            AddOrderToTicket(ticket, tax18, 9, 1);
            AddOrderToTicket(ticket, tax18, 105, 2);
            ticket.Recalculate();
            Assert.AreEqual(715, ticket.GetSum());
            Assert.AreEqual(34.78 + 36.07, ticket.GetTaxTotal());
            Assert.AreEqual(36.07, ticket.TransactionDocument.AccountTransactions.Single(x => x.AccountTransactionTypeId == 2).Amount);
            Assert.AreEqual(34.78, ticket.TransactionDocument.AccountTransactions.Single(x => x.AccountTransactionTypeId == 3).Amount);
        }