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.supplychain.order.action;
|
14 |
package org.openconcerto.erp.core.supplychain.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.supplychain.order.element.CommandeElementSQLElement;
|
19 |
import org.openconcerto.sql.Configuration;
|
- |
|
20 |
import org.openconcerto.sql.element.SQLElement;
|
20 |
import org.openconcerto.sql.element.SQLElement;
|
21 |
import org.openconcerto.sql.model.FieldPath;
|
- |
|
22 |
import org.openconcerto.sql.model.FieldRef;
|
- |
|
23 |
import org.openconcerto.sql.model.SQLName;
|
21 |
import org.openconcerto.sql.model.SQLName;
|
24 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
- |
|
25 |
import org.openconcerto.sql.model.SQLSelect;
|
22 |
import org.openconcerto.sql.model.SQLSelect;
|
26 |
import org.openconcerto.sql.model.SQLSelectJoin;
|
- |
|
27 |
import org.openconcerto.sql.model.Where;
|
23 |
import org.openconcerto.sql.model.Where;
|
28 |
import org.openconcerto.sql.model.graph.Path;
|
- |
|
29 |
import org.openconcerto.sql.view.IListFrame;
|
24 |
import org.openconcerto.sql.view.IListPanel;
|
30 |
import org.openconcerto.sql.view.ListeAddPanel;
|
- |
|
31 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
- |
|
32 |
import org.openconcerto.sql.view.list.IListe;
|
- |
|
33 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
- |
|
34 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
- |
|
35 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
25 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
36 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
26 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
37 |
import org.openconcerto.ui.FrameUtil;
|
- |
|
38 |
import org.openconcerto.ui.state.WindowStateManager;
|
- |
|
39 |
import org.openconcerto.utils.CollectionUtils;
|
- |
|
40 |
import org.openconcerto.utils.DecimalUtils;
|
- |
|
41 |
import org.openconcerto.utils.cc.ITransformer;
|
27 |
import org.openconcerto.utils.cc.ITransformer;
|
42 |
|
28 |
|
43 |
import java.awt.GridBagConstraints;
|
29 |
import java.awt.GridBagConstraints;
|
44 |
import java.awt.GridBagLayout;
|
30 |
import java.awt.GridBagLayout;
|
45 |
import java.awt.event.ActionEvent;
|
- |
|
46 |
import java.io.File;
|
- |
|
47 |
import java.math.BigDecimal;
|
- |
|
48 |
import java.math.RoundingMode;
|
- |
|
49 |
import java.util.Arrays;
|
- |
|
50 |
import java.util.Collection;
|
- |
|
51 |
import java.util.Set;
|
- |
|
52 |
|
31 |
|
53 |
import javax.swing.AbstractAction;
|
- |
|
54 |
import javax.swing.Action;
|
- |
|
55 |
import javax.swing.JFrame;
|
- |
|
56 |
import javax.swing.JPanel;
|
32 |
import javax.swing.JPanel;
|
57 |
|
33 |
|
58 |
public class ListeDesElementsACommanderAction extends CreateFrameAbstractAction {
|
34 |
public class ListeDesElementsACommanderAction extends CreateIListFrameAbstractAction<CommandeElementSQLElement> {
|
59 |
|
35 |
|
60 |
public ListeDesElementsACommanderAction() {
|
36 |
public ListeDesElementsACommanderAction(final ComptaPropsConfiguration conf) {
|
61 |
super();
|
- |
|
62 |
this.putValue(Action.NAME, "Liste des éléments en attente de réception");
|
37 |
super(conf, CommandeElementSQLElement.class);
|
63 |
}
|
38 |
}
|
64 |
|
39 |
|
65 |
private BaseSQLTableModelColumn colAvancement;
|
- |
|
66 |
|
- |
|
67 |
public JFrame createFrame() {
|
- |
|
68 |
final JFrame frame = new JFrame("Eléments à réceptionner");
|
- |
|
69 |
// Actions
|
40 |
@Override
|
70 |
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_ELEMENT");
|
- |
|
71 |
final JPanel orderPanel = createPanel();
|
41 |
protected String getPanelVariant() {
|
72 |
|
- |
|
73 |
frame.getContentPane().add(orderPanel);
|
42 |
return this.getClass().getSimpleName();
|
74 |
FrameUtil.setBounds(frame);
|
- |
|
75 |
final File file = IListFrame.getConfigFile(eltCmd, frame.getClass());
|
- |
|
76 |
if (file != null)
|
- |
|
77 |
new WindowStateManager(frame, file).loadState();
|
- |
|
78 |
return frame;
|
- |
|
79 |
}
|
43 |
}
|
80 |
|
44 |
|
81 |
JPanel createPanel() {
|
45 |
@Override
|
82 |
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_ELEMENT");
|
46 |
protected SQLTableModelSource createTableSource() {
|
83 |
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
|
47 |
final SQLTableModelSource tableSource = super.createTableSource();
|
- |
|
48 |
final SQLElement eltCmd = getElem();
|
84 |
tableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
49 |
tableSource.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
85 |
|
50 |
|
86 |
@Override
|
51 |
@Override
|
87 |
public SQLSelect transformChecked(SQLSelect input) {
|
52 |
public SQLSelect transformChecked(SQLSelect input) {
|
88 |
// new SQLName(eltCmd.getTable().getDBRoot().getName(),
|
53 |
// new SQLName(eltCmd.getTable().getDBRoot().getName(),
|
Line 90... |
Line 55... |
90 |
final String quoteQteL = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_RECUE").quote();
|
55 |
final String quoteQteL = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_RECUE").quote();
|
91 |
final String quoteQte = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE").quote();
|
56 |
final String quoteQte = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE").quote();
|
92 |
final String quoteQteU = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_UNITAIRE").quote();
|
57 |
final String quoteQteU = new SQLName(input.getAlias(eltCmd.getTable()).getAlias(), "QTE_UNITAIRE").quote();
|
93 |
Where w = Where.createRaw(quoteQteL + " < (" + quoteQte + "*" + quoteQteU + ")", eltCmd.getTable().getField("QTE_RECUE"), eltCmd.getTable().getField("QTE"),
|
58 |
Where w = Where.createRaw(quoteQteL + " < (" + quoteQte + "*" + quoteQteU + ")", eltCmd.getTable().getField("QTE_RECUE"), eltCmd.getTable().getField("QTE"),
|
94 |
eltCmd.getTable().getField("QTE_UNITAIRE"));
|
59 |
eltCmd.getTable().getField("QTE_UNITAIRE"));
|
- |
|
60 |
w = w.and(new Where(eltCmd.getTable().getField("RECU_FORCED"), "=", Boolean.FALSE));
|
95 |
input.setWhere(w);
|
61 |
input.setWhere(w);
|
96 |
return input;
|
62 |
return input;
|
97 |
}
|
63 |
}
|
98 |
});
|
64 |
});
|
99 |
|
65 |
|
100 |
final ListeAddPanel panel = getPanel(eltCmd, tableSource);
|
- |
|
101 |
|
- |
|
102 |
return panel;
|
66 |
return tableSource;
|
103 |
}
|
67 |
}
|
104 |
|
68 |
|
- |
|
69 |
@Override
|
105 |
private ListeAddPanel getPanel(final SQLElement eltCmd, final SQLTableModelSourceOnline tableSource) {
|
70 |
protected IListPanel instantiateListPanel(final SQLTableModelSource tableSource, String panelVariant) {
|
106 |
final ListeAddPanel panel = new ListeAddPanel(eltCmd, new IListe(tableSource));
|
71 |
final IListPanel panel = super.instantiateListPanel(tableSource, panelVariant);
|
107 |
|
- |
|
108 |
// final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new
|
72 |
// final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields = new
|
109 |
// ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
|
73 |
// ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
|
110 |
// fields.add(Tuple2.create(panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")),
|
74 |
// fields.add(Tuple2.create(panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")),
|
111 |
// IListTotalPanel.Type.SOMME));
|
75 |
// IListTotalPanel.Type.SOMME));
|
112 |
// fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC));
|
76 |
// fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC));
|
Line 119... |
Line 83... |
119 |
c.anchor = GridBagConstraints.EAST;
|
83 |
c.anchor = GridBagConstraints.EAST;
|
120 |
c.weightx = 1;
|
84 |
c.weightx = 1;
|
121 |
c.gridy = 4;
|
85 |
c.gridy = 4;
|
122 |
|
86 |
|
123 |
// Date panel
|
87 |
// Date panel
|
124 |
final IListFilterDatePanel datePanel = new IListFilterDatePanel(panel.getListe(), eltCmd.getTable().getForeignTable("ID_COMMANDE").getField("DATE"), IListFilterDatePanel.getDefaultMap());
|
88 |
final IListFilterDatePanel datePanel = new IListFilterDatePanel(panel.getListe(), getElem().getTable().getForeignTable("ID_COMMANDE").getField("DATE"), IListFilterDatePanel.getDefaultMap());
|
125 |
|
89 |
|
126 |
datePanel.setFilterOnDefault();
|
90 |
datePanel.setFilterOnDefault();
|
127 |
|
91 |
|
128 |
final JPanel bottomPanel = new JPanel();
|
92 |
final JPanel bottomPanel = new JPanel();
|
129 |
bottomPanel.setLayout(new GridBagLayout());
|
93 |
bottomPanel.setLayout(new GridBagLayout());
|