Exemplo n.º 1
0
  private BigDecimal transferAmount(Account account1, Account account2, BigDecimal amount1) {
    if (account1.getCurrency().equals(account2.getCurrency())) return amount1;

    BigDecimal rate1 = currencyRates.get(account1.getCurrencyCode());
    BigDecimal rate2 = currencyRates.get(account2.getCurrencyCode());
    return amount1.multiply(rate1).divide(rate2, 0, RoundingMode.HALF_UP);
  }
Exemplo n.º 2
0
 public SampleDataGenerator() {
   currencyRates.put("rub", BigDecimal.ONE);
   currencyRates.put("usd", new BigDecimal("30"));
   currencyRates.put("eur", new BigDecimal("40"));
 }