Package org.compiere.model
Class MConversionRate
java.lang.Object
org.compiere.model.PO
org.compiere.model.X_C_Conversion_Rate
org.compiere.model.MConversionRate
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparator<Object>
,I_C_Conversion_Rate
,I_Persistent
,Evaluatee
Currency Conversion Rate Model
- Version:
- $Id: MConversionRate.java,v 1.2 2006/07/30 00:58:18 jjanke Exp $
- Author:
- Jorg Janke
- See Also:
-
Field Summary
Fields inherited from class org.compiere.model.PO
ACCESSLEVEL_ALL, ACCESSLEVEL_CLIENT, ACCESSLEVEL_CLIENTORG, ACCESSLEVEL_ORG, ACCESSLEVEL_SYSTEM, ACCESSLEVEL_SYSTEMCLIENT, ENTITYTYPE_Dictionary, ENTITYTYPE_UserMaintained, I_ZERO, LOCAL_TRX_PREFIX, log, p_ctx, p_info, UUID_NEW_RECORD, XML_ATTRIBUTE_AD_Table_ID, XML_ATTRIBUTE_Record_ID
Fields inherited from interface org.compiere.model.I_C_Conversion_Rate
accessLevel, COLUMNNAME_AD_Client_ID, COLUMNNAME_AD_Org_ID, COLUMNNAME_C_Conversion_Rate_ID, COLUMNNAME_C_Conversion_Rate_UU, COLUMNNAME_C_ConversionType_ID, COLUMNNAME_C_Currency_ID, COLUMNNAME_C_Currency_ID_To, COLUMNNAME_Created, COLUMNNAME_CreatedBy, COLUMNNAME_DivideRate, COLUMNNAME_IsActive, COLUMNNAME_MultiplyRate, COLUMNNAME_Updated, COLUMNNAME_UpdatedBy, COLUMNNAME_ValidFrom, COLUMNNAME_ValidTo, Model, Table_ID, Table_Name
-
Constructor Summary
ConstructorDescriptionMConversionRate
(Properties ctx, int C_Conversion_Rate_ID, String trxName) Standard ConstructorMConversionRate
(Properties ctx, int C_Conversion_Rate_ID, String trxName, String... virtualColumns) MConversionRate
(Properties ctx, String C_Conversion_Rate_UU, String trxName) UUID based ConstructorMConversionRate
(Properties ctx, ResultSet rs, String trxName) Load ConstructorMConversionRate
(PO po, int C_ConversionType_ID, int C_Currency_ID, int C_Currency_ID_To, BigDecimal MultiplyRate, Timestamp ValidFrom) New Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
afterSave
(boolean newRecord, boolean success) Called after Save for Post-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.protected boolean
beforeSave
(boolean newRecord) Called before Save for Pre-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.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 ratestatic 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 amountstatic 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 amountstatic 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 Currencystatic BigDecimal
getRate
(int CurFrom_ID, int CurTo_ID, Timestamp ConvDate, int ConversionType_ID, int AD_Client_ID, int AD_Org_ID) Get Currency Conversion Ratevoid
setDivideRate
(BigDecimal DivideRate) Set Divide Rate.void
setMultiplyRate
(BigDecimal MultiplyRate) Set Multiply Rate.static void
setRate
(String CurFrom_ISO, String CurTo_ISO, Date spotDate, BigDecimal MultiplyRate) Sets system spot conversion rate for a single day.toString()
String RepresentationMethods inherited from class org.compiere.model.X_C_Conversion_Rate
get_AccessLevel, getC_Conversion_Rate_ID, getC_Conversion_Rate_UU, getC_ConversionType, getC_ConversionType_ID, getC_Currency, getC_Currency_ID, getC_Currency_ID_To, getC_Currency_To, getDivideRate, getKeyNamePair, getMultiplyRate, getValidFrom, getValidTo, initPO, setC_Conversion_Rate_ID, setC_Conversion_Rate_UU, setC_ConversionType_ID, setC_Currency_ID, setC_Currency_ID_To, setValidFrom, setValidTo
Methods inherited from class org.compiere.model.PO
afterDelete, beforeDelete, buildInsertSQL, checkImmutable, clearCrossTenantSafe, clone, columnExists, columnExists, compare, copyPO, copyValues, copyValues, createAttachment, delete, delete, delete_Accounting, delete_Tree, deleteEx, deleteEx, dump, dump, equals, get_Attribute, get_Attributes, get_ColumnCount, get_ColumnDescription, get_ColumnDisplayType, get_ColumnIndex, get_ColumnLabel, get_ColumnLookup, get_ColumnName, get_DisplayValue, get_HashMap, get_ID, get_IDOld, get_KeyColumns, get_Logger, get_OptimisticLockingColumns, get_Table_ID, get_TableName, get_Translation, get_Translation, get_Translation, get_Translation, get_Translation, get_TrxName, get_UUID, get_Value, get_Value, get_ValueAsBoolean, get_ValueAsInt, get_ValueAsInt, get_ValueAsString, get_ValueAsString, get_ValueDifference, get_ValueDifference, get_ValueE, get_ValueOfColumn, get_ValueOld, get_ValueOld, get_ValueOldAsInt, get_WhereClause, get_WhereClause, get_xmlDocument, get_xmlString, getAD_Client_ID, getAD_Org_ID, getAllIDs, getAttachment, getAttachment, getAttachmentData, getCreated, getCreatedBy, getCtx, getDoc, getFindParameter, getPdfAttachment, getUpdated, getUpdatedBy, getUUIDColumnName, getUUIDColumnName, hashCode, insert_Accounting, insert_Tree, insert_Tree, is_Changed, is_Immutable, is_new, is_UseOptimisticLocking, is_ValueChanged, is_ValueChanged, isActive, isAttachment, isColumnMandatory, isColumnUpdateable, isMandatoryOK, isPdfAttachment, isReplication, load, load, load, load, loadByUU, loadComplete, loadDefaults, loadPO, loadSpecial, lock, makeImmutable, postDelete, retrieveIdOfParentValue, retrieveIdOfParentValue, save, save, saveCrossTenantSafe, saveCrossTenantSafeEx, saveCrossTenantSafeEx, saveEx, saveEx, saveNew_afterSetID, saveNew_getID, saveNewSpecial, saveReplica, saveUpdate, set_Attribute, set_ColumnUpdateable, set_CustomColumn, set_CustomColumnReturningBoolean, set_OptimisticLockingColumns, set_TrxName, set_TrxName, set_UseOptimisticLocking, set_Value, set_Value, set_Value, set_Value, set_ValueE, set_ValueNoCheck, set_ValueNoCheckE, set_ValueOfColumn, set_ValueOfColumn, set_ValueOfColumnReturningBoolean, set_ValueOfColumnReturningBoolean, setAD_Client_ID, setAD_Org_ID, setClientOrg, setClientOrg, setCrossTenantSafe, setDoc, setDocWorkflowMgr, setIsActive, setProcessedOn, setReplication, setStandardDefaults, setUpdateable, setUpdatedBy, toInsertSQL, unlock, update_Tree, validForeignKeys
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Methods inherited from interface org.compiere.model.I_C_Conversion_Rate
getAD_Client_ID, getAD_Org_ID, getCreated, getCreatedBy, getUpdated, getUpdatedBy, isActive, setAD_Org_ID, setIsActive
Methods inherited from interface org.compiere.model.I_Persistent
save
-
Constructor Details
-
MConversionRate
UUID based Constructor- Parameters:
ctx
- ContextC_Conversion_Rate_UU
- UUID keytrxName
- Transaction
-
MConversionRate
Standard Constructor- Parameters:
ctx
- contextC_Conversion_Rate_ID
- idtrxName
- transaction
-
MConversionRate
Load Constructor- Parameters:
ctx
- contextrs
- result settrxName
- 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
- parentC_ConversionType_ID
- conversion typeC_Currency_ID
- currencyC_Currency_ID_To
- currency toMultiplyRate
- multiply rateValidFrom
- 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
- contextCurFrom_ID
- The C_Currency_ID FROMConvDate
- conversion date - if null - use current dateC_ConversionType_ID
- conversion rate type - if 0 - use DefaultAmt
- amount to be convertedAD_Client_ID
- clientAD_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
- contextCurFrom_ID
- The C_Currency_ID FROMCurTo_ID
- The C_Currency_ID TOAmt
- amount to be convertedAD_Client_ID
- clientAD_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
- contextCurFrom_ID
- The C_Currency_ID FROMCurTo_ID
- The C_Currency_ID TOConvDate
- conversion date - if null - use current dateC_ConversionType_ID
- conversion rate type - if 0 - use DefaultAmt
- amount to be convertedAD_Client_ID
- clientAD_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
- contextAmt
- amount to be convertedCurFrom_ID
- The C_Currency_ID FROMCurTo_ID
- The C_Currency_ID TOConvDate
- conversion date - if null - use current dateC_ConversionType_ID
- conversion rate type - if 0 - use DefaultAD_Client_ID
- clientAD_Org_ID
- organizationisCosting
- 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 codeCurTo_ISO
- Currency to ISO codespotDate
- 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 FROMCurTo_ID
- The C_Currency_ID TOConvDate
- The Conversion date - if null - use current dateConversionType_ID
- Conversion rate type - if 0 - use DefaultAD_Client_ID
- clientAD_Org_ID
- organization- Returns:
- currency Rate or null
-
setMultiplyRate
Set Multiply Rate. Sets also Divide Rate (calculate from multiply rate).- Specified by:
setMultiplyRate
in interfaceI_C_Conversion_Rate
- Overrides:
setMultiplyRate
in classX_C_Conversion_Rate
- Parameters:
MultiplyRate
- multiply rate
-
setDivideRate
Set Divide Rate. Sets also Multiply Rate (calculate from divide rate)- Specified by:
setDivideRate
in interfaceI_C_Conversion_Rate
- Overrides:
setDivideRate
in classX_C_Conversion_Rate
- Parameters:
DivideRate
- divide rate
-
toString
String Representation- Overrides:
toString
in classX_C_Conversion_Rate
- Returns:
- info
-
beforeSave
protected boolean beforeSave(boolean newRecord) Description copied from class:PO
Called before Save for Pre-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.- Overrides:
beforeSave
in classPO
- Parameters:
newRecord
- true if it is a new record- Returns:
- true if record can be saved
-
afterSave
protected boolean afterSave(boolean newRecord, boolean success) Description copied from class:PO
Called after Save for Post-Save Operation.
Default implementation is nop, to be implemented in sub-classes that needed it.
-