Tabnine Logo
CurrencyConversionApi
Code IndexAdd Tabnine to your IDE (free)

How to use
CurrencyConversionApi
in
com.ning.billing.currency.api

Best Java code snippets using com.ning.billing.currency.api.CurrencyConversionApi (Showing top 2 results out of 315)

origin: com.ning.billing/killbill-invoice

@Override
public String getProcessedPaymentRate() {
  final Currency currency = getProcessedCurrency();
  if (currency == null) {
    return null;
  }
  // If there were multiple payments (and refunds) we pick chose the last one
  DateTime latestPaymentDate = null;
  final Iterator<InvoicePayment> paymentIterator = ((DefaultInvoice) invoice).getPayments().iterator();
  while (paymentIterator.hasNext()) {
    final InvoicePayment cur = paymentIterator.next();
    latestPaymentDate = latestPaymentDate != null && latestPaymentDate.isAfter(cur.getPaymentDate()) ?
              latestPaymentDate : cur.getPaymentDate();
  }
  try {
    final CurrencyConversion conversion = currencyConversionApi.getCurrencyConversion(currency, latestPaymentDate);
    for (Rate rate : conversion.getRates()) {
      if (rate.getCurrency() == getCurrency()) {
        return rate.getValue().toString();
      }
    }
  } catch (CurrencyConversionException e) {
    logger.warn("Failed to retrieve currency conversion rates for currency = " + currency + " and date = " + latestPaymentDate, e);
    return null;
  }
  logger.warn("Failed to retrieve currency conversion rates for currency = " + currency + " and date = " + latestPaymentDate);
  return null;
}
origin: com.ning.billing/killbill-invoice

Mockito.when(currencyConversion.getRates()).thenReturn(rates);
try {
  Mockito.when(currencyConversionApi.getCurrencyConversion(Mockito.<Currency>any(), Mockito.<DateTime>any())).thenReturn(currencyConversion);
} catch (CurrencyConversionException e) {
  throw new RuntimeException(e);
com.ning.billing.currency.apiCurrencyConversionApi

Most used methods

  • getCurrencyConversion

Popular in Java

  • Start an intent from android
  • putExtra (Intent)
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JOptionPane (javax.swing)
  • Runner (org.openjdk.jmh.runner)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now