← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6658: Added relative periods to report table, this financial year, last financial year, last 5 financia...

 

------------------------------------------------------------
revno: 6658
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-04-20 09:38:56 +0200
message:
  Added relative periods to report table, this financial year, last financial year, last 5 financial years
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java	2012-04-05 11:57:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java	2012-04-20 07:38:56 +0000
@@ -142,7 +142,7 @@
         
         boolean past = cal.get( Calendar.MONTH ) >= getBaseMonth();
         
-        cal.add( Calendar.YEAR, past ? -5 : -6 );
+        cal.add( Calendar.YEAR, past ? -4 : -5 );
         cal.set( Calendar.MONTH, getBaseMonth() );
         cal.set( Calendar.DATE, 1 );
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java	2012-03-27 20:10:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java	2012-04-20 07:38:56 +0000
@@ -55,6 +55,8 @@
     public static final String LAST_SIXMONTH = "last_sixmonth";
     public static final String THIS_YEAR = "year";
     public static final String LAST_YEAR = "last_year";
+    public static final String THIS_FINANCIAL_YEAR = "financial_year";
+    public static final String LAST_FINANCIAL_YEAR = "last_financial_year";
 
     public static final String[] MONTHS_THIS_YEAR = {
         "january",
@@ -120,14 +122,21 @@
         "quarter1_last_year",
         "quarter2_last_year",
         "quarter3_last_year",
-        "quarter4_last_year"};
+        "quarter4_last_year" };
 
     public static final String[] LAST_5_YEARS = {
         "year_minus_4",
         "year_minus_3",
         "year_minus_2",
         "year_minus_1",
-        "year_this"};
+        "year_this" };
+    
+    public static final String[] LAST_5_FINANCIAL_YEARS = {
+        "financial_year_minus_4",
+        "financial_year_minus_3",
+        "financial_year_minus_2",
+        "financial_year_minus_1",
+        "financial_year_this" };
 
     private static final int MONTHS_IN_YEAR = 12;
 
@@ -160,6 +169,12 @@
     private boolean last4Quarters = false;
 
     private boolean last2SixMonths = false;
+    
+    private boolean thisFinancialYear = false;
+    
+    private boolean lastFinancialYear = false;
+    
+    private boolean last5FinancialYears = false;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -188,7 +203,8 @@
     public RelativePeriods( boolean reportingMonth, boolean reportingBimonth, boolean reportingQuarter, boolean lastSixMonth,
                             boolean monthsThisYear, boolean quartersThisYear, boolean thisYear,
                             boolean monthsLastYear, boolean quartersLastYear, boolean lastYear, boolean last5Years,
-                            boolean last12Months, boolean last6BiMonths, boolean last4Quarters, boolean last2SixMonths )
+                            boolean last12Months, boolean last6BiMonths, boolean last4Quarters, boolean last2SixMonths,
+                            boolean thisFinancialYear, boolean lastFinancialYear, boolean last5FinancialYears )
     {
         this.reportingMonth = reportingMonth;
         this.reportingBimonth = reportingBimonth;
@@ -205,6 +221,9 @@
         this.last6BiMonths = last6BiMonths;
         this.last4Quarters = last4Quarters;
         this.last2SixMonths = last2SixMonths;
+        this.thisFinancialYear = thisFinancialYear;
+        this.lastFinancialYear = lastFinancialYear;
+        this.last5FinancialYears = last5FinancialYears;
     }
 
     // -------------------------------------------------------------------------
@@ -393,6 +412,16 @@
             periods.addAll( getRelativePeriodList( new SixMonthlyPeriodType().generateRollingPeriods( date ), SIXMONHTS_LAST_2, dynamicNames, format ) );
         }
 
+        if ( isThisFinancialYear() )
+        {
+            periods.add( getRelativePeriod( new FinancialJulyPeriodType(), THIS_FINANCIAL_YEAR, date, dynamicNames, format ) );
+        }
+
+        if ( isLast5FinancialYears() )
+        {
+            periods.addAll( getRelativePeriodList( new FinancialJulyPeriodType().generateLast5Years( date ), LAST_5_FINANCIAL_YEARS, dynamicNames, format ) );
+        }
+
         date = getDate( MONTHS_IN_YEAR, date );
 
         if ( isMonthsLastYear() )
@@ -409,7 +438,12 @@
         {
             periods.add( getRelativePeriod( new YearlyPeriodType(), LAST_YEAR, date, dynamicNames, format ) );
         }
-
+        
+        if ( isLastFinancialYear() )
+        {
+            periods.add( getRelativePeriod( new FinancialJulyPeriodType(), LAST_FINANCIAL_YEAR, date, dynamicNames, format ) );
+        }
+        
         return periods;
     }
 
