Fix [2519902] factacctreset contains a sql-statement with an error

https://sourceforge.net/tracker2/?func=detail&atid=879332&aid=2519902&group_id=176962
QA for [ 2432714 ] Reset accounting ignores automatic period control
https://sourceforge.net/tracker/index.php?func=detail&aid=2432714&group_id=176962&atid=879332
This commit is contained in:
Carlos Ruiz 2009-01-19 16:53:25 +00:00
parent 87c1fd51bf
commit fd421d842c
1 changed files with 28 additions and 21 deletions

View File

@ -181,11 +181,15 @@ public class FactAcctReset extends SvrProcess
if (autoPeriod)
{
Timestamp temp = TimeUtil.addDays(today, - as.getPeriod_OpenHistory());
if ( p_DateAcct_From == null || p_DateAcct_From.before(temp) )
if ( p_DateAcct_From == null || p_DateAcct_From.before(temp) ) {
p_DateAcct_From = temp;
log.info("DateAcct From set to: " + p_DateAcct_From);
}
temp = TimeUtil.addDays(today, as.getPeriod_OpenFuture());
if ( p_DateAcct_To == null || p_DateAcct_To.after(temp) )
if ( p_DateAcct_To == null || p_DateAcct_To.after(temp) ) {
p_DateAcct_To = temp;
log.info("DateAcct To set to: " + p_DateAcct_To);
}
}
reset(TableName);
@ -252,37 +256,40 @@ public class FactAcctReset extends SvrProcess
docBaseType = " AND pc.DocBaseType " + docBaseType;
// Doc
String sql1 = "UPDATE " + TableName + " doc"
String sql1 = "UPDATE " + TableName
+ " SET Posted='N', Processing='N' "
+ "WHERE AD_Client_ID=" + p_AD_Client_ID
+ " AND (Posted<>'N' OR Posted IS NULL OR Processing<>'N' OR Processing IS NULL)"
+ " AND EXISTS (SELECT * FROM C_PeriodControl pc"
+ " INNER JOIN Fact_Acct fact ON (fact.C_Period_ID=pc.C_Period_ID) "
+ " AND EXISTS (SELECT 1 FROM C_PeriodControl pc"
+ " INNER JOIN Fact_Acct fact ON (fact.C_Period_ID=pc.C_Period_ID) "
+ " WHERE fact.AD_Table_ID=" + AD_Table_ID
+ " AND fact.Record_ID=doc." + TableName + "_ID";
if ( !autoPeriod )
sql1 += " AND pc.PeriodStatus = 'O'" + docBaseType;
if (p_DateAcct_From != null)
sql1 += " AND TRIM(fact.DateAcct) >= " + DB.TO_DATE(p_DateAcct_From);
if (p_DateAcct_To != null)
sql1 += " AND TRIM(fact.DateAcct) <= " + DB.TO_DATE(p_DateAcct_To);
sql1 += ")";
+ " AND fact.Record_ID=" + TableName + "." + TableName + "_ID";
if ( !autoPeriod )
sql1 += " AND pc.PeriodStatus = 'O'" + docBaseType;
if (p_DateAcct_From != null)
sql1 += " AND TRUNC(fact.DateAcct) >= " + DB.TO_DATE(p_DateAcct_From);
if (p_DateAcct_To != null)
sql1 += " AND TRUNC(fact.DateAcct) <= " + DB.TO_DATE(p_DateAcct_To);
sql1 += ")";
log.log(Level.FINE, sql1);
int reset = DB.executeUpdate(sql1, get_TrxName());
// Fact
String sql2 = "DELETE Fact_Acct fact "
String sql2 = "DELETE Fact_Acct "
+ "WHERE AD_Client_ID=" + p_AD_Client_ID
+ " AND AD_Table_ID=" + AD_Table_ID;
if ( !autoPeriod )
sql2 += " AND EXISTS (SELECT * FROM C_PeriodControl pc"
sql2 += " AND EXISTS (SELECT 1 FROM C_PeriodControl pc "
+ "WHERE pc.PeriodStatus = 'O'" + docBaseType
+ " AND fact.C_Period_ID=pc.C_Period_ID)";
+ " AND Fact_Acct.C_Period_ID=pc.C_Period_ID)";
else
sql2 += " AND EXISTS (SELECT 1 FROM C_PeriodControl pc "
+ "WHERE Fact_Acct.C_Period_ID=pc.C_Period_ID)";
if (p_DateAcct_From != null)
sql2 += " AND TRIM(fact.DateAcct) >= " + DB.TO_DATE(p_DateAcct_From);
sql2 += " AND TRUNC(Fact_Acct.DateAcct) >= " + DB.TO_DATE(p_DateAcct_From);
if (p_DateAcct_To != null)
sql2 += " AND TRIM(fact.DateAcct) <= " + DB.TO_DATE(p_DateAcct_To);
sql2 += " AND TRUNC(Fact_Acct.DateAcct) <= " + DB.TO_DATE(p_DateAcct_To);
log.log(Level.FINE, sql2);