reverting rev.10291 - EOL problem
This commit is contained in:
parent
70f952af1b
commit
db1daa7922
File diff suppressed because it is too large
Load Diff
|
@ -1,367 +1,327 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* 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 *
|
* 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 *
|
* 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 *
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
* See the GNU General Public License for more details. *
|
* See the GNU General Public License for more details. *
|
||||||
* You should have received a copy of the GNU General Public License along *
|
* 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., *
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* 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 *
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.report;
|
package org.compiere.report;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.compiere.model.MAcctSchemaElement;
|
import org.compiere.model.MAcctSchemaElement;
|
||||||
import org.compiere.model.MElementValue;
|
import org.compiere.model.MElementValue;
|
||||||
import org.compiere.model.MPeriod;
|
import org.compiere.model.MPeriod;
|
||||||
import org.compiere.print.MPrintFormat;
|
import org.compiere.print.MPrintFormat;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
import org.compiere.process.SvrProcess;
|
import org.compiere.process.SvrProcess;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Ini;
|
import org.compiere.util.Ini;
|
||||||
import org.compiere.util.Language;
|
import org.compiere.util.Language;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Statement of Account
|
* Statement of Account
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: FinStatement.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
|
* @version $Id: FinStatement.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
* - Remove update balance option to resolved Feature Request [ 1557707 ] and
|
* - Remove update balance option to resolved Feature Request [ 1557707 ] and
|
||||||
* bug [1619917]
|
* bug [1619917]
|
||||||
*
|
*
|
||||||
* @author victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
|
* @author victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
|
||||||
* <li> FR [ 2520591 ] Support multiples calendar for Org
|
* <li> FR [ 2520591 ] Support multiples calendar for Org
|
||||||
* @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
|
* @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
|
||||||
*
|
*/
|
||||||
* @author Armen Rizal, Goodwill Consulting
|
public class FinStatement extends SvrProcess
|
||||||
* <li>FR [2857076] User Element 1 and 2 completion - https://sourceforge.net/tracker/?func=detail&aid=2857076&group_id=176962&atid=879335
|
{
|
||||||
*/
|
/** AcctSchame Parameter */
|
||||||
public class FinStatement extends SvrProcess
|
private int p_C_AcctSchema_ID = 0;
|
||||||
{
|
/** Posting Type */
|
||||||
/** AcctSchame Parameter */
|
private String p_PostingType = "A";
|
||||||
private int p_C_AcctSchema_ID = 0;
|
/** Period Parameter */
|
||||||
/** Posting Type */
|
private int p_C_Period_ID = 0;
|
||||||
private String p_PostingType = "A";
|
private Timestamp p_DateAcct_From = null;
|
||||||
/** Period Parameter */
|
private Timestamp p_DateAcct_To = null;
|
||||||
private int p_C_Period_ID = 0;
|
/** Org Parameter */
|
||||||
private Timestamp p_DateAcct_From = null;
|
private int p_AD_Org_ID = 0;
|
||||||
private Timestamp p_DateAcct_To = null;
|
/** Account Parameter */
|
||||||
/** Org Parameter */
|
private int p_Account_ID = 0;
|
||||||
private int p_AD_Org_ID = 0;
|
/** BPartner Parameter */
|
||||||
/** Account Parameter */
|
private int p_C_BPartner_ID = 0;
|
||||||
private int p_Account_ID = 0;
|
/** Product Parameter */
|
||||||
/** BPartner Parameter */
|
private int p_M_Product_ID = 0;
|
||||||
private int p_C_BPartner_ID = 0;
|
/** Project Parameter */
|
||||||
/** Product Parameter */
|
private int p_C_Project_ID = 0;
|
||||||
private int p_M_Product_ID = 0;
|
/** Activity Parameter */
|
||||||
/** Project Parameter */
|
private int p_C_Activity_ID = 0;
|
||||||
private int p_C_Project_ID = 0;
|
/** SalesRegion Parameter */
|
||||||
/** Activity Parameter */
|
private int p_C_SalesRegion_ID = 0;
|
||||||
private int p_C_Activity_ID = 0;
|
/** Campaign Parameter */
|
||||||
/** SalesRegion Parameter */
|
private int p_C_Campaign_ID = 0;
|
||||||
private int p_C_SalesRegion_ID = 0;
|
/** Hierarchy */
|
||||||
/** Campaign Parameter */
|
private int p_PA_Hierarchy_ID = 0;
|
||||||
private int p_C_Campaign_ID = 0;
|
|
||||||
//AZ Goodwill
|
/** Parameter Where Clause */
|
||||||
/** User List 1 Parameter */
|
private StringBuffer m_parameterWhere = new StringBuffer();
|
||||||
private int p_User1_ID = 0;
|
/** Account */
|
||||||
/** User List 2 Parameter */
|
private MElementValue m_acct = null;
|
||||||
private int p_User2_ID = 0;
|
|
||||||
/** User Element 1 Parameter */
|
/** Start Time */
|
||||||
private int p_UserElement1_ID = 0;
|
private long m_start = System.currentTimeMillis();
|
||||||
/** User Element 2 Parameter */
|
|
||||||
private int p_UserElement2_ID = 0;
|
/**
|
||||||
//end AZ
|
* Prepare - e.g., get Parameters.
|
||||||
/** Hierarchy */
|
*/
|
||||||
private int p_PA_Hierarchy_ID = 0;
|
protected void prepare()
|
||||||
|
{
|
||||||
/** Parameter Where Clause */
|
StringBuffer sb = new StringBuffer ("Record_ID=")
|
||||||
private StringBuffer m_parameterWhere = new StringBuffer();
|
.append(getRecord_ID());
|
||||||
/** Account */
|
// Parameter
|
||||||
private MElementValue m_acct = null;
|
ProcessInfoParameter[] para = getParameter();
|
||||||
|
for (int i = 0; i < para.length; i++)
|
||||||
/** Start Time */
|
{
|
||||||
private long m_start = System.currentTimeMillis();
|
String name = para[i].getParameterName();
|
||||||
|
if (para[i].getParameter() == null)
|
||||||
/**
|
;
|
||||||
* Prepare - e.g., get Parameters.
|
else if (name.equals("C_AcctSchema_ID"))
|
||||||
*/
|
p_C_AcctSchema_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
protected void prepare()
|
else if (name.equals("PostingType"))
|
||||||
{
|
p_PostingType = (String)para[i].getParameter();
|
||||||
StringBuffer sb = new StringBuffer ("Record_ID=")
|
else if (name.equals("C_Period_ID"))
|
||||||
.append(getRecord_ID());
|
p_C_Period_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
// Parameter
|
else if (name.equals("DateAcct"))
|
||||||
ProcessInfoParameter[] para = getParameter();
|
{
|
||||||
for (int i = 0; i < para.length; i++)
|
p_DateAcct_From = (Timestamp)para[i].getParameter();
|
||||||
{
|
p_DateAcct_To = (Timestamp)para[i].getParameter_To();
|
||||||
String name = para[i].getParameterName();
|
}
|
||||||
if (para[i].getParameter() == null)
|
else if (name.equals("PA_Hierarchy_ID"))
|
||||||
;
|
p_PA_Hierarchy_ID = para[i].getParameterAsInt();
|
||||||
else if (name.equals("C_AcctSchema_ID"))
|
else if (name.equals("AD_Org_ID"))
|
||||||
p_C_AcctSchema_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
p_AD_Org_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
else if (name.equals("PostingType"))
|
else if (name.equals("Account_ID"))
|
||||||
p_PostingType = (String)para[i].getParameter();
|
p_Account_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
else if (name.equals("C_Period_ID"))
|
else if (name.equals("C_BPartner_ID"))
|
||||||
p_C_Period_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
p_C_BPartner_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
else if (name.equals("DateAcct"))
|
else if (name.equals("M_Product_ID"))
|
||||||
{
|
p_M_Product_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
p_DateAcct_From = (Timestamp)para[i].getParameter();
|
else if (name.equals("C_Project_ID"))
|
||||||
p_DateAcct_To = (Timestamp)para[i].getParameter_To();
|
p_C_Project_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
}
|
else if (name.equals("C_Activity_ID"))
|
||||||
else if (name.equals("PA_Hierarchy_ID"))
|
p_C_Activity_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
p_PA_Hierarchy_ID = para[i].getParameterAsInt();
|
else if (name.equals("C_SalesRegion_ID"))
|
||||||
else if (name.equals("AD_Org_ID"))
|
p_C_SalesRegion_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
p_AD_Org_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
else if (name.equals("C_Campaign_ID"))
|
||||||
else if (name.equals("Account_ID"))
|
p_C_Campaign_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||||
p_Account_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
else
|
||||||
else if (name.equals("C_BPartner_ID"))
|
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||||
p_C_BPartner_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
}
|
||||||
else if (name.equals("M_Product_ID"))
|
// Mandatory C_AcctSchema_ID, PostingType
|
||||||
p_M_Product_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
m_parameterWhere.append("C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
|
||||||
else if (name.equals("C_Project_ID"))
|
.append(" AND PostingType='").append(p_PostingType).append("'");
|
||||||
p_C_Project_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
// Optional Account_ID
|
||||||
else if (name.equals("C_Activity_ID"))
|
if (p_Account_ID != 0)
|
||||||
p_C_Activity_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
||||||
else if (name.equals("C_SalesRegion_ID"))
|
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Account, p_Account_ID));
|
||||||
p_C_SalesRegion_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
// Optional Org
|
||||||
else if (name.equals("C_Campaign_ID"))
|
if (p_AD_Org_ID != 0)
|
||||||
p_C_Campaign_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
||||||
//AZ Goodwill
|
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Organization, p_AD_Org_ID));
|
||||||
else if (name.equals("User1_ID"))
|
// Optional BPartner
|
||||||
p_User1_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
if (p_C_BPartner_ID != 0)
|
||||||
else if (name.equals("User2_ID"))
|
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
||||||
p_User2_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_BPartner, p_C_BPartner_ID));
|
||||||
else if (name.equals("UserElement1_ID"))
|
// Optional Product
|
||||||
p_UserElement1_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
if (p_M_Product_ID != 0)
|
||||||
else if (name.equals("UserElement2_ID"))
|
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
||||||
p_UserElement2_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Product, p_M_Product_ID));
|
||||||
//end AZ
|
// Optional Project
|
||||||
else
|
if (p_C_Project_ID != 0)
|
||||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
||||||
}
|
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Project, p_C_Project_ID));
|
||||||
// Mandatory C_AcctSchema_ID, PostingType
|
// Optional Activity
|
||||||
m_parameterWhere.append("C_AcctSchema_ID=").append(p_C_AcctSchema_ID)
|
if (p_C_Activity_ID != 0)
|
||||||
.append(" AND PostingType='").append(p_PostingType).append("'");
|
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
||||||
// Optional Account_ID
|
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Activity, p_C_Activity_ID));
|
||||||
if (p_Account_ID != 0)
|
// Optional Campaign
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
if (p_C_Campaign_ID != 0)
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Account, p_Account_ID));
|
m_parameterWhere.append(" AND C_Campaign_ID=").append(p_C_Campaign_ID);
|
||||||
// Optional Org
|
// m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
||||||
if (p_AD_Org_ID != 0)
|
// MAcctSchemaElement.ELEMENTTYPE_Campaign, p_C_Campaign_ID));
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
// Optional Sales Region
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Organization, p_AD_Org_ID));
|
if (p_C_SalesRegion_ID != 0)
|
||||||
// Optional BPartner
|
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
||||||
if (p_C_BPartner_ID != 0)
|
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_SalesRegion, p_C_SalesRegion_ID));
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
//
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_BPartner, p_C_BPartner_ID));
|
setDateAcct();
|
||||||
// Optional Product
|
sb.append(" - DateAcct ").append(p_DateAcct_From).append("-").append(p_DateAcct_To);
|
||||||
if (p_M_Product_ID != 0)
|
sb.append(" - Where=").append(m_parameterWhere);
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
log.fine(sb.toString());
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Product, p_M_Product_ID));
|
} // prepare
|
||||||
// Optional Project
|
|
||||||
if (p_C_Project_ID != 0)
|
/**
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
* Set Start/End Date of Report - if not defined current Month
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Project, p_C_Project_ID));
|
*/
|
||||||
// Optional Activity
|
private void setDateAcct()
|
||||||
if (p_C_Activity_ID != 0)
|
{
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
// Date defined
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_Activity, p_C_Activity_ID));
|
if (p_DateAcct_From != null)
|
||||||
// Optional Campaign
|
{
|
||||||
if (p_C_Campaign_ID != 0)
|
if (p_DateAcct_To == null)
|
||||||
m_parameterWhere.append(" AND C_Campaign_ID=").append(p_C_Campaign_ID);
|
p_DateAcct_To = new Timestamp (System.currentTimeMillis());
|
||||||
// m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
return;
|
||||||
// MAcctSchemaElement.ELEMENTTYPE_Campaign, p_C_Campaign_ID));
|
}
|
||||||
// Optional Sales Region
|
// Get Date from Period
|
||||||
if (p_C_SalesRegion_ID != 0)
|
if (p_C_Period_ID == 0)
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
{
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_SalesRegion, p_C_SalesRegion_ID));
|
GregorianCalendar cal = new GregorianCalendar(Language.getLoginLanguage().getLocale());
|
||||||
//AZ Goodwill
|
cal.setTimeInMillis(System.currentTimeMillis());
|
||||||
// Optional User1_ID
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
if (p_User1_ID != 0)
|
cal.set(Calendar.MINUTE, 0);
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
cal.set(Calendar.SECOND, 0);
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_UserList1, p_User1_ID));
|
cal.set(Calendar.MILLISECOND, 0);
|
||||||
// Optional User2_ID
|
cal.set(Calendar.DAY_OF_MONTH, 1); // set to first of month
|
||||||
if (p_User2_ID != 0)
|
p_DateAcct_From = new Timestamp (cal.getTimeInMillis());
|
||||||
m_parameterWhere.append(" AND ").append(MReportTree.getWhereClause(getCtx(),
|
cal.add(Calendar.MONTH, 1);
|
||||||
p_PA_Hierarchy_ID, MAcctSchemaElement.ELEMENTTYPE_UserList2, p_User2_ID));
|
cal.add(Calendar.DAY_OF_YEAR, -1); // last of month
|
||||||
// Optional UserElement1_ID
|
p_DateAcct_To = new Timestamp (cal.getTimeInMillis());
|
||||||
if (p_UserElement1_ID != 0)
|
return;
|
||||||
m_parameterWhere.append(" AND UserElement1_ID=").append(p_UserElement1_ID);
|
}
|
||||||
// Optional UserElement2_ID
|
|
||||||
if (p_UserElement2_ID != 0)
|
String sql = "SELECT StartDate, EndDate FROM C_Period WHERE C_Period_ID=?";
|
||||||
m_parameterWhere.append(" AND UserElement2_ID=").append(p_UserElement2_ID);
|
PreparedStatement pstmt = null;
|
||||||
//end AZ
|
ResultSet rs = null;
|
||||||
|
try
|
||||||
//
|
{
|
||||||
setDateAcct();
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
sb.append(" - DateAcct ").append(p_DateAcct_From).append("-").append(p_DateAcct_To);
|
pstmt.setInt(1, p_C_Period_ID);
|
||||||
sb.append(" - Where=").append(m_parameterWhere);
|
rs = pstmt.executeQuery();
|
||||||
log.fine(sb.toString());
|
if (rs.next())
|
||||||
} // prepare
|
{
|
||||||
|
p_DateAcct_From = rs.getTimestamp(1);
|
||||||
/**
|
p_DateAcct_To = rs.getTimestamp(2);
|
||||||
* Set Start/End Date of Report - if not defined current Month
|
}
|
||||||
*/
|
}
|
||||||
private void setDateAcct()
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// Date defined
|
log.log(Level.SEVERE, sql, e);
|
||||||
if (p_DateAcct_From != null)
|
}
|
||||||
{
|
finally
|
||||||
if (p_DateAcct_To == null)
|
{
|
||||||
p_DateAcct_To = new Timestamp (System.currentTimeMillis());
|
DB.close(rs, pstmt);
|
||||||
return;
|
rs = null; pstmt = null;
|
||||||
}
|
}
|
||||||
// Get Date from Period
|
} // setDateAcct
|
||||||
if (p_C_Period_ID == 0)
|
|
||||||
{
|
|
||||||
GregorianCalendar cal = new GregorianCalendar(Language.getLoginLanguage().getLocale());
|
|
||||||
cal.setTimeInMillis(System.currentTimeMillis());
|
/**************************************************************************
|
||||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
* Perform process.
|
||||||
cal.set(Calendar.MINUTE, 0);
|
* @return Message to be translated
|
||||||
cal.set(Calendar.SECOND, 0);
|
*/
|
||||||
cal.set(Calendar.MILLISECOND, 0);
|
protected String doIt()
|
||||||
cal.set(Calendar.DAY_OF_MONTH, 1); // set to first of month
|
{
|
||||||
p_DateAcct_From = new Timestamp (cal.getTimeInMillis());
|
createBalanceLine();
|
||||||
cal.add(Calendar.MONTH, 1);
|
createDetailLines();
|
||||||
cal.add(Calendar.DAY_OF_YEAR, -1); // last of month
|
|
||||||
p_DateAcct_To = new Timestamp (cal.getTimeInMillis());
|
int AD_PrintFormat_ID = 134;
|
||||||
return;
|
if (Ini.isClient())
|
||||||
}
|
getProcessInfo().setTransientObject (MPrintFormat.get (getCtx(), AD_PrintFormat_ID, false));
|
||||||
|
else
|
||||||
String sql = "SELECT StartDate, EndDate FROM C_Period WHERE C_Period_ID=?";
|
getProcessInfo().setSerializableObject(MPrintFormat.get (getCtx(), AD_PrintFormat_ID, false));
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
log.fine((System.currentTimeMillis() - m_start) + " ms");
|
||||||
try
|
return "";
|
||||||
{
|
} // doIt
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
|
||||||
pstmt.setInt(1, p_C_Period_ID);
|
/**
|
||||||
rs = pstmt.executeQuery();
|
* Create Beginning Balance Line
|
||||||
if (rs.next())
|
*/
|
||||||
{
|
private void createBalanceLine()
|
||||||
p_DateAcct_From = rs.getTimestamp(1);
|
{
|
||||||
p_DateAcct_To = rs.getTimestamp(2);
|
StringBuffer sb = new StringBuffer ("INSERT INTO T_ReportStatement "
|
||||||
}
|
+ "(AD_PInstance_ID, Fact_Acct_ID, LevelNo,"
|
||||||
}
|
+ "DateAcct, Name, Description,"
|
||||||
catch (Exception e)
|
+ "AmtAcctDr, AmtAcctCr, Balance, Qty) ");
|
||||||
{
|
sb.append("SELECT ").append(getAD_PInstance_ID()).append(",0,0,")
|
||||||
log.log(Level.SEVERE, sql, e);
|
.append(DB.TO_DATE(p_DateAcct_From, true)).append(",")
|
||||||
}
|
.append(DB.TO_STRING(Msg.getMsg(Env.getCtx(), "BeginningBalance"))).append(",NULL,"
|
||||||
finally
|
+ "COALESCE(SUM(AmtAcctDr),0), COALESCE(SUM(AmtAcctCr),0), COALESCE(SUM(AmtAcctDr-AmtAcctCr),0), COALESCE(SUM(Qty),0) "
|
||||||
{
|
+ "FROM Fact_Acct "
|
||||||
DB.close(rs, pstmt);
|
+ "WHERE ").append(m_parameterWhere)
|
||||||
rs = null; pstmt = null;
|
.append(" AND TRUNC(DateAcct) < ").append(DB.TO_DATE(p_DateAcct_From));
|
||||||
}
|
|
||||||
} // setDateAcct
|
// Start Beginning of Year
|
||||||
|
if (p_Account_ID > 0)
|
||||||
|
{
|
||||||
|
m_acct = new MElementValue (getCtx(), p_Account_ID, get_TrxName());
|
||||||
/**************************************************************************
|
if (!m_acct.isBalanceSheet())
|
||||||
* Perform process.
|
{
|
||||||
* @return Message to be translated
|
MPeriod first = MPeriod.getFirstInYear (getCtx(), p_DateAcct_From, p_AD_Org_ID);
|
||||||
*/
|
if (first != null)
|
||||||
protected String doIt()
|
sb.append(" AND TRUNC(DateAcct) >= ").append(DB.TO_DATE(first.getStartDate()));
|
||||||
{
|
else
|
||||||
createBalanceLine();
|
log.log(Level.SEVERE, "First period not found");
|
||||||
createDetailLines();
|
}
|
||||||
|
}
|
||||||
int AD_PrintFormat_ID = 134;
|
//
|
||||||
if (Ini.isClient())
|
int no = DB.executeUpdate(sb.toString(), get_TrxName());
|
||||||
getProcessInfo().setTransientObject (MPrintFormat.get (getCtx(), AD_PrintFormat_ID, false));
|
log.fine("#" + no + " (Account_ID=" + p_Account_ID + ")");
|
||||||
else
|
log.finest(sb.toString());
|
||||||
getProcessInfo().setSerializableObject(MPrintFormat.get (getCtx(), AD_PrintFormat_ID, false));
|
} // createBalanceLine
|
||||||
|
|
||||||
log.fine((System.currentTimeMillis() - m_start) + " ms");
|
/**
|
||||||
return "";
|
* Create Beginning Balance Line
|
||||||
} // doIt
|
*/
|
||||||
|
private void createDetailLines()
|
||||||
/**
|
{
|
||||||
* Create Beginning Balance Line
|
StringBuffer sb = new StringBuffer ("INSERT INTO T_ReportStatement "
|
||||||
*/
|
+ "(AD_PInstance_ID, Fact_Acct_ID, LevelNo,"
|
||||||
private void createBalanceLine()
|
+ "DateAcct, Name, Description,"
|
||||||
{
|
+ "AmtAcctDr, AmtAcctCr, Balance, Qty) ");
|
||||||
StringBuffer sb = new StringBuffer ("INSERT INTO T_ReportStatement "
|
sb.append("SELECT ").append(getAD_PInstance_ID()).append(",Fact_Acct_ID,1,")
|
||||||
+ "(AD_PInstance_ID, Fact_Acct_ID, LevelNo,"
|
.append("TRUNC(DateAcct),NULL,NULL,"
|
||||||
+ "DateAcct, Name, Description,"
|
+ "AmtAcctDr, AmtAcctCr, AmtAcctDr-AmtAcctCr, Qty "
|
||||||
+ "AmtAcctDr, AmtAcctCr, Balance, Qty) ");
|
+ "FROM Fact_Acct "
|
||||||
sb.append("SELECT ").append(getAD_PInstance_ID()).append(",0,0,")
|
+ "WHERE ").append(m_parameterWhere)
|
||||||
.append(DB.TO_DATE(p_DateAcct_From, true)).append(",")
|
.append(" AND TRUNC(DateAcct) BETWEEN ").append(DB.TO_DATE(p_DateAcct_From))
|
||||||
.append(DB.TO_STRING(Msg.getMsg(Env.getCtx(), "BeginningBalance"))).append(",NULL,"
|
.append(" AND ").append(DB.TO_DATE(p_DateAcct_To));
|
||||||
+ "COALESCE(SUM(AmtAcctDr),0), COALESCE(SUM(AmtAcctCr),0), COALESCE(SUM(AmtAcctDr-AmtAcctCr),0), COALESCE(SUM(Qty),0) "
|
//
|
||||||
+ "FROM Fact_Acct "
|
int no = DB.executeUpdate(sb.toString(), get_TrxName());
|
||||||
+ "WHERE ").append(m_parameterWhere)
|
log.fine("#" + no);
|
||||||
.append(" AND TRUNC(DateAcct) < ").append(DB.TO_DATE(p_DateAcct_From));
|
log.finest(sb.toString());
|
||||||
|
|
||||||
// Start Beginning of Year
|
// Set Name,Description
|
||||||
if (p_Account_ID > 0)
|
String sql_select = "SELECT e.Name, fa.Description "
|
||||||
{
|
+ "FROM Fact_Acct fa"
|
||||||
m_acct = new MElementValue (getCtx(), p_Account_ID, get_TrxName());
|
+ " INNER JOIN AD_Table t ON (fa.AD_Table_ID=t.AD_Table_ID)"
|
||||||
if (!m_acct.isBalanceSheet())
|
+ " INNER JOIN AD_Element e ON (t.TableName||'_ID'=e.ColumnName) "
|
||||||
{
|
+ "WHERE r.Fact_Acct_ID=fa.Fact_Acct_ID";
|
||||||
MPeriod first = MPeriod.getFirstInYear (getCtx(), p_DateAcct_From, p_AD_Org_ID);
|
// Translated Version ...
|
||||||
if (first != null)
|
sb = new StringBuffer ("UPDATE T_ReportStatement r SET (Name,Description)=(")
|
||||||
sb.append(" AND TRUNC(DateAcct) >= ").append(DB.TO_DATE(first.getStartDate()));
|
.append(sql_select).append(") "
|
||||||
else
|
+ "WHERE Fact_Acct_ID <> 0 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
|
||||||
log.log(Level.SEVERE, "First period not found");
|
//
|
||||||
}
|
no = DB.executeUpdate(sb.toString(), get_TrxName());
|
||||||
}
|
log.fine("Name #" + no);
|
||||||
//
|
log.finest("Name - " + sb);
|
||||||
int no = DB.executeUpdate(sb.toString(), get_TrxName());
|
|
||||||
log.fine("#" + no + " (Account_ID=" + p_Account_ID + ")");
|
} // createDetailLines
|
||||||
log.finest(sb.toString());
|
|
||||||
} // createBalanceLine
|
} // FinStatement
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Beginning Balance Line
|
|
||||||
*/
|
|
||||||
private void createDetailLines()
|
|
||||||
{
|
|
||||||
StringBuffer sb = new StringBuffer ("INSERT INTO T_ReportStatement "
|
|
||||||
+ "(AD_PInstance_ID, Fact_Acct_ID, LevelNo,"
|
|
||||||
+ "DateAcct, Name, Description,"
|
|
||||||
+ "AmtAcctDr, AmtAcctCr, Balance, Qty) ");
|
|
||||||
sb.append("SELECT ").append(getAD_PInstance_ID()).append(",Fact_Acct_ID,1,")
|
|
||||||
.append("TRUNC(DateAcct),NULL,NULL,"
|
|
||||||
+ "AmtAcctDr, AmtAcctCr, AmtAcctDr-AmtAcctCr, Qty "
|
|
||||||
+ "FROM Fact_Acct "
|
|
||||||
+ "WHERE ").append(m_parameterWhere)
|
|
||||||
.append(" AND TRUNC(DateAcct) BETWEEN ").append(DB.TO_DATE(p_DateAcct_From))
|
|
||||||
.append(" AND ").append(DB.TO_DATE(p_DateAcct_To));
|
|
||||||
//
|
|
||||||
int no = DB.executeUpdate(sb.toString(), get_TrxName());
|
|
||||||
log.fine("#" + no);
|
|
||||||
log.finest(sb.toString());
|
|
||||||
|
|
||||||
// Set Name,Description
|
|
||||||
String sql_select = "SELECT e.Name, fa.Description "
|
|
||||||
+ "FROM Fact_Acct fa"
|
|
||||||
+ " INNER JOIN AD_Table t ON (fa.AD_Table_ID=t.AD_Table_ID)"
|
|
||||||
+ " INNER JOIN AD_Element e ON (t.TableName||'_ID'=e.ColumnName) "
|
|
||||||
+ "WHERE r.Fact_Acct_ID=fa.Fact_Acct_ID";
|
|
||||||
// Translated Version ...
|
|
||||||
sb = new StringBuffer ("UPDATE T_ReportStatement r SET (Name,Description)=(")
|
|
||||||
.append(sql_select).append(") "
|
|
||||||
+ "WHERE Fact_Acct_ID <> 0 AND AD_PInstance_ID=").append(getAD_PInstance_ID());
|
|
||||||
//
|
|
||||||
no = DB.executeUpdate(sb.toString(), get_TrxName());
|
|
||||||
log.fine("Name #" + no);
|
|
||||||
log.finest("Name - " + sb);
|
|
||||||
|
|
||||||
} // createDetailLines
|
|
||||||
|
|
||||||
} // FinStatement
|
|
||||||
|
|
Loading…
Reference in New Issue