dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29271
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14757: PBF: work in progress Payment Adjustment Functionality
------------------------------------------------------------
revno: 14757
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-04-09 10:36:29 +0100
message:
PBF: work in progress Payment Adjustment Functionality
modified:
local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultPBFAggregationService.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/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/impl/DefaultPBFAggregationService.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultPBFAggregationService.java 2014-04-07 12:32:43 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultPBFAggregationService.java 2014-04-09 09:36:29 +0000
@@ -219,7 +219,7 @@
" startdate <='"+ simpleDateFormat.format( period.getStartDate() ) +"' AND "+
" enddate >='"+ simpleDateFormat.format( period.getEndDate() ) +"' AND " +
" organisationunitid = "+ maxScoreOrgUnitId +" AND "+
- " datasetid = " + dataSetId +" AND " +
+ " datasetid = " + dataSetId +" " +
" GROUP BY dataelementid";
//System.out.println( query );
=== 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-08 12:05:57 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/payment/action/LoadPaymentAdjustmentAction.java 2014-04-09 09:36:29 +0000
@@ -34,7 +34,8 @@
import com.opensymphony.xwork2.Action;
-public class LoadPaymentAdjustmentAction implements Action
+public class LoadPaymentAdjustmentAction
+ implements Action
{
// -------------------------------------------------------------------------
@@ -54,7 +55,7 @@
@Autowired
private PBFDataValueService pbfDataValueService;
-
+
@Autowired
private TariffDataValueService tariffDataValueService;
@@ -72,7 +73,7 @@
@Autowired
private QualityMaxValueService qualityMaxValueService;
-
+
@Autowired
private DefaultPBFAggregationService defaultPBFAggregationService;
@@ -94,20 +95,20 @@
}
private Double overAllQualityScore = 0.0;
-
- public Double getOverAllQualityScore()
+
+ public Double getOverAllQualityScore()
{
- return overAllQualityScore;
- }
-
+ return overAllQualityScore;
+ }
+
Set<DataElement> dataElements = new HashSet<DataElement>();
-
- public Set<DataElement> getDataElements()
- {
- return dataElements;
- }
-
- private String orgUnitId;
+
+ public Set<DataElement> getDataElements()
+ {
+ return dataElements;
+ }
+
+ private String orgUnitId;
public void setOrgUnitId( String orgUnitId )
{
@@ -135,41 +136,43 @@
public String execute()
throws Exception
{
-
- System.out.println("Inside Adjustment screen");
-
- if( periodIso.equals("-1") )
- return SUCCESS;
-
+
+ System.out.println( "Inside Adjustment screen" );
+
+ if ( periodIso.equals( "-1" ) )
+ return SUCCESS;
+
OrganisationUnit selOrgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
-
+
DataSet selDataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
-
+
Period period = PeriodType.getPeriodFromIsoString( periodIso );
-
+
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 );
-
+
dataElements.addAll( selDataSet.getDataElements() );
-
+
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 );
-
- //--------------------------------------------------------
+
+ // --------------------------------------------------------
// Quantity Calculation
- //--------------------------------------------------------
-
+ // --------------------------------------------------------
+
pbfQtyMap.putAll( pbfDataValueService.getPBFDataValues( orgUnitIdsByComma, selDataSet, periodIdsByComma ) );
-
- //--------------------------------------------------------
+
+ // --------------------------------------------------------
// Quantity Tariff Calculation
- //--------------------------------------------------------
+ // --------------------------------------------------------
Constant tariff_authority = constantService.getConstantByName( Lookup.TARIFF_SETTING_AUTHORITY );
int tariff_setting_authority = 1;
if ( tariff_authority != null )
@@ -178,37 +181,37 @@
}
OrganisationUnit tariffOrgUnit = findParentOrgunitforTariff( selOrgUnit, tariff_setting_authority );
-
- if( tariffOrgUnit != null )
+
+ if ( tariffOrgUnit != null )
{
pbfTariffMap.putAll( tariffDataValueService.getTariffDataValues( tariffOrgUnit, selDataSet, period ) );
}
-
- //-----------------------------------------------------------
+
+ // -----------------------------------------------------------
// QualityScore
- //-----------------------------------------------------------
-
+ // -----------------------------------------------------------
+
List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_PAYMENT_TYPE ) );
DataSet qualityScoreDataSet = null;
for ( Lookup lookup : lookups )
{
String[] lookupType = lookup.getValue().split( ":" );
+ System.out.println( lookup.getValue() +" " + Integer.parseInt( lookupType[0] ) + " " + Integer.parseInt( dataSetId ) );
if ( Integer.parseInt( lookupType[0] ) == Integer.parseInt( dataSetId ) )
{
- qualityScoreDataSet = dataSetService.getDataSet( lookupType[1] );
- break;
+ qualityScoreDataSet = dataSetService.getDataSet( Integer.parseInt( lookupType[1] ) );
+ break;
}
}
-
- if( qualityScoreDataSet != null )
+
+ if ( qualityScoreDataSet != null )
{
- overAllQualityScore = defaultPBFAggregationService.calculateOverallQualityScore( period, qualityScoreDataSet.getSources(), qualityScoreDataSet.getId(), tariffOrgUnit.getId() );
+ overAllQualityScore = defaultPBFAggregationService.calculateOverallQualityScore( period, qualityScoreDataSet.getSources(), qualityScoreDataSet.getId(), tariffOrgUnit.getId() );
}
-
-
+
return SUCCESS;
}
-
+
public OrganisationUnit findParentOrgunitforTariff( OrganisationUnit organisationUnit, Integer tariffOULevel )
{
Integer ouLevel = organisationUnitService.getLevelOfOrganisationUnit( organisationUnit.getId() );
=== 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-01 18:59:55 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getPaymentAdjustmentList.vm 2014-04-09 09:36:29 +0000
@@ -13,78 +13,80 @@
var adjustmentPer = ( parseFloat( amountAvail ) / parseFloat (totalAvail) ) * 100 ;
$("#adjustment").val( adjustmentPer.toFixed(2) );
}
+
function saveDataValue()
{
var period = document.getElementById("selectedPeriodId").value;
var valueId = "amountAvail";
- var fieldId = "#"+valueId;
- var defaultValue = document.getElementById(valueId).defaultValue;
- var value = document.getElementById(valueId).value;
+ var fieldId = "#"+valueId;
+ var defaultValue = document.getElementById(valueId).defaultValue;
+ var value = document.getElementById(valueId).value;
- if(defaultValue != value)
- {
- var dataValue = {
- 'dataElementId' : $amountDEId,
- 'organisationUnitId' : $("#selectedOrgunitID").val(),
- 'periodIso' : period,
- 'value' : value
- };
- jQuery.ajax( {
+ if(defaultValue != value)
+ {
+ var dataValue = {
+ 'dataElementId' : $amountDEId,
+ 'organisationUnitId' : $("#selectedOrgunitID").val(),
+ 'periodIso' : period,
+ 'value' : value
+ };
+
+ jQuery.ajax( {
url: 'saveDataValue.action',
data: dataValue,
dataType: 'json',
success: handleSuccess,
error: handleError
} );
- }
+ }
- function handleSuccess( json )
- {
- var code = json.c;
- if ( code == '0' || code == 0) // Value successfully saved on server
- {
- markValue( fieldId, COLOR_GREEN );
- adjustPer();
- }
- else if ( code == 2 )
- {
- markValue( fieldId, COLOR_RED );
- window.alert( i18n_saving_value_failed_dataset_is_locked );
- }
- else // Server error during save
- {
- markValue( fieldId, COLOR_RED );
- window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
- }
- }
-
- function handleError( jqXHR, textStatus, errorThrown )
- {
- markValue( fieldId, COLOR_RED );
- }
-
- function markValue( fieldId, color )
- {
- document.getElementById(valueId).style.backgroundColor = color;
- }
+ function handleSuccess( json )
+ {
+ var code = json.c;
+ if ( code == '0' || code == 0) // Value successfully saved on server
+ {
+ markValue( fieldId, COLOR_GREEN );
+ adjustPer();
+ }
+ else if ( code == 2 )
+ {
+ markValue( fieldId, COLOR_RED );
+ window.alert( i18n_saving_value_failed_dataset_is_locked );
+ }
+ else // Server error during save
+ {
+ markValue( fieldId, COLOR_RED );
+ window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
+ }
+ }
+
+ function handleError( jqXHR, textStatus, errorThrown )
+ {
+ markValue( fieldId, COLOR_RED );
+ }
+
+ function markValue( fieldId, color )
+ {
+ document.getElementById(valueId).style.backgroundColor = color;
+ }
}
</script>
<style >
#tariffSetting {
- width: 280px;
- height: 50px;
- margin: 10px 10px 10px 10px;
- float:right;
- padding: 10px 10px 10px 10px ;
- font: 1.6em bold;
- background: #ccc;
- box-shadow: 2px 2px 2px rgba(0,0,0,0.5),
- inset 8px 10px 10px rgba(255,255,255,0.75);
- -webkit-box-shadow: 2px 2px 2px rgba(0,0,0,0.5),
- inset 8px 10px 10px rgba(255,255,255,0.75);
- -moz-box-shadow: 2px 2px 2px rgba(0,0,0,0.5),
- inset 8px 10px 10px rgba(255,255,255,0.75);
+ width: 280px;
+ height: 50px;
+ margin: 10px 10px 10px 10px;
+ float:right;
+ padding: 10px 10px 10px 10px ;
+ font: 1.6em bold;
+ background: #ccc;
+ box-shadow: 2px 2px 2px rgba(0,0,0,0.5),
+ inset 8px 10px 10px rgba(255,255,255,0.75);
+ -webkit-box-shadow: 2px 2px 2px rgba(0,0,0,0.5),
+ inset 8px 10px 10px rgba(255,255,255,0.75);
+ -moz-box-shadow: 2px 2px 2px rgba(0,0,0,0.5),
+ inset 8px 10px 10px rgba(255,255,255,0.75);
}
</style>
=== 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-08 12:05:57 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadPaymentAdjustment.vm 2014-04-09 09:36:29 +0000
@@ -29,8 +29,9 @@
<th >$i18n.getString( "Tariff" )</th>
<th >$i18n.getString( "amount" )</th>
<th >$i18n.getString( "amount_including_quality" )</th>
- <th >$i18n.getString( "adjusted_per" )</th>
- <th >$i18n.getString( "adjusted_per" )</th>
+ <th >$i18n.getString( "adjusted_tariff" )</th>
+ <th >$i18n.getString( "adjusted_amount" )</th>
+ <th >$i18n.getString( "adjusted_amount_including_quality" )</th>
</tr>
</thead>
<tbody>
@@ -45,32 +46,25 @@
<tr #if( $mark ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8" #end>
<td>$!dataElement.name</td>
- <td>$!pbfQtyMap.get( $dataElement.id )</td>
- <td>$!pbfTariffMap.get( $dataElement.id )</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>$tariffVal</td>
- <td>$!overAllQualityScore</td>
+ <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> </td>
- </tr>
- <script>
- function calValue()
- {
- var adjusted = $("#adjustment").val();
- var amount = '$!pbfTariffMap.get( $dataElement.id )';
- var adjustedPer = 0.0;
- adjustedPer = (parseFloat(amount)/parseFloat(adjusted))*100
- $('#adjusted_$dataElement.uid').text(adjustedPer.toFixed(2));
- }
- calValue();
- </script>
+ <td align="center"> </td>
+ <td align="center"> </td>
+ </tr>
#end
+
<tr>
- <td> </td>
- <td colspan="2" >Unadjusted Amount </td>
- <td colspan="2"><input type="text" name="total" id="total" value="$!unAdjustedAmount"/></td>
- <td> </td>
- <td> </td>
+ <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>