Compiere 3.1

org.compiere.model
Class MUOMConversion

java.lang.Object
  extended by org.compiere.framework.PO
      extended by org.compiere.model.X_C_UOM_Conversion
          extended by org.compiere.model.MUOMConversion
All Implemented Interfaces:
Serializable, Cloneable, Comparator<PO>, Evaluatee

public class MUOMConversion
extends X_C_UOM_Conversion

Unit of Measure Conversion Model

Version:
$Id: MUOMConversion.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
Author:
Jorg Janke
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.compiere.model.X_C_UOM_Conversion
accessLevel, C_UOM_ID_AD_Reference_ID, C_UOM_TO_ID_AD_Reference_ID, Model, Table_ID, Table_Name, updatedMS
 
Fields inherited from class org.compiere.framework.PO
ACCESSLEVEL_ALL, ACCESSLEVEL_CLIENT, ACCESSLEVEL_CLIENTORG, ACCESSLEVEL_ORG, ACCESSLEVEL_SYSTEM, ACCESSLEVEL_SYSTEMCLIENT, ENTITYTYPE_Dictionary, ENTITYTYPE_UserMaintained, I_ZERO, log, p_changeVO, p_info, XML_ATTRIBUTE_AD_Table_ID, XML_ATTRIBUTE_Record_ID
 
Constructor Summary
MUOMConversion(Ctx ctx, int C_UOM_Conversion_ID, String trxName)
          Default Constructor
MUOMConversion(Ctx ctx, ResultSet rs, String trxName)
          Load Constructor
MUOMConversion(MProduct parent)
          Parent Constructor
MUOMConversion(MUOM parent)
          Parent Constructor
 
Method Summary
protected  boolean beforeSave(boolean newRecord)
          Before Save
static BigDecimal convert(Ctx ctx, int C_UOM_ID, int C_UOM_To_ID, BigDecimal qty)
          Convert qty to target UOM and round.
static BigDecimal convert(int C_UOM_From_ID, int C_UOM_To_ID, BigDecimal qty, boolean StdPrecision)
          Get Converted Qty from Server (no cache)
static BigDecimal convertProductFrom(Ctx ctx, int M_Product_ID, int C_UOM_To_ID, BigDecimal qtyPrice)
          Convert Qty/Amt FROM product UOM to entered UOM and round.
static BigDecimal convertProductTo(Ctx ctx, int M_Product_ID, int C_UOM_To_ID, BigDecimal qtyPrice)
          Convert Qty/Amt from entered UOM TO product UoM and round.
static int convertToMinutes(Ctx ctx, int C_UOM_ID, BigDecimal qty)
          Convert qty to target UOM and round.
static BigDecimal deriveRate(Ctx ctx, int C_UOM_ID, int C_UOM_To_ID)
          Derive Standard Conversions
static Timestamp getEndDate(Ctx ctx, Timestamp startDate, int C_UOM_ID, BigDecimal qty)
          Calculate End Date based on start date and qty
static MUOMConversion[] getProductConversions(Ctx ctx, int M_Product_ID, boolean requery)
          Get Product Conversions (cached)
static BigDecimal getProductRateFrom(Ctx ctx, int M_Product_ID, int C_UOM_To_ID)
          Get Divide Rate FROM product UOM to entered UOM and round.
static BigDecimal getProductRateTo(Ctx ctx, int M_Product_ID, int C_UOM_To_ID)
          Get Multiplier Rate from entered UOM TO product UoM
static BigDecimal getRate(Ctx ctx, int C_UOM_ID, int C_UOM_To_ID)
          Get Multiplier Rate to target UOM
static BigDecimal getRate(int C_UOM_ID, int C_UOM_To_ID)
          Get Conversion Multiplier Rate from Server
 void setDivideRate(BigDecimal DivideRate)
          Set Divide Rate.
 void setDivideRate(String DivideRateOld, String DivideRateNew, int WindowNo)
          Callout
 void setMultiplyRate(BigDecimal MultiplyRate)
          Set Multiply Rate Sets also Divide Rate
 void setMultiplyRate(String MultiplyRateOld, String MultiplyRateNew, int windowNo)
          Callout
 String toString()
          String Representation
 
Methods inherited from class org.compiere.model.X_C_UOM_Conversion
get_AccessLevel, getC_UOM_Conversion_ID, getC_UOM_ID, getC_UOM_To_ID, getDivideRate, getKeyNamePair, getM_Product_ID, getMultiplyRate, initPO, setC_UOM_Conversion_ID, setC_UOM_ID, setC_UOM_To_ID, setM_Product_ID
 
