Example #1
0
        public AccountTransaction AddNewTransaction(AccountTransactionType template, int accountTypeId, int accountId)
        {
            var transaction = AccountTransaction.Create(template, accountTypeId, accountId);

            AccountTransactions.Add(transaction);
            return(transaction);
        }
Example #2
0
 public void AddSingletonTransaction(int transactionTypeId, AccountTransactionType template, IEnumerable <AccountData> accountDataList)
 {
     if (AccountTransactions.SingleOrDefault(x => x.AccountTransactionTypeId == transactionTypeId) == null)
     {
         AddNewTransaction(template, accountDataList);
     }
 }
Example #3
0
        public static AccountTransaction Create(AccountTransactionType template, IEnumerable <AccountData> accountDataList)
        {
            var result = Create(template);

            result.UpdateAccounts(accountDataList);
            return(result);
        }
Example #4
0
        public static AccountTransaction Create(AccountTransactionType template)
        {
            // <pex>
            if (template == null)
            {
                throw new ArgumentNullException("template");
            }
            // </pex>

            var result = new AccountTransaction
            {
                Name = template.Name,
                AccountTransactionTypeId = template.Id,
                SourceTransactionValue   = new AccountTransactionValue {
                    AccountId = template.DefaultSourceAccountId, AccountTypeId = template.SourceAccountTypeId, Name = template.Name
                },
                TargetTransactionValue = new AccountTransactionValue {
                    AccountId = template.DefaultTargetAccountId, AccountTypeId = template.TargetAccountTypeId, Name = template.Name
                },
                SourceAccountTypeId = template.SourceAccountTypeId,
                TargetAccountTypeId = template.TargetAccountTypeId
            };


            return(result);
        }
Example #5
0
        public AccountTransaction AddNewTransaction(AccountTransactionType template, IEnumerable <AccountData> accountDataList)
        {
            var transaction = AccountTransaction.Create(template, accountDataList);

            AccountTransactions.Add(transaction);
            return(transaction);
        }
 public void AddSingletonTransaction(int transactionTypeId, AccountTransactionType template, IEnumerable<AccountData> accountDataList)
 {
     if (AccountTransactions.SingleOrDefault(x => x.AccountTransactionTypeId == transactionTypeId) == null)
     {
         AddNewTransaction(template, accountDataList);
     }
 }
Example #7
0
        public static AccountTransaction Create(AccountTransactionType template, int accountTypeId, int accountId)
        {
            var result = Create(template);

            result.UpdateAccounts(accountTypeId, accountId);
            return(result);
        }
 public void AddSingletonTransaction(int transactionTypeId, AccountTransactionType template, int accountTypeId, int accountId)
 {
     if (AccountTransactions.SingleOrDefault(x => x.AccountTransactionTypeId == transactionTypeId) == null)
     {
         AddNewTransaction(template, accountTypeId, accountId);
     }
 }
 public AccountTransaction AddNewTransaction(AccountTransactionType template, IEnumerable<AccountData> accountDataList, decimal amount, decimal exchangeRate)
 {
     var transaction = AccountTransaction.Create(template, accountDataList);
     transaction.UpdateAmount(amount, exchangeRate);
     AccountTransactions.Add(transaction);
     return transaction;
 }
Example #10
0
 public void AddSingletonTransaction(int transactionTypeId, AccountTransactionType template, int accountTypeId, int accountId)
 {
     if (AccountTransactions.SingleOrDefault(x => x.AccountTransactionTypeId == transactionTypeId) == null)
     {
         AddNewTransaction(template, accountTypeId, accountId);
     }
 }
Example #11
0
        public AccountTransaction AddNewTransaction(AccountTransactionType template, IEnumerable <AccountData> accountDataList, decimal amount, decimal exchangeRate)
        {
            var transaction = AccountTransaction.Create(template, accountDataList);

            transaction.UpdateAmount(amount, exchangeRate);
            AccountTransactions.Add(transaction);
            return(transaction);
        }
 public AccountTransaction AddNewTransaction(AccountTransactionType template, int accountTypeId, int accountId, Account account, decimal amount, decimal exchangeRate)
 {
     var transaction = AccountTransaction.Create(template, accountTypeId, accountId);
     transaction.UpdateAccounts(account.AccountTypeId, account.Id);
     transaction.UpdateAmount(amount, exchangeRate);
     AccountTransactions.Add(transaction);
     return transaction;
 }
 public AccountTransactionViewModel(IWorkspace workspace, AccountTransaction model, AccountTransactionDocument document)
 {
     Model = model ?? AccountTransaction.Null;
     _document = document;
     _workspace = workspace;
     _accountTransactionType =
         AccountTransactionTypes.SingleOrDefault(x => x.Id == Model.AccountTransactionTypeId);
 }
Example #14
0
        public AccountTransaction AddNewTransaction(AccountTransactionType template, int accountTypeId, int accountId, Account account, decimal amount, decimal exchangeRate)
        {
            var transaction = AccountTransaction.Create(template, accountTypeId, accountId);

            transaction.UpdateAccounts(account.AccountTypeId, account.Id);
            transaction.UpdateAmount(amount, exchangeRate);
            AccountTransactions.Add(transaction);
            return(transaction);
        }
Example #15
0
 public static AccountTransaction Create(AccountTransactionType template, int accountTypeId, int accountId)
 {
     var result = Create(template);
     result.UpdateAccounts(accountTypeId, accountId);
     return result;
 }
Example #16
0
        public static AccountTransaction Create(AccountTransactionType template)
        {
            // <pex>
            if (template == null)
                throw new ArgumentNullException("template");
            // </pex>

            var result = new AccountTransaction
                             {
                                 Name = template.Name,
                                 AccountTransactionTypeId = template.Id,
                                 SourceTransactionValue = new AccountTransactionValue { AccountId = template.DefaultSourceAccountId, AccountTypeId = template.SourceAccountTypeId, Name = template.Name },
                                 TargetTransactionValue = new AccountTransactionValue { AccountId = template.DefaultTargetAccountId, AccountTypeId = template.TargetAccountTypeId, Name = template.Name },
                                 SourceAccountTypeId = template.SourceAccountTypeId,
                                 TargetAccountTypeId = template.TargetAccountTypeId
                             };

            return result;
        }
Example #17
0
        public void AddOrder(Order order, IEnumerable<TaxTemplate> taxTemplates, AccountTransactionType template, string userName)
        {
            TransactionDocument.AddSingletonTransaction(template.Id, template, GetTicketAccounts());

            if (taxTemplates != null)
            {
                foreach (var taxTemplate in taxTemplates)
                {
                    TransactionDocument.AddSingletonTransaction(taxTemplate.AccountTransactionType.Id,
                                               taxTemplate.AccountTransactionType,
                                               GetTicketAccounts());
                }
            }

            Orders.Add(order);
            LastModifiedUserName = userName;
        }
Example #18
0
        public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList<TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer)
        {
            UnLock();
            var order = OrderBuilder.Create()
                                    .WithDepartment(department)
                                    .ForMenuItem(menuItem)
                                    .WithUserName(userName)
                                    .WithTaxTemplates(taxTemplates)
                                    .WithPortion(portion)
                                    .WithPriceTag(priceTag)
                                    .WithAccountTransactionType(template)
                                    .WithProductTimer(timer)
                                    .Build();

            AddOrder(order, taxTemplates, template, userName);
            return order;
        }
Example #19
0
        public Order AddOrder(AccountTransactionType template, Department department, string userName, MenuItem menuItem, IList<TaxTemplate> taxTemplates, MenuItemPortion portion, string priceTag, ProductTimer timer)
        {
            UnLock();
            var order = new Order();
            order.UpdateMenuItem(userName, menuItem, taxTemplates, portion, priceTag, 1);
            order.AccountTransactionTypeId = template.Id;
            order.WarehouseId = department.WarehouseId;
            order.DepartmentId = department.Id;
            TransactionDocument.AddSingletonTransaction(template.Id, template, GetTicketAccounts());

            if (taxTemplates != null)
            {
                foreach (var taxTemplate in taxTemplates)
                {
                    TransactionDocument.AddSingletonTransaction(taxTemplate.AccountTransactionType.Id,
                                               taxTemplate.AccountTransactionType,
                                               GetTicketAccounts());
                }
            }

            order.UpdateProductTimer(timer);
            Orders.Add(order);
            return order;
        }
Example #20
0
 public bool CanMakeAccountTransaction(TicketEntity ticketEntity, AccountTransactionType accountTransactionType, decimal targetBalance)
 {
     if (ticketEntity.AccountId == 0) return false;
     var entityType = _cacheService.GetEntityTypeById(ticketEntity.EntityTypeId);
     var typeId = accountTransactionType.TargetAccountTypeId;
     if (accountTransactionType.DefaultSourceAccountId == 0)
         typeId = accountTransactionType.SourceAccountTypeId;
     var result = entityType.AccountTypeId == typeId;
     if (result)
     {
         var accountType = _cacheService.GetAccountTypeById(entityType.AccountTypeId);
         if (accountType.WorkingRule != 0)
         {
             if (accountType.WorkingRule == 1 && targetBalance < 0) return false; //disallow credit
             if (accountType.WorkingRule == 2 && targetBalance > ticketEntity.GetCustomDataAsDecimal(Resources.CreditLimit)) return false; //disallow debit
         }
     }
     return result;
 }
 public AccountTransactionType Build()
 {
     var result = new AccountTransactionType { Id = _id };
     return result;
 }
Example #22
0
        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 };
        }
Example #23
0
 public CalculationTypeBuilder WithAccountTransactionType(AccountTransactionType accountTransactionType)
 {
     _accountTransactionType = accountTransactionType;
     return this;
 }
 public AccountTransaction AddNewTransaction(AccountTransactionType template, IEnumerable<AccountData> accountDataList)
 {
     var transaction = AccountTransaction.Create(template, accountDataList);
     AccountTransactions.Add(transaction);
     return transaction;
 }
Example #25
0
 public static AccountTransaction Create(AccountTransactionType template, IEnumerable<AccountData> accountDataList)
 {
     var result = Create(template);
     result.UpdateAccounts(accountDataList);
     return result;
 }
 public AccountTransaction AddNewTransaction(AccountTransactionType template, int accountTypeId, int accountId)
 {
     var transaction = AccountTransaction.Create(template, accountTypeId, accountId);
     AccountTransactions.Add(transaction);
     return transaction;
 }
Example #27
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 };
        }
Example #28
0
        public Order AddOrder(AccountTransactionType template, string userName, MenuItem menuItem, MenuItemPortion portion, string priceTag, ProductTimer timer)
        {
            Locked = false;
            var order = new Order();
            order.UpdateMenuItem(userName, menuItem, portion, priceTag, 1);
            order.AccountTransactionTypeId = template.Id;

            TransactionDocument.AddSingletonTransaction(template.Id, template, AccountTypeId, AccountId);

            if (menuItem.TaxTemplate != null)
            {
                TransactionDocument.AddSingletonTransaction(order.TaxTempleteAccountTransactionTypeId,
                                                               menuItem.TaxTemplate.AccountTransactionType,
                                                               AccountTypeId, AccountId);
            }

            order.UpdateProductTimer(timer);
            Orders.Add(order);
            return order;
        }
Example #29
0
        private AccountTransactionType CreateTransactionType(Account sourceAccount, Account targetAccount, ForeignCurrency foreignCurrency)
        {
            var result = new AccountTransactionType
             {
                 SourceAccountTypeId = sourceAccount.AccountTypeId,
                 TargetAccountTypeId = targetAccount.AccountTypeId,
                 DefaultSourceAccountId = sourceAccount.Id,
                 DefaultTargetAccountId = targetAccount.Id,
                 ForeignCurrencyId = foreignCurrency.Id
             };

            Workspace.Add(result);
            Workspace.CommitChanges();
            return result;
        }