144 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
185 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
144 |
ilm |
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 |
/*
|
|
|
15 |
* Créé le 18 oct. 2011
|
|
|
16 |
*/
|
|
|
17 |
package org.openconcerto.erp.core.supplychain.order.element;
|
|
|
18 |
|
|
|
19 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
|
|
20 |
import org.openconcerto.erp.core.common.element.StyleSQLElement;
|
149 |
ilm |
21 |
import org.openconcerto.erp.core.common.ui.DeviseTableCellRenderer;
|
144 |
ilm |
22 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
149 |
ilm |
23 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
144 |
ilm |
24 |
import org.openconcerto.erp.core.supplychain.order.ui.EtatDemandeAchatRenderer;
|
|
|
25 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
26 |
import org.openconcerto.sql.model.SQLInjector;
|
|
|
27 |
import org.openconcerto.sql.model.SQLRow;
|
174 |
ilm |
28 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
144 |
ilm |
29 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
30 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
|
|
31 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
32 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
33 |
import org.openconcerto.sql.model.Where;
|
|
|
34 |
import org.openconcerto.sql.view.EditFrame;
|
|
|
35 |
import org.openconcerto.sql.view.list.IListe;
|
149 |
ilm |
36 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
144 |
ilm |
37 |
import org.openconcerto.sql.view.list.RowAction;
|
149 |
ilm |
38 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
144 |
ilm |
39 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
|
|
40 |
import org.openconcerto.ui.FrameUtil;
|
|
|
41 |
import org.openconcerto.utils.ExceptionHandler;
|
|
|
42 |
import org.openconcerto.utils.ListMap;
|
|
|
43 |
import org.openconcerto.utils.cc.ITransformer;
|
|
|
44 |
|
|
|
45 |
import java.awt.event.ActionEvent;
|
|
|
46 |
import java.math.BigDecimal;
|
|
|
47 |
import java.sql.SQLException;
|
|
|
48 |
import java.util.ArrayList;
|
|
|
49 |
import java.util.Arrays;
|
|
|
50 |
import java.util.Collection;
|
|
|
51 |
import java.util.Date;
|
|
|
52 |
import java.util.List;
|
|
|
53 |
|
|
|
54 |
import javax.swing.AbstractAction;
|
|
|
55 |
|
|
|
56 |
public class DemandeAchatItemSQLElement extends ComptaSQLConfElement {
|
|
|
57 |
|
|
|
58 |
public DemandeAchatItemSQLElement() {
|
156 |
ilm |
59 |
super("DEMANDE_ACHAT_ELEMENT");
|
149 |
ilm |
60 |
{
|
|
|
61 |
PredicateRowAction actionP = new PredicateRowAction(new AbstractAction("Créer à partir de") {
|
144 |
ilm |
62 |
|
149 |
ilm |
63 |
@Override
|
|
|
64 |
public void actionPerformed(ActionEvent e) {
|
|
|
65 |
SQLRow row = IListe.get(e).getSelectedRow().asRow();
|
|
|
66 |
SQLRowValues rowDupl = new SQLRowValues(row.getTable());
|
|
|
67 |
List<String> copyFields = Arrays.asList("COLOR", "NUMERO_SE", "DESCRIPTIF_SE", "REVISION", "P_HT", "T_HT", "REPERE_SOURCE", "CODE_SOURCE", "NOM_SOURCE", "CODE", "NOM", "QTE",
|
|
|
68 |
"QTE_UNITAIRE", "REPERE", "REFERENCE", "ID_FABRICANT", "ID_UNITE_VENTE", "ID_ARTICLE", "ID_FOURNISSEUR", "ID_FAMILLE_ARTICLE", "ID_AFFAIRE");
|
|
|
69 |
// "CODE" character varying(256) NOT NULL DEFAULT ''::character varying,
|
|
|
70 |
//
|
|
|
71 |
// "DATE" date,
|
|
|
72 |
// "ID_ETAT_DEMANDE_ACHAT_ELEMENT" integer DEFAULT 1,
|
|
|
73 |
// "REPRISE" boolean NOT NULL DEFAULT false,
|
|
|
74 |
for (String string : copyFields) {
|
185 |
ilm |
75 |
if (getTable().contains(string)) {
|
|
|
76 |
if (string.startsWith("ID_")) {
|
|
|
77 |
rowDupl.put(string, row.getForeignID(string));
|
|
|
78 |
} else {
|
|
|
79 |
rowDupl.put(string, row.getObject(string));
|
|
|
80 |
}
|
149 |
ilm |
81 |
}
|
|
|
82 |
}
|
|
|
83 |
rowDupl.put("DATE", new Date());
|
|
|
84 |
EditFrame frame = new EditFrame(getDirectory().getElement("DEMANDE_ACHAT_ELEMENT"));
|
|
|
85 |
frame.getSQLComponent().select(rowDupl);
|
|
|
86 |
FrameUtil.showPacked(frame);
|
|
|
87 |
}
|
|
|
88 |
}, true);
|
|
|
89 |
|
|
|
90 |
actionP.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
91 |
getRowActions().add(actionP);
|
|
|
92 |
}
|
144 |
ilm |
93 |
{
|
|
|
94 |
RowAction actionP = new RowAction(new AbstractAction("Transfert en demande de prix") {
|
|
|
95 |
|
|
|
96 |
@Override
|
|
|
97 |
public void actionPerformed(ActionEvent e) {
|
|
|
98 |
StyleSQLElement styleElt = getDirectory().getElement(StyleSQLElement.class);
|
|
|
99 |
int idNormal = styleElt.getAllStyleByName().get("Normal");
|
|
|
100 |
|
|
|
101 |
SQLRowValues rowVals = new SQLRowValues(getTable().getTable("DEMANDE_PRIX"));
|
|
|
102 |
rowVals.put("DATE", new Date());
|
|
|
103 |
SQLInjector inj = SQLInjector.getInjector(getTable(), getTable().getTable("DEMANDE_PRIX_ELEMENT"));
|
174 |
ilm |
104 |
|
|
|
105 |
final List<SQLRow> rows = SQLRowListRSH.fetch(IListe.get(e).getRequest().getPrimaryTable(), IListe.get(e).getSelection().getSelectedIDs());
|
|
|
106 |
|
|
|
107 |
for (SQLRow row : rows) {
|
185 |
ilm |
108 |
if (getTable().contains("ID_AFFAIRE")) {
|
|
|
109 |
rowVals.put("ID_AFFAIRE", row.getForeignID("ID_AFFAIRE"));
|
|
|
110 |
}
|
144 |
ilm |
111 |
SQLRowValues rowValsCmdElt = inj.createRowValuesFrom(row);
|
|
|
112 |
rowValsCmdElt.put("ID_STYLE", idNormal);
|
149 |
ilm |
113 |
rowValsCmdElt.put("ID_MODE_VENTE_ARTICLE", ReferenceArticleSQLElement.A_LA_PIECE);
|
177 |
ilm |
114 |
rowValsCmdElt.put("ID_TAXE", TaxeCache.getCache().getFirstTaxeAchat().getID());
|
144 |
ilm |
115 |
rowValsCmdElt.put("ID_DEMANDE_PRIX", rowVals);
|
|
|
116 |
rowValsCmdElt.put("ID_DEMANDE_ACHAT_ELEMENT", row.getID());
|
|
|
117 |
if (row.getObject("ID_ARTICLE") != null && !row.isForeignEmpty("ID_ARTICLE")) {
|
|
|
118 |
BigDecimal ha = row.getForeign("ID_ARTICLE").getBigDecimal("PA_HT");
|
|
|
119 |
rowValsCmdElt.put("PA_HT", ha);
|
|
|
120 |
rowValsCmdElt.put("PRIX_METRIQUE_HA_1", ha);
|
185 |
ilm |
121 |
rowValsCmdElt.put("PA_DEVISE", ha);
|
144 |
ilm |
122 |
} else {
|
|
|
123 |
rowValsCmdElt.put("PA_HT", BigDecimal.ZERO);
|
|
|
124 |
rowValsCmdElt.put("PRIX_METRIQUE_HA_1", BigDecimal.ZERO);
|
185 |
ilm |
125 |
rowValsCmdElt.put("PA_DEVISE", BigDecimal.ZERO);
|
144 |
ilm |
126 |
}
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
EditFrame frame = new EditFrame(getDirectory().getElement("DEMANDE_PRIX"));
|
|
|
130 |
frame.getSQLComponent().select(rowVals);
|
|
|
131 |
FrameUtil.showPacked(frame);
|
|
|
132 |
}
|
|
|
133 |
}, true) {
|
|
|
134 |
@Override
|
|
|
135 |
public boolean enabledFor(List<SQLRowValues> selection) {
|
|
|
136 |
if (selection != null && selection.size() > 0) {
|
|
|
137 |
int idAff = -1;
|
|
|
138 |
for (SQLRowValues sqlRowValues : selection) {
|
|
|
139 |
if (getTable().contains("ID_AFFAIRE")) {
|
|
|
140 |
if (sqlRowValues.getObject("ID_AFFAIRE") != null && !sqlRowValues.isForeignEmpty("ID_AFFAIRE")) {
|
|
|
141 |
if (idAff == -1) {
|
|
|
142 |
idAff = sqlRowValues.getForeignID("ID_AFFAIRE");
|
|
|
143 |
}
|
|
|
144 |
if (idAff != sqlRowValues.getForeignID("ID_AFFAIRE")) {
|
|
|
145 |
return false;
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
return true;
|
|
|
151 |
}
|
|
|
152 |
return false;
|
|
|
153 |
}
|
|
|
154 |
};
|
|
|
155 |
getRowActions().add(actionP);
|
|
|
156 |
}
|
|
|
157 |
{
|
|
|
158 |
RowAction actionP = new RowAction(new AbstractAction("Transfert en commande") {
|
|
|
159 |
|
|
|
160 |
@Override
|
|
|
161 |
public void actionPerformed(ActionEvent e) {
|
|
|
162 |
StyleSQLElement styleElt = getDirectory().getElement(StyleSQLElement.class);
|
|
|
163 |
int idNormal = styleElt.getAllStyleByName().get("Normal");
|
|
|
164 |
|
|
|
165 |
SQLRowValues rowVals = new SQLRowValues(getTable().getTable("COMMANDE"));
|
|
|
166 |
rowVals.put("DATE", new Date());
|
|
|
167 |
SQLInjector inj = SQLInjector.getInjector(getTable(), getTable().getTable("COMMANDE_ELEMENT"));
|
174 |
ilm |
168 |
final List<SQLRow> rows = SQLRowListRSH.fetch(IListe.get(e).getRequest().getPrimaryTable(), IListe.get(e).getSelection().getSelectedIDs());
|
|
|
169 |
for (SQLRow row : rows) {
|
185 |
ilm |
170 |
if (getTable().contains("ID_AFFAIRE")) {
|
|
|
171 |
rowVals.put("ID_AFFAIRE", row.getForeignID("ID_AFFAIRE"));
|
|
|
172 |
}
|
144 |
ilm |
173 |
SQLRowValues rowValsCmdElt = inj.createRowValuesFrom(row);
|
|
|
174 |
rowValsCmdElt.put("ID_STYLE", idNormal);
|
149 |
ilm |
175 |
rowValsCmdElt.put("ID_MODE_VENTE_ARTICLE", ReferenceArticleSQLElement.A_LA_PIECE);
|
177 |
ilm |
176 |
rowValsCmdElt.put("ID_TAXE", TaxeCache.getCache().getFirstTaxeAchat().getID());
|
144 |
ilm |
177 |
rowValsCmdElt.put("ID_COMMANDE", rowVals);
|
|
|
178 |
rowValsCmdElt.put("ID_DEMANDE_ACHAT_ELEMENT", row.getID());
|
|
|
179 |
if (row.getObject("ID_ARTICLE") != null && !row.isForeignEmpty("ID_ARTICLE")) {
|
|
|
180 |
BigDecimal ha = row.getForeign("ID_ARTICLE").getBigDecimal("PA_HT");
|
|
|
181 |
rowValsCmdElt.put("PA_HT", ha);
|
|
|
182 |
rowValsCmdElt.put("PRIX_METRIQUE_HA_1", ha);
|
185 |
ilm |
183 |
rowValsCmdElt.put("PA_DEVISE", ha);
|
144 |
ilm |
184 |
} else {
|
|
|
185 |
rowValsCmdElt.put("PA_HT", BigDecimal.ZERO);
|
|
|
186 |
rowValsCmdElt.put("PRIX_METRIQUE_HA_1", BigDecimal.ZERO);
|
185 |
ilm |
187 |
rowValsCmdElt.put("PA_DEVISE", BigDecimal.ZERO);
|
144 |
ilm |
188 |
}
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
EditFrame frame = new EditFrame(getDirectory().getElement("COMMANDE"));
|
|
|
192 |
frame.getSQLComponent().select(rowVals);
|
|
|
193 |
FrameUtil.showPacked(frame);
|
|
|
194 |
}
|
|
|
195 |
}, true) {
|
|
|
196 |
@Override
|
|
|
197 |
public boolean enabledFor(List<SQLRowValues> selection) {
|
|
|
198 |
if (selection != null && selection.size() > 0) {
|
|
|
199 |
int idAff = -1;
|
|
|
200 |
for (SQLRowValues sqlRowValues : selection) {
|
|
|
201 |
if (getTable().contains("ID_AFFAIRE")) {
|
|
|
202 |
if (sqlRowValues.getObject("ID_AFFAIRE") != null && !sqlRowValues.isForeignEmpty("ID_AFFAIRE")) {
|
|
|
203 |
if (idAff == -1) {
|
|
|
204 |
idAff = sqlRowValues.getForeignID("ID_AFFAIRE");
|
|
|
205 |
}
|
|
|
206 |
if (idAff != sqlRowValues.getForeignID("ID_AFFAIRE")) {
|
|
|
207 |
return false;
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
}
|
|
|
211 |
}
|
|
|
212 |
return true;
|
|
|
213 |
}
|
|
|
214 |
return false;
|
|
|
215 |
}
|
|
|
216 |
};
|
|
|
217 |
getRowActions().add(actionP);
|
|
|
218 |
}
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
public void updateStatus(final SQLTable table, final SQLTable tableElt, final int id) {
|
|
|
222 |
SQLRowValues rowVals = new SQLRowValues(tableElt);
|
|
|
223 |
rowVals.put("ID_DEMANDE_ACHAT_ELEMENT", null);
|
|
|
224 |
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
|
|
|
225 |
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
|
|
226 |
|
|
|
227 |
@Override
|
|
|
228 |
public SQLSelect transformChecked(SQLSelect input) {
|
|
|
229 |
|
|
|
230 |
Where w = new Where(tableElt.getField("ID_" + table.getName()), "=", id);
|
|
|
231 |
w = w.and(new Where(tableElt.getField("ID_DEMANDE_ACHAT_ELEMENT"), "!=", (Object) null));
|
|
|
232 |
w = w.and(new Where(tableElt.getField("ID_DEMANDE_ACHAT_ELEMENT"), ">", 1));
|
|
|
233 |
input.setWhere(w);
|
|
|
234 |
|
|
|
235 |
return input;
|
|
|
236 |
}
|
|
|
237 |
});
|
|
|
238 |
|
|
|
239 |
List<SQLRowValues> result = fetcher.fetch();
|
|
|
240 |
List<Integer> ids = new ArrayList<Integer>();
|
|
|
241 |
for (SQLRowValues sqlRowValues : result) {
|
|
|
242 |
ids.add(sqlRowValues.getForeignID("ID_DEMANDE_ACHAT_ELEMENT"));
|
|
|
243 |
}
|
|
|
244 |
updateAllStatus(ids);
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
private void updateAllStatus(final List<Integer> ids) {
|
|
|
248 |
|
|
|
249 |
SQLRowValues rowVals = new SQLRowValues(getTable());
|
|
|
250 |
rowVals.put("QTE", null);
|
149 |
ilm |
251 |
rowVals.put("QTE_UNITAIRE", null);
|
144 |
ilm |
252 |
rowVals.put("ID_ETAT_DEMANDE_ACHAT_ELEMENT", null);
|
|
|
253 |
|
|
|
254 |
final List<String> refTable = Arrays.asList("COMMANDE_ELEMENT", "DEMANDE_PRIX_ELEMENT", "BON_RECEPTION_ELEMENT");
|
|
|
255 |
for (String tableName : refTable) {
|
|
|
256 |
SQLRowValues rowValsRef = new SQLRowValues(getTable().getTable(tableName));
|
|
|
257 |
rowValsRef.put("QTE", null);
|
149 |
ilm |
258 |
rowValsRef.put("PA_HT", null);
|
144 |
ilm |
259 |
rowValsRef.put("ID_DEMANDE_ACHAT_ELEMENT", rowVals);
|
|
|
260 |
rowValsRef.put("QTE_UNITAIRE", null);
|
|
|
261 |
rowValsRef.put("ID_" + tableName.replaceAll("_ELEMENT", ""), null);
|
|
|
262 |
}
|
|
|
263 |
|
|
|
264 |
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
|
|
|
265 |
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
|
|
266 |
|
|
|
267 |
@Override
|
|
|
268 |
public SQLSelect transformChecked(SQLSelect input) {
|
|
|
269 |
|
|
|
270 |
input.setWhere(new Where(input.getTable("DEMANDE_ACHAT_ELEMENT").getKey(), ids));
|
|
|
271 |
|
|
|
272 |
return input;
|
|
|
273 |
}
|
|
|
274 |
});
|
|
|
275 |
final List<SQLRowValues> result = fetcher.fetch();
|
|
|
276 |
for (SQLRowValues sqlRowValues : result) {
|
|
|
277 |
updateStatus(sqlRowValues);
|
|
|
278 |
}
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
private void updateStatus(SQLRowValues rowValsDmd) {
|
|
|
282 |
Collection<SQLRowValues> rowValsBR = rowValsDmd.getReferentRows(getTable().getTable("BON_RECEPTION_ELEMENT"));
|
|
|
283 |
int newStatus = EtatDemandeAchatItemSQLElement.EN_ATTENTE;
|
|
|
284 |
final SQLRowValues createEmptyUpdateRow = rowValsDmd.createEmptyUpdateRow();
|
|
|
285 |
if (!rowValsBR.isEmpty()) {
|
|
|
286 |
int qte = 0;
|
|
|
287 |
int idBR = 1;
|
149 |
ilm |
288 |
BigDecimal prix = BigDecimal.ZERO;
|
144 |
ilm |
289 |
for (SQLRowValues sqlRowValues : rowValsBR) {
|
|
|
290 |
qte += sqlRowValues.getInt("QTE");
|
|
|
291 |
idBR = sqlRowValues.getForeignID("ID_BON_RECEPTION");
|
149 |
ilm |
292 |
prix = sqlRowValues.getBigDecimal("PA_HT");
|
144 |
ilm |
293 |
}
|
|
|
294 |
if (qte > 0) {
|
|
|
295 |
createEmptyUpdateRow.put("ID_BON_RECEPTION", idBR);
|
|
|
296 |
createEmptyUpdateRow.put("QTE_RECUE", qte);
|
149 |
ilm |
297 |
createEmptyUpdateRow.put("P_HT", prix);
|
|
|
298 |
createEmptyUpdateRow.put("T_HT", prix.multiply(rowValsDmd.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(rowValsDmd.getInt("QTE")))));
|
144 |
ilm |
299 |
if (qte >= rowValsDmd.getInt("QTE")) {
|
|
|
300 |
newStatus = EtatDemandeAchatItemSQLElement.RECPETION;
|
|
|
301 |
} else {
|
|
|
302 |
newStatus = EtatDemandeAchatItemSQLElement.RECPETION_PARTIEL;
|
|
|
303 |
}
|
|
|
304 |
}
|
|
|
305 |
} else {
|
|
|
306 |
Collection<SQLRowValues> rowValsCmd = rowValsDmd.getReferentRows(getTable().getTable("COMMANDE_ELEMENT"));
|
|
|
307 |
if (!rowValsCmd.isEmpty()) {
|
149 |
ilm |
308 |
final SQLRowValues next = rowValsCmd.iterator().next();
|
|
|
309 |
createEmptyUpdateRow.put("ID_COMMANDE", next.getForeignID("ID_COMMANDE"));
|
|
|
310 |
createEmptyUpdateRow.put("P_HT", next.getBigDecimal("PA_HT"));
|
|
|
311 |
createEmptyUpdateRow.put("T_HT", next.getBigDecimal("PA_HT").multiply(rowValsDmd.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(rowValsDmd.getInt("QTE")))));
|
144 |
ilm |
312 |
newStatus = EtatDemandeAchatItemSQLElement.COMMANDE;
|
|
|
313 |
} else {
|
|
|
314 |
Collection<SQLRowValues> rowValsDmdElt = rowValsDmd.getReferentRows(getTable().getTable("DEMANDE_PRIX_ELEMENT"));
|
|
|
315 |
if (!rowValsDmdElt.isEmpty()) {
|
|
|
316 |
newStatus = EtatDemandeAchatItemSQLElement.DEMANDE;
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
}
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
// if (newStatus != rowValsDmd.getForeignID("ID_ETAT_DEMANDE_ACHAT_ELEMENT")) {
|
|
|
323 |
try {
|
|
|
324 |
|
|
|
325 |
createEmptyUpdateRow.put("ID_ETAT_DEMANDE_ACHAT_ELEMENT", newStatus).commit();
|
|
|
326 |
} catch (SQLException e) {
|
|
|
327 |
ExceptionHandler.handle("Erreur lors la mise à jour de l'état de la demande d'achat [" + rowValsDmd.getID() + "]", e);
|
|
|
328 |
}
|
|
|
329 |
// }
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
@Override
|
|
|
333 |
protected List<String> getListFields() {
|
|
|
334 |
final List<String> l = new ArrayList<String>();
|
149 |
ilm |
335 |
l.add("DATE");
|
144 |
ilm |
336 |
l.add("REVISION");
|
|
|
337 |
l.add("CODE");
|
|
|
338 |
l.add("NOM");
|
149 |
ilm |
339 |
l.add("IMPORT");
|
|
|
340 |
l.add("REPRISE");
|
144 |
ilm |
341 |
l.add("QTE_UNITAIRE");
|
|
|
342 |
l.add("ID_UNITE_VENTE");
|
149 |
ilm |
343 |
l.add("P_HT");
|
144 |
ilm |
344 |
l.add("QTE");
|
149 |
ilm |
345 |
l.add("T_HT");
|
144 |
ilm |
346 |
l.add("ID_FABRICANT");
|
|
|
347 |
l.add("ID_FOURNISSEUR");
|
|
|
348 |
l.add("CODE_SOURCE");
|
|
|
349 |
l.add("NOM_SOURCE");
|
|
|
350 |
l.add("ID_COMMANDE");
|
|
|
351 |
l.add("ID_BON_RECEPTION");
|
|
|
352 |
l.add("QTE_RECUE");
|
|
|
353 |
l.add("ID_ETAT_DEMANDE_ACHAT_ELEMENT");
|
|
|
354 |
return l;
|
|
|
355 |
}
|
|
|
356 |
|
|
|
357 |
@Override
|
|
|
358 |
protected void _initTableSource(SQLTableModelSource res) {
|
|
|
359 |
final SQLTable foreignTable = getTable().getForeignTable("ID_ETAT_DEMANDE_ACHAT_ELEMENT");
|
|
|
360 |
res.init();
|
|
|
361 |
res.getColumn(foreignTable.getField("NOM")).setRenderer(new EtatDemandeAchatRenderer(foreignTable));
|
|
|
362 |
|
149 |
ilm |
363 |
res.getColumn(getTable().getField("P_HT")).setRenderer(new DeviseTableCellRenderer());
|
|
|
364 |
res.getColumn(getTable().getField("T_HT")).setRenderer(new DeviseTableCellRenderer());
|
|
|
365 |
res.getColumn(getTable().getField("QTE_UNITAIRE")).setRenderer(new DeviseTableCellRenderer());
|
144 |
ilm |
366 |
|
149 |
ilm |
367 |
// BaseSQLTableModelColumn dpt = new BaseSQLTableModelColumn("Prix Total", BigDecimal.class)
|
|
|
368 |
// {
|
|
|
369 |
//
|
|
|
370 |
// @Override
|
|
|
371 |
// protected Object show_(SQLRowAccessor r) {
|
|
|
372 |
//
|
|
|
373 |
// if (r.getObject("ID_ARTICLE") != null && !r.isForeignEmpty("ID_ARTICLE")) {
|
|
|
374 |
// SQLRowAccessor rA = r.getForeign("ID_ARTICLE");
|
|
|
375 |
// return rA.getBigDecimal("PA_HT");
|
|
|
376 |
// } else {
|
|
|
377 |
// return null;
|
|
|
378 |
// }
|
|
|
379 |
// }
|
|
|
380 |
//
|
|
|
381 |
// @Override
|
|
|
382 |
// public Set<FieldPath> getPaths() {
|
|
|
383 |
// Path p = new Path(getTable());
|
|
|
384 |
// final SQLTable clientT = getTable().getForeignTable("ID_ARTICLE");
|
|
|
385 |
// p = p.add(clientT);
|
|
|
386 |
// return CollectionUtils.createSet(new FieldPath(p, "PA_HT"));
|
|
|
387 |
// }
|
|
|
388 |
// };
|
|
|
389 |
//
|
|
|
390 |
// res.getColumns().add(dpt);
|
144 |
ilm |
391 |
|
|
|
392 |
super._initTableSource(res);
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
// @Override
|
|
|
396 |
// public Set<String> getReadOnlyFields() {
|
|
|
397 |
// Set<String> s = new HashSet<String>(super.getReadOnlyFields());
|
|
|
398 |
// s.add("NUMERO_CARTE");
|
|
|
399 |
// return s;
|
|
|
400 |
// }
|
|
|
401 |
|
|
|
402 |
@Override
|
|
|
403 |
protected List<String> getComboFields() {
|
|
|
404 |
final List<String> l = new ArrayList<String>();
|
149 |
ilm |
405 |
if (getTable().contains("ID_AFFAIRE")) {
|
|
|
406 |
l.add("ID_AFFAIRE");
|
|
|
407 |
}
|
|
|
408 |
l.add("DATE");
|
|
|
409 |
l.add("REVISION");
|
|
|
410 |
l.add("CODE");
|
|
|
411 |
l.add("NOM");
|
|
|
412 |
|
144 |
ilm |
413 |
return l;
|
|
|
414 |
}
|
|
|
415 |
|
|
|
416 |
@Override
|
|
|
417 |
public ListMap<String, String> getShowAs() {
|
|
|
418 |
return ListMap.singleton(null, "CODE", "NOM");
|
|
|
419 |
}
|
|
|
420 |
|
|
|
421 |
@Override
|
|
|
422 |
public SQLComponent createComponent() {
|
|
|
423 |
return new DemandeAchatItemSQLComponent(this);
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
@Override
|
|
|
427 |
protected String createCode() {
|
156 |
ilm |
428 |
return createCodeOfPackage() + ".demande.achat";
|
144 |
ilm |
429 |
}
|
|
|
430 |
|
|
|
431 |
}
|