/******************************************************************************
 * Product: iDempiere ERP & CRM Smart Business Solution                       *
 * Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved.                *
 * This program is free software, you can redistribute it and/or modify it    *
 * under the terms version 2 of the GNU General Public License as published   *
 * by the Free Software Foundation. This program is distributed in the hope   *
 * that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
 * See the GNU General Public License for more details.                       *
 * You should have received a copy of the GNU General Public License along    *
 * with this program, if not, write to the Free Software Foundation, Inc.,    *
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
 * For the text or an alternative of this public license, you may reach us    *
 * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
 * or via info@compiere.org or http://www.compiere.org/license.html           *
 *****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.compiere.model;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;

/** Generated Model for C_Conversion_Rate
 *  @author iDempiere (generated)
 *  @version Release 11 - $Id$ */
@org.adempiere.base.Model(table="C_Conversion_Rate")
public class X_C_Conversion_Rate extends PO implements I_C_Conversion_Rate, I_Persistent
{

	/**
	 *
	 */
	private static final long serialVersionUID = 20231222L;

    /** Standard Constructor */
    public X_C_Conversion_Rate (Properties ctx, int C_Conversion_Rate_ID, String trxName)
    {
      super (ctx, C_Conversion_Rate_ID, trxName);
      /** if (C_Conversion_Rate_ID == 0)
        {
			setC_Conversion_Rate_ID (0);
			setC_ConversionType_ID (0);
			setC_Currency_ID (0);
			setC_Currency_ID_To (0);
			setDivideRate (Env.ZERO);
			setMultiplyRate (Env.ZERO);
			setValidFrom (new Timestamp( System.currentTimeMillis() ));
        } */
    }

    /** Standard Constructor */
    public X_C_Conversion_Rate (Properties ctx, int C_Conversion_Rate_ID, String trxName, String ... virtualColumns)
    {
      super (ctx, C_Conversion_Rate_ID, trxName, virtualColumns);
      /** if (C_Conversion_Rate_ID == 0)
        {
			setC_Conversion_Rate_ID (0);
			setC_ConversionType_ID (0);
			setC_Currency_ID (0);
			setC_Currency_ID_To (0);
			setDivideRate (Env.ZERO);
			setMultiplyRate (Env.ZERO);
			setValidFrom (new Timestamp( System.currentTimeMillis() ));
        } */
    }

    /** Standard Constructor */
    public X_C_Conversion_Rate (Properties ctx, String C_Conversion_Rate_UU, String trxName)
    {
      super (ctx, C_Conversion_Rate_UU, trxName);
      /** if (C_Conversion_Rate_UU == null)
        {
			setC_Conversion_Rate_ID (0);
			setC_ConversionType_ID (0);
			setC_Currency_ID (0);
			setC_Currency_ID_To (0);
			setDivideRate (Env.ZERO);
			setMultiplyRate (Env.ZERO);
			setValidFrom (new Timestamp( System.currentTimeMillis() ));
        } */
    }

    /** Standard Constructor */
    public X_C_Conversion_Rate (Properties ctx, String C_Conversion_Rate_UU, String trxName, String ... virtualColumns)
    {
      super (ctx, C_Conversion_Rate_UU, trxName, virtualColumns);
      /** if (C_Conversion_Rate_UU == null)
        {
			setC_Conversion_Rate_ID (0);
			setC_ConversionType_ID (0);
			setC_Currency_ID (0);
			setC_Currency_ID_To (0);
			setDivideRate (Env.ZERO);
			setMultiplyRate (Env.ZERO);
			setValidFrom (new Timestamp( System.currentTimeMillis() ));
        } */
    }

    /** Load Constructor */
    public X_C_Conversion_Rate (Properties ctx, ResultSet rs, String trxName)
    {
      super (ctx, rs, trxName);
    }

    /** AccessLevel
      * @return 6 - System - Client
      */
    protected int get_AccessLevel()
    {
      return accessLevel.intValue();
    }

    /** Load Meta Data */
    protected POInfo initPO (Properties ctx)
    {
      POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
      return poi;
    }

    public String toString()
    {
      StringBuilder sb = new StringBuilder ("X_C_Conversion_Rate[")
        .append(get_ID()).append("]");
      return sb.toString();
    }

	/** Set Conversion Rate.
		@param C_Conversion_Rate_ID Rate used for converting currencies
	*/
	public void setC_Conversion_Rate_ID (int C_Conversion_Rate_ID)
	{
		if (C_Conversion_Rate_ID < 1)
			set_ValueNoCheck (COLUMNNAME_C_Conversion_Rate_ID, null);
		else
			set_ValueNoCheck (COLUMNNAME_C_Conversion_Rate_ID, Integer.valueOf(C_Conversion_Rate_ID));
	}

	/** Get Conversion Rate.
		@return Rate used for converting currencies
	  */
	public int getC_Conversion_Rate_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_Conversion_Rate_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

    /** Get Record ID/ColumnName
        @return ID/ColumnName pair
      */
    public KeyNamePair getKeyNamePair()
    {
        return new KeyNamePair(get_ID(), String.valueOf(getC_Conversion_Rate_ID()));
    }

