Related to issue 29808: Backout wrong changeset
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Tue, 19 May 2015 14:23:05 +0200
changeset 26700 ba8075e92bef
parent 26699 c279b5411456
child 26701 19fce9568e90
Related to issue 29808: Backout wrong changeset
The changeset pushed was not the good one, and failed in Oracle
src-db/database/model/functions/C_YEARPERIODS.xml
src/org/openbravo/event/PeriodEventHandler.java
--- a/src-db/database/model/functions/C_YEARPERIODS.xml	Mon May 18 17:30:26 2015 +0200
+++ b/src-db/database/model/functions/C_YEARPERIODS.xml	Tue May 19 14:23:05 2015 +0200
@@ -19,7 +19,7 @@
   * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
   * All Rights Reserved.
   * Contributor(s): Openbravo SLU
-  * Contributions are Copyright (C) 2001-2015 Openbravo, S.L.U.
+  * Contributions are Copyright (C) 2001-2012 Openbravo, S.L.U.
   *
   * Specifically, this derivative work is based upon the following Compiere
   * file and version.
@@ -129,15 +129,13 @@
         AD_Sequence_Next('C_Period', v_Year_ID, v_NextNo) ;
         --          DBMS_OUTPUT.PUT_LINE('Adding Period ID: '||v_NextNo);
 
-        SELECT COUNT(P.*) INTO V_COUNT 
-	FROM C_PERIOD P
-	INNER JOIN C_YEAR Y ON (P.C_YEAR_ID = Y.C_YEAR_ID)
-	WHERE P.C_PERIOD_ID <> v_NextNo
-	AND P.AD_ORG_ID = v_Org_ID
-	AND P.AD_CLIENT_ID = v_Client_ID
-	AND Y.C_CALENDAR_ID = v_Calendar_ID
-	AND TO_DATE(ADD_MONTHS(v_StartDate, v_MonthNo-1)) <= P.ENDDATE 
-	AND ADD_MONTHS(TRUNC(TO_DATE(ADD_MONTHS(v_StartDate, v_MonthNo-1)), 'MM'), 1) -1 >= P.STARTDATE;
+        SELECT COUNT(*) INTO V_COUNT 
+	FROM C_PERIOD 
+	WHERE C_PERIOD_ID <> v_NextNo
+	AND AD_ORG_ID = v_Org_ID
+	AND AD_CLIENT_ID = v_Client_ID
+	AND TO_DATE(ADD_MONTHS(v_StartDate, v_MonthNo-1)) <= ENDDATE 
+	AND ADD_MONTHS(TRUNC(TO_DATE(ADD_MONTHS(v_StartDate, v_MonthNo-1)), 'MM'), 1) -1 >= STARTDATE;
 	
 	IF (V_COUNT > 0) THEN
 		RAISE_APPLICATION_ERROR(-20000, '@DatesOverlapped@');
--- a/src/org/openbravo/event/PeriodEventHandler.java	Mon May 18 17:30:26 2015 +0200
+++ b/src/org/openbravo/event/PeriodEventHandler.java	Tue May 19 14:23:05 2015 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2013-2015 Openbravo SLU
+ * All portions are Copyright (C) 2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -34,7 +34,6 @@
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.financialmgmt.calendar.Period;
-import org.openbravo.model.financialmgmt.calendar.Year;
 import org.openbravo.service.db.DalConnectionProvider;
 
 public class PeriodEventHandler extends EntityPersistenceEventObserver {
@@ -46,8 +45,7 @@
     return entities;
   }
 
-  public void onUpdate(@Observes
-  EntityUpdateEvent event) {
+  public void onUpdate(@Observes EntityUpdateEvent event) {
     if (!isValidEvent(event)) {
       return;
     }
@@ -56,8 +54,7 @@
     }
   }
 
-  public void onSave(@Observes
-  EntityNewEvent event) {
+  public void onSave(@Observes EntityNewEvent event) {
     if (!isValidEvent(event)) {
       return;
     }
@@ -84,8 +81,6 @@
     criteria.add(Restrictions.ge(Period.PROPERTY_ENDINGDATE, period.getStartingDate()));
     criteria.add(Restrictions.le(Period.PROPERTY_STARTINGDATE, period.getEndingDate()));
     criteria.add(Restrictions.eq(Period.PROPERTY_PERIODTYPE, "S"));
-    criteria.createAlias(Period.PROPERTY_YEAR, "y");
-    criteria.add(Restrictions.eq("y." + Year.PROPERTY_CALENDAR, period.getYear().getCalendar()));
     criteria.setMaxResults(1);
 
     if (criteria.uniqueResult() != null) {