FR2793242 Fact Acct Summary
https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2793242&group_id=176962
This commit is contained in:
parent
0c973e7eeb
commit
50112175b6
|
@ -225,6 +225,30 @@ public interface I_PA_Report
|
|||
|
||||
public I_PA_ReportColumnSet getPA_ReportColumnSet() throws RuntimeException;
|
||||
|
||||
/** Column name PA_ReportCube_ID */
|
||||
public static final String COLUMNNAME_PA_ReportCube_ID = "PA_ReportCube_ID";
|
||||
|
||||
/** Set Report Cube.
|
||||
* Define reporting cube for pre-calculation of summary accounting data.
|
||||
*/
|
||||
public void setPA_ReportCube_ID (int PA_ReportCube_ID);
|
||||
|
||||
/** Get Report Cube.
|
||||
* Define reporting cube for pre-calculation of summary accounting data.
|
||||
*/
|
||||
public int getPA_ReportCube_ID();
|
||||
|
||||
/** Column name PA_ReportLineSet_ID */
|
||||
public static final String COLUMNNAME_PA_ReportLineSet_ID = "PA_ReportLineSet_ID";
|
||||
|
||||
/** Set Report Line Set */
|
||||
public void setPA_ReportLineSet_ID (int PA_ReportLineSet_ID);
|
||||
|
||||
/** Get Report Line Set */
|
||||
public int getPA_ReportLineSet_ID();
|
||||
|
||||
public I_PA_ReportLineSet getPA_ReportLineSet() throws RuntimeException;
|
||||
|
||||
/** Column name PA_Report_ID */
|
||||
public static final String COLUMNNAME_PA_Report_ID = "PA_Report_ID";
|
||||
|
||||
|
@ -238,17 +262,6 @@ public interface I_PA_Report
|
|||
*/
|
||||
public int getPA_Report_ID();
|
||||
|
||||
/** Column name PA_ReportLineSet_ID */
|
||||
public static final String COLUMNNAME_PA_ReportLineSet_ID = "PA_ReportLineSet_ID";
|
||||
|
||||
/** Set Report Line Set */
|
||||
public void setPA_ReportLineSet_ID (int PA_ReportLineSet_ID);
|
||||
|
||||
/** Get Report Line Set */
|
||||
public int getPA_ReportLineSet_ID();
|
||||
|
||||
public I_PA_ReportLineSet getPA_ReportLineSet() throws RuntimeException;
|
||||
|
||||
/** Column name Processing */
|
||||
public static final String COLUMNNAME_Processing = "Processing";
|
||||
|
||||
|
|
|
@ -0,0 +1,406 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 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.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
/** Generated Interface for PA_ReportCube
|
||||
* @author Adempiere (generated)
|
||||
* @version Release 3.5.3a
|
||||
*/
|
||||
public interface I_PA_ReportCube
|
||||
{
|
||||
|
||||
/** TableName=PA_ReportCube */
|
||||
public static final String Table_Name = "PA_ReportCube";
|
||||
|
||||
/** AD_Table_ID=53202 */
|
||||
public static final int Table_ID = MTable.getTable_ID(Table_Name);
|
||||
|
||||
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
||||
|
||||
/** AccessLevel = 3 - Client - Org
|
||||
*/
|
||||
BigDecimal accessLevel = BigDecimal.valueOf(3);
|
||||
|
||||
/** Load Meta Data */
|
||||
|
||||
/** Column name AD_Client_ID */
|
||||
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
||||
|
||||
/** Get Client.
|
||||
* Client/Tenant for this installation.
|
||||
*/
|
||||
public int getAD_Client_ID();
|
||||
|
||||
/** Column name AD_Org_ID */
|
||||
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
|
||||
|
||||
/** Set Organization.
|
||||
* Organizational entity within client
|
||||
*/
|
||||
public void setAD_Org_ID (int AD_Org_ID);
|
||||
|
||||
/** Get Organization.
|
||||
* Organizational entity within client
|
||||
*/
|
||||
public int getAD_Org_ID();
|
||||
|
||||
/** Column name C_Calendar_ID */
|
||||
public static final String COLUMNNAME_C_Calendar_ID = "C_Calendar_ID";
|
||||
|
||||
/** Set Calendar.
|
||||
* Accounting Calendar Name
|
||||
*/
|
||||
public void setC_Calendar_ID (int C_Calendar_ID);
|
||||
|
||||
/** Get Calendar.
|
||||
* Accounting Calendar Name
|
||||
*/
|
||||
public int getC_Calendar_ID();
|
||||
|
||||
public I_C_Calendar getC_Calendar() throws RuntimeException;
|
||||
|
||||
/** Column name Created */
|
||||
public static final String COLUMNNAME_Created = "Created";
|
||||
|
||||
/** Get Created.
|
||||
* Date this record was created
|
||||
*/
|
||||
public Timestamp getCreated();
|
||||
|
||||
/** Column name CreatedBy */
|
||||
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
|
||||
|
||||
/** Get Created By.
|
||||
* User who created this records
|
||||
*/
|
||||
public int getCreatedBy();
|
||||
|
||||
/** Column name Description */
|
||||
public static final String COLUMNNAME_Description = "Description";
|
||||
|
||||
/** Set Description.
|
||||
* Optional short description of the record
|
||||
*/
|
||||
public void setDescription (String Description);
|
||||
|
||||
/** Get Description.
|
||||
* Optional short description of the record
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/** Column name IsActive */
|
||||
public static final String COLUMNNAME_IsActive = "IsActive";
|
||||
|
||||
/** Set Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public void setIsActive (boolean IsActive);
|
||||
|
||||
/** Get Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public boolean isActive();
|
||||
|
||||
/** Column name IsActivityDim */
|
||||
public static final String COLUMNNAME_IsActivityDim = "IsActivityDim";
|
||||
|
||||
/** Set Activity Dimension.
|
||||
* Include Activity as a cube dimension
|
||||
*/
|
||||
public void setIsActivityDim (boolean IsActivityDim);
|
||||
|
||||
/** Get Activity Dimension.
|
||||
* Include Activity as a cube dimension
|
||||
*/
|
||||
public boolean isActivityDim();
|
||||
|
||||
/** Column name IsBPartnerDim */
|
||||
public static final String COLUMNNAME_IsBPartnerDim = "IsBPartnerDim";
|
||||
|
||||
/** Set Business Partner Dimension.
|
||||
* Include Business Partner as a cube dimension
|
||||
*/
|
||||
public void setIsBPartnerDim (boolean IsBPartnerDim);
|
||||
|
||||
/** Get Business Partner Dimension.
|
||||
* Include Business Partner as a cube dimension
|
||||
*/
|
||||
public boolean isBPartnerDim();
|
||||
|
||||
/** Column name IsCampaignDim */
|
||||
public static final String COLUMNNAME_IsCampaignDim = "IsCampaignDim";
|
||||
|
||||
/** Set Campaign Dimension.
|
||||
* Include Campaign as a cube dimension
|
||||
*/
|
||||
public void setIsCampaignDim (boolean IsCampaignDim);
|
||||
|
||||
/** Get Campaign Dimension.
|
||||
* Include Campaign as a cube dimension
|
||||
*/
|
||||
public boolean isCampaignDim();
|
||||
|
||||
/** Column name IsGLBudgetDim */
|
||||
public static final String COLUMNNAME_IsGLBudgetDim = "IsGLBudgetDim";
|
||||
|
||||
/** Set GL Budget Dimension.
|
||||
* Include GL Budget as a cube dimension
|
||||
*/
|
||||
public void setIsGLBudgetDim (boolean IsGLBudgetDim);
|
||||
|
||||
/** Get GL Budget Dimension.
|
||||
* Include GL Budget as a cube dimension
|
||||
*/
|
||||
public boolean isGLBudgetDim();
|
||||
|
||||
/** Column name IsLocFromDim */
|
||||
public static final String COLUMNNAME_IsLocFromDim = "IsLocFromDim";
|
||||
|
||||
/** Set Location From Dimension.
|
||||
* Include Location From as a cube dimension
|
||||
*/
|
||||
public void setIsLocFromDim (boolean IsLocFromDim);
|
||||
|
||||
/** Get Location From Dimension.
|
||||
* Include Location From as a cube dimension
|
||||
*/
|
||||
public boolean isLocFromDim();
|
||||
|
||||
/** Column name IsLocToDim */
|
||||
public static final String COLUMNNAME_IsLocToDim = "IsLocToDim";
|
||||
|
||||
/** Set Location To Dimension.
|
||||
* Include Location To as a cube dimension
|
||||
*/
|
||||
public void setIsLocToDim (boolean IsLocToDim);
|
||||
|
||||
/** Get Location To Dimension.
|
||||
* Include Location To as a cube dimension
|
||||
*/
|
||||
public boolean isLocToDim();
|
||||
|
||||
/** Column name IsOrgTrxDim */
|
||||
public static final String COLUMNNAME_IsOrgTrxDim = "IsOrgTrxDim";
|
||||
|
||||
/** Set OrgTrx Dimension.
|
||||
* Include OrgTrx as a cube dimension
|
||||
*/
|
||||
public void setIsOrgTrxDim (boolean IsOrgTrxDim);
|
||||
|
||||
/** Get OrgTrx Dimension.
|
||||
* Include OrgTrx as a cube dimension
|
||||
*/
|
||||
public boolean isOrgTrxDim();
|
||||
|
||||
/** Column name IsProductDim */
|
||||
public static final String COLUMNNAME_IsProductDim = "IsProductDim";
|
||||
|
||||
/** Set Product Dimension.
|
||||
* Include Product as a cube dimension
|
||||
*/
|
||||
public void setIsProductDim (boolean IsProductDim);
|
||||
|
||||
/** Get Product Dimension.
|
||||
* Include Product as a cube dimension
|
||||
*/
|
||||
public boolean isProductDim();
|
||||
|
||||
/** Column name IsProjectDim */
|
||||
public static final String COLUMNNAME_IsProjectDim = "IsProjectDim";
|
||||
|
||||
/** Set Project Dimension.
|
||||
* Include Project as a cube dimension
|
||||
*/
|
||||
public void setIsProjectDim (boolean IsProjectDim);
|
||||
|
||||
/** Get Project Dimension.
|
||||
* Include Project as a cube dimension
|
||||
*/
|
||||
public boolean isProjectDim();
|
||||
|
||||
/** Column name IsProjectPhaseDim */
|
||||
public static final String COLUMNNAME_IsProjectPhaseDim = "IsProjectPhaseDim";
|
||||
|
||||
/** Set Project Phase Dimension.
|
||||
* Include Project Phase as a cube dimension
|
||||
*/
|
||||
public void setIsProjectPhaseDim (boolean IsProjectPhaseDim);
|
||||
|
||||
/** Get Project Phase Dimension.
|
||||
* Include Project Phase as a cube dimension
|
||||
*/
|
||||
public boolean isProjectPhaseDim();
|
||||
|
||||
/** Column name IsProjectTaskDim */
|
||||
public static final String COLUMNNAME_IsProjectTaskDim = "IsProjectTaskDim";
|
||||
|
||||
/** Set Project Task Dimension.
|
||||
* Include Project Task as a cube dimension
|
||||
*/
|
||||
public void setIsProjectTaskDim (boolean IsProjectTaskDim);
|
||||
|
||||
/** Get Project Task Dimension.
|
||||
* Include Project Task as a cube dimension
|
||||
*/
|
||||
public boolean isProjectTaskDim();
|
||||
|
||||
/** Column name IsSalesRegionDim */
|
||||
public static final String COLUMNNAME_IsSalesRegionDim = "IsSalesRegionDim";
|
||||
|
||||
/** Set Sales Region Dimension.
|
||||
* Include Sales Region as a cube dimension
|
||||
*/
|
||||
public void setIsSalesRegionDim (boolean IsSalesRegionDim);
|
||||
|
||||
/** Get Sales Region Dimension.
|
||||
* Include Sales Region as a cube dimension
|
||||
*/
|
||||
public boolean isSalesRegionDim();
|
||||
|
||||
/** Column name IsSubAcctDim */
|
||||
public static final String COLUMNNAME_IsSubAcctDim = "IsSubAcctDim";
|
||||
|
||||
/** Set Sub Acct Dimension.
|
||||
* Include Sub Acct as a cube dimension
|
||||
*/
|
||||
public void setIsSubAcctDim (boolean IsSubAcctDim);
|
||||
|
||||
/** Get Sub Acct Dimension.
|
||||
* Include Sub Acct as a cube dimension
|
||||
*/
|
||||
public boolean isSubAcctDim();
|
||||
|
||||
/** Column name IsUser1Dim */
|
||||
public static final String COLUMNNAME_IsUser1Dim = "IsUser1Dim";
|
||||
|
||||
/** Set User 1 Dimension.
|
||||
* Include User 1 as a cube dimension
|
||||
*/
|
||||
public void setIsUser1Dim (boolean IsUser1Dim);
|
||||
|
||||
/** Get User 1 Dimension.
|
||||
* Include User 1 as a cube dimension
|
||||
*/
|
||||
public boolean isUser1Dim();
|
||||
|
||||
/** Column name IsUser2Dim */
|
||||
public static final String COLUMNNAME_IsUser2Dim = "IsUser2Dim";
|
||||
|
||||
/** Set User 2 Dimension.
|
||||
* Include User 2 as a cube dimension
|
||||
*/
|
||||
public void setIsUser2Dim (boolean IsUser2Dim);
|
||||
|
||||
/** Get User 2 Dimension.
|
||||
* Include User 2 as a cube dimension
|
||||
*/
|
||||
public boolean isUser2Dim();
|
||||
|
||||
/** Column name IsUserElement1Dim */
|
||||
public static final String COLUMNNAME_IsUserElement1Dim = "IsUserElement1Dim";
|
||||
|
||||
/** Set User Element 1 Dimension.
|
||||
* Include User Element 1 as a cube dimension
|
||||
*/
|
||||
public void setIsUserElement1Dim (boolean IsUserElement1Dim);
|
||||
|
||||
/** Get User Element 1 Dimension.
|
||||
* Include User Element 1 as a cube dimension
|
||||
*/
|
||||
public boolean isUserElement1Dim();
|
||||
|
||||
/** Column name IsUserElement2Dim */
|
||||
public static final String COLUMNNAME_IsUserElement2Dim = "IsUserElement2Dim";
|
||||
|
||||
/** Set User Element 2 Dimension.
|
||||
* Include User Element 2 as a cube dimension
|
||||
*/
|
||||
public void setIsUserElement2Dim (boolean IsUserElement2Dim);
|
||||
|
||||
/** Get User Element 2 Dimension.
|
||||
* Include User Element 2 as a cube dimension
|
||||
*/
|
||||
public boolean isUserElement2Dim();
|
||||
|
||||
/** Column name LastRecalculated */
|
||||
public static final String COLUMNNAME_LastRecalculated = "LastRecalculated";
|
||||
|
||||
/** Set Last Recalculated.
|
||||
* The time last recalculated.
|
||||
*/
|
||||
public void setLastRecalculated (Timestamp LastRecalculated);
|
||||
|
||||
/** Get Last Recalculated.
|
||||
* The time last recalculated.
|
||||
*/
|
||||
public Timestamp getLastRecalculated();
|
||||
|
||||
/** Column name Name */
|
||||
public static final String COLUMNNAME_Name = "Name";
|
||||
|
||||
/** Set Name.
|
||||
* Alphanumeric identifier of the entity
|
||||
*/
|
||||
public void setName (String Name);
|
||||
|
||||
/** Get Name.
|
||||
* Alphanumeric identifier of the entity
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/** Column name PA_ReportCube_ID */
|
||||
public static final String COLUMNNAME_PA_ReportCube_ID = "PA_ReportCube_ID";
|
||||
|
||||
/** Set Report Cube.
|
||||
* Define reporting cube for pre-calculation of summary accounting data.
|
||||
*/
|
||||
public void setPA_ReportCube_ID (int PA_ReportCube_ID);
|
||||
|
||||
/** Get Report Cube.
|
||||
* Define reporting cube for pre-calculation of summary accounting data.
|
||||
*/
|
||||
public int getPA_ReportCube_ID();
|
||||
|
||||
/** Column name Processing */
|
||||
public static final String COLUMNNAME_Processing = "Processing";
|
||||
|
||||
/** Set Process Now */
|
||||
public void setProcessing (boolean Processing);
|
||||
|
||||
/** Get Process Now */
|
||||
public boolean isProcessing();
|
||||
|
||||
/** Column name Updated */
|
||||
public static final String COLUMNNAME_Updated = "Updated";
|
||||
|
||||
/** Get Updated.
|
||||
* Date this record was updated
|
||||
*/
|
||||
public Timestamp getUpdated();
|
||||
|
||||
/** Column name UpdatedBy */
|
||||
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
|
||||
|
||||
/** Get Updated By.
|
||||
* User who updated this records
|
||||
*/
|
||||
public int getUpdatedBy();
|
||||
}
|
|
@ -0,0 +1,231 @@
|
|||
/******************************************************************************
|
||||
* 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.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.X_PA_ReportCube;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
public class MReportCube extends X_PA_ReportCube {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1115698413818333478L;
|
||||
|
||||
public MReportCube(Properties ctx, int PA_ReportCube_ID, String trxName) {
|
||||
super(ctx, PA_ReportCube_ID, trxName);
|
||||
}
|
||||
|
||||
public MReportCube(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
public String update(boolean reset, boolean force) {
|
||||
|
||||
String result = getName() + ": ";
|
||||
Timestamp ts = null;
|
||||
long start;
|
||||
long elapsed;
|
||||
|
||||
String where = " WHERE PA_ReportCube_ID = " + getPA_ReportCube_ID();
|
||||
String periods = " (-1) ";
|
||||
if ( getLastRecalculated() != null && !reset )
|
||||
{
|
||||
StringBuilder periodList = new StringBuilder();
|
||||
StringBuilder periodNames = new StringBuilder();
|
||||
|
||||
String sql = "SELECT DISTINCT p.C_Period_ID, p.Name FROM C_Period p " +
|
||||
"INNER JOIN C_Year y ON (y.C_Year_ID=p.C_Year_ID) " +
|
||||
"INNER JOIN PA_ReportCube c ON (c.C_Calendar_ID = y.C_Calendar_ID) " +
|
||||
"INNER JOIN Fact_Acct fact ON (fact.dateacct between p.startdate and p.enddate " +
|
||||
" and fact.ad_client_id = c.ad_client_id) " +
|
||||
"WHERE c.PA_ReportCube_ID = ? " +
|
||||
"AND fact.updated > c.LastRecalculated " +
|
||||
"AND p.periodtype='S' ";
|
||||
|
||||
log.log (Level.FINE, sql);
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
KeyNamePair[] changedPeriods = DB.getKeyNamePairs(sql, false, getPA_ReportCube_ID());
|
||||
elapsed = (System.currentTimeMillis() - start)/1000;
|
||||
log.log(Level.FINE, "Selecting changed periods took:" + elapsed + "s");
|
||||
|
||||
if (changedPeriods != null && changedPeriods.length > 0 )
|
||||
{
|
||||
periodList.append(" (");
|
||||
for (KeyNamePair p : changedPeriods )
|
||||
{
|
||||
periodList.append(p.getID() + ", ");
|
||||
periodNames.append(p.getName() + ", ");
|
||||
}
|
||||
periodList.delete(periodList.length() - 2, periodList.length());
|
||||
periodList.append(" )");
|
||||
|
||||
log.log(Level.FINE, "Periods requiring update: " + periodNames.toString());
|
||||
}
|
||||
else
|
||||
return "Nothing to update in " + getName();
|
||||
|
||||
periods = periodList.toString();
|
||||
where += (" AND C_Period_ID IN " + periods);
|
||||
}
|
||||
|
||||
|
||||
if ( !force )
|
||||
{
|
||||
String lockSQL = "UPDATE PA_ReportCube SET Processing = 'Y' " +
|
||||
"WHERE Processing = 'N' AND PA_ReportCube_ID = " + getPA_ReportCube_ID();
|
||||
int locked = DB.executeUpdateEx(lockSQL, null); // outside trx
|
||||
if (locked != 1)
|
||||
{
|
||||
throw new AdempiereException("Unable to lock cube for update:" + getName());
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
// delete
|
||||
String delSQL = "DELETE FROM Fact_Acct_Summary fas " + where;
|
||||
log.log(Level.FINE, "Delete sql: " + delSQL);
|
||||
start = System.currentTimeMillis();
|
||||
int deleted = DB.executeUpdateEx(delSQL, get_TrxName());
|
||||
elapsed = (System.currentTimeMillis() - start)/1000;
|
||||
result += "Deleted " + deleted + " in " + elapsed + " s;";
|
||||
|
||||
log.log(Level.FINE, result);
|
||||
|
||||
// insert
|
||||
StringBuilder insert = new StringBuilder("INSERT " +
|
||||
"INTO FACT_ACCT_SUMMARY (PA_ReportCube_ID , AD_Client_ID, " +
|
||||
"AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, IsActive, " +
|
||||
"C_AcctSchema_ID, Account_ID, PostingType, " +
|
||||
"GL_Budget_ID, C_Period_ID, DateAcct, AmtAcctDr, AmtAcctCr, Qty");
|
||||
|
||||
StringBuilder select = new StringBuilder(" ) SELECT " +
|
||||
"?, f.AD_CLIENT_ID, f.AD_ORG_ID, " +
|
||||
"max(f.Created), max(f.CreatedBy), max(f.Updated), max(f.UpdatedBy), 'Y', " +
|
||||
"f.C_ACCTSCHEMA_ID, f.ACCOUNT_ID, f.POSTINGTYPE, GL_Budget_ID, " +
|
||||
"p.c_period_id, p.StartDate, COALESCE(SUM(AmtAcctDr),0), COALESCE(SUM(AmtAcctCr),0), " +
|
||||
"COALESCE(SUM(Qty),0)");
|
||||
String from = " FROM fact_acct f " +
|
||||
" INNER JOIN C_Period p ON ( f.DateAcct BETWEEN p.StartDate AND p.EndDate ) " +
|
||||
" INNER JOIN C_Year y ON ( p.C_Year_ID = y.C_Year_ID ) " +
|
||||
" WHERE p.PeriodType = 'S' " +
|
||||
" AND y.C_Calendar_ID = ? ";
|
||||
if ( getLastRecalculated() != null && !reset )
|
||||
from += "AND p.C_Period_ID IN " + periods;
|
||||
|
||||
StringBuilder groups = new StringBuilder(" GROUP BY " +
|
||||
"f.AD_CLIENT_ID, f.AD_ORG_ID, f.C_ACCTSCHEMA_ID, f.ACCOUNT_ID, " +
|
||||
"f.POSTINGTYPE, GL_Budget_ID, p.c_period_id, p.StartDate ");
|
||||
|
||||
ArrayList<String> values = new ArrayList<String>();
|
||||
|
||||
if ( isProductDim() )
|
||||
values.add("M_Product_ID");
|
||||
if ( isBPartnerDim() )
|
||||
values.add("C_BPartner_ID");
|
||||
if ( isProjectDim() )
|
||||
values.add("C_Project_ID");
|
||||
if ( isOrgTrxDim() )
|
||||
values.add("AD_OrgTrx_ID");
|
||||
if ( isSalesRegionDim() )
|
||||
values.add("C_SalesRegion_ID");
|
||||
if ( isActivityDim() )
|
||||
values.add("C_Activity_ID");
|
||||
if ( isCampaignDim() )
|
||||
values.add("C_Campaign_ID");
|
||||
if ( isLocToDim() )
|
||||
values.add("C_LocTo_ID");
|
||||
if ( isLocFromDim() )
|
||||
values.add("C_LocFrom_ID");
|
||||
if ( isUser1Dim() )
|
||||
values.add("User1_ID");
|
||||
if ( isUser2Dim() )
|
||||
values.add("User2_ID");
|
||||
if ( isUserElement1Dim() )
|
||||
values.add("UserElement1_ID");
|
||||
if ( isUserElement2Dim() )
|
||||
values.add("UserElement2_ID");
|
||||
if ( isSubAcctDim() )
|
||||
values.add("C_SubAcct_ID");
|
||||
if ( isProjectPhaseDim() )
|
||||
values.add("C_ProjectPhase_ID");
|
||||
if ( isProjectTaskDim() )
|
||||
values.add("C_ProjectTask_ID");
|
||||
|
||||
// --(CASE v.IsGL_Category_ID WHEN 'Y' THEN f."GL_Category_ID END) GL_Category_ID
|
||||
|
||||
Iterator<String> iter = values.iterator();
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
String dim = iter.next();
|
||||
insert.append(", " + dim );
|
||||
select.append(", f." + dim);
|
||||
groups.append(", f." + dim);
|
||||
}
|
||||
|
||||
|
||||
String sql = insert.append(select.toString()).append(from).append(groups.toString()).toString();
|
||||
log.log(Level.FINE, sql);
|
||||
Object[] params = new Object[] { getPA_ReportCube_ID(), getC_Calendar_ID() };
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
int rows = DB.executeUpdateEx(sql, params, get_TrxName());
|
||||
long seconds = (System.currentTimeMillis() - start)/1000;
|
||||
|
||||
String insertResult = "Inserted " + rows + " in " + seconds + " s.";
|
||||
log.log(Level.FINE, insertResult);
|
||||
result += insertResult;
|
||||
|
||||
|
||||
// set timestamp
|
||||
String tsSQL = "SELECT max(fas.Updated)" +
|
||||
" FROM Fact_Acct_Summary fas" +
|
||||
" WHERE fas.PA_ReportCube_ID = " + getPA_ReportCube_ID();
|
||||
ts = DB.getSQLValueTS(get_TrxName(), tsSQL);
|
||||
log.log(Level.FINE, "Last updated: " + ts);
|
||||
|
||||
}
|
||||
catch (DBException e)
|
||||
{
|
||||
// failure results in null timestamp => rebuild on next run
|
||||
// nothing else to do
|
||||
log.log(Level.FINE, getName() + " update failed:" + e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
// unlock
|
||||
String unlockSQL = "UPDATE PA_ReportCube SET Processing = 'N', " +
|
||||
"LastRecalculated = " + ( ts == null ? "null" : "?") +
|
||||
" WHERE PA_ReportCube_ID = " + getPA_ReportCube_ID();
|
||||
Object[] parameters = ts == null ? new Object[] {} : new Object[] {ts};
|
||||
DB.executeUpdateEx(unlockSQL, parameters, null); // outside trx
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -46,8 +46,8 @@ public class X_PA_Report extends PO implements I_PA_Report, I_Persistent
|
|||
setListTrx (false);
|
||||
setName (null);
|
||||
setPA_ReportColumnSet_ID (0);
|
||||
setPA_Report_ID (0);
|
||||
setPA_ReportLineSet_ID (0);
|
||||
setPA_Report_ID (0);
|
||||
setProcessing (false);
|
||||
} */
|
||||
}
|
||||
|
@ -363,24 +363,24 @@ public class X_PA_Report extends PO implements I_PA_Report, I_Persistent
|
|||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Financial Report.
|
||||
@param PA_Report_ID
|
||||
Financial Report
|
||||
/** Set Report Cube.
|
||||
@param PA_ReportCube_ID
|
||||
Define reporting cube for pre-calculation of summary accounting data.
|
||||
*/
|
||||
public void setPA_Report_ID (int PA_Report_ID)
|
||||
public void setPA_ReportCube_ID (int PA_ReportCube_ID)
|
||||
{
|
||||
if (PA_Report_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_PA_Report_ID, null);
|
||||
if (PA_ReportCube_ID < 1)
|
||||
set_Value (COLUMNNAME_PA_ReportCube_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_PA_Report_ID, Integer.valueOf(PA_Report_ID));
|
||||
set_Value (COLUMNNAME_PA_ReportCube_ID, Integer.valueOf(PA_ReportCube_ID));
|
||||
}
|
||||
|
||||
/** Get Financial Report.
|
||||
@return Financial Report
|
||||
/** Get Report Cube.
|
||||
@return Define reporting cube for pre-calculation of summary accounting data.
|
||||
*/
|
||||
public int getPA_Report_ID ()
|
||||
public int getPA_ReportCube_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_PA_Report_ID);
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_PA_ReportCube_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
|
@ -422,6 +422,29 @@ public class X_PA_Report extends PO implements I_PA_Report, I_Persistent
|
|||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Financial Report.
|
||||
@param PA_Report_ID
|
||||
Financial Report
|
||||
*/
|
||||
public void setPA_Report_ID (int PA_Report_ID)
|
||||
{
|
||||
if (PA_Report_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_PA_Report_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_PA_Report_ID, Integer.valueOf(PA_Report_ID));
|
||||
}
|
||||
|
||||
/** Get Financial Report.
|
||||
@return Financial Report
|
||||
*/
|
||||
public int getPA_Report_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_PA_Report_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Process Now.
|
||||
@param Processing Process Now */
|
||||
public void setProcessing (boolean Processing)
|
||||
|
|
|
@ -0,0 +1,620 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 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 *
|
||||
*****************************************************************************/
|
||||
/** Generated Model - DO NOT CHANGE */
|
||||
package org.compiere.model;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/** Generated Model for PA_ReportCube
|
||||
* @author Adempiere (generated)
|
||||
* @version Release 3.5.3a - $Id$ */
|
||||
public class X_PA_ReportCube extends PO implements I_PA_ReportCube, I_Persistent
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20081221L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_PA_ReportCube (Properties ctx, int PA_ReportCube_ID, String trxName)
|
||||
{
|
||||
super (ctx, PA_ReportCube_ID, trxName);
|
||||
/** if (PA_ReportCube_ID == 0)
|
||||
{
|
||||
setC_Calendar_ID (0);
|
||||
setName (null);
|
||||
setPA_ReportCube_ID (0);
|
||||
setProcessing (false);
|
||||
// N
|
||||
} */
|
||||
}
|
||||
|
||||
/** Load Constructor */
|
||||
public X_PA_ReportCube (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
}
|
||||
|
||||
/** AccessLevel
|
||||
* @return 3 - Client - Org
|
||||
*/
|
||||
protected int get_AccessLevel()
|
||||
{
|
||||
return accessLevel.intValue();
|
||||
}
|
||||
|
||||
/** Load Meta Data */
|
||||
protected POInfo initPO (Properties ctx)
|
||||
{
|
||||
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
|
||||
return poi;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("X_PA_ReportCube[")
|
||||
.append(get_ID()).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public I_C_Calendar getC_Calendar() throws RuntimeException
|
||||
{
|
||||
Class<?> clazz = MTable.getClass(I_C_Calendar.Table_Name);
|
||||
I_C_Calendar result = null;
|
||||
try {
|
||||
Constructor<?> constructor = null;
|
||||
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
|
||||
result = (I_C_Calendar)constructor.newInstance(new Object[] {getCtx(), new Integer(getC_Calendar_ID()), get_TrxName()});
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
|
||||
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Set Calendar.
|
||||
@param C_Calendar_ID
|
||||
Accounting Calendar Name
|
||||
*/
|
||||
public void setC_Calendar_ID (int C_Calendar_ID)
|
||||
{
|
||||
if (C_Calendar_ID < 1)
|
||||
set_Value (COLUMNNAME_C_Calendar_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_C_Calendar_ID, Integer.valueOf(C_Calendar_ID));
|
||||
}
|
||||
|
||||
/** Get Calendar.
|
||||
@return Accounting Calendar Name
|
||||
*/
|
||||
public int getC_Calendar_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_C_Calendar_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Description.
|
||||
@param Description
|
||||
Optional short description of the record
|
||||
*/
|
||||
public void setDescription (String Description)
|
||||
{
|
||||
set_Value (COLUMNNAME_Description, Description);
|
||||
}
|
||||
|
||||
/** Get Description.
|
||||
@return Optional short description of the record
|
||||
*/
|
||||
public String getDescription ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Description);
|
||||
}
|
||||
|
||||
/** Set Activity Dimension.
|
||||
@param IsActivityDim
|
||||
Include Activity as a cube dimension
|
||||
*/
|
||||
public void setIsActivityDim (boolean IsActivityDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsActivityDim, Boolean.valueOf(IsActivityDim));
|
||||
}
|
||||
|
||||
/** Get Activity Dimension.
|
||||
@return Include Activity as a cube dimension
|
||||
*/
|
||||
public boolean isActivityDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsActivityDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Business Partner Dimension.
|
||||
@param IsBPartnerDim
|
||||
Include Business Partner as a cube dimension
|
||||
*/
|
||||
public void setIsBPartnerDim (boolean IsBPartnerDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsBPartnerDim, Boolean.valueOf(IsBPartnerDim));
|
||||
}
|
||||
|
||||
/** Get Business Partner Dimension.
|
||||
@return Include Business Partner as a cube dimension
|
||||
*/
|
||||
public boolean isBPartnerDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsBPartnerDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Campaign Dimension.
|
||||
@param IsCampaignDim
|
||||
Include Campaign as a cube dimension
|
||||
*/
|
||||
public void setIsCampaignDim (boolean IsCampaignDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsCampaignDim, Boolean.valueOf(IsCampaignDim));
|
||||
}
|
||||
|
||||
/** Get Campaign Dimension.
|
||||
@return Include Campaign as a cube dimension
|
||||
*/
|
||||
public boolean isCampaignDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsCampaignDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set GL Budget Dimension.
|
||||
@param IsGLBudgetDim
|
||||
Include GL Budget as a cube dimension
|
||||
*/
|
||||
public void setIsGLBudgetDim (boolean IsGLBudgetDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsGLBudgetDim, Boolean.valueOf(IsGLBudgetDim));
|
||||
}
|
||||
|
||||
/** Get GL Budget Dimension.
|
||||
@return Include GL Budget as a cube dimension
|
||||
*/
|
||||
public boolean isGLBudgetDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsGLBudgetDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Location From Dimension.
|
||||
@param IsLocFromDim
|
||||
Include Location From as a cube dimension
|
||||
*/
|
||||
public void setIsLocFromDim (boolean IsLocFromDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsLocFromDim, Boolean.valueOf(IsLocFromDim));
|
||||
}
|
||||
|
||||
/** Get Location From Dimension.
|
||||
@return Include Location From as a cube dimension
|
||||
*/
|
||||
public boolean isLocFromDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsLocFromDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Location To Dimension.
|
||||
@param IsLocToDim
|
||||
Include Location To as a cube dimension
|
||||
*/
|
||||
public void setIsLocToDim (boolean IsLocToDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsLocToDim, Boolean.valueOf(IsLocToDim));
|
||||
}
|
||||
|
||||
/** Get Location To Dimension.
|
||||
@return Include Location To as a cube dimension
|
||||
*/
|
||||
public boolean isLocToDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsLocToDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set OrgTrx Dimension.
|
||||
@param IsOrgTrxDim
|
||||
Include OrgTrx as a cube dimension
|
||||
*/
|
||||
public void setIsOrgTrxDim (boolean IsOrgTrxDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsOrgTrxDim, Boolean.valueOf(IsOrgTrxDim));
|
||||
}
|
||||
|
||||
/** Get OrgTrx Dimension.
|
||||
@return Include OrgTrx as a cube dimension
|
||||
*/
|
||||
public boolean isOrgTrxDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsOrgTrxDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Product Dimension.
|
||||
@param IsProductDim
|
||||
Include Product as a cube dimension
|
||||
*/
|
||||
public void setIsProductDim (boolean IsProductDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsProductDim, Boolean.valueOf(IsProductDim));
|
||||
}
|
||||
|
||||
/** Get Product Dimension.
|
||||
@return Include Product as a cube dimension
|
||||
*/
|
||||
public boolean isProductDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsProductDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Project Dimension.
|
||||
@param IsProjectDim
|
||||
Include Project as a cube dimension
|
||||
*/
|
||||
public void setIsProjectDim (boolean IsProjectDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsProjectDim, Boolean.valueOf(IsProjectDim));
|
||||
}
|
||||
|
||||
/** Get Project Dimension.
|
||||
@return Include Project as a cube dimension
|
||||
*/
|
||||
public boolean isProjectDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsProjectDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Project Phase Dimension.
|
||||
@param IsProjectPhaseDim
|
||||
Include Project Phase as a cube dimension
|
||||
*/
|
||||
public void setIsProjectPhaseDim (boolean IsProjectPhaseDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsProjectPhaseDim, Boolean.valueOf(IsProjectPhaseDim));
|
||||
}
|
||||
|
||||
/** Get Project Phase Dimension.
|
||||
@return Include Project Phase as a cube dimension
|
||||
*/
|
||||
public boolean isProjectPhaseDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsProjectPhaseDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Project Task Dimension.
|
||||
@param IsProjectTaskDim
|
||||
Include Project Task as a cube dimension
|
||||
*/
|
||||
public void setIsProjectTaskDim (boolean IsProjectTaskDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsProjectTaskDim, Boolean.valueOf(IsProjectTaskDim));
|
||||
}
|
||||
|
||||
/** Get Project Task Dimension.
|
||||
@return Include Project Task as a cube dimension
|
||||
*/
|
||||
public boolean isProjectTaskDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsProjectTaskDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Sales Region Dimension.
|
||||
@param IsSalesRegionDim
|
||||
Include Sales Region as a cube dimension
|
||||
*/
|
||||
public void setIsSalesRegionDim (boolean IsSalesRegionDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsSalesRegionDim, Boolean.valueOf(IsSalesRegionDim));
|
||||
}
|
||||
|
||||
/** Get Sales Region Dimension.
|
||||
@return Include Sales Region as a cube dimension
|
||||
*/
|
||||
public boolean isSalesRegionDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsSalesRegionDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Sub Acct Dimension.
|
||||
@param IsSubAcctDim
|
||||
Include Sub Acct as a cube dimension
|
||||
*/
|
||||
public void setIsSubAcctDim (boolean IsSubAcctDim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsSubAcctDim, Boolean.valueOf(IsSubAcctDim));
|
||||
}
|
||||
|
||||
/** Get Sub Acct Dimension.
|
||||
@return Include Sub Acct as a cube dimension
|
||||
*/
|
||||
public boolean isSubAcctDim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsSubAcctDim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set User 1 Dimension.
|
||||
@param IsUser1Dim
|
||||
Include User 1 as a cube dimension
|
||||
*/
|
||||
public void setIsUser1Dim (boolean IsUser1Dim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsUser1Dim, Boolean.valueOf(IsUser1Dim));
|
||||
}
|
||||
|
||||
/** Get User 1 Dimension.
|
||||
@return Include User 1 as a cube dimension
|
||||
*/
|
||||
public boolean isUser1Dim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsUser1Dim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set User 2 Dimension.
|
||||
@param IsUser2Dim
|
||||
Include User 2 as a cube dimension
|
||||
*/
|
||||
public void setIsUser2Dim (boolean IsUser2Dim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsUser2Dim, Boolean.valueOf(IsUser2Dim));
|
||||
}
|
||||
|
||||
/** Get User 2 Dimension.
|
||||
@return Include User 2 as a cube dimension
|
||||
*/
|
||||
public boolean isUser2Dim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsUser2Dim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set User Element 1 Dimension.
|
||||
@param IsUserElement1Dim
|
||||
Include User Element 1 as a cube dimension
|
||||
*/
|
||||
public void setIsUserElement1Dim (boolean IsUserElement1Dim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsUserElement1Dim, Boolean.valueOf(IsUserElement1Dim));
|
||||
}
|
||||
|
||||
/** Get User Element 1 Dimension.
|
||||
@return Include User Element 1 as a cube dimension
|
||||
*/
|
||||
public boolean isUserElement1Dim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsUserElement1Dim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set User Element 2 Dimension.
|
||||
@param IsUserElement2Dim
|
||||
Include User Element 2 as a cube dimension
|
||||
*/
|
||||
public void setIsUserElement2Dim (boolean IsUserElement2Dim)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsUserElement2Dim, Boolean.valueOf(IsUserElement2Dim));
|
||||
}
|
||||
|
||||
/** Get User Element 2 Dimension.
|
||||
@return Include User Element 2 as a cube dimension
|
||||
*/
|
||||
public boolean isUserElement2Dim ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsUserElement2Dim);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Last Recalculated.
|
||||
@param LastRecalculated
|
||||
The time last recalculated.
|
||||
*/
|
||||
public void setLastRecalculated (Timestamp LastRecalculated)
|
||||
{
|
||||
set_Value (COLUMNNAME_LastRecalculated, LastRecalculated);
|
||||
}
|
||||
|
||||
/** Get Last Recalculated.
|
||||
@return The time last recalculated.
|
||||
*/
|
||||
public Timestamp getLastRecalculated ()
|
||||
{
|
||||
return (Timestamp)get_Value(COLUMNNAME_LastRecalculated);
|
||||
}
|
||||
|
||||
/** Set Name.
|
||||
@param Name
|
||||
Alphanumeric identifier of the entity
|
||||
*/
|
||||
public void setName (String Name)
|
||||
{
|
||||
set_Value (COLUMNNAME_Name, Name);
|
||||
}
|
||||
|
||||
/** Get Name.
|
||||
@return Alphanumeric identifier of the entity
|
||||
*/
|
||||
public String getName ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Name);
|
||||
}
|
||||
|
||||
/** Set Report Cube.
|
||||
@param PA_ReportCube_ID
|
||||
Define reporting cube for pre-calculation of summary accounting data.
|
||||
*/
|
||||
public void setPA_ReportCube_ID (int PA_ReportCube_ID)
|
||||
{
|
||||
if (PA_ReportCube_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_PA_ReportCube_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_PA_ReportCube_ID, Integer.valueOf(PA_ReportCube_ID));
|
||||
}
|
||||
|
||||
/** Get Report Cube.
|
||||
@return Define reporting cube for pre-calculation of summary accounting data.
|
||||
*/
|
||||
public int getPA_ReportCube_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_PA_ReportCube_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Process Now.
|
||||
@param Processing Process Now */
|
||||
public void setProcessing (boolean Processing)
|
||||
{
|
||||
set_Value (COLUMNNAME_Processing, Boolean.valueOf(Processing));
|
||||
}
|
||||
|
||||
/** Get Process Now.
|
||||
@return Process Now */
|
||||
public boolean isProcessing ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_Processing);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/******************************************************************************
|
||||
* 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.process;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MReportCube;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_PA_ReportCube;
|
||||
|
||||
/*
|
||||
* Populate Fact_Acct_Summary table with pre-calculated totals of
|
||||
* accounting facts, grouped by the dimensions selected in active report cubes.
|
||||
* @author Paul Bowden
|
||||
*/
|
||||
public class FactAcctSummary extends SvrProcess {
|
||||
|
||||
|
||||
private boolean p_reset = false;
|
||||
private int p_Cube_ID = 0;
|
||||
private String periods;
|
||||
private boolean p_force = false;
|
||||
|
||||
@Override
|
||||
protected void prepare() {
|
||||
|
||||
ProcessInfoParameter[] params = getParameter();
|
||||
for (ProcessInfoParameter p : params)
|
||||
{
|
||||
if ( p.getParameterName().equals("Reset") )
|
||||
p_reset = p.getParameterAsBoolean();
|
||||
else if ( p.getParameterName().equals("PA_ReportCube_ID"))
|
||||
p_Cube_ID = p.getParameterAsInt();
|
||||
else if ( p.getParameterName().equals("Force"))
|
||||
p_force = p.getParameterAsBoolean();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + p.getParameterName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doIt() throws Exception {
|
||||
|
||||
String where = "";
|
||||
if ( p_Cube_ID > 0)
|
||||
where = "PA_ReportCube_ID = " + p_Cube_ID;
|
||||
|
||||
List<MReportCube> cubes = new Query(getCtx(), X_PA_ReportCube.Table_Name, where, get_TrxName())
|
||||
.setOnlyActiveRecords(true).setClient_ID()
|
||||
.list();
|
||||
|
||||
for ( MReportCube cube : cubes )
|
||||
{
|
||||
addLog( cube.update( p_reset, p_force ) );
|
||||
} // for each cube
|
||||
|
||||
|
||||
return "@OK@";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MAcctSchemaElement;
|
||||
import org.compiere.model.MReportCube;
|
||||
import org.compiere.print.MPrintFormat;
|
||||
import org.compiere.print.MPrintFormatItem;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
|
@ -63,6 +64,8 @@ public class FinReport extends SvrProcess
|
|||
private boolean p_DetailsSourceFirst = false;
|
||||
/** Hierarchy */
|
||||
private int p_PA_Hierarchy_ID = 0;
|
||||
/** Optional report cube */
|
||||
private int p_PA_ReportCube_ID = 0;
|
||||
|
||||
/** Start Time */
|
||||
private long m_start = System.currentTimeMillis();
|
||||
|
@ -115,6 +118,8 @@ public class FinReport extends SvrProcess
|
|||
p_C_Campaign_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
else if (name.equals("DetailsSourceFirst"))
|
||||
p_DetailsSourceFirst = "Y".equals(para[i].getParameter());
|
||||
else if (name.equals("PA_ReportCube_ID"))
|
||||
p_PA_ReportCube_ID = para[i].getParameterAsInt();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
|
@ -156,6 +161,10 @@ public class FinReport extends SvrProcess
|
|||
sb.append(" - C_Period_ID=").append(p_C_Period_ID)
|
||||
.append(" - ").append(m_parameterWhere);
|
||||
//
|
||||
|
||||
if ( p_PA_ReportCube_ID > 0)
|
||||
m_parameterWhere.append(" AND PA_ReportCube_ID=").append(p_PA_ReportCube_ID);
|
||||
|
||||
log.info(sb.toString());
|
||||
// m_report.list();
|
||||
} // prepare
|
||||
|
@ -226,6 +235,13 @@ public class FinReport extends SvrProcess
|
|||
protected String doIt() throws Exception
|
||||
{
|
||||
log.info("AD_PInstance_ID=" + getAD_PInstance_ID());
|
||||
|
||||
if ( p_PA_ReportCube_ID > 0 )
|
||||
{
|
||||
MReportCube cube = new MReportCube(getCtx(), p_PA_ReportCube_ID, get_TrxName());
|
||||
String result = cube.update(false, false);
|
||||
log.log(Level.FINE, result);
|
||||
}
|
||||
// ** Create Temporary and empty Report Lines from PA_ReportLine
|
||||
// - AD_PInstance_ID, PA_ReportLine_ID, 0, 0
|
||||
int PA_ReportLineSet_ID = m_report.getLineSet().getPA_ReportLineSet_ID();
|
||||
|
@ -315,9 +331,14 @@ public class FinReport extends SvrProcess
|
|||
log.warning("No Amount Type in line: " + m_lines[line] + " or column: " + m_columns[col]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_PA_ReportCube_ID > 0)
|
||||
select.append(" FROM Fact_Acct_Summary fa WHERE DateAcct ");
|
||||
else {
|
||||
// Get Period/Date info
|
||||
select.append(" FROM Fact_Acct fa WHERE TRUNC(DateAcct) ");
|
||||
}
|
||||
|
||||
// Get Period/Date info
|
||||
select.append(" FROM Fact_Acct WHERE TRUNC(DateAcct) ");
|
||||
BigDecimal relativeOffset = null; // current
|
||||
if (m_columns[col].isColumnTypeRelativePeriod())
|
||||
relativeOffset = m_columns[col].getRelativePeriod();
|
||||
|
@ -345,9 +366,7 @@ public class FinReport extends SvrProcess
|
|||
}
|
||||
else if (m_lines[line].isNatural())
|
||||
{
|
||||
String sql = frp.getNaturalWhere("Fact_Acct");
|
||||
info.append("Natural");
|
||||
select.append(sql);
|
||||
select.append( frp.getNaturalWhere("fa"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -378,9 +397,7 @@ public class FinReport extends SvrProcess
|
|||
}
|
||||
else if (m_columns[col].isNatural())
|
||||
{
|
||||
String sql = frp.getNaturalWhere("Fact_Acct");
|
||||
info.append("Natural");
|
||||
select.append(sql);
|
||||
select.append( frp.getNaturalWhere("fa"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -388,31 +405,31 @@ public class FinReport extends SvrProcess
|
|||
select.append("=0"); // valid sql
|
||||
}
|
||||
}
|
||||
|
||||
// Line Where
|
||||
String s = m_lines[line].getWhereClause(p_PA_Hierarchy_ID); // (sources, posting type)
|
||||
if (s != null && s.length() > 0)
|
||||
select.append(" AND ").append(s);
|
||||
|
||||
// Report Where
|
||||
s = m_report.getWhereClause();
|
||||
if (s != null && s.length() > 0)
|
||||
select.append(" AND ").append(s);
|
||||
// Line Where
|
||||
String s = m_lines[line].getWhereClause(p_PA_Hierarchy_ID); // (sources, posting type)
|
||||
if (s != null && s.length() > 0)
|
||||
select.append(" AND ").append(s);
|
||||
|
||||
// PostingType
|
||||
if (!m_lines[line].isPostingType()) // only if not defined on line
|
||||
{
|
||||
String PostingType = m_columns[col].getPostingType();
|
||||
if (PostingType != null && PostingType.length() > 0)
|
||||
select.append(" AND PostingType='").append(PostingType).append("'");
|
||||
// globalqss - CarlosRuiz
|
||||
if (PostingType.equals(MReportColumn.POSTINGTYPE_Budget)) {
|
||||
if (m_columns[col].getGL_Budget_ID() > 0)
|
||||
select.append(" AND GL_Budget_ID=" + m_columns[col].getGL_Budget_ID());
|
||||
}
|
||||
// end globalqss
|
||||
// Report Where
|
||||
s = m_report.getWhereClause();
|
||||
if (s != null && s.length() > 0)
|
||||
select.append(" AND ").append(s);
|
||||
|
||||
// PostingType
|
||||
if (!m_lines[line].isPostingType()) // only if not defined on line
|
||||
{
|
||||
String PostingType = m_columns[col].getPostingType();
|
||||
if (PostingType != null && PostingType.length() > 0)
|
||||
select.append(" AND PostingType='").append(PostingType).append("'");
|
||||
// globalqss - CarlosRuiz
|
||||
if (PostingType.equals(MReportColumn.POSTINGTYPE_Budget)) {
|
||||
if (m_columns[col].getGL_Budget_ID() > 0)
|
||||
select.append(" AND GL_Budget_ID=" + m_columns[col].getGL_Budget_ID());
|
||||
}
|
||||
|
||||
// end globalqss
|
||||
}
|
||||
|
||||
if (m_columns[col].isColumnTypeSegmentValue())
|
||||
select.append(m_columns[col].getWhereClause(p_PA_Hierarchy_ID));
|
||||
|
||||
|
@ -724,7 +741,7 @@ public class FinReport extends SvrProcess
|
|||
|
||||
|
||||
/**************************************************************************
|
||||
* Get Financial Reporting Period based on reportong Period and offset.
|
||||
* Get Financial Reporting Period based on reporting Period and offset.
|
||||
* @param relativeOffset offset
|
||||
* @return reporting period
|
||||
*/
|
||||
|
@ -886,8 +903,13 @@ public class FinReport extends SvrProcess
|
|||
continue;
|
||||
}
|
||||
|
||||
if (p_PA_ReportCube_ID > 0) {
|
||||
select.append(" FROM Fact_Acct_Summary fb WHERE DateAcct ");
|
||||
} //report cube
|
||||
else {
|
||||
// Get Period info
|
||||
select.append(" FROM Fact_Acct fb WHERE TRUNC(DateAcct) ");
|
||||
select.append(" FROM Fact_Acct fb WHERE TRUNC(DateAcct) ");
|
||||
}
|
||||
FinReportPeriod frp = getPeriod (m_columns[col].getRelativePeriod());
|
||||
if (m_lines[line].getAmountType() != null) // line amount type overwrites column
|
||||
{
|
||||
|
@ -952,7 +974,10 @@ public class FinReport extends SvrProcess
|
|||
if (where.length() > 0)
|
||||
where.append(" AND ");
|
||||
where.append(variable).append(" IS NOT NULL");
|
||||
|
||||
|
||||
if (p_PA_ReportCube_ID > 0)
|
||||
insert.append(" FROM Fact_Acct_Summary x WHERE ").append(where);
|
||||
else
|
||||
// FROM .. WHERE
|
||||
insert.append(" FROM Fact_Acct x WHERE ").append(where);
|
||||
//
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue