/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 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 *
*****************************************************************************/
package org.compiere.acct;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.logging.Level;
import org.compiere.model.MAcctSchema;
import org.compiere.model.MCostDetail;
import org.compiere.model.MProduct;
import org.compiere.model.MProject;
import org.compiere.model.MProjectIssue;
import org.compiere.model.ProductCost;
import org.compiere.util.DB;
import org.compiere.util.Env;
/**
* Posting for {@link MProjectIssue} document. DOCTYPE_ProjectIssue.
* Note:
* Will load the default GL Category.
* Set up a document type to set the GL Category.
*
* @author Jorg Janke
* @version $Id: Doc_ProjectIssue.java,v 1.2 2006/07/30 00:53:33 jjanke Exp $
*/
public class Doc_ProjectIssue extends Doc
{
/**
* Constructor
* @param as accounting schema
* @param rs record
* @param trxName trx
*/
public Doc_ProjectIssue (MAcctSchema as, ResultSet rs, String trxName)
{
super (as, MProjectIssue.class, rs, DOCTYPE_ProjectIssue, trxName);
} // Doc_ProjectIssue
/** Pseudo Line */
private DocLine m_line = null;
/** Issue */
private MProjectIssue m_issue = null;
/**
* Load Document Details
* @return error message or null
*/
@Override
protected String loadDocumentDetails()
{
setC_Currency_ID(NO_CURRENCY);
m_issue = (MProjectIssue)getPO();
setDateDoc (m_issue.getMovementDate());
setDateAcct(m_issue.getMovementDate());
// Pseudo Line
m_line = new DocLine (m_issue, this);
m_line.setQty (m_issue.getMovementQty(), true); // sets Trx and Storage Qty
// Pseudo Line Check
if (m_line.getM_Product_ID() == 0)
log.warning(m_line.toString() + " - No Product");
if (log.isLoggable(Level.FINE)) log.fine(m_line.toString());
return null;
} // loadDocumentDetails
/**
* Get DocumentNo
* @return document no
*/
@Override
public String getDocumentNo ()
{
MProject p = m_issue.getParent();
if (p != null){
StringBuilder msgreturn = new StringBuilder().append(p.getValue()).append(" #").append(m_issue.getLine());
return msgreturn.toString();
}
StringBuilder msgreturn = new StringBuilder("(").append(m_issue.get_ID()).append(")");
return msgreturn.toString();
} // getDocumentNo
/**
* Get Balance
* @return Zero (always balanced)
*/
@Override
public BigDecimal getBalance()
{
BigDecimal retValue = Env.ZERO;
return retValue;
} // getBalance
/**
* Create Facts (the accounting logic) for
* PJI
*
* Issue * ProjectWIP DR * Inventory CR ** Project Account is either Asset or WIP depending on Project Type * @param as accounting schema * @return Fact */ @Override public ArrayList