Test for Financial Report add Dater Acounting
--HG-- branch : FinancialReport
This commit is contained in:
parent
52f7299479
commit
37d6304428
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,115 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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 andromedia.midsuit.process;
|
||||||
|
|
||||||
|
import java.sql.CallableStatement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.util.ProcessUtil;
|
||||||
|
import org.compiere.model.MPInstance;
|
||||||
|
import org.compiere.model.MProcess;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
|
import org.compiere.report.MReport;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
import org.compiere.util.Trx;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Financial Report Engine
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: FinReport.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class MID_FinReportJasper extends MID_FinReport
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Report Definition */
|
||||||
|
private MReport m_report = null;
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Perform process.
|
||||||
|
* @return Message to be translated
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected String doIt() throws Exception
|
||||||
|
{
|
||||||
|
// Call the normal FinReport to fill the T_Report table
|
||||||
|
String finReportMsg = super.doIt();
|
||||||
|
|
||||||
|
// Now invoke the associated jasper report (must report on the T_Report table)
|
||||||
|
ArrayList<ProcessInfoParameter> list = new ArrayList<ProcessInfoParameter>();
|
||||||
|
|
||||||
|
// Copy the list of parameters from the financial report
|
||||||
|
ProcessInfoParameter oldpara[] = getParameter();
|
||||||
|
for (int i = 0; i < oldpara.length; i++)
|
||||||
|
list.add (oldpara[i]);
|
||||||
|
// and add the T_Report_AD_PInstance_ID parameter
|
||||||
|
list.add (new ProcessInfoParameter("T_Report_AD_PInstance_ID", new Integer(getAD_PInstance_ID()), null, null, null));
|
||||||
|
ProcessInfoParameter[] pars = new ProcessInfoParameter[list.size()];
|
||||||
|
list.toArray(pars);
|
||||||
|
|
||||||
|
// Load Report Definition
|
||||||
|
m_report = new MReport (getCtx(), getRecord_ID(), get_TrxName());
|
||||||
|
|
||||||
|
MProcess proc = new MProcess(getCtx(), m_report.getJasperProcess_ID(), get_TrxName());
|
||||||
|
MPInstance instance = new MPInstance(proc, getRecord_ID());
|
||||||
|
instance.saveEx();
|
||||||
|
ProcessInfo poInfo = new ProcessInfo(proc.getName(), proc.getAD_Process_ID());
|
||||||
|
poInfo.setParameter(pars);
|
||||||
|
poInfo.setRecord_ID(getRecord_ID());
|
||||||
|
poInfo.setAD_Process_ID(proc.getAD_Process_ID());
|
||||||
|
poInfo.setAD_PInstance_ID(instance.getAD_PInstance_ID());
|
||||||
|
|
||||||
|
// need to commit in order to allow jasper to view the data
|
||||||
|
Trx trx = Trx.get(get_TrxName(), true);
|
||||||
|
trx.commit();
|
||||||
|
|
||||||
|
// CarlosRuiz - globalqss - allow procedure preprocess
|
||||||
|
if (proc.getProcedureName() != null && proc.getProcedureName().length() > 0) {
|
||||||
|
// execute on this thread/connection
|
||||||
|
String sql = "{call " + proc.getProcedureName() + "(?)}";
|
||||||
|
CallableStatement cstmt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cstmt = DB.prepareCall(sql); // ro??
|
||||||
|
cstmt.setInt(1, getAD_PInstance_ID());
|
||||||
|
cstmt.executeUpdate();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql, e);
|
||||||
|
poInfo.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(cstmt);
|
||||||
|
cstmt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO - allow java class preprocess if the classname <> ProcessUtil.JASPER_STARTER_CLASS
|
||||||
|
|
||||||
|
ProcessUtil.startJavaProcess(getCtx(), poInfo, trx);
|
||||||
|
|
||||||
|
return finReportMsg;
|
||||||
|
} // doIt
|
||||||
|
|
||||||
|
} // FinReport
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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 andromedia.midsuit.process;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Financial Report Periods
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: FinReportPeriod.java,v 1.3 2006/08/03 22:16:52 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class MID_FinReportPeriod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param C_Period_ID period
|
||||||
|
* @param Name name
|
||||||
|
* @param StartDate period start date
|
||||||
|
* @param EndDate period end date
|
||||||
|
* @param YearStartDate year start date
|
||||||
|
*/
|
||||||
|
public MID_FinReportPeriod (int C_Period_ID, String Name, Timestamp StartDate, Timestamp EndDate,
|
||||||
|
Timestamp YearStartDate)
|
||||||
|
{
|
||||||
|
m_C_Period_ID = C_Period_ID;
|
||||||
|
m_Name = Name;
|
||||||
|
m_StartDate = StartDate;
|
||||||
|
m_EndDate = EndDate;
|
||||||
|
m_YearStartDate = YearStartDate;
|
||||||
|
} //
|
||||||
|
|
||||||
|
private int m_C_Period_ID;
|
||||||
|
private String m_Name;
|
||||||
|
private Timestamp m_StartDate;
|
||||||
|
private Timestamp m_EndDate;
|
||||||
|
private Timestamp m_YearStartDate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Period Info
|
||||||
|
* @return BETWEEN start AND end
|
||||||
|
*/
|
||||||
|
public String getPeriodWhere ()
|
||||||
|
{
|
||||||
|
StringBuilder sql = new StringBuilder ("BETWEEN ");
|
||||||
|
sql.append(DB.TO_DATE(m_StartDate))
|
||||||
|
.append(" AND ")
|
||||||
|
.append(DB.TO_DATE(m_EndDate));
|
||||||
|
return sql.toString();
|
||||||
|
} // getPeriodWhere
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Year Info
|
||||||
|
* @return BETWEEN start AND end
|
||||||
|
*/
|
||||||
|
public String getYearWhere ()
|
||||||
|
{
|
||||||
|
StringBuilder sql = new StringBuilder ("BETWEEN ");
|
||||||
|
sql.append(DB.TO_DATE(m_YearStartDate))
|
||||||
|
.append(" AND ")
|
||||||
|
.append(DB.TO_DATE(m_EndDate));
|
||||||
|
return sql.toString();
|
||||||
|
} // getPeriodWhere
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Total Info
|
||||||
|
* @return <= end
|
||||||
|
*/
|
||||||
|
public String getTotalWhere ()
|
||||||
|
{
|
||||||
|
StringBuilder sql = new StringBuilder ("<= ");
|
||||||
|
sql.append(DB.TO_DATE(m_EndDate));
|
||||||
|
return sql.toString();
|
||||||
|
} // getPeriodWhere
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is date in period
|
||||||
|
* @param date date
|
||||||
|
* @return true if in period
|
||||||
|
*/
|
||||||
|
public boolean inPeriod (Timestamp date)
|
||||||
|
{
|
||||||
|
if (date == null)
|
||||||
|
return false;
|
||||||
|
if (date.before(m_StartDate))
|
||||||
|
return false;
|
||||||
|
if (date.after(m_EndDate))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
} // inPeriod
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return m_Name;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get C_Period_ID
|
||||||
|
* @return period
|
||||||
|
*/
|
||||||
|
public int getC_Period_ID()
|
||||||
|
{
|
||||||
|
return m_C_Period_ID;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get End Date
|
||||||
|
* @return end date
|
||||||
|
*/
|
||||||
|
public Timestamp getEndDate()
|
||||||
|
{
|
||||||
|
return m_EndDate;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get Start Date
|
||||||
|
* @return start date
|
||||||
|
*/
|
||||||
|
public Timestamp getStartDate()
|
||||||
|
{
|
||||||
|
return m_StartDate;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get Year Start Date
|
||||||
|
* @return year start date
|
||||||
|
*/
|
||||||
|
public Timestamp getYearStartDate()
|
||||||
|
{
|
||||||
|
return m_YearStartDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get natural balance dateacct filter
|
||||||
|
* @param alias table name or alias name
|
||||||
|
* @return is balance sheet a/c and <= end or BETWEEN start AND end
|
||||||
|
*/
|
||||||
|
public String getNaturalWhere(String alias) {
|
||||||
|
String yearWhere = getYearWhere();
|
||||||
|
String totalWhere = getTotalWhere();
|
||||||
|
String bs = " EXISTS (SELECT C_ElementValue_ID FROM C_ElementValue WHERE C_ElementValue_ID = " + alias + ".Account_ID AND AccountType NOT IN ('R', 'E'))";
|
||||||
|
String full = totalWhere + " AND ( " + bs + " OR TRUNC(" + alias + ".DateAcct) " + yearWhere + " ) ";
|
||||||
|
|
||||||
|
return full;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // FinReportPeriod
|
||||||
Loading…
Reference in New Issue