refactor(workshop): remove redundant VAT rounding method

roundVatAmount duplicated default rounding logic and did not
demonstrate a distinct rounding use case.
This commit is contained in:
Marcus Fihlon 2026-04-20 00:15:42 +02:00
parent 21d835b9ca
commit e7e8662414
Signed by: McPringle
GPG key ID: C6B7F469EE363E1F
2 changed files with 4 additions and 26 deletions

View file

@ -24,18 +24,6 @@ public class RoundingStrategyExercises {
throw new UnsupportedOperationException("TODO");
}
/**
* <p>Apply explicit default rounding to a VAT amount.</p>
*
* <p>Use rounding as a separate, explicit step.</p>
*
* @param taxAmount tax amount to round
* @return rounded tax amount
*/
public MonetaryAmount roundVatAmount(MonetaryAmount taxAmount) {
throw new UnsupportedOperationException("TODO");
}
/**
* <p>Apply Swiss cash rounding to the nearest 0.05 for CHF amounts.</p>
*

View file

@ -1,11 +1,12 @@
package swiss.fihlon.workshop.money.part2;
import java.math.BigDecimal;
import javax.money.MonetaryAmount;
import javax.money.MonetaryOperator;
import org.javamoney.moneta.Money;
import org.junit.jupiter.api.Test;
import javax.money.MonetaryAmount;
import javax.money.MonetaryOperator;
import java.math.BigDecimal;
import static org.assertj.core.api.Assertions.assertThat;
class RoundingStrategyExercisesTest {
@ -23,17 +24,6 @@ class RoundingStrategyExercisesTest {
assertThat(result.getNumber().numberValueExact(BigDecimal.class)).isEqualByComparingTo("10.02");
}
@Test
void shouldRoundVatAmount() {
MonetaryAmount taxAmount = Money.of(1.537, "CHF");
MonetaryAmount result = exercises.roundVatAmount(taxAmount);
assertThat(result).isNotNull();
assertThat(result.getCurrency().getCurrencyCode()).isEqualTo("CHF");
assertThat(result.getNumber().numberValueExact(BigDecimal.class)).isEqualByComparingTo("1.54");
}
@Test
void shouldApplySwissCashRounding() {
MonetaryAmount firstAmount = Money.of(10.02, "CHF");