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 85e3a92842f52eb5f7914605d1c28179dad57154 Author: Jean Couteau <jean.couteau@gmail.com> Date: Fri Feb 5 17:14:22 2016 +0100 refs #1313 : Fix account billing report --- .../financial/AccountBillingReportAction.java | 32 +++++++++++++++------- .../jsp/financial/reports/accountBillingReport.jsp | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/AccountBillingReportAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/AccountBillingReportAction.java index 7bc595a..932ee8e 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/AccountBillingReportAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/AccountBillingReportAction.java @@ -22,15 +22,14 @@ package org.chorem.webmotion.actions.financial; */ import org.chorem.ChoremClient; -import org.chorem.entities.Accepted; +import org.chorem.ChoremQueryMaker; +import org.chorem.entities.Company; import org.chorem.entities.FinancialTransaction; -import org.chorem.entities.Quotation; import org.chorem.webmotion.actions.sales.SalesData; -import org.chorem.webmotion.actions.sales.SalesReportHelper; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; +import org.nuiton.wikitty.entities.Element; import org.nuiton.wikitty.query.WikittyQuery; -import org.nuiton.wikitty.query.WikittyQueryMaker; import java.util.Date; import java.util.LinkedHashMap; @@ -59,7 +58,7 @@ public class AccountBillingReportAction extends WebMotionController { to = String.valueOf(BillingReportHelper.getLastYear()); } - Map<Integer, SalesData> salesData = new LinkedHashMap<Integer, SalesData>(); + Map<Integer, SalesData> salesData = new LinkedHashMap<>(); List<Integer> listAllYears = BillingReportHelper.listAllYears(from, to); @@ -67,32 +66,37 @@ public class AccountBillingReportAction extends WebMotionController { double previousYearValue = 0.0; + Company company = client.restore(Company.class, account); + for (Integer year:listAllYears){ + Date yearFirstDay = BillingReportHelper.getFirstDayOfYear(year); Date yearLastDay = BillingReportHelper.getLastDayOfYear(year); SalesData yearData = new SalesData(); - WikittyQuery projectQuery = new WikittyQueryMaker() + WikittyQuery projectQuery = new ChoremQueryMaker() .select().sum(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_AMOUNT).where().and() - .eq(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_PAYER, account) .bw(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_EMITTEDDATE, yearFirstDay, yearLastDay) + .containsOne(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_PAYER) + .select(Element.ID).filterOnCompanyOrEmployee(account) .end(); Double sales = client.findByQuery(Double.class, projectQuery); //TODO JC 2012-01-26 Find a way to replace two queries into one. - WikittyQuery quotationsQuery = new WikittyQueryMaker().and() - .eq(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_PAYER, account) + WikittyQuery quotationsQuery = new ChoremQueryMaker().and() .bw(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_EMITTEDDATE, yearFirstDay, yearLastDay) + .containsOne(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_PAYER) + .select(Element.ID).filterOnCompanyOrEmployee(account) .end(); List<FinancialTransaction> quotations = client.findAllByQuery(FinancialTransaction.class, quotationsQuery).getAll(); - //Progression devis envoyés + //Progression ventes double salesProgression = 0; if (previousYearValue != 0){ salesProgression = 100 * (sales - previousYearValue) / previousYearValue; @@ -107,8 +111,16 @@ public class AccountBillingReportAction extends WebMotionController { salesData.put(year, yearData); } + Double total = 0.0; + + for (Map.Entry<Integer, SalesData> entry : salesData.entrySet()) { + total += entry.getValue().getSales(); + } + return renderView("financial/reports/accountBillingReport.jsp", + "account", company.getName(), "data", salesData, + "total", total, "allYears", listAllYearsInChorem, "fromYear", from, "toYear", to); diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/accountBillingReport.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/accountBillingReport.jsp index 11f52a9..e835868 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/accountBillingReport.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/accountBillingReport.jsp @@ -70,7 +70,7 @@ }); </script> - <h2>Facturation par année</h2> + <h2>Facturation par année - ${account}</h2> <form action="sales" method="get"> <select name="from"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.