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

📄 doc_movement.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  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.util.*;
import java.sql.*;

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

/**
 *  Post Invoice Documents.
 *  <pre>
 *  Table:              M_Movement (323)
 *  Document Types:     MMM
 *  </pre>
 *  @author Jorg Janke
 *  @version  $Id: Doc_Movement.java,v 1.7 2003/03/19 06:47:32 jjanke Exp $
 */
public class Doc_Movement extends Doc
{
	/**
	 *  Constructor
	 *  @param AD_Client_ID client
	 */
	public Doc_Movement (int AD_Client_ID)
	{
		super (AD_Client_ID);
	}   //  Doc_Movement

	/**
	 *  Get AD_Table_ID
	 *  @return AD_Table_ID (323)
	 */
	public int getAD_Table_ID()
	{
		return 323;
	}   //  get_Table_ID

	/**
	 *  Table Name
	 *  @return Table Name (M_Movement)
	 */
	public String getTableName()
	{
		return "M_Movement";
	}   //  getTableName

	/**
	 *  Load Document Details
	 *  @param rs result set
	 *  @return true if loadDocumentType was set
	 */
	protected boolean loadDocumentDetails(ResultSet rs)
	{
		p_vo.DocumentType = DocVO.DOCTYPE_MatMovement;
		p_vo.C_Currency_ID = NO_CURRENCY;
		try
		{
			p_vo.DateDoc = rs.getTimestamp("MovementDate");
		}
		catch (SQLException e)
		{
			log.debug("loadDocumentDetails", e);
		}
		loadDocumentType();     //  lines require doc type
		//	Contained Objects
		p_lines = loadLines();
		log.debug("Lines=" + p_lines.length);
		return true;
	}   //  loadDocumentDetails

	/**
	 *	Load Invoice Line
	 *  @return document lines (DocLine_Material)
	 */
	private DocLine[] loadLines()
	{
		ArrayList list = new ArrayList();
		String sql = "SELECT * FROM M_MovementLine WHERE M_Movement_ID=? ORDER BY Line";
		try
		{
			PreparedStatement pstmt = DB.prepareStatement(sql);
			pstmt.setInt(1, p_vo.Record_ID);
			ResultSet rs = pstmt.executeQuery();
			//
			while (rs.next())
			{
				int Line_ID = rs.getInt("M_MovementLine_ID");
				DocLine_Material docLine = new DocLine_Material (p_vo.DocumentType, p_vo.Record_ID, Line_ID);
				docLine.loadAttributes(rs, p_vo);
				docLine.setQty(rs.getBigDecimal("MovementQty"));
				docLine.setM_Locator_ID (rs.getInt("M_Locator_ID"));
				docLine.setM_LocatorTo_ID (rs.getInt("M_LocatorTo_ID"));
				//
				log.debug(docLine.toString());
				list.add (docLine);
			}
			//
			rs.close();
			pstmt.close();
		}
		catch (SQLException e)
		{
			log.error ("loadLines", e);
		}

		//	Return Array
		DocLine[] dl = new DocLine[list.size()];
		list.toArray(dl);
		return dl;
	}	//	loadLines

	/**
	 *  Get Balance
	 *  @return balance (ZERO) - always balanced
	 */
	public BigDecimal getBalance()
	{
		BigDecimal retValue = Env.ZERO;
		return retValue;
	}   //  getBalance

	/**
	 *  Create Facts (the accounting logic) for
	 *  MMM.
	 *  <pre>
	 *  Movement
	 *      Inventory       DR      CR
	 *      InventoryTo     DR      CR
	 *  </pre>
	 *  @param as account schema
	 *  @return Fact
	 */
	public Fact createFact(AcctSchema as)
	{
		p_vo.C_Currency_ID = as.getC_Currency_ID();
		//  create Fact Header
		Fact fact = new Fact(this, as, Fact.POST_Actual);

		//  Line pointers
		FactLine dr = null;
		FactLine cr = null;

		for (int i = 0; i < p_lines.length; i++)
		{
			DocLine_Material line = (DocLine_Material)p_lines[i];
			BigDecimal costs = line.getProductCosts(as);
			//  Inventory       DR      CR
			dr = fact.createLine(line,
				line.getAccount(ProductInfo.ACCTTYPE_P_Asset, as),
				as.getC_Currency_ID(), costs);
			dr.setM_Locator_ID(line.getM_Locator_ID());
			//  InventoryTo     DR      CR
			cr = fact.createLine(line,
				line.getAccount(ProductInfo.ACCTTYPE_P_Asset, as),
				as.getC_Currency_ID(), costs.negate());
			cr.setM_Locator_ID(line.getM_LocatorTo_ID());
		}

		return fact;
	}   //  createFact

}   //  Doc_Movement

⌨️ 快捷键说明

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