diff --git a/libreplan-business/src/main/java/org/libreplan/business/reports/dtos/ProjectStatusReportDTO.java b/libreplan-business/src/main/java/org/libreplan/business/reports/dtos/ProjectStatusReportDTO.java
index 506691e23..7b5446c71 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/reports/dtos/ProjectStatusReportDTO.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/reports/dtos/ProjectStatusReportDTO.java
@@ -19,7 +19,8 @@
package org.libreplan.business.reports.dtos;
-import org.apache.commons.lang.StringUtils;
+import java.math.BigDecimal;
+
import org.libreplan.business.orders.entities.OrderElement;
import org.libreplan.business.orders.entities.SumChargedEffort;
import org.libreplan.business.orders.entities.TaskSource;
@@ -44,9 +45,18 @@ public class ProjectStatusReportDTO {
private EffortDuration imputedHours;
+ private BigDecimal budget;
+
+ private BigDecimal hoursCost;
+
+ private BigDecimal expensesCost;
+
+ private BigDecimal totalCost;
+
public ProjectStatusReportDTO(OrderElement orderElement) {
code = orderElement.getCode();
- name = orderElement.getName();
+ name = Util.getPrefixSpacesDependingOnDepth(orderElement)
+ + orderElement.getName();
Integer estimatedHours = orderElement.getWorkHours();
this.estimatedHours = estimatedHours != null ? EffortDuration
@@ -62,7 +72,7 @@ public class ProjectStatusReportDTO {
imputedHours = sumChargedEffort.getTotalChargedEffort();
}
- appendPrefixSpacesDependingOnDepth(orderElement);
+ setBudget(orderElement.getBudget());
}
public String getCode() {
@@ -92,14 +102,68 @@ public class ProjectStatusReportDTO {
return effortDuration.toFormattedString();
}
- private void appendPrefixSpacesDependingOnDepth(OrderElement orderElement) {
- int depth = 0;
- while (!orderElement.getParent().isOrder()) {
- depth++;
- orderElement = orderElement.getParent();
- }
+ public BigDecimal getBudget() {
+ return budget;
+ }
- name = StringUtils.repeat(INDENT_PREFIX, depth) + name;
+ public void setBudget(BigDecimal budget) {
+ this.budget = budget;
+ }
+
+ public BigDecimal getHoursCost() {
+ return hoursCost;
+ }
+
+ public void setHoursCost(BigDecimal hoursCost) {
+ this.hoursCost = hoursCost;
+ }
+
+ public BigDecimal getExpensesCost() {
+ return expensesCost;
+ }
+
+ public void setExpensesCost(BigDecimal expensesCost) {
+ this.expensesCost = expensesCost;
+ }
+
+ public BigDecimal getTotalCost() {
+ return totalCost;
+ }
+
+ public void setTotalCost(BigDecimal totalCost) {
+ this.totalCost = totalCost;
+ }
+
+ public BigDecimal getBudgetIntegerPart() {
+ return Util.getIntegerPart(budget);
+ }
+
+ public BigDecimal getBudgetFractionalPart() {
+ return Util.getFractionalPart(budget);
+ }
+
+ public BigDecimal getHoursCostIntegerPart() {
+ return Util.getIntegerPart(hoursCost);
+ }
+
+ public BigDecimal getHoursCostFractionalPart() {
+ return Util.getFractionalPart(hoursCost);
+ }
+
+ public BigDecimal getExpensesCostIntegerPart() {
+ return Util.getIntegerPart(expensesCost);
+ }
+
+ public BigDecimal getExpensesCostFractionalPart() {
+ return Util.getFractionalPart(expensesCost);
+ }
+
+ public BigDecimal getTotalCostIntegerPart() {
+ return Util.getIntegerPart(totalCost);
+ }
+
+ public BigDecimal getTotalCostFractionalPart() {
+ return Util.getFractionalPart(totalCost);
}
}
\ No newline at end of file
diff --git a/libreplan-business/src/main/java/org/libreplan/business/reports/dtos/Util.java b/libreplan-business/src/main/java/org/libreplan/business/reports/dtos/Util.java
new file mode 100644
index 000000000..3657c7394
--- /dev/null
+++ b/libreplan-business/src/main/java/org/libreplan/business/reports/dtos/Util.java
@@ -0,0 +1,64 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 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
+ * 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 .
+ */
+
+package org.libreplan.business.reports.dtos;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+import org.apache.commons.lang.StringUtils;
+import org.libreplan.business.trees.ITreeNode;
+
+/**
+ * Utilities methods for report DTOs.
+ *
+ * @author Manuel Rego Casasnovas
+ */
+public class Util {
+
+ public static final String INDENT_PREFIX = " ";
+
+ public static BigDecimal getIntegerPart(BigDecimal value) {
+ if (value == null) {
+ return value;
+ }
+ return value.setScale(2, RoundingMode.DOWN);
+ }
+
+ public static BigDecimal getFractionalPart(BigDecimal value) {
+ if (value == null) {
+ return value;
+ }
+ BigDecimal fractionalPart = value.subtract(value.setScale(0,
+ RoundingMode.FLOOR));
+ return (fractionalPart.compareTo(BigDecimal.ZERO) != 0) ? fractionalPart
+ : null;
+ }
+
+ public static String getPrefixSpacesDependingOnDepth(ITreeNode> node) {
+ int depth = 0;
+ while (node.getParent() != null && node.getParent().getParent() != null) {
+ depth++;
+ node = node.getParent();
+ }
+
+ return StringUtils.repeat(INDENT_PREFIX, depth);
+ }
+
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/reports/IProjectStatusReportModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/reports/IProjectStatusReportModel.java
index 774041a75..6a5f0fff5 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/reports/IProjectStatusReportModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/reports/IProjectStatusReportModel.java
@@ -19,6 +19,7 @@
package org.libreplan.web.reports;
+import java.math.BigDecimal;
import java.util.List;
import org.libreplan.business.orders.entities.Order;
@@ -35,4 +36,10 @@ public interface IProjectStatusReportModel {
List getProjectStatusReportDTOs(Order order);
+ BigDecimal getHoursCost(Order order);
+
+ BigDecimal getExpensesCost(Order order);
+
+ BigDecimal getTotalCost(Order order);
+
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/reports/ProjectStatusReportController.java b/libreplan-webapp/src/main/java/org/libreplan/web/reports/ProjectStatusReportController.java
index 167f4ee72..fd7068009 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/reports/ProjectStatusReportController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/reports/ProjectStatusReportController.java
@@ -33,6 +33,7 @@ import org.libreplan.business.orders.entities.SumChargedEffort;
import org.libreplan.business.orders.entities.TaskSource;
import org.libreplan.business.reports.dtos.ProjectStatusReportDTO;
import org.libreplan.business.workingday.EffortDuration;
+import org.libreplan.web.common.Util;
import org.libreplan.web.common.components.bandboxsearch.BandboxSearch;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
@@ -122,6 +123,15 @@ public class ProjectStatusReportController extends LibrePlanReportController {
result.put("imputedHours",
ProjectStatusReportDTO.toString(imputedHours));
+ result.put("budget", Util.addCurrencySymbol(order.getBudget()));
+ result.put("hoursCost", Util.addCurrencySymbol(projectStatusReportModel
+ .getHoursCost(order)));
+ result.put("expensesCost", Util
+ .addCurrencySymbol(projectStatusReportModel
+ .getExpensesCost(order)));
+ result.put("totalCost", Util.addCurrencySymbol(projectStatusReportModel
+ .getTotalCost(order)));
+
return result;
}
}
\ No newline at end of file
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/reports/ProjectStatusReportModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/reports/ProjectStatusReportModel.java
index 4f7a1de72..aec53c453 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/reports/ProjectStatusReportModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/reports/ProjectStatusReportModel.java
@@ -19,6 +19,7 @@
package org.libreplan.web.reports;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -26,6 +27,7 @@ import java.util.List;
import org.libreplan.business.orders.daos.IOrderDAO;
import org.libreplan.business.orders.entities.Order;
import org.libreplan.business.orders.entities.OrderElement;
+import org.libreplan.business.planner.entities.IMoneyCostCalculator;
import org.libreplan.business.reports.dtos.ProjectStatusReportDTO;
import org.libreplan.business.scenarios.IScenarioManager;
import org.libreplan.web.security.SecurityUtils;
@@ -51,6 +53,9 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
@Autowired
private IScenarioManager scenarioManager;
+ @Autowired
+ private IMoneyCostCalculator moneyCostCalculator;
+
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
@@ -72,10 +77,33 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
List dtos = new ArrayList();
for (OrderElement child : order.getAllChildren()) {
- dtos.add(new ProjectStatusReportDTO(child));
+ ProjectStatusReportDTO dto = new ProjectStatusReportDTO(child);
+ dto.setHoursCost(moneyCostCalculator.getHoursMoneyCost(child));
+ dto.setExpensesCost(moneyCostCalculator.getExpensesMoneyCost(child));
+ dto.setTotalCost(moneyCostCalculator.getTotalMoneyCost(child));
+
+ dtos.add(dto);
}
return dtos;
}
+ @Override
+ @Transactional(readOnly = true)
+ public BigDecimal getHoursCost(Order order) {
+ return moneyCostCalculator.getHoursMoneyCost(order);
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public BigDecimal getExpensesCost(Order order) {
+ return moneyCostCalculator.getExpensesMoneyCost(order);
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public BigDecimal getTotalCost(Order order) {
+ return moneyCostCalculator.getTotalMoneyCost(order);
+ }
+
}
\ No newline at end of file