/** * Calculates the net price of the given amount according to its tax rate. * Whether the provided amount is already net or gross is determined by the tax rate. * @param amount the monetary amount * @param taxRate the tax rate corresponding to the {@code amount} * @return the net monetary amount */ public static MonetaryAmount calculateNetPrice(final MonetaryAmount amount, final TaxRate taxRate) { return taxRate.isIncludedInPrice() ? convertGrossToNetPrice(amount, taxRate.getAmount()) : amount; }
/** * Calculates the gross price of the given amount according to its tax rate. * Whether the provided amount is already gross or net is determined by the tax rate. * @param amount the monetary amount * @param taxRate the tax rate corresponding to the {@code amount} * @return the gross monetary amount */ public static MonetaryAmount calculateGrossPrice(final MonetaryAmount amount, final TaxRate taxRate) { return taxRate.isIncludedInPrice() ? amount : convertNetToGrossPrice(amount, taxRate.getAmount()); }
/** * Calculates the gross price of the given amount according to its tax rate. * Whether the provided amount is already gross or net is determined by the tax rate. * @param amount the monetary amount * @param taxRate the tax rate corresponding to the {@code amount} * @return the gross monetary amount */ public static MonetaryAmount calculateGrossPrice(final MonetaryAmount amount, final TaxRate taxRate) { return taxRate.isIncludedInPrice() ? amount : convertNetToGrossPrice(amount, taxRate.getAmount()); }
/** * Calculates the net price of the given amount according to its tax rate. * Whether the provided amount is already net or gross is determined by the tax rate. * @param amount the monetary amount * @param taxRate the tax rate corresponding to the {@code amount} * @return the net monetary amount */ public static MonetaryAmount calculateNetPrice(final MonetaryAmount amount, final TaxRate taxRate) { return taxRate.isIncludedInPrice() ? convertGrossToNetPrice(amount, taxRate.getAmount()) : amount; }
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()); }
public static TaxRateDraftBuilder of(final TaxRate taxRate) { return of(taxRate.getName(), taxRate.getAmount(), taxRate.isIncludedInPrice(), taxRate.getCountry()) .state(taxRate.getState()) .subRates(taxRate.getSubRates()); }
assertThat(lineItem.getVariant().getAttribute("foo").getValue(AttributeAccess.ofString())).isEqualTo("bar"); 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(taxRate.getName()).isEqualTo(taxRateName); assertThat(taxRate.getAmount()).isEqualTo(0.2); assertThat(taxRate.isIncludedInPrice()).isFalse(); assertThat(lineItem.getTotalPrice()).isEqualTo(MoneyImpl.ofCents(3000, "EUR")); assertThat(lineItem.getTaxedPrice().getTotalNet()).isEqualTo(MoneyImpl.ofCents(3000, "EUR"));
@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; }); }); }