public IActionResult ItemTaxGroups() { var itemTaxGroupsDto = new List <ItemTaxGroup>(); var itemTaxGroups = _taxService.GetItemTaxGroups(); foreach (var group in itemTaxGroups) { var groupDto = new ItemTaxGroup() { Id = group.Id, Name = group.Name, IsFullyExempt = group.IsFullyExempt }; itemTaxGroupsDto.Add(groupDto); } return(new ObjectResult(itemTaxGroupsDto)); }
public static void InitTax() { // NOTE: each tax should have its own tax account. var salesTaxAccount = _context.Accounts.Where(a => a.AccountCode == "20300").FirstOrDefault(); var purchaseTaxAccount = _context.Accounts.Where(a => a.AccountCode == "50700").FirstOrDefault(); var vat5 = new Tax() { TaxCode = "VAT5%", TaxName = "VAT 5%", Rate = 5, IsActive = true, SalesAccountId = salesTaxAccount.Id, PurchasingAccountId = purchaseTaxAccount.Id, }; var vat10 = new Tax() { TaxCode = "VAT10%", TaxName = "VAT 10%", Rate = 10, IsActive = true, SalesAccountId = salesTaxAccount.Id, PurchasingAccountId = purchaseTaxAccount.Id, }; var evat12 = new Tax() { TaxCode = "VAT12%", TaxName = "VAT 12%", Rate = 12, IsActive = true, SalesAccountId = salesTaxAccount.Id, PurchasingAccountId = purchaseTaxAccount.Id, }; var exportTax1 = new Tax() { TaxCode = "exportTax1%", TaxName = "Export Tax 1%", Rate = 1, IsActive = true, SalesAccountId = salesTaxAccount.Id, PurchasingAccountId = purchaseTaxAccount.Id, }; _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, }; var taxGroupExport = new TaxGroup() { Description = "Export", TaxAppliedToShipping = false, IsActive = true, }; _context.TaxGroups.Add(taxGroupVAT); _context.TaxGroups.Add(taxGroupExport); var itemTaxGroupRegular = new ItemTaxGroup() { Name = "Regular", IsFullyExempt = false, }; var itemTaxGroupRegularPreferenced = new ItemTaxGroup() { Name = "Preferenced", IsFullyExempt = false, }; _context.ItemTaxGroups.Add(itemTaxGroupRegular); _context.ItemTaxGroups.Add(itemTaxGroupRegularPreferenced); vat5.TaxGroupTaxes.Add(new TaxGroupTax() { TaxGroup = taxGroupVAT, }); evat12.TaxGroupTaxes.Add(new TaxGroupTax() { TaxGroup = taxGroupVAT, }); exportTax1.TaxGroupTaxes.Add(new TaxGroupTax() { TaxGroup = taxGroupExport, }); vat5.ItemTaxGroupTaxes.Add(new ItemTaxGroupTax() { ItemTaxGroup = itemTaxGroupRegularPreferenced, IsExempt = false, }); evat12.ItemTaxGroupTaxes.Add(new ItemTaxGroupTax() { ItemTaxGroup = itemTaxGroupRegular, IsExempt = false, }); _context.SaveChanges(); }
public static void InitTax() { // NOTE: each tax should have its own tax account. var salesTaxAccount = _context.Accounts.Where(a => a.AccountCode == "20300").FirstOrDefault(); var purchaseTaxAccount = _context.Accounts.Where(a => a.AccountCode == "50700").FirstOrDefault(); var vat5 = new Tax() { TaxCode = "VAT5%", TaxName = "VAT 5%", Rate = 5, IsActive = true, SalesAccountId = salesTaxAccount.Id, PurchasingAccountId = purchaseTaxAccount.Id, }; var vat10 = new Tax() { TaxCode = "VAT10%", TaxName = "VAT 10%", Rate = 10, IsActive = true, SalesAccountId = salesTaxAccount.Id, PurchasingAccountId = purchaseTaxAccount.Id, }; var evat12 = new Tax() { TaxCode = "VAT12%", TaxName = "VAT 12%", Rate = 12, IsActive = true, SalesAccountId = salesTaxAccount.Id, PurchasingAccountId = purchaseTaxAccount.Id, }; var exportTax1 = new Tax() { TaxCode = "exportTax1%", TaxName = "Export Tax 1%", Rate = 1, IsActive = true, SalesAccountId = salesTaxAccount.Id, PurchasingAccountId = purchaseTaxAccount.Id, }; _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, }; var taxGroupExport = new TaxGroup() { Description = "Export", TaxAppliedToShipping = false, IsActive = true, }; _context.TaxGroups.Add(taxGroupVAT); _context.TaxGroups.Add(taxGroupExport); var itemTaxGroupRegular = new ItemTaxGroup() { Name = "Regular", IsFullyExempt = false, }; var itemTaxGroupRegularPreferenced = new ItemTaxGroup() { Name = "Preferenced", IsFullyExempt = false, }; _context.ItemTaxGroups.Add(itemTaxGroupRegular); _context.ItemTaxGroups.Add(itemTaxGroupRegularPreferenced); vat5.TaxGroupTaxes.Add(new TaxGroupTax() { TaxGroup = taxGroupVAT, }); evat12.TaxGroupTaxes.Add(new TaxGroupTax() { TaxGroup = taxGroupVAT, }); exportTax1.TaxGroupTaxes.Add(new TaxGroupTax() { TaxGroup = taxGroupExport, }); vat5.ItemTaxGroupTaxes.Add(new ItemTaxGroupTax() { ItemTaxGroup = itemTaxGroupRegular, IsExempt = false, }); evat12.ItemTaxGroupTaxes.Add(new ItemTaxGroupTax() { ItemTaxGroup = itemTaxGroupRegularPreferenced, IsExempt = false, }); _context.SaveChanges(); }
private 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 IActionResult Taxes() { var taxes = _taxService.GetTaxes(true); var taxSystemDto = new TaxSystemDto(); var taxesDto = new List <Tax>(); foreach (var tax in taxes) { taxesDto.Add(new Tax() { Id = tax.Id, TaxCode = tax.TaxCode, TaxName = tax.TaxName, Rate = tax.Rate, IsActive = tax.IsActive }); } taxSystemDto.Taxes = taxesDto; var taxGroupsDto = new List <TaxGroup>(); var taxGroups = _taxService.GetTaxGroups(); foreach (var group in taxGroups) { var groupDto = new TaxGroup() { Id = group.Id, Description = group.Description, IsActive = group.IsActive, TaxAppliedToShipping = group.TaxAppliedToShipping }; foreach (var tax in group.TaxGroupTax) { var taxDto = new TaxGroupTax() { Id = tax.Id, TaxId = tax.TaxId, TaxGroupId = tax.TaxGroupId }; groupDto.Taxes.Add(taxDto); } taxGroupsDto.Add(groupDto); } taxSystemDto.TaxGroups = taxGroupsDto; var itemTaxGroupsDto = new List <ItemTaxGroup>(); var itemTaxGroups = _taxService.GetItemTaxGroups(); foreach (var group in itemTaxGroups) { var groupDto = new ItemTaxGroup() { Id = group.Id, Name = group.Name, IsFullyExempt = group.IsFullyExempt }; foreach (var tax in group.ItemTaxGroupTax) { var taxDto = new ItemTaxGroupTax() { Id = tax.Id, TaxId = tax.TaxId, ItemTaxGroupId = tax.ItemTaxGroupId }; groupDto.Taxes.Add(taxDto); } itemTaxGroupsDto.Add(groupDto); } taxSystemDto.ItemTaxGroups = itemTaxGroupsDto; return(new ObjectResult(taxSystemDto)); }