Line 11... |
Line 11... |
11 |
* When distributing the software, include this License Header Notice in each file.
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
12 |
*/
|
12 |
*/
|
13 |
|
13 |
|
14 |
package org.openconcerto.erp.core.sales.order.action;
|
14 |
package org.openconcerto.erp.core.sales.order.action;
|
15 |
|
15 |
|
16 |
import org.openconcerto.erp.action.CreateFrameAbstractAction;
|
16 |
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
|
- |
|
17 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
17 |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
|
18 |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
|
18 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
19 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
19 |
import org.openconcerto.erp.core.sales.order.element.CommandeClientElementSQLElement;
|
20 |
import org.openconcerto.erp.core.sales.order.element.CommandeClientElementSQLElement;
|
20 |
import org.openconcerto.sql.Configuration;
|
21 |
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
|
- |
|
22 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
21 |
import org.openconcerto.sql.element.SQLElement;
|
23 |
import org.openconcerto.sql.element.SQLElement;
|
22 |
import org.openconcerto.sql.model.FieldPath;
|
24 |
import org.openconcerto.sql.model.FieldPath;
|
23 |
import org.openconcerto.sql.model.FieldRef;
|
25 |
import org.openconcerto.sql.model.FieldRef;
|
24 |
import org.openconcerto.sql.model.SQLName;
|
26 |
import org.openconcerto.sql.model.SQLName;
|
25 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
27 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
26 |
import org.openconcerto.sql.model.SQLRowValues;
|
28 |
import org.openconcerto.sql.model.SQLRowValues;
|
27 |
import org.openconcerto.sql.model.SQLSelect;
|
29 |
import org.openconcerto.sql.model.SQLSelect;
|
28 |
import org.openconcerto.sql.model.SQLSelectJoin;
|
30 |
import org.openconcerto.sql.model.SQLSelectJoin;
|
29 |
import org.openconcerto.sql.model.Where;
|
31 |
import org.openconcerto.sql.model.Where;
|
30 |
import org.openconcerto.sql.model.graph.Path;
|
32 |
import org.openconcerto.sql.model.graph.Path;
|
- |
|
33 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
31 |
import org.openconcerto.sql.view.IListFrame;
|
34 |
import org.openconcerto.sql.view.IListFrame;
|
32 |
import org.openconcerto.sql.view.ListeAddPanel;
|
35 |
import org.openconcerto.sql.view.IListPanel;
|
33 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
36 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
34 |
import org.openconcerto.sql.view.list.IListe;
|
37 |
import org.openconcerto.sql.view.list.IListe;
|
35 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
38 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
36 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
39 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
- |
|
40 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
37 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
41 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
38 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
42 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
39 |
import org.openconcerto.ui.FrameUtil;
|
43 |
import org.openconcerto.ui.FrameUtil;
|
40 |
import org.openconcerto.ui.state.WindowStateManager;
|
- |
|
41 |
import org.openconcerto.utils.CollectionUtils;
|
44 |
import org.openconcerto.utils.CollectionUtils;
|
42 |
import org.openconcerto.utils.DecimalUtils;
|
45 |
import org.openconcerto.utils.DecimalUtils;
|
43 |
import org.openconcerto.utils.cc.ITransformer;
|
46 |
import org.openconcerto.utils.cc.ITransformer;
|
44 |
|
47 |
|
45 |
import java.awt.GridBagConstraints;
|
48 |
import java.awt.GridBagConstraints;
|
46 |
import java.awt.GridBagLayout;
|
49 |
import java.awt.GridBagLayout;
|
47 |
import java.awt.event.ActionEvent;
|
50 |
import java.awt.event.ActionEvent;
|
48 |
import java.io.File;
|
- |
|
49 |
import java.math.BigDecimal;
|
51 |
import java.math.BigDecimal;
|
50 |
import java.math.RoundingMode;
|
52 |
import java.math.RoundingMode;
|
51 |
import java.util.Collection;
|
53 |
import java.util.Collection;
|
52 |
import java.util.List;
|
54 |
import java.util.List;
|
53 |
import java.util.Set;
|
55 |
import java.util.Set;
|
54 |
|
56 |
|
55 |
import javax.swing.AbstractAction;
|
57 |
import javax.swing.AbstractAction;
|
56 |
import javax.swing.Action;
|
- |
|
57 |
import javax.swing.JFrame;
|
- |
|
58 |
import javax.swing.JPanel;
|
58 |
import javax.swing.JPanel;
|
59 |
|
59 |
|
60 |
public class ListeDesElementsACommanderClientAction extends CreateFrameAbstractAction {
|
60 |
public class ListeDesElementsACommanderClientAction extends CreateIListFrameAbstractAction<CommandeClientElementSQLElement> {
|
61 |
final CommandeClientElementSQLElement eltCmd = (CommandeClientElementSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT");
|
- |
|
62 |
|
61 |
|
63 |
public ListeDesElementsACommanderClientAction() {
|
62 |
public ListeDesElementsACommanderClientAction(final ComptaPropsConfiguration conf) {
|
64 |
super();
|
- |
|
65 |
this.putValue(Action.NAME, "Liste des éléments en attente de livraison");
|
63 |
super(conf, CommandeClientElementSQLElement.class);
|
66 |
}
|
64 |
}
|
67 |
|
65 |
|
68 |
private BaseSQLTableModelColumn colAvancement;
|
- |
|
69 |
|
- |
|
70 |
public JFrame createFrame() {
|
- |
|
71 |
final JFrame frame = new JFrame("Eléments en attente de livraison");
|
- |
|
72 |
// Actions
|
66 |
@Override
|
73 |
|
- |
|
74 |
final JPanel orderPanel = createPanel();
|
67 |
protected String getPanelVariant() {
|
75 |
|
- |
|
76 |
frame.getContentPane().add(orderPanel);
|
68 |
return this.getClass().getSimpleName();
|
77 |
FrameUtil.setBounds(frame);
|
- |
|
78 |
final File file = IListFrame.getConfigFile(eltCmd, frame.getClass());
|
- |
|
79 |
if (file != null)
|
- |
|
80 |
new WindowStateManager(frame, file).loadState();
|
- |
|
81 |
return frame;
|
- |
|
82 |
}
|
69 |
}
|
83 |
|
70 |
|
- |
|
71 |
@Override
|
84 |
JPanel createPanel() {
|
72 |
protected SQLTableModelSource createTableSource() {
|
85 |
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
|
73 |
final SQLTableModelSource tableSource = super.createTableSource();
|
- |
|
74 |
final CommandeClientElementSQLElement eltCmd = getElem();
|
86 |
tableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
75 |
tableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
87 |
|
76 |
|
88 |
@Override
|
77 |
@Override
|
89 |
public SQLSelect transformChecked(SQLSelect input) {
|
78 |
public SQLSelect transformChecked(SQLSelect input) {
|
90 |
// new SQLName(eltCmd.getTable().getDBRoot().getName(),
|
79 |
// new SQLName(eltCmd.getTable().getDBRoot().getName(),
|
Line 92... |
Line 81... |
92 |
final String quoteQteL = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_LIVREE").quote();
|
81 |
final String quoteQteL = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_LIVREE").quote();
|
93 |
final String quoteQte = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE").quote();
|
82 |
final String quoteQte = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE").quote();
|
94 |
final String quoteQteU = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_UNITAIRE").quote();
|
83 |
final String quoteQteU = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_UNITAIRE").quote();
|
95 |
Where w = Where.createRaw(quoteQteL + " < (" + quoteQte + "*" + quoteQteU + ")", eltCmd.getTable().getField("QTE_LIVREE"), eltCmd.getTable().getField("QTE"),
|
84 |
Where w = Where.createRaw(quoteQteL + " < (" + quoteQte + "*" + quoteQteU + ")", eltCmd.getTable().getField("QTE_LIVREE"), eltCmd.getTable().getField("QTE"),
|
96 |
eltCmd.getTable().getField("QTE_UNITAIRE"));
|
85 |
eltCmd.getTable().getField("QTE_UNITAIRE"));
|
- |
|
86 |
w = w.and(new Where(eltCmd.getTable().getField("LIVRE_FORCED"), "=", Boolean.FALSE));
|
97 |
input.setWhere(w);
|
87 |
input.setWhere(w);
|
98 |
return input;
|
88 |
return input;
|
99 |
}
|
89 |
}
|
100 |
});
|
90 |
});
|
101 |
|
91 |
|
- |
|
92 |
SQLPreferences prefs = SQLPreferences.getMemCached(eltCmd.getTable().getDBRoot());
|
- |
|
93 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false)) {
|
- |
|
94 |
BaseSQLTableModelColumn colStockD = new BaseSQLTableModelColumn("Dépôt", String.class) {
|
- |
|
95 |
|
- |
|
96 |
@Override
|
- |
|
97 |
protected Object show_(SQLRowAccessor r) {
|
- |
|
98 |
|
- |
|
99 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
- |
|
100 |
if (foreign != null && !foreign.isUndefined()) {
|
- |
|
101 |
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
|
- |
|
102 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
- |
|
103 |
return foreign2.getForeign("ID_DEPOT_STOCK").getString("NOM");
|
- |
|
104 |
}
|
- |
|
105 |
}
|
- |
|
106 |
return "";
|
- |
|
107 |
}
|
- |
|
108 |
|
- |
|
109 |
@Override
|
- |
|
110 |
public Set<FieldPath> getPaths() {
|
- |
|
111 |
Path p = new Path(eltCmd.getTable());
|
- |
|
112 |
p = p.add(p.getLast().getField("ID_ARTICLE"));
|
- |
|
113 |
Path p2 = p.add(p.getLast().getTable("STOCK").getField("ID_ARTICLE"));
|
- |
|
114 |
Path p3 = p2.add(p2.getLast().getField("ID_DEPOT_STOCK"));
|
- |
|
115 |
Path p4 = p.add(p.getLast().getField("ID_DEPOT_STOCK"));
|
- |
|
116 |
return CollectionUtils.createSet(new FieldPath(p3, "NOM"), new FieldPath(p4, "NOM"));
|
- |
|
117 |
}
|
- |
|
118 |
};
|
- |
|
119 |
tableSource.getColumns().add(colStockD);
|
- |
|
120 |
}
|
102 |
BaseSQLTableModelColumn colStockR = new BaseSQLTableModelColumn("Stock Reel", Float.class) {
|
121 |
BaseSQLTableModelColumn colStockR = new BaseSQLTableModelColumn("Stock Reel", Float.class) {
|
103 |
|
122 |
|
104 |
@Override
|
123 |
@Override
|
105 |
protected Object show_(SQLRowAccessor r) {
|
124 |
protected Object show_(SQLRowAccessor r) {
|
106 |
|
125 |
|
107 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
126 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
108 |
if (foreign != null && !foreign.isUndefined()) {
|
127 |
if (foreign != null && !foreign.isUndefined()) {
|
109 |
final SQLRowAccessor foreign2 = foreign.getForeign("ID_STOCK");
|
128 |
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
|
110 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
129 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
111 |
return foreign2.getFloat("QTE_REEL");
|
130 |
return foreign2.getFloat("QTE_REEL");
|
112 |
}
|
131 |
}
|
113 |
}
|
132 |
}
|
114 |
return 0F;
|
133 |
return 0F;
|
Line 116... |
Line 135... |
116 |
|
135 |
|
117 |
@Override
|
136 |
@Override
|
118 |
public Set<FieldPath> getPaths() {
|
137 |
public Set<FieldPath> getPaths() {
|
119 |
Path p = new Path(eltCmd.getTable());
|
138 |
Path p = new Path(eltCmd.getTable());
|
120 |
p = p.add(p.getLast().getField("ID_ARTICLE"));
|
139 |
p = p.add(p.getLast().getField("ID_ARTICLE"));
|
121 |
p = p.add(p.getLast().getField("ID_STOCK"));
|
140 |
Path p2 = p.add(p.getLast().getTable("STOCK").getField("ID_ARTICLE"));
|
122 |
return CollectionUtils.createSet(new FieldPath(p, "QTE_REEL"));
|
141 |
return CollectionUtils.createSet(new FieldPath(p, "ID_DEPOT_STOCK"), new FieldPath(p2, "QTE_REEL"), new FieldPath(p2, "ID_DEPOT_STOCK"));
|
123 |
}
|
142 |
}
|
124 |
};
|
143 |
};
|
125 |
tableSource.getColumns().add(colStockR);
|
144 |
tableSource.getColumns().add(colStockR);
|
126 |
|
145 |
|
127 |
BaseSQLTableModelColumn colLiv2 = new BaseSQLTableModelColumn("Stock TH", Float.class) {
|
146 |
BaseSQLTableModelColumn colLiv2 = new BaseSQLTableModelColumn("Stock TH", Float.class) {
|
Line 129... |
Line 148... |
129 |
@Override
|
148 |
@Override
|
130 |
protected Object show_(SQLRowAccessor r) {
|
149 |
protected Object show_(SQLRowAccessor r) {
|
131 |
|
150 |
|
132 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
151 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
133 |
if (foreign != null && !foreign.isUndefined()) {
|
152 |
if (foreign != null && !foreign.isUndefined()) {
|
134 |
final SQLRowAccessor foreign2 = foreign.getForeign("ID_STOCK");
|
153 |
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
|
135 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
154 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
136 |
return foreign2.getFloat("QTE_TH");
|
155 |
return foreign2.getFloat("QTE_TH");
|
137 |
}
|
156 |
}
|
138 |
}
|
157 |
}
|
139 |
return 0F;
|
158 |
return 0F;
|
Line 141... |
Line 160... |
141 |
|
160 |
|
142 |
@Override
|
161 |
@Override
|
143 |
public Set<FieldPath> getPaths() {
|
162 |
public Set<FieldPath> getPaths() {
|
144 |
Path p = new Path(eltCmd.getTable());
|
163 |
Path p = new Path(eltCmd.getTable());
|
145 |
p = p.add(p.getLast().getField("ID_ARTICLE"));
|
164 |
p = p.add(p.getLast().getField("ID_ARTICLE"));
|
146 |
p = p.add(p.getLast().getField("ID_STOCK"));
|
165 |
Path p2 = p.add(p.getLast().getTable("STOCK").getField("ID_ARTICLE"));
|
147 |
return CollectionUtils.createSet(new FieldPath(p, "QTE_TH"));
|
166 |
return CollectionUtils.createSet(new FieldPath(p, "ID_DEPOT_STOCK"), new FieldPath(p2, "QTE_TH"), new FieldPath(p2, "ID_DEPOT_STOCK"));
|
148 |
}
|
167 |
}
|
149 |
};
|
168 |
};
|
150 |
tableSource.getColumns().add(colLiv2);
|
169 |
tableSource.getColumns().add(colLiv2);
|
151 |
|
170 |
|
152 |
BaseSQLTableModelColumn colStockMin = new BaseSQLTableModelColumn("Stock Min", Integer.class) {
|
171 |
BaseSQLTableModelColumn colStockMin = new BaseSQLTableModelColumn("Stock Min", Float.class) {
|
153 |
|
172 |
|
154 |
@Override
|
173 |
@Override
|
155 |
protected Object show_(SQLRowAccessor r) {
|
174 |
protected Object show_(SQLRowAccessor r) {
|
156 |
|
175 |
|
157 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
176 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
- |
|
177 |
if (foreign != null && !foreign.isUndefined()) {
|
- |
|
178 |
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
|
- |
|
179 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
158 |
return foreign.getInt("QTE_MIN");
|
180 |
return foreign2.getFloat("QTE_MIN");
|
- |
|
181 |
}
|
- |
|
182 |
}
|
- |
|
183 |
return 0F;
|
159 |
}
|
184 |
}
|
160 |
|
185 |
|
161 |
@Override
|
186 |
@Override
|
162 |
public Set<FieldPath> getPaths() {
|
187 |
public Set<FieldPath> getPaths() {
|
163 |
Path p = new Path(eltCmd.getTable());
|
188 |
Path p = new Path(eltCmd.getTable());
|
164 |
p = p.add(p.getLast().getField("ID_ARTICLE"));
|
189 |
p = p.add(p.getLast().getField("ID_ARTICLE"));
|
165 |
|
- |
|
- |
|
190 |
Path p2 = p.add(p.getLast().getTable("STOCK").getField("ID_ARTICLE"));
|
166 |
return CollectionUtils.createSet(new FieldPath(p, "QTE_MIN"));
|
191 |
return CollectionUtils.createSet(new FieldPath(p, "ID_DEPOT_STOCK"), new FieldPath(p2, "QTE_MIN"), new FieldPath(p2, "ID_DEPOT_STOCK"));
|
167 |
}
|
192 |
}
|
168 |
};
|
193 |
};
|
169 |
tableSource.getColumns().add(colStockMin);
|
194 |
tableSource.getColumns().add(colStockMin);
|
170 |
|
195 |
|
171 |
BaseSQLTableModelColumn colSug = new BaseSQLTableModelColumn("Qtè à commander", Float.class) {
|
196 |
BaseSQLTableModelColumn colSug = new BaseSQLTableModelColumn("Qtè à commander", Float.class) {
|
172 |
|
197 |
|
173 |
@Override
|
198 |
@Override
|
174 |
protected Object show_(SQLRowAccessor r) {
|
199 |
protected Object show_(SQLRowAccessor r) {
|
175 |
|
200 |
|
176 |
// final float qteCommande = r.getBigDecimal("QTE_UNITAIRE").multiply(new
|
- |
|
177 |
// BigDecimal(r.getInt("QTE"))).subtract(r.getBigDecimal("QTE_LIVREE")).floatValue();
|
- |
|
178 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
201 |
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
|
179 |
if (foreign != null && !foreign.isUndefined()) {
|
202 |
if (foreign != null && !foreign.isUndefined()) {
|
180 |
float qteMin = foreign.getFloat("QTE_MIN");
|
- |
|
181 |
final SQLRowAccessor foreign2 = foreign.getForeign("ID_STOCK");
|
203 |
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
|
182 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
204 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
- |
|
205 |
float qteMin = foreign2.getFloat("QTE_MIN");
|
183 |
float manque = foreign2.getFloat("QTE_TH") - qteMin;
|
206 |
float manque = foreign2.getFloat("QTE_TH") - qteMin;
|
184 |
if (manque < 0) {
|
207 |
if (manque < 0) {
|
185 |
return -manque;
|
208 |
return -manque;
|
186 |
}
|
209 |
}
|
187 |
}
|
210 |
}
|
188 |
}
|
211 |
}
|
189 |
return 0F;
|
212 |
return 0F;
|
- |
|
213 |
|
190 |
}
|
214 |
}
|
191 |
|
215 |
|
192 |
@Override
|
216 |
@Override
|
193 |
public Set<FieldPath> getPaths() {
|
217 |
public Set<FieldPath> getPaths() {
|
194 |
Path pA = new Path(eltCmd.getTable());
|
218 |
Path p = new Path(eltCmd.getTable());
|
195 |
|
- |
|
196 |
pA = pA.add(pA.getLast().getField("ID_ARTICLE"));
|
219 |
p = p.add(p.getLast().getField("ID_ARTICLE"));
|
197 |
Path p = pA.add(pA.getLast().getField("ID_STOCK"));
|
220 |
Path p2 = p.add(p.getLast().getTable("STOCK").getField("ID_ARTICLE"));
|
198 |
return CollectionUtils.createSet(new FieldPath(pA, "QTE_MIN"), new FieldPath(p, "QTE_TH"));
|
221 |
return CollectionUtils.createSet(new FieldPath(p, "ID_DEPOT_STOCK"), new FieldPath(p2, "QTE_TH"), new FieldPath(p2, "QTE_MIN"), new FieldPath(p2, "ID_DEPOT_STOCK"));
|
199 |
}
|
222 |
}
|
200 |
};
|
223 |
};
|
201 |
tableSource.getColumns().add(colSug);
|
224 |
tableSource.getColumns().add(colSug);
|
202 |
// colLiv2.setRenderer(new PercentTableCellRenderer());
|
225 |
// colLiv2.setRenderer(new PercentTableCellRenderer());
|
203 |
|
226 |
|
204 |
final ListeAddPanel panel = getPanel(eltCmd, tableSource);
|
- |
|
205 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Calcul des besoins") {
|
- |
|
206 |
|
- |
|
207 |
@Override
|
- |
|
208 |
public void actionPerformed(ActionEvent e) {
|
- |
|
209 |
final SQLElement artElt = eltCmd.getForeignElement("ID_ARTICLE");
|
- |
|
210 |
final SQLTableModelSourceOnline createTableSource = artElt.createTableSource();
|
- |
|
211 |
createTableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
- |
|
212 |
@Override
|
- |
|
213 |
public SQLSelect transformChecked(SQLSelect input) {
|
- |
|
214 |
FieldRef refStock = input.getAlias(artElt.getTable().getForeignTable("ID_STOCK").getField("QTE_TH"));
|
- |
|
215 |
|
- |
|
216 |
SQLSelectJoin j = input.getJoinFromField(artElt.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
|
- |
|
217 |
Where w = new Where(refStock, "<", artElt.getTable().getField("QTE_MIN"));
|
- |
|
218 |
w = w.and(new Where(j.getJoinedTable().getKey(), "=", (Object) null));
|
- |
|
219 |
input.setWhere(w);
|
- |
|
220 |
// input.setHaving(Where.createRaw("COUNT(\"" + j.getJoinedTable().getKey()
|
- |
|
221 |
// + "\")" + " = 0", Arrays.asList(j.getJoinedTable().getKey())));
|
- |
|
222 |
return input;
|
- |
|
223 |
}
|
- |
|
224 |
});
|
- |
|
225 |
|
- |
|
226 |
BaseSQLTableModelColumn colSug = new BaseSQLTableModelColumn("Qtè à commander", Float.class) {
|
- |
|
227 |
|
- |
|
228 |
@Override
|
- |
|
229 |
protected Object show_(SQLRowAccessor r) {
|
- |
|
230 |
|
- |
|
231 |
float qteMin = r.getFloat("QTE_MIN");
|
- |
|
232 |
final SQLRowAccessor foreign2 = r.getForeign("ID_STOCK");
|
- |
|
233 |
if (foreign2 != null && !foreign2.isUndefined()) {
|
- |
|
234 |
float manque = foreign2.getFloat("QTE_TH") - qteMin;
|
- |
|
235 |
if (manque < 0) {
|
- |
|
236 |
return -manque;
|
- |
|
237 |
}
|
- |
|
238 |
}
|
- |
|
239 |
|
- |
|
240 |
return 0F;
|
- |
|
241 |
}
|
- |
|
242 |
|
- |
|
243 |
@Override
|
- |
|
244 |
public Set<FieldPath> getPaths() {
|
- |
|
245 |
Path pA = new Path(artElt.getTable());
|
- |
|
246 |
|
- |
|
247 |
Path p = pA.add(pA.getLast().getField("ID_STOCK"));
|
- |
|
248 |
return CollectionUtils.createSet(new FieldPath(pA, "QTE_MIN"), new FieldPath(p, "QTE_TH"));
|
- |
|
249 |
}
|
- |
|
250 |
};
|
- |
|
251 |
createTableSource.getColumns().add(colSug);
|
- |
|
252 |
|
- |
|
253 |
IListe listeArt = new IListe(createTableSource);
|
- |
|
254 |
final PredicateRowAction predicateACtion = new PredicateRowAction(new AbstractAction("Passer une commande fournisseur") {
|
- |
|
255 |
|
- |
|
256 |
@Override
|
- |
|
257 |
public void actionPerformed(ActionEvent e) {
|
- |
|
258 |
List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
|
- |
|
259 |
eltCmd.createCommandeF(selectedRows);
|
- |
|
260 |
}
|
- |
|
261 |
}, true);
|
- |
|
262 |
predicateACtion.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
- |
|
263 |
listeArt.addIListeAction(predicateACtion);
|
- |
|
264 |
ListeViewPanel p = new ListeViewPanel(artElt, listeArt);
|
- |
|
265 |
IListFrame f = new IListFrame(p);
|
- |
|
266 |
FrameUtil.show(f);
|
- |
|
267 |
}
|
- |
|
268 |
}, true);
|
- |
|
269 |
action.setPredicate(IListeEvent.createTotalRowCountPredicate(0, Integer.MAX_VALUE));
|
- |
|
270 |
panel.getListe().addIListeAction(action);
|
- |
|
271 |
return panel;
|
227 |
return tableSource;
|
272 |
}
|
228 |
}
|
273 |
|
229 |
|
274 |
private BigDecimal getAvancementLFromBL(SQLRowAccessor r) {
|
230 |
private BigDecimal getAvancementLFromBL(SQLRowAccessor r) {
|
275 |
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("COMMANDE_CLIENT_ELEMENT"));
|
231 |
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("COMMANDE_CLIENT_ELEMENT"));
|
276 |
BigDecimal totalQte = BigDecimal.ZERO;
|
232 |
BigDecimal totalQte = BigDecimal.ZERO;
|
Line 289... |
Line 245... |
289 |
} else {
|
245 |
} else {
|
290 |
return BigDecimal.ONE.movePointRight(2);
|
246 |
return BigDecimal.ONE.movePointRight(2);
|
291 |
}
|
247 |
}
|
292 |
}
|
248 |
}
|
293 |
|
249 |
|
- |
|
250 |
@Override
|
294 |
private ListeAddPanel getPanel(final SQLElement eltCmd, final SQLTableModelSourceOnline tableSource) {
|
251 |
protected IListPanel instantiateListPanel(SQLTableModelSource tableSource, String panelVariant) {
|
295 |
final ListeAddPanel panel = new ListeAddPanel(eltCmd, new IListe(tableSource));
|
252 |
final IListPanel panel = super.instantiateListPanel(tableSource, panelVariant);
|
296 |
|
- |
|
- |
|
253 |
final CommandeClientElementSQLElement eltCmd = getElem();
|
297 |
// final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new
|
254 |
// final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new
|
298 |
// ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
|
255 |
// ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
|
299 |
// fields.add(Tuple2.create(panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")),
|
256 |
// fields.add(Tuple2.create(panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")),
|
300 |
// IListTotalPanel.Type.SOMME));
|
257 |
// IListTotalPanel.Type.SOMME));
|
301 |
// fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC));
|
258 |
// fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC));
|
Line 327... |
Line 284... |
327 |
// c2.weightx = 0;
|
284 |
// c2.weightx = 0;
|
328 |
// c2.anchor = GridBagConstraints.EAST;
|
285 |
// c2.anchor = GridBagConstraints.EAST;
|
329 |
// bottomPanel.add(totalPanel, c2);
|
286 |
// bottomPanel.add(totalPanel, c2);
|
330 |
|
287 |
|
331 |
panel.add(bottomPanel, c);
|
288 |
panel.add(bottomPanel, c);
|
- |
|
289 |
|
- |
|
290 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Calcul des besoins") {
|
- |
|
291 |
|
- |
|
292 |
@Override
|
- |
|
293 |
public void actionPerformed(ActionEvent e) {
|
- |
|
294 |
final SQLElement artElt = eltCmd.getForeignElement("ID_ARTICLE");
|
- |
|
295 |
final SQLTableModelSourceOnline createTableSource = artElt.createTableSource();
|
- |
|
296 |
createTableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
- |
|
297 |
@Override
|
- |
|
298 |
public SQLSelect transformChecked(SQLSelect input) {
|
- |
|
299 |
FieldRef refStock = input.getAlias(artElt.getTable().getForeignTable("ID_STOCK").getField("QTE_TH"));
|
- |
|
300 |
|
- |
|
301 |
SQLSelectJoin j = input.getJoinFromField(artElt.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
|
- |
|
302 |
Where w = new Where(refStock, "<", artElt.getTable().getField("QTE_MIN"));
|
- |
|
303 |
w = w.and(new Where(j.getJoinedTable().getKey(), "=", (Object) null));
|
- |
|
304 |
input.setWhere(w);
|
- |
|
305 |
// input.setHaving(Where.createRaw("COUNT(\"" + j.getJoinedTable().getKey()
|
- |
|
306 |
// + "\")" + " = 0", Arrays.asList(j.getJoinedTable().getKey())));
|
- |
|
307 |
return input;
|
- |
|
308 |
}
|
- |
|
309 |
});
|
- |
|
310 |
|
- |
|
311 |
IListe listeArt = new IListe(createTableSource);
|
- |
|
312 |
final PredicateRowAction predicateACtion = new PredicateRowAction(new AbstractAction("Passer une commande fournisseur") {
|
- |
|
313 |
|
- |
|
314 |
@Override
|
- |
|
315 |
public void actionPerformed(ActionEvent e) {
|
- |
|
316 |
List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
|
- |
|
317 |
eltCmd.createCommandeF(selectedRows);
|
- |
|
318 |
}
|
- |
|
319 |
}, true);
|
- |
|
320 |
predicateACtion.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
- |
|
321 |
listeArt.addIListeAction(predicateACtion);
|
- |
|
322 |
ListeViewPanel p = new ListeViewPanel(artElt, listeArt);
|
- |
|
323 |
IListFrame f = new IListFrame(p);
|
- |
|
324 |
FrameUtil.show(f);
|
- |
|
325 |
}
|
- |
|
326 |
|
- |
|
327 |
}, true);
|
- |
|
328 |
action.setPredicate(IListeEvent.createTotalRowCountPredicate(0, Integer.MAX_VALUE));
|
- |
|
329 |
panel.getListe().addIListeAction(action);
|
- |
|
330 |
|
332 |
return panel;
|
331 |
return panel;
|
333 |
}
|
332 |
}
|
334 |
|
333 |
|
335 |
}
|
334 |
}
|