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

📄 docline.java

📁 Java写的ERP系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
 * 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  Business Solution
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
 * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.acct;

import java.math.*;
import java.sql.*;

import org.apache.log4j.Logger;

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

/**
 *  Standard Document Line
 *
 *  @author 	Jorg Janke
 *  @version 	$Id: DocLine.java,v 1.13 2003/03/19 06:47:31 jjanke Exp $
 */
public class DocLine
{
	/**
	 *	Create Document Line
	 *  @param DocumentType document type
	 *  @param TrxHeader_ID Record_ID
	 *  @param TrxLine_ID   Line_ID
	 */
	public DocLine(String DocumentType, int TrxHeader_ID, int TrxLine_ID)
	{
		if (DocumentType == null)
			throw new IllegalArgumentException("DocLine - DocumentType is null");
		p_DocumentType = DocumentType;
		m_TrxHeader_ID = TrxHeader_ID;
		m_TrxLine_ID = TrxLine_ID;
	}	//	DocLine

	/**	 Log					*/
	protected Logger		log = Logger.getLogger(getClass());

	/** ID - Document Type      */
	protected String 		p_DocumentType = null;
	/** ID - Trx Header         */
	private int 			m_TrxHeader_ID = 0;
	/** ID - Line ID            */
	private int 			m_TrxLine_ID = 0;
	/** Line                    */
	private int             m_Line = 0;

	/**	Qty UOM                 */
	private int				m_C_UOM_ID = 0;
	/** Qty                     */
	private BigDecimal	 	m_qty = null;


	/** Currency                */
	private int				m_C_Currency_ID = 0;

	//  -- GL Amounts
	/** Debit Journal Amt   */
	private BigDecimal      m_AmtSourceDr = Env.ZERO;
	/** Credit Journal Amt	*/
	private BigDecimal      m_AmtSourceCr = Env.ZERO;

	/** Converted Amounts       */
	private BigDecimal      m_AmtAcctDr = null;
	private BigDecimal      m_AmtAcctCr = null;
	private int             m_C_AcctSchema_ID = 0;

	protected ProductInfo   p_productInfo = null;

	/** Account used only for GL Journal    */
	private Account 		m_account = null;

	//  Dimensions
	private int             m_AD_Org_ID = 0;
	private int		        m_C_BPartner_ID = 0;
	private int             m_M_Product_ID = 0;
	private int             m_AD_OrgTrx_ID = 0;
	private int             m_C_SalesRegion_ID = 0;
	private int             m_C_Project_ID = 0;
	private int             m_C_Campaign_ID = 0;
	private int             m_C_Activity_ID = 0;
	private int             m_C_LocFrom_ID = 0;
	private int             m_C_LocTo_ID = 0;
	private int             m_User1_ID = 0;
	private int             m_User2_ID = 0;
	//
	private int				m_C_Charge_ID = 0;
	private BigDecimal      m_ChargeAmt = Env.ZERO;
	/** Description             */
	private String 			m_description = null;
	/** Tax ID                  */
	private int				m_C_Tax_ID = 0;

	private Timestamp       m_DateAcct = null;
	private Timestamp       m_DateDoc = null;

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

	/**
	 *  Load Attributes from ResultSet
	 *  @param rs result set
	 *  @param vo doc value object
	 */
	public void loadAttributes (ResultSet rs, DocVO vo)
	{
	//	Log.trace(this,Log.l4_Data, "DocLine.loadAttributes");
		try
		{
			ResultSetMetaData rsmd = rs.getMetaData();
			for (int i = 1; i <= rsmd.getColumnCount(); i++)
			{
				String col = rsmd.getColumnName(i);
				if (col.equalsIgnoreCase("AD_Org_ID"))
					m_AD_Org_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("C_BPartner_ID"))
					m_C_BPartner_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("M_Product_ID"))
					m_M_Product_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("AD_OrgTrx_ID"))
					m_AD_OrgTrx_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("C_SalesRegion_ID"))
					m_C_SalesRegion_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("C_Project_ID"))
					m_C_Project_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("C_Campaign_ID"))
					m_C_Campaign_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("C_Activity_ID"))
					m_C_Activity_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("C_LocFrom_ID"))
					m_C_LocFrom_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("C_LocTo_ID"))
					m_C_LocTo_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("User1_ID"))
					m_User1_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("User2_ID"))
					m_User2_ID = rs.getInt(i);
				//  Line, Description, Currency
				else if (col.equalsIgnoreCase("Line"))
					m_Line = rs.getInt(i);
				else if (col.equalsIgnoreCase("Description"))
					m_description = rs.getString(i);
				else if (col.equalsIgnoreCase("C_Currency_ID"))
					m_C_Currency_ID = rs.getInt(i);
				//	Qty
				else if (col.equalsIgnoreCase("C_UOM_ID"))
					m_C_UOM_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("Qty"))
					m_qty = rs.getBigDecimal(i);
				//
				else if (col.equalsIgnoreCase("C_Tax_ID"))
					m_C_Tax_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("C_Charge_ID"))
					m_C_Charge_ID = rs.getInt(i);
				else if (col.equalsIgnoreCase("ChargeAmt"))
					m_ChargeAmt = rs.getBigDecimal(i);
				//
				else if (col.equalsIgnoreCase("DateAcct"))
					m_DateAcct = rs.getTimestamp(i);
				else if (col.equalsIgnoreCase("DateDoc"))
					m_DateDoc = rs.getTimestamp(i);
				//
			}   //  for all columns
		}
		catch (SQLException e)
		{
			log.error ("loadAttributes", e);
		}
		//  Product Info
		p_productInfo = new ProductInfo(m_M_Product_ID);

		//  Document Consistency
		if (m_AD_Org_ID == 0)
			m_AD_Org_ID = vo.AD_Org_ID;
		if (m_C_Currency_ID == 0)
			m_C_Currency_ID = vo.C_Currency_ID;
	}   //  loadAttributes


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

	/**
	 *  Set Currency
	 *  @param C_Currency_ID currency
	 */
	public void setC_Currency_ID (int C_Currency_ID)
	{
		m_C_Currency_ID = C_Currency_ID;
	}   //  setC_Currency_ID

	/**
	 *  Get Currency
	 *  @return c_Currency_ID
	 */
	public int getC_Currency_ID ()
	{
		return m_C_Currency_ID;
	}   //  getC_Currency_ID

	/**
	 *  Set Amount (DR)
	 *  @param sourceAmt source amt
	 */
	public void setAmount (BigDecimal sourceAmt)
	{
		m_AmtSourceDr = sourceAmt == null ? Env.ZERO : sourceAmt;
		m_AmtSourceCr = Env.ZERO;
	}   //  setAmounts

	/**
	 *  Set Amounts
	 *  @param amtSourceDr source amount dr
	 *  @param amtSourceCr source amount cr
	 */
	public void setAmount (BigDecimal amtSourceDr, BigDecimal amtSourceCr)
	{
		m_AmtSourceDr = amtSourceDr == null ? Env.ZERO : amtSourceDr;
		m_AmtSourceCr = amtSourceCr == null ? Env.ZERO : amtSourceCr;
	}   //  setAmounts

	/**
	 *  Set Converted Amounts
	 *  @param C_AcctSchema_ID acct schema
	 *  @param amtAcctDr acct amount dr
	 *  @param amtAcctCr acct amount cr
	 */
	public void setConvertedAmt (int C_AcctSchema_ID, BigDecimal amtAcctDr, BigDecimal amtAcctCr)
	{
		m_C_AcctSchema_ID = C_AcctSchema_ID;
		m_AmtAcctDr = amtAcctDr;
		m_AmtAcctCr = amtAcctCr;
	}   //  setConvertedAmt

	/**
	 *  Line Net Amount or Dr-Cr
	 *  @return balance
	 */
	public BigDecimal getAmount()
	{
		return m_AmtSourceDr.subtract(m_AmtSourceCr);
	}   //  getAmount

	/**
	 *  Get (Journal) Line Source Dr Amount
	 *  @return DR source amount
	 */
	public BigDecimal getAmtSourceDr()
	{
		return m_AmtSourceDr;
	}   //  getAmtSourceDr

	/**
	 *  Get (Journal) Line Source Cr Amount
	 *  @return CR source amount
	 */
	public BigDecimal getAmtSourceCr()
	{
		return m_AmtSourceCr;
	}   //  getAmtSourceCr

	/**
	 *  Line Journal Accounted Dr Amount
	 *  @return DR accounted amount
	 */
	public BigDecimal getAmtAcctDr()
	{
		return m_AmtAcctDr;
	}   //  getAmtAcctDr

	/**
	 *  Line Journal Accounted Cr Amount
	 *  @return CR accounted amount
	 */
	public BigDecimal getAmtAcctCr()
	{
		return m_AmtAcctCr;
	}   //  getAmtAccrCr

	/**
	 *  Charge Amount
	 *  @param chargeAmt charge amt
	 */
	public void setChargeAmt (BigDecimal chargeAmt)
	{
		m_ChargeAmt = chargeAmt == null ? Env.ZERO : chargeAmt;
	}   //  setChargeAmt

	/**
	 *  Charge Amount
	 *  @return charge amount
	 */
	public BigDecimal getChargeAmt()
	{
		return m_ChargeAmt;
	}   //  getChargeAmt

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

	/**
	 *  Set Accounting Date
	 *  @param dateAcct acct date
	 */
	public void setDateAcct (Timestamp dateAcct)
	{
		m_DateAcct = dateAcct;
	}   //  setDateAcct

	/**
	 *  Get Accounting Date
	 *  @return accounting date
	 */
	public Timestamp getDateAcct ()
	{
		return m_DateAcct;
	}   //  getDateAcct

	/**
	 *  Set Document Date
	 *  @param dateDoc doc date
	 */
	public void setDateDoc (Timestamp dateDoc)
	{
		m_DateDoc = dateDoc;
	}   //  setDateDoc

	/**

⌨️ 快捷键说明

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