📄 doc_production.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_Production (325)
* Document Types: MMP
* </pre>
* @author Jorg Janke
* @version $Id: Doc_Production.java,v 1.6 2003/03/19 06:47:32 jjanke Exp $
*/
public class Doc_Production extends Doc
{
/**
* Constructor
* @param AD_Client_ID client
*/
public Doc_Production (int AD_Client_ID)
{
super (AD_Client_ID);
} // Doc_Production
/**
* Get AD_Table_ID
* @return 325
*/
public int getAD_Table_ID()
{
return 325;
} // get_Table_ID
/**
* Table Name
* @return M_Production
*/
public String getTableName()
{
return "M_Production";
} // getTableName
/**
* Load Document Details
* @param rs result set
* @return true if loadDocumentType was set
*/
protected boolean loadDocumentDetails(ResultSet rs)
{
p_vo.DocumentType = DocVO.DOCTYPE_MatProduction;
p_vo.C_Currency_ID = NO_CURRENCY;
try
{
p_vo.DateDoc = rs.getTimestamp("MovementDate");
}
catch (SQLException e)
{
log.error("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 DoaLine Array
*/
private DocLine[] loadLines()
{
ArrayList list = new ArrayList();
String sql = "SELECT * FROM M_ProductionLine WHERE M_Production_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_ProductionLine_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"));
//
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 Zero (always balanced)
*/
public BigDecimal getBalance()
{
BigDecimal retValue = Env.ZERO;
return retValue;
} // getBalance
/**
* Create Facts (the accounting logic) for
* MMP.
* <pre>
* Production
* Inventory 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 fl = 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
fl = fact.createLine(line,
line.getAccount(ProductInfo.ACCTTYPE_P_Asset, as),
as.getC_Currency_ID(), costs);
fl.setM_Locator_ID(line.getM_Locator_ID());
}
return fact;
} // createFact
} // Doc_Production
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -