⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mreportcolumn.java

📁 Java写的ERP系统
💻 JAVA
字号:
/******************************************************************************
 * The contents of this file are subject to the   Compiere License  Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * You may obtain a copy of the License at http://www.compiere.org/license.html
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Original Code is             Compiere  ERP & CRM Smart Business Solution
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
 * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.report;

import java.util.*;
import java.sql.*;
import java.math.*;
import java.io.Serializable;

import org.compiere.model.*;
import org.compiere.util.*;

/**
 *  Report Column Model
 *
 *  @author Jorg Janke
 *  @version $Id: MReportColumn.java,v 1.7 2003/03/15 07:02:37 jjanke Exp $
 */
public class MReportColumn
  extends PO
{
	/**
	 * 	Constructor
	 * 	@param ctx context
	 * 	@param PA_ReportColumn_ID id
	 */
	public MReportColumn (Properties ctx, int PA_ReportColumn_ID)
	{
		super (ctx, PA_ReportColumn_ID);
		if (PA_ReportColumn_ID == 0)
		{
			setIsPrinted (true);
			setSeqNo (0);
			setName (null);
			setPA_ReportColumnSet_ID (0);
			setColumnType (null);
			setPostingType (null);
		}
	}	//	MReportColumn

	/**
	 * 	Constructor
	 * 	@param ctx context
	 * 	@param rs ResultSet to load from
	 */
	public MReportColumn (Properties ctx, ResultSet rs)
	{
		super (ctx, rs);
	}	//	MReportColumn

	/**
	 * 	Copy Constructor
	 * 	@param ctx context
	 * 	@param AD_Client_ID parent
	 * 	@param AD_Org_ID parent
	 * 	@param PA_ReportColumnSet_ID parent
	 * 	@param source copy source
	 */
	public MReportColumn (Properties ctx, int AD_Client_ID, int AD_Org_ID, int PA_ReportColumnSet_ID, MReportColumn source)
	{
		super (ctx, source, AD_Client_ID, AD_Org_ID);
		setPA_ReportColumnSet_ID(PA_ReportColumnSet_ID);	//	parent
	}	//	MReportColumn

	/**
	 * 	Initialize
	 * 	@param ctx context
	 * 	@return meta data
	 */
	protected POInfo initPO (Properties ctx)
	{
		int AD_Table_ID = 446;
		POInfo poi = POInfo.getPOInfo (ctx, AD_Table_ID);
		return poi;
	}	//	initPO

	/*************************************************************************/

	/**
	 * 	Get SQL Select Clause.
	 * 	@param withSum with SUM() function
	 * 	@return select clause - AmtAcctCR+AmtAcctDR/etc or "null" if not defined
	 */
	public String getSelectClause (boolean withSum)
	{
		String at = getAmountType().substring(0,1);
		StringBuffer sb = new StringBuffer();
		if (withSum)
			sb.append("SUM(");
		if (AmountType_Balance.equals(at))
			sb.append("AmtAcctDr-AmtAcctCr");
		else if (AmountType_CR.equals(at))
			sb.append("AmtAcctCr");
		else if (AmountType_DR.equals(at))
			sb.append("AmtAcctDr");
		else if (AmountType_Qty.equals(at))
			sb.append("Qty");
		else
		{
			Log.error ("MReportColumn.getSelectClause - AmountType=" + getAmountType () + ", at=" + at);
			return "NULL";
		}
		if (withSum)
			sb.append(")");
		return sb.toString();
	}	//	getSelectClause

	/**
	 * 	Is it Period Balance?
	 * 	@return true if Period Balance
	 */
	public boolean isPeriodBalance()
	{
		if (getAmountType() == null)
			return false;
		String at = getAmountType().substring(1);
		return AmountType_Period.equals(at);
	}	//	isPeriodBalance

	/**
	 * 	Is it Year Balance?
	 * 	@return true if Year Balance
	 */
	public boolean isYearBalance()
	{
		if (getAmountType() == null)
			return false;
		String at = getAmountType().substring(1);
		return AmountType_Year.equals(at);
	}	//	isYearBalance

	/**
	 * 	Is it Total Balance?
	 * 	@return true if Year Balance
	 */
	public boolean isTotalBalance()
	{
		if (getAmountType() == null)
			return false;
		String at = getAmountType().substring(1);
		return AmountType_Total.equals(at);
	}	//	isTotalBalance


	/**
	 * 	Get String Representation
	 * 	@return	String Representation
	 */
	public String toString ()
	{
		StringBuffer sb = new StringBuffer ("MReportColumn[")
			.append(getID()).append(" - ").append(getName()).append(" - ").append(getDescription())
			.append(", SeqNo=").append(getSeqNo()).append(", AmountType=").append(getAmountType())
			.append(", CurrencyType=").append(getCurrencyType()).append("/").append(getC_Currency_ID())
			.append(" - ColumnType=").append(getColumnType());
		if (isColumnTypeCalculation())
			sb.append(" - Calculation=").append(getCalculationType())
				.append(" - ").append(getOper_1_ID()).append(" - ").append(getOper_2_ID());
		else if (isColumnTypeRelativePeriod())
			sb.append(" - Period=").append(getRelativePeriod());
		else
			sb.append(" - SegmentValue ElementType=").append(getElementType());
		sb.append ("]");
		return sb.toString ();
	}	//	toString



	public boolean save ()
	{
		Log.trace (Log.l4_Data, "MReportColumn.save");
		return super.save ();
	}

	public void setIsPrinted (boolean IsPrinted)
	{
		setValue ("IsPrinted", IsPrinted ? "Y" : "N");
	}

	public boolean isPrinted ()
	{
		Boolean bb = (Boolean)getValue ("IsPrinted");
		if (bb != null)
			return bb.booleanValue ();
		return false;
	}

	public void setRelativePeriod (int RelativePeriod)
	{
		setValue ("RelativePeriod", new BigDecimal(RelativePeriod));
	}

	public int getRelativePeriod ()
	{
		BigDecimal bd = (BigDecimal)getValue ("RelativePeriod");
		if (bd == null)
			return 0;
		return bd.intValue();
	}

	public void setOper_1_ID (int Oper_1_ID)
	{
		setValue ("Oper_1_ID", new Integer (Oper_1_ID));
	}

	public int getOper_1_ID ()
	{
		Integer ii = (Integer)getValue ("Oper_1_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_SalesRegion_ID (int C_SalesRegion_ID)
	{
		setValue ("C_SalesRegion_ID", new Integer (C_SalesRegion_ID));
	}

	public int getC_SalesRegion_ID ()
	{
		Integer ii = (Integer)getValue ("C_SalesRegion_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_Activity_ID (int C_Activity_ID)
	{
		setValue ("C_Activity_ID", new Integer (C_Activity_ID));
	}

	public int getC_Activity_ID ()
	{
		Integer ii = (Integer)getValue ("C_Activity_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setDescription (String Description)
	{
		setValue ("Description", Description);
	}

	public String getDescription ()
	{
		return (String)getValue ("Description");
	}

	public void setCalculationType (String CalculationType)
	{
		if (CalculationType.equals ("A") || CalculationType.equals ("P")
		  || CalculationType.equals ("R") || CalculationType.equals ("S"))
			;
		else
			throw new IllegalArgumentException (
			  "CalculationType Invalid value - Reference_ID=236 - A - P - R - S");
		setValue ("CalculationType", CalculationType);
	}

	public String getCalculationType ()
	{
		return (String)getValue ("CalculationType");
	}

	public boolean isCalculationTypeRange()
	{
		return "R".equals(getCalculationType());
	}
	public boolean isCalculationTypeAdd()
	{
		return "A".equals(getCalculationType());
	}
	public boolean isCalculationTypeSubtract()
	{
		return "S".equals(getCalculationType());
	}
	public boolean isCalculationTypePercent()
	{
		return "P".equals(getCalculationType());
	}



	public void setCurrencyType (String CurrencyType)
	{
		if (CurrencyType.equals ("A") || CurrencyType.equals ("S"))
			;
		else
			throw new IllegalArgumentException (
			  "CurrencyType Invalid value - Reference_ID=238 - A - S");
		setValue ("CurrencyType", CurrencyType);
	}

	public String getCurrencyType ()
	{
		return (String)getValue ("CurrencyType");
	}

	public void setM_Product_ID (int M_Product_ID)
	{
		setValue ("M_Product_ID", new Integer (M_Product_ID));
	}

	public int getM_Product_ID ()
	{
		Integer ii = (Integer)getValue ("M_Product_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setSeqNo (int SeqNo)
	{
		setValue ("SeqNo", new Integer (SeqNo));
	}

	public int getSeqNo ()
	{
		Integer ii = (Integer)getValue ("SeqNo");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setOrg_ID (int Org_ID)
	{
		setValue ("Org_ID", new Integer (Org_ID));
	}

	public int getOrg_ID ()
	{
		Integer ii = (Integer)getValue ("Org_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public int getPA_ReportColumn_ID ()
	{
		return getID();
	}

	public void setC_Campaign_ID (int C_Campaign_ID)
	{
		setValue ("C_Campaign_ID", new Integer (C_Campaign_ID));
	}

	public int getC_Campaign_ID ()
	{
		Integer ii = (Integer)getValue ("C_Campaign_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_Location_ID (int C_Location_ID)
	{
		setValue ("C_Location_ID", new Integer (C_Location_ID));
	}

	public int getC_Location_ID ()
	{
		Integer ii = (Integer)getValue ("C_Location_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_BPartner_ID (int C_BPartner_ID)
	{
		setValue ("C_BPartner_ID", new Integer (C_BPartner_ID));
	}

	public int getC_BPartner_ID ()
	{
		Integer ii = (Integer)getValue ("C_BPartner_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public static final String		AmountType_Balance = "B";
	public static final String		AmountType_CR = "C";
	public static final String		AmountType_DR = "D";
	public static final String		AmountType_Qty = "Q";
	//
	public static final String		AmountType_Period = "P";
	public static final String		AmountType_Year = "Y";
	public static final String		AmountType_Total = "T";

	public void setAmountType (String AmountType)
	{
		setValue ("AmountType", AmountType);
	}

	public String getAmountType ()
	{
		return (String)getValue ("AmountType");
	}

	public void setName (String Name)
	{
		if (Name == null)
			throw new IllegalArgumentException ("Name is mandatory");
		setValue ("Name", Name);
	}

	public String getName ()
	{
		return (String)getValue ("Name");
	}

	public void setGL_Budget_ID (int GL_Budget_ID)
	{
		setValue ("GL_Budget_ID", new Integer (GL_Budget_ID));
	}

	public int getGL_Budget_ID ()
	{
		Integer ii = (Integer)getValue ("GL_Budget_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_ElementValue_ID (int C_ElementValue_ID)
	{
		setValue ("C_ElementValue_ID", new Integer (C_ElementValue_ID));
	}

	public int getC_ElementValue_ID ()
	{
		Integer ii = (Integer)getValue ("C_ElementValue_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_Project_ID (int C_Project_ID)
	{
		setValue ("C_Project_ID", new Integer (C_Project_ID));
	}

	public int getC_Project_ID ()
	{
		Integer ii = (Integer)getValue ("C_Project_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_Currency_ID (int C_Currency_ID)
	{
		setValue ("C_Currency_ID", new Integer (C_Currency_ID));
	}

	public int getC_Currency_ID ()
	{
		Integer ii = (Integer)getValue ("C_Currency_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setOper_2_ID (int Oper_2_ID)
	{
		setValue ("Oper_2_ID", new Integer (Oper_2_ID));
	}

	public int getOper_2_ID ()
	{
		Integer ii = (Integer)getValue ("Oper_2_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setElementType (String ElementType)
	{
		if (ElementType.equals ("AC") || ElementType.equals ("AY")
		  || ElementType.equals ("BP") || ElementType.equals ("LF")
		  || ElementType.equals ("LT") || ElementType.equals ("MC")
		  || ElementType.equals ("OO") || ElementType.equals ("OT")
		  || ElementType.equals ("PJ") || ElementType.equals ("PR")
		  || ElementType.equals ("SR") || ElementType.equals ("U1")
		  || ElementType.equals ("U2"))
			;
		else
			throw new IllegalArgumentException ("ElementType Invalid value - Reference_ID=181 - AC - AY - BP - LF - LT - MC - OO - OT - PJ - PR - SR - U1 - U2");
		setValue ("ElementType", ElementType);
	}

	public String getElementType ()
	{
		return (String)getValue ("ElementType");
	}

	public void setIsAdhocConversion (boolean IsAdhocConversion)
	{
		setValue ("IsAdhocConversion", IsAdhocConversion ? "Y" : "N");
	}

	public boolean isAdhocConversion ()
	{
		Boolean bb = (Boolean)getValue ("IsAdhocConversion");
		if (bb != null)
			return bb.booleanValue ();
		return false;
	}

	void setPA_ReportColumnSet_ID (int PA_ReportColumnSet_ID)
	{
		setValueNoCheck ("PA_ReportColumnSet_ID", new Integer (PA_ReportColumnSet_ID));
	}

	public int getPA_ReportColumnSet_ID ()
	{
		Integer ii = (Integer)getValue ("PA_ReportColumnSet_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}


	private static final String	ColumnType_Calculation = "C";
	private static final String	ColumnType_RelativePeriod = "R";
	private static final String	ColumnType_SegmentValue = "S";

	public void setColumnType (String ColumnType)
	{
		if (ColumnType.equals ("C") || ColumnType.equals ("R")
		  || ColumnType.equals ("S"))
			;
		else
			throw new IllegalArgumentException (
			  "ColumnType Invalid value - Reference_ID=237 - C - R - S");
		if (ColumnType == null)
			throw new IllegalArgumentException ("ColumnType is mandatory");
		setValue ("ColumnType", ColumnType);
	}

	public String getColumnType ()
	{
		return (String)getValue ("ColumnType");
	}

	public boolean isColumnTypeCalculation()
	{
		return ColumnType_Calculation.equals(getColumnType());
	}
	public boolean isColumnTypeRelativePeriod()
	{
		return ColumnType_RelativePeriod.equals(getColumnType());
	}
	public boolean isColumnTypeSegmentValue()
	{
		return ColumnType_SegmentValue.equals(getColumnType());
	}


	public void setPostingType (String PostingType)
	{
		if (PostingType.equals ("A") || PostingType.equals ("B")
		  || PostingType.equals ("E") || PostingType.equals ("S"))
			;
		else
			throw new IllegalArgumentException (
			  "PostingType Invalid value - Reference_ID=125 - A - B - E - S");
		if (PostingType == null)
			throw new IllegalArgumentException ("PostingType is mandatory");
		setValue ("PostingType", PostingType);
	}

	public String getPostingType ()
	{
		return (String)getValue ("PostingType");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -