[Bug #1178] Showing EffortDuration in reports instead of BigDecimal

Some new scriptlet classes were added

FEA: ItEr75S04BugFixing
This commit is contained in:
Ignacio Diaz Teijido 2011-09-14 20:13:24 +02:00 committed by Manuel Rego Casasnovas
parent 24b34efd6e
commit 8188f3c190
14 changed files with 277 additions and 69 deletions

View file

@ -21,13 +21,13 @@
package org.navalplanner.business.reports.dtos;
import java.math.BigDecimal;
import java.util.List;
import org.joda.time.LocalDate;
import org.navalplanner.business.common.Registry;
import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.workingday.EffortDuration;
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
import org.navalplanner.business.workreports.entities.WorkReportLine;
@ -48,7 +48,7 @@ public class CompletedEstimatedHoursPerTaskDTO {
private Integer partialPlannedHours;
private BigDecimal realHours;
private EffortDuration realHours;
private CompletedEstimatedHoursPerTaskDTO() {
workReportLineDAO = Registry.getWorkReportLineDAO();
@ -87,8 +87,8 @@ public class CompletedEstimatedHoursPerTaskDTO {
return result;
}
public BigDecimal calculateRealHours(Task task, LocalDate date) {
BigDecimal result = BigDecimal.ZERO;
public EffortDuration calculateRealHours(Task task, LocalDate date) {
EffortDuration result = EffortDuration.zero();
final List<WorkReportLine> workReportLines = workReportLineDAO
.findByOrderElementAndChildren(task.getOrderElement());
@ -99,8 +99,7 @@ public class CompletedEstimatedHoursPerTaskDTO {
for (WorkReportLine workReportLine : workReportLines) {
final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate());
if (date == null || workReportLineDate.compareTo(date) <= 0) {
result = result.add(workReportLine.getEffort()
.toHoursAsDecimalWithScale(2));
result = EffortDuration.sum(result, workReportLine.getEffort());
}
}
return result;
@ -130,11 +129,11 @@ public class CompletedEstimatedHoursPerTaskDTO {
this.partialPlannedHours = partialPlannedHours;
}
public BigDecimal getRealHours() {
public EffortDuration getRealHours() {
return realHours;
}
public void setRealHours(BigDecimal realHours) {
public void setRealHours(EffortDuration realHours) {
this.realHours = realHours;
}

View file

@ -21,7 +21,6 @@
package org.navalplanner.business.reports.dtos;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;
@ -29,6 +28,7 @@ import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
import org.navalplanner.business.labels.entities.Label;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.workingday.EffortDuration;
import org.navalplanner.business.workreports.entities.WorkReportLine;
import org.navalplanner.business.workreports.valueobjects.DescriptionValue;
@ -42,7 +42,7 @@ public class HoursWorkedPerResourceDTO implements Comparable {
private LocalTime clockFinish;
private BigDecimal effort;
private EffortDuration effort;
private String orderElementCode;
@ -52,15 +52,14 @@ public class HoursWorkedPerResourceDTO implements Comparable {
private String labels;
public HoursWorkedPerResourceDTO(
Resource resource,
public HoursWorkedPerResourceDTO(Resource resource,
WorkReportLine workReportLine) {
this.workerName = resource.getName();
this.date = workReportLine.getDate();
this.clockStart = workReportLine.getClockStart();
this.clockFinish = workReportLine.getClockFinish();
this.effort = workReportLine.getEffort().toHoursAsDecimalWithScale(2);
this.effort = workReportLine.getEffort();
this.orderElementCode = workReportLine.getOrderElement().getCode();
this.orderElementName = workReportLine.getOrderElement().getName();
this.descriptionValues = descriptionValuesAsString(workReportLine.getDescriptionValues());
@ -83,11 +82,11 @@ Resource resource,
return (result.length() > 0) ? result.substring(0, result.length() - 2) : result;
}
public BigDecimal getEffort() {
public EffortDuration getEffort() {
return effort;
}
public void setEffort(BigDecimal effort) {
public void setEffort(EffortDuration effort) {
this.effort = effort;
}

View file

@ -21,27 +21,27 @@
package org.navalplanner.business.reports.dtos;
import java.math.BigDecimal;
import org.navalplanner.business.resources.entities.Worker;
import org.navalplanner.business.workingday.EffortDuration;
public class HoursWorkedPerWorkerInAMonthDTO {
private String workerName;
private BigDecimal numHours;
private EffortDuration numHours;
public HoursWorkedPerWorkerInAMonthDTO(Worker worker, BigDecimal numHours) {
public HoursWorkedPerWorkerInAMonthDTO(Worker worker,
EffortDuration numHours) {
this.workerName = worker.getName();
this.numHours = numHours;
}
public BigDecimal getNumHours() {
public EffortDuration getNumHours() {
return numHours;
}
public void setNumHours(BigDecimal numHours) {
public void setNumHours(EffortDuration numHours) {
this.numHours = numHours;
}

View file

@ -35,6 +35,7 @@ import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.workingday.EffortDuration;
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
import org.navalplanner.business.workreports.entities.WorkReportLine;
@ -57,7 +58,7 @@ public class SchedulingProgressPerOrderDTO {
private Integer partialPlannedHours;
private BigDecimal realHours;
private EffortDuration realHours;
private BigDecimal averageProgress;
@ -107,7 +108,8 @@ public class SchedulingProgressPerOrderDTO {
// Progress calculations
this.imputedProgress = (totalPlannedHours != 0) ? new Double(
realHours.doubleValue()
realHours
.toHoursAsDecimalWithScale(2).doubleValue()
/ totalPlannedHours.doubleValue()) : new Double(0);
this.plannedProgress = (totalPlannedHours != 0) ? new Double(
partialPlannedHours / totalPlannedHours.doubleValue())
@ -115,7 +117,8 @@ public class SchedulingProgressPerOrderDTO {
// Differences calculations
this.costDifference = calculateCostDifference(averageProgress,
new BigDecimal(totalPlannedHours), realHours);
new BigDecimal(totalPlannedHours),
realHours.toHoursAsDecimalWithScale(2));
this.planningDifference = calculatePlanningDifference(averageProgress,
new BigDecimal(totalPlannedHours), new BigDecimal(
partialPlannedHours));
@ -168,8 +171,8 @@ public class SchedulingProgressPerOrderDTO {
.roundToHours();
}
public BigDecimal calculateRealHours(Order order, LocalDate date) {
BigDecimal result = BigDecimal.ZERO;
public EffortDuration calculateRealHours(Order order, LocalDate date) {
EffortDuration result = EffortDuration.zero();
final List<WorkReportLine> workReportLines = workReportLineDAO
.findByOrderElementAndChildren(order);
@ -177,8 +180,7 @@ public class SchedulingProgressPerOrderDTO {
for (WorkReportLine workReportLine : workReportLines) {
final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate());
if (date == null || workReportLineDate.compareTo(date) <= 0) {
result = result.add(workReportLine.getEffort()
.toHoursAsDecimalWithScale(2));
result = EffortDuration.sum(result, workReportLine.getEffort());
}
}
return result;
@ -196,7 +198,7 @@ public class SchedulingProgressPerOrderDTO {
return partialPlannedHours;
}
public BigDecimal getRealHours() {
public EffortDuration getRealHours() {
return realHours;
}

View file

@ -29,6 +29,7 @@ import org.joda.time.LocalDate;
import org.navalplanner.business.common.Registry;
import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.workingday.EffortDuration;
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
import org.navalplanner.business.workreports.entities.WorkReportLine;
@ -49,7 +50,7 @@ public class WorkingProgressPerTaskDTO {
private Integer partialPlannedHours;
private BigDecimal realHours;
private EffortDuration realHours;
private BigDecimal averageProgress;
@ -82,11 +83,14 @@ public class WorkingProgressPerTaskDTO {
this.averageProgress = task.getOrderElement().getAdvancePercentage(date);
this.imputedProgress = (totalPlannedHours != 0) ? new Double(
realHours.doubleValue() / totalPlannedHours.doubleValue())
realHours
.toHoursAsDecimalWithScale(2).doubleValue()
/ totalPlannedHours.doubleValue())
: new Double(0);
this.plannedProgress = (totalPlannedHours != 0) ? new Double(partialPlannedHours / totalPlannedHours.doubleValue()) : new Double(0);
this.costDifference = calculateCostDifference(averageProgress,
new BigDecimal(totalPlannedHours), realHours);
new BigDecimal(totalPlannedHours),
realHours.toHoursAsDecimalWithScale(2));
this.planningDifference = calculatePlanningDifference(averageProgress,
new BigDecimal(totalPlannedHours), new BigDecimal(
partialPlannedHours));
@ -118,8 +122,8 @@ public class WorkingProgressPerTaskDTO {
return result;
}
public BigDecimal calculateRealHours(Task task, LocalDate date) {
BigDecimal result = BigDecimal.ZERO;
public EffortDuration calculateRealHours(Task task, LocalDate date) {
EffortDuration result = EffortDuration.zero();
final List<WorkReportLine> workReportLines = workReportLineDAO
.findByOrderElementAndChildren(task.getOrderElement());
@ -130,8 +134,7 @@ public class WorkingProgressPerTaskDTO {
for (WorkReportLine workReportLine : workReportLines) {
final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate());
if (date == null || workReportLineDate.compareTo(date) <= 0) {
result = result.add(workReportLine.getEffort()
.toHoursAsDecimalWithScale(2));
result = EffortDuration.sum(result, workReportLine.getEffort());
}
}
return result;
@ -161,11 +164,11 @@ public class WorkingProgressPerTaskDTO {
this.partialPlannedHours = partialPlannedHours;
}
public BigDecimal getRealHours() {
public EffortDuration getRealHours() {
return realHours;
}
public void setRealHours(BigDecimal realHours) {
public void setRealHours(EffortDuration realHours) {
this.realHours = realHours;
}

View file

@ -21,7 +21,6 @@
package org.navalplanner.business.resources.daos;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
@ -232,11 +231,11 @@ public class ResourceDAO extends IntegrationEntityDAO<Resource> implements
for (Object row: rows) {
Object[] columns = (Object[]) row;
Worker worker = (Worker) findExistingEntity((Long) columns[0]);
BigDecimal numHours = (EffortDuration.seconds(((Long) columns[1])
.intValue())).toHoursAsDecimalWithScale(2);
EffortDuration effort = EffortDuration.seconds(((Long) columns[1])
.intValue());
HoursWorkedPerWorkerInAMonthDTO dto = new HoursWorkedPerWorkerInAMonthDTO(
worker, numHours);
worker, effort);
result.add(dto);
}
return result;

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="completedEstimatedHours" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="completedEstimatedHours">
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="completedEstimatedHours" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="completedEstimatedHours" scriptletClass="org.navalplanner.web.reports.RealHoursScriptlet">
<reportFont name="FreeSans" isDefault="true" fontName="FreeSans" size="9"/>
<parameter name="referenceDate" class="java.util.Date"/>
<parameter name="orderName" class="java.lang.String"/>
@ -10,7 +10,7 @@
<field name="estimatedHours" class="java.lang.Integer"/>
<field name="totalPlannedHours" class="java.lang.Integer"/>
<field name="partialPlannedHours" class="java.lang.Integer"/>
<field name="realHours" class="java.math.BigDecimal"/>
<field name="realHours" class="org.navalplanner.business.workingday.EffortDuration"/>
<group name="Group2">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/5)]]></groupExpression>
</group>
@ -237,7 +237,7 @@
<textField isBlankWhenNull="true">
<reportElement x="441" y="0" width="55" height="36"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{realHours}]]></textFieldExpression>
<textFieldExpression class="java.lang.String"><![CDATA[$P{REPORT_SCRIPTLET}.getRealHours()]]></textFieldExpression>
</textField>
</band>
</detail>

View file

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="hoursWorkedPerWorkerInAMonth" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="hoursWorkedPerWorkerInAMonth">
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="hoursWorkedPerWorkerInAMonth" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="hoursWorkedPerWorkerInAMonth" scriptletClass="org.navalplanner.web.reports.HoursWorkedPerWorkerInAMonthScriptlet">
<reportFont name="FreeSans" isDefault="true" fontName="FreeSans" size="9"/>
<parameter name="showNote" class="java.lang.Boolean"/>
<parameter name="year" class="java.lang.String"/>
<parameter name="month" class="java.lang.String"/>
<parameter name="logo" class="java.lang.String"/>
<field name="workerName" class="java.lang.String"/>
<field name="numHours" class="java.math.BigDecimal"/>
<variable name="sumNumHours" class="java.math.BigDecimal" calculation="Sum">
<variableExpression><![CDATA[$F{numHours}]]></variableExpression>
<initialValueExpression><![CDATA[java.math.BigDecimal.ZERO]]></initialValueExpression>
<field name="numHours" class="org.navalplanner.business.workingday.EffortDuration"/>
<variable name="sumNumHours" class="java.lang.String" calculation="System">
<variableExpression><![CDATA[$P{REPORT_SCRIPTLET}.getNumHours()]]></variableExpression>
<initialValueExpression><![CDATA["0"]]></initialValueExpression>
</variable>
<background>
<band splitType="Stretch"/>
@ -123,7 +123,7 @@
<textField isBlankWhenNull="true">
<reportElement x="213" y="0" width="100" height="15"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{numHours}]]></textFieldExpression>
<textFieldExpression class="java.lang.String"><![CDATA[$P{REPORT_SCRIPTLET}.getNumHours()]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="13" y="0" width="200" height="15"/>
@ -138,7 +138,7 @@
<textField evaluationTime="Report" isBlankWhenNull="true">
<reportElement x="213" y="10" width="100" height="15"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{sumNumHours}]]></textFieldExpression>
<textFieldExpression class="java.lang.String"><![CDATA[$V{sumNumHours}]]></textFieldExpression>
</textField>
<line>
<reportElement x="224" y="4" width="80" height="1"/>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="hoursWorkedPerWorker" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="hoursWorkedPerWorker">
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="hoursWorkedPerWorker" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="hoursWorkedPerWorker" scriptletClass="org.navalplanner.web.reports.HoursWorkedPerWorkerScriptlet">
<reportFont name="FreeSans" isDefault="true" fontName="FreeSans" size="9"/>
<parameter name="startingDate" class="java.util.Date"/>
<parameter name="endingDate" class="java.util.Date"/>
@ -11,18 +11,18 @@
<field name="date" class="java.util.Date"/>
<field name="clockStart" class="java.util.Date"/>
<field name="clockFinish" class="java.util.Date"/>
<field name="effort" class="java.math.BigDecimal"/>
<field name="effort" class="org.navalplanner.business.workingday.EffortDuration"/>
<field name="orderElementCode" class="java.lang.String"/>
<field name="orderElementName" class="java.lang.String"/>
<field name="descriptionValues" class="java.lang.String"/>
<field name="labels" class="java.lang.String"/>
<variable name="sumHoursPerDay" class="java.math.BigDecimal" resetType="Group" resetGroup="Date group" calculation="Sum">
<variableExpression><![CDATA[$F{effort}]]></variableExpression>
<initialValueExpression><![CDATA[java.math.BigDecimal.ZERO]]></initialValueExpression>
<variable name="sumHoursPerDay" class="java.lang.String" resetType="Group" resetGroup="Date group" calculation="System">
<variableExpression><![CDATA[$P{REPORT_SCRIPTLET}.getSumEffort()]]></variableExpression>
<initialValueExpression><![CDATA["0"]]></initialValueExpression>
</variable>
<variable name="sumHoursPerWorker" class="java.math.BigDecimal" resetType="Group" resetGroup="Worker group" incrementType="Group" incrementGroup="Date group" calculation="Sum">
<variableExpression><![CDATA[$V{sumHoursPerDay}]]></variableExpression>
<initialValueExpression><![CDATA[java.math.BigDecimal.ZERO]]></initialValueExpression>
<variable name="sumHoursPerWorker" class="java.lang.String" resetType="Group" resetGroup="Worker group" incrementType="Group" incrementGroup="Date group" calculation="System">
<variableExpression><![CDATA[$P{REPORT_SCRIPTLET}.getEffortWorker()]]></variableExpression>
<initialValueExpression><![CDATA["0"]]></initialValueExpression>
</variable>
<group name="Worker group">
<groupExpression><![CDATA[$F{workerName}]]></groupExpression>
@ -55,7 +55,7 @@
<textField isBlankWhenNull="true">
<reportElement x="257" y="1" width="38" height="15"/>
<textElement textAlignment="Center" verticalAlignment="Top"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{sumHoursPerWorker}]]></textFieldExpression>
<textFieldExpression class="java.lang.String"><![CDATA[$V{sumHoursPerWorker}]]></textFieldExpression>
</textField>
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="21" width="555" height="1"/>
@ -175,7 +175,7 @@
<textField isBlankWhenNull="true">
<reportElement x="257" y="10" width="38" height="15"/>
<textElement textAlignment="Center" verticalAlignment="Top"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{sumHoursPerDay}]]></textFieldExpression>
<textFieldExpression class="java.lang.String"><![CDATA[$V{sumHoursPerDay}]]></textFieldExpression>
</textField>
<line>
<reportElement x="257" y="6" width="35" height="1"/>
@ -330,7 +330,7 @@
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{effort}]]></textFieldExpression>
<textFieldExpression class="java.lang.String"><![CDATA[$P{REPORT_SCRIPTLET}.getEffort()]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="186" y="0" width="66" height="30"/>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="schedulingProgressPerOrder">
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="schedulingProgressPerOrder" scriptletClass="org.navalplanner.web.reports.RealHoursScriptlet">
<reportFont name="FreeSans" isDefault="true" fontName="FreeSans" size="9"/>
<parameter name="referenceDate" class="java.util.Date"/>
<parameter name="orderName" class="java.lang.String"/>
@ -12,7 +12,7 @@
<field name="estimatedHours" class="java.lang.Integer"/>
<field name="totalPlannedHours" class="java.lang.Integer"/>
<field name="partialPlannedHours" class="java.lang.Integer"/>
<field name="realHours" class="java.math.BigDecimal"/>
<field name="realHours" class="org.navalplanner.business.workingday.EffortDuration"/>
<field name="averageProgress" class="java.math.BigDecimal"/>
<field name="imputedProgress" class="java.lang.Double"/>
<field name="plannedProgress" class="java.lang.Double"/>
@ -196,7 +196,7 @@
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{realHours}]]></textFieldExpression>
<textFieldExpression class="java.lang.String"><![CDATA[$P{REPORT_SCRIPTLET}.getRealHours()]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="24" y="1" width="450" height="16"/>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="workingProgressPerTask">
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="workingProgressPerTask" scriptletClass="org.navalplanner.web.reports.RealHoursScriptlet">
<reportFont name="FreeSans" isDefault="true" fontName="FreeSans" size="9"/>
<parameter name="referenceDate" class="java.util.Date"/>
<parameter name="orderName" class="java.lang.String"/>
@ -10,7 +10,7 @@
<field name="estimatedHours" class="java.lang.Integer"/>
<field name="totalPlannedHours" class="java.lang.Integer"/>
<field name="partialPlannedHours" class="java.lang.Integer"/>
<field name="realHours" class="java.math.BigDecimal"/>
<field name="realHours" class="org.navalplanner.business.workingday.EffortDuration"/>
<field name="averageProgress" class="java.math.BigDecimal"/>
<field name="imputedProgress" class="java.lang.Double"/>
<field name="plannedProgress" class="java.lang.Double"/>
@ -290,7 +290,7 @@
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{realHours}]]></textFieldExpression>
<textFieldExpression class="java.lang.String"><![CDATA[$P{REPORT_SCRIPTLET}.getRealHours()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="86" y="96" width="80" height="20"/>

View file

@ -0,0 +1,45 @@
/*
* This file is part of NavalPlan
*
* Copyright (C) 2011 - ComtecSF, 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.reports;
import net.sf.jasperreports.engine.JRDefaultScriptlet;
import net.sf.jasperreports.engine.JRScriptletException;
import org.navalplanner.business.workingday.EffortDuration;
/**
* This class will be used to implement methods that could be called from jrxml
* to make calculations over {@link EffortDuration} elements.
*
* @author Ignacio Diaz Teijido <ignacio.diaz@comtecsf.es>
*
*/
public class HoursWorkedPerWorkerInAMonthScriptlet extends JRDefaultScriptlet {
/**
* Method used in hoursWorkedPerWorkerInAMonthReport.jrxml
*
* @return
* @throws JRScriptletException
*/
public String getNumHours() throws JRScriptletException {
EffortDuration effort = (EffortDuration) this.getFieldValue("numHours");
return effort.toFormattedString();
}
}

View file

@ -0,0 +1,119 @@
/*
* This file is part of NavalPlan
*
* Copyright (C) 2011 - ComtecSF, 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.reports;
import java.util.HashSet;
import java.util.Set;
import net.sf.jasperreports.engine.JRAbstractScriptlet;
import net.sf.jasperreports.engine.JRScriptletException;
import org.navalplanner.business.workingday.EffortDuration;
/**
* This class will be used to implement methods that could be called from
* hoursWoerkedPerWorkerReport.jrxml to make calculations over
* {@link EffortDuration} elements.
*
* @author Ignacio Diaz Teijido <ignacio.diaz@comtecsf.es>
*
*/
public class HoursWorkedPerWorkerScriptlet extends JRAbstractScriptlet {
private Set<EffortDuration> efforts = new HashSet<EffortDuration>();
public String getEffort() throws JRScriptletException {
EffortDuration effort = (EffortDuration) this.getFieldValue("effort");
return effort.toFormattedString();
}
public String getSumEffort() throws JRScriptletException {
return (String) this.getVariableValue("sumHoursPerDay");
}
public String getEffortWorker() throws JRScriptletException {
return (String) this.getVariableValue("sumHoursPerWorker");
}
@Override
public void afterDetailEval() throws JRScriptletException {
// We use the set because elements could be processed twice depending on
// the report
EffortDuration current = (EffortDuration) this.getFieldValue("effort");
if (!efforts.contains(current)) {
// The effort of the worker is the sum of all efforts.
EffortDuration effortWorker = EffortDuration.sum(current,
EffortDuration.parseFromFormattedString((String) this
.getVariableValue("sumHoursPerWorker")));
this.setVariableValue("sumHoursPerWorker",
effortWorker.toFormattedString());
// We calculate here the effort for a particular day
EffortDuration effort = EffortDuration.sum(current, EffortDuration
.parseFromFormattedString((String) this
.getVariableValue("sumHoursPerDay")));
this.setVariableValue("sumHoursPerDay", effort.toFormattedString());
efforts.add(current);
}
}
@Override
public void afterColumnInit() throws JRScriptletException {
}
@Override
public void afterGroupInit(String arg0) throws JRScriptletException {
}
@Override
public void afterPageInit() throws JRScriptletException {
}
@Override
public void afterReportInit() throws JRScriptletException {
}
@Override
public void beforeColumnInit() throws JRScriptletException {
}
@Override
public void beforeDetailEval() throws JRScriptletException {
}
@Override
public void beforeGroupInit(String arg0) throws JRScriptletException {
}
@Override
public void beforePageInit() throws JRScriptletException {
}
@Override
public void beforeReportInit() throws JRScriptletException {
}
}

View file

@ -0,0 +1,42 @@
/*
* This file is part of NavalPlan
*
* Copyright (C) 2011 - ComtecSF, 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.reports;
import net.sf.jasperreports.engine.JRDefaultScriptlet;
import net.sf.jasperreports.engine.JRScriptletException;
import org.navalplanner.business.workingday.EffortDuration;
/**
* This class will be used to implement methods that could be called from
* hoursWorkedPerWorkerReport.jrxml, completedEstimatedHours.jrxml and
* workingProgressPerTask.jrxml to make calculations over {@link EffortDuration}
* elements.
*
* @author Ignacio Diaz Teijido <ignacio.diaz@comtecsf.es>
*
*/
public class RealHoursScriptlet extends JRDefaultScriptlet {
public String getRealHours() throws JRScriptletException {
EffortDuration effort = (EffortDuration) this
.getFieldValue("realHours");
return effort.toFormattedString();
}
}