Add new Where to Financial Report
--HG-- branch : FinancialReport
This commit is contained in:
parent
0db90f7bb6
commit
10f72c815a
|
|
@ -98,7 +98,7 @@ public class MID_FinReport extends SvrProcess
|
|||
/** Report Definition */
|
||||
private MReport m_report = null;
|
||||
/** Periods in Calendar */
|
||||
private FinReportPeriod[] m_periods = null;
|
||||
private MID_FinReportPeriod[] m_periods = null;
|
||||
/** Index of m_C_Period_ID in m_periods **/
|
||||
private int m_reportPeriod = -1;
|
||||
/** Parameter Where Clause */
|
||||
|
|
@ -153,10 +153,12 @@ public class MID_FinReport extends SvrProcess
|
|||
p_DetailsSourceFirst = "Y".equals(para[i].getParameter());
|
||||
else if (name.equals("PA_ReportCube_ID"))
|
||||
p_PA_ReportCube_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("DATE1"))
|
||||
else if (name.equals("DATE")) {
|
||||
p_Date1 = para[i].getParameterAsTimestamp();
|
||||
else if (name.equals("DATE2"))
|
||||
p_Date2 = para[i].getParameterAsTimestamp();
|
||||
p_Date2 = para[i].getParameter_ToAsTimestamp();
|
||||
}
|
||||
// else if (name.equals("DATE2"))
|
||||
// p_Date2 = para[i].getParameterAsTimestamp();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
|
|
@ -254,7 +256,7 @@ public class MID_FinReport extends SvrProcess
|
|||
p_C_Period_ID = 0;
|
||||
}
|
||||
}
|
||||
ArrayList<FinReportPeriod> list = new ArrayList<FinReportPeriod>();
|
||||
ArrayList<MID_FinReportPeriod> list = new ArrayList<MID_FinReportPeriod>();
|
||||
|
||||
String sql = "SELECT p.C_Period_ID, p.Name, p.StartDate, p.EndDate, MIN(p1.StartDate) "
|
||||
+ "FROM C_Period p "
|
||||
|
|
@ -277,8 +279,8 @@ public class MID_FinReport extends SvrProcess
|
|||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
FinReportPeriod frp = new FinReportPeriod (rs.getInt(1), rs.getString(2),
|
||||
rs.getTimestamp(3), rs.getTimestamp(4), rs.getTimestamp(5));
|
||||
MID_FinReportPeriod frp = new MID_FinReportPeriod (rs.getInt(1), rs.getString(2),
|
||||
rs.getTimestamp(3), rs.getTimestamp(4), rs.getTimestamp(5), p_Date1, p_Date2);
|
||||
list.add(frp);
|
||||
if (p_C_Period_ID == 0 && frp.inPeriod(today))
|
||||
p_C_Period_ID = frp.getC_Period_ID();
|
||||
|
|
@ -294,7 +296,7 @@ public class MID_FinReport extends SvrProcess
|
|||
rs = null; pstmt = null;
|
||||
}
|
||||
// convert to Array
|
||||
m_periods = new FinReportPeriod[list.size()];
|
||||
m_periods = new MID_FinReportPeriod[list.size()];
|
||||
list.toArray(m_periods);
|
||||
// today after latest period
|
||||
if (p_C_Period_ID == 0)
|
||||
|
|
@ -413,25 +415,29 @@ public class MID_FinReport extends SvrProcess
|
|||
String p_DateAcct = "";
|
||||
if (p_PA_ReportCube_ID > 0) {
|
||||
select.append(" FROM Fact_Acct_Summary fa WHERE ").append(p_AdjPeriodToExclude);
|
||||
if(p_Date1!=null)
|
||||
select.append("DateAcct>="+DB.TO_DATE(p_Date1)+" AND DateAcct<="+DB.TO_DATE(p_Date2)+" AND");
|
||||
// if(p_Date1!=null)
|
||||
// select.append("DateAcct>="+DB.TO_DATE(p_Date1)+" AND DateAcct<="+DB.TO_DATE(p_Date2)+" AND");
|
||||
select.append("DateAcct ");
|
||||
}else {
|
||||
// Get Period/Date info
|
||||
select.append(" FROM Fact_Acct fa WHERE ").append(p_AdjPeriodToExclude);
|
||||
if(p_Date1!=null)
|
||||
select.append("TRUNCT(DateAcct)>="+DB.TO_DATE(p_Date1)+" AND TRUNC(DateAcct)<="+DB.TO_DATE(p_Date2)+" AND");
|
||||
// if(p_Date1!=null)
|
||||
// select.append("TRUNCT(DateAcct)>="+DB.TO_DATE(p_Date1)+" AND TRUNC(DateAcct)<="+DB.TO_DATE(p_Date2)+" AND");
|
||||
select.append("TRUNC(DateAcct) ");
|
||||
}
|
||||
|
||||
BigDecimal relativeOffset = null; // current
|
||||
if (m_columns[col].isColumnTypeRelativePeriod())
|
||||
relativeOffset = m_columns[col].getRelativePeriod();
|
||||
FinReportPeriod frp = getPeriod (relativeOffset);
|
||||
MID_FinReportPeriod frp = getPeriod (relativeOffset);
|
||||
if (m_lines[line].getPAPeriodType() != null) // line amount type overwrites column
|
||||
{
|
||||
info.append(" - LineDateAcct=");
|
||||
if (m_lines[line].isPeriod())
|
||||
if(p_Date1!=null) {
|
||||
String sql = frp.getDateRangeWhere();
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_lines[line].isPeriod())
|
||||
{
|
||||
String sql = frp.getPeriodWhere();
|
||||
info.append("Period");
|
||||
|
|
@ -462,7 +468,11 @@ public class MID_FinReport extends SvrProcess
|
|||
else if (m_columns[col].getPAPeriodType() != null)
|
||||
{
|
||||
info.append(" - ColumnDateAcct=");
|
||||
if (m_columns[col].isPeriod())
|
||||
if(p_Date1!=null) {
|
||||
String sql = frp.getDateRangeWhere();
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_columns[col].isPeriod())
|
||||
{
|
||||
String sql = frp.getPeriodWhere();
|
||||
info.append("Period");
|
||||
|
|
@ -1179,7 +1189,7 @@ public class MID_FinReport extends SvrProcess
|
|||
* @param relativeOffset offset
|
||||
* @return reporting period
|
||||
*/
|
||||
private FinReportPeriod getPeriod (BigDecimal relativeOffset)
|
||||
private MID_FinReportPeriod getPeriod (BigDecimal relativeOffset)
|
||||
{
|
||||
if (relativeOffset == null)
|
||||
return getPeriod(0);
|
||||
|
|
@ -1191,7 +1201,7 @@ public class MID_FinReport extends SvrProcess
|
|||
* @param relativeOffset offset
|
||||
* @return reporting period
|
||||
*/
|
||||
private FinReportPeriod getPeriod (int relativeOffset)
|
||||
private MID_FinReportPeriod getPeriod (int relativeOffset)
|
||||
{
|
||||
// find current reporting period C_Period_ID
|
||||
if (m_reportPeriod < 0)
|
||||
|
|
@ -1363,21 +1373,25 @@ public class MID_FinReport extends SvrProcess
|
|||
|
||||
if (p_PA_ReportCube_ID > 0) {
|
||||
select.append(" FROM Fact_Acct_Summary fb WHERE ").append(p_AdjPeriodToExclude);
|
||||
if(p_Date1!=null)
|
||||
select.append("DateAcct>="+DB.TO_DATE(p_Date1)+" AND DateAcct<="+DB.TO_DATE(p_Date2)+" AND");
|
||||
// if(p_Date1!=null)
|
||||
// select.append("DateAcct>="+DB.TO_DATE(p_Date1)+" AND DateAcct<="+DB.TO_DATE(p_Date2)+" AND");
|
||||
select.append("DateAcct ");
|
||||
} //report cube
|
||||
else {
|
||||
// Get Period info
|
||||
select.append(" FROM Fact_Acct fb WHERE ").append(p_AdjPeriodToExclude);
|
||||
if(p_Date1!=null)
|
||||
select.append("TRUNC(DateAcct)>="+DB.TO_DATE(p_Date1)+" AND TRUNC(DateAcct)<="+DB.TO_DATE(p_Date2)+" AND");
|
||||
// if(p_Date1!=null)
|
||||
// select.append("TRUNC(DateAcct)>="+DB.TO_DATE(p_Date1)+" AND TRUNC(DateAcct)<="+DB.TO_DATE(p_Date2)+" AND");
|
||||
select.append("TRUNC(DateAcct) ");
|
||||
}
|
||||
FinReportPeriod frp = getPeriod (m_columns[col].getRelativePeriod());
|
||||
MID_FinReportPeriod frp = getPeriod (m_columns[col].getRelativePeriod());
|
||||
if (m_lines[line].getPAPeriodType() != null) // line amount type overwrites column
|
||||
{
|
||||
if (m_lines[line].isPeriod())
|
||||
if(p_Date1!=null) {
|
||||
String sql = frp.getDateRangeWhere();
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_lines[line].isPeriod())
|
||||
select.append(frp.getPeriodWhere());
|
||||
else if (m_lines[line].isYear())
|
||||
select.append(frp.getYearWhere());
|
||||
|
|
@ -1388,7 +1402,11 @@ public class MID_FinReport extends SvrProcess
|
|||
}
|
||||
else if (m_columns[col].getPAPeriodType() != null)
|
||||
{
|
||||
if (m_columns[col].isPeriod())
|
||||
if(p_Date1!=null) {
|
||||
String sql = frp.getDateRangeWhere();
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_columns[col].isPeriod())
|
||||
select.append(frp.getPeriodWhere());
|
||||
else if (m_columns[col].isYear())
|
||||
select.append(frp.getYearWhere());
|
||||
|
|
@ -1578,10 +1596,14 @@ public class MID_FinReport extends SvrProcess
|
|||
// Get Period info
|
||||
select.append(" FROM Fact_Acct fb WHERE ").append(p_AdjPeriodToExclude).append("TRUNC(DateAcct) ");
|
||||
}
|
||||
FinReportPeriod frp = getPeriod (m_columns[col].getRelativePeriod());
|
||||
MID_FinReportPeriod frp = getPeriod (m_columns[col].getRelativePeriod());
|
||||
if (m_lines[line].getPAPeriodType() != null) // line amount type overwrites column
|
||||
{
|
||||
if (m_lines[line].isPeriod())
|
||||
if(p_Date1!=null) {
|
||||
String sql = frp.getDateRangeWhere();
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_lines[line].isPeriod())
|
||||
select.append(frp.getPeriodWhere());
|
||||
else if (m_lines[line].isYear())
|
||||
select.append(frp.getYearWhere());
|
||||
|
|
@ -1592,7 +1614,11 @@ public class MID_FinReport extends SvrProcess
|
|||
}
|
||||
else if (m_columns[col].getPAPeriodType() != null)
|
||||
{
|
||||
if (m_columns[col].isPeriod())
|
||||
if(p_Date1!=null) {
|
||||
String sql = frp.getDateRangeWhere();
|
||||
select.append(sql);
|
||||
}
|
||||
else if (m_columns[col].isPeriod())
|
||||
select.append(frp.getPeriodWhere());
|
||||
else if (m_columns[col].isYear())
|
||||
select.append(frp.getYearWhere());
|
||||
|
|
@ -1765,7 +1791,7 @@ public class MID_FinReport extends SvrProcess
|
|||
if (m_columns[index].isColumnTypeRelativePeriod())
|
||||
{
|
||||
BigDecimal relativeOffset = m_columns[index].getRelativePeriod();
|
||||
FinReportPeriod frp = getPeriod (relativeOffset);
|
||||
MID_FinReportPeriod frp = getPeriod (relativeOffset);
|
||||
|
||||
if ( s.contains("@Period@") )
|
||||
s = s.replace("@Period@", frp.getName() );
|
||||
|
|
|
|||
|
|
@ -37,13 +37,15 @@ public class MID_FinReportPeriod
|
|||
* @param YearStartDate year start date
|
||||
*/
|
||||
public MID_FinReportPeriod (int C_Period_ID, String Name, Timestamp StartDate, Timestamp EndDate,
|
||||
Timestamp YearStartDate)
|
||||
Timestamp YearStartDate, Timestamp date1, Timestamp date2)
|
||||
{
|
||||
m_C_Period_ID = C_Period_ID;
|
||||
m_Name = Name;
|
||||
m_StartDate = StartDate;
|
||||
m_EndDate = EndDate;
|
||||
m_YearStartDate = YearStartDate;
|
||||
m_Date1 = date1;
|
||||
m_Date2 = date2;
|
||||
} //
|
||||
|
||||
private int m_C_Period_ID;
|
||||
|
|
@ -51,7 +53,8 @@ public class MID_FinReportPeriod
|
|||
private Timestamp m_StartDate;
|
||||
private Timestamp m_EndDate;
|
||||
private Timestamp m_YearStartDate;
|
||||
|
||||
private Timestamp m_Date1;
|
||||
private Timestamp m_Date2;
|
||||
|
||||
/**
|
||||
* Get Period Info
|
||||
|
|
@ -160,5 +163,20 @@ public class MID_FinReportPeriod
|
|||
|
||||
return full;
|
||||
}
|
||||
|
||||
public String getDateRangeWhere ()
|
||||
{
|
||||
StringBuilder sql = new StringBuilder ("BETWEEN ");
|
||||
sql.append(DB.TO_DATE(m_Date1))
|
||||
.append(" AND ")
|
||||
.append(DB.TO_DATE(m_Date2));
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
public Timestamp getM_Date1() {
|
||||
return m_Date1;
|
||||
}
|
||||
public Timestamp getM_Date2() {
|
||||
return m_Date2;
|
||||
}
|
||||
} // FinReportPeriod
|
||||
|
|
|
|||
Loading…
Reference in New Issue