public static Ticket Create(Department department, TicketType ticketType, decimal exchangeRate, IEnumerable <CalculationType> calculationTypes) { var ticket = new Ticket { TicketTypeId = ticketType.Id, DepartmentId = department.Id, TaxIncluded = ticketType.TaxIncluded, TransactionDocument = new AccountTransactionDocument(), ExchangeRate = exchangeRate }; if (calculationTypes != null) { foreach (var calculationType in calculationTypes.OrderBy(x => x.SortOrder)) { ticket.AddCalculation(calculationType, calculationType.Amount); } } return(ticket); }
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 }; }
public void SetCurrentTicketType(TicketType ticketType) { if (ticketType != CurrentTicketType) { CurrentTicketType = ticketType ?? TicketType.Default; CurrentTicketType.PublishEvent(EventTopicNames.TicketTypeChanged); } }
public void SetCurrentTicketType(TicketType ticketType) { CurrentTicketType = ticketType ?? TicketType.Default; }
public static Ticket Create(Department department, TicketType ticketType, decimal exchangeRate, IEnumerable<CalculationType> calculationTypes) { var ticket = new Ticket { TicketTypeId = ticketType.Id, DepartmentId = department.Id, TaxIncluded = ticketType.TaxIncluded, TransactionDocument = new AccountTransactionDocument(), ExchangeRate = exchangeRate }; if (calculationTypes != null) { foreach (var calculationType in calculationTypes.OrderBy(x => x.SortOrder)) { ticket.AddCalculation(calculationType, calculationType.Amount); } } return ticket; }
private void OnSelectTicketType(TicketType obj) { obj.PublishEvent(EventTopicNames.TicketTypeSelected, true); }
public void Setup() { Pizza = CreateMenuItem(1, "Pizza", 10); Cola = CreateMenuItem(2, "Cola", 5); Beer = CreateMenuItem(3, "Beer", 10); Product = CreateMenuItem(4, "Product", 1); 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 }; var 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 = TaxTemplateBuilder.Create("State Tax") .WithRate(25) .WithRounding(2) .WithAccountTransactionType(stateTaxTransactionType) .AddDefaultTaxTemplateMap() .Build(); var localTax = TaxTemplateBuilder.Create("Local Tax").WithRate(3) .AddTaxTemplateMap(new TaxTemplateMap {MenuItemId = Cola.Id}) .AddTaxTemplateMap(new TaxTemplateMap {MenuItemId = Beer.Id}) .WithAccountTransactionType(localTaxTransactionType) .WithRounding(2) .Build(); TaxTemplates = new List<TaxTemplate> { stateTax, localTax }; TicketType = new TicketType { SaleTransactionType = saleTransactionType, TaxIncluded = true }; }