branch develop updated (965a77e -> 929d3e1)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository chorem. See http://git.chorem.org/chorem.git from 965a77e [jgitflow-maven-plugin]Updating develop poms back to pre merge state new 9858179 refs #1313 Fix BillingPerProject report new 79a93ec refs #1313 : Fix BillingPerAccount report new b847cbe Organise imports new 85e3a92 refs #1313 : Fix account billing report new 5908028 refs #1313 : Fix project billing report new d0ddcd5 refs #1313 : Add total on account billing report new 929d3e1 Merge branch 'feature/1313' into develop The 7 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 929d3e1c1addd6cb52bb99e7ac24280f9de8d9b4 Merge: 965a77e d0ddcd5 Author: Jean Couteau <jean.couteau@gmail.com> Date: Sat Feb 6 15:56:14 2016 +0100 Merge branch 'feature/1313' into develop commit d0ddcd51ade5cbd1fd32008cc89c39ad513d8ab9 Author: Jean Couteau <jean.couteau@gmail.com> Date: Sat Feb 6 15:53:44 2016 +0100 refs #1313 : Add total on account billing report commit 590802817b8546f0e8d353f1930d425633c933e9 Author: Jean Couteau <jean.couteau@gmail.com> Date: Sat Feb 6 15:53:09 2016 +0100 refs #1313 : Fix project billing report commit 85e3a92842f52eb5f7914605d1c28179dad57154 Author: Jean Couteau <jean.couteau@gmail.com> Date: Fri Feb 5 17:14:22 2016 +0100 refs #1313 : Fix account billing report commit b847cbe2c6b89186e419fdf3f3209011b9b9cecb Author: Jean Couteau <jean.couteau@gmail.com> Date: Fri Feb 5 16:15:28 2016 +0100 Organise imports commit 79a93ec73bcdf0224187d223d5b8b57b81628618 Author: Jean Couteau <jean.couteau@gmail.com> Date: Fri Feb 5 16:08:33 2016 +0100 refs #1313 : Fix BillingPerAccount report commit 9858179a2b09d9b99fd780e7acdbae519b85dc43 Author: Jean Couteau <jean.couteau@gmail.com> Date: Fri Feb 5 15:18:03 2016 +0100 refs #1313 Fix BillingPerProject report Summary of changes: .../src/main/java/org/chorem/ChoremQueryMaker.java | 13 ++++ .../financial/AccountBillingReportAction.java | 32 +++++--- .../financial/BillingPerAccountReportAction.java | 90 +++++++++++++++++----- .../financial/BillingPerProjectReportAction.java | 44 ++++++++--- .../financial/ProjectBillingReportAction.java | 31 +++++--- chorem-webmotion/src/main/resources/mapping | 2 +- .../jsp/financial/reports/accountBillingReport.jsp | 6 +- .../financial/reports/billingPerAccountReport.jsp | 4 + .../financial/reports/billingPerProjectReport.jsp | 6 +- .../jsp/financial/reports/projectBillingReport.jsp | 6 +- pom.xml | 2 +- 11 files changed, 180 insertions(+), 56 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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>.
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 79a93ec73bcdf0224187d223d5b8b57b81628618 Author: Jean Couteau <jean.couteau@gmail.com> Date: Fri Feb 5 16:08:33 2016 +0100 refs #1313 : Fix BillingPerAccount report --- .../financial/BillingPerAccountReportAction.java | 77 +++++++++++++++++----- .../financial/reports/billingPerAccountReport.jsp | 4 ++ 2 files changed, 65 insertions(+), 16 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerAccountReportAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerAccountReportAction.java index a1ea506..868aebe 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerAccountReportAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerAccountReportAction.java @@ -22,12 +22,15 @@ 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; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; import org.nuiton.wikitty.WikittyClient; +import org.nuiton.wikitty.entities.Element; +import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; @@ -56,10 +59,17 @@ public class BillingPerAccountReportAction extends WebMotionController { Map<Company, SalesData> billingData = getBillingPerAccountData(from, to, client); + Double total = 0.0; + + for (Map.Entry<Company, SalesData> entry : billingData.entrySet()) { + total += entry.getValue().getSales(); + } + List<Integer> listAllYearsInChorem = BillingReportHelper.listAllYears(client); return renderView("financial/reports/billingPerAccountReport.jsp", "data", billingData, + "total", total, "allYears", listAllYearsInChorem, "fromYear", from, "toYear", to); @@ -67,22 +77,20 @@ public class BillingPerAccountReportAction extends WebMotionController { protected Map<Company,SalesData> getBillingPerAccountData(String firstYear, String lastYear, - WikittyClient client){ + ChoremClient client){ Date last = BillingReportHelper.getLastDayOfYear(Integer.valueOf(lastYear)); Date first = BillingReportHelper.getFirstDayOfYear(Integer.valueOf(firstYear)); - System.out.println(firstYear); - System.out.println(first); - - System.out.println(lastYear); - System.out.println(last); - Map<Company,SalesData> salesData = 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, @@ -90,22 +98,61 @@ public class BillingPerAccountReportAction extends WebMotionController { Map<String,SalesData> salesDataPerId = new LinkedHashMap<>(); + Set<String> payersId = new HashSet<>(); + for (FinancialTransaction bill:bills){ + String payer = bill.getPayer(); + if (payer != null) { + payersId.add(payer); + } + } + + List<Wikitty> payersWikitty = client.restore(new ArrayList<>(payersId)); + + Map<String,Company> companiesById = new HashMap<>(); + + List<String> companiesId = new ArrayList<>(); + + Map <String, Wikitty> wikittyById = new HashMap<>(); + + for (Wikitty wkt:payersWikitty){ + if (wkt.hasExtension(Company.EXT_COMPANY)){ + companiesById.put(wkt.getWikittyId(), client.castTo(Company.class, wkt)); + } else if (wkt.hasExtension(Employee.EXT_EMPLOYEE)){ + companiesId.add(wkt.getFieldAsWikitty(Employee.EXT_EMPLOYEE, Employee.FIELD_EMPLOYEE_COMPANY)); + wikittyById.put(wkt.getWikittyId(), wkt); + } + } + + List<Company> companies = client.restore(Company.class, companiesId, false); + for (Company company:companies){ + if (company != null) { + companiesById.put(company.getWikittyId(), company); + } + } + //group bills by account and sum values for (FinancialTransaction bill:bills){ - System.out.println(bill.getReference()); - String companyId = bill.getPayer(); + String payerId = bill.getPayer(); SalesData accountData; - if (salesDataPerId.containsKey(companyId)){ - accountData = salesDataPerId.get(companyId); + + //if payer is an employee, replace payerId with the employee company + if (!companiesById.containsKey(payerId)) { + Wikitty wkt = wikittyById.get(payerId); + if (wkt != null){ + payerId = wkt.getFieldAsWikitty(Employee.EXT_EMPLOYEE, Employee.FIELD_EMPLOYEE_COMPANY); + } + } + + if (salesDataPerId.containsKey(payerId)){ + accountData = salesDataPerId.get(payerId); } else { accountData = new SalesData(); } accountData.setSales(accountData.getSales() + bill.getAmount()); accountData.setQuotations(accountData.getQuotations()+1); - salesDataPerId.put(companyId, accountData); + salesDataPerId.put(payerId, accountData); } - System.out.println(salesDataPerId); //get accounts and create a map id->company List<Company> accounts = client.restore(Company.class, new ArrayList<>(salesDataPerId.keySet()), false); @@ -116,8 +163,6 @@ public class BillingPerAccountReportAction extends WebMotionController { } } - System.out.println(accountsById); - //populate the output for (Map.Entry<String, SalesData> entry : salesDataPerId.entrySet()) { Company account = accountsById.get(entry.getKey()); diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/billingPerAccountReport.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/billingPerAccountReport.jsp index 1be0524..b3100f0 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/billingPerAccountReport.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/billingPerAccountReport.jsp @@ -93,6 +93,10 @@ <td>${account.value.mean} €</td> </tr> </c:forEach> + <tr> + <td>Total</td> + <td>${total} €</td> + </tr> </tbody> </table> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 b847cbe2c6b89186e419fdf3f3209011b9b9cecb Author: Jean Couteau <jean.couteau@gmail.com> Date: Fri Feb 5 16:15:28 2016 +0100 Organise imports --- .../financial/BillingPerAccountReportAction.java | 13 +++++++++---- .../financial/BillingPerProjectReportAction.java | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerAccountReportAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerAccountReportAction.java index 868aebe..8dbfb72 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerAccountReportAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/BillingPerAccountReportAction.java @@ -25,16 +25,21 @@ 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; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; -import org.nuiton.wikitty.WikittyClient; import org.nuiton.wikitty.entities.Element; import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.query.WikittyQuery; -import org.nuiton.wikitty.query.WikittyQueryMaker; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * @author jcouteau <couteau@codelutin.com> 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 7f2b487..55d2ee1 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 @@ -23,18 +23,25 @@ package org.chorem.webmotion.actions.financial; import org.chorem.ChoremClient; import org.chorem.ChoremQueryMaker; -import org.chorem.entities.*; +import org.chorem.entities.FinancialTransaction; +import org.chorem.entities.Project; +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.WikittyClient; import org.nuiton.wikitty.entities.Element; import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.query.WikittyQuery; -import org.nuiton.wikitty.query.WikittyQueryMaker; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * @author jcouteau <couteau@codelutin.com> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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>.
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 590802817b8546f0e8d353f1930d425633c933e9 Author: Jean Couteau <jean.couteau@gmail.com> Date: Sat Feb 6 15:53:09 2016 +0100 refs #1313 : Fix project billing report --- .../src/main/java/org/chorem/ChoremQueryMaker.java | 13 +++++++++ .../financial/ProjectBillingReportAction.java | 31 +++++++++++++++------- chorem-webmotion/src/main/resources/mapping | 2 +- .../jsp/financial/reports/projectBillingReport.jsp | 6 ++++- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/chorem-entities/src/main/java/org/chorem/ChoremQueryMaker.java b/chorem-entities/src/main/java/org/chorem/ChoremQueryMaker.java index f8ab911..01eabbb 100644 --- a/chorem-entities/src/main/java/org/chorem/ChoremQueryMaker.java +++ b/chorem-entities/src/main/java/org/chorem/ChoremQueryMaker.java @@ -25,6 +25,7 @@ package org.chorem; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.entities.Employee; +import org.chorem.entities.Quotation; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMakerAbstract; @@ -82,6 +83,18 @@ public class ChoremQueryMaker extends WikittyQueryMakerAbstract<ChoremQueryMaker return this; } + /** + * Ajoute une contrainte qui filtre sur un projet ou une quotation qui pointe sur ce projet + * company + * + * @param projectId + * @return maker qui etait en argument + */ + public ChoremQueryMaker filterOnProjectOrQuotation(String projectId) { + this.or().ideq(projectId).eq(Quotation.FQ_FIELD_QUOTATION_PROJECT, projectId).close(); + return this; + } + // // Des methodes utilisables en function dans les select // diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/ProjectBillingReportAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/ProjectBillingReportAction.java index e75ce1e..1caedd1 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/ProjectBillingReportAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/financial/ProjectBillingReportAction.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.FinancialTransaction; -import org.chorem.entities.Quotation; +import org.chorem.entities.Project; 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; @@ -48,7 +47,7 @@ public class ProjectBillingReportAction extends WebMotionController { * @param client * @return */ - public Render billing(ChoremClient client, String project, String from, + public Render billing(ChoremClient client, String projectId, String from, String to) { if (null == from) { @@ -59,7 +58,7 @@ public class ProjectBillingReportAction 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,26 +66,30 @@ public class ProjectBillingReportAction extends WebMotionController { double previousYearValue = 0; + Project project = client.restore(Project.class, projectId); + 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.amount").where().and() - .eq(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_TARGET, project) .bw(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_EMITTEDDATE, yearFirstDay, yearLastDay) + .containsOne(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_TARGET) + .select(Element.ID).filterOnProjectOrQuotation(projectId) .end(); Double billing = client.findByQuery(Double.class, projectQuery); //TODO JC 2012-01-22 Find a way to replace two queries into one. - WikittyQuery quotationsQuery = new WikittyQueryMaker().and() - .eq(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_TARGET, project) + WikittyQuery quotationsQuery = new ChoremQueryMaker().and() .bw(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_EMITTEDDATE, yearFirstDay, yearLastDay) + .containsOne(FinancialTransaction.FQ_FIELD_FINANCIALTRANSACTION_TARGET) + .select(Element.ID).filterOnProjectOrQuotation(projectId) .end(); List<FinancialTransaction> quotations = client.findAllByQuery(FinancialTransaction.class, @@ -107,8 +110,16 @@ public class ProjectBillingReportAction 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/projectBillingReport.jsp", + "project", project.getName(), "data", salesData, + "total", total, "allYears", listAllYearsInChorem, "fromYear", from, "toYear", to); diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index e1bf470..6fb51f8 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -108,7 +108,7 @@ GET /financial/expenseAccounts/{expenseAccountId} action:financial.Expense PUT /financial/expenseAccounts/{expenseAccountId} action:financial.ExpenseAccountAction.saveExpenseAccount * /financial/report/billing action:financial.BillingReportAction.billing * /financial/report/billingPerProject action:financial.BillingPerProjectReportAction.billing -* /financial/report/billingPerProject/{project} action:financial.ProjectBillingReportAction.billing +* /financial/report/billingPerProject/{projectId} action:financial.ProjectBillingReportAction.billing * /financial/report/billingPerAccount action:financial.BillingPerAccountReportAction.billing * /financial/report/billingPerAccount/{account} action:financial.AccountBillingReportAction.billing * /billingMenu view:financial/reports/menu.jsp diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/projectBillingReport.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/projectBillingReport.jsp index 11f52a9..e5aed3b 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/projectBillingReport.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial/reports/projectBillingReport.jsp @@ -70,7 +70,7 @@ }); </script> - <h2>Facturation par année</h2> + <h2>Facturation par année - ${project}</h2> <form action="sales" method="get"> <select name="from"> @@ -109,6 +109,10 @@ <td class="percent">${year.value.progression} %</td> </tr> </c:forEach> + <tr> + <td>Total</td> + <td>${total} €</td> + </tr> </tbody> </table> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 d0ddcd51ade5cbd1fd32008cc89c39ad513d8ab9 Author: Jean Couteau <jean.couteau@gmail.com> Date: Sat Feb 6 15:53:44 2016 +0100 refs #1313 : Add total on account billing report --- .../webapp/WEB-INF/jsp/financial/reports/accountBillingReport.jsp | 4 ++++ 1 file changed, 4 insertions(+) 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 e835868..63e90ca 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 @@ -109,6 +109,10 @@ <td class="percent">${year.value.progression} %</td> </tr> </c:forEach> + <tr> + <td>Total</td> + <td>${total} €</td> + </tr> </tbody> </table> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 929d3e1c1addd6cb52bb99e7ac24280f9de8d9b4 Merge: 965a77e d0ddcd5 Author: Jean Couteau <jean.couteau@gmail.com> Date: Sat Feb 6 15:56:14 2016 +0100 Merge branch 'feature/1313' into develop .../src/main/java/org/chorem/ChoremQueryMaker.java | 13 ++++ .../financial/AccountBillingReportAction.java | 32 +++++--- .../financial/BillingPerAccountReportAction.java | 90 +++++++++++++++++----- .../financial/BillingPerProjectReportAction.java | 44 ++++++++--- .../financial/ProjectBillingReportAction.java | 31 +++++--- chorem-webmotion/src/main/resources/mapping | 2 +- .../jsp/financial/reports/accountBillingReport.jsp | 6 +- .../financial/reports/billingPerAccountReport.jsp | 4 + .../financial/reports/billingPerProjectReport.jsp | 6 +- .../jsp/financial/reports/projectBillingReport.jsp | 6 +- pom.xml | 2 +- 11 files changed, 180 insertions(+), 56 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm