Add information about budget in "Imputed hours" tab
FEA: ItEr76S17MoneyCostMonitoringSystem
This commit is contained in:
parent
0b35f7dd5e
commit
e11ebf485c
6 changed files with 148 additions and 15 deletions
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
package org.libreplan.web.orders;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
|
|
@ -33,7 +34,9 @@ import org.zkoss.zul.Vbox;
|
|||
|
||||
/**
|
||||
* Controller for show the asigned hours of the selected order element<br />
|
||||
*
|
||||
* @author Susana Montes Pedreria <smontes@wirelessgalicia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public class AssignedHoursToOrderElementController extends
|
||||
GenericForwardComposer {
|
||||
|
|
@ -42,6 +45,14 @@ public class AssignedHoursToOrderElementController extends
|
|||
|
||||
private Vbox orderElementHours;
|
||||
|
||||
private Progressmeter hoursProgressBar;
|
||||
|
||||
private Progressmeter exceedHoursProgressBar;
|
||||
|
||||
private Progressmeter moneyCostProgressBar;
|
||||
|
||||
private Progressmeter exceedMoneyCostProgressBar;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
|
@ -76,6 +87,18 @@ public class AssignedHoursToOrderElementController extends
|
|||
return assignedHoursToOrderElementModel.getProgressWork();
|
||||
}
|
||||
|
||||
public BigDecimal getBudget() {
|
||||
return assignedHoursToOrderElementModel.getBudget();
|
||||
}
|
||||
|
||||
public BigDecimal getMoneyCost() {
|
||||
return assignedHoursToOrderElementModel.getMoneyCost();
|
||||
}
|
||||
|
||||
public BigDecimal getMoneyCostPercentage() {
|
||||
return assignedHoursToOrderElementModel.getMoneyCostPercentage();
|
||||
}
|
||||
|
||||
private IOrderElementModel orderElementModel;
|
||||
|
||||
public void openWindow(IOrderElementModel orderElementModel) {
|
||||
|
|
@ -87,7 +110,12 @@ public class AssignedHoursToOrderElementController extends
|
|||
Util.reloadBindings(orderElementHours);
|
||||
}
|
||||
|
||||
paintProgressBars();
|
||||
}
|
||||
|
||||
public void paintProgressBars() {
|
||||
viewPercentage();
|
||||
showMoneyCostPercentageBars();
|
||||
}
|
||||
|
||||
public void setOrderElementModel(IOrderElementModel orderElementModel) {
|
||||
|
|
@ -98,10 +126,6 @@ public class AssignedHoursToOrderElementController extends
|
|||
return orderElementModel.getOrderElement();
|
||||
}
|
||||
|
||||
private Progressmeter hoursProgressBar;
|
||||
|
||||
private Progressmeter exceedHoursProgressBar;
|
||||
|
||||
/**
|
||||
* This method shows the percentage of the imputed hours with respect to the
|
||||
* estimated hours.If the hours imputed is greater that the hours estimated
|
||||
|
|
@ -110,17 +134,29 @@ public class AssignedHoursToOrderElementController extends
|
|||
private void viewPercentage() {
|
||||
if (this.getProgressWork() > 100) {
|
||||
hoursProgressBar.setValue(100);
|
||||
|
||||
exceedHoursProgressBar.setVisible(true);
|
||||
exceedHoursProgressBar.setValue(0);
|
||||
String exceedValue = String.valueOf(getProgressWork() - 100);
|
||||
exceedHoursProgressBar.setWidth(exceedValue + "px");
|
||||
exceedHoursProgressBar.setLeft("left");
|
||||
exceedHoursProgressBar
|
||||
.setStyle("background:red ; border:1px solid red");
|
||||
} else {
|
||||
hoursProgressBar.setValue(getProgressWork());
|
||||
exceedHoursProgressBar.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void showMoneyCostPercentageBars() {
|
||||
BigDecimal moneyCostPercentage = getMoneyCostPercentage();
|
||||
if (moneyCostPercentage.compareTo(new BigDecimal(100)) > 0) {
|
||||
moneyCostProgressBar.setValue(100);
|
||||
|
||||
exceedMoneyCostProgressBar.setVisible(true);
|
||||
exceedMoneyCostProgressBar.setWidth(moneyCostPercentage.subtract(
|
||||
new BigDecimal(100)).intValue()
|
||||
+ "px");
|
||||
} else {
|
||||
moneyCostProgressBar.setValue(moneyCostPercentage.intValue());
|
||||
exceedMoneyCostProgressBar.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -32,6 +32,7 @@ import org.apache.commons.lang.Validate;
|
|||
import org.joda.time.LocalDate;
|
||||
import org.libreplan.business.orders.daos.IOrderElementDAO;
|
||||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
import org.libreplan.business.planner.entities.MoneyCostCalculator;
|
||||
import org.libreplan.business.reports.dtos.WorkReportLineDTO;
|
||||
import org.libreplan.business.workingday.EffortDuration;
|
||||
import org.libreplan.business.workreports.daos.IWorkReportLineDAO;
|
||||
|
|
@ -46,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
*
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
* @author Ignacio Díaz Teijido <ignacio.diaz@comtecsf.es>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@Service
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
|
|
@ -58,6 +60,9 @@ public class AssignedHoursToOrderElementModel implements
|
|||
@Autowired
|
||||
private IOrderElementDAO orderElementDAO;
|
||||
|
||||
@Autowired
|
||||
private MoneyCostCalculator moneyCostCalculator;
|
||||
|
||||
private EffortDuration assignedDirectEffort;
|
||||
|
||||
private OrderElement orderElement;
|
||||
|
|
@ -197,4 +202,32 @@ public class AssignedHoursToOrderElementModel implements
|
|||
.multiply(new BigDecimal(100)).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getBudget() {
|
||||
if (orderElement == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return orderElement.getBudget();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public BigDecimal getMoneyCost() {
|
||||
if (orderElement == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return moneyCostCalculator.getMoneyCost(orderElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public BigDecimal getMoneyCostPercentage() {
|
||||
if (orderElement == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return MoneyCostCalculator.getMoneyCostProportion(
|
||||
moneyCostCalculator.getMoneyCost(orderElement),
|
||||
orderElement.getBudget()).multiply(new BigDecimal(100));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
package org.libreplan.web.orders;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
|
|
@ -29,6 +30,7 @@ import org.libreplan.business.workingday.EffortDuration;
|
|||
|
||||
/**
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public interface IAssignedHoursToOrderElementModel{
|
||||
public List<WorkReportLineDTO> getWorkReportLines();
|
||||
|
|
@ -42,4 +44,11 @@ public interface IAssignedHoursToOrderElementModel{
|
|||
public int getProgressWork();
|
||||
|
||||
public EffortDuration getAssignedDirectEffort();
|
||||
|
||||
BigDecimal getBudget();
|
||||
|
||||
BigDecimal getMoneyCost();
|
||||
|
||||
BigDecimal getMoneyCostPercentage();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -491,14 +491,18 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
setCurrentTab();
|
||||
|
||||
Component orderElementHours = editWindow
|
||||
.getFellowIfAny("orderElementHours");
|
||||
if (assignedHoursController == null) {
|
||||
Component orderElementHours = editWindow
|
||||
.getFellowIfAny("orderElementHours");
|
||||
assignedHoursController = (AssignedHoursToOrderElementController) orderElementHours
|
||||
.getVariable("assignedHoursToOrderElementController", true);
|
||||
|
||||
final IOrderElementModel orderElementModel = getOrderElementModel();
|
||||
assignedHoursController.openWindow(orderElementModel);
|
||||
} else {
|
||||
Util.createBindingsFor(orderElementHours);
|
||||
Util.reloadBindings(orderElementHours);
|
||||
assignedHoursController.paintProgressBars();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ public class OrderElementController extends GenericForwardComposer {
|
|||
assignedHoursToOrderElementController.openWindow(orderElementModel);
|
||||
} else {
|
||||
redraw(orderElementHours);
|
||||
assignedHoursToOrderElementController.paintProgressBars();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
Desenvolvemento Tecnolóxico de Galicia
|
||||
Copyright (C) 2010-2011 Igalia, S.L.
|
||||
Copyright (C) 2010-2012 Igalia, S.L.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -117,7 +117,57 @@
|
|||
value="@{assignedHoursToOrderElementController.progressWork}" />
|
||||
<label value="${i18n:_('%')}" />
|
||||
<progressmeter id="hoursProgressBar" />
|
||||
<progressmeter id="exceedHoursProgressBar" />
|
||||
<progressmeter id="exceedHoursProgressBar"
|
||||
style="background:red ; border:1px solid red"
|
||||
value="0" />
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
</vbox>
|
||||
|
||||
<!-- Money consumed -->
|
||||
<vbox width="100%">
|
||||
<panel
|
||||
title="${i18n:_('Percentage of estimated budget in money / money spent')}">
|
||||
<panelchildren>
|
||||
<grid fixedLayout="true">
|
||||
<columns>
|
||||
<column />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<grid fixedLayout="true">
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column width="200px" />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label
|
||||
value="${i18n:_('Budget in money')}:" />
|
||||
<label
|
||||
value="@{assignedHoursToOrderElementController.budget}" />
|
||||
</row>
|
||||
<row>
|
||||
<label
|
||||
value="${i18n:_('Money spent')}:" />
|
||||
<label
|
||||
value="@{assignedHoursToOrderElementController.moneyCost}" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<hbox>
|
||||
<label
|
||||
value="@{assignedHoursToOrderElementController.moneyCostPercentage}" />
|
||||
<label value="${i18n:_('%')}" />
|
||||
<progressmeter id="moneyCostProgressBar" />
|
||||
<progressmeter id="exceedMoneyCostProgressBar"
|
||||
style="background:red ; border:1px solid red"
|
||||
value="0" />
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue