151 |
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.action;
|
|
|
15 |
|
156 |
ilm |
16 |
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
|
|
|
17 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
151 |
ilm |
18 |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
|
|
|
19 |
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
|
|
|
20 |
import org.openconcerto.erp.core.common.ui.IListTotalPanel.Type;
|
|
|
21 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
156 |
ilm |
22 |
import org.openconcerto.erp.core.sales.order.element.CommandeClientElementSQLElement;
|
151 |
ilm |
23 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
24 |
import org.openconcerto.sql.model.FieldPath;
|
|
|
25 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
26 |
import org.openconcerto.sql.model.Where;
|
|
|
27 |
import org.openconcerto.sql.model.graph.Path;
|
|
|
28 |
import org.openconcerto.sql.view.IListFrame;
|
156 |
ilm |
29 |
import org.openconcerto.sql.view.IListPanel;
|
151 |
ilm |
30 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
|
|
31 |
import org.openconcerto.sql.view.list.IListe;
|
|
|
32 |
import org.openconcerto.sql.view.list.SQLTableModelColumn;
|
156 |
ilm |
33 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
151 |
ilm |
34 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
35 |
import org.openconcerto.utils.Tuple2;
|
|
|
36 |
|
|
|
37 |
import java.awt.GridBagConstraints;
|
|
|
38 |
import java.math.BigDecimal;
|
|
|
39 |
import java.util.ArrayList;
|
156 |
ilm |
40 |
import java.util.Arrays;
|
151 |
ilm |
41 |
import java.util.List;
|
|
|
42 |
import java.util.Set;
|
|
|
43 |
|
156 |
ilm |
44 |
public class ListeDesCommandesClientItemsAction extends CreateIListFrameAbstractAction<CommandeClientElementSQLElement> {
|
151 |
ilm |
45 |
|
156 |
ilm |
46 |
public ListeDesCommandesClientItemsAction(final ComptaPropsConfiguration conf) {
|
|
|
47 |
super(conf, CommandeClientElementSQLElement.class);
|
|
|
48 |
}
|
151 |
ilm |
49 |
|
156 |
ilm |
50 |
@Override
|
|
|
51 |
protected SQLTableModelSource createTableSource() {
|
|
|
52 |
final SQLTableModelSource res = super.createTableSource();
|
|
|
53 |
res.getReq().setWhere(new Where(getElem().getTable().getField("ID_COMMANDE_CLIENT"), ">", 1));
|
|
|
54 |
return res;
|
151 |
ilm |
55 |
}
|
|
|
56 |
|
156 |
ilm |
57 |
@Override
|
|
|
58 |
protected IListPanel instantiateListPanel(final SQLTableModelSource tableSource, String panelVariant) {
|
|
|
59 |
return new ListeViewPanel(tableSource.getElem(), new IListe(tableSource));
|
|
|
60 |
}
|
151 |
ilm |
61 |
|
156 |
ilm |
62 |
@Override
|
|
|
63 |
protected void initFrame(IListFrame frame) {
|
|
|
64 |
super.initFrame(frame);
|
|
|
65 |
final SQLElement element = getElem();
|
151 |
ilm |
66 |
|
156 |
ilm |
67 |
final IListPanel listeAddPanel = frame.getPanel();
|
|
|
68 |
final SQLTableModelSource tableSource = listeAddPanel.getListe().getSource();
|
|
|
69 |
|
|
|
70 |
final Set<FieldPath> paths = FieldPath.create(new Path(getElem().getTable()), Arrays.asList("QTE", "QTE_UNITAIRE", "QTE_LIVREE"));
|
151 |
ilm |
71 |
BaseSQLTableModelColumn colStockR = new BaseSQLTableModelColumn("Qté restante à livrer", BigDecimal.class) {
|
|
|
72 |
|
|
|
73 |
@Override
|
|
|
74 |
protected Object show_(SQLRowAccessor r) {
|
|
|
75 |
|
|
|
76 |
BigDecimal qteAlivrer = r.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(r.getInt("QTE")));
|
|
|
77 |
BigDecimal qteLivree = BigDecimal.ZERO;
|
|
|
78 |
if (r.getObject("QTE_LIVREE") != null) {
|
|
|
79 |
qteLivree = r.getBigDecimal("QTE_LIVREE");
|
|
|
80 |
}
|
|
|
81 |
return qteAlivrer.subtract(qteLivree);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
@Override
|
|
|
85 |
public Set<FieldPath> getPaths() {
|
156 |
ilm |
86 |
return paths;
|
151 |
ilm |
87 |
}
|
|
|
88 |
};
|
|
|
89 |
tableSource.getColumns().add(colStockR);
|
|
|
90 |
|
|
|
91 |
List<Tuple2<? extends SQLTableModelColumn, Type>> listField = new ArrayList<Tuple2<? extends SQLTableModelColumn, Type>>();
|
|
|
92 |
listField.add(Tuple2.create(tableSource.getColumn(element.getTable().getField("QTE")), IListTotalPanel.Type.SOMME_QTE));
|
|
|
93 |
listField.add(Tuple2.create(colStockR, IListTotalPanel.Type.SOMME_QTE));
|
|
|
94 |
listField.add(Tuple2.create(tableSource.getColumn(element.getTable().getField("T_PA_HT")), IListTotalPanel.Type.SOMME));
|
|
|
95 |
listField.add(Tuple2.create(tableSource.getColumn(element.getTable().getField("T_PV_HT")), IListTotalPanel.Type.SOMME));
|
|
|
96 |
listField.add(Tuple2.create(tableSource.getColumn(element.getTable().getField("T_PV_TTC")), IListTotalPanel.Type.SOMME));
|
|
|
97 |
IListTotalPanel total = new IListTotalPanel(listeAddPanel.getListe(), listField, null, "Total");
|
|
|
98 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
99 |
c.gridy = 2;
|
|
|
100 |
c.weightx = 0;
|
|
|
101 |
c.weighty = 0;
|
|
|
102 |
c.anchor = GridBagConstraints.EAST;
|
|
|
103 |
c.fill = GridBagConstraints.NONE;
|
|
|
104 |
listeAddPanel.add(total, c);
|
156 |
ilm |
105 |
|
|
|
106 |
frame.setTextTitle(String.valueOf(getValue(NAME)));
|
151 |
ilm |
107 |
frame.getPanel().getListe().setModificationAllowed(false);
|
|
|
108 |
frame.getPanel().setAddVisible(false);
|
|
|
109 |
frame.getPanel().setSearchFullMode(true);
|
|
|
110 |
|
|
|
111 |
// Date panel
|
|
|
112 |
IListFilterDatePanel datePanel = new IListFilterDatePanel(frame.getPanel().getListe(), element.getTable().getTable("COMMANDE_CLIENT").getField("DATE"), IListFilterDatePanel.getDefaultMap());
|
|
|
113 |
c.gridy++;
|
|
|
114 |
c.anchor = GridBagConstraints.CENTER;
|
|
|
115 |
frame.getPanel().add(datePanel, c);
|
|
|
116 |
}
|
|
|
117 |
}
|