← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14590: PBF Payment Adjustment

 

------------------------------------------------------------
revno: 14590
committer: samta bajpayee<samta.bajpayee@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-01 19:59:55 +0100
message:
  PBF Payment Adjustment
added:
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentNextPrePeriodsAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentPeriodsAction.java
modified:
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/GetOrganisationUnitForPaymentAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/GetPaymentAdjustmentDetailsAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentAdjustmentDetailsAction.java
  local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties
  local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getPaymentAdjustmentList.vm
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/paymentAdjustment.js
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/jsonPeriods.vm
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadPaymentAdjustment.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 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/GetOrganisationUnitForPaymentAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/GetOrganisationUnitForPaymentAction.java	2014-03-28 18:52:45 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/GetOrganisationUnitForPaymentAction.java	2014-04-01 18:59:55 +0000
@@ -1,20 +1,29 @@
 package org.hisp.dhis.pbf.payment.action;
 
 import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.pbf.api.Lookup;
 import org.hisp.dhis.pbf.api.LookupService;
+import org.hisp.dhis.period.CalendarPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
+import org.hisp.dhis.system.util.FilterUtils;
 
 import com.opensymphony.xwork2.Action;
 
 public class GetOrganisationUnitForPaymentAction implements Action
 {
+	
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -39,7 +48,12 @@
     {
         this.dataSetService = dataSetService;
     }
-    
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
     
     // -------------------------------------------------------------------------
     // Input/output
@@ -69,7 +83,12 @@
     {
         return dataSets;
     }
+    private List<Period> periods = new ArrayList<Period>();
 
+    public Collection<Period> getPeriods()
+    {
+        return periods;
+    }
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -98,8 +117,26 @@
 
 			dataSets.add(dataSet);
 		}
-        Collections.sort(dataSets);
-        
+        Collections.sort(dataSets); 
+        String periodType = "Quarterly" ;
+        
+        CalendarPeriodType _periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( periodType );
+        
+        Calendar cal = PeriodType.createCalendarInstance();
+        
+        periods = _periodType.generatePeriods( cal.getTime() );
+        //periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( periodType ) );
+        
+        FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+
+        Collections.reverse( periods );
+        //Collections.sort( periods );
+        for ( Period period : periods )
+        {
+            //System.out.println("ISO Date : " + period.getIsoDate() );
+            
+            period.setName( format.formatPeriod( period ) );
+        }
        
         System.out.println( dataSets.size() );
         if ( dataSets.size() > 0 )

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/GetPaymentAdjustmentDetailsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/GetPaymentAdjustmentDetailsAction.java	2014-03-28 18:52:45 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/GetPaymentAdjustmentDetailsAction.java	2014-04-01 18:59:55 +0000
@@ -1,16 +1,25 @@
 package org.hisp.dhis.pbf.payment.action;
 
 import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 import org.hisp.dhis.constant.Constant;
 import org.hisp.dhis.constant.ConstantService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.pbf.api.Lookup;
 import org.hisp.dhis.pbf.api.LookupService;
+import org.hisp.dhis.period.CalendarPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
+import org.hisp.dhis.system.util.FilterUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -47,7 +56,14 @@
 	public void setConstantService(ConstantService constantService) {
 		this.constantService = constantService;
 	}
+	
+	private I18nFormat format;
 
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+    
 	// -------------------------------------------------------------------------
 	// Input / Output
 	// -------------------------------------------------------------------------
@@ -69,12 +85,24 @@
 	public String getAmountDEId() {
 		return amountDEId;
 	}
+	
+	private List<Period> periods = new ArrayList<Period>();
+
+    public Collection<Period> getPeriods()
+    {
+        return periods;
+    }
+    
+    private String amountAvailable = "";
+    
+    public String getAmountAvailable() {
+		return amountAvailable;
+	}
+    
 	// -------------------------------------------------------------------------
 	// Action implementation
 	// -------------------------------------------------------------------------
 
-	
-
 	public String execute() throws Exception {
 		Constant orgUnitGrp = constantService
 				.getConstantByName(PAYMENT_ADJUSTMENT_LEVEL_ORG_GROUP);
@@ -104,6 +132,27 @@
 
 			dataSets.add(dataSet);
 		}
+		String periodType = "Quarterly" ;
+        
+        CalendarPeriodType _periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( periodType );
+        
+        Calendar cal = PeriodType.createCalendarInstance();
+        
+        periods = _periodType.generatePeriods( cal.getTime() );
+        //periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( periodType ) );
+        
+        FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+
+        Collections.reverse( periods );
+        //Collections.sort( periods );
+        for ( Period period : periods )
+        {
+            //System.out.println("ISO Date : " + period.getIsoDate() );
+            
+            period.setName( format.formatPeriod( period ) );
+        }
+        
+        
 		return SUCCESS;
 	}
 }
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentAdjustmentDetailsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentAdjustmentDetailsAction.java	2014-03-28 18:52:45 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentAdjustmentDetailsAction.java	2014-04-01 18:59:55 +0000
@@ -3,39 +3,35 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
-import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.constant.Constant;
 import org.hisp.dhis.constant.ConstantService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.pbf.api.LookupService;
-import org.hisp.dhis.pbf.api.QualityMaxValue;
-import org.hisp.dhis.pbf.api.QualityMaxValueService;
 import org.hisp.dhis.pbf.api.TariffDataValue;
 import org.hisp.dhis.pbf.api.TariffDataValueService;
 import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
 public class LoadPaymentAdjustmentDetailsAction
     implements Action
 {
-
+	private final static String PAYMENT_ADJUSTMENT_AMOUNT_DE = "PAYMENT_ADJUSTMENT_AMOUNT_DE";
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -73,8 +69,21 @@
     {
         this.tariffDataValueService = tariffDataValueService;
     }
-
-
+    private DataElementService dataElementService;
+
+	public void setDataElementService(DataElementService dataElementService) {
+		this.dataElementService = dataElementService;
+	}
+
+	private ConstantService constantService;
+
+	public void setConstantService(ConstantService constantService) {
+		this.constantService = constantService;
+	}
+	
+	@Autowired
+	private PeriodService periodService;
+	
     // -------------------------------------------------------------------------
     // Input / Output
     // -------------------------------------------------------------------------
@@ -125,6 +134,12 @@
 		return tariffDataValueMap;
 	}
     
+    private String amountAvailable = "";
+    
+    public String getAmountAvailable() {
+		return amountAvailable;
+	}
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -140,31 +155,46 @@
         
         dataElements.addAll(dataSet.getDataElements());
         
+        Constant paymentAmount = constantService.getConstantByName(PAYMENT_ADJUSTMENT_AMOUNT_DE);
+		
+		String amountDEId = paymentAmount.getValue()+"";
+        
         DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
         
         for(DataElement de : dataElements)
         {
-        	DataValue dataValue = dataValueService.getDataValue(de, period, organisationUnit, optionCombo );
-        	if(dataValue != null)
-        	{
-        		quantityValidatedMap.put(de.getUid(), dataValue.getValue());
-        	}
-        	else
-        	{
-        		quantityValidatedMap.put(de.getUid(), "");
-        	} 
-        	TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue(organisationUnit, de, dataSet, period.getStartDate(), period.getEndDate());
-        	
-        	if(tariffDataValue != null)
-        	{
-        		tariffDataValueMap.put(de.getUid(), tariffDataValue.getValue()+"");
-        	}
-        	else
-        	{
-        		tariffDataValueMap.put(de.getUid(), "");
-        	}
+        	int quantityValue = 0;
+        	int tariffValue = 0;
+        	List<OrganisationUnit> orgList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( organisationUnit.getId()));
+        	for(OrganisationUnit ou : orgList )
+        	{
+        		List<Period> periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates(period.getStartDate(), period.getEndDate()));
+	        	for(Period prd : periodList)
+	        	{
+	        		DataValue dataValue = dataValueService.getDataValue(de, prd, ou, optionCombo );
+		        	if(dataValue != null)
+		        	{
+		        		quantityValue = quantityValue + Integer.parseInt(dataValue.getValue());	        		
+		        	}	        	
+		        	TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue( ou , de, dataSet, prd.getStartDate(), prd.getEndDate());
+		        	
+		        	if(tariffDataValue != null)
+		        	{
+		        		tariffValue = tariffValue + Integer.parseInt(tariffDataValue.getValue()+"");
+		        	}
+	        	}
+        	}
+        	quantityValidatedMap.put(de.getUid(), quantityValue+"" );
+        	tariffDataValueMap.put(de.getUid(), tariffValue+"");
         }
