Пример #1
0
 public TaxValue(TaxTemplate taxTemplate)
 {
     TaxRate         = taxTemplate.Rate;
     TaxTemplateId   = taxTemplate.Id;
     TaxTemplateName = taxTemplate.Name;
     TaxTempleteAccountTransactionTypeId = taxTemplate.AccountTransactionType.Id;
 }
Пример #2
0
 public void UpdateTaxTemplate(TaxTemplate taxTemplate)
 {
     TaxRate         = taxTemplate.Rate;
     TaxTemplateId   = taxTemplate.Id;
     TaxTemplateName = taxTemplate.Name;
     TaxIncluded     = taxTemplate.TaxIncluded;
     UpdatePrice(Price, PriceTag);
 }
 public OrderBuilderTestContext With18PTaxTemplate()
 {
     TaxTemplate = new TaxTemplate
     {
         Id   = 8,
         Name = "%18 Tax",
         Rate = 18,
         AccountTransactionType = AccountTransactionType.Default
     };
     return(this);
 }
Пример #4
0
        public int UpdateTax(ref TaxTemplate obj_Tax, out string strError)
        {
            int UpdateRow = 0;

            strError = string.Empty;
            try
            {
                SqlParameter PAction        = new SqlParameter(TaxTemplate._Action, SqlDbType.BigInt);
                SqlParameter PTaxID         = new SqlParameter(TaxTemplate._TaxID, SqlDbType.BigInt);
                SqlParameter PTaxName       = new SqlParameter(TaxTemplate._TaxName, SqlDbType.NVarChar);
                SqlParameter PTaxPer        = new SqlParameter(TaxTemplate._TaxPer, SqlDbType.NVarChar);
                SqlParameter PTaxAmt        = new SqlParameter(TaxTemplate._TaxAmt, SqlDbType.NVarChar);
                SqlParameter PEffectiveDate = new SqlParameter(TaxTemplate._EffectiveDate, SqlDbType.DateTime);
                SqlParameter PUpdatedBy     = new SqlParameter(TaxTemplate._UpdatedBy, SqlDbType.BigInt);
                SqlParameter PUpdatedDate   = new SqlParameter(TaxTemplate._UpdatedDate, SqlDbType.DateTime);

                PAction.Value        = 2;
                PTaxID.Value         = obj_Tax.TaxId;
                PTaxName.Value       = obj_Tax.TaxName;
                PTaxPer.Value        = obj_Tax.TaxPer;
                PTaxAmt.Value        = obj_Tax.TaxAmt;
                PEffectiveDate.Value = obj_Tax.EffectiveDate;


                PUpdatedBy.Value   = obj_Tax.UpdatedByID.Equals("") ? 0 : obj_Tax.UpdatedByID;
                PUpdatedDate.Value = obj_Tax.UpdatedDate;

                SqlParameter[] ParamArray = new SqlParameter[] { PAction, PTaxID, PTaxName, PTaxPer, PTaxAmt, PEffectiveDate, PUpdatedBy, PUpdatedDate };
                Open(Setting.CONNECTION_STRING);
                BeginTransaction();
                UpdateRow = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, TaxTemplate.PRO_TAXTemplateMASTER, ParamArray);

                if (UpdateRow != 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                strError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(UpdateRow);
        }
Пример #5
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));
        }
Пример #6
0
        public TaxTemplate Build()
        {
            var result = new TaxTemplate
            {
                AccountTransactionType = _accountTransactionType,
                Name     = _taxName,
                Rate     = _rate,
                Rounding = _rounding
            };

            foreach (var taxTemplateMap in _taxTemplateMaps)
            {
                result.TaxTemplateMaps.Add(taxTemplateMap);
            }
            return(result);
        }
Пример #7
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;
            }
        }
Пример #8
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
            };
        }
Пример #9
0
 public OrderBuilder AddTaxTemplate(TaxTemplate taxTemplate)
 {
     _taxTemplates.Add(taxTemplate);
     return(this);
 }
Пример #10
0
 public void UpdateTax(TaxTemplate taxTemplate)
 {
     Orders.ToList().ForEach(x => x.UpdateTaxTemplate(taxTemplate));
 }
Пример #11
0
 public void UpdatePortion(MenuItemPortion portion, string priceTag, TaxTemplate taxTemplate)
 {
     _model.UpdatePortion(portion, priceTag, taxTemplate);
     RaisePropertyChanged(() => Description);
     RaisePropertyChanged(() => TotalPrice);
 }
Пример #12
0
 public OrderBuilderFor <T> WithTaxTemplate(TaxTemplate taxTemplate)
 {
     _orderBuilder.AddTaxTemplate(taxTemplate);
     return(this);
 }