psdi.app.currency

Class CurrencyService

    • Constructor Detail

      • CurrencyService

        public CurrencyService()
                        throws java.rmi.RemoteException
        The currency code object.
        Throws:
        java.rmi.RemoteException
      • CurrencyService

        public CurrencyService(MXServer mxServer)
                        throws java.rmi.RemoteException
        The Server environment this service is created in.
        Parameters:
        mxServer - Mxserver
        Throws:
        java.rmi.RemoteException
    • Method Detail

      • calculateCurrencyCost

        public double calculateCurrencyCost(UserInfo userInfo,
                                            java.lang.String currencyFrom,
                                            java.lang.String currencyTo,
                                            double value,
                                            java.util.Date date,
                                            java.lang.String orgId)
                                     throws MXException,
                                            java.rmi.RemoteException
        Calculates the To currency cost given From currency code, From currency cost, To currency code and date. This is a generic method that calculates the cost equivalent of one currency to another using the exchange rate.
        Specified by:
        calculateCurrencyCost in interface CurrencyServiceRemote
        Parameters:
        userInfo - user information to instantiate a mbo set
        currencyFrom - the From currency code
        currencyTo - the To currency code
        value - value of currencyfrom to be converted
        date - the given date to find an exchange rate
        orgId - the orgId associated with the currencyTo
        Returns:
        converted currency cost
        Throws:
        MXApplicationException - (currency, InvalidCurrency) is thrown when the given From currency code is not a valid one
        MXException
        java.rmi.RemoteException
        See Also:
        Currency.getCurrencyCost(String, double, Date, String)
      • getCurrencyExchangeRate

        public double getCurrencyExchangeRate(UserInfo userInfo,
                                              java.lang.String currencyCodeFrom,
                                              java.lang.String currencyCodeTo,
                                              java.util.Date exchangeDate,
                                              java.lang.String orgId)
                                       throws MXException,
                                              java.rmi.RemoteException
        This is a generic method that returns the exchange rate for converting one currency code to another.
        The three-step method to find an exchange rate between the "From" currency and the "To" currency:
         
        First, an attempt is made to find the requested exchange rate in the EXCHANGE table.
         
        Second, if the exchange rate is not found, an attempt is made to find the inverse of the rate requested, that is, an attempt is made to find the exchange rate for the "To" currency to the "From" currency. If this is found, the inverse (1/rate) is used for the excahnge rate for the "From" currency to the "To" currency.
         
        Third, If the above fail, an attempt is made to find the exchange rates for both the "From" currency to the "Base" currency, and the "To" currency to the "Base" currency. If this succeeds, the desired exchange rate is calculated from these two rates.
         
        If all attempts fail,an exception is thrown.

        Specified by:
        getCurrencyExchangeRate in interface CurrencyServiceRemote
        Parameters:
        userInfo - user information to instantiate a mbo set
        currencyFrom - the From currency code
        currencyTo - the To currency code
        date - the given date to find an exchange rate
        orgId - organization identifier used to get base currency
        Returns:
        exchange rate
        Throws:
        MXApplicationException - (currency, GetExchangeRate) is thrown when the exchange rate cannot be found for the given currency codes
        MXException
        java.rmi.RemoteException
        See Also:
        CurrencyService.getCurrencyExchangeRate(UserInfo userInfo,String currencyFrom,String currencyTo,Date date,String orgId)