/******************************************************************************
 * 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_Opportunity
 *  @author iDempiere (generated)
 *  @version Release 12 - $Id$ */
@org.adempiere.base.Model(table="C_Opportunity")
public class X_C_Opportunity extends PO implements I_C_Opportunity, I_Persistent
{

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

    /** Standard Constructor */
    public X_C_Opportunity (Properties ctx, int C_Opportunity_ID, String trxName)
    {
      super (ctx, C_Opportunity_ID, trxName);
      /** if (C_Opportunity_ID == 0)
        {
			setC_BPartner_ID (0);
// @C_BPartner_ID@
			setC_Currency_ID (0);
			setC_Opportunity_ID (0);
			setC_SalesStage_ID (0);
			setDocumentNo (null);
			setExpectedCloseDate (new Timestamp( System.currentTimeMillis() ));
			setOpportunityAmt (Env.ZERO);
			setProbability (Env.ZERO);
        } */
    }

    /** Standard Constructor */
    public X_C_Opportunity (Properties ctx, int C_Opportunity_ID, String trxName, String ... virtualColumns)
    {
      super (ctx, C_Opportunity_ID, trxName, virtualColumns);
      /** if (C_Opportunity_ID == 0)
        {
			setC_BPartner_ID (0);
// @C_BPartner_ID@
			setC_Currency_ID (0);
			setC_Opportunity_ID (0);
			setC_SalesStage_ID (0);
			setDocumentNo (null);
			setExpectedCloseDate (new Timestamp( System.currentTimeMillis() ));
			setOpportunityAmt (Env.ZERO);
			setProbability (Env.ZERO);
        } */
    }

    /** Standard Constructor */
    public X_C_Opportunity (Properties ctx, String C_Opportunity_UU, String trxName)
    {
      super (ctx, C_Opportunity_UU, trxName);
      /** if (C_Opportunity_UU == null)
        {
			setC_BPartner_ID (0);
// @C_BPartner_ID@
			setC_Currency_ID (0);
			setC_Opportunity_ID (0);
			setC_SalesStage_ID (0);
			setDocumentNo (null);
			setExpectedCloseDate (new Timestamp( System.currentTimeMillis() ));
			setOpportunityAmt (Env.ZERO);
			setProbability (Env.ZERO);
        } */
    }

    /** Standard Constructor */
    public X_C_Opportunity (Properties ctx, String C_Opportunity_UU, String trxName, String ... virtualColumns)
    {
      super (ctx, C_Opportunity_UU, trxName, virtualColumns);
      /** if (C_Opportunity_UU == null)
        {
			setC_BPartner_ID (0);
// @C_BPartner_ID@
			setC_Currency_ID (0);
			setC_Opportunity_ID (0);
			setC_SalesStage_ID (0);
			setDocumentNo (null);
			setExpectedCloseDate (new Timestamp( System.currentTimeMillis() ));
			setOpportunityAmt (Env.ZERO);
			setProbability (Env.ZERO);
        } */
    }

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

    /** AccessLevel
      * @return 3 - Client - Org
      */
    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_Opportunity[")
        .append(get_ID()).append("]");
      return sb.toString();
    }

