144 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.core.sales.invoice.report;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
|
|
|
17 |
import org.openconcerto.erp.preferences.PrinterNXProps;
|
|
|
18 |
import org.openconcerto.sql.Configuration;
|
|
|
19 |
import org.openconcerto.sql.element.SQLElement;
|
156 |
ilm |
20 |
import org.openconcerto.sql.model.AliasedTable;
|
144 |
ilm |
21 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
22 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
|
|
23 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
24 |
import org.openconcerto.sql.model.SQLSelectJoin;
|
|
|
25 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
26 |
import org.openconcerto.sql.model.Where;
|
|
|
27 |
|
|
|
28 |
import java.math.BigDecimal;
|
|
|
29 |
import java.text.DateFormat;
|
|
|
30 |
import java.text.SimpleDateFormat;
|
|
|
31 |
import java.util.ArrayList;
|
|
|
32 |
import java.util.Collections;
|
|
|
33 |
import java.util.Comparator;
|
|
|
34 |
import java.util.Date;
|
|
|
35 |
import java.util.HashMap;
|
|
|
36 |
import java.util.List;
|
|
|
37 |
import java.util.Map;
|
|
|
38 |
import java.util.Map.Entry;
|
|
|
39 |
import java.util.TreeMap;
|
|
|
40 |
|
|
|
41 |
import javax.swing.JProgressBar;
|
|
|
42 |
|
|
|
43 |
public class ReportingVenteXmlSheet extends AbstractListeSheetXml {
|
|
|
44 |
|
|
|
45 |
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
|
|
|
46 |
|
|
|
47 |
public static final String TEMPLATE_ID = "ReportingVentes";
|
|
|
48 |
public static final String TEMPLATE_PROPERTY_NAME = DEFAULT_PROPERTY_NAME;
|
|
|
49 |
|
|
|
50 |
private Date du, au;
|
|
|
51 |
private Date date;
|
|
|
52 |
private JProgressBar bar;
|
|
|
53 |
|
|
|
54 |
private SQLElement eltFact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
|
|
55 |
private SQLElement eltFactItem = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
|
|
|
56 |
private List<Integer> idS;
|
|
|
57 |
|
|
|
58 |
public ReportingVenteXmlSheet(List<Integer> idS, Date du, Date au, JProgressBar bar, boolean commande) {
|
|
|
59 |
super();
|
|
|
60 |
eltFact = Configuration.getInstance().getDirectory().getElement(commande ? "COMMANDE_CLIENT" : "SAISIE_VENTE_FACTURE");
|
|
|
61 |
eltFactItem = Configuration.getInstance().getDirectory().getElement(commande ? "COMMANDE_CLIENT_ELEMENT" : "SAISIE_VENTE_FACTURE_ELEMENT");
|
|
|
62 |
|
|
|
63 |
this.printer = PrinterNXProps.getInstance().getStringProperty("BonPrinter");
|
|
|
64 |
this.du = du;
|
|
|
65 |
this.au = au;
|
|
|
66 |
this.bar = bar;
|
|
|
67 |
this.idS = idS;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
@Override
|
|
|
71 |
public String getStoragePathP() {
|
|
|
72 |
return "Autres";
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
@Override
|
|
|
76 |
public String getDefaultTemplateId() {
|
|
|
77 |
return TEMPLATE_ID;
|
|
|
78 |
};
|
|
|
79 |
|
|
|
80 |
@Override
|
|
|
81 |
public String getName() {
|
|
|
82 |
if (this.date == null) {
|
|
|
83 |
this.date = new Date();
|
|
|
84 |
}
|
|
|
85 |
return "ReportingVentes" + this.date.getTime();
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
protected void createListeValues() {
|
|
|
89 |
|
|
|
90 |
SQLSelect sel = new SQLSelect();
|
|
|
91 |
final SQLTable tableItemFact = eltFactItem.getTable();
|
156 |
ilm |
92 |
AliasedTable tableAlias = new AliasedTable(tableItemFact, "eltTable");
|
|
|
93 |
sel.addRawSelect("SUM(\"eltTable\".\"QTE\"*\"eltTable\".\"QTE_UNITAIRE\")", "q");
|
|
|
94 |
sel.addSelect(tableAlias.getField("T_PA_HT"), "SUM");
|
|
|
95 |
sel.addSelect(tableAlias.getField("T_PV_HT"), "SUM");
|
|
|
96 |
sel.addSelect(tableAlias.getField("T_PV_TTC"), "SUM");
|
144 |
ilm |
97 |
final SQLTable tableArt = eltFactItem.getForeignElement("ID_ARTICLE").getTable();
|
156 |
ilm |
98 |
sel.addSelect(tableAlias.getField("ID_ARTICLE"));
|
144 |
ilm |
99 |
|
156 |
ilm |
100 |
final SQLSelectJoin joinFact = sel.addJoin("LEFT", tableAlias.getField("ID_" + eltFact.getTable().getName()));
|
144 |
ilm |
101 |
|
156 |
ilm |
102 |
Where wA = new Where(tableArt.getKey(), "=", tableAlias.getField("ID_ARTICLE"));
|
144 |
ilm |
103 |
Where w = new Where(joinFact.getJoinedTable().getField("DATE"), this.du, this.au);
|
|
|
104 |
|
|
|
105 |
if (idS != null && idS.size() > 0) {
|
|
|
106 |
sel.addSelect(joinFact.getJoinedTable().getField("ID_COMMERCIAL"));
|
|
|
107 |
sel.addGroupBy(joinFact.getJoinedTable().getField("ID_COMMERCIAL"));
|
|
|
108 |
|
|
|
109 |
w = w.and(new Where(joinFact.getJoinedTable().getField("ID_COMMERCIAL"), idS));
|
|
|
110 |
}
|
|
|
111 |
sel.setWhere(wA.and(w));
|
|
|
112 |
|
156 |
ilm |
113 |
sel.addGroupBy(tableAlias.getField("ID_ARTICLE"));
|
144 |
ilm |
114 |
|
|
|
115 |
List<Object[]> result = eltFact.getTable().getDBSystemRoot().getDataSource().executeA(sel.asString());
|
|
|
116 |
|
|
|
117 |
SQLSelect selCom = new SQLSelect();
|
|
|
118 |
final SQLTable tableCom = eltFact.getTable().getTable("COMMERCIAL");
|
|
|
119 |
selCom.addSelect(tableCom.getKey());
|
|
|
120 |
selCom.addSelect(tableCom.getField("NOM"));
|
|
|
121 |
selCom.addSelect(tableCom.getField("PRENOM"));
|
|
|
122 |
|
|
|
123 |
List<SQLRow> coms = SQLRowListRSH.execute(selCom);
|
|
|
124 |
Map<Integer, SQLRow> mapCom = new HashMap<Integer, SQLRow>();
|
|
|
125 |
for (SQLRow sqlRow : coms) {
|
|
|
126 |
mapCom.put(sqlRow.getID(), sqlRow);
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
SQLSelect selArt = new SQLSelect();
|
|
|
130 |
selArt.addSelect(tableArt.getKey());
|
|
|
131 |
selArt.addSelect(tableArt.getField("NOM"));
|
|
|
132 |
selArt.addSelect(tableArt.getField("CODE"));
|
|
|
133 |
selArt.addSelect(tableArt.getField("ID_FAMILLE_ARTICLE"));
|
|
|
134 |
|
|
|
135 |
List<SQLRow> art = SQLRowListRSH.execute(selArt);
|
|
|
136 |
Map<Integer, SQLRow> mapA = new HashMap<Integer, SQLRow>();
|
|
|
137 |
for (SQLRow sqlRow : art) {
|
|
|
138 |
mapA.put(sqlRow.getID(), sqlRow);
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
final SQLTable tableF = eltFactItem.getTable().getTable("FAMILLE_ARTICLE");
|
|
|
142 |
|
|
|
143 |
SQLSelect selFam = new SQLSelect();
|
|
|
144 |
selFam.addSelect(tableF.getKey());
|
|
|
145 |
selFam.addSelect(tableF.getField("NOM"));
|
|
|
146 |
selFam.addSelect(tableF.getField("ID_FAMILLE_ARTICLE_PERE"));
|
|
|
147 |
|
|
|
148 |
List<SQLRow> fam = SQLRowListRSH.execute(selFam);
|
|
|
149 |
Map<Integer, SQLRow> mapF = new HashMap<Integer, SQLRow>();
|
|
|
150 |
for (SQLRow sqlRow : fam) {
|
|
|
151 |
mapF.put(sqlRow.getID(), sqlRow);
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
Map<String, Line> linesFamilles = new HashMap<String, Line>();
|
|
|
155 |
Map<String, Line> linesCommercial = new HashMap<String, Line>();
|
|
|
156 |
Map<String, Map<Line, Map<Line, List<Line>>>> myValues = new TreeMap<String, Map<Line, Map<Line, List<Line>>>>();
|
|
|
157 |
|
|
|
158 |
Line lineTotal = new Line("Total", "", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO);
|
|
|
159 |
final HashMap<Integer, String> style = new HashMap<Integer, String>();
|
|
|
160 |
for (Object[] vals : result) {
|
|
|
161 |
BigDecimal qte = (BigDecimal) vals[0];
|
|
|
162 |
BigDecimal ha = (BigDecimal) vals[1];
|
|
|
163 |
BigDecimal ht = (BigDecimal) vals[2];
|
|
|
164 |
BigDecimal ttc = (BigDecimal) vals[3];
|
|
|
165 |
int idArt = (Integer) vals[4];
|
|
|
166 |
|
|
|
167 |
SQLRow rowArt = mapA.get(idArt);
|
|
|
168 |
int idFamille = rowArt.getForeignID("ID_FAMILLE_ARTICLE");
|
|
|
169 |
SQLRow rowF = mapF.get(idFamille);
|
|
|
170 |
Line lineArt = new Line(rowArt.getString("NOM"), rowArt.getString("CODE"), ha, ttc, ht, qte);
|
|
|
171 |
|
|
|
172 |
// Init des lines familles
|
|
|
173 |
final Line lineF, lineSF;
|
|
|
174 |
if (rowF == null) {
|
|
|
175 |
if (!linesFamilles.containsKey("Undef")) {
|
|
|
176 |
linesFamilles.put("Undef", new Line("Sans famille", "", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
177 |
linesFamilles.put("Undef-Undef", new Line("", "", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
178 |
}
|
|
|
179 |
lineF = linesFamilles.get("Undef");
|
|
|
180 |
lineSF = linesFamilles.get("Undef-Undef");
|
|
|
181 |
} else if (rowF.getObject("ID_FAMILLE_ARTICLE_PERE") == null || rowF.isForeignEmpty("ID_FAMILLE_ARTICLE_PERE")) {
|
|
|
182 |
final String idRowF = String.valueOf(rowF.getID());
|
|
|
183 |
if (!linesFamilles.containsKey(idRowF)) {
|
|
|
184 |
linesFamilles.put(idRowF, new Line(rowF.getString("NOM"), "", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
185 |
linesFamilles.put(idRowF + "-Undef", new Line("", "", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
186 |
}
|
|
|
187 |
lineF = linesFamilles.get(idRowF);
|
|
|
188 |
if (!linesFamilles.containsKey(idRowF + "-Undef")) {
|
|
|
189 |
linesFamilles.put(idRowF + "-Undef", new Line("", "", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
190 |
}
|
|
|
191 |
lineSF = linesFamilles.get(idRowF + "-Undef");
|
|
|
192 |
if (lineSF == null) {
|
|
|
193 |
System.err.println("null SF");
|
|
|
194 |
}
|
|
|
195 |
if (lineF == null) {
|
|
|
196 |
System.err.println("null F");
|
|
|
197 |
}
|
|
|
198 |
} else {
|
|
|
199 |
final String idRowF = String.valueOf(rowF.getID());
|
|
|
200 |
|
|
|
201 |
if (!linesFamilles.containsKey(idRowF)) {
|
|
|
202 |
linesFamilles.put(idRowF, new Line(rowF.getString("NOM"), "", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
203 |
}
|
|
|
204 |
if (!linesFamilles.containsKey(String.valueOf(rowF.getForeignID("ID_FAMILLE_ARTICLE_PERE")))) {
|
|
|
205 |
SQLRow rowSF = mapF.get(rowF.getForeignID("ID_FAMILLE_ARTICLE_PERE"));
|
|
|
206 |
linesFamilles.put(String.valueOf(rowF.getForeignID("ID_FAMILLE_ARTICLE_PERE")),
|
|
|
207 |
new Line(rowSF.getString("NOM"), "", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
208 |
}
|
|
|
209 |
lineF = linesFamilles.get(String.valueOf(rowF.getForeignID("ID_FAMILLE_ARTICLE_PERE")));
|
|
|
210 |
lineSF = linesFamilles.get(idRowF);
|
|
|
211 |
if (lineSF == null) {
|
|
|
212 |
System.err.println("null SF");
|
|
|
213 |
}
|
|
|
214 |
if (lineF == null) {
|
|
|
215 |
System.err.println("null F");
|
|
|
216 |
}
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
// init values
|
|
|
220 |
final String commercial;
|
|
|
221 |
if (idS != null && idS.size() > 0) {
|
|
|
222 |
|
|
|
223 |
SQLRow rowCom = mapCom.get(vals[5]);
|
|
|
224 |
commercial = rowCom.getString("PRENOM") + " " + rowCom.getString("NOM");
|
|
|
225 |
if (!linesCommercial.containsKey(commercial)) {
|
|
|
226 |
linesCommercial.put(commercial, new Line(commercial, "COMMERCIAL", BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
227 |
}
|
|
|
228 |
linesCommercial.get(commercial).add(lineArt);
|
|
|
229 |
} else {
|
|
|
230 |
commercial = "";
|
|
|
231 |
}
|
|
|
232 |
Map<Line, Map<Line, List<Line>>> mapCommercial;
|
|
|
233 |
if (!myValues.containsKey(commercial)) {
|
|
|
234 |
myValues.put(commercial, new TreeMap<Line, Map<Line, List<Line>>>(new Comparator<Line>() {
|
|
|
235 |
@Override
|
|
|
236 |
public int compare(Line o1, Line o2) {
|
|
|
237 |
return o1.getNomArt().compareTo(o2.getNomArt());
|
|
|
238 |
}
|
|
|
239 |
}));
|
|
|
240 |
|
|
|
241 |
}
|
|
|
242 |
mapCommercial = myValues.get(commercial);
|
|
|
243 |
|
|
|
244 |
if (!mapCommercial.containsKey(lineF)) {
|
|
|
245 |
mapCommercial.put(lineF, new TreeMap<Line, List<Line>>(new Comparator<Line>() {
|
|
|
246 |
@Override
|
|
|
247 |
public int compare(Line o1, Line o2) {
|
|
|
248 |
return o1.getNomArt().compareTo(o2.getNomArt());
|
|
|
249 |
}
|
|
|
250 |
}));
|
|
|
251 |
mapCommercial.get(lineF).put(lineSF, new ArrayList<Line>());
|
|
|
252 |
}
|
|
|
253 |
Map<Line, List<Line>> mapSF = mapCommercial.get(lineF);
|
|
|
254 |
if (!mapSF.containsKey(lineSF)) {
|
|
|
255 |
mapSF.put(lineSF, new ArrayList<Line>());
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
// Store values
|
|
|
259 |
List<Line> lines = mapSF.get(lineSF);
|
|
|
260 |
lines.add(lineArt);
|
|
|
261 |
lineTotal.add(lineArt);
|
|
|
262 |
lineF.add(lineArt);
|
|
|
263 |
lineSF.add(lineArt);
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
// Sort Values
|
|
|
267 |
List<Map<String, Object>> listValues = new ArrayList<Map<String, Object>>();
|
|
|
268 |
|
|
|
269 |
for (Entry<String, Map<Line, Map<Line, List<Line>>>> commercial : myValues.entrySet()) {
|
|
|
270 |
|
|
|
271 |
if (linesCommercial.get(commercial.getKey()) != null) {
|
|
|
272 |
listValues.add(linesCommercial.get(commercial.getKey()).getMapXMLSheet());
|
|
|
273 |
style.put(style.keySet().size(), "Titre 1");
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
for (Line f : commercial.getValue().keySet()) {
|
|
|
277 |
listValues.add(f.getMapXMLSheet());
|
|
|
278 |
style.put(style.keySet().size(), "Titre 1");
|
|
|
279 |
Map<Line, List<Line>> sfs = commercial.getValue().get(f);
|
|
|
280 |
for (Line sf : sfs.keySet()) {
|
|
|
281 |
listValues.add(sf.getMapXMLSheet());
|
|
|
282 |
style.put(style.keySet().size(), "Titre 2");
|
|
|
283 |
List<Line> vals = sfs.get(sf);
|
|
|
284 |
Collections.sort(vals, new Comparator<Line>() {
|
|
|
285 |
@Override
|
|
|
286 |
public int compare(Line o1, Line o2) {
|
|
|
287 |
return o1.getNomArt().compareTo(o2.getNomArt());
|
|
|
288 |
}
|
|
|
289 |
});
|
|
|
290 |
for (Line line : vals) {
|
|
|
291 |
if (line.getQte().signum() > 0) {
|
|
|
292 |
listValues.add(line.getMapXMLSheet());
|
|
|
293 |
style.put(style.keySet().size(), "Normal");
|
|
|
294 |
}
|
|
|
295 |
}
|
|
|
296 |
}
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
listValues.add(lineTotal.getMapXMLSheet());
|
|
|
300 |
style.put(style.keySet().size(), "Titre 1");
|
|
|
301 |
|
|
|
302 |
// SwingUtilities.invokeLater(new Runnable() {
|
|
|
303 |
// public void run() {
|
|
|
304 |
// ReportingVenteXmlSheet.this.bar.setMaximum(ReportingVenteXmlSheet.this.listeIds.size());
|
|
|
305 |
// }
|
|
|
306 |
// });
|
|
|
307 |
// List<Map<String, Object>> listValues = new ArrayList<Map<String,
|
|
|
308 |
// Object>>(this.listeIds.size());
|
|
|
309 |
// int i = 1;
|
|
|
310 |
// for (SQLRow rowFacture : this.listeIds) {
|
|
|
311 |
// Map<String, Object> mValues = new HashMap<String, Object>();
|
|
|
312 |
// final String dateFacture = dateFormat.format((Date) rowFacture.getObject("DATE"));
|
|
|
313 |
// mValues.put("DATE", dateFacture);
|
|
|
314 |
// mValues.put("NUMERO", rowFacture.getObject("NUMERO"));
|
|
|
315 |
// if (rowFacture.getTable().getName().equalsIgnoreCase(this.eltAvoir.getTable().getName()))
|
|
|
316 |
// {
|
|
|
317 |
// mValues.put("MONTANT_HT", new Double(-((Number)
|
|
|
318 |
// rowFacture.getObject("MONTANT_HT")).longValue() / 100.0));
|
|
|
319 |
// mValues.put("MONTANT_TVA", new Double(-((Number)
|
|
|
320 |
// rowFacture.getObject("MONTANT_TVA")).longValue() / 100.0));
|
|
|
321 |
// mValues.put("MONTANT_TTC", new Double(-((Number)
|
|
|
322 |
// rowFacture.getObject("MONTANT_TTC")).longValue() / 100.0));
|
|
|
323 |
// } else {
|
|
|
324 |
// mValues.put("MONTANT_HT", new Double(((Number) rowFacture.getObject("T_HT")).longValue()
|
|
|
325 |
// / 100.0));
|
|
|
326 |
// mValues.put("MONTANT_TVA", new Double(((Number)
|
|
|
327 |
// rowFacture.getObject("T_TVA")).longValue() / 100.0));
|
|
|
328 |
// mValues.put("MONTANT_TTC", new Double(((Number)
|
|
|
329 |
// rowFacture.getObject("T_TTC")).longValue() / 100.0));
|
|
|
330 |
// }
|
|
|
331 |
//
|
|
|
332 |
// // Client
|
|
|
333 |
// SQLRow rowCli;
|
|
|
334 |
// // #if gestionnx
|
|
|
335 |
// if (((ComptaPropsConfiguration) Configuration.getInstance()).customerUseControle()) {
|
|
|
336 |
// rowCli = rowFacture.getForeignRow("ID_CLIENT").getForeignRow("ID_CLIENT");
|
|
|
337 |
// } else {
|
|
|
338 |
// // #endif
|
|
|
339 |
// rowCli = rowFacture.getForeignRow("ID_CLIENT");
|
|
|
340 |
// // #if gestionnx
|
|
|
341 |
// }
|
|
|
342 |
// // #endif
|
|
|
343 |
// String libClient = rowCli.getString("FORME_JURIDIQUE") + " " + rowCli.getString("NOM");
|
|
|
344 |
// mValues.put("CLIENT", libClient.trim());
|
|
|
345 |
//
|
|
|
346 |
// // Mode de reglement
|
|
|
347 |
// SQLRow rowMode = rowFacture.getForeignRow("ID_MODE_REGLEMENT");
|
|
|
348 |
// final int typeReglement = rowMode.getInt("ID_TYPE_REGLEMENT");
|
|
|
349 |
// if (rowMode.getBoolean("COMPTANT") && typeReglement <= TypeReglementSQLElement.TRAITE) {
|
|
|
350 |
//
|
|
|
351 |
// final SQLRow foreignRow = rowMode.getForeignRow("ID_TYPE_REGLEMENT");
|
|
|
352 |
// Date d = (Date) rowFacture.getObject("DATE");
|
|
|
353 |
// if (foreignRow.getID() == TypeReglementSQLElement.TRAITE) {
|
|
|
354 |
// Calendar c = (rowMode.getDate("DATE_VIREMENT"));
|
|
|
355 |
// if (c != null) {
|
|
|
356 |
// d = c.getTime();
|
|
|
357 |
// }
|
|
|
358 |
// } else if (foreignRow.getID() == TypeReglementSQLElement.CHEQUE) {
|
|
|
359 |
// Calendar c = (rowMode.getDate("DATE"));
|
|
|
360 |
// if (c != null) {
|
|
|
361 |
// d = c.getTime();
|
|
|
362 |
// }
|
|
|
363 |
// }
|
|
|
364 |
//
|
|
|
365 |
// mValues.put("DATE_REGLEMENT", dateFormat.format(d));
|
|
|
366 |
// mValues.put("TYPE_REGLEMENT", foreignRow.getString("NOM"));
|
|
|
367 |
// } else {
|
|
|
368 |
//
|
|
|
369 |
// SQLRow rowMvt = rowFacture.getForeignRow("ID_MOUVEMENT");
|
|
|
370 |
// SQLRow rowPiece = rowMvt.getForeignRow("ID_PIECE");
|
|
|
371 |
//
|
|
|
372 |
// SQLSelect sel = new SQLSelect(rowFacture.getTable().getBase());
|
|
|
373 |
//
|
|
|
374 |
// sel.addSelect(this.eltEnc.getTable().getKey());
|
|
|
375 |
// sel.addSelect(this.eltEnc.getTable().getField("ID_MODE_REGLEMENT"));
|
|
|
376 |
//
|
|
|
377 |
// Where w = new Where(rowMvt.getTable().getField("ID_PIECE"), "=", rowPiece.getID());
|
|
|
378 |
// w = w.and(new Where(rowMvt.getTable().getKey(), "=",
|
|
|
379 |
// this.eltEncElt.getTable().getField("ID_MOUVEMENT_ECHEANCE")));
|
|
|
380 |
// w = w.and(new Where(this.eltEncElt.getTable().getField("ID_ENCAISSER_MONTANT"), "=",
|
|
|
381 |
// this.eltEnc.getTable().getKey()));
|
|
|
382 |
//
|
|
|
383 |
// sel.setWhere(w);
|
|
|
384 |
//
|
|
|
385 |
// List<SQLRow> l = (List<SQLRow>)
|
|
|
386 |
// Configuration.getInstance().getBase().getDataSource().execute(sel.asString(),
|
|
|
387 |
// SQLRowListRSH.createFromSelect(sel, eltEnc.getTable()));
|
|
|
388 |
// for (SQLRow sqlRow : l) {
|
|
|
389 |
// final SQLRow foreignRow = sqlRow.getForeignRow("ID_MODE_REGLEMENT");
|
|
|
390 |
// SQLRow rowTypeRegl = foreignRow.getForeignRow("ID_TYPE_REGLEMENT");
|
|
|
391 |
// Calendar cDate = foreignRow.getDate("DATE");
|
|
|
392 |
// Calendar cDateVirement = foreignRow.getDate("DATE_VIREMENT");
|
|
|
393 |
// if (cDate != null) {
|
|
|
394 |
// mValues.put("DATE_REGLEMENT", dateFormat.format(cDate.getTime()));
|
|
|
395 |
// } else if (cDateVirement != null) {
|
|
|
396 |
// mValues.put("DATE_REGLEMENT", dateFormat.format(cDateVirement.getTime()));
|
|
|
397 |
// } else {
|
|
|
398 |
// mValues.put("DATE_REGLEMENT", dateFormat.format(sqlRow.getDate("DATE").getTime()));
|
|
|
399 |
// }
|
|
|
400 |
//
|
|
|
401 |
// mValues.put("TYPE_REGLEMENT", rowTypeRegl.getString("NOM"));
|
|
|
402 |
// }
|
|
|
403 |
// }
|
|
|
404 |
//
|
|
|
405 |
// listValues.add(mValues);
|
|
|
406 |
// final int value = i++;
|
|
|
407 |
// SwingUtilities.invokeLater(new Runnable() {
|
|
|
408 |
// public void run() {
|
|
|
409 |
// ReportingVenteXmlSheet.this.bar.setValue(value);
|
|
|
410 |
// }
|
|
|
411 |
// });
|
|
|
412 |
// }
|
|
|
413 |
final Map<String, Object> values = new HashMap<String, Object>();
|
|
|
414 |
values.put("DATE", "Du " + dateFormat.format(this.du) + " au " + dateFormat.format(this.au));
|
|
|
415 |
values.put("NOM", "Reporting des " + (eltFact.getTable().getName().startsWith("COMMANDE") ? "commandes" : "factures"));
|
|
|
416 |
//
|
|
|
417 |
this.listAllSheetValues.put(0, listValues);
|
|
|
418 |
|
|
|
419 |
this.styleAllSheetValues.put(0, style);
|
|
|
420 |
this.mapAllSheetValues.put(0, values);
|
|
|
421 |
}
|
|
|
422 |
|
|
|
423 |
class Line {
|
|
|
424 |
final private String nomArt, codeArt;
|
|
|
425 |
private BigDecimal totalTTC, totalHT, qte, totalHA;
|
|
|
426 |
|
|
|
427 |
public Line(String nomArt, String codeArt, BigDecimal totalHA, BigDecimal totalTTC, BigDecimal totalHT, BigDecimal qte) {
|
|
|
428 |
this.nomArt = nomArt;
|
|
|
429 |
this.codeArt = codeArt;
|
|
|
430 |
this.totalHA = totalHA;
|
|
|
431 |
this.totalHT = totalHT;
|
|
|
432 |
this.totalTTC = totalTTC;
|
|
|
433 |
this.qte = qte;
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
public BigDecimal getTotalHA() {
|
|
|
437 |
return totalHA;
|
|
|
438 |
}
|
|
|
439 |
|
|
|
440 |
public BigDecimal getQte() {
|
|
|
441 |
return qte;
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
public String getCodeArt() {
|
|
|
445 |
return codeArt;
|
|
|
446 |
}
|
|
|
447 |
|
|
|
448 |
public String getNomArt() {
|
|
|
449 |
return nomArt;
|
|
|
450 |
}
|
|
|
451 |
|
|
|
452 |
public BigDecimal getTotalHT() {
|
|
|
453 |
return totalHT;
|
|
|
454 |
}
|
|
|
455 |
|
|
|
456 |
public BigDecimal getTotalTTC() {
|
|
|
457 |
return totalTTC;
|
|
|
458 |
}
|
|
|
459 |
|
|
|
460 |
public void add(Line l) {
|
|
|
461 |
this.qte = this.qte.add(l.getQte());
|
|
|
462 |
this.totalHA = this.totalHA.add(l.getTotalHA());
|
|
|
463 |
this.totalHT = this.totalHT.add(l.getTotalHT());
|
|
|
464 |
this.totalTTC = this.totalTTC.add(l.getTotalTTC());
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
public Map<String, Object> getMapXMLSheet() {
|
|
|
468 |
Map<String, Object> m = new HashMap<String, Object>();
|
|
|
469 |
m.put("CODE", getCodeArt());
|
|
|
470 |
m.put("NOM", getNomArt());
|
|
|
471 |
m.put("QTE", getQte());
|
|
|
472 |
m.put("TOTAL_HA", getTotalHA());
|
|
|
473 |
m.put("TOTAL_HT", getTotalHT());
|
|
|
474 |
m.put("TOTAL_TTC", getTotalTTC());
|
|
|
475 |
return m;
|
|
|
476 |
}
|
|
|
477 |
|
|
|
478 |
}
|
|
|
479 |
|
|
|
480 |
}
|