@@ -732,6 +766,42 @@
         return this;
     }
 
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    public boolean isThisFinancialYear()
+    {
+        return thisFinancialYear;
+    }
+
+    public void setThisFinancialYear( boolean thisFinancialYear )
+    {
+        this.thisFinancialYear = thisFinancialYear;
+    }
+
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    public boolean isLastFinancialYear()
+    {
+        return lastFinancialYear;
+    }
+
+    public void setLastFinancialYear( boolean lastFinancialYear )
+    {
+        this.lastFinancialYear = lastFinancialYear;
+    }
+
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    public boolean isLast5FinancialYears()
+    {
+        return last5FinancialYears;
+    }
+
+    public void setLast5FinancialYears( boolean last5FinancialYears )
+    {
+        this.last5FinancialYears = last5FinancialYears;
+    }
+
     // -------------------------------------------------------------------------
     // Equals, hashCode, and toString
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java	2012-04-20 07:38:56 +0000
@@ -61,7 +61,7 @@
     @Test
     public void getRelativePeriods()
     {        
-        RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true, true, true, true, true, true, true, true, true );
+        RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true );
         
         List<Period> relatives = periods.getRelativePeriods( getDate( 2001, 1, 1 ), i18nFormat, false );
         
@@ -120,8 +120,14 @@
         assertTrue( relatives.contains( new Period( new YearlyPeriodType(), getDate( 1999, 1, 1 ), getDate( 1999, 12, 31 ) ) ) );
         assertTrue( relatives.contains( new Period( new YearlyPeriodType(), getDate( 2000, 1, 1 ), getDate( 2000, 12, 31 ) ) ) );
         assertTrue( relatives.contains( new Period( new YearlyPeriodType(), getDate( 2001, 1, 1 ), getDate( 2001, 12, 31 ) ) ) );
-        
-        assertEquals( 67, relatives.size() );
+ 
+        assertTrue( relatives.contains( new Period( new FinancialJulyPeriodType(), getDate( 1996, 7, 1 ), getDate( 1997, 6, 30 ) ) ) );
+        assertTrue( relatives.contains( new Period( new FinancialJulyPeriodType(), getDate( 1997, 7, 1 ), getDate( 1998, 6, 30 ) ) ) );
+        assertTrue( relatives.contains( new Period( new FinancialJulyPeriodType(), getDate( 1998, 7, 1 ), getDate( 1999, 6, 30 ) ) ) );
+        assertTrue( relatives.contains( new Period( new FinancialJulyPeriodType(), getDate( 1999, 7, 1 ), getDate( 2000, 6, 30 ) ) ) );
+        assertTrue( relatives.contains( new Period( new FinancialJulyPeriodType(), getDate( 2000, 7, 1 ), getDate( 2001, 6, 30 ) ) ) );
+        System.out.println( relatives );
+        assertEquals( 74, relatives.size() );
     }
     
     @Test

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2012-04-19 08:56:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2012-04-20 07:38:56 +0000
@@ -398,6 +398,9 @@
         executeSql( "update reporttable set last6bimonths = false where last6bimonths is null" );
         executeSql( "update reporttable set last4quarters = false where last4quarters is null" );
         executeSql( "update reporttable set last2sixmonths = false where last2sixmonths is null" );
+        executeSql( "update reporttable set thisfinancialyear = false where thisfinancialyear is null" );
+        executeSql( "update reporttable set lastfinancialyear = false where lastfinancialyear is null" );
+        executeSql( "update reporttable set last5financialyears = false where last5financialyears is null" );
         executeSql( "update reporttable set cumulative = false where cumulative is null" );
 
         executeSql( "update chart set reportingmonth = false where reportingmonth is null" );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2012-04-18 20:24:12 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2012-04-20 07:38:56 +0000
@@ -92,6 +92,9 @@
       <property name="last12Months" />
       <property name="last4Quarters" />
       <property name="last2SixMonths" />
+	  <property name="thisFinancialYear" />
+	  <property name="lastFinancialYear" />
+	  <property name="last5FinancialYears" />
     </component>
 
     <component name="reportParams">

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-04-12 12:39:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-04-20 07:38:56 +0000
@@ -1417,7 +1417,10 @@
          isChecked( "last12Months" ) ||
          isChecked( "last6BiMonths" ) ||
          isChecked( "last4Quarters" ) ||