	public org.compiere.model.I_AD_User getAD_User() throws RuntimeException
	{
		return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_ID)
			.getPO(getAD_User_ID(), get_TrxName());
	}

	/** Set User/Contact.
		@param AD_User_ID User within the system - Internal or Business Partner Contact
	*/
	public void setAD_User_ID (int AD_User_ID)
	{
		if (AD_User_ID < 1)
			set_Value (COLUMNNAME_AD_User_ID, null);
		else
			set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
	}

	/** Get User/Contact.
		@return User within the system - Internal or Business Partner Contact
	  */
	public int getAD_User_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_AD_User_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException
	{
		return (org.compiere.model.I_C_BPartner)MTable.get(getCtx(), org.compiere.model.I_C_BPartner.Table_ID)
			.getPO(getC_BPartner_ID(), get_TrxName());
	}

	/** Set Business Partner.
		@param C_BPartner_ID Identifies a Business Partner
	*/
	public void setC_BPartner_ID (int C_BPartner_ID)
	{
		if (C_BPartner_ID < 1)
			set_Value (COLUMNNAME_C_BPartner_ID, null);
		else
			set_Value (COLUMNNAME_C_BPartner_ID, Integer.valueOf(C_BPartner_ID));
	}

	/** Get Business Partner.
		@return Identifies a Business Partner
	  */
	public int getC_BPartner_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_BPartner_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	public org.compiere.model.I_C_Campaign getC_Campaign() throws RuntimeException
	{
		return (org.compiere.model.I_C_Campaign)MTable.get(getCtx(), org.compiere.model.I_C_Campaign.Table_ID)
			.getPO(getC_Campaign_ID(), get_TrxName());
	}

	/** Set Campaign.
		@param C_Campaign_ID Marketing Campaign
	*/
	public void setC_Campaign_ID (int C_Campaign_ID)
	{
		if (C_Campaign_ID < 1)
			set_Value (COLUMNNAME_C_Campaign_ID, null);
		else
			set_Value (COLUMNNAME_C_Campaign_ID, Integer.valueOf(C_Campaign_ID));
	}

	/** Get Campaign.
		@return Marketing Campaign
	  */
	public int getC_Campaign_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_Campaign_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_Value (COLUMNNAME_C_Currency_ID, null);
		else
			set_Value (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();
	}

	/** Set Sales Opportunity.
		@param C_Opportunity_ID Sales Opportunity
	*/
	public void setC_Opportunity_ID (int C_Opportunity_ID)
	{
		if (C_Opportunity_ID < 1)
			set_ValueNoCheck (COLUMNNAME_C_Opportunity_ID, null);
		else
			set_ValueNoCheck (COLUMNNAME_C_Opportunity_ID, Integer.valueOf(C_Opportunity_ID));
	}

	/** Get Sales Opportunity.
		@return Sales Opportunity	  */
	public int getC_Opportunity_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_Opportunity_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	/** Set C_Opportunity_UU.
		@param C_Opportunity_UU C_Opportunity_UU
	*/
	public void setC_Opportunity_UU (String C_Opportunity_UU)
	{
		set_Value (COLUMNNAME_C_Opportunity_UU, C_Opportunity_UU);
	}

	/** Get C_Opportunity_UU.
		@return C_Opportunity_UU	  */
	public String getC_Opportunity_UU()
	{
		return (String)get_Value(COLUMNNAME_C_Opportunity_UU);
	}

	public org.compiere.model.I_C_Order getC_Order() throws RuntimeException
	{
		return (org.compiere.model.I_C_Order)MTable.get(getCtx(), org.compiere.model.I_C_Order.Table_ID)
			.getPO(getC_Order_ID(), get_TrxName());
	}

	/** Set Order.
		@param C_Order_ID Order
	*/
	public void setC_Order_ID (int C_Order_ID)
	{
		if (C_Order_ID < 1)
			set_Value (COLUMNNAME_C_Order_ID, null);
		else
			set_Value (COLUMNNAME_C_Order_ID, Integer.valueOf(C_Order_ID));
	}

	/** Get Order.
		@return Order
	  */
	public int getC_Order_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_Order_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	public org.compiere.model.I_C_SalesStage getC_SalesStage() throws RuntimeException
	{
		return (org.compiere.model.I_C_SalesStage)MTable.get(getCtx(), org.compiere.model.I_C_SalesStage.Table_ID)
			.getPO(getC_SalesStage_ID(), get_TrxName());
	}

	/** Set Sales Stage.
		@param C_SalesStage_ID Stages of the sales process
	*/
	public void setC_SalesStage_ID (int C_SalesStage_ID)
	{
		if (C_SalesStage_ID < 1)
			set_Value (COLUMNNAME_C_SalesStage_ID, null);
		else
			set_Value (COLUMNNAME_C_SalesStage_ID, Integer.valueOf(C_SalesStage_ID));
	}

	/** Get Sales Stage.
		@return Stages of the sales process
	  */
	public int getC_SalesStage_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_C_SalesStage_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	/** Set Close Date.
		@param CloseDate Close Date
	*/
	public void setCloseDate (Timestamp CloseDate)
	{
		set_Value (COLUMNNAME_CloseDate, CloseDate);
	}

	/** Get Close Date.
		@return Close Date
	  */
	public Timestamp getCloseDate()
	{
		return (Timestamp)get_Value(COLUMNNAME_CloseDate);
	}

	/** Set Comments.
		@param Comments Comments or additional information
	*/
	public void setComments (String Comments)
	{
		set_Value (COLUMNNAME_Comments, Comments);
	}

	/** Get Comments.
		@return Comments or additional information
	  */
	public String getComments()
	{
		return (String)get_Value(COLUMNNAME_Comments);
	}

	/** Set Cost.
		@param Cost Cost information
	*/
	public void setCost (BigDecimal Cost)
	{
		set_Value (COLUMNNAME_Cost, Cost);
	}

	/** Get Cost.
		@return Cost information
	  */
	public BigDecimal getCost()
	{
		BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Cost);
		if (bd == null)
			 return Env.ZERO;
		return bd;
	}

	/** Set Description.
		@param Description Optional short description of the record
	*/
	public void setDescription (String Description)
	{
		set_Value (COLUMNNAME_Description, Description);
	}

	/** Get Description.
		@return Optional short description of the record
	  */
	public String getDescription()
	{
		return (String)get_Value(COLUMNNAME_Description);
	}

	/** Set Document No.
		@param DocumentNo Document sequence number of the document
	*/
	public void setDocumentNo (String DocumentNo)
	{
		set_Value (COLUMNNAME_DocumentNo, DocumentNo);
	}

	/** Get Document No.
		@return Document sequence number of the document
	  */
	public String getDocumentNo()
	{
		return (String)get_Value(COLUMNNAME_DocumentNo);
	}

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

	/** Set Expected Close Date.
		@param ExpectedCloseDate Expected Close Date
	*/
	public void setExpectedCloseDate (Timestamp ExpectedCloseDate)
	{
		set_Value (COLUMNNAME_ExpectedCloseDate, ExpectedCloseDate);
	}

	/** Get Expected Close Date.
		@return Expected Close Date
	  */
	public Timestamp getExpectedCloseDate()
	{
		return (Timestamp)get_Value(COLUMNNAME_ExpectedCloseDate);
	}

	/** Set Opportunity Amount.
		@param OpportunityAmt The estimated value of this opportunity.
	*/
	public void setOpportunityAmt (BigDecimal OpportunityAmt)
	{
		set_Value (COLUMNNAME_OpportunityAmt, OpportunityAmt);
	}

	/** Get Opportunity Amount.
		@return The estimated value of this opportunity.
	  */
	public BigDecimal getOpportunityAmt()
	{
		BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_OpportunityAmt);
		if (bd == null)
			 return Env.ZERO;
		return bd;
	}

	/** Set Probability.
		@param Probability Probability
	*/
	public void setProbability (BigDecimal Probability)
	{
		set_Value (COLUMNNAME_Probability, Probability);
	}

	/** Get Probability.
		@return Probability	  */
	public BigDecimal getProbability()
	{
		BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Probability);
		if (bd == null)
			 return Env.ZERO;
		return bd;
	}

	public org.compiere.model.I_AD_User getSalesRep() throws RuntimeException
	{
		return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_ID)
			.getPO(getSalesRep_ID(), get_TrxName());
	}

	/** Set Sales Representative.
		@param SalesRep_ID Sales Representative or Company Agent
	*/
	public void setSalesRep_ID (int SalesRep_ID)
	{
		if (SalesRep_ID < 1)
			set_Value (COLUMNNAME_SalesRep_ID, null);
		else
			set_Value (COLUMNNAME_SalesRep_ID, Integer.valueOf(SalesRep_ID));
	}

	/** Get Sales Representative.
		@return Sales Representative or Company Agent
	  */
	public int getSalesRep_ID()
	{
		Integer ii = (Integer)get_Value(COLUMNNAME_SalesRep_ID);
		if (ii == null)
			 return 0;
		return ii.intValue();
	}

	/** Set Weighted Amount.
		@param WeightedAmt The amount adjusted by the probability.
	*/
	public void setWeightedAmt (BigDecimal WeightedAmt)
	{
		throw new IllegalArgumentException ("WeightedAmt is virtual column");	}

	/** Get Weighted Amount.
		@return The amount adjusted by the probability.
	  */
	public BigDecimal getWeightedAmt()
	{
		BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_WeightedAmt);
		if (bd == null)
			 return Env.ZERO;
		return bd;
	}
}