+        Collections.sort(dataElements);
+        DataElement dataElement = dataElementService.getDataElement((int)paymentAmount.getValue());
+        DataValue dataValue = dataValueService.getDataValue(dataElement, period, organisationUnit, optionCombo);
         
+        if(dataValue != null)
+        {
+        	amountAvailable = dataValue.getValue();        	
+        }
         return SUCCESS;
     }
 }
\ No newline at end of file

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentNextPrePeriodsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentNextPrePeriodsAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentNextPrePeriodsAction.java	2014-04-01 18:59:55 +0000
@@ -0,0 +1,114 @@
+package org.hisp.dhis.pbf.payment.action;
+
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.period.CalendarPeriodType;
+import org.hisp.dhis.period.MonthlyPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
+import org.hisp.dhis.system.util.FilterUtils;
+import org.hisp.dhis.util.SessionUtils;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ */
+
+public class LoadPaymentNextPrePeriodsAction implements Action
+{
+   
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+   
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private int dataSetId;
+    
+    public void setDataSetId( int dataSetId )
+    {
+        this.dataSetId = dataSetId;
+    }
+
+    private int year;
+
+    public void setYear( int year )
+    {
+        this.year = year;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<Period> periods;
+
+    public List<Period> getPeriods()
+    {
+        return periods;
+    }
+
+    private String periodType;
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()  throws Exception
+    {
+        
+    	String periodType = "Quarterly";
+        
+        //periodType = periodType != null && !periodType.isEmpty() ? periodType : MonthlyPeriodType.NAME;
+
+        CalendarPeriodType _periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( periodType );
+
+        int thisYear = Calendar.getInstance().get( Calendar.YEAR );
+
+        int currentYear = (Integer) SessionUtils.getSessionVar( SessionUtils.KEY_CURRENT_YEAR, thisYear );
+
+        Calendar cal = PeriodType.createCalendarInstance();
+
+        // Cannot go to next year if current year equals this year
+        
+        if ( !( currentYear == thisYear && year > 0 ) )
+        {
+            cal.set( Calendar.YEAR, currentYear );
+            cal.add( Calendar.YEAR, year );
+
+            SessionUtils.setSessionVar( SessionUtils.KEY_CURRENT_YEAR, cal.get( Calendar.YEAR ) );
+        }
+
+        periods = _periodType.generatePeriods( cal.getTime() );
+
+        FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+
+        Collections.reverse( periods );
+
+
+        for ( Period period : periods )
+        {
+            period.setName( format.formatPeriod( period ) );
+        }
+
+        return SUCCESS;
+    }
+
+
+}

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentPeriodsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentPeriodsAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentPeriodsAction.java	2014-04-01 18:59:55 +0000
@@ -0,0 +1,91 @@
+package org.hisp.dhis.pbf.payment.action;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.period.CalendarPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
+import org.hisp.dhis.system.util.FilterUtils;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Samta Bajpai
+ */
+
+public class LoadPaymentPeriodsAction implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+    
+    private int dataSetId;
+    
+    public void setDataSetId( int dataSetId )
+    {
+        this.dataSetId = dataSetId;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+ 
+    private List<Period> periods = new ArrayList<Period>();
+
+    public Collection<Period> getPeriods()
+    {
+        return periods;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute() throws Exception
+    { 
+       
+        String periodType = "Quarterly";
+        
+        CalendarPeriodType _periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( periodType );
+        
+        Calendar cal = PeriodType.createCalendarInstance();
+        
+        periods = _periodType.generatePeriods( cal.getTime() );
+        
+        //periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( periodType ) );
+        
+        FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+
+        Collections.reverse( periods );
+        //Collections.sort( periods );
+        for ( Period period : periods )
+        {
+            //System.out.println("ISO Date : " + period.getIsoDate() );
+            
+            period.setName( format.formatPeriod( period ) );
+        }
+        
+        return SUCCESS;
+    }
+}
+

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml	2014-03-28 18:52:45 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml	2014-04-01 18:59:55 +0000
@@ -259,6 +259,8 @@
 		<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="tariffDataValueService" ref="org.hisp.dhis.pbf.api.TariffDataValueService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
 	</bean>
 	
 	<!-- Save Quality Data -->

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties	2014-03-14 11:22:16 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties	2014-04-01 18:59:55 +0000
@@ -26,8 +26,16 @@
 quality_score = Score
 quality_max = Max
 quality_percentage = Percentage
-
-
+payment_adjustment = Payment Adjustment
+payment_adjustment_screen = Payment adjustment screen for quarterly payments?
+amount_avaliable = Amount Available
+adjustment_per = Adjustment %
+indicator = Indicator
+quantity_for = Quantity for
+payment = Payment
+amount = Amount
+amount_including_quality = Amount (Including Quality)
+adjusted_per = Adjusted
 
 aggregation_builder = Aggregation Builder
 aggregation_query_list = Aggregation Query List

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml	2014-03-28 18:52:45 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml	2014-04-01 18:59:55 +0000
@@ -173,6 +173,15 @@
 	</action>
 		
 	<!-- Payment Adjustment Screen -->
+		
+	 <action name="loadPaymentPeriods" class="org.hisp.dhis.pbf.payment.action.LoadPaymentPeriodsAction">
+        <result name="success" type="velocity-json">/dhis-web-maintenance-pbf/jsonPeriods.vm</result>
+    </action>
+	
+	<action name="getPaymentAvailableNextPrePeriods" class="org.hisp.dhis.pbf.payment.action.LoadPaymentNextPrePeriodsAction">
+        <result name="success" type="velocity-json">/dhis-web-maintenance-pbf/jsonPeriods.vm</result>
+    </action>
+		
 	<action name="getOrganisationUnitForPayment" class="org.hisp.dhis.pbf.payment.action.GetOrganisationUnitForPaymentAction">
         <result name="success" type="velocity-json">/dhis-web-maintenance-pbf/jsonResponseSuccess.vm</result>
         <result name="input" type="velocity-json">/dhis-web-maintenance-pbf/jsonResponseInput.vm</result>
@@ -183,8 +192,8 @@
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-maintenance-pbf/getPaymentAdjustmentList.vm</param>
       <param name="menu">/dhis-web-maintenance-pbf/menuPayment.vm</param>
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/paymentAdjustment.js</param>
-      <param name="stylesheets">css/dataentry.css</param>
+      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/paymentAdjustment.js,../dhis-web-commons/javascripts/ext/ext-all.js,javascript/TransformGrid.js</param>
+      <param name="stylesheets">../dhis-web-commons/javascripts/ext/resources/css/ext-all-gray.css,css/dataentry.css</param>
     </action>
     
 	<!-- Load Payment Adjustment List -->

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getPaymentAdjustmentList.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getPaymentAdjustmentList.vm	2014-03-28 18:52:45 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getPaymentAdjustmentList.vm	2014-04-01 18:59:55 +0000
@@ -5,6 +5,14 @@
 	currentDiv = 'paymentAdjustmentForm';
 	
     }); 
+    function adjustPer()
+	{
+		var amountAvail = $("#amountAvail").val();	
+		var totalAvail = $("#total").val();	
+		
+		var adjustmentPer = ( parseFloat( amountAvail ) / parseFloat (totalAvail) ) * 100 ;
+		$("#adjustment").val( adjustmentPer.toFixed(2) );
+	}
     function saveDataValue()
     {
     	var period = document.getElementById("selectedPeriodId").value;
@@ -36,7 +44,8 @@
 	    var code = json.c;
 	    if ( code == '0' || code == 0) // Value successfully saved on server
 	    {
-	    	 markValue( fieldId, COLOR_GREEN );
+	    	markValue( fieldId, COLOR_GREEN );
+	    	adjustPer();
 	    }
 	    else if ( code == 2 )
 	    {
@@ -52,7 +61,7 @@
 
 	function handleError( jqXHR, textStatus, errorThrown )
 	{       
-	    markValue( fieldId, COLOR_GREEN );
+	    markValue( fieldId, COLOR_RED );
 	}
 
 	function markValue( fieldId, color )
@@ -89,10 +98,10 @@
 </div>
 
 <div class="inputCriteria" style="width:90%;height:auto;">
-<table>
+<table style="width:100%;">
 	<tr>
 		<td>
-			<table>
+			<table style="width:100%;">
 					<tr>
 						<td><label for="orgUnitName">$i18n.getString( "organisation_unit" )</label></td>
 						<td><input type="text" id="orgUnitName" name = "orgUnitName" readonly="readonly" value="$!organisationUnit.name" style="width:352px"></td>
@@ -125,11 +134,11 @@
 				</table>
 		</td>
 		<td>
-			<table>
+			<table style="width:100%;">
 				<tr>
 					<td>$i18n.getString( "amount_avaliable" )</td>
-					<td><input type="text" id="amountAvail" name="amountAvail" onblur="saveDataValue() "/></td>
-				</tr>
+					<td><input type="text" id="amountAvail" name="amountAvail" onblur="saveDataValue()" value="$!amountAvailable"/></td>
+				</tr>				
 				<tr>
 					<td>$i18n.getString( "adjustment_per" )</td>
 					<td><input type="text" id="adjustment" name="adjustment"/></td>

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/paymentAdjustment.js'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/paymentAdjustment.js	2014-03-28 18:52:45 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/paymentAdjustment.js	2014-04-01 18:59:55 +0000
@@ -18,8 +18,7 @@
 		 $.getJSON( 'getOrganisationUnitForPayment.action', {orgUnitId:orgUnitIds[0]}
 	        , function( json ) 
 	        {
-	            var type = json.response;
-	            alert(type);
+	            var type = json.response;	            
 	            setFieldValue('orgUnitName', json.message );
 	            setFieldValue('selectedOrgunitName', json.message );	            
 	            if( type == "success" )
@@ -52,9 +51,10 @@
 	        } );		
 	}
 }
