details:   https://code.openbravo.com/erp/devel/pi/rev/a9ba88ccb266
changeset: 18187:a9ba88ccb266
user:      amayavicente <avi <at> openbravo.com>
date:      Wed Oct 10 17:41:19 2012 +0200
summary:   Fixes issue:21819:AcctServer classes need some new methods

diffstat:

 src/org/openbravo/erpCommon/ad_forms/AcctServer.java      |  45 +++++++++-
 src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql |  67 +++++++++++++++
 2 files changed, 109 insertions(+), 3 deletions(-)

diffs (155 lines):

diff -r 86ff038e5ebd -r a9ba88ccb266 
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Wed Oct 10 
11:57:22 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Wed Oct 10 
17:41:19 2012 +0200
@@ -350,6 +350,11 @@
   }
 
   public void run(VariablesSecureApp vars) throws IOException, 
ServletException {
+    run(vars, null, null);
+  }
+
+  public void run(VariablesSecureApp vars, String strDateFrom, String 
strDateTo)
+      throws IOException, ServletException {
     if (AD_Client_ID.equals(""))
       AD_Client_ID = vars.getClient();
     Connection con = null;
@@ -357,13 +362,23 @@
       String strIDs = "";
 
       if (log4j.isDebugEnabled()) {
-        log4j.debug("AcctServer - Run - TableName = " + tableName);
+        log4j.debug("AcctServer - Run - TableName = " + tableName + 
strDateFrom + strDateTo);
       }
 
       log4j.debug("AcctServer.run - AD_Client_ID: " + AD_Client_ID);
-      AcctServerData[] data = AcctServerData.select(connectionProvider, 
tableName, AD_Client_ID,
-          AD_Org_ID, strDateColumn, 0, Integer.valueOf(batchSize).intValue());
 
+      AcctServerData[] data = null;
+
+      if ((strDateFrom == null && strDateTo == null)
+          || (strDateFrom.equals("") && strDateTo.equals(""))) {
+        data = AcctServerData.select(connectionProvider, tableName, 
AD_Client_ID, AD_Org_ID,
+            strDateColumn, 0, Integer.valueOf(batchSize).intValue());
+      } else {
+
+        data = AcctServerData.selectFilterDates(connectionProvider, tableName, 
AD_Client_ID,
+            AD_Org_ID, strDateColumn, strDateFrom, strDateTo);
+
+      }
       if (data != null && data.length > 0) {
         if (log4j.isDebugEnabled()) {
           log4j.debug("AcctServer - Run -Select inicial realizada N = " + 
data.length + " - Key: "
@@ -1878,6 +1893,30 @@
     return false;
   } // end of checkDocuments() method
 
+  public boolean filterDatesCheckDocuments(String dateFrom, String dateTo) 
throws ServletException {
+    if (m_as.length == 0)
+      return false;
+    AcctServerData[] docTypes = 
AcctServerData.selectDocTypes(connectionProvider, AD_Table_ID,
+        AD_Client_ID);
+    // if (log4j.isDebugEnabled())
+    // log4j.debug("AcctServer - AcctSchema length-" + (this.m_as).length);
+    for (int i = 0; i < docTypes.length; i++) {
+      AcctServerData data = 
AcctServerData.filterDatesSelectDocuments(connectionProvider,
+          tableName, AD_Client_ID, AD_Org_ID, docTypes[i].name, strDateColumn, 
dateFrom, dateTo);
+
+      if (data != null) {
+        if (data.id != null && !data.id.equals("")) {
+          if (log4j.isDebugEnabled()) {
+            log4j.debug("AcctServer - not posted - " + docTypes[i].name + " 
document id: "
+                + data.id);
+          }
+          return true;
+        }
+      }
+    }
+    return false;
+  } // end of filterDatesCheckDocuments() method
+
   public void setMessageResult(OBError error) {
     messageResult = error;
   }
diff -r 86ff038e5ebd -r a9ba88ccb266 
src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql Wed Oct 10 
11:57:22 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql Wed Oct 10 
17:41:19 2012 +0200
@@ -551,6 +551,44 @@
       <Parameter name="dateColumn" type="replace" optional="true" after="and   
 a." text="dateacct"/>
       <Parameter name="dateColumn" type="replace" optional="true" after="and   
  a." text="dateacct"/>
    </SqlMethod>
+   <SqlMethod name="filterDatesSelectDocuments" type="preparedStatement" 
return="single">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql>
+      <![CDATA[
+        select MIN(C_INVOICE_ID) as id
+        from c_invoice a, ad_org
+        where posted = 'N'
+        and processed = 'Y'
+        and (processing = 'N' or processing is null)
+        AND ad_org.ad_org_id=a.ad_org_id
+        AND a.ad_client_id = ?
+        AND AD_ISORGINCLUDED(ad_org.ad_org_id, ?, ad_org.ad_client_id)<>-1
+        AND EXISTS (select 1
+               from c_year, c_period, c_periodcontrol, ad_org
+               where c_year.c_year_id = c_period.c_year_id
+              and c_period.c_period_id = c_periodcontrol.c_period_id
+              and c_year.c_calendar_id = ad_org.c_calendar_id
+              and ad_org.ad_client_id = a.ad_client_id
+              and c_periodcontrol.docbasetype = ?
+              and c_periodcontrol.periodstatus = 'O'
+              and    a.dateacct >= c_period.StartDate
+              and     a.dateacct < c_period.EndDate + 1)
+        and      a.dateacct >= to_date(?)
+        and       a.dateacct <= to_date(?)
+      ]]>
+      </Sql>
+      <Parameter name="tableName" type="replace" optional="true" after="select 
MIN(" text="C_INVOICE"/>
+      <Parameter name="tableName" type="replace" optional="true" after="from " 
text="c_invoice"/>
+      <Parameter name="adClientId" />
+      <Parameter name="adOrgId"/>
+      <Parameter name="docbasetype"/>
+      <Parameter name="dateColumn" type="replace" optional="true" after="and   
 a." text="dateacct"/>
+      <Parameter name="dateColumn" type="replace" optional="true" after="and   
  a." text="dateacct"/>
+      <Parameter name="dateColumn" type="replace" optional="true" after="and   
   a." text="dateacct"/>
+      <Parameter name="dateColumn" type="replace" optional="true" after="and   
    a." text="dateacct"/>
+      <Parameter name="dateFrom"/>
+      <Parameter name="dateTo"/>
+   </SqlMethod>
    <SqlMethod name="selectDocTypes" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql>
@@ -673,4 +711,33 @@
      <Parameter name="acctschemaId"/>
      <Parameter name="tableId"/>
    </SqlMethod>
+   <SqlMethod name="selectFilterDates" type="preparedStatement" 
return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+          Select * from(
+        SELECT  a.C_INVOICE_ID AS ID
+        FROM C_INVOICE a, ad_org WHERE a.AD_CLIENT_ID=?
+        AND ad_org.ad_org_id=a.ad_org_id
+        AND AD_ISORGINCLUDED(ad_org.ad_org_id, ?, ad_org.ad_client_id)<>-1
+        AND PROCESSED='Y'
+        AND (PROCESSING='N' OR PROCESSING IS NULL)
+        AND POSTED='N'
+        AND a.DATEACCT >= to_date(?)
+        AND  a.DATEACCT <= to_date(?)
+        ORDER BY a.CREATED) A
+     ]]>
+     </Sql>
+     <Parameter name="tableName" type="replace" optional="true" after="SELECT  
a." text="C_INVOICE"/>
+     <Parameter name="tableName" type="replace" optional="true" after="FROM " 
text="C_INVOICE"/>
+     <Parameter name="client"/>
+     <Parameter name="org"/>
+     <Parameter name="dateColumn" type="replace" optional="true" after="AND 
a." text="DATEACCT"/>
+     <Parameter name="dateColumn" type="replace" optional="true" after="AND  
a." text="DATEACCT"/>
+     <Parameter name="dateFrom"/>
+     <Parameter name="dateTo"/>
+     <Parameter name="dateColumn" type="replace" optional="true" after="ORDER 
BY a." text="CREATED"/>
+   </SqlMethod>
+   
   </SqlClass>
+  

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to