@Test public void calculateDeliveryTaxes() throws Exception { Double orderTaxes = 12D; BigDecimal itemTaxes = BigDecimal.TEN; String deliveryTaxes = "2.00"; CurrencyModel currency = new CurrencyModel(); currency.setIsocode(CURRENCY_EUR); AbstractOrderModel order = new OrderModel(); order.setCurrency(currency); order.setTotalTax(orderTaxes); OrderItem orderItem = new OrderItem(); wirecardAbsoluteTaxCalculatorStrategy.calculateDeliveryTaxes(order, orderItem, itemTaxes); assertNotNull("Tax amount should not be null", orderItem.getTaxAmount()); assertEquals("Currency does not match", CURRENCY_EUR, orderItem.getTaxAmount().getCurrency()); assertEquals("Delivery taxes amount does not match", deliveryTaxes, orderItem.getTaxAmount().getValue().toString()); }
public void calculateDeliveryTaxes(final AbstractOrderModel abstractOrderModel, final OrderItem orderItem, BigDecimal totalItemTaxes) { Money taxAmount = new Money(); taxAmount.setValue(BigDecimal.valueOf(abstractOrderModel.getTotalTax()) .subtract(totalItemTaxes) .setScale(DECIMAL_DIGITS_MAX, RoundingMode.HALF_EVEN)); taxAmount.setCurrency(abstractOrderModel.getCurrency().getIsocode()); orderItem.setTaxAmount(taxAmount); }
WirecardAbsoluteTaxCalculatorStrategy implements WirecardTaxCalculatorStrategy { public void calculateDeliveryTaxes(final AbstractOrderModel abstractOrderModel, final OrderItem orderItem, BigDecimal totalItemTaxes) { Money taxAmount = new Money(); taxAmount.setValue(BigDecimal.valueOf(abstractOrderModel.getTotalTax()) .subtract(totalItemTaxes) .setScale(DECIMAL_DIGITS_MAX, RoundingMode.HALF_EVEN)); taxAmount.setCurrency(abstractOrderModel.getCurrency().getIsocode()); orderItem.setTaxAmount(taxAmount); } }
WirecardAbsoluteTaxCalculatorStrategy implements WirecardTaxCalculatorStrategy { public void calculateDeliveryTaxes(final AbstractOrderModel abstractOrderModel, final OrderItem orderItem, BigDecimal totalItemTaxes) { Money taxAmount = new Money(); taxAmount.setValue(BigDecimal.valueOf(abstractOrderModel.getTotalTax()) .subtract(totalItemTaxes) .setScale(DECIMAL_DIGITS_MAX, RoundingMode.HALF_EVEN)); taxAmount.setCurrency(abstractOrderModel.getCurrency().getIsocode()); orderItem.setTaxAmount(taxAmount); }  }
WirecardAbsoluteTaxCalculatorStrategy implements WirecardTaxCalculatorStrategy { public void calculateDeliveryTaxes(final AbstractOrderModel abstractOrderModel, final OrderItem orderItem, BigDecimal totalItemTaxes) { Money taxAmount = new Money(); taxAmount.setValue(BigDecimal.valueOf(abstractOrderModel.getTotalTax()) .subtract(totalItemTaxes) .setScale(DECIMAL_DIGITS_MAX, RoundingMode.HALF_EVEN)); taxAmount.setCurrency(abstractOrderModel.getCurrency().getIsocode()); orderItem.setTaxAmount(taxAmount); }  BigDecimal calculateItemTaxes(final AbstractOrderEntryModel entry, final OrderItem orderItem, BigDecimal totalItemTaxes); void calculateDeliveryTaxes(final AbstractOrderModel abstractOrderModel,
                                       final OrderItem orderItem,
                                       BigDecimal totalItemTaxes); }
WirecardAbsoluteTaxCalculatorStrategy implements WirecardTaxCalculatorStrategy { public void calculateDeliveryTaxes(final AbstractOrderModel abstractOrderModel, final OrderItem orderItem, BigDecimal totalItemTaxes) { Money taxAmount = new Money(); taxAmount.setValue(BigDecimal.valueOf(abstractOrderModel.getTotalTax()) .subtract(totalItemTaxes) .setScale(DECIMAL_DIGITS_MAX, RoundingMode.HALF_EVEN)); taxAmount.setCurrency(abstractOrderModel.getCurrency().getIsocode()); orderItem.setTaxAmount(taxAmount); }  BigDecimal calculateItemTaxes(final AbstractOrderEntryModel entry, final OrderItem orderItem, BigDecimal totalItemTaxes); void calculateDeliveryTaxes(final AbstractOrderModel abstractOrderModel,
                                       final OrderItem orderItem,
                                       BigDecimal totalItemTaxes);  }