Class MConversionRate

    • Constructor Detail

      • MConversionRate

        public MConversionRate​(Properties ctx,
                               int C_Conversion_Rate_ID,
                               String trxName)
        Standard Constructor
        Parameters:
        ctx - context
        C_Conversion_Rate_ID - id
        trxName - transaction
      • MConversionRate

        public MConversionRate​(Properties ctx,
                               ResultSet rs,
                               String trxName)
        Load Constructor
        Parameters:
        ctx - context
        rs - result set
        trxName - transaction
      • MConversionRate

        public MConversionRate​(PO po,
                               int C_ConversionType_ID,
                               int C_Currency_ID,
                               int C_Currency_ID_To,
                               BigDecimal MultiplyRate,
                               Timestamp ValidFrom)
        New Constructor
        Parameters:
        po - parent
        C_ConversionType_ID - conversion type
        C_Currency_ID - currency
        C_Currency_ID_To - currency to
        MultiplyRate - multiply rate
        ValidFrom - valid from
    • Method Detail

      • convertBase

        public static BigDecimal convertBase​(Properties ctx,
                                             BigDecimal Amt,
                                             int CurFrom_ID,
                                             Timestamp ConvDate,
                                             int C_ConversionType_ID,
                                             int AD_Client_ID,
                                             int AD_Org_ID)
        Convert an amount to base Currency
        Parameters:
        ctx - context
        CurFrom_ID - The C_Currency_ID FROM
        ConvDate - conversion date - if null - use current date
        C_ConversionType_ID - conversion rate type - if 0 - use Default
        Amt - amount to be converted
        AD_Client_ID - client
        AD_Org_ID - organization
        Returns:
        converted amount
      • convert

        public static BigDecimal convert​(Properties ctx,
                                         BigDecimal Amt,
                                         int CurFrom_ID,
                                         int CurTo_ID,
                                         int AD_Client_ID,
                                         int AD_Org_ID)
        Convert an amount with today's default rate
        Parameters:
        ctx - context
        CurFrom_ID - The C_Currency_ID FROM
        CurTo_ID - The C_Currency_ID TO
        Amt - amount to be converted
        AD_Client_ID - client
        AD_Org_ID - organization
        Returns:
        converted amount
      • convert

        public static BigDecimal convert​(Properties ctx,
                                         BigDecimal Amt,
                                         int CurFrom_ID,
                                         int CurTo_ID,
                                         Timestamp ConvDate,
                                         int C_ConversionType_ID,
                                         int AD_Client_ID,
                                         int AD_Org_ID)
        Convert an amount
        Parameters:
        ctx - context
        CurFrom_ID - The C_Currency_ID FROM
        CurTo_ID - The C_Currency_ID TO
        ConvDate - conversion date - if null - use current date
        C_ConversionType_ID - conversion rate type - if 0 - use Default
        Amt - amount to be converted
        AD_Client_ID - client
        AD_Org_ID - organization
        Returns:
        converted amount or null if no rate
      • convert

        public static BigDecimal convert​(Properties ctx,
                                         BigDecimal Amt,
                                         int CurFrom_ID,
                                         int CurTo_ID,
                                         Timestamp ConvDate,
                                         int C_ConversionType_ID,
                                         int AD_Client_ID,
                                         int AD_Org_ID,
                                         boolean isCosting)
        Convert an amount
        Parameters:
        ctx - context
        Amt - amount to be converted
        CurFrom_ID - The C_Currency_ID FROM
        CurTo_ID - The C_Currency_ID TO
        ConvDate - conversion date - if null - use current date
        C_ConversionType_ID - conversion rate type - if 0 - use Default
        AD_Client_ID - client
        AD_Org_ID - organization
        isCosting - use for costing
        Returns:
        converted amount or null if no rate
      • setRate

        public static void setRate​(String CurFrom_ISO,
                                   String CurTo_ISO,
                                   Date spotDate,
                                   BigDecimal MultiplyRate)
                            throws Exception
        Sets system spot conversion rate for a single day. Checks for overlaps of spot rate is made. If an overlap is found, the overlapping rate is removed.
        Parameters:
        CurFrom_ISO - Currency from ISO code
        CurTo_ISO - Currency to ISO code
        spotDate - If null, today's date is used.
        MultiplyRate - CurFrom_ISO * MultiplyRate = amount in CurTo_ISO
        Throws:
        Exception
      • getRate

        public static BigDecimal getRate​(int CurFrom_ID,
                                         int CurTo_ID,
                                         Timestamp ConvDate,
                                         int ConversionType_ID,
                                         int AD_Client_ID,
                                         int AD_Org_ID)
        Get Currency Conversion Rate
        Parameters:
        CurFrom_ID - The C_Currency_ID FROM
        CurTo_ID - The C_Currency_ID TO
        ConvDate - The Conversion date - if null - use current date
        ConversionType_ID - Conversion rate type - if 0 - use Default
        AD_Client_ID - client
        AD_Org_ID - organization
        Returns:
        currency Rate or null
      • beforeSave

        protected boolean beforeSave​(boolean newRecord)
        Before Save. - Same Currency - Date Range Check - Set To date to 2056
        Overrides:
        beforeSave in class PO
        Parameters:
        newRecord - new
        Returns:
        true if OK to save
      • afterSave

        protected boolean afterSave​(boolean newRecord,
                                    boolean success)
        Description copied from class: PO
        Called after Save for Post-Save Operation
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - new record
        success - true if save operation was success
        Returns:
        if save was a success