public final class AddTaxRate extends UpdateActionImpl<TaxCategory>
See also TaxCategoryUpdateCommand.
withUpdateableTaxCategory(client(), taxCategory -> {
//add tax rate
final String name = "ag7";
final CountryCode countryCode = CountryCode.AG;
final TaxRateDraft de7 = TaxRateDraftBuilder.of(name, 0.07, true, countryCode).build();
final TaxCategory taxCategoryWithTaRate = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategory, AddTaxRate.of(de7)));
final TaxRate actual = taxCategoryWithTaRate.getTaxRates().stream().filter(rate -> name.equals(rate.getName())).findFirst().get();
assertThat(actual.getCountry()).isEqualTo(countryCode);
assertThat(actual.getAmount()).isEqualTo(0.07);
assertThat(actual.getId())
.overridingErrorMessage("the tax rate fetched from API has an id")
.isNotNull();
assertThat(actual.getName()).isEqualTo(de7.getName());
//remove tax rate
final TaxCategory updatedTaxCategory = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategoryWithTaRate, RemoveTaxRate.of(actual.getId())));
assertThat(updatedTaxCategory.getTaxRates()).matches(rates -> !rates.stream().anyMatch(rate -> name.equals(rate.getName())));
return updatedTaxCategory;
});
See the test code.
TaxCategory.getTaxRates()
,
RemoveTaxRate
,
ReplaceTaxRate
Modifier and Type | Method and Description |
---|---|
TaxRateDraft |
getTaxRate() |
static AddTaxRate |
of(TaxRateDraft taxRate) |
getAction
public static AddTaxRate of(TaxRateDraft taxRate)
public TaxRateDraft getTaxRate()