18 |
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.order.element;
|
|
|
15 |
|
94 |
ilm |
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
|
|
17 |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
|
|
|
18 |
import org.openconcerto.erp.core.common.component.TransfertGroupSQLComponent;
|
18 |
ilm |
19 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
94 |
ilm |
20 |
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent;
|
|
|
21 |
import org.openconcerto.erp.core.sales.account.VenteFactureSoldeSQLComponent;
|
18 |
ilm |
22 |
import org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent;
|
94 |
ilm |
23 |
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
|
93 |
ilm |
24 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient;
|
174 |
ilm |
25 |
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
|
|
|
26 |
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
|
|
|
27 |
import org.openconcerto.erp.core.sales.product.model.ProductHelper;
|
142 |
ilm |
28 |
import org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent;
|
19 |
ilm |
29 |
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
|
156 |
ilm |
30 |
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
|
94 |
ilm |
31 |
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
|
93 |
ilm |
32 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
18 |
ilm |
33 |
import org.openconcerto.sql.Configuration;
|
|
|
34 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
35 |
import org.openconcerto.sql.element.SQLElement;
|
142 |
ilm |
36 |
import org.openconcerto.sql.element.SQLElementLink.LinkType;
|
132 |
ilm |
37 |
import org.openconcerto.sql.element.SQLElementLinksSetup;
|
90 |
ilm |
38 |
import org.openconcerto.sql.element.TreesOfSQLRows;
|
93 |
ilm |
39 |
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
|
|
|
40 |
import org.openconcerto.sql.model.SQLDataSource;
|
19 |
ilm |
41 |
import org.openconcerto.sql.model.SQLInjector;
|
|
|
42 |
import org.openconcerto.sql.model.SQLRow;
|
94 |
ilm |
43 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
93 |
ilm |
44 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
19 |
ilm |
45 |
import org.openconcerto.sql.model.SQLRowValues;
|
93 |
ilm |
46 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
83 |
ilm |
47 |
import org.openconcerto.sql.model.SQLSelect;
|
142 |
ilm |
48 |
import org.openconcerto.sql.model.SQLSelectJoin;
|
19 |
ilm |
49 |
import org.openconcerto.sql.model.SQLTable;
|
83 |
ilm |
50 |
import org.openconcerto.sql.model.Where;
|
93 |
ilm |
51 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
|
|
52 |
import org.openconcerto.sql.request.UpdateBuilder;
|
|
|
53 |
import org.openconcerto.sql.utils.SQLUtils;
|
144 |
ilm |
54 |
import org.openconcerto.sql.view.EditFrame;
|
180 |
ilm |
55 |
import org.openconcerto.sql.view.EditPanel;
|
93 |
ilm |
56 |
import org.openconcerto.sql.view.list.IListe;
|
|
|
57 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
94 |
ilm |
58 |
import org.openconcerto.sql.view.list.RowAction;
|
93 |
ilm |
59 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
|
|
60 |
import org.openconcerto.sql.view.list.SQLTableModelColumn;
|
142 |
ilm |
61 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
93 |
ilm |
62 |
import org.openconcerto.utils.CompareUtils;
|
90 |
ilm |
63 |
import org.openconcerto.utils.DecimalUtils;
|
93 |
ilm |
64 |
import org.openconcerto.utils.ExceptionHandler;
|
83 |
ilm |
65 |
import org.openconcerto.utils.ListMap;
|
94 |
ilm |
66 |
import org.openconcerto.utils.NumberUtils;
|
93 |
ilm |
67 |
import org.openconcerto.utils.cc.ITransformer;
|
18 |
ilm |
68 |
|
142 |
ilm |
69 |
import java.awt.Component;
|
|
|
70 |
import java.awt.event.ActionEvent;
|
|
|
71 |
import java.io.IOException;
|
|
|
72 |
import java.math.BigDecimal;
|
|
|
73 |
import java.math.RoundingMode;
|
|
|
74 |
import java.sql.SQLException;
|
|
|
75 |
import java.util.ArrayList;
|
|
|
76 |
import java.util.Arrays;
|
|
|
77 |
import java.util.Collection;
|
|
|
78 |
import java.util.HashSet;
|
|
|
79 |
import java.util.List;
|
|
|
80 |
import java.util.Map;
|
|
|
81 |
import java.util.Set;
|
|
|
82 |
|
|
|
83 |
import javax.swing.AbstractAction;
|
|
|
84 |
import javax.swing.JLabel;
|
|
|
85 |
import javax.swing.JTable;
|
|
|
86 |
import javax.swing.SwingUtilities;
|
|
|
87 |
import javax.swing.table.DefaultTableCellRenderer;
|
|
|
88 |
|
|
|
89 |
import org.apache.commons.dbutils.ResultSetHandler;
|
|
|
90 |
import org.apache.commons.dbutils.handlers.ArrayListHandler;
|
|
|
91 |
|
18 |
ilm |
92 |
public class CommandeClientSQLElement extends ComptaSQLConfElement {
|
|
|
93 |
|
|
|
94 |
public CommandeClientSQLElement() {
|
|
|
95 |
super("COMMANDE_CLIENT", "une commande client", "commandes clients");
|
93 |
ilm |
96 |
|
|
|
97 |
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
|
|
|
98 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ORDER_PACKAGING_MANAGEMENT, true)) {
|
|
|
99 |
|
|
|
100 |
for (final EtatCommandeClient etat : EtatCommandeClient.values()) {
|
|
|
101 |
|
|
|
102 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction(etat.getTranslation()) {
|
|
|
103 |
|
|
|
104 |
@Override
|
|
|
105 |
public void actionPerformed(ActionEvent e) {
|
|
|
106 |
changeStateOfRows(IListe.get(e).getSelectedRows(), etat);
|
|
|
107 |
}
|
|
|
108 |
}, false);
|
|
|
109 |
action.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
|
|
110 |
action.setPath(Arrays.asList("Etat", "Etat", "Etat"));
|
|
|
111 |
getRowActions().add(action);
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
PredicateRowAction actionTransfertBL = new PredicateRowAction(new AbstractAction("Transfert automatique vers BL") {
|
|
|
115 |
|
|
|
116 |
@Override
|
|
|
117 |
public void actionPerformed(ActionEvent e) {
|
|
|
118 |
TransfertCommandeAutoUtils transfert = new TransfertCommandeAutoUtils(getTable());
|
|
|
119 |
transfert.transfertMultiBL(IListe.get(e).getSelectedRows());
|
|
|
120 |
}
|
|
|
121 |
}, false);
|
|
|
122 |
actionTransfertBL.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
|
|
123 |
getRowActions().add(actionTransfertBL);
|
|
|
124 |
|
|
|
125 |
PredicateRowAction actionStock = new PredicateRowAction(new AbstractAction("Vérification des stocks") {
|
|
|
126 |
|
|
|
127 |
@Override
|
|
|
128 |
public void actionPerformed(ActionEvent e) {
|
|
|
129 |
new Thread("Check Commande To Ship") {
|
|
|
130 |
public void run() {
|
|
|
131 |
try {
|
|
|
132 |
checkCommandeToShip();
|
|
|
133 |
} catch (Exception e) {
|
|
|
134 |
ExceptionHandler.handle("Erreur pendant la vérification du statut des commandes", e);
|
|
|
135 |
}
|
|
|
136 |
}
|
|
|
137 |
}.start();
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
}, false);
|
|
|
141 |
actionStock.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
|
|
142 |
getRowActions().add(actionStock);
|
|
|
143 |
|
|
|
144 |
PredicateRowAction actionFacture = new PredicateRowAction(new AbstractAction("Transfert automatique en facture") {
|
|
|
145 |
|
|
|
146 |
@Override
|
|
|
147 |
public void actionPerformed(ActionEvent e) {
|
|
|
148 |
TransfertCommandeAutoUtils transfert = new TransfertCommandeAutoUtils(getTable());
|
|
|
149 |
transfert.transfertFacture(IListe.get(e).getSelectedRows());
|
|
|
150 |
}
|
|
|
151 |
}, false);
|
|
|
152 |
actionFacture.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
|
|
153 |
getRowActions().add(actionFacture);
|
|
|
154 |
|
|
|
155 |
}
|
94 |
ilm |
156 |
|
|
|
157 |
final List<RowAction> allowedActions = new ArrayList<RowAction>();
|
|
|
158 |
// Transfert vers facture
|
|
|
159 |
PredicateRowAction bonAction = new PredicateRowAction(new AbstractAction() {
|
|
|
160 |
public void actionPerformed(ActionEvent e) {
|
|
|
161 |
transfertBonLivraisonClient(IListe.get(e).getSelectedRows());
|
|
|
162 |
}
|
151 |
ilm |
163 |
}, true, "sales.order.create.deliverynote");
|
94 |
ilm |
164 |
|
|
|
165 |
// Transfert vers facture
|
|
|
166 |
RowAction factureAction = new RowAction(new AbstractAction() {
|
|
|
167 |
public void actionPerformed(ActionEvent e) {
|
|
|
168 |
transfertFactureClient(IListe.get(e).getSelectedRows());
|
|
|
169 |
}
|
151 |
ilm |
170 |
}, true, "sales.order.create.invoice") {
|
94 |
ilm |
171 |
|
|
|
172 |
@Override
|
|
|
173 |
public boolean enabledFor(List<SQLRowValues> selection) {
|
|
|
174 |
if (selection.isEmpty()) {
|
|
|
175 |
return false;
|
|
|
176 |
} else if (selection.size() > 1) {
|
|
|
177 |
return true;
|
|
|
178 |
} else {
|
|
|
179 |
BigDecimal d = getAvancement(selection.get(0));
|
|
|
180 |
return d.signum() == 0;
|
|
|
181 |
}
|
|
|
182 |
}
|
|
|
183 |
};
|
|
|
184 |
|
|
|
185 |
// Transfert vers facture intermédiaire
|
|
|
186 |
RowAction acompteAction = new RowAction(new AbstractAction("Créer une facture intermédiaire") {
|
|
|
187 |
public void actionPerformed(ActionEvent e) {
|
|
|
188 |
transfertAcompteClient(IListe.get(e).getSelectedRows());
|
|
|
189 |
}
|
|
|
190 |
}, false, "sales.order.create.account") {
|
|
|
191 |
BigDecimal cent = BigDecimal.ONE.movePointRight(2);
|
|
|
192 |
|
|
|
193 |
@Override
|
|
|
194 |
public boolean enabledFor(List<SQLRowValues> selection) {
|
|
|
195 |
if (selection.isEmpty() || selection.size() > 1) {
|
|
|
196 |
return false;
|
|
|
197 |
} else {
|
|
|
198 |
BigDecimal d = getAvancement(selection.get(0));
|
|
|
199 |
return NumberUtils.compare(d, cent) != 0;
|
|
|
200 |
}
|
|
|
201 |
}
|
|
|
202 |
};
|
|
|
203 |
|
|
|
204 |
// Transfert vers facture solde
|
|
|
205 |
RowAction soldeAction = new RowAction(new AbstractAction("Facturer le solde") {
|
|
|
206 |
public void actionPerformed(ActionEvent e) {
|
|
|
207 |
transfertSoldeClient(IListe.get(e).getSelectedRows());
|
|
|
208 |
}
|
|
|
209 |
}, false, "sales.order.create.account.solde") {
|
|
|
210 |
BigDecimal cent = BigDecimal.ONE.movePointRight(2);
|
|
|
211 |
|
|
|
212 |
@Override
|
|
|
213 |
public boolean enabledFor(List<SQLRowValues> selection) {
|
|
|
214 |
if (selection.isEmpty() || selection.size() > 1) {
|
|
|
215 |
return false;
|
|
|
216 |
} else {
|
|
|
217 |
BigDecimal d = getAvancement(selection.get(0));
|
|
|
218 |
return NumberUtils.compare(d, cent) != 0 && NumberUtils.compare(d, BigDecimal.ZERO) != 0;
|
|
|
219 |
}
|
|
|
220 |
}
|
|
|
221 |
};
|
|
|
222 |
|
|
|
223 |
// Transfert vers commande
|
|
|
224 |
PredicateRowAction cmdAction = new PredicateRowAction(new AbstractAction() {
|
|
|
225 |
public void actionPerformed(ActionEvent e) {
|
|
|
226 |
final int selectedId = IListe.get(e).getSelectedId();
|
|
|
227 |
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
|
|
|
228 |
|
|
|
229 |
@Override
|
|
|
230 |
public void run() {
|
|
|
231 |
final CommandeClientSQLElement elt = (CommandeClientSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
|
142 |
ilm |
232 |
elt.transfertCommande(selectedId, true);
|
94 |
ilm |
233 |
|
|
|
234 |
}
|
|
|
235 |
});
|
|
|
236 |
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
}, false, "sales.order.create.supplier.order");
|
|
|
240 |
|
|
|
241 |
cmdAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
242 |
|
|
|
243 |
bonAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
244 |
|
|
|
245 |
MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(CommandeClientXmlSheet.class);
|
|
|
246 |
mouseSheetXmlListeListener.setGenerateHeader(true);
|
|
|
247 |
mouseSheetXmlListeListener.setShowHeader(true);
|
|
|
248 |
|
180 |
ilm |
249 |
// Dupliquer
|
|
|
250 |
RowAction cloneAction = getCloneAction();
|
|
|
251 |
allowedActions.add(cloneAction);
|
|
|
252 |
|
94 |
ilm |
253 |
allowedActions.add(bonAction);
|
|
|
254 |
allowedActions.add(factureAction);
|
|
|
255 |
allowedActions.add(acompteAction);
|
|
|
256 |
allowedActions.add(soldeAction);
|
|
|
257 |
allowedActions.add(cmdAction);
|
|
|
258 |
allowedActions.addAll(mouseSheetXmlListeListener.getRowActions());
|
|
|
259 |
getRowActions().addAll(allowedActions);
|
18 |
ilm |
260 |
}
|
|
|
261 |
|
180 |
ilm |
262 |
private boolean chiffrageEditableInUI = true;
|
|
|
263 |
|
|
|
264 |
public void setChiffrageEditableInUI(boolean chiffrageEditableInUI) {
|
|
|
265 |
this.chiffrageEditableInUI = chiffrageEditableInUI;
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
public boolean isChiffrageEditableInUI() {
|
|
|
269 |
return this.chiffrageEditableInUI;
|
|
|
270 |
}
|
|
|
271 |
|
132 |
ilm |
272 |
@Override
|
|
|
273 |
protected void setupLinks(SQLElementLinksSetup links) {
|
|
|
274 |
super.setupLinks(links);
|
|
|
275 |
if (getTable().contains("ID_ADRESSE")) {
|
|
|
276 |
links.get("ID_ADRESSE").setType(LinkType.ASSOCIATION);
|
|
|
277 |
}
|
142 |
ilm |
278 |
if (getTable().contains("ID_ADRESSE_FACT")) {
|
|
|
279 |
links.get("ID_ADRESSE_FACT").setType(LinkType.ASSOCIATION);
|
|
|
280 |
}
|
132 |
ilm |
281 |
if (getTable().contains("ID_ADRESSE_LIVRAISON")) {
|
|
|
282 |
links.get("ID_ADRESSE_LIVRAISON").setType(LinkType.ASSOCIATION);
|
|
|
283 |
}
|
|
|
284 |
}
|
|
|
285 |
|
93 |
ilm |
286 |
public SQLRow getNextCommandeToPrepare() {
|
|
|
287 |
final SQLTable tableCmd = getTable();
|
|
|
288 |
SQLSelect sel = new SQLSelect();
|
|
|
289 |
sel.addSelect(tableCmd.getKey());
|
|
|
290 |
sel.addSelect(tableCmd.getField("NUMERO"));
|
|
|
291 |
sel.addSelect(tableCmd.getField("DATE"));
|
|
|
292 |
sel.addSelect(tableCmd.getField("T_HT"));
|
|
|
293 |
sel.addSelect(tableCmd.getField("T_TVA"));
|
|
|
294 |
sel.addSelect(tableCmd.getField("T_TTC"));
|
|
|
295 |
sel.addSelect(tableCmd.getField("PORT_HT"));
|
|
|
296 |
sel.addSelect(tableCmd.getField("REMISE_HT"));
|
|
|
297 |
sel.addSelect(tableCmd.getField("ID_TAXE_PORT"));
|
|
|
298 |
sel.addSelect(tableCmd.getField("ID_CLIENT"));
|
|
|
299 |
Where w = new Where(tableCmd.getField("ETAT_COMMANDE"), "=", EtatCommandeClient.A_PREPARER.getId());
|
|
|
300 |
sel.setWhere(w);
|
|
|
301 |
sel.clearOrder();
|
|
|
302 |
sel.addFieldOrder(sel.getAlias(tableCmd.getField("DATE")));
|
|
|
303 |
sel.addFieldOrder(sel.getAlias(tableCmd.getField("T_HT")));
|
|
|
304 |
|
|
|
305 |
List<SQLRow> result = SQLRowListRSH.execute(sel);
|
|
|
306 |
if (result == null || result.size() == 0) {
|
|
|
307 |
return null;
|
|
|
308 |
} else {
|
|
|
309 |
return result.get(0);
|
|
|
310 |
}
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
public int getNbCommandeAPreparer() {
|
|
|
314 |
final SQLTable tableCmd = getTable();
|
|
|
315 |
SQLSelect sel = new SQLSelect();
|
|
|
316 |
sel.addSelect(tableCmd.getKey(), "COUNT");
|
|
|
317 |
Where w = new Where(tableCmd.getField("ETAT_COMMANDE"), "=", EtatCommandeClient.A_PREPARER.getId());
|
|
|
318 |
sel.setWhere(w);
|
|
|
319 |
|
|
|
320 |
Object r = getTable().getDBSystemRoot().getDataSource().executeScalar(sel.asString());
|
|
|
321 |
int nb = 0;
|
|
|
322 |
if (r != null) {
|
|
|
323 |
nb = ((Number) r).intValue();
|
|
|
324 |
}
|
|
|
325 |
return nb;
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
public void checkCommandeToShip() throws Exception {
|
|
|
329 |
assert !SwingUtilities.isEventDispatchThread();
|
|
|
330 |
|
|
|
331 |
SQLUtils.executeAtomic(getTable().getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
|
|
|
332 |
@Override
|
|
|
333 |
public Object handle(final SQLDataSource ds) throws SQLException, IOException {
|
|
|
334 |
final SQLTable tableCmd = getTable();
|
|
|
335 |
|
|
|
336 |
SQLRowValues rowVals = new SQLRowValues(tableCmd);
|
|
|
337 |
rowVals.put(tableCmd.getKey().getName(), null);
|
|
|
338 |
rowVals.put("NUMERO", null);
|
|
|
339 |
|
|
|
340 |
final SQLTable tableCmdElt = tableCmd.getTable("COMMANDE_CLIENT_ELEMENT");
|
|
|
341 |
SQLRowValues rowValsElt = new SQLRowValues(tableCmdElt);
|
|
|
342 |
rowValsElt.put("QTE", null);
|
156 |
ilm |
343 |
rowValsElt.put("ID_DEPOT_STOCK", null);
|
93 |
ilm |
344 |
rowValsElt.put("QTE_UNITAIRE", null);
|
|
|
345 |
rowValsElt.put("ID_COMMANDE_CLIENT", rowVals);
|
|
|
346 |
|
|
|
347 |
SQLRowValues rowValsArt = new SQLRowValues(tableCmd.getTable("ARTICLE"));
|
156 |
ilm |
348 |
SQLRowValues rowValsStock = new SQLRowValues(tableCmd.getTable("STOCK"));
|
|
|
349 |
rowValsStock.putNulls("QTE_REEL", "QTE_TH");
|
|
|
350 |
rowValsStock.put("ID_DEPOT_STOCK", null);
|
|
|
351 |
rowValsStock.put("ID_ARTICLE", rowValsArt);
|
|
|
352 |
rowValsArt.put("ID_DEPOT_STOCK", null);
|
93 |
ilm |
353 |
rowValsElt.put("ID_ARTICLE", rowValsArt);
|
|
|
354 |
|
|
|
355 |
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
|
|
|
356 |
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
|
|
357 |
|
|
|
358 |
@Override
|
|
|
359 |
public SQLSelect transformChecked(SQLSelect input) {
|
|
|
360 |
Where w = new Where(input.getAlias(tableCmd).getField("ETAT_COMMANDE"), "=", EtatCommandeClient.A_PREPARER.getId());
|
|
|
361 |
w = w.or(new Where(input.getAlias(tableCmd).getField("ETAT_COMMANDE"), "=", EtatCommandeClient.RUPTURE.getId()));
|
|
|
362 |
input.setWhere(w);
|
|
|
363 |
// ORDER BY ETAT COMMANDE et T_HT pour mettre en priorité les ruptures de
|
|
|
364 |
// stock et les commandes les plus chers
|
|
|
365 |
input.clearOrder();
|
|
|
366 |
input.addFieldOrder(input.getAlias(tableCmd.getField("ETAT_COMMANDE")));
|
|
|
367 |
input.addFieldOrder(input.getAlias(tableCmd.getField("T_HT")));
|
|
|
368 |
System.err.println(input.asString());
|
|
|
369 |
return input;
|
|
|
370 |
}
|
|
|
371 |
});
|
|
|
372 |
|
|
|
373 |
List<SQLRowValues> result = fetcher.fetch();
|
|
|
374 |
List<Integer> cmdStockOK = new ArrayList<Integer>();
|
|
|
375 |
List<Integer> cmdNoStock = new ArrayList<Integer>();
|
|
|
376 |
|
|
|
377 |
// Stock utilisé par les commandes à préparer
|
|
|
378 |
StockCommande stockGlobalUsed = new StockCommande();
|
|
|
379 |
for (int i = result.size() - 1; i >= 0; i--) {
|
|
|
380 |
SQLRowValues sqlRowValues = result.get(i);
|
|
|
381 |
boolean inStock = true;
|
|
|
382 |
|
|
|
383 |
// Stock utilisé par la commande actuelle
|
|
|
384 |
StockCommande stockCmd = new StockCommande();
|
|
|
385 |
for (SQLRowValues item : sqlRowValues.getReferentRows(tableCmdElt)) {
|
|
|
386 |
|
156 |
ilm |
387 |
if (item.getObject("ID_ARTICLE") != null && !item.isForeignEmpty("ID_ARTICLE")) {
|
|
|
388 |
final int foreignID = item.getForeignID("ID_ARTICLE");
|
93 |
ilm |
389 |
|
156 |
ilm |
390 |
// Stock = stock actuel dans la base - stock utilisé par les commandes
|
|
|
391 |
// déja testées -
|
|
|
392 |
// stock utilisé par la commande en cours (si 2 fois le meme article)
|
|
|
393 |
BigDecimal stock = BigDecimal.ZERO;
|
|
|
394 |
SQLRowAccessor rowStock = StockSQLElement.getStockFetched(item);
|
|
|
395 |
if (rowStock != null) {
|
|
|
396 |
stock = new BigDecimal(rowStock.getFloat("QTE_REEL"));
|
|
|
397 |
}
|
|
|
398 |
stock = stock.subtract(stockCmd.getQty(foreignID)).subtract(stockGlobalUsed.getQty(foreignID));
|
93 |
ilm |
399 |
|
156 |
ilm |
400 |
BigDecimal needQty = item.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(item.getInt("QTE")), DecimalUtils.HIGH_PRECISION);
|
93 |
ilm |
401 |
|
156 |
ilm |
402 |
stockCmd.addQty(foreignID, needQty);
|
93 |
ilm |
403 |
|
156 |
ilm |
404 |
inStock = CompareUtils.compare(stock, needQty) >= 0;
|
|
|
405 |
|
|
|
406 |
if (!inStock) {
|
|
|
407 |
break;
|
|
|
408 |
}
|
93 |
ilm |
409 |
}
|
|
|
410 |
}
|
|
|
411 |
|
|
|
412 |
if (inStock) {
|
|
|
413 |
Map<Integer, BigDecimal> m = stockCmd.getMap();
|
|
|
414 |
for (Integer id : m.keySet()) {
|
|
|
415 |
stockGlobalUsed.addQty(id, m.get(id));
|
|
|
416 |
}
|
|
|
417 |
|
|
|
418 |
cmdStockOK.add(sqlRowValues.getID());
|
|
|
419 |
} else {
|
|
|
420 |
cmdNoStock.add(sqlRowValues.getID());
|
|
|
421 |
}
|
|
|
422 |
}
|
|
|
423 |
|
|
|
424 |
List<String> reqs = new ArrayList<String>(2);
|
|
|
425 |
|
|
|
426 |
if (cmdStockOK.size() > 0) {
|
|
|
427 |
UpdateBuilder builderStockOK = new UpdateBuilder(tableCmd);
|
|
|
428 |
builderStockOK.setObject("ETAT_COMMANDE", EtatCommandeClient.A_PREPARER.getId());
|
|
|
429 |
builderStockOK.setWhere(new Where(getTable().getKey(), cmdStockOK));
|
|
|
430 |
reqs.add(builderStockOK.asString());
|
|
|
431 |
}
|
|
|
432 |
|
|
|
433 |
if (cmdNoStock.size() > 0) {
|
|
|
434 |
UpdateBuilder builderNoStock = new UpdateBuilder(tableCmd);
|
|
|
435 |
builderNoStock.setObject("ETAT_COMMANDE", EtatCommandeClient.RUPTURE.getId());
|
|
|
436 |
builderNoStock.setWhere(new Where(getTable().getKey(), cmdNoStock));
|
|
|
437 |
reqs.add(builderNoStock.asString());
|
|
|
438 |
}
|
|
|
439 |
|
|
|
440 |
if (reqs.size() > 0) {
|
|
|
441 |
List<? extends ResultSetHandler> handlers = new ArrayList<ResultSetHandler>(reqs.size());
|
|
|
442 |
for (String s : reqs) {
|
|
|
443 |
handlers.add(null);
|
|
|
444 |
}
|
|
|
445 |
SQLUtils.executeMultiple(tableCmd.getDBSystemRoot(), reqs, handlers);
|
|
|
446 |
tableCmd.fireTableModified(-1);
|
|
|
447 |
}
|
|
|
448 |
return null;
|
|
|
449 |
}
|
|
|
450 |
});
|
|
|
451 |
|
|
|
452 |
}
|
|
|
453 |
|
|
|
454 |
private void changeStateOfRows(List<SQLRowValues> l, EtatCommandeClient etat) {
|
|
|
455 |
|
|
|
456 |
List<Integer> ids = new ArrayList<Integer>(l.size());
|
|
|
457 |
for (SQLRowValues sqlRowValues : l) {
|
|
|
458 |
ids.add(sqlRowValues.getID());
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
UpdateBuilder builder = new UpdateBuilder(getTable());
|
|
|
462 |
builder.setObject("ETAT_COMMANDE", etat.getId());
|
|
|
463 |
builder.setWhere(new Where(getTable().getKey(), ids));
|
|
|
464 |
|
|
|
465 |
getTable().getDBSystemRoot().getDataSource().execute(builder.asString());
|
|
|
466 |
getTable().fireTableModified(-1);
|
|
|
467 |
}
|
|
|
468 |
|
18 |
ilm |
469 |
/*
|
|
|
470 |
* (non-Javadoc)
|
|
|
471 |
*
|
|
|
472 |
* @see org.openconcerto.devis.BaseSQLElement#getComboFields()
|
|
|
473 |
*/
|
|
|
474 |
protected List<String> getComboFields() {
|
73 |
ilm |
475 |
final List<String> l = new ArrayList<String>();
|
18 |
ilm |
476 |
l.add("NUMERO");
|
|
|
477 |
return l;
|
|
|
478 |
}
|
|
|
479 |
|
|
|
480 |
/*
|
|
|
481 |
* (non-Javadoc)
|
|
|
482 |
*
|
|
|
483 |
* @see org.openconcerto.devis.BaseSQLElement#getListFields()
|
|
|
484 |
*/
|
|
|
485 |
protected List<String> getListFields() {
|
73 |
ilm |
486 |
final List<String> l = new ArrayList<String>();
|
18 |
ilm |
487 |
l.add("NUMERO");
|
|
|
488 |
l.add("DATE");
|
142 |
ilm |
489 |
if (getTable().contains("DATE_LIVRAISON_PREV")) {
|
|
|
490 |
l.add("DATE_LIVRAISON_PREV");
|
|
|
491 |
}
|
18 |
ilm |
492 |
l.add("ID_CLIENT");
|
41 |
ilm |
493 |
l.add("ID_COMMERCIAL");
|
18 |
ilm |
494 |
l.add("T_HT");
|
|
|
495 |
l.add("T_TTC");
|
156 |
ilm |
496 |
if (getTable().getFieldsName().contains("ACOMPTE_COMMANDE")) {
|
|
|
497 |
l.add("ACOMPTE_COMMANDE");
|
|
|
498 |
}
|
18 |
ilm |
499 |
l.add("NOM");
|
|
|
500 |
l.add("INFOS");
|
93 |
ilm |
501 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
|
|
502 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ORDER_PACKAGING_MANAGEMENT, true)) {
|
|
|
503 |
l.add("NUMERO_EXPEDITION");
|
|
|
504 |
l.add("ETAT_COMMANDE");
|
|
|
505 |
}
|
18 |
ilm |
506 |
return l;
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
@Override
|
28 |
ilm |
510 |
public Set<String> getReadOnlyFields() {
|
73 |
ilm |
511 |
final Set<String> s = new HashSet<String>();
|
28 |
ilm |
512 |
s.add("ID_DEVIS");
|
|
|
513 |
return s;
|
|
|
514 |
}
|
|
|
515 |
|
67 |
ilm |
516 |
@Override
|
90 |
ilm |
517 |
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
|
83 |
ilm |
518 |
|
90 |
ilm |
519 |
for (SQLRow row : trees.getRows()) {
|
|
|
520 |
|
|
|
521 |
// Mise à jour des stocks
|
|
|
522 |
SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK");
|
|
|
523 |
SQLSelect sel = new SQLSelect();
|
|
|
524 |
sel.addSelect(eltMvtStock.getTable().getField("ID"));
|
|
|
525 |
Where w = new Where(eltMvtStock.getTable().getField("IDSOURCE"), "=", row.getID());
|
|
|
526 |
Where w2 = new Where(eltMvtStock.getTable().getField("SOURCE"), "=", getTable().getName());
|
|
|
527 |
sel.setWhere(w.and(w2));
|
|
|
528 |
|
|
|
529 |
@SuppressWarnings("rawtypes")
|
|
|
530 |
List l = (List) eltMvtStock.getTable().getBase().getDataSource().execute(sel.asString(), new ArrayListHandler());
|
|
|
531 |
if (l != null) {
|
|
|
532 |
for (int i = 0; i < l.size(); i++) {
|
|
|
533 |
Object[] tmp = (Object[]) l.get(i);
|
|
|
534 |
eltMvtStock.archive(((Number) tmp[0]).intValue());
|
|
|
535 |
}
|
83 |
ilm |
536 |
}
|
|
|
537 |
}
|
90 |
ilm |
538 |
super.archive(trees, cutLinks);
|
83 |
ilm |
539 |
}
|
|
|
540 |
|
|
|
541 |
@Override
|
142 |
ilm |
542 |
protected synchronized void _initTableSource(final SQLTableModelSource source) {
|
|
|
543 |
super._initTableSource(source);
|
73 |
ilm |
544 |
// TODO: refaire un renderer pour les commandes transférées en BL
|
|
|
545 |
// final CommandeClientRenderer rend = CommandeClientRenderer.getInstance();
|
|
|
546 |
// final SQLTableModelColumn col = source.getColumn(getTable().getField("T_HT"));
|
|
|
547 |
// col.setColumnInstaller(new IClosure<TableColumn>() {
|
|
|
548 |
// @Override
|
|
|
549 |
// public void executeChecked(TableColumn input) {
|
|
|
550 |
// input.setCellRenderer(rend);
|
|
|
551 |
// }
|
|
|
552 |
// });
|
93 |
ilm |
553 |
source.init();
|
|
|
554 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
|
|
555 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ORDER_PACKAGING_MANAGEMENT, true)) {
|
|
|
556 |
|
|
|
557 |
SQLTableModelColumn col = source.getColumn(getTable().getField("ETAT_COMMANDE"));
|
|
|
558 |
if (col != null) {
|
|
|
559 |
col.setRenderer(new DefaultTableCellRenderer() {
|
|
|
560 |
|
|
|
561 |
@Override
|
|
|
562 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
|
|
563 |
|
|
|
564 |
JLabel comp = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
|
565 |
if (value != null) {
|
|
|
566 |
final EtatCommandeClient fromID = EtatCommandeClient.fromID((Integer) value);
|
|
|
567 |
if (fromID != null) {
|
|
|
568 |
comp.setText(fromID.getTranslation());
|
|
|
569 |
} else {
|
|
|
570 |
comp.setText("");
|
|
|
571 |
}
|
|
|
572 |
}
|
|
|
573 |
return comp;
|
|
|
574 |
}
|
|
|
575 |
});
|
|
|
576 |
|
|
|
577 |
}
|
|
|
578 |
}
|
67 |
ilm |
579 |
}
|
|
|
580 |
|
18 |
ilm |
581 |
/*
|
|
|
582 |
* (non-Javadoc)
|
|
|
583 |
*
|
|
|
584 |
* @see org.openconcerto.devis.SQLElement#getComponent()
|
|
|
585 |
*/
|
|
|
586 |
public SQLComponent createComponent() {
|
|
|
587 |
return new CommandeClientSQLComponent();
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
/**
|
19 |
ilm |
591 |
* Transfert d'une commande en commande fournisseur
|
|
|
592 |
*
|
|
|
593 |
* @param commandeID
|
|
|
594 |
*/
|
142 |
ilm |
595 |
public void transfertCommande(int commandeID, boolean useCommandeEnCours) {
|
19 |
ilm |
596 |
|
|
|
597 |
SQLElement elt = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT");
|
|
|
598 |
SQLRow rowCmd = getTable().getRow(commandeID);
|
|
|
599 |
List<SQLRow> rows = rowCmd.getReferentRows(elt.getTable());
|
174 |
ilm |
600 |
transfertEltToCommandeF(rows);
|
|
|
601 |
}
|
73 |
ilm |
602 |
|
174 |
ilm |
603 |
public void transfertEltToCommandeF(List<? extends SQLRowAccessor> rowsItems) {
|
|
|
604 |
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
|
|
|
605 |
|
|
|
606 |
@Override
|
|
|
607 |
public void run() {
|
|
|
608 |
ProductHelper helper = new ProductHelper(getTable().getDBRoot());
|
|
|
609 |
List<ProductComponent> productComp = new ArrayList<>();
|
|
|
610 |
helper.fillProductComponent(rowsItems, productComp, 1, 0, 1);
|
|
|
611 |
|
|
|
612 |
List<ProductComponent> leafItems = helper.getChildWithQtyFrom(productComp);
|
|
|
613 |
|
|
|
614 |
final ListMap<SQLRow, SQLRowValues> map = new ListMap<SQLRow, SQLRowValues>();
|
|
|
615 |
final Set<Integer> stockChecked = new HashSet<Integer>();
|
|
|
616 |
for (ProductComponent comp : leafItems) {
|
|
|
617 |
SQLRowAccessor rowArticleFind = comp.getProduct();
|
|
|
618 |
|
|
|
619 |
SQLRow row = rowArticleFind.asRow();
|
|
|
620 |
SQLRowAccessor rowStock = comp.getStock();
|
|
|
621 |
int value = 0;
|
|
|
622 |
if (row.getBoolean("GESTION_STOCK") && !stockChecked.contains(rowStock.getID())) {
|
|
|
623 |
stockChecked.add(rowStock.getID());
|
|
|
624 |
|
|
|
625 |
value = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
|
|
|
626 |
} else if (!row.getBoolean("GESTION_STOCK")) {
|
|
|
627 |
value = comp.getQty().intValue();
|
|
|
628 |
}
|
|
|
629 |
if (value > 0) {
|
|
|
630 |
|
|
|
631 |
SQLInjector inj = SQLInjector.getInjector(row.getTable(), row.getTable().getTable("COMMANDE_ELEMENT"));
|
|
|
632 |
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(row));
|
|
|
633 |
|
|
|
634 |
int qte = 1;
|
|
|
635 |
BigDecimal qteUV = BigDecimal.ONE;
|
|
|
636 |
|
|
|
637 |
if (row.getObject("ID_UNITE_VENTE") != null && row.getForeignID("ID_UNITE_VENTE") != UniteVenteArticleSQLElement.A_LA_PIECE) {
|
|
|
638 |
qteUV = comp.getQty();
|
|
|
639 |
} else {
|
|
|
640 |
qte = comp.getQty().setScale(0, RoundingMode.HALF_UP).intValue();
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
rowValsElt.put("QTE", qte);
|
|
|
644 |
rowValsElt.put("QTE_UNITAIRE", qteUV);
|
|
|
645 |
|
|
|
646 |
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
|
|
|
647 |
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
|
|
|
648 |
rowValsElt.put("T_PA_TTC", ((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)),
|
|
|
649 |
DecimalUtils.HIGH_PRECISION));
|
|
|
650 |
// rowValsElt.put("ID_DEVISE",
|
|
|
651 |
// rowCmd.getForeignRow("ID_TARIF").getForeignID("ID_DEVISE"));
|
|
|
652 |
map.add(rowArticleFind.getForeign("ID_FOURNISSEUR").asRow(), rowValsElt);
|
|
|
653 |
}
|
|
|
654 |
|
156 |
ilm |
655 |
}
|
174 |
ilm |
656 |
MouvementStockSQLElement.createCommandeF(map, null, "");
|
132 |
ilm |
657 |
}
|
174 |
ilm |
658 |
});
|
19 |
ilm |
659 |
}
|
94 |
ilm |
660 |
|
|
|
661 |
/**
|
|
|
662 |
* Transfert en BL
|
|
|
663 |
*
|
|
|
664 |
* @param row
|
|
|
665 |
*/
|
142 |
ilm |
666 |
public void transfertBonLivraisonClient(final List<SQLRowValues> rows) {
|
|
|
667 |
BonDeLivraisonSQLComponent comp = (BonDeLivraisonSQLComponent) TransfertBaseSQLComponent.openTransfertFrame(rows, "BON_DE_LIVRAISON").getSQLComponent();
|
|
|
668 |
final SQLTable tableElt = comp.getElement().getTable().getTable("BON_DE_LIVRAISON_ELEMENT");
|
|
|
669 |
SQLRowValues rowVals = new SQLRowValues(tableElt);
|
|
|
670 |
rowVals.put("QTE_UNITAIRE", null);
|
|
|
671 |
rowVals.put("QTE", null);
|
|
|
672 |
rowVals.put("QTE_LIVREE", null);
|
|
|
673 |
rowVals.put("ID_ARTICLE", null);
|
156 |
ilm |
674 |
rowVals.put("PV_HT", null);
|
|
|
675 |
rowVals.put("ID_COMMANDE_CLIENT_ELEMENT", null);
|
142 |
ilm |
676 |
|
|
|
677 |
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
|
|
|
678 |
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
|
|
679 |
|
|
|
680 |
@Override
|
|
|
681 |
public SQLSelect transformChecked(SQLSelect input) {
|
|
|
682 |
List<Integer> ids = new ArrayList<Integer>(rows.size());
|
|
|
683 |
for (SQLRowValues sqlRowValues : rows) {
|
|
|
684 |
ids.add(sqlRowValues.getID());
|
|
|
685 |
}
|
|
|
686 |
SQLSelectJoin joinBR = input.addJoin("RIGHT", tableElt.getTable("BON_DE_LIVRAISON_ELEMENT").getField("ID_BON_DE_LIVRAISON"));
|
|
|
687 |
SQLSelectJoin joinTR = input.addBackwardJoin("RIGHT", tableElt.getTable("TR_COMMANDE_CLIENT").getField("ID_BON_DE_LIVRAISON"), joinBR.getJoinedTable().getAlias());
|
|
|
688 |
joinTR.setWhere(new Where(joinTR.getJoinedTable().getField("ID_COMMANDE_CLIENT"), ids));
|
|
|
689 |
System.err.println(input.asString());
|
|
|
690 |
return input;
|
|
|
691 |
}
|
|
|
692 |
});
|
156 |
ilm |
693 |
comp.loadQuantity(fetcher.fetch(), "COMMANDE_CLIENT_ELEMENT");
|
142 |
ilm |
694 |
|
94 |
ilm |
695 |
}
|
|
|
696 |
|
|
|
697 |
/**
|
|
|
698 |
* Transfert en Facture
|
|
|
699 |
*
|
|
|
700 |
* @param row
|
|
|
701 |
*/
|
144 |
ilm |
702 |
public EditFrame transfertFactureClient(List<SQLRowValues> rows) {
|
|
|
703 |
return TransfertBaseSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE");
|
94 |
ilm |
704 |
|
|
|
705 |
}
|
|
|
706 |
|
|
|
707 |
/**
|
|
|
708 |
* Transfert en Facture
|
|
|
709 |
*
|
|
|
710 |
* @param row
|
|
|
711 |
*/
|
144 |
ilm |
712 |
public EditFrame transfertAcompteClient(List<SQLRowValues> rows) {
|
|
|
713 |
return TransfertGroupSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE", VenteFactureSituationSQLComponent.ID);
|
94 |
ilm |
714 |
}
|
|
|
715 |
|
|
|
716 |
/**
|
|
|
717 |
* Transfert en Facture
|
|
|
718 |
*
|
|
|
719 |
* @param row
|
|
|
720 |
*/
|
144 |
ilm |
721 |
public EditFrame transfertSoldeClient(List<SQLRowValues> rows) {
|
|
|
722 |
return TransfertGroupSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE", VenteFactureSoldeSQLComponent.ID);
|
94 |
ilm |
723 |
}
|
|
|
724 |
|
151 |
ilm |
725 |
public BigDecimal getAvancement(SQLRowAccessor r) {
|
94 |
ilm |
726 |
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_COMMANDE_CLIENT"));
|
|
|
727 |
long totalFact = 0;
|
|
|
728 |
long total = r.getLong("T_HT");
|
|
|
729 |
for (SQLRowAccessor row : rows) {
|
|
|
730 |
if (!row.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) {
|
|
|
731 |
SQLRowAccessor rowFact = row.getForeign("ID_SAISIE_VENTE_FACTURE");
|
|
|
732 |
Long l = rowFact.getLong("T_HT");
|
|
|
733 |
totalFact += l;
|
|
|
734 |
}
|
|
|
735 |
}
|
|
|
736 |
if (total > 0) {
|
|
|
737 |
return new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
|
|
|
738 |
} else {
|
|
|
739 |
return BigDecimal.ONE.movePointRight(2);
|
|
|
740 |
}
|
|
|
741 |
}
|
156 |
ilm |
742 |
|
180 |
ilm |
743 |
public RowAction getCloneAction() {
|
|
|
744 |
return new RowAction(new AbstractAction() {
|
|
|
745 |
|
|
|
746 |
public void actionPerformed(ActionEvent e) {
|
|
|
747 |
SQLRowAccessor selectedRow = IListe.get(e).getSelectedRow();
|
|
|
748 |
|
|
|
749 |
EditFrame editFrame = new EditFrame(CommandeClientSQLElement.this, EditPanel.CREATION);
|
|
|
750 |
|
|
|
751 |
((CommandeClientSQLComponent) editFrame.getSQLComponent()).loadCommandeExistant(selectedRow.getID());
|
|
|
752 |
editFrame.setVisible(true);
|
|
|
753 |
}
|
|
|
754 |
}, true, "sales.quote.clone") {
|
|
|
755 |
@Override
|
|
|
756 |
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowValues> selection) {
|
|
|
757 |
return (selection != null && selection.size() == 1);
|
|
|
758 |
}
|
|
|
759 |
};
|
|
|
760 |
}
|
|
|
761 |
|
156 |
ilm |
762 |
@Override
|
|
|
763 |
protected String createCode() {
|
|
|
764 |
return "sales.order";
|
|
|
765 |
}
|
|
|
766 |
|
18 |
ilm |
767 |
}
|