Line 15... |
Line 15... |
15 |
|
15 |
|
16 |
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
|
16 |
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
|
17 |
import org.openconcerto.erp.preferences.PrinterNXProps;
|
17 |
import org.openconcerto.erp.preferences.PrinterNXProps;
|
18 |
import org.openconcerto.sql.Configuration;
|
18 |
import org.openconcerto.sql.Configuration;
|
19 |
import org.openconcerto.sql.element.SQLElement;
|
19 |
import org.openconcerto.sql.element.SQLElement;
|
- |
|
20 |
import org.openconcerto.sql.model.AliasedTable;
|
20 |
import org.openconcerto.sql.model.SQLRow;
|
21 |
import org.openconcerto.sql.model.SQLRow;
|
21 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
22 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
22 |
import org.openconcerto.sql.model.SQLSelect;
|
23 |
import org.openconcerto.sql.model.SQLSelect;
|
23 |
import org.openconcerto.sql.model.SQLSelectJoin;
|
24 |
import org.openconcerto.sql.model.SQLSelectJoin;
|
24 |
import org.openconcerto.sql.model.SQLTable;
|
25 |
import org.openconcerto.sql.model.SQLTable;
|
Line 85... |
Line 86... |
85 |
}
|
86 |
}
|
86 |
|
87 |
|
87 |
protected void createListeValues() {
|
88 |
protected void createListeValues() {
|
88 |
|
89 |
|
89 |
SQLSelect sel = new SQLSelect();
|
90 |
SQLSelect sel = new SQLSelect();
|
90 |
sel.addRawSelect("SUM(\"QTE\"*\"QTE_UNITAIRE\")", "q");
|
- |
|
91 |
final SQLTable tableItemFact = eltFactItem.getTable();
|
91 |
final SQLTable tableItemFact = eltFactItem.getTable();
|
- |
|
92 |
AliasedTable tableAlias = new AliasedTable(tableItemFact, "eltTable");
|
- |
|
93 |
sel.addRawSelect("SUM(\"eltTable\".\"QTE\"*\"eltTable\".\"QTE_UNITAIRE\")", "q");
|
92 |
sel.addSelect(tableItemFact.getField("T_PA_HT"), "SUM");
|
94 |
sel.addSelect(tableAlias.getField("T_PA_HT"), "SUM");
|
93 |
sel.addSelect(tableItemFact.getField("T_PV_HT"), "SUM");
|
95 |
sel.addSelect(tableAlias.getField("T_PV_HT"), "SUM");
|
94 |
sel.addSelect(tableItemFact.getField("T_PV_TTC"), "SUM");
|
96 |
sel.addSelect(tableAlias.getField("T_PV_TTC"), "SUM");
|
95 |
final SQLTable tableArt = eltFactItem.getForeignElement("ID_ARTICLE").getTable();
|
97 |
final SQLTable tableArt = eltFactItem.getForeignElement("ID_ARTICLE").getTable();
|
96 |
sel.addSelect(tableItemFact.getField("ID_ARTICLE"));
|
98 |
sel.addSelect(tableAlias.getField("ID_ARTICLE"));
|
97 |
|
99 |
|
98 |
final SQLSelectJoin joinFact = sel.addJoin("LEFT", tableItemFact.getField("ID_" + eltFact.getTable().getName()));
|
100 |
final SQLSelectJoin joinFact = sel.addJoin("LEFT", tableAlias.getField("ID_" + eltFact.getTable().getName()));
|
99 |
|
101 |
|
100 |
Where wA = new Where(tableArt.getKey(), "=", tableItemFact.getField("ID_ARTICLE"));
|
102 |
Where wA = new Where(tableArt.getKey(), "=", tableAlias.getField("ID_ARTICLE"));
|
101 |
Where w = new Where(joinFact.getJoinedTable().getField("DATE"), this.du, this.au);
|
103 |
Where w = new Where(joinFact.getJoinedTable().getField("DATE"), this.du, this.au);
|
102 |
|
104 |
|
103 |
if (idS != null && idS.size() > 0) {
|
105 |
if (idS != null && idS.size() > 0) {
|
104 |
sel.addSelect(joinFact.getJoinedTable().getField("ID_COMMERCIAL"));
|
106 |
sel.addSelect(joinFact.getJoinedTable().getField("ID_COMMERCIAL"));
|
105 |
sel.addGroupBy(joinFact.getJoinedTable().getField("ID_COMMERCIAL"));
|
107 |
sel.addGroupBy(joinFact.getJoinedTable().getField("ID_COMMERCIAL"));
|
106 |
|
108 |
|
107 |
w = w.and(new Where(joinFact.getJoinedTable().getField("ID_COMMERCIAL"), idS));
|
109 |
w = w.and(new Where(joinFact.getJoinedTable().getField("ID_COMMERCIAL"), idS));
|
108 |
}
|
110 |
}
|
109 |
sel.setWhere(wA.and(w));
|
111 |
sel.setWhere(wA.and(w));
|
110 |
|
112 |
|
111 |
sel.addGroupBy(tableItemFact.getField("ID_ARTICLE"));
|
113 |
sel.addGroupBy(tableAlias.getField("ID_ARTICLE"));
|
112 |
|
114 |
|
113 |
List<Object[]> result = eltFact.getTable().getDBSystemRoot().getDataSource().executeA(sel.asString());
|
115 |
List<Object[]> result = eltFact.getTable().getDBSystemRoot().getDataSource().executeA(sel.asString());
|
114 |
|
116 |
|
115 |
SQLSelect selCom = new SQLSelect();
|
117 |
SQLSelect selCom = new SQLSelect();
|
116 |
final SQLTable tableCom = eltFact.getTable().getTable("COMMERCIAL");
|
118 |
final SQLTable tableCom = eltFact.getTable().getTable("COMMERCIAL");
|