-
-selection.setListenerFunction( orgUnitHasBeenSelected );
-
+jQuery(window).load(function() 
+{
+	selection.setListenerFunction( orgUnitHasBeenSelected );
+});
 
 function loadDataEntryForm()
 {
@@ -247,10 +247,9 @@
 		enable('prevButton');
 		enable('nextButton');
 				
-		var url = 'loadPeriods.action?dataSetId=' + dataSetId;
+		var url = 'loadPaymentPeriods.action';
 		
 		var list = document.getElementById( 'selectedPeriodId' );
-			
 		clearList( list );
 		
 		addOptionToList( list, '-1', '[ Select ]' );
@@ -259,6 +258,7 @@
 	    	for ( i in json.periods ) {
 	    		addOptionToList( list, json.periods[i].isoDate, json.periods[i].name );
 	    	}
+	    	document.getElementById("amountAvail").value = json.amountAvailable;
 	    } );
 	    
 	}	
@@ -269,9 +269,6 @@
 function getAvailablePeriodsTemp( availablePeriodsId, selectedPeriodsId, year )
 {	
 	$( '#paymentDiv' ).html( '' );
-	
-	var dataSetId = $( '#dataSetId' ).val();
-	
 	var availableList = document.getElementById( availablePeriodsId );
 	var selectedList = document.getElementById( selectedPeriodsId );
 	
@@ -279,15 +276,14 @@
 	
 	addOptionToList( selectedList, '-1', '[ Select ]' );
 	
-	$.getJSON( "getAvailableNextPrePeriods.action", {
-		"dataSetId": dataSetId ,
+	$.getJSON( "getPaymentAvailableNextPrePeriods.action", {
 		"year": year },
 		function( json ) {
 			
 			for ( i in json.periods ) {
 	    		addOptionToList( selectedList, json.periods[i].isoDate, json.periods[i].name );
 	    	}
-			
+			document.getElementById("amountAvail").value = json.amountAvailable;
 		} );
 }
 

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/jsonPeriods.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/jsonPeriods.vm	2013-12-31 07:59:05 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/jsonPeriods.vm	2014-04-01 18:59:55 +0000
@@ -1,5 +1,6 @@
 #set( $size = $periods.size() )
-{ "periods": [
+{ 
+"periods": [
 #foreach( $period in $periods )
   {
     "id": $!{period.id},
@@ -10,4 +11,5 @@
 	"isoDate": "$!{period.isoDate}"
   }#if( $velocityCount < $size ),#end    
 #end
-] }
+]
+ }

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadPaymentAdjustment.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadPaymentAdjustment.vm	2014-03-28 18:52:45 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadPaymentAdjustment.vm	2014-04-01 18:59:55 +0000
@@ -1,6 +1,11 @@
 
 <script type="text/javascript" >
-
+	var total = 0;
+	var windowWidth = $(window).width();
+	var windowHeight = $(window).height();
+	var tableWidth = (parseInt( windowWidth ) * 75) / 100 ;	
+	var columnWidth = (parseInt( windowWidth ) * 10) / 100 ;
+	var indicatorWidth = (parseInt( windowWidth ) * 15) / 100 ;
 	Ext.Loader.setConfig({
 		enabled: true
 	});
@@ -24,7 +29,7 @@
             enableColumnResize: true,
             sortOnLoad: true,
 			width: tableWidth,
-        	height: 360,			
+        	height: 200,			
             sorters: {direction: 'ASC'},
 			autoCreateViewPort:false,
 			renderTo: Ext.Element.get('#paymentTable'),
@@ -35,7 +40,7 @@
 			columns: [
     		{
                 text     : '$i18n.getString( "indicator" )',
-    			width    : columnWidth,            
+    			width    : indicatorWidth,            
                 sortable : true
             },
 			{
@@ -44,7 +49,7 @@
                 sortable : true
             },
 			{
-                text     : '$i18n.getString( "payment" )',
+                text     : '$i18n.getString( "Tariff" )',
     			width    : columnWidth,						
                 sortable : true
             },
@@ -90,7 +95,7 @@
 		<tr >
 			<th >$i18n.getString( "indicator" )</th>
 			<th >$i18n.getString( "quantity_for" )</th>
-			<th >$i18n.getString( "payment" )</th>
+			<th >$i18n.getString( "Tariff" )</th>			
 			<th >$i18n.getString( "amount" )</th>
 			<th >$i18n.getString( "amount_including_quality" )</th>
 			<th >$i18n.getString( "adjusted_per" )</th>
@@ -105,16 +110,34 @@
 			#else
 				#set( $mark = true )
 			#end
+			
             <tr >
 				<td>$!dataElement.name</td>
 				<td>$!quantityValidatedMap.get( $dataElement.uid )</td>
-				<td>$!tariffDataValueMap.get( $dataElement.uid )</td>
-				<td>$!quantityValidatedMap.get( $dataElement.uid ) * $!tariffDataValueMap.get( $dataElement.uid )</td>
+				<td>$!tariffDataValueMap.get( $dataElement.uid )</td>				
+				<td id="amount_$dataElement.id"></td>
 				<td>&nbsp; </td>
 				<td>&nbsp;</td>
-	            <td>&nbsp;</td>			
+	            <td>&nbsp;</td>		            		
         </tr>
+        <script>
+        	function calVal( ) {
+        		var amount = 0.0;
+        		amount = parseFloat( '$!quantityValidatedMap.get( $dataElement.uid )' ) * parseFloat( '$!tariffDataValueMap.get( $dataElement.uid )' );
+        		$('#amount_'+$dataElement.id).text( amount.toFixed(2) );
+        		total = total + parseFloat( amount  );
+        		document.getElementById("total").value = total.toFixed(2) ;
+        	}
+        	calVal( );
+        </script>
 		#end
+		<tr>
+			<td>&nbsp; </td>			
+			<td colspan="2" >Unadjusted Amount </td>
+			<td colspan="2"><input type="text" name="total" id="total"/></td>
+			<td>&nbsp; </td>
+			<td>&nbsp; </td>>
+		</tr>
     </tbody>
 </table>
 </div>
\ No newline at end of file