public async Task <TaxResponse> GetTax(TaxRequest taxRequest) { var taxSetupResult = await _taxRepository.GetTax(taxRequest); var taxAmount = TaxRuleFactory.GetTaxRule(taxRequest.municipalityName)?.ApplyRule(taxSetupResult); return(new TaxResponse { municipilityName = taxRequest?.municipalityName, taxRate = taxAmount, message = !taxSetupResult.Any() ? "No result found." : String.Empty }); }
public tax_rule_group GetTaxRuleGroupByRate(decimal rate) { var taxRules = TaxRuleFactory.GetByFilter(PsFilter.Create("id_country", DefaultCountry.id), null, null); foreach (var taxRule in taxRules) { if (taxRule.id_tax.HasValue && taxRule.id_tax_rules_group.HasValue) { var tax = TaxFactory.Get(taxRule.id_tax.Value); if (tax.rate == rate) { return(TaxRuleGroupFactory.Get(taxRule.id_tax_rules_group.Value)); } } } return(null); }