dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29297
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14767: PBF: Payment Adjustment Functionality
------------------------------------------------------------
revno: 14767
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-04-10 11:30:33 +0100
message:
PBF: Payment Adjustment Functionality
modified:
local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java
local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentAdjustmentAction.java
local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties
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/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/action/AddTariffDataAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java 2014-02-01 06:47:08 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java 2014-04-10 10:30:33 +0000
@@ -1,6 +1,8 @@
package org.hisp.dhis.pbf.action;
import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import org.hisp.dhis.dataelement.DataElement;
@@ -176,7 +178,7 @@
tariffDataValueService.updateTariffDataValue( tariffDataValue );
System.out.println("Tariff Data Updated");
}
-
+
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/LoadPaymentAdjustmentAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentAdjustmentAction.java 2014-04-09 09:36:29 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentAdjustmentAction.java 2014-04-10 10:30:33 +0000
@@ -11,13 +11,16 @@
import java.util.Map;
import java.util.Set;
+import org.apache.velocity.tools.generic.MathTool;
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;
@@ -80,7 +83,21 @@
// -------------------------------------------------------------------------
// Input / Output
// -------------------------------------------------------------------------
- private Map<Integer, Double> pbfQtyMap = new HashMap<Integer, Double>();
+ private MathTool mathTool = new MathTool();
+
+ public MathTool getMathTool()
+ {
+ return mathTool;
+ }
+
+ private String availableAmount = "";
+
+ public String getAvailableAmount()
+ {
+ return availableAmount;
+ }
+
+ private Map<Integer, Double> pbfQtyMap = new HashMap<Integer, Double>();
public Map<Integer, Double> getPbfQtyMap()
{
@@ -129,18 +146,21 @@
this.periodIso = periodIso;
}
+
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
- public String execute()
+ public String execute()
throws Exception
{
-
System.out.println( "Inside Adjustment screen" );
if ( periodIso.equals( "-1" ) )
+ {
return SUCCESS;
+ }
OrganisationUnit selOrgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
@@ -150,8 +170,7 @@
period = periodService.reloadPeriod( period );
- Set<Period> periods = new HashSet<Period>( periodService.getIntersectingPeriods( period.getStartDate(),
- period.getEndDate() ) );
+ Set<Period> periods = new HashSet<Period>( periodService.getIntersectingPeriods( period.getStartDate(), period.getEndDate() ) );
Collection<Integer> periodIds = new ArrayList<Integer>( getIdentifiers( Period.class, periods ) );
String periodIdsByComma = getCommaDelimitedString( periodIds );
@@ -160,8 +179,7 @@
Set<OrganisationUnit> pbfQtyOrgUnits = new HashSet<OrganisationUnit>();
pbfQtyOrgUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( selOrgUnit.getId() ) );
pbfQtyOrgUnits.retainAll( selDataSet.getSources() );
- Collection<Integer> orgUnitIds = new ArrayList<Integer>(
- getIdentifiers( OrganisationUnit.class, pbfQtyOrgUnits ) );
+ Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, pbfQtyOrgUnits ) );
String orgUnitIdsByComma = getCommaDelimitedString( orgUnitIds );
// --------------------------------------------------------
@@ -209,6 +227,18 @@
overAllQualityScore = defaultPBFAggregationService.calculateOverallQualityScore( period, qualityScoreDataSet.getSources(), qualityScoreDataSet.getId(), tariffOrgUnit.getId() );
}
+ //-------------------------------------------------------------
+ // Availbale Amount
+ //-------------------------------------------------------------
+ Constant paymentAmount = constantService.getConstantByName( Lookup.PAYMENT_ADJUSTMENT_AMOUNT_DE );
+ DataElement dataElement = dataElementService.getDataElement( (int) paymentAmount.getValue() );
+ DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+ DataValue dataValue = dataValueService.getDataValue( dataElement, period, selOrgUnit, optionCombo );
+ if ( dataValue != null )
+ {
+ availableAmount = dataValue.getValue();
+ }
+
return SUCCESS;
}
=== 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-04-05 12:21:33 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties 2014-04-10 10:30:33 +0000
@@ -54,3 +54,8 @@
update_aggregation_query_builder_detail = Update Aggregation Query Builder Detail
quarterly_invoice_for_PBF_indicators_PMA = Quarterly invoice for PBF indicators PMA
+adjusted_tariff = Adjusted Tariff
+adjusted_amount = Adjusted Amount
+adjusted_amount_including_quality = Adjusted Amount (Incl Quality)
+total_amt_to_pay = Total Amount to Pay
+total_unadjusted_amount = Total Unadjusted Amount
\ No newline at end of file
=== 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-04-09 09:36:29 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getPaymentAdjustmentList.vm 2014-04-10 10:30:33 +0000
@@ -1,4 +1,5 @@
<script>
+ var dataElementIdArray = new Array();
jQuery(document).ready( function(){
countryTags = $orgUnitList;
@@ -12,6 +13,8 @@
var adjustmentPer = ( parseFloat( amountAvail ) / parseFloat (totalAvail) ) * 100 ;
$("#adjustment").val( adjustmentPer.toFixed(2) );
+
+ calculateAdjustedTariffAmount();
}
function saveDataValue()
=== 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-04-09 09:36:29 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadPaymentAdjustment.vm 2014-04-10 10:30:33 +0000
@@ -1,71 +1,108 @@
-
-<script type="text/javascript" >
- jQuery(document).ready( function(){
- document.getElementById("amountAvail").value = '$amountAvailable';
- adjustPer();
- });
- var total = 0.0;
-
-</script>
-
-<script >
-
-</script>
-<style >
- .mandatory
- {
- color:red;
- font-size: 1.5em;
- }
-</style>
-
-<input type="hidden" id="dataElementId" name="dataElementId" value="$!selecteddataElement.id"/>
-<div style="width:95%;" id="paymentTable">
-<table style="width:100%;" id="paymentDetails" name="paymentDetails" cellspacing="0" class="formSection">
- <thead >
- <tr bgcolor="#CBDDEB">
- <th >$i18n.getString( "indicator" )</th>
- <th >$i18n.getString( "quantity_for" )</th>
- <th >$i18n.getString( "Tariff" )</th>
- <th >$i18n.getString( "amount" )</th>
- <th >$i18n.getString( "amount_including_quality" )</th>
- <th >$i18n.getString( "adjusted_tariff" )</th>
- <th >$i18n.getString( "adjusted_amount" )</th>
- <th >$i18n.getString( "adjusted_amount_including_quality" )</th>
- </tr>
- </thead>
- <tbody>
- #set( $mark = false )
-
- #foreach( $dataElement in $dataElements )
- #if( $mark )
- #set( $mark = false )
- #else
- #set( $mark = true )
- #end
-
- <tr #if( $mark ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8" #end>
- <td>$!dataElement.name</td>
- <td id="pbfQty_$dataElement.id" align="center">$!pbfQtyMap.get( $dataElement.id )</td>
- <td id="pbfTariff_$dataElement.id" align="center">$!pbfTariffMap.get( $dataElement.id )</td>
- #set( $tariffVal = $!pbfQtyMap.get( $dataElement.id ) * $!pbfTariffMap.get( $dataElement.id ) )
- <td id="pbfAmt_$dataElement.id" align="center">$tariffVal</td>
- #set( $pbfAmtIncQS = ( $!tariffVal * $!overAllQualityScore )/100 )
- <td id="pbfAmtIncQS_$dataElement.id" align="center">$!pbfAmtIncQS</td>
- <td id="adjusted_$dataElement.uid"> </td>
- <td align="center"> </td>
- <td align="center"> </td>
- </tr>
- #end
-
- <tr>
- <td>$i18n.getString( "quality_score" ) : $!overAllQualityScore</td>
- <td colspan="2">$i18n.getString( "unadjusted_amount" )</td>
- <td><input type="text" name="total" id="total" readonly value="$!unAdjustedAmount"/></td>
- <td> </td>
- <td colspan="2">$i18n.getString("total_amt_to_pay")</td>
- <td><input type="text" name="total_amt_to_pay" id="total_amt_to_pay" readonly /></td>
- </tr>
- </tbody>
-</table>
+
+<script type="text/javascript" >
+
+ jQuery(document).ready( function(){
+
+ #foreach( $dataElement in $dataElements )
+ dataElementIdArray.push( $dataElement.id )
+ #end
+
+ document.getElementById("amountAvail").value = '$!availableAmount';
+ adjustPer();
+
+ calculateAdjustedTariffAmount();
+ });
+
+ var total = 0.0;
+
+ function calculateAdjustedTariffAmount()
+ {
+ var amountAvail = $("#amountAvail").val();
+ var totalAvail = $("#total").val();
+ var qualityScore = $("#quality_score").val();
+
+ var totalAmtToPay = 0;
+
+ var adjustmentPer = ( parseFloat( amountAvail ) / parseFloat (totalAvail) ) * 100 ;
+
+ for ( i = 0; i < dataElementIdArray.length; i++ )
+ {
+ var tariffAmount = document.getElementById("pbfTariff_"+dataElementIdArray[i]).value;
+ var totalCalculatedValue = ( parseFloat( tariffAmount ) * parseFloat (adjustmentPer) ) / 100;
+ document.getElementById( "adjusted_"+dataElementIdArray[i] ).value = Math.round(totalCalculatedValue*100)/100;
+
+ var pbfAmount = document.getElementById("pbfQty_"+dataElementIdArray[i]).value;
+
+ var adjustedAmount = parseFloat(totalCalculatedValue) * parseFloat (pbfAmount);
+ document.getElementById( "adjustedAmt_"+dataElementIdArray[i] ).value = Math.round(adjustedAmount*100)/100;
+
+ var adjAmtIncQS = ( parseFloat( adjustedAmount ) * parseFloat ( qualityScore ) ) / 100;
+ document.getElementById( "adjAmtIncQS_"+dataElementIdArray[i] ).value = Math.round(adjAmtIncQS*100)/100;
+
+ totalAmtToPay += parseFloat( adjAmtIncQS );
+ }
+
+ document.getElementById( "total_amt_to_pay" ).value = Math.round(totalAmtToPay*100)/100;
+ }
+
+</script>
+
+<style >
+ .mandatory
+ {
+ color:red;
+ font-size: 1.5em;
+ }
+</style>
+
+<input type="hidden" id="dataElementId" name="dataElementId" value="$!selecteddataElement.id"/>
+<div style="width:95%;" id="paymentTable">
+<table style="width:100%;" id="paymentDetails" name="paymentDetails" cellspacing="0" class="formSection">
+ <thead >
+ <tr bgcolor="#CBDDEB">
+ <th >$i18n.getString( "indicator" )</th>
+ <th >$i18n.getString( "quantity_for" )</th>
+ <th >$i18n.getString( "Tariff" )</th>
+ <th >$i18n.getString( "amount" )</th>
+ <th >$i18n.getString( "amount_including_quality" )</th>
+ <th >$i18n.getString( "adjusted_tariff" )</th>
+ <th >$i18n.getString( "adjusted_amount" )</th>
+ <th >$i18n.getString( "adjusted_amount_including_quality" )</th>
+ </tr>
+ </thead>
+ <tbody>
+ #set( $mark = false )
+ #set( $pbfTotalUnadjustedAmount = 0 )
+ #foreach( $dataElement in $dataElements )
+ #if( $mark )
+ #set( $mark = false )
+ #else
+ #set( $mark = true )
+ #end
+
+ <tr #if( $mark ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8" #end>
+ <td>$!dataElement.name</td>
+ <td align="center"><input type="text" name="pbfQty_$dataElement.id" id="pbfQty_$dataElement.id" size="10" value="$!mathTool.round( $!pbfQtyMap.get( $dataElement.id ) )" readonly="readonly"/></td>
+ <td align="center"><input type="text" name="pbfTariff_$dataElement.id" id="pbfTariff_$dataElement.id" size="10" value="$!mathTool.roundTo(1, $!pbfTariffMap.get( $dataElement.id ) )" readonly="readonly"/></td>
+ #set( $tariffVal = $!pbfQtyMap.get( $dataElement.id ) * $!pbfTariffMap.get( $dataElement.id ) )
+ <td id="pbfAmt_$dataElement.id" align="center">$!mathTool.roundTo(2, $tariffVal )</td>
+ #set( $pbfAmtIncQS = ( $!tariffVal * $!overAllQualityScore )/100 )
+ <td id="pbfAmtIncQS_$dataElement.id" align="center">$!mathTool.roundTo(2, $!pbfAmtIncQS )</td>
+ #set( $pbfTotalUnadjustedAmount = $!pbfTotalUnadjustedAmount + $!pbfAmtIncQS )
+ <td><input type="text" name="adjusted_$dataElement.id" id="adjusted_$dataElement.id" size="10" /></td>
+ <td align="center"><input type="text" name="adjustedAmt_$dataElement.id" id="adjustedAmt_$dataElement.id" size="15" /></td>
+ <td align="center"><input type="text" name="adjAmtIncQS_$dataElement.id" id="adjAmtIncQS_$dataElement.id" size="15" /></td>
+ </tr>
+ #end
+
+ <tr>
+ <td>$i18n.getString( "quality_score" ) : <input type="text" name="quality_score" id="quality_score" size="10" value="$!mathTool.roundTo(2, $!overAllQualityScore )" readonly /></td>
+ <td colspan="2" align="right">$i18n.getString( "total_unadjusted_amount" )</td>
+ <td><input type="text" name="total" id="total" size="20" value="$!mathTool.roundTo(2, $pbfTotalUnadjustedAmount )" readonly /></td>
+ <td> </td>
+ <td colspan="2" align="right">$i18n.getString("total_amt_to_pay")</td>
+ <td><input type="text" name="total_amt_to_pay" id="total_amt_to_pay" size="20" readonly /></td>
+ </tr>
+ </tbody>
+</table>
</div>
\ No newline at end of file