public TaxService AddTaxService(decimal percent) { var queryService = _oAuthService.GetQueryService <TaxAgency>(); var taxAgency = queryService.Where(x => x != null).FirstOrDefault(); if (taxAgency == null) { var dataService = _oAuthService.GetDataService(); taxAgency = dataService.Add(new TaxAgency { DisplayName = "New Tax Agency" }); } var name = $"{percent} percent tax"; var taxRateDetailses = new[] { new TaxRateDetails { RateValue = percent, RateValueSpecified = true, TaxAgencyId = taxAgency.Id, TaxApplicableOn = TaxRateApplicableOnEnum.Sales, TaxRateName = name } }; var taxService = new TaxService { TaxCode = name, TaxRateDetails = taxRateDetailses }; var globalTaxService = _oAuthService.GetGlobalTaxService(); taxService = globalTaxService.AddTaxCode(taxService); return(taxService); }