Chorem-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
September 2012
- 1 participants
- 8 discussions
r270 - in trunk: chorem-entities/src/main/java/org/chorem chorem-webmotion/src/main/java/org/chorem/webmotion/actions
by bpoussin@users.chorem.org 15 Sep '12
by bpoussin@users.chorem.org 15 Sep '12
15 Sep '12
Author: bpoussin
Date: 2012-09-15 14:39:27 +0200 (Sat, 15 Sep 2012)
New Revision: 270
Url: http://chorem.org/repositories/revision/chorem/270
Log:
refactoring pour eviter de faire a des endroits different les memes choses sur les requetes
Added:
trunk/chorem-entities/src/main/java/org/chorem/ChoremQueryHelper.java
trunk/chorem-entities/src/main/java/org/chorem/ChoremQueryMaker.java
Modified:
trunk/chorem-entities/src/main/java/org/chorem/ChoremClient.java
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
Modified: trunk/chorem-entities/src/main/java/org/chorem/ChoremClient.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ChoremClient.java 2012-09-15 12:38:47 UTC (rev 269)
+++ trunk/chorem-entities/src/main/java/org/chorem/ChoremClient.java 2012-09-15 12:39:27 UTC (rev 270)
@@ -253,7 +253,7 @@
}
/**
- * Retourne la comparny par defaut pour l'utilisateur loggue, si par d'utilisateur
+ * Retourne la company par defaut pour l'utilisateur loggue, si pas d'utilisateur
* alors on prend la company defini dans la configuration general. S'il n'y
* a aucune company, on en cree une nouvelle (non stocke) pour que tout
* fonctionne bien. Cette company n'existant pas reellement les recherches
Added: trunk/chorem-entities/src/main/java/org/chorem/ChoremQueryHelper.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ChoremQueryHelper.java (rev 0)
+++ trunk/chorem-entities/src/main/java/org/chorem/ChoremQueryHelper.java 2012-09-15 12:39:27 UTC (rev 270)
@@ -0,0 +1,48 @@
+package org.chorem;
+
+
+import java.util.Collection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.wikitty.entities.ElementField;
+import org.nuiton.wikitty.entities.WikittyExtension;
+import org.nuiton.wikitty.query.WikittyQuery;
+
+/**
+ * Classe contenant des methodes permettant d'ajouter des elements a une Query.
+ * Ceci permet de centraliser les modification de query et de les faire evoluer
+ * pour toutes les requetes facilement.
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class ChoremQueryHelper {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ChoremQueryHelper.class);
+
+ /**
+ * Ajoute les tries comme declarer sur les extensions passer en parametre.
+ * Si extensions est vide ou null, alors on ajoute les tries de toutes les
+ * extensions connues
+ *
+ * @param client
+ * @param query
+ * @param extensions les noms des extensions sur lequel il faut faire les tries
+ * @return query qui etait en parametre
+ */
+ static public WikittyQuery addSort(ChoremClient client, WikittyQuery query, String ... extensions) {
+ // on essai de trier les resultats au mieux tout en ne faisant qu'un requete
+ Collection<WikittyExtension> exts = client.restoreExtensionLastVersion(extensions);
+ for (WikittyExtension ext : exts) {
+ query.addSortAscending(ext.getSortAscending().toArray(new ElementField[0]));
+ query.addSortDescending(ext.getSortDescending().toArray(new ElementField[0]));
+ }
+
+ return query;
+ }
+
+}
Added: trunk/chorem-entities/src/main/java/org/chorem/ChoremQueryMaker.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ChoremQueryMaker.java (rev 0)
+++ trunk/chorem-entities/src/main/java/org/chorem/ChoremQueryMaker.java 2012-09-15 12:39:27 UTC (rev 270)
@@ -0,0 +1,64 @@
+package org.chorem;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.entities.Employee;
+import org.nuiton.wikitty.query.WikittyQuery;
+import org.nuiton.wikitty.query.WikittyQueryMakerAbstract;
+
+/**
+ * Extension de WikittyQueryMaker pour ajouter de nouvelle methode qui permette
+ * de centraliser l'ajout de contrainte que l'on fait dans plusieurs requetes.
+ * Cet objet peut-etre utiliser directement a la place de WikittyQueryMaker.
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class ChoremQueryMaker extends WikittyQueryMakerAbstract<ChoremQueryMaker> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ChoremQueryMaker.class);
+
+ public ChoremQueryMaker() {
+ super();
+ }
+
+ public ChoremQueryMaker(WikittyQuery query) {
+ super(query);
+ }
+
+ @Override
+ protected ChoremQueryMaker asM() {
+ return this;
+ }
+
+ /**
+ * Ajoute une contrainte qui filtre sur une company ou un employer de cette
+ * company
+ *
+ * @param client permet de rechercher l'id de la company par defaut pour l'utilisateur courant
+ * @return maker qui etait en argument
+ */
+ public ChoremQueryMaker filterOnCompanyOrEmployee(ChoremClient client) {
+ String companyId = client.getDefaultCompany().getWikittyId();
+ filterOnCompanyOrEmployee(companyId);
+ return this;
+ }
+
+ /**
+ * Ajoute une contrainte qui filtre sur une company ou un employer de cette
+ * company
+ *
+ * @param companyId
+ * @return maker qui etait en argument
+ */
+ public ChoremQueryMaker filterOnCompanyOrEmployee(String companyId) {
+ this.or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close();
+ return this;
+ }
+
+}
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-15 12:38:47 UTC (rev 269)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-15 12:39:27 UTC (rev 270)
@@ -39,6 +39,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.ChoremClient;
+import org.chorem.ChoremQueryHelper;
+import org.chorem.ChoremQueryMaker;
import org.chorem.entities.Attachment;
import org.chorem.entities.Category;
import org.chorem.entities.Configuration;
@@ -146,23 +148,23 @@
protected WikittyQuery[] getDebtIncomeQuery(Date first, Date last, String companyId) {
// toutes les depenses depuis le debut de l'annee
- WikittyQuery debtQuery = new WikittyQueryMaker()
+ WikittyQuery debtQuery = new ChoremQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.exteq(Invoice.EXT_INVOICE)
.bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, first, last)
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ .select(Element.ID).filterOnCompanyOrEmployee(companyId)
.end().setLimit(WikittyQuery.MAX);
// toutes les factures emises depuis le debut de l'annee
- WikittyQuery incomeQuery = new WikittyQueryMaker()
+ WikittyQuery incomeQuery = new ChoremQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.exteq(Invoice.EXT_INVOICE)
.bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, first, last)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ .select(Element.ID).filterOnCompanyOrEmployee(companyId)
.end().setLimit(WikittyQuery.MAX);
WikittyQuery[] result = new WikittyQuery[]{
@@ -231,25 +233,25 @@
WikittyQuery[] pastAnnualDebtIncomeQuery = getDebtIncomeQuery(lastYearFirstDay, lastYearNow, companyId);
// les factures que notre societe doit payer au plus tard dans 7 jours
- WikittyQuery invoiceDebtQuery = new WikittyQueryMaker()
+ WikittyQuery invoiceDebtQuery = new ChoremQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.exteq(Invoice.EXT_INVOICE)
.lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, inOneWeek)
.isNull(Invoice.FQ_FIELD_INVOICE_PAYMENTDATE)
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ .select(Element.ID).filterOnCompanyOrEmployee(companyId)
.end().setLimit(WikittyQuery.MAX);
// les factures qu'auraient du payer nos clients (ils sont en retard)
- WikittyQuery invoiceIncomeQuery = new WikittyQueryMaker()
+ WikittyQuery invoiceIncomeQuery = new ChoremQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.exteq(Invoice.EXT_INVOICE)
.lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, now)
.isNull(Invoice.FQ_FIELD_INVOICE_PAYMENTDATE)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ .select(Element.ID).filterOnCompanyOrEmployee(companyId)
.end().setLimit(WikittyQuery.MAX);
// les contacts qui doivnet etre pris dans les 7 prochains jours
@@ -584,12 +586,8 @@
.bw(Invoice.FQ_FIELD_INVOICE_PAYMENTDATE, start, end)
.end().setLimit(WikittyQuery.MAX);
- WikittyExtension ext = client.restoreExtensionLastVersion(Invoice.EXT_INVOICE);
+ ChoremQueryHelper.addSort(client, invoiceQuery, Invoice.EXT_INVOICE);
- invoiceQuery.addSortAscending(ext.getSortAscending().toArray(new ElementField[0]));
- invoiceQuery.addSortDescending(ext.getSortDescending().toArray(new ElementField[0]));
-
-
WikittyQueryResult<Invoice> invoices =
client.findAllByQuery(Invoice.class, invoiceQuery);
@@ -676,42 +674,42 @@
end = DateUtil.setLastDayOfMonth(end);
// La somme des factures que la company doit payer jusqu'a la date demandee
- WikittyQuery debt = new WikittyQueryMaker()
+ WikittyQuery debt = new ChoremQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ .select(Element.ID).filterOnCompanyOrEmployee(companyId)
.close()
.lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start)
.end()
.setLimit(WikittyQuery.MAX);
// La somme des factures que la company doit percevoir jusqu'a la date demandee
- WikittyQuery income = new WikittyQueryMaker()
+ WikittyQuery income = new ChoremQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ .select(Element.ID).filterOnCompanyOrEmployee(companyId)
.close()
.lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start)
.end()
.setLimit(WikittyQuery.MAX);
// La liste des factures entre les deux dates que l'on doit payer
- WikittyQuery invoiceDebt = new WikittyQueryMaker().and()
+ WikittyQuery invoiceDebt = new ChoremQueryMaker().and()
.parse(query)
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ .select(Element.ID).filterOnCompanyOrEmployee(companyId)
.close()
.bw(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start, end)
.end()
.setLimit(WikittyQuery.MAX);
// La liste des factures entre les deux dates que l'on doit payer
- WikittyQuery invoiceIncome = new WikittyQueryMaker().and()
+ WikittyQuery invoiceIncome = new ChoremQueryMaker().and()
.parse(query)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ .select(Element.ID).filterOnCompanyOrEmployee(companyId)
.close()
.bw(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start, end)
.end()
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-09-15 12:38:47 UTC (rev 269)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-09-15 12:39:27 UTC (rev 270)
@@ -30,6 +30,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -46,6 +47,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.ChoremClient;
import org.chorem.ChoremConfigOption;
+import org.chorem.ChoremQueryHelper;
import org.debux.webmotion.server.WebMotionController;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.UploadFile;
@@ -187,13 +189,8 @@
}
// on essai de trier les resultats au mieux tout en ne faisant qu'un requete
- Collection<WikittyExtension> exts = client.restoreExtensionLastVersion(extension);
- for (WikittyExtension ext : exts) {
- q.addSortAscending(ext.getSortAscending().toArray(new ElementField[0]));
- q.addSortDescending(ext.getSortDescending().toArray(new ElementField[0]));
- }
+ ChoremQueryHelper.addSort(client, q, extension);
-
WikittyQueryResult<Wikitty> results =
client.findAllByQuery(Wikitty.class, q);
@@ -201,19 +198,24 @@
Map<String, List<Wikitty>> map =
new MapWithDefault<String, List<Wikitty>>(
new TreeMap<String, List<Wikitty>>(), new LinkedList<Wikitty>());
+
+ Set<String> exts = null;
+ if (extension != null && extension.length > 0) {
+ exts = new HashSet<String>(Arrays.asList(extension));
+ }
+
+ Set<String> extExcluded = new HashSet<String>(client.getConfig().getOptionAsList(
+ ChoremConfigOption.CHOREM_EXTENSION_SEARCH_EXCLUSION.key).getOption());
+
for (Wikitty w : results) {
for (WikittyExtension ext : w.getExtensions()) {
- if (exts.contains(ext)) {
+ // on ne garde que les extensions demandees et qui ne sont pas exclus sauf si demandee explicitement
+ if ((exts == null && !extExcluded.contains(ext.getName()))
+ || (exts != null && exts.contains(ext.getName()))) {
map.get(ext.getName()).add(w);
}
}
}
-
- List<String> extExcluded = client.getConfig().getOptionAsList(
- ChoremConfigOption.CHOREM_EXTENSION_SEARCH_EXCLUSION.key).getOption();
- for (String ext : extExcluded) {
- map.remove(ext);
- }
if (extension != null) {
for (String ext : extension) {
1
0
15 Sep '12
Author: bpoussin
Date: 2012-09-15 14:38:47 +0200 (Sat, 15 Sep 2012)
New Revision: 269
Url: http://chorem.org/repositories/revision/chorem/269
Log:
les donnes de chorem-topia sont TTC, on les converti en HT
Modified:
trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java
Modified: trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java 2012-09-14 00:02:58 UTC (rev 268)
+++ trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java 2012-09-15 12:38:47 UTC (rev 269)
@@ -524,6 +524,8 @@
}
} else {
Double amount = Double.parseDouble(line[BILL_HEADER.value.ordinal()])/100.0;
+ // on enleve la TVA, sur chorem-topia estelle mettait avec la TVA les factures
+ amount = amount * 100.0 / 119.6;
Date issuedate = parseDate(line[BILL_HEADER.issuedate.ordinal()]);
Date hopedate = parseDate(line[BILL_HEADER.hopedate.ordinal()]);
Date realdate = parseDate(line[BILL_HEADER.realdate.ordinal()]);
1
0
r268 - in trunk/chorem-webmotion/src/main: java/org/chorem/webmotion/actions webapp/WEB-INF/jsp
by bpoussin@users.chorem.org 14 Sep '12
by bpoussin@users.chorem.org 14 Sep '12
14 Sep '12
Author: bpoussin
Date: 2012-09-14 02:02:58 +0200 (Fri, 14 Sep 2012)
New Revision: 268
Url: http://chorem.org/repositories/revision/chorem/268
Log:
ajout d'un dashboard: annual profit
Added:
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardAnnualProfit.jsp
Modified:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/report.jsp
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-13 16:55:55 UTC (rev 267)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-14 00:02:58 UTC (rev 268)
@@ -31,6 +31,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
@@ -143,56 +144,92 @@
//
////////////////////////////////////////////////////////////////////////////
- public Render summary(ChoremClient client) {
- Date now = new Date();
- Date inOneWeek = DateUtils.addDays(now, 7);
- Date firstDayYear = DateUtil.setFirstDayOfYear(now);
- Date lastYearNow = DateUtils.addYears(now, -1);
- Date lastYearFirstDay = DateUtil.setFirstDayOfYear(lastYearNow);
-
- String companyId = client.getConfiguration().getDefaultCompany();
-
+ protected WikittyQuery[] getDebtIncomeQuery(Date first, Date last, String companyId) {
// toutes les depenses depuis le debut de l'annee
- WikittyQuery annualDebtQuery = new WikittyQueryMaker()
+ WikittyQuery debtQuery = new WikittyQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.exteq(Invoice.EXT_INVOICE)
- .bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, firstDayYear, now)
+ .bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, first, last)
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
.select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.end().setLimit(WikittyQuery.MAX);
// toutes les factures emises depuis le debut de l'annee
- WikittyQuery annualIncomeQuery = new WikittyQueryMaker()
+ WikittyQuery incomeQuery = new WikittyQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.exteq(Invoice.EXT_INVOICE)
- .bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, firstDayYear, now)
+ .bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, first, last)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
.select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.end().setLimit(WikittyQuery.MAX);
+
+ WikittyQuery[] result = new WikittyQuery[]{
+ debtQuery, incomeQuery
+ };
+ return result;
+ }
- // toutes les depenses depuis le debut de l'annee
- WikittyQuery lastYearAnnualDebtQuery = new WikittyQueryMaker()
- .select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
- .and()
- .exteq(Invoice.EXT_INVOICE)
- .bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, lastYearFirstDay, lastYearNow)
- .containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
- .end().setLimit(WikittyQuery.MAX);
+ /**
+ * Dashbord qui indique pour toutes les annees du systeme le CA et les depenses
+ * @param client
+ * @return
+ */
+ public Render annualProfit(ChoremClient client) {
+ Map<Date, Double[]> result = new TreeMap<Date, Double[]>();
- // toutes les factures emises depuis le debut de l'annee
- WikittyQuery lastYearAnnualIncomeQuery = new WikittyQueryMaker()
- .select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
- .and()
- .exteq(Invoice.EXT_INVOICE)
- .bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, lastYearFirstDay, lastYearNow)
- .containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
+ String companyId = client.getConfiguration().getDefaultCompany();
+
+ // La premiere annee
+ WikittyQuery firstDateQuery = new WikittyQueryMaker()
+ .select(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, Aggregate.MIN)
+ .exteq(Invoice.EXT_INVOICE)
.end().setLimit(WikittyQuery.MAX);
+ // La derniere annee
+ WikittyQuery lastDateQuery = new WikittyQueryMaker()
+ .select(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, Aggregate.MAX)
+ .exteq(Invoice.EXT_INVOICE)
+ .end().setLimit(WikittyQuery.MAX);
+ Date[] dates = client.findByQuery(Date.class, firstDateQuery, lastDateQuery);
+ Date firstDay = DateUtil.setFirstDayOfYear(dates[0]);
+ Date lastDay = DateUtil.setLastDayOfYear(dates[1]);
+ log.debug(String.format("first date: %s last date: %s", dates[0], dates[1]));
+
+ Date currentFirst = firstDay;
+ Date currentLast = DateUtil.setLastDayOfYear(firstDay);
+ while (currentLast.compareTo(lastDay) <= 0) {
+ WikittyQuery[] annualDebtIncomeQuery =
+ getDebtIncomeQuery(currentFirst, currentLast, companyId);
+ Double[] values = client.findByQuery(Double.class,
+ annualDebtIncomeQuery[0], annualDebtIncomeQuery[1]);
+ result.put(currentFirst, values);
+ currentFirst = DateUtils.addYears(currentFirst, 1);
+ currentLast = DateUtils.addYears(currentLast, 1);
+ }
+ return renderView("dashboardAnnualProfit.jsp", "annualProfit", result);
+ }
+
+ /**
+ * Dashbord pour la page d'accueil
+ * @param client
+ * @return
+ */
+ public Render summary(ChoremClient client) {
+ Date now = new Date();
+ Date inOneWeek = DateUtils.addDays(now, 7);
+ Date firstDayYear = DateUtil.setFirstDayOfYear(now);
+ Date lastYearNow = DateUtils.addYears(now, -1);
+ Date lastYearFirstDay = DateUtil.setFirstDayOfYear(lastYearNow);
+
+ String companyId = client.getConfiguration().getDefaultCompany();
+
+ // toutes les depenses depuis le debut de l'annee
+ WikittyQuery[] annualDebtIncomeQuery = getDebtIncomeQuery(firstDayYear, now, companyId);
+ WikittyQuery[] pastAnnualDebtIncomeQuery = getDebtIncomeQuery(lastYearFirstDay, lastYearNow, companyId);
+
// les factures que notre societe doit payer au plus tard dans 7 jours
WikittyQuery invoiceDebtQuery = new WikittyQueryMaker()
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
@@ -225,8 +262,8 @@
WikittyQueryResult<Double>[] invoices =
client.findAllByQuery(Double.class,
invoiceDebtQuery, invoiceIncomeQuery,
- annualDebtQuery, annualIncomeQuery,
- lastYearAnnualDebtQuery, lastYearAnnualIncomeQuery);
+ annualDebtIncomeQuery[0], annualDebtIncomeQuery[1],
+ pastAnnualDebtIncomeQuery[0], pastAnnualDebtIncomeQuery[1]);
WikittyQueryResult<String> touchs =
client.findAllByQuery(touchQuery);
Copied: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardAnnualProfit.jsp (from rev 263, trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardWorkingProjectDaysByEmployee.jsp)
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardAnnualProfit.jsp (rev 0)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardAnnualProfit.jsp 2012-09-14 00:02:58 UTC (rev 268)
@@ -0,0 +1,46 @@
+<%--
+ #%L
+ Chorem webmotion
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2011 - 2012 CodeLutin
+ %%
+ 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 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/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
+
+<h1>Bénéfice ou perte par année</h1>
+
+<table class="table table-striped table-bordered table-condensed">
+ <tr>
+ <th>Année</th>
+ <th>CA HT</th>
+ <th>CA TTC</th>
+ <th>Dépense</th>
+ <th>Bénéfice/perte</th>
+ </tr>
+ <c:forEach var="q" items="${annualProfit.keySet()}">
+ <tr>
+ <th><f:formatDate pattern="yyyy" value="${q}"/></th>
+ <td><f:formatNumber type="currency" value="${annualProfit.get(q)[1]}"/></td>
+ <td><f:formatNumber type="currency" value="${annualProfit.get(q)[1]*1.196}"/></td>
+ <td><f:formatNumber type="currency" value="${annualProfit.get(q)[0]}"/></td>
+ <td><f:formatNumber type="currency" value="${annualProfit.get(q)[1]*1.196 - annualProfit.get(q)[0]}"/></td>
+ </tr>
+ </c:forEach>
+</table>
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp 2012-09-13 16:55:55 UTC (rev 267)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp 2012-09-14 00:02:58 UTC (rev 268)
@@ -152,6 +152,7 @@
<li><a href="<c:url value="/report?report=invoiceIncome"/>">Income</a></li>
<li><a href="<c:url value="/report?report=profitability"/>">Profitability</a></li>
<li><a href="<c:url value="/report?report=budget"/>">Budget</a></li>
+ <li><a href="<c:url value="/report?report=annualProfit"/>">Annual profit</a></li>
</ul>
</li>
<li class="dropdown nav-group">
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/report.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/report.jsp 2012-09-13 16:55:55 UTC (rev 267)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/report.jsp 2012-09-14 00:02:58 UTC (rev 268)
@@ -55,3 +55,6 @@
<c:if test="${report == null || report == '' || report.contains('budget')}">
<jsp:include page="/fragment/dashboard/budget"/>
</c:if>
+ <c:if test="${report == null || report == '' || report.contains('annualProfit')}">
+ <jsp:include page="/fragment/dashboard/annualProfit"/>
+ </c:if>
1
0
13 Sep '12
Author: bpoussin
Date: 2012-09-13 18:55:55 +0200 (Thu, 13 Sep 2012)
New Revision: 267
Url: http://chorem.org/repositories/revision/chorem/267
Log:
si on ne trouve pas de description on utilise le nom
Modified:
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardInvoice.jsp
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardInvoice.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardInvoice.jsp 2012-09-13 16:27:19 UTC (rev 266)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardInvoice.jsp 2012-09-13 16:55:55 UTC (rev 267)
@@ -47,7 +47,7 @@
<tr>
<td><w:display wikitty="${q.wikitty}" fqfield="Invoiceable.target" label=""/></td>
<td><w:display wikitty="${q.wikitty}" toString="%Invoice.reference|no reference$s" label=""/></td>
- <td><w:display wikitty="${q.wikitty}" toString="%Invoice.description|no description$s" label=""/></td>
+ <td><w:display wikitty="${q.wikitty}" toString="%Invoice.description|Invoiceable.name$s" label=""/></td>
<td><w:display wikitty="${q.wikitty}" fqfield="Invoice.customer" label=""/></td>
<td><w:display wikitty="${q.wikitty}" fqfield="Invoice.supplier" label=""/></td>
<td class="currency"><w:display wikitty="${q.wikitty}" fqfield="Invoice.amount" label=""/></td>
1
0
r266 - in trunk: chorem-entities/src/main/java/org/chorem chorem-webmotion/src/main/java/org/chorem/webmotion/actions chorem-webmotion/src/main/webapp/WEB-INF/jsp
by bpoussin@users.chorem.org 13 Sep '12
by bpoussin@users.chorem.org 13 Sep '12
13 Sep '12
Author: bpoussin
Date: 2012-09-13 18:27:19 +0200 (Thu, 13 Sep 2012)
New Revision: 266
Url: http://chorem.org/repositories/revision/chorem/266
Log:
- prise en compte du supplier/customer qui peuvent etre des companies
- CA en TTC car il y a la TVA dans les depenses (19.6 dans la jsp)
- import cost chorem-topia, tag aussi dans la description
Modified:
trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardInvoice.jsp
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSummary.jsp
Modified: trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java 2012-09-13 10:16:43 UTC (rev 265)
+++ trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java 2012-09-13 16:27:19 UTC (rev 266)
@@ -639,6 +639,7 @@
InvoiceImpl invoice = new InvoiceImpl();
invoice.setName(tag);
+ invoice.setDescription(tag);
invoice.setCategory(categoryNameId.get(category));
invoice.setCustomer(codeLutinId);
invoice.setAmount(amount);
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-13 10:16:43 UTC (rev 265)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-13 16:27:19 UTC (rev 266)
@@ -57,6 +57,7 @@
import org.nuiton.util.DateUtil;
import org.nuiton.wikitty.entities.Element;
import org.nuiton.wikitty.entities.ElementField;
+import org.nuiton.wikitty.entities.WikittyExtension;
import org.nuiton.wikitty.query.WikittyQuery;
import org.nuiton.wikitty.query.WikittyQueryMaker;
import org.nuiton.wikitty.query.WikittyQueryResult;
@@ -169,7 +170,7 @@
.bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, firstDayYear, now)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
.select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
- .end();
+ .end().setLimit(WikittyQuery.MAX);
// toutes les depenses depuis le debut de l'annee
WikittyQuery lastYearAnnualDebtQuery = new WikittyQueryMaker()
@@ -189,7 +190,7 @@
.bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, lastYearFirstDay, lastYearNow)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
.select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
- .end();
+ .end().setLimit(WikittyQuery.MAX);
// les factures que notre societe doit payer au plus tard dans 7 jours
@@ -212,7 +213,7 @@
.isNull(Invoice.FQ_FIELD_INVOICE_PAYMENTDATE)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
.select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
- .end();
+ .end().setLimit(WikittyQuery.MAX);
// les contacts qui doivnet etre pris dans les 7 prochains jours
WikittyQuery touchQuery = new WikittyQueryMaker().and()
@@ -315,7 +316,7 @@
.isNull(Interval.FQ_FIELD_INTERVAL_BEGINDATE)
.isNull(Interval.FQ_FIELD_INTERVAL_ENDDATE)
.isNull(Quotation.FQ_FIELD_QUOTATION_POSTEDDATE)
- .end();
+ .end().setLimit(WikittyQuery.MAX);
WikittyQueryResult<Quotation> result =
client.findAllByQuery(Quotation.class, quotationQuery);
@@ -544,8 +545,14 @@
.isNull(Invoice.FQ_FIELD_INVOICE_POSTEDDATE)
.bw(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start, end)
.bw(Invoice.FQ_FIELD_INVOICE_PAYMENTDATE, start, end)
- .end();
+ .end().setLimit(WikittyQuery.MAX);
+ WikittyExtension ext = client.restoreExtensionLastVersion(Invoice.EXT_INVOICE);
+
+ invoiceQuery.addSortAscending(ext.getSortAscending().toArray(new ElementField[0]));
+ invoiceQuery.addSortDescending(ext.getSortDescending().toArray(new ElementField[0]));
+
+
WikittyQueryResult<Invoice> invoices =
client.findAllByQuery(Invoice.class, invoiceQuery);
@@ -582,7 +589,7 @@
String title = "Factures à payer par la société";
String companyId = client.getConfiguration().getDefaultCompany();
String filter = Invoice.FQ_FIELD_INVOICE_CUSTOMER + "={SELECT id WHERE (" +
- Employee.FQ_FIELD_EMPLOYEE_COMPANY + "=" + companyId+" OR " + companyId + ")}";
+ Employee.FQ_FIELD_EMPLOYEE_COMPANY + "=" + companyId+" OR id=" + companyId + ")}";
return invoiceFilter(client, title, filter, start, end, query);
}
@@ -591,7 +598,7 @@
String title = "Factures émises par la société";
String companyId = client.getConfiguration().getDefaultCompany();
String filter = Invoice.FQ_FIELD_INVOICE_SUPPLIER + "={SELECT id WHERE (" +
- Employee.FQ_FIELD_EMPLOYEE_COMPANY + "=" + companyId+" OR " + companyId + ")}";
+ Employee.FQ_FIELD_EMPLOYEE_COMPANY + "=" + companyId+" OR id=" + companyId + ")}";
return invoiceFilter(client, title, filter, start, end, query);
}
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardInvoice.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardInvoice.jsp 2012-09-13 10:16:43 UTC (rev 265)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardInvoice.jsp 2012-09-13 16:27:19 UTC (rev 266)
@@ -46,8 +46,8 @@
<tbody>
<tr>
<td><w:display wikitty="${q.wikitty}" fqfield="Invoiceable.target" label=""/></td>
- <td><w:display wikitty="${q.wikitty}" toString="%Invoice.reference$s" label=""/></td>
- <td><w:display wikitty="${q.wikitty}" fqfield="Invoice.description" label=""/></td>
+ <td><w:display wikitty="${q.wikitty}" toString="%Invoice.reference|no reference$s" label=""/></td>
+ <td><w:display wikitty="${q.wikitty}" toString="%Invoice.description|no description$s" label=""/></td>
<td><w:display wikitty="${q.wikitty}" fqfield="Invoice.customer" label=""/></td>
<td><w:display wikitty="${q.wikitty}" fqfield="Invoice.supplier" label=""/></td>
<td class="currency"><w:display wikitty="${q.wikitty}" fqfield="Invoice.amount" label=""/></td>
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSummary.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSummary.jsp 2012-09-13 10:16:43 UTC (rev 265)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSummary.jsp 2012-09-13 16:27:19 UTC (rev 266)
@@ -49,9 +49,9 @@
</ul>
<ul>
- <li>Chiffre d'affaire: <strong><f:formatNumber type="currency" value="${annualIncome}"/></strong> (N-1: <strong><f:formatNumber type="currency" value="${lastYearAnnualIncome}"/></strong>)
+ <li>Chiffre d'affaire TTC: <strong><f:formatNumber type="currency" value="${annualIncome*1.196}"/></strong> (N-1: <strong><f:formatNumber type="currency" value="${lastYearAnnualIncome*1.196}"/></strong>)
<li>Dépenses: <strong><f:formatNumber type="currency" value="${annualDebt}"/></strong> (N-1: <strong><f:formatNumber type="currency" value="${lastYearAnnualDebt}"/></strong>)
- <li>Bénéfice/perte: <strong><f:formatNumber type="currency" value="${annualIncome-annualDebt}"/></strong> (N-1: <strong><f:formatNumber type="currency" value="${lastYearAnnualIncome-lastYearAnnualDebt}"/></strong>)
+ <li>Bénéfice/perte: <strong><f:formatNumber type="currency" value="${annualIncome*1.196-annualDebt}"/></strong> (N-1: <strong><f:formatNumber type="currency" value="${lastYearAnnualIncome*1.196-lastYearAnnualDebt}"/></strong>)
</ul>
</div>
</div>
1
0
r265 - trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions
by bpoussin@users.chorem.org 13 Sep '12
by bpoussin@users.chorem.org 13 Sep '12
13 Sep '12
Author: bpoussin
Date: 2012-09-13 12:16:43 +0200 (Thu, 13 Sep 2012)
New Revision: 265
Url: http://chorem.org/repositories/revision/chorem/265
Log:
- reprise du dashboard summary pour prendre en compte les changements sur invoices (supplier/customer)
Modified:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-13 10:09:57 UTC (rev 264)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-13 10:16:43 UTC (rev 265)
@@ -158,7 +158,7 @@
.exteq(Invoice.EXT_INVOICE)
.bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, firstDayYear, now)
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.end().setLimit(WikittyQuery.MAX);
// toutes les factures emises depuis le debut de l'annee
@@ -168,7 +168,7 @@
.exteq(Invoice.EXT_INVOICE)
.bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, firstDayYear, now)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.end();
// toutes les depenses depuis le debut de l'annee
@@ -178,7 +178,7 @@
.exteq(Invoice.EXT_INVOICE)
.bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, lastYearFirstDay, lastYearNow)
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.end().setLimit(WikittyQuery.MAX);
// toutes les factures emises depuis le debut de l'annee
@@ -188,7 +188,7 @@
.exteq(Invoice.EXT_INVOICE)
.bw(Invoice.FQ_FIELD_INVOICE_POSTEDDATE, lastYearFirstDay, lastYearNow)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.end();
@@ -200,7 +200,7 @@
.lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, inOneWeek)
.isNull(Invoice.FQ_FIELD_INVOICE_PAYMENTDATE)
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.end().setLimit(WikittyQuery.MAX);
// les factures qu'auraient du payer nos clients (ils sont en retard)
@@ -211,7 +211,7 @@
.lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, now)
.isNull(Invoice.FQ_FIELD_INVOICE_PAYMENTDATE)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.end();
// les contacts qui doivnet etre pris dans les 7 prochains jours
1
0
r264 - in trunk: chorem-entities/src/main/java/org/chorem chorem-entities/src/main/xmi chorem-webmotion/src/main/java/org/chorem/webmotion/actions
by bpoussin@users.chorem.org 13 Sep '12
by bpoussin@users.chorem.org 13 Sep '12
13 Sep '12
Author: bpoussin
Date: 2012-09-13 12:09:57 +0200 (Thu, 13 Sep 2012)
New Revision: 264
Url: http://chorem.org/repositories/revision/chorem/264
Log:
- une facture peut avoir comme supplier/customer: Company, Employee ou Person
- ajout de l'import des factures et cout depuis chorem-topia
Modified:
trunk/chorem-entities/src/main/java/org/chorem/ChoremAction.java
trunk/chorem-entities/src/main/java/org/chorem/ChoremConfigAction.java
trunk/chorem-entities/src/main/java/org/chorem/ChoremMain.java
trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java
trunk/chorem-entities/src/main/xmi/chorem-model.properties
trunk/chorem-entities/src/main/xmi/chorem-model.zargo
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
Modified: trunk/chorem-entities/src/main/java/org/chorem/ChoremAction.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ChoremAction.java 2012-09-10 06:43:45 UTC (rev 263)
+++ trunk/chorem-entities/src/main/java/org/chorem/ChoremAction.java 2012-09-13 10:09:57 UTC (rev 264)
@@ -25,6 +25,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.ApplicationConfig;
+import org.nuiton.wikitty.query.WikittyQuery;
+import org.nuiton.wikitty.query.WikittyQueryMaker;
+import org.nuiton.wikitty.query.WikittyQueryResult;
/**
*
@@ -46,15 +49,42 @@
}
/**
- * Remove all data in database, used with caution
+ * Vide les objets qui porte une certaine extensions
+ * @param extensionName
*/
- public void clean() {
- System.out.println("Cleaning database ...");
+ @ApplicationConfig.Action.Step(0)
+ public void clean(String extensionName) {
+ System.out.println("##### EFFACEMENT: " + extensionName + " #####");
ChoremClient proxy = ChoremClient.getClient(config);
- proxy.clear();
+ WikittyQuery q = new WikittyQueryMaker().exteq(extensionName)
+ .end().setLimit(WikittyQuery.MAX);
+ WikittyQueryResult<String> result = proxy.findAllByQuery(q);
+ proxy.delete(result.getAll());
System.out.println("... clean done");
}
+ /**
+ * Vide tous les objets
+ */
+ @ApplicationConfig.Action.Step(0)
+ public void clear() {
+ System.out.println("##### EFFACEMENT TOTAL DES DONNEES #####");
+ ChoremClient proxy = ChoremClient.getClient(config);
+ proxy.clear();
+ System.out.println("... clear done");
+ }
+
+ /**
+ * Reindex les donnees existantes
+ */
+ @ApplicationConfig.Action.Step(0)
+ public void reindex() {
+ System.out.println("##### REINDEXATION #####");
+ ChoremClient proxy = ChoremClient.getClient(config);
+ proxy.syncSearchEngine();
+ System.out.println("... reindexation done");
+ }
+
public void configInfo() {
config.printConfig();
}
Modified: trunk/chorem-entities/src/main/java/org/chorem/ChoremConfigAction.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ChoremConfigAction.java 2012-09-10 06:43:45 UTC (rev 263)
+++ trunk/chorem-entities/src/main/java/org/chorem/ChoremConfigAction.java 2012-09-13 10:09:57 UTC (rev 264)
@@ -37,6 +37,8 @@
HELP(ChoremAction.class.getName() + "#help", "-h", "--help"),
INFO(ChoremAction.class.getName() + "#configInfo", "-i", "--config-info" , "--configInfo"),
CLEAN(ChoremAction.class.getName() + "#clean", "--clean"),
+ CLEAR(ChoremAction.class.getName() + "#clear", "--clear"),
+ REINDEX(ChoremAction.class.getName() + "#reindex", "--reindex"),
IMPORT_PERSON(ImportChoremTopia.class.getName() + "#importPerson",
"-ip", "--import-person", "--importPerson"),
IMPORT_COMPANY(ImportChoremTopia.class.getName() + "#importCompany",
@@ -47,6 +49,10 @@
"--import-contract", "--importContract"),
IMPORT_CONTRACT_TYPE(ImportChoremTopia.class.getName() + "#importContractType",
"--import-contract-type", "--importContractType"),
+ IMPORT_INVOICE(ImportChoremTopia.class.getName() + "#importInvoices",
+ "-ii", "--import-invoices", "--importInvoices"),
+ IMPORT_COST(ImportChoremTopia.class.getName() + "#importCosts",
+ "--import-costs", "--importCosts"),
IMPORT_COMMIT(ImportChoremTopia.class.getName() + "#commit", "--commit");
public String action;
Modified: trunk/chorem-entities/src/main/java/org/chorem/ChoremMain.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ChoremMain.java 2012-09-10 06:43:45 UTC (rev 263)
+++ trunk/chorem-entities/src/main/java/org/chorem/ChoremMain.java 2012-09-13 10:09:57 UTC (rev 264)
@@ -41,9 +41,11 @@
static private Log log = LogFactory.getLog(ChoremMain.class);
static public void main(String[] args) throws Exception {
+// args = "--clear -ic /tmp/chorem-company.csv -ip /tmp/chorem-person.csv -ie /tmp/chorem-employee.csv --import-contract-type /tmp/chorem-contracttype.csv --import-contract /tmp/chorem-contract.csv --commit".split(" ");
+// args = "-ii /tmp/bill.csv --import-costs /tmp/cost.csv --commit".split(" ");
+ args = "--reindex".split(" ");
System.out.println(String.format("Launching ChoremMain ... (args: %s)", Arrays.toString(args)));
// getConfig do all: parse and doAllAction
-// String[] forceArgs = "--clean -ic /tmp/chorem-company.csv -ip /tmp/chorem-person.csv -ie /tmp/chorem-employee.csv --import-contract-type /tmp/chorem-contracttype.csv --import-contract /tmp/chorem-contract.csv --commit".split(" ");
ApplicationConfig config = ChoremConfig.getConfig(null, args);
System.exit(0);
Modified: trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java 2012-09-10 06:43:45 UTC (rev 263)
+++ trunk/chorem-entities/src/main/java/org/chorem/ImportChoremTopia.java 2012-09-13 10:09:57 UTC (rev 264)
@@ -27,20 +27,32 @@
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.entities.Category;
+import org.chorem.entities.CategoryImpl;
+import org.chorem.entities.Company;
import org.chorem.entities.CompanyImpl;
import org.chorem.entities.ContactDetailsImpl;
+import org.chorem.entities.Employee;
import org.chorem.entities.EmployeeImpl;
+import org.chorem.entities.Invoice;
import org.chorem.entities.InvoiceImpl;
+import org.chorem.entities.Person;
import org.chorem.entities.PersonImpl;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ApplicationConfig.Action.Step;
import org.nuiton.wikitty.entities.BusinessEntityImpl;
+import org.nuiton.wikitty.query.WikittyQuery;
+import org.nuiton.wikitty.query.WikittyQueryMaker;
+import org.nuiton.wikitty.query.WikittyQueryResult;
/**
* Les donnees doivent etre exportees de la base postgresql avec les commandes:
@@ -53,6 +65,7 @@
*
* pour bill
* \copy (SELECT subcategory.name AS category, number, issuedate, hopedate, realdate, value, company.name AS company from bill LEFT OUTER JOIN subcategory ON bill.subcategory=subcategory.topiaid LEFT OUTER JOIN task ON bill.task=task.topiaid LEFT OUTER JOIN contact ON bill.contact=contact.topiaid LEFT OUTER JOIN company ON contact.company=company.topiaid order by company.name) TO '/tmp/bill.csv' delimiter ';' CSV HEADER
+ * \copy (SELECT date,subcategory.name AS category,tag,value from tagvalue LEFT OUTER JOIN subcategory ON tagvalue.subcategory=subcategory.topiaid) TO '/tmp/cost.csv' delimiter ';' CSV HEADER
* </pre>
*
* @author poussin
@@ -99,11 +112,17 @@
category,number,issuedate,hopedate,realdate,value,company
}
+ enum COST_HEADER {
+ date,category,tag,value
+ }
+
protected List<ContactDetailsImpl> contacts = new LinkedList<ContactDetailsImpl>();
protected Map<String, CompanyImpl> companies = new HashMap<String, CompanyImpl>();
protected Map<String, PersonImpl> persons = new HashMap<String, PersonImpl>();
protected Map<String, EmployeeImpl> employees = new HashMap<String, EmployeeImpl>();
protected Map<String, InvoiceImpl> invoices = new HashMap<String, InvoiceImpl>();
+ protected Map<String, InvoiceImpl> costs = new HashMap<String, InvoiceImpl>();
+ protected Map<String, CategoryImpl> categories = new HashMap<String, CategoryImpl>();
// a ne pas stocker dans wikitty
protected Map<String, String> contractType = new HashMap<String, String>();
@@ -149,11 +168,14 @@
@Step(99)
public void commit() {
List<BusinessEntityImpl> data = new LinkedList<BusinessEntityImpl>();
-
+
+ data.addAll(categories.values());
data.addAll(companies.values());
data.addAll(persons.values());
data.addAll(employees.values());
data.addAll(contacts);
+ data.addAll(invoices.values());
+ data.addAll(costs.values());
ChoremClient proxy = ChoremClient.getClient(config);
data = proxy.store(data);
@@ -429,4 +451,230 @@
System.out.println(String.format("%s contracts loaded", count));
}
+ @Step(4)
+ public void importInvoices(String filename) {
+ System.out.println(String.format("Try to import invoices '%s'", filename));
+ try {
+ ChoremClient proxy = ChoremClient.getClient(config);
+
+ // Pour les invoices existantes
+ WikittyQuery invoicesQuery = new WikittyQueryMaker()
+ .exteq(Invoice.EXT_INVOICE).end().setLimit(WikittyQuery.MAX);
+ WikittyQueryResult<Invoice> invoicesResult =
+ proxy.findAllByQuery(Invoice.class, invoicesQuery);
+ Set<String> knowInvoices = new HashSet<String>();
+ Set<String> passedInvoices = new HashSet<String>();
+ Set<String> rejectedInvoices = new HashSet<String>();
+ Set<String> treatedInvoices = new HashSet<String>();
+ for (Invoice c : invoicesResult) {
+ knowInvoices.add(c.getReference());
+ }
+
+ // Pour les categories
+ WikittyQuery categoryQuery = new WikittyQueryMaker()
+ .exteq(Category.EXT_CATEGORY).end().setLimit(WikittyQuery.MAX);
+ WikittyQueryResult<Category> categoryResult =
+ proxy.findAllByQuery(Category.class, categoryQuery);
+ // key: category name; value: id
+ Map<String, String> categories = new HashMap<String, String>();
+ Set<String> unknowCategories = new HashSet<String>();
+ for (Category c : categoryResult) {
+ categories.put(c.getName(), c.getWikittyId());
+ }
+
+ // Pour les customer
+ WikittyQuery customerQuery = new WikittyQueryMaker()
+ .exteq(Company.EXT_COMPANY)
+ .end().setLimit(WikittyQuery.MAX);
+ WikittyQueryResult<Company> customerResult =
+ proxy.findAllByQuery(Company.class, customerQuery);
+ // key: name; value: id
+ Map<String, String> customers = new HashMap<String, String>();
+ Set<String> unknowCustomers = new HashSet<String>();
+ for (Company c : customerResult) {
+ customers.put(c.getName(), c.getWikittyId());
+ }
+
+ // Pour les supplier
+ WikittyQuery supplierQuery = new WikittyQueryMaker()
+ .eq(Company.FQ_FIELD_COMPANY_NAME, "Code Lutin").end();
+ String codeLutinId = proxy.findByQuery(supplierQuery);
+
+ FileReader in = new FileReader(filename);
+ // separateur ';' String delimiter '"', skip first line (header)
+ CSVReader reader = new CSVReader(in, ';', '"', 1);
+ for(String[] line : reader.readAll()) {
+ String number = line[BILL_HEADER.number.ordinal()];
+ if (knowInvoices.contains(number)) {
+ passedInvoices.add(number);
+ } else {
+ String category = line[BILL_HEADER.category.ordinal()];
+ String company = line[BILL_HEADER.company.ordinal()];
+ if (codeLutinId == null
+ || !categories.containsKey(category)
+ || !customers.containsKey(company)) {
+ rejectedInvoices.add(number);
+ // check des infos
+ if (!categories.containsKey(category)) {
+ unknowCategories.add(category);
+ }
+
+ if (!customers.containsKey(company)) {
+ unknowCustomers.add(company);
+ }
+ } else {
+ Double amount = Double.parseDouble(line[BILL_HEADER.value.ordinal()])/100.0;
+ Date issuedate = parseDate(line[BILL_HEADER.issuedate.ordinal()]);
+ Date hopedate = parseDate(line[BILL_HEADER.hopedate.ordinal()]);
+ Date realdate = parseDate(line[BILL_HEADER.realdate.ordinal()]);
+
+ InvoiceImpl invoice = new InvoiceImpl();
+ invoice.setCategory(categories.get(category));
+ invoice.setSupplier(codeLutinId);
+ invoice.setCustomer(company);
+ invoice.setReference(number);
+ invoice.setAmount(amount);
+ invoice.setPostedDate(issuedate);
+ invoice.setExpectedDate(hopedate);
+ invoice.setPaymentDate(realdate);
+
+ invoices.put(invoice.getWikittyId(), invoice);
+ treatedInvoices.add(number);
+ }
+ }
+ }
+
+ reader.close();
+
+ System.out.println("Invoices deja importee: " + passedInvoices);
+ System.out.println("Invoices a importee: " + treatedInvoices);
+ if (codeLutinId == null || !unknowCategories.isEmpty() || !unknowCustomers.isEmpty()) {
+ System.out.println("-- Erreur d'import --");
+ System.out.println("Invoices rejetees: " + rejectedInvoices);
+ System.out.println("Code Lutin id: " + codeLutinId);
+ System.out.println("Categorie manquante: " + unknowCategories);
+ System.out.println("Company manquante: " + unknowCustomers);
+ }
+ } catch (Exception eee) {
+ log.fatal(String.format("Can't import file '%s'", filename));
+ if (log.isDebugEnabled()) {
+ log.debug("StackTrace", eee);
+ }
+ System.exit(1);
+ }
+ System.out.println(String.format("%s invoices loaded", invoices.size()));
+ }
+
+ protected String invoiceToKey(Invoice c) {
+ String result = c.getCategory() + ";" + c.getPaymentDate() + ";" + c.getName() + ";" + c.getAmount();
+ return result;
+ }
+
+ @Step(5)
+ public void importCosts(String filename) {
+ System.out.println(String.format("Try to import cost '%s'", filename));
+ try {
+ ChoremClient proxy = ChoremClient.getClient(config);
+
+ // Pour les invoices existantes
+ WikittyQuery invoicesQuery = new WikittyQueryMaker()
+ .exteq(Invoice.EXT_INVOICE).end().setLimit(WikittyQuery.MAX);
+ WikittyQueryResult<Invoice> invoicesResult =
+ proxy.findAllByQuery(Invoice.class, invoicesQuery);
+ Set<String> knowInvoices = new HashSet<String>();
+ Set<String> passedInvoices = new HashSet<String>();
+ Set<String> rejectedInvoices = new HashSet<String>();
+ Set<String> treatedInvoices = new HashSet<String>();
+ for (Invoice c : invoicesResult) {
+ // on fait une concatenation pour optimiser les futurs recherche
+ knowInvoices.add(invoiceToKey(c));
+ }
+
+ // Pour les categories
+ WikittyQuery categoryQuery = new WikittyQueryMaker()
+ .exteq(Category.EXT_CATEGORY).end().setLimit(WikittyQuery.MAX);
+ WikittyQueryResult<Category> categoryResult =
+ proxy.findAllByQuery(Category.class, categoryQuery);
+ // key: category name; value: id
+ Map<String, String> categoryNameId = new HashMap<String, String>();
+ Set<String> unknowCategories = new HashSet<String>();
+ for (Category c : categoryResult) {
+ categoryNameId.put(c.getName(), c.getWikittyId());
+ }
+
+ // le customer est code lutin
+ WikittyQuery customerQuery = new WikittyQueryMaker()
+ .eq(Company.FQ_FIELD_COMPANY_NAME, "Code Lutin").end();
+ String codeLutinId = proxy.findByQuery(customerQuery);
+
+ // la category par defaut ou creer les manquantes
+ WikittyQuery fraisQuery = new WikittyQueryMaker()
+ .eq(Category.FQ_FIELD_WIKITTYTREENODE_NAME, "Frais").end();
+ String frais = proxy.findByQuery(fraisQuery);
+ if (frais == null) {
+ CategoryImpl c = new CategoryImpl();
+ c.setName("Frais");
+ categories.put(c.getWikittyId(), c);
+ categoryNameId.put(c.getName(), c.getWikittyId());
+ frais = c.getWikittyId();
+ }
+
+ FileReader in = new FileReader(filename);
+ // separateur ';' String delimiter '"', skip first line (header)
+ CSVReader reader = new CSVReader(in, ';', '"', 1);
+ for(String[] line : reader.readAll()) {
+ String tag = line[COST_HEADER.tag.ordinal()];
+ String category = line[COST_HEADER.category.ordinal()];
+ Date date = parseDate(line[COST_HEADER.date.ordinal()]);
+ Double amount = Double.parseDouble(line[COST_HEADER.value.ordinal()])/100.0;
+
+ if (StringUtils.isNotBlank(category) && !categoryNameId.containsKey(category)) {
+ CategoryImpl c = new CategoryImpl();
+ c.setName(category);
+ c.setParent(frais);
+ categories.put(c.getWikittyId(), c);
+ categoryNameId.put(c.getName(), c.getWikittyId());
+ unknowCategories.add(category);
+ }
+
+ InvoiceImpl invoice = new InvoiceImpl();
+ invoice.setName(tag);
+ invoice.setCategory(categoryNameId.get(category));
+ invoice.setCustomer(codeLutinId);
+ invoice.setAmount(amount);
+ invoice.setPostedDate(date);
+ invoice.setExpectedDate(date);
+ invoice.setPaymentDate(date);
+
+ String invoiceKey = invoiceToKey(invoice);
+ if (knowInvoices.contains(invoiceKey)) {
+ passedInvoices.add(invoiceKey);
+ } else if (codeLutinId == null || date == null || StringUtils.isBlank(category)) {
+ rejectedInvoices.add(invoiceKey);
+ } else {
+ costs.put(invoice.getWikittyId(), invoice);
+ treatedInvoices.add(invoiceKey);
+ }
+ }
+
+ reader.close();
+
+ System.out.println("Cost deja importee: " + passedInvoices);
+ System.out.println("Cost a importee: " + treatedInvoices);
+ System.out.println("Category creee: " + unknowCategories);
+ if (codeLutinId == null || !rejectedInvoices.isEmpty()) {
+ System.out.println("-- Erreur d'import costs--");
+ System.out.println("Cost rejetees: " + rejectedInvoices);
+ System.out.println("Code Lutin id: " + codeLutinId);
+ }
+ } catch (Exception eee) {
+ log.fatal(String.format("Can't import file '%s'", filename));
+ if (log.isDebugEnabled()) {
+ log.debug("StackTrace", eee);
+ }
+ System.exit(1);
+ }
+ System.out.println(String.format("%s costs loaded", costs.size()));
+ }
+
}
Modified: trunk/chorem-entities/src/main/xmi/chorem-model.properties
===================================================================
--- trunk/chorem-entities/src/main/xmi/chorem-model.properties 2012-09-10 06:43:45 UTC (rev 263)
+++ trunk/chorem-entities/src/main/xmi/chorem-model.properties 2012-09-13 10:09:57 UTC (rev 264)
@@ -109,7 +109,9 @@
org.chorem.entities.Invoice.attribute.expectedDate.tagvalue.help=La date souhait\u00e9e de paiement
org.chorem.entities.Invoice.attribute.paymentDate.tagvalue.help=La date de paiement r\u00e9elle
org.chorem.entities.Invoice.attribute.supplier.tagvalue.help=La personne chez Code Lutin qui g\u00e8re la facturation
+org.chorem.entities.Invoice.attribute.parent.tagvalue.allowed=Company,Person,Employee
org.chorem.entities.Invoice.attribute.customer.tagvalue.help=La personne chez le client \u00e0 qui ont a envoyer la facture
+org.chorem.entities.Invoice.attribute.parent.tagvalue.allowed=Company,Person,Employee
#
# Invoiceable
#
Modified: trunk/chorem-entities/src/main/xmi/chorem-model.zargo
===================================================================
(Binary files differ)
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-10 06:43:45 UTC (rev 263)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-09-13 10:09:57 UTC (rev 264)
@@ -582,7 +582,7 @@
String title = "Factures à payer par la société";
String companyId = client.getConfiguration().getDefaultCompany();
String filter = Invoice.FQ_FIELD_INVOICE_CUSTOMER + "={SELECT id WHERE (" +
- Employee.FQ_FIELD_EMPLOYEE_COMPANY + "=" + companyId+")}";
+ Employee.FQ_FIELD_EMPLOYEE_COMPANY + "=" + companyId+" OR " + companyId + ")}";
return invoiceFilter(client, title, filter, start, end, query);
}
@@ -591,7 +591,7 @@
String title = "Factures émises par la société";
String companyId = client.getConfiguration().getDefaultCompany();
String filter = Invoice.FQ_FIELD_INVOICE_SUPPLIER + "={SELECT id WHERE (" +
- Employee.FQ_FIELD_EMPLOYEE_COMPANY + "=" + companyId+")}";
+ Employee.FQ_FIELD_EMPLOYEE_COMPANY + "=" + companyId+" OR " + companyId + ")}";
return invoiceFilter(client, title, filter, start, end, query);
}
@@ -636,7 +636,7 @@
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.close()
.lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start)
.end()
@@ -647,7 +647,7 @@
.select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
.and()
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.close()
.lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start)
.end()
@@ -657,7 +657,7 @@
WikittyQuery invoiceDebt = new WikittyQueryMaker().and()
.parse(query)
.containsOne(Invoice.FQ_FIELD_INVOICE_CUSTOMER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.close()
.bw(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start, end)
.end()
@@ -667,7 +667,7 @@
WikittyQuery invoiceIncome = new WikittyQueryMaker().and()
.parse(query)
.containsOne(Invoice.FQ_FIELD_INVOICE_SUPPLIER)
- .select(Element.ID).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId)
+ .select(Element.ID).or().ideq(companyId).eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).close()
.close()
.bw(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start, end)
.end()
@@ -787,7 +787,7 @@
Date d = getDate(invoice);
String date = DateFormatUtils.format(d, budgetDateFormat);
- Category c = invoice.getCategory(true);
+ Category c = invoice.getCategory(false);
double amount = invoice.getAmount();
addAmount(date, c, amount);
1
0
r263 - in trunk: . chorem-webmotion/src/main/java/org/chorem/webmotion/actions
by bpoussin@users.chorem.org 10 Sep '12
by bpoussin@users.chorem.org 10 Sep '12
10 Sep '12
Author: bpoussin
Date: 2012-09-10 08:43:45 +0200 (Mon, 10 Sep 2012)
New Revision: 263
Url: http://chorem.org/repositories/revision/chorem/263
Log:
l'utilisateur peut indiquer dans son filtre la plage des resultats
souhait?\195?\169s
Modified:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
trunk/pom.xml
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-08-25 08:53:18 UTC (rev 262)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-09-10 06:43:45 UTC (rev 263)
@@ -61,6 +61,7 @@
import org.nuiton.wikitty.query.WikittyQueryMaker;
import org.nuiton.wikitty.query.WikittyQueryParser;
import org.nuiton.wikitty.query.WikittyQueryResult;
+import org.nuiton.wikitty.query.conditions.True;
/**
*
@@ -155,20 +156,36 @@
depth = 0;
}
- WikittyQuery q;
+ WikittyQueryMaker maker;
+ // S'il y a des extensions on force la requete sur ces types d'extension
if (extension != null) {
- q = new WikittyQueryMaker().and()
- .extContainsOne(Arrays.asList(extension))
- .parse(query)
- .end();
+ maker = new WikittyQueryMaker().and()
+ .extContainsOne(Arrays.asList(extension));
} else {
- q = new WikittyQueryMaker()
- .parse(query)
- .end();
+ maker = new WikittyQueryMaker();
}
+
+ // s'il y a un filtre on l'utilise, et on utilisera aussi #offset et #limit
+ // de ce filtre s'ils sont positionne
+ WikittyQuery filter = WikittyQueryParser.parse(query);
+ if (filter != null) { // filter peut-etre null si la requete a une mauvaise syntaxe
+ maker.condition(filter.getCondition());
+ // si l'utilisateur a force le depth dans son filtre on l'utilise
+ if (StringUtils.containsIgnoreCase(query, WikittyQueryParser.DEPTH)) {
+ depth = filter.getWikittyFieldSearchDepth();
+ }
+ }
+
+ // on recupere la requete
+ WikittyQuery q = maker.end();
+
q.setWikittyFieldSearchDepth(depth);
-
+ if (filter != null) {
+ q.setOffset(filter.getOffset());
+ q.setLimit(filter.getLimit());
+ }
+
// on essai de trier les resultats au mieux tout en ne faisant qu'un requete
Collection<WikittyExtension> exts = client.restoreExtensionLastVersion(extension);
for (WikittyExtension ext : exts) {
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-25 08:53:18 UTC (rev 262)
+++ trunk/pom.xml 2012-09-10 06:43:45 UTC (rev 263)
@@ -98,7 +98,7 @@
<nuitonUtilsVersion>2.4.8</nuitonUtilsVersion>
<nuitonWebVersion>1.7</nuitonWebVersion>
<nuitonI18nVersion>2.3.1</nuitonI18nVersion>
- <wikittyVersion>3.8</wikittyVersion>
+ <wikittyVersion>3.9-SNAPSHOT</wikittyVersion>
<slf4jVersion>1.6.1</slf4jVersion>
<struts2Version>2.2.3</struts2Version>
<struts2jqueryVersion>3.2.0</struts2jqueryVersion>
1
0