-         isChecked( "last2SixMonths" ) )
+         isChecked( "last2SixMonths" ) ||
+         isChecked( "thisFinancialYear" ) ||
+         isChecked( "lastFinancialYear" ) ||
+         isChecked( "last5FinancialYears" ) )
     {
         return true;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2012-04-07 14:06:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2012-04-20 07:38:56 +0000
@@ -327,6 +327,27 @@
     {
         this.last2SixMonths = last2SixMonths;
     }
+    
+    private boolean thisFinancialYear;
+
+    public void setThisFinancialYear( boolean thisFinancialYear )
+    {
+        this.thisFinancialYear = thisFinancialYear;
+    }
+
+    private boolean lastFinancialYear;
+
+    public void setLastFinancialYear( boolean lastFinancialYear )
+    {
+        this.lastFinancialYear = lastFinancialYear;
+    }
+
+    private boolean last5FinancialYears;
+
+    public void setLast5FinancialYears( boolean last5FinancialYears )
+    {
+        this.last5FinancialYears = last5FinancialYears;
+    }
 
     private boolean paramReportingMonth;
 
@@ -417,7 +438,8 @@
         RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter, lastSixMonth,
             monthsThisYear, quartersThisYear, thisYear, 
             monthsLastYear, quartersLastYear, lastYear, 
-            last5years, last12Months, false, last4Quarters, last2SixMonths );
+            last5years, last12Months, false, last4Quarters, last2SixMonths,
+            thisFinancialYear, lastFinancialYear, last5FinancialYears );
         
         ReportParams reportParams = new ReportParams();
         

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2012-04-16 14:54:22 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2012-04-20 07:38:56 +0000
@@ -208,4 +208,7 @@
 print=Print
 reporting_period=Reporting period
 completed_by=Completed by
-view_resource=View resource
\ No newline at end of file
+view_resource=View resource
+this_financial_year=This financial year
+last_financial_year=Last financial year
+last_5_financial_years=Last 5 financial years
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2012-04-07 14:06:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2012-04-20 07:38:56 +0000
@@ -421,14 +421,18 @@
 			<label for="quartersThisYear">$i18n.getString( "quarters_this_year" )</label>
 			<input type="checkbox" id="quartersThisYear" name="quartersThisYear" value="true"#if( $reportTable.relatives.isQuartersThisYear() ) checked#end>&nbsp;
 			<label for="thisYear">$i18n.getString( "this_year" )</label>
-			<input type="checkbox" id="thisYear" name="thisYear" value="true"#if( $reportTable.relatives.isThisYear() ) checked#end><br><br>
+			<input type="checkbox" id="thisYear" name="thisYear" value="true"#if( $reportTable.relatives.isThisYear() ) checked#end>&nbsp;
+			<label for="thisFinancialYear">$i18n.getString( "this_financial_year" )</label>
+			<input type="checkbox" id="thisFinancialYear" name="thisFinancialYear" value="true"#if( $reportTable.relatives.isThisFinancialYear() ) checked#end><br><br>
 			
 			<label for="monthsLastYear">$i18n.getString( "months_last_year" )</label>
 			<input type="checkbox" id="monthsLastYear" name="monthsLastYear" value="true""#if( $reportTable.relatives.isMonthsLastYear() ) checked#end>&nbsp;
 			<label for="quartersLastYear">$i18n.getString( "quarters_last_year" )</label>
 			<input type="checkbox" id="quartersLastYear" name="quartersLastYear" value="true"#if( $reportTable.relatives.isQuartersLastYear() ) checked#end>&nbsp;
 			<label for="lastYear">$i18n.getString( "last_year" )</label>
-			<input type="checkbox" id="lastYear" name="lastYear" value="true"#if( $reportTable.relatives.isLastYear() ) checked#end><br><br>
+			<input type="checkbox" id="lastYear" name="lastYear" value="true"#if( $reportTable.relatives.isLastYear() ) checked#end>&nbsp;
+			<label for="lastFinancialYear">$i18n.getString( "last_financial_year" )</label>
+			<input type="checkbox" id="lastFinancialYear" name="lastFinancialYear" value="true"#if( $reportTable.relatives.isLastFinancialYear() ) checked#end><br><br>
 				
 			<label for="last5years">$i18n.getString( "last_5_years" )</label>
 			<input type="checkbox" id="last5Years" name="last5Years" value="true"#if( $reportTable.relatives.isLast5Years() ) checked#end>&nbsp;
@@ -437,7 +441,9 @@
 			<label for="last4Quarters">$i18n.getString( "last_4_quarters" )</label>
 			<input type="checkbox" id="last4Quarters" name="last4Quarters" value="true"#if( $reportTable.relatives.isLast4Quarters() ) checked#end>&nbsp;
 			<label for="last2SixMonths">$i18n.getString( "last_2_sixmonths" )</label>
-			<input type="checkbox" id="last2SixMonths" name="last2SixMonths" value="true"#if( $reportTable.relatives.isLast2SixMonths() ) checked#end>
+			<input type="checkbox" id="last2SixMonths" name="last2SixMonths" value="true"#if( $reportTable.relatives.isLast2SixMonths() ) checked#end>&nbsp;
+			<label for="last5FinancialYears">$i18n.getString( "last_5_financial_years" )</label>
+			<input type="checkbox" id="last5FinancialYears" name="last5FinancialYears" value="true"#if( $reportTable.relatives.isLast5FinancialYears() ) checked#end>
         </td>
     </tr>
     <tr>