Class MConversionRate

All Implemented Interfaces:
Serializable, Cloneable, Comparator<Object>, I_C_Conversion_Rate, I_Persistent, Evaluatee

public class MConversionRate extends X_C_Conversion_Rate
Currency Conversion Rate Model
Version:
$Id: MConversionRate.java,v 1.2 2006/07/30 00:58:18 jjanke Exp $
Author:
Jorg Janke
See Also:
  • Constructor Details

    • MConversionRate

      public MConversionRate(Properties ctx, String C_Conversion_Rate_UU, String trxName)
      UUID based Constructor
      Parameters:
      ctx - Context
      C_Conversion_Rate_UU - UUID key
      trxName - Transaction
    • 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
    • MConversionRate

      public MConversionRate(Properties ctx, int C_Conversion_Rate_ID, String trxName, String... virtualColumns)
      Parameters:
      ctx -
      C_Conversion_Rate_ID -
      trxName -
      virtualColumns -
  • Method Details

    • 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
    • setMultiplyRate

      public void setMultiplyRate(BigDecimal MultiplyRate)
      Set Multiply Rate. Sets also Divide Rate (calculate from multiply rate).
      Specified by:
      setMultiplyRate in interface I_C_Conversion_Rate
      Overrides:
      setMultiplyRate in class X_C_Conversion_Rate
      Parameters:
      MultiplyRate - multiply rate
    • setDivideRate

      public void setDivideRate(BigDecimal DivideRate)
      Set Divide Rate. Sets also Multiply Rate (calculate from divide rate)
      Specified by:
      setDivideRate in interface I_C_Conversion_Rate
      Overrides:
      setDivideRate in class X_C_Conversion_Rate
      Parameters:
      DivideRate - divide rate
    • toString

      public String toString()
      String Representation
      Overrides:
      toString in class X_C_Conversion_Rate
      Returns:
      info
    • 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