Idempiere 4066 (#235)
* IDEMPIERE-4066: Adding 'Relative Period To' on financial report column which allow to specify period range to produce YoY. QoQ like comparision report. * IDEMPIERE-4066: Fixing defaulting RelativePeriodTo to Null issue * IDEMPIERE-4066: Fix as per Carlos review. 1. Fixing compilation issue 2. Moving Column ID constants to systemIDs 3. Updating serial version for MReportColumn. * IDEMPIERE-4066: Reverted GridField class changes and configured defailt for RelativePeriodTo to be 'NULL'
This commit is contained in:
parent
bd03a89d1c
commit
ee48ef2be4
|
@ -0,0 +1,31 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- Financial Report Header Print Format - Related Period To
|
||||
-- Oct 14, 2019 4:05:49 PM IST
|
||||
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,PrintName,EntityType,AD_Element_UU) VALUES (203370,0,0,'Y',TO_DATE('2019-10-14 16:05:49','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2019-10-14 16:05:49','YYYY-MM-DD HH24:MI:SS'),100,'RelativePeriodTo','Relative Period To','Period offset (0 is current)','Relative Period To','D','30311109-8745-48d7-825f-a562fefe4c98')
|
||||
;
|
||||
|
||||
-- Oct 14, 2019 4:06:50 PM IST
|
||||
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (214087,0,'Relative Period To','Period offset (0 is current)',446,'RelativePeriodTo','NULL',22,'N','N','N','N','N',0,'N',22,0,0,'Y',TO_DATE('2019-10-14 16:06:50','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2019-10-14 16:06:50','YYYY-MM-DD HH24:MI:SS'),100,203370,'Y','N','D','N','N','N','Y','48d4dd26-197e-4a9a-add3-f2e1d5ed0e22','Y',0,'N','N')
|
||||
;
|
||||
|
||||
-- Oct 14, 2019 4:44:49 PM IST
|
||||
ALTER TABLE PA_ReportColumn ADD RelativePeriodTo NUMBER DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Oct 14, 2019 4:09:10 PM IST
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLogic,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (206213,'Relative Period To','Period offset (0 is current)',374,214087,'Y','@ColumnType@=R',26,145,'N','N','N','N',0,0,'Y',TO_DATE('2019-10-14 16:09:10','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2019-10-14 16:09:10','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','ebe78b9f-d030-46fa-b1c0-eaafe2521d3a','Y',145,4,2,1,'N','N','N')
|
||||
;
|
||||
|
||||
-- Nov 27, 2019 4:51:42 PM IST
|
||||
UPDATE AD_Field SET DisplayLogic='@ColumnType@=R | @ColumnType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2019-11-27 16:51:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4757
|
||||
;
|
||||
|
||||
-- Nov 27, 2019 4:51:47 PM IST
|
||||
UPDATE AD_Field SET DisplayLogic='@ColumnType@=R | @ColumnType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2019-11-27 16:51:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206213
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201912301730_IDEMPIERE-4066.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
-- Financial Report Header Print Format - Related Period To
|
||||
-- Oct 14, 2019 4:05:49 PM IST
|
||||
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,PrintName,EntityType,AD_Element_UU) VALUES (203370,0,0,'Y',TO_TIMESTAMP('2019-10-14 16:05:49','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2019-10-14 16:05:49','YYYY-MM-DD HH24:MI:SS'),100,'RelativePeriodTo','Relative Period To','Period offset (0 is current)','Relative Period To','D','30311109-8745-48d7-825f-a562fefe4c98')
|
||||
;
|
||||
|
||||
-- Oct 14, 2019 4:06:50 PM IST
|
||||
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (214087,0,'Relative Period To','Period offset (0 is current)',446,'RelativePeriodTo','NULL',22,'N','N','N','N','N',0,'N',22,0,0,'Y',TO_TIMESTAMP('2019-10-14 16:06:50','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2019-10-14 16:06:50','YYYY-MM-DD HH24:MI:SS'),100,203370,'Y','N','D','N','N','N','Y','48d4dd26-197e-4a9a-add3-f2e1d5ed0e22','Y',0,'N','N')
|
||||
;
|
||||
|
||||
-- Oct 14, 2019 4:44:49 PM IST
|
||||
ALTER TABLE PA_ReportColumn ADD COLUMN RelativePeriodTo NUMERIC DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Oct 14, 2019 4:09:10 PM IST
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLogic,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (206213,'Relative Period To','Period offset (0 is current)',374,214087,'Y','@ColumnType@=R',26,145,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2019-10-14 16:09:10','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2019-10-14 16:09:10','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','ebe78b9f-d030-46fa-b1c0-eaafe2521d3a','Y',145,4,2,1,'N','N','N')
|
||||
;
|
||||
|
||||
-- Nov 27, 2019 4:51:42 PM IST
|
||||
UPDATE AD_Field SET DisplayLogic='@ColumnType@=R | @ColumnType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2019-11-27 16:51:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4757
|
||||
;
|
||||
|
||||
-- Nov 27, 2019 4:51:47 PM IST
|
||||
UPDATE AD_Field SET DisplayLogic='@ColumnType@=R | @ColumnType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2019-11-27 16:51:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206213
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201912301730_IDEMPIERE-4066.sql') FROM dual
|
||||
;
|
|
@ -686,6 +686,19 @@ public interface I_PA_ReportColumn
|
|||
*/
|
||||
public BigDecimal getRelativePeriod();
|
||||
|
||||
/** Column name RelativePeriodTo */
|
||||
public static final String COLUMNNAME_RelativePeriodTo = "RelativePeriodTo";
|
||||
|
||||
/** Set Relative Period To.
|
||||
* Period offset (0 is current)
|
||||
*/
|
||||
public void setRelativePeriodTo (BigDecimal RelativePeriodTo);
|
||||
|
||||
/** Get Relative Period To.
|
||||
* Period offset (0 is current)
|
||||
*/
|
||||
public BigDecimal getRelativePeriodTo();
|
||||
|
||||
/** Column name SeqNo */
|
||||
public static final String COLUMNNAME_SeqNo = "SeqNo";
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class X_PA_ReportColumn extends PO implements I_PA_ReportColumn, I_Persis
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20200413L;
|
||||
private static final long serialVersionUID = 20200814L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_PA_ReportColumn (Properties ctx, int PA_ReportColumn_ID, String trxName)
|
||||
|
@ -1246,6 +1246,26 @@ public class X_PA_ReportColumn extends PO implements I_PA_ReportColumn, I_Persis
|
|||
return bd;
|
||||
}
|
||||
|
||||
/** Set Relative Period To.
|
||||
@param RelativePeriodTo
|
||||
Period offset (0 is current)
|
||||
*/
|
||||
public void setRelativePeriodTo (BigDecimal RelativePeriodTo)
|
||||
{
|
||||
set_Value (COLUMNNAME_RelativePeriodTo, RelativePeriodTo);
|
||||
}
|
||||
|
||||
/** Get Relative Period To.
|
||||
@return Period offset (0 is current)
|
||||
*/
|
||||
public BigDecimal getRelativePeriodTo ()
|
||||
{
|
||||
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_RelativePeriodTo);
|
||||
if (bd == null)
|
||||
return Env.ZERO;
|
||||
return bd;
|
||||
}
|
||||
|
||||
/** Set Sequence.
|
||||
@param SeqNo
|
||||
Method of ordering records; lowest number comes first
|
||||
|
|
|
@ -414,9 +414,14 @@ public class FinReport extends SvrProcess
|
|||
}
|
||||
|
||||
BigDecimal relativeOffset = null; // current
|
||||
BigDecimal relativeOffsetTo = null;
|
||||
if (m_columns[col].isColumnTypeRelativePeriod())
|
||||
{
|
||||
relativeOffset = m_columns[col].getRelativePeriod();
|
||||
relativeOffsetTo = m_columns[col].getRelativePeriodTo();
|
||||
}
|
||||
FinReportPeriod frp = getPeriod (relativeOffset);
|
||||
FinReportPeriod frpTo = getPeriodTo(relativeOffsetTo);
|
||||
if (m_lines[line].getPAPeriodType() != null) // line amount type overwrites column
|
||||
{
|
||||
info.append(" - LineDateAcct=");
|
||||
|
@ -453,25 +458,39 @@ public class FinReport extends SvrProcess
|
|||
info.append(" - ColumnDateAcct=");
|
||||
if (m_columns[col].isPeriod())
|
||||
{
|
||||
String sql = frp.getPeriodWhere();
|
||||
if (frpTo == null)
|
||||
select.append(frp.getPeriodWhere());
|
||||
else
|
||||
select.append(" BETWEEN " + DB.TO_DATE(frp.getStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate()));
|
||||
info.append("Period");
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_columns[col].isYear())
|
||||
{
|
||||
String sql = frp.getYearWhere();
|
||||
if (frpTo == null)
|
||||
select.append(frp.getYearWhere());
|
||||
else
|
||||
select.append(" BETWEEN " + DB.TO_DATE(frp.getYearStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate()));
|
||||
info.append("Year");
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_columns[col].isTotal())
|
||||
{
|
||||
String sql = frp.getTotalWhere();
|
||||
if (frpTo == null)
|
||||
select.append(frp.getTotalWhere());
|
||||
else
|
||||
select.append(frpTo.getTotalWhere());
|
||||
info.append("Total");
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_columns[col].isNatural())
|
||||
{
|
||||
select.append( frp.getNaturalWhere("fa"));
|
||||
if (frpTo == null)
|
||||
select.append(frp.getNaturalWhere("fa"));
|
||||
else
|
||||
{
|
||||
String yearWhere = " BETWEEN " + DB.TO_DATE(frp.getYearStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate());
|
||||
String totalWhere = frpTo.getTotalWhere();
|
||||
String bs = " EXISTS (SELECT C_ElementValue_ID FROM C_ElementValue WHERE C_ElementValue_ID = fa.Account_ID AND AccountType NOT IN ('R', 'E'))";
|
||||
select.append(totalWhere + " AND ( " + bs + " OR TRUNC(fa.DateAcct) " + yearWhere + " ) ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1397,6 +1416,7 @@ public class FinReport extends SvrProcess
|
|||
select.append(" FROM Fact_Acct fb WHERE ").append(p_AdjPeriodToExclude).append("TRUNC(DateAcct) ");
|
||||
}
|
||||
FinReportPeriod frp = getPeriod (m_columns[col].getRelativePeriod());
|
||||
FinReportPeriod frpTo = getPeriodTo(m_columns[col].getRelativePeriodTo());
|
||||
if (m_lines[line].getPAPeriodType() != null) // line amount type overwrites column
|
||||
{
|
||||
if (m_lines[line].isPeriod())
|
||||
|
@ -1411,13 +1431,39 @@ public class FinReport extends SvrProcess
|
|||
else if (m_columns[col].getPAPeriodType() != null)
|
||||
{
|
||||
if (m_columns[col].isPeriod())
|
||||
select.append(frp.getPeriodWhere());
|
||||
{
|
||||
if (frpTo == null)
|
||||
select.append(frp.getPeriodWhere());
|
||||
else
|
||||
select.append(" BETWEEN " + DB.TO_DATE(frp.getStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate()));
|
||||
}
|
||||
else if (m_columns[col].isYear())
|
||||
select.append(frp.getYearWhere());
|
||||
{
|
||||
if (frpTo == null)
|
||||
select.append(frp.getYearWhere());
|
||||
else
|
||||
select.append(" BETWEEN " + DB.TO_DATE(frp.getYearStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate()));
|
||||
}
|
||||
else if (m_columns[col].isNatural())
|
||||
select.append(frp.getNaturalWhere("fb"));
|
||||
{
|
||||
if (frpTo == null)
|
||||
select.append(frp.getNaturalWhere("fb"));
|
||||
else
|
||||
{
|
||||
String yearWhere = " BETWEEN " + DB.TO_DATE(frp.getYearStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate());
|
||||
String totalWhere = frpTo.getTotalWhere();
|
||||
String bs = " EXISTS (SELECT C_ElementValue_ID FROM C_ElementValue WHERE C_ElementValue_ID = fb.Account_ID AND AccountType NOT IN ('R', 'E'))";
|
||||
String full = totalWhere + " AND ( " + bs + " OR TRUNC(fb.DateAcct) " + yearWhere + " ) ";
|
||||
select.append(full);
|
||||
}
|
||||
}
|
||||
else
|
||||
select.append(frp.getTotalWhere());
|
||||
{
|
||||
if (frpTo == null)
|
||||
select.append(frp.getTotalWhere());
|
||||
else
|
||||
select.append(frpTo.getTotalWhere());
|
||||
}
|
||||
}
|
||||
// Link
|
||||
select.append(" AND fb.").append(variable).append("=x.").append(variable);
|
||||
|
@ -1599,6 +1645,7 @@ public class FinReport extends SvrProcess
|
|||
select.append(" FROM Fact_Acct fb WHERE ").append(p_AdjPeriodToExclude).append("TRUNC(DateAcct) ");
|
||||
}
|
||||
FinReportPeriod frp = getPeriod (m_columns[col].getRelativePeriod());
|
||||
FinReportPeriod frpTo = getPeriodTo(m_columns[col].getRelativePeriodTo());
|
||||
if (m_lines[line].getPAPeriodType() != null) // line amount type overwrites column
|
||||
{
|
||||
if (m_lines[line].isPeriod())
|
||||
|
@ -1613,13 +1660,39 @@ public class FinReport extends SvrProcess
|
|||
else if (m_columns[col].getPAPeriodType() != null)
|
||||
{
|
||||
if (m_columns[col].isPeriod())
|
||||
select.append(frp.getPeriodWhere());
|
||||
{
|
||||
if (frpTo == null)
|
||||
select.append(frp.getPeriodWhere());
|
||||
else
|
||||
select.append(" BETWEEN " + DB.TO_DATE(frp.getStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate()));
|
||||
}
|
||||
else if (m_columns[col].isYear())
|
||||
select.append(frp.getYearWhere());
|
||||
{
|
||||
if (frpTo == null)
|
||||
select.append(frp.getYearWhere());
|
||||
else
|
||||
select.append(" BETWEEN " + DB.TO_DATE(frp.getYearStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate()));
|
||||
}
|
||||
else if (m_columns[col].isNatural())
|
||||
select.append(frp.getNaturalWhere("fb"));
|
||||
{
|
||||
if (frpTo == null)
|
||||
select.append(frp.getNaturalWhere("fb"));
|
||||
else
|
||||
{
|
||||
String yearWhere = " BETWEEN " + DB.TO_DATE(frp.getYearStartDate()) + " AND " + DB.TO_DATE(frpTo.getEndDate());
|
||||
String totalWhere = frpTo.getTotalWhere();
|
||||
String bs = " EXISTS (SELECT C_ElementValue_ID FROM C_ElementValue WHERE C_ElementValue_ID = fb.Account_ID AND AccountType NOT IN ('R', 'E'))";
|
||||
String full = totalWhere + " AND ( " + bs + " OR TRUNC(fb.DateAcct) " + yearWhere + " ) ";
|
||||
select.append(full);
|
||||
}
|
||||
}
|
||||
else
|
||||
select.append(frp.getTotalWhere());
|
||||
{
|
||||
if (frpTo == null)
|
||||
select.append(frp.getTotalWhere());
|
||||
else
|
||||
select.append(frpTo.getTotalWhere());
|
||||
}
|
||||
}
|
||||
// Link
|
||||
select.append(" AND fb.Fact_Acct_ID=x.Fact_Acct_ID");
|
||||
|
@ -1785,10 +1858,22 @@ public class FinReport extends SvrProcess
|
|||
if (m_columns[index].isColumnTypeRelativePeriod())
|
||||
{
|
||||
BigDecimal relativeOffset = m_columns[index].getRelativePeriod();
|
||||
BigDecimal relativeOffsetTo = m_columns[index].getRelativePeriodTo();
|
||||
|
||||
FinReportPeriod frp = getPeriod (relativeOffset);
|
||||
|
||||
if ( s.contains("@Period@") )
|
||||
s = s.replace("@Period@", frp.getName() );
|
||||
FinReportPeriod frpTo = getPeriodTo(relativeOffsetTo);
|
||||
|
||||
if (s.contains("@Period@"))
|
||||
{
|
||||
if (frpTo != null)
|
||||
{
|
||||
s = s.replace("@Period@", frp.getName() + " - " + frpTo.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
s = s.replace("@Period@", frp.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pfi.getName().equals(s))
|
||||
|
@ -1874,4 +1959,17 @@ public class FinReport extends SvrProcess
|
|||
return pf;
|
||||
} // getPrintFormat
|
||||
|
||||
/****************************************************************************
|
||||
* Get Financial Reporting Period To based on reporting Period and offset to.
|
||||
*
|
||||
* @param relativeOffsetTo - offset TO
|
||||
* @return reporting period
|
||||
*/
|
||||
private FinReportPeriod getPeriodTo(BigDecimal relativeOffsetTo)
|
||||
{
|
||||
if (relativeOffsetTo != null)
|
||||
return getPeriod(relativeOffsetTo);
|
||||
return null;
|
||||
} // getPeriodTo
|
||||
|
||||
} // FinReport
|
||||
|
|
|
@ -34,7 +34,7 @@ public class MReportColumn extends X_PA_ReportColumn
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2395905882810790219L;
|
||||
private static final long serialVersionUID = 2584173320087743126L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -442,6 +442,20 @@ public class MReportColumn extends X_PA_ReportColumn
|
|||
return super.getRelativePeriod();
|
||||
return null;
|
||||
} // getRelativePeriod
|
||||
|
||||
/**
|
||||
* Get Relative Period To
|
||||
*
|
||||
* @return relative period to
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal getRelativePeriodTo()
|
||||
{
|
||||
if (getColumnType().equals(COLUMNTYPE_RelativePeriod) || getColumnType().equals(COLUMNTYPE_SegmentValue))
|
||||
return (BigDecimal) get_Value(COLUMNNAME_RelativePeriodTo);
|
||||
return null;
|
||||
} // getRelativePeriodTo
|
||||
|
||||
/**
|
||||
* Get Element Type
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue