code: @Override
      public CurrencyAmount getPaymentAmountForBuying(final CurrencyAmount amountToBuy) {
          boolean inverse = amountToBuy.getCurrency().equals(currencyPair.getCcy2());
          final String targetCcy = inverse ? currencyPair.getCcy1() : currencyPair.getCcy2();
  
          int decPlace = DEC_PLACE_FOR_MONEY;
  
          try {
              decPlace = Currency.getInstance(targetCcy).getDefaultFractionDigits();
          } catch (IllegalArgumentException iae) {
              // do nothing
          }
  
          return inverse ? new Cash(targetCcy, setScale(
                  BigDecimalUtil.divide(PRECISION_FOR_INVERSE, amountToBuy.getAmount(), bid, BigDecimal.ROUND_HALF_UP), decPlace)) : new Cash(
                  targetCcy, setScale(amountToBuy.getAmount().multiply(ask), decPlace));
      }
docs: Calculates the amount to pay given an amount to buy, e.g. how much should you pay in Y if you are buying n X?
  More explicitly, how many EURos should you pay to buy 1,000 USD?
  Given EUR/USD rate, this would be 1,000 / bid.
  @param amountToBuy amount you want to buy.
  @return amount you have to pay in the other ccy.