This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository chorem. See http://git.chorem.org/chorem.git commit 9858179a2b09d9b99fd780e7acdbae519b85dc43 Author: Jean Couteau <jean.couteau@gmail.com> Date: Fri Feb 5 15:18:03 2016 +0100 refs #1313 Fix BillingPerProject report --- .../financial/BillingPerProjectReportAction.java | 27 +++++++++++++++++----- .../financial/reports/billingPerProjectReport.jsp | 6 ++++- pom.xml | 2 +- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerProjectReportAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerProjectReportAction.java index 192fbf4..7f2b487 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerProjectReportAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerProjectReportAction.java @@ -22,6 +22,7 @@ package org.chorem.webmotion.actions.financial; */ import org.chorem.ChoremClient; +import org.chorem.ChoremQueryMaker; import org.chorem.entities.*; import org.chorem.webmotion.actions.sales.SalesData; import org.chorem.webmotion.actions.sales.SalesReportHelper; @@ -58,10 +59,17 @@ public class BillingPerProjectReportAction extends WebMotionController { Map<Project, SalesData> billingData = getBillingPerProjectData(from, to, client); + Double total = 0.0; + + for (Map.Entry<Project, SalesData> entry : billingData.entrySet()) { + total += entry.getValue().getSales(); + } + List<Integer> listAllYearsInChorem = BillingReportHelper.listAllYears(client); return renderView("financial/reports/billingPerProjectReport.jsp", "data", billingData, + "total", total, "allYears", listAllYearsInChorem, "fromYear", from, "toYear", to); @@ -69,24 +77,28 @@ public class BillingPerProjectReportAction extends WebMotionController { protected Map<Project,SalesData> getBillingPerProjectData(String firstYear, String lastYear, - WikittyClient client){ + ChoremClient client){ Date last = BillingReportHelper.getLastDayOfYear(Integer.valueOf(lastYear)); Date first = BillingReportHelper.getFirstDayOfYear(Integer.valueOf(firstYear)); Map<Project,SalesData> billingData = new LinkedHashMap<>(); + String companyId = client.getConfiguration().getDefaultCompany(); + //get all the bills between first and last - WikittyQuery billsQuery = new WikittyQueryMaker() + WikittyQuery billsQuery = new ChoremQueryMaker().and() .bw(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_EMITTEDDATE, first, last) + .containsOne(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_BENEFICIARY) + .select(Element.ID).filterOnCompanyOrEmployee(companyId) .end(); List<FinancialTransaction> bills = client.findAllByQuery(FinancialTransaction.class, - billsQuery).getAll(); + billsQuery.setLimit(WikittyQuery.MAX)).getAll(); Map<String,SalesData> billingDataPerId = new LinkedHashMap<>(); - List<String> targetsId = new ArrayList<>(); + Set<String> targetsId = new HashSet<>(); for (FinancialTransaction bill:bills){ String target = bill.getTarget(); if (target != null) { @@ -94,7 +106,7 @@ public class BillingPerProjectReportAction extends WebMotionController { } } - List<Wikitty> targetsWikitty = client.restore(targetsId); + List<Wikitty> targetsWikitty = client.restore(new ArrayList<>(targetsId)); Map<String,Project> projectsById = new HashMap<>(); @@ -107,12 +119,15 @@ public class BillingPerProjectReportAction extends WebMotionController { projectsById.put(wkt.getWikittyId(), client.castTo(Project.class, wkt)); } else if (wkt.hasExtension(Quotation.EXT_QUOTATION)){ projectsId.add(wkt.getFieldAsWikitty(Quotation.EXT_QUOTATION, Quotation.FIELD_QUOTATION_PROJECT)); + wikittyById.put(wkt.getWikittyId(), wkt); } } List<Project> projects = client.restore(Project.class, projectsId, false); for (Project project:projects){ - projectsById.put(project.getWikittyId(), project); + if (project != null) { + projectsById.put(project.getWikittyId(), project); + } } //group bills by project and sum values diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/billingPerProjectReport.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/billingPerProjectReport.jsp index a3dfafe..c6555a8 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/billingPerProjectReport.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/billingPerProjectReport.jsp @@ -88,11 +88,15 @@ <c:forEach var="project" items="${data}"> <tr> <td><a href="<c:url value="/financial/report/billingPerProject/${project.key.wikittyId}"/>">${project.key.name}</a></td> - <td>${project.value.sales}</td> + <td>${project.value.sales} €</td> <td>${project.value.quotations}</td> <td>${project.value.mean} €</td> </tr> </c:forEach> + <tr> + <td>Total</td> + <td>${total} €</td> + </tr> </tbody> </table> diff --git a/pom.xml b/pom.xml index 6b51c9b..f610f47 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ <nuitonI18nVersion>3.3</nuitonI18nVersion> <nuitonConfigVersion>3.0-rc-2</nuitonConfigVersion> <nuitonWebVersion>1.17</nuitonWebVersion> - <wikittyVersion>3.11</wikittyVersion> + <wikittyVersion>3.13</wikittyVersion> <commonsCollectionsVersion>3.2.1</commonsCollectionsVersion> <commonsLoggingVersion>1.2</commonsLoggingVersion> <junitVersion>4.12</junitVersion> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.