	/** Set C_Conversion_Rate_UU.
		@param C_Conversion_Rate_UU C_Conversion_Rate_UU
	*/
	public void setC_Conversion_Rate_UU (String C_Conversion_Rate_UU)
	{
		set_Value (COLUMNNAME_C_Conversion_Rate_UU, C_Conversion_Rate_UU);
	}

	/** Get C_Conversion_Rate_UU.
		@return C_Conversion_Rate_UU	  */
	public String getC_Conversion_Rate_UU()
	{
		return (String)get_Value(COLUMNNAME_C_Conversion_Rate_UU);
	}

	public org.compiere.model.I_C_ConversionType getC_ConversionType() throws RuntimeException
	{
		return (org.compiere.model.I_C_ConversionType)MTable.get(getCtx(), org.compiere.model.I_C_ConversionType.Table_ID)
			.getPO(getC_ConversionType_ID(), get_TrxName());
	}

	/** Set Currency Type.
		@param C_ConversionType_ID Currency Conversion Rate Type
	*/
	public void setC_ConversionType_ID (int C_ConversionType_ID)
	{
		if (C_ConversionType_ID < 1)
			set_ValueNoCheck (COLUMNNAME_C_ConversionType_ID, null);
		else
			set_ValueNoCheck (COLUMNNAME_C_ConversionType_ID, Integer.valueOf(C_ConversionType_ID));
	}

	/** Get Currency Type.
		@return Currency Conversion Rate Type
	  */
	public int getC_ConversionType_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_ConversionType_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException
	{
		return (org.compiere.model.I_C_Currency)MTable.get(getCtx(), org.compiere.model.I_C_Currency.Table_ID)
			.getPO(getC_Currency_ID(), get_TrxName());
	}

	/** Set Currency.
		@param C_Currency_ID The Currency for this record
	*/
	public void setC_Currency_ID (int C_Currency_ID)
	{
		if (C_Currency_ID < 1)
			set_ValueNoCheck (COLUMNNAME_C_Currency_ID, null);
		else
			set_ValueNoCheck (COLUMNNAME_C_Currency_ID, Integer.valueOf(C_Currency_ID));
	}

	/** Get Currency.
		@return The Currency for this record
	  */
	public int getC_Currency_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_Currency_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	public org.compiere.model.I_C_Currency getC_Currency_To() throws RuntimeException
	{
		return (org.compiere.model.I_C_Currency)MTable.get(getCtx(), org.compiere.model.I_C_Currency.Table_ID)
			.getPO(getC_Currency_ID_To(), get_TrxName());
	}

	/** Set Currency To.
		@param C_Currency_ID_To Target currency
	*/
	public void setC_Currency_ID_To (int C_Currency_ID_To)
	{
		set_ValueNoCheck (COLUMNNAME_C_Currency_ID_To, Integer.valueOf(C_Currency_ID_To));
	}

	/** Get Currency To.
		@return Target currency
	  */
	public int getC_Currency_ID_To()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_Currency_ID_To);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	/** Set Divide Rate.
		@param DivideRate To convert Source number to Target number, the Source is divided
	*/
	public void setDivideRate (BigDecimal DivideRate)
	{
		set_Value (COLUMNNAME_DivideRate, DivideRate);
	}

	/** Get Divide Rate.
		@return To convert Source number to Target number, the Source is divided
	  */
	public BigDecimal getDivideRate()
	{
		BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_DivideRate);
		if (bd == null)
			 return Env.ZERO;
		return bd;
	}

	/** Set Multiply Rate.
		@param MultiplyRate Rate to multiple the source by to calculate the target.
	*/
	public void setMultiplyRate (BigDecimal MultiplyRate)
	{
		set_Value (COLUMNNAME_MultiplyRate, MultiplyRate);
	}

	/** Get Multiply Rate.
		@return Rate to multiple the source by to calculate the target.
	  */
	public BigDecimal getMultiplyRate()
	{
		BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_MultiplyRate);
		if (bd == null)
			 return Env.ZERO;
		return bd;
	}

	/** Set Valid from.
		@param ValidFrom Valid from including this date (first day)
	*/
	public void setValidFrom (Timestamp ValidFrom)
	{
		set_ValueNoCheck (COLUMNNAME_ValidFrom, ValidFrom);
	}

	/** Get Valid from.
		@return Valid from including this date (first day)
	  */
	public Timestamp getValidFrom()
	{
		return (Timestamp)get_Value(COLUMNNAME_ValidFrom);
	}

	/** Set Valid to.
		@param ValidTo Valid to including this date (last day)
	*/
	public void setValidTo (Timestamp ValidTo)
	{
		set_ValueNoCheck (COLUMNNAME_ValidTo, ValidTo);
	}

	/** Get Valid to.
		@return Valid to including this date (last day)
	  */
	public Timestamp getValidTo()
	{
		return (Timestamp)get_Value(COLUMNNAME_ValidTo);
	}
}