public void UpdateTax(Tax tax)
 {
     _taxRepo.Update(tax);
 }
        public static void InitTax()
        {
            var vat5 = new Tax()
            {
                TaxCode = "VAT5%",
                TaxName = "VAT 5%",
                Rate = 5,
                IsActive = true,
                SalesAccountId = 37,
                PurchasingAccountId = 37,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            };

            var vat10 = new Tax()
            {
                TaxCode = "VAT10%",
                TaxName = "VAT 10%",
                Rate = 10,
                IsActive = true,
                SalesAccountId = 37,
                PurchasingAccountId = 37,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            };

            var evat12 = new Tax()
            {
                TaxCode = "VAT12%",
                TaxName = "VAT 12%",
                Rate = 12,
                IsActive = true,
                SalesAccountId = 37,
                PurchasingAccountId = 37,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            };

            var exportTax1 = new Tax()
            {
                TaxCode = "exportTax1%",
                TaxName = "Export Tax 1%",
                Rate = 1,
                IsActive = true,
                SalesAccountId = 37,
                PurchasingAccountId = 37,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            };

            _context.Taxes.Add(vat5);
            _context.Taxes.Add(vat10);
            _context.Taxes.Add(evat12);
            _context.Taxes.Add(exportTax1);

            var taxGroupVAT = new TaxGroup()
            {
                Description = "VAT",
                TaxAppliedToShipping = false,
                IsActive = true,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            };

            var taxGroupExport = new TaxGroup()
            {
                Description = "Export",
                TaxAppliedToShipping = false,
                IsActive = true,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            };

            _context.TaxGroups.Add(taxGroupVAT);
            _context.TaxGroups.Add(taxGroupExport);

            var itemTaxGroupRegular = new ItemTaxGroup()
            {
                Name = "Regular",
                IsFullyExempt = false,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            };

            var itemTaxGroupRegularPreferenced = new ItemTaxGroup()
            {
                Name = "Preferenced",
                IsFullyExempt = false,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            };

            _context.ItemTaxGroups.Add(itemTaxGroupRegular);
            _context.ItemTaxGroups.Add(itemTaxGroupRegularPreferenced);

            vat5.TaxGroupTaxes.Add(new TaxGroupTax()
            {
                TaxGroup = taxGroupVAT,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            });

            evat12.TaxGroupTaxes.Add(new TaxGroupTax()
            {
                TaxGroup = taxGroupVAT,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            });

            exportTax1.TaxGroupTaxes.Add(new TaxGroupTax()
            {
                TaxGroup = taxGroupExport,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            });

            vat5.ItemTaxGroupTaxes.Add(new ItemTaxGroupTax()
            {
                ItemTaxGroup = itemTaxGroupRegular,
                IsExempt = false,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            });

            evat12.ItemTaxGroupTaxes.Add(new ItemTaxGroupTax()
            {
                ItemTaxGroup = itemTaxGroupRegularPreferenced,
                IsExempt = false,
                CreatedBy = "System",
                CreatedOn = DateTime.Now,
                ModifiedBy = "System",
                ModifiedOn = DateTime.Now
            });

            _context.SaveChanges();
        }
 public void AddNewTax(Tax tax)
 {
     _taxRepo.Insert(tax);
 }