Methods inherited from class org.compiere.framework.PO
addAttachment, addAttachment, addError, afterDelete, afterSave, beforeDelete, compare, convertToBigDecimal, convertToBoolean, convertToInt, convertToTimestamp, copy, copyValues, copyValues, createAttachment, delete_Accounting, delete, delete, dump, dump, equals, get_ChangeVO, get_ColumnCount, get_ColumnDescription, get_ColumnDisplayType, get_ColumnIndex, get_ColumnLabel, get_ColumnLookup, get_ColumnName, get_DisplayValue, get_EntityType, get_HashMap, get_ID, get_IDOld, get_Info, get_KeyColumns, get_Logger, get_Table_ID, get_Table_ID, get_TableName, get_Translation, get_TrxName, get_Value, get_Value, get_ValueAsInt, get_ValueAsInt, get_ValueAsString, get_ValueDifference, get_ValueDifference, get_ValueOfColumn, get_ValueOld, get_ValueOld, get_ValueOldAsInt, get_ValuesAsString, get_WhereClause, get_xmlDocument, get_xmlString, get_xmlString, getAD_Client_ID, getAD_Org_ID, getAllIDs, getAttachment, getAttachment, getAttachmentData, getCreated, getCreatedBy, getCtx, getFindParameter, getPdfAttachment, getUpdated, getUpdatedBy, getVO, hashCode, insert_Accounting, is_Changed, is_KeyColumn, is_new, is_ValueChanged, is_ValueChanged, isActive, isAttachment, isColumnMandatory, isColumnUpdateable, isMandatoryOK, isPdfAttachment, load, load, load, load, loadComplete, loadDefaults, loadSpecial, lock, save, save, saveNew_getID, saveNewInsertSQL, saveNewSpecial, saveUpdate, set_ChangeVO, set_ColumnUpdateable, set_CustomColumn, set_TrxName, set_Value, set_Value, set_ValueE, set_ValueNoCheck, set_ValueNoCheckE, set_ValueOfColumn, set_ValueString, setAD_Client_ID, setAD_Org_ID, setClientOrg, setClientOrg, setContext, setCtx, setDocWorkflowMgr, setIsActive, setStandardDefaults, setUpdateable, setUpdatedBy, toStringX, unlock, update
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MUOMConversion

public MUOMConversion(Ctx ctx,
                      int C_UOM_Conversion_ID,
                      String trxName)
Default Constructor

Parameters:
ctx - context
C_UOM_Conversion_ID - id
trxName - transaction

MUOMConversion

public MUOMConversion(Ctx ctx,
                      ResultSet rs,
                      String trxName)
Load Constructor

Parameters:
ctx - context
rs - result set
trxName - transaction

MUOMConversion

public MUOMConversion(MUOM parent)
Parent Constructor

Parameters:
parent - uom parent

MUOMConversion

public MUOMConversion(MProduct parent)
Parent Constructor

Parameters:
parent - product parent
Method Detail

convert

public static BigDecimal convert(Ctx ctx,
                                 int C_UOM_ID,
                                 int C_UOM_To_ID,
                                 BigDecimal qty)
Convert qty to target UOM and round.

Parameters:
ctx - context
C_UOM_ID - from UOM
C_UOM_To_ID - to UOM
qty - qty
Returns:
converted qty (std precision)

getRate

public static BigDecimal getRate(Ctx ctx,
                                 int C_UOM_ID,
                                 int C_UOM_To_ID)
Get Multiplier Rate to target UOM

Parameters:
ctx - context
C_UOM_ID - from UOM
C_UOM_To_ID - to UOM
Returns:
multiplier

convertToMinutes

public static int convertToMinutes(Ctx ctx,
                                   int C_UOM_ID,
                                   BigDecimal qty)
Convert qty to target UOM and round.

Parameters:
ctx - context
C_UOM_ID - from UOM
qty - qty
Returns:
minutes - 0 if not found

getEndDate

public static Timestamp getEndDate(Ctx ctx,
                                   Timestamp startDate,
                                   int C_UOM_ID,
                                   BigDecimal qty)
Calculate End Date based on start date and qty

Parameters:
ctx - context
startDate - date
C_UOM_ID - UOM
qty - qty
Returns:
end date

deriveRate

public static BigDecimal deriveRate(Ctx ctx,
                                    int C_UOM_ID,
                                    int C_UOM_To_ID)
Derive Standard Conversions

Parameters:
ctx - context
C_UOM_ID - from UOM
C_UOM_To_ID - to UOM
Returns:
Conversion or null

getRate

public static BigDecimal getRate(int C_UOM_ID,
                                 int C_UOM_To_ID)
Get Conversion Multiplier Rate from Server

Parameters:
C_UOM_ID - from UOM
C_UOM_To_ID - to UOM
Returns:
conversion multiplier or null

convert

public static BigDecimal convert(int C_UOM_From_ID,
                                 int C_UOM_To_ID,
                                 BigDecimal qty,
                                 boolean StdPrecision)
Get Converted Qty from Server (no cache)

Parameters:
qty - The quantity to be converted
C_UOM_From_ID - The C_UOM_ID of the qty
C_UOM_To_ID - The targeted UOM
StdPrecision - if true, standard precision, if false costing precision
Returns:
amount

convertProductTo

public static BigDecimal convertProductTo(Ctx ctx,
                                          int M_Product_ID,
                                          int C_UOM_To_ID,
                                          BigDecimal qtyPrice)
Convert Qty/Amt from entered UOM TO product UoM and round.

Parameters:
ctx - context
M_Product_ID - product
C_UOM_To_ID - entered UOM
qtyPrice - entered quantity or price
Returns:
Product: Qty/Amt in product UoM (precision rounded)

getProductRateTo

public static BigDecimal getProductRateTo(Ctx ctx,
                                          int M_Product_ID,
                                          int C_UOM_To_ID)
Get Multiplier Rate from entered UOM TO product UoM

Parameters:
ctx - context
M_Product_ID - product
C_UOM_To_ID - entered UOM
Returns:
multiplier or null

convertProductFrom

public static BigDecimal convertProductFrom(Ctx ctx,
                                            int M_Product_ID,
                                            int C_UOM_To_ID,
                                            BigDecimal qtyPrice)
Convert Qty/Amt FROM product UOM to entered UOM and round.

Parameters:
ctx - context
M_Product_ID - product
C_UOM_To_ID - entered UOM
qtyPrice - quantity or price
Returns:
Entered: Qty in entered UoM (precision rounded)

getProductRateFrom

public static BigDecimal getProductRateFrom(Ctx ctx,
                                            int M_Product_ID,
                                            int C_UOM_To_ID)
Get Divide Rate FROM product UOM to entered UOM and round.

Parameters:
ctx - context
M_Product_ID - product
C_UOM_To_ID - entered UOM
Returns:
divisor or null

getProductConversions

public static MUOMConversion[] getProductConversions(Ctx ctx,
                                                     int M_Product_ID,
                                                     boolean requery)
Get Product Conversions (cached)

Parameters:
ctx - context
M_Product_ID - product
requery - get new results
Returns:
array of conversions

beforeSave

protected boolean beforeSave(boolean newRecord)
Before Save

Overrides:
beforeSave in class PO
Parameters:
newRecord - new
Returns:
true if can be saved

toString

public String toString()
String Representation

Overrides:
toString in class X_C_UOM_Conversion
Returns:
info

setMultiplyRate

@UICallout
public void setMultiplyRate(String MultiplyRateOld,
                                      String MultiplyRateNew,
                                      int windowNo)
                     throws Exception
Callout

Parameters:
MultiplyRateOld - old value
MultiplyRateNew - new value
windowNo - windowNo
Throws:
Exception

setMultiplyRate

public void setMultiplyRate(BigDecimal MultiplyRate)
Set Multiply Rate Sets also Divide Rate

Overrides:
setMultiplyRate in class X_C_UOM_Conversion
Parameters:
MultiplyRate - multiply rate

setDivideRate

@UICallout
public void setDivideRate(String DivideRateOld,
                                    String DivideRateNew,
                                    int WindowNo)
                   throws Exception
Callout

Parameters:
DivideRateOld - old value
DivideRateNew - new value
windowNo - window no
Throws:
Exception

setDivideRate

public void setDivideRate(BigDecimal DivideRate)
Set Divide Rate. Sets also Multiply Rate

Overrides:
setDivideRate in class X_C_UOM_Conversion
Parameters:
DivideRate - divide rate

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.