public final class ChangeTaxRoundingMode extends UpdateActionImpl<Cart>
CartLike.getTaxRoundingMode()
() tax rounding mode} of a cart.
See also CartInStoreUpdateCommand.
final int centAmount = 25; final double taxRate = 0.14; final boolean isTaxIncluded = false; withTaxedCartWithProduct(client(), centAmount, taxRate, isTaxIncluded, cartWithDefaultRounding -> { assertThat(cartWithDefaultRounding.getTaxRoundingMode()).isEqualTo(RoundingMode.HALF_EVEN); assertThat(extractTaxAmount(cartWithDefaultRounding)) .as("Should be rounded half to even") .isEqualTo(0.03); final CartUpdateCommand updateToHalfUp = CartUpdateCommand.of(cartWithDefaultRounding, ChangeTaxRoundingMode.of(RoundingMode.HALF_UP)); final Cart cartWithHalfUpRounding = client().executeBlocking(updateToHalfUp); assertThat(cartWithHalfUpRounding.getTaxRoundingMode()).isEqualTo(RoundingMode.HALF_UP); assertThat(extractTaxAmount(cartWithHalfUpRounding)) .as("Should be rounded half up") .isEqualTo(0.04); final CartUpdateCommand updateToHalfDown = CartUpdateCommand.of(cartWithHalfUpRounding, ChangeTaxRoundingMode.of(RoundingMode.HALF_DOWN)); final Cart cartWithHalfDownRounding = client().executeBlocking(updateToHalfDown); assertThat(cartWithHalfDownRounding.getTaxRoundingMode()).isEqualTo(RoundingMode.HALF_DOWN); assertThat(extractTaxAmount(cartWithHalfDownRounding)) .as("Should be rounded half down") .isEqualTo(0.03); return cartWithHalfDownRounding; });
See the test code.
Modifier and Type | Method and Description |
---|---|
RoundingMode |
getTaxRoundingMode() |
static ChangeTaxRoundingMode |
of(RoundingMode taxRoundingMode) |
getAction
public static ChangeTaxRoundingMode of(RoundingMode taxRoundingMode)
@Nullable public RoundingMode getTaxRoundingMode()