Fixed bug 28952: Period Not Updated in G/L Journal if Acct Date belongs to a closed period.
authorFernando Soto <fernando.soto@peoplewalking.com>
Mon, 23 Mar 2015 14:11:56 -0500
changeset 26421 908de9299675
parent 26420 b509a9c376d0
child 26422 17cd117fb31b
Fixed bug 28952: Period Not Updated in G/L Journal if Acct Date belongs to a closed period.

Modified SL_Journal_Period class (callout) to display a error message if the Acct. Date belongs to a closed period.
Modified GL_JOURNAL_CHK_RESTRICT_TRG trigger to not allow to save if the Acct. Date belongs to a closed period.
Created UpdateGLJournalDateAcct to fix the data.
src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml
src/org/openbravo/erpCommon/ad_callouts/SL_Journal_Period.java
--- a/src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml	Fri Mar 27 15:57:12 2015 -0500
+++ b/src-db/database/model/triggers/GL_JOURNAL_CHK_RESTRICT_TRG.xml	Mon Mar 23 14:11:56 2015 -0500
@@ -19,12 +19,12 @@
     * under the License.
     * The Original Code is Openbravo ERP.
     * The Initial Developer of the Original Code is Openbravo SLU
-    * All portions are Copyright (C) 2001-2012 Openbravo SLU
+    * All portions are Copyright (C) 2001-2015 Openbravo SLU
     * All Rights Reserved.
     * Contributor(s):  ______________________________________.
     ************************************************************************/
     v_DateNull DATE := TO_DATE('01-01-1900', 'DD-MM-YYYY');
-        
+    v_ValidPeriod NUMBER;    
 BEGIN
     
     IF AD_isTriggerEnabled()='N' THEN RETURN;
@@ -59,6 +59,13 @@
         )) 
         THEN RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
       END IF;    
+
+      
+      IF (:old.DateAcct <> :new.DateAcct and 
+        c_chk_open_period(:new.AD_ORG_ID, :new.DATEACCT, null, :new.C_DOCTYPE_ID) <> 1) THEN 
+        RAISE_APPLICATION_ERROR(-20000, '@PeriodNotValid@');
+      END IF;
+
     END IF;
     IF(DELETING) THEN
       IF(:old.Processed='Y') THEN
@@ -69,6 +76,9 @@
       IF(:NEW.Processed='Y') THEN
         RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
       END IF;
+      IF (c_chk_open_period(:new.AD_ORG_ID, :new.DATEACCT, null, :new.C_DOCTYPE_ID) <> 1) THEN 
+        RAISE_APPLICATION_ERROR(-20000, '@PeriodNotValid@');
+      END IF;
     END IF;
     END GL_JOURNAL_CHK_RESTRICT_TRG
 ]]></body>
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_Journal_Period.java	Fri Mar 27 15:57:12 2015 -0500
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_Journal_Period.java	Mon Mar 23 14:11:56 2015 -0500
@@ -103,8 +103,24 @@
     // When DateAcct is changed, set C_Period_ID
     if (strChanged.equals("inpdateacct")) {
       strcPeriodId = SLJournalPeriodData.period(this, stradClientId, stradOrgId, strDateAcct);
-      if (strcPeriodId.equals(""))
-        strcPeriodId = strcPeriodIdNew;
+      if (strcPeriodId.equals("")) {
+//        strcPeriodId = strcPeriodIdNew;
+
+        StringBuffer resultado = new StringBuffer();
+        resultado.append("var calloutName='SL_Journal_Period';\n\n");
+        resultado.append("var respuesta = new Array(");
+        resultado.append("new Array(\"ERROR\", \"" 
+            + Utility.messageBD(this, "PeriodNotValid", vars.getLanguage()) + "\")");
+        resultado.append(");");
+        xmlDocument.setParameter("array", resultado.toString());
+        xmlDocument.setParameter("frameName", "appFrame");
+        response.setContentType("text/html; charset=UTF-8");
+        PrintWriter out = response.getWriter();
+        out.println(xmlDocument.print());
+        out.close();
+        return;
+      }
+      
     }
     boolean isStandardPeriod = true;
     if (strChanged.equals("inpcPeriodId") && !strcPeriodId.equals("")) {