public static TaxRateDraftBuilder of(final TaxRate taxRate) { return of(taxRate.getName(), taxRate.getAmount(), taxRate.isIncludedInPrice(), taxRate.getCountry()) .state(taxRate.getState()) .subRates(taxRate.getSubRates()); }
public static TaxRateBuilder of(final TaxRate taxRate) { return of(taxRate.getName(), taxRate.getAmount(), taxRate.isIncludedInPrice(), taxRate.getCountry()) .id(taxRate.getId()) .state(taxRate.getState()); }
public static TaxRateDraftBuilder of(final TaxRate taxRate) { return of(taxRate.getName(), taxRate.getAmount(), taxRate.isIncludedInPrice(), taxRate.getCountry()) .state(taxRate.getState()) .subRates(taxRate.getSubRates()); }
@Test public void replaceTaxRate() { withUpdateableTaxCategory(client(), taxCategory -> { final TaxRate old = taxCategory.getTaxRates().get(0); final double newAmount = old.getAmount() * 2; final TaxRateDraft newTaxRate = TaxRateDraftBuilder.of(old).amount(newAmount).build(); final TaxCategory updatedTaxCategory = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategory, ReplaceTaxRate.of(old.getId(), newTaxRate))); final TaxRate actual = updatedTaxCategory.getTaxRates().get(0); assertThat(actual.getCountry()).isEqualTo(old.getCountry()); assertThat(actual.getAmount()).isEqualTo(newAmount); assertThat(actual.getName()).isEqualTo(old.getName()); return updatedTaxCategory; }); } }
@Test public void addTaxRate() { 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; }); }
assertThat(lineItem.getTaxRate().getName()).isEqualTo("default-tax"); assertThat(lineItem.getTaxRate().isIncludedInPrice()).isTrue(); assertThat(lineItem.getTaxRate().getCountry()).isEqualTo(CountryCode.DE); final CustomLineItem customLineItem = order.getCustomLineItems().get(0); assertThat(customLineItem.getName().get(ENGLISH)).isEqualTo("a custom line item");
final TaxRate taxRate = lineItem.getTaxRate(); assertThat(taxRate.getSubRates()).isEqualTo(subRates); assertThat(taxRate.getCountry()).isEqualTo(DE); assertThat(taxRate.getId()).isNull(); assertThat(taxRate.getName()).isEqualTo(taxRateName);
s.assertThat(taxRate.getName()).isEqualTo(taxRateName); s.assertThat(taxRate.getAmount()).isEqualTo(rate); s.assertThat(taxRate.getCountry()).isEqualTo(DE); s.assertThat(taxRate.getId()).as("tax rate id").isNull(); s.assertThat(taxRate.getSubRates()).as("sub rates").isEmpty();
@Test public void shippingMethodQuery() throws Exception { withShippingMethodForGermany(client(), shippingMethod -> { withCart(client(), createCartWithShippingAddress(client()), cart -> { final CartUpdateCommand updateCommand = CartUpdateCommand.of(cart, SetShippingMethod.of(shippingMethod)) .plusExpansionPaths(m -> m.shippingInfo().shippingMethod().taxCategory()) .plusExpansionPaths(m -> m.shippingInfo().taxCategory()); final Cart cartWithShippingMethod = client().executeBlocking(updateCommand); final CartShippingInfo shippingInfo = cartWithShippingMethod.getShippingInfo(); final CartQuery query = CartQuery.of() .plusPredicates(m -> m.id().is(cart.getId())) .plusPredicates(m -> m.shippingInfo().shippingMethodName().is(shippingMethod.getName())) .plusPredicates(m -> m.shippingInfo().price().centAmount().is(MoneyImpl.centAmountOf(shippingInfo.getPrice()))) .plusPredicates(m -> m.shippingInfo().taxRate().name().is(shippingInfo.getTaxRate().getName())) .plusPredicates(m -> m.shippingInfo().taxRate().includedInPrice().is(shippingInfo.getTaxRate().isIncludedInPrice())) .plusPredicates(m -> m.shippingInfo().taxRate().country().is(shippingInfo.getTaxRate().getCountry())) .plusPredicates(m -> m.shippingInfo().shippingMethod().is(shippingMethod)) .plusPredicates(m -> m.shippingInfo().discountedPrice().isNotPresent()); assertThat(client().executeBlocking(query).head().get()).isEqualTo(cartWithShippingMethod); return cartWithShippingMethod; }); }); }