details: https://code.openbravo.com/erp/devel/pi/rev/6c0299666135 changeset: 26604:6c0299666135 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Thu May 07 12:11:39 2015 +0200 summary: Fixed bug 28787: Impossible to create several calendars for the same organization
Two pieces of code were affected by this bug: PeriodEventHandler.java: EntityPersistenceEventObserver in charge of checking overlap in manual inserts/updates (or any java process) in c_period table C_YEARPERIODS: db function associated to the create periods process inside the Fiscal Calendar | Year tab. It also verifies the periods don't overlap other periods. The fix consists in checking that there is no date overlap per calendar. Before this fix the calendar wasn't taken into account, so it was not possible to define several calendars for the same organization with the same periods. details: https://code.openbravo.com/erp/devel/pi/rev/1414a1029667 changeset: 26605:1414a1029667 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Fri May 08 14:02:09 2015 +0200 summary: Fixed bug 29823: Open/Close Period Control shows calendars associated to organizations The Open/Close Period Control window was showing all the periods available at the C_Period table. The target of this window is to open/close periods in fiscal calendars, so it should only show periods belonging to a fiscal calendar linked to an organization set as ready. The fix has 2 parts: 1. Added a hql where clause to include only periods belonging to a fiscal calendar linked to an organization set as ready. 2. The hql filter clause was wrong because it was filtering by the c_period.ad_org_id. Instead it should be filtering by the organization linked to the calendar's periods diffstat: src-db/database/model/functions/C_YEARPERIODS.xml | 16 +++++++++------- src-db/database/sourcedata/AD_TAB.xml | 3 ++- src/org/openbravo/event/PeriodEventHandler.java | 11 ++++++++--- 3 files changed, 19 insertions(+), 11 deletions(-) diffs (96 lines): diff -r 10f0bcd9165b -r 1414a1029667 src-db/database/model/functions/C_YEARPERIODS.xml --- a/src-db/database/model/functions/C_YEARPERIODS.xml Thu May 07 16:36:25 2015 +0200 +++ b/src-db/database/model/functions/C_YEARPERIODS.xml Fri May 08 14:02:09 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-2012 Openbravo, S.L.U. + * Contributions are Copyright (C) 2001-2015 Openbravo, S.L.U. * * Specifically, this derivative work is based upon the following Compiere * file and version. @@ -130,12 +130,14 @@ -- DBMS_OUTPUT.PUT_LINE('Adding Period ID: '||v_NextNo); 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; + 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; IF (V_COUNT > 0) THEN RAISE_APPLICATION_ERROR(-20000, '@DatesOverlapped@'); diff -r 10f0bcd9165b -r 1414a1029667 src-db/database/sourcedata/AD_TAB.xml --- a/src-db/database/sourcedata/AD_TAB.xml Thu May 07 16:36:25 2015 +0200 +++ b/src-db/database/sourcedata/AD_TAB.xml Fri May 08 14:02:09 2015 +0200 @@ -19049,8 +19049,9 @@ <!--E429CB8F5CDF4D8395B76D553E72A2D0--> <ISSORTTAB><![CDATA[N]]></ISSORTTAB> <!--E429CB8F5CDF4D8395B76D553E72A2D0--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID> <!--E429CB8F5CDF4D8395B76D553E72A2D0--> <UIPATTERN><![CDATA[SR]]></UIPATTERN> +<!--E429CB8F5CDF4D8395B76D553E72A2D0--> <HQLWHERECLAUSE><![CDATA[exists (from Organization o where e.year.calendar.id = o.calendar.id and o.ready=true)]]></HQLWHERECLAUSE> <!--E429CB8F5CDF4D8395B76D553E72A2D0--> <HQLORDERBYCLAUSE><![CDATA[startingDate]]></HQLORDERBYCLAUSE> -<!--E429CB8F5CDF4D8395B76D553E72A2D0--> <HQLFILTERCLAUSE><![CDATA[e.organization.id = ad_org_getperiodcontrolallow(@#AD_Org_ID@) and e._computedColumns.status not in ('P','C')]]></HQLFILTERCLAUSE> +<!--E429CB8F5CDF4D8395B76D553E72A2D0--> <HQLFILTERCLAUSE><![CDATA[exists (from Organization org where org.id = ad_org_getperiodcontrolallow(@#AD_Org_ID@) and e.year.calendar.id = org.calendar.id) and e._computedColumns.status not in ('P','C')]]></HQLFILTERCLAUSE> <!--E429CB8F5CDF4D8395B76D553E72A2D0--> <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS> <!--E429CB8F5CDF4D8395B76D553E72A2D0--> <DISABLE_PARENT_KEY_PROPERTY><![CDATA[N]]></DISABLE_PARENT_KEY_PROPERTY> <!--E429CB8F5CDF4D8395B76D553E72A2D0--> <ISREADONLYTREE><![CDATA[N]]></ISREADONLYTREE> diff -r 10f0bcd9165b -r 1414a1029667 src/org/openbravo/event/PeriodEventHandler.java --- a/src/org/openbravo/event/PeriodEventHandler.java Thu May 07 16:36:25 2015 +0200 +++ b/src/org/openbravo/event/PeriodEventHandler.java Fri May 08 14:02:09 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 Openbravo SLU + * All portions are Copyright (C) 2013-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************* @@ -34,6 +34,7 @@ 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 { @@ -45,7 +46,8 @@ return entities; } - public void onUpdate(@Observes EntityUpdateEvent event) { + public void onUpdate(@Observes + EntityUpdateEvent event) { if (!isValidEvent(event)) { return; } @@ -54,7 +56,8 @@ } } - public void onSave(@Observes EntityNewEvent event) { + public void onSave(@Observes + EntityNewEvent event) { if (!isValidEvent(event)) { return; } @@ -81,6 +84,8 @@ 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) { ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
