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.shipment.action;
|
14 |
package org.openconcerto.erp.core.sales.shipment.action;
|
15 |
|
15 |
|
16 |
import org.openconcerto.erp.action.CreateFrameAbstractAction;
|
16 |
import org.openconcerto.erp.action.CreateListFrameAbstractAction;
|
- |
|
17 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
17 |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
|
18 |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
|
18 |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
|
19 |
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;
|
- |
|
21 |
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonSQLElement;
|
20 |
import org.openconcerto.erp.core.sales.shipment.report.BonLivraisonXmlSheet;
|
22 |
import org.openconcerto.erp.core.sales.shipment.report.BonLivraisonXmlSheet;
|
21 |
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
|
23 |
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
|
22 |
import org.openconcerto.sql.Configuration;
|
24 |
import org.openconcerto.erp.utils.TM;
|
23 |
import org.openconcerto.sql.element.SQLElement;
|
- |
|
24 |
import org.openconcerto.sql.model.FieldPath;
|
25 |
import org.openconcerto.sql.model.FieldPath;
|
25 |
import org.openconcerto.sql.model.SQLField;
|
26 |
import org.openconcerto.sql.model.SQLField;
|
26 |
import org.openconcerto.sql.model.SQLInjector;
|
27 |
import org.openconcerto.sql.model.SQLInjector;
|
27 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
28 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
28 |
import org.openconcerto.sql.model.SQLRowValues;
|
29 |
import org.openconcerto.sql.model.SQLRowValues;
|
29 |
import org.openconcerto.sql.model.graph.Path;
|
30 |
import org.openconcerto.sql.model.graph.Path;
|
30 |
import org.openconcerto.sql.model.graph.PathBuilder;
|
31 |
import org.openconcerto.sql.model.graph.PathBuilder;
|
31 |
import org.openconcerto.sql.view.IListFrame;
|
- |
|
32 |
import org.openconcerto.sql.view.ListeAddPanel;
|
32 |
import org.openconcerto.sql.view.ListeAddPanel;
|
33 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
33 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
34 |
import org.openconcerto.sql.view.list.IListe;
|
34 |
import org.openconcerto.sql.view.list.IListe;
|
35 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
35 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
36 |
import org.openconcerto.sql.view.list.RowAction;
|
36 |
import org.openconcerto.sql.view.list.RowAction;
|
37 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
37 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
38 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
38 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
39 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
39 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
40 |
import org.openconcerto.ui.FrameUtil;
|
- |
|
41 |
import org.openconcerto.ui.state.WindowStateManager;
|
- |
|
42 |
import org.openconcerto.ui.table.PercentTableCellRenderer;
|
40 |
import org.openconcerto.ui.table.PercentTableCellRenderer;
|
43 |
import org.openconcerto.utils.CollectionUtils;
|
41 |
import org.openconcerto.utils.CollectionUtils;
|
44 |
import org.openconcerto.utils.DecimalUtils;
|
42 |
import org.openconcerto.utils.DecimalUtils;
|
45 |
|
43 |
|
46 |
import java.awt.GridBagConstraints;
|
44 |
import java.awt.GridBagConstraints;
|
47 |
import java.awt.GridBagLayout;
|
45 |
import java.awt.GridBagLayout;
|
48 |
import java.awt.event.ActionEvent;
|
46 |
import java.awt.event.ActionEvent;
|
49 |
import java.io.File;
|
- |
|
50 |
import java.math.BigDecimal;
|
47 |
import java.math.BigDecimal;
|
51 |
import java.math.RoundingMode;
|
48 |
import java.math.RoundingMode;
|
52 |
import java.util.ArrayList;
|
49 |
import java.util.ArrayList;
|
53 |
import java.util.Collection;
|
50 |
import java.util.Collection;
|
54 |
import java.util.List;
|
51 |
import java.util.List;
|
55 |
import java.util.Set;
|
52 |
import java.util.Set;
|
56 |
|
53 |
|
57 |
import javax.swing.AbstractAction;
|
54 |
import javax.swing.AbstractAction;
|
58 |
import javax.swing.Action;
|
- |
|
59 |
import javax.swing.JFrame;
|
55 |
import javax.swing.JFrame;
|
60 |
import javax.swing.JPanel;
|
56 |
import javax.swing.JPanel;
|
61 |
import javax.swing.JTabbedPane;
|
57 |
import javax.swing.JTabbedPane;
|
62 |
|
58 |
|
63 |
public class ListeDesBonsDeLivraisonAction extends CreateFrameAbstractAction {
|
59 |
public class ListeDesBonsDeLivraisonAction extends CreateListFrameAbstractAction<BonDeLivraisonSQLElement, JFrame> {
|
64 |
|
60 |
|
65 |
public ListeDesBonsDeLivraisonAction() {
|
61 |
public ListeDesBonsDeLivraisonAction(final ComptaPropsConfiguration conf) {
|
66 |
super();
|
- |
|
67 |
this.putValue(Action.NAME, "Liste des bons de livraison");
|
62 |
super(conf, BonDeLivraisonSQLElement.class);
|
68 |
}
|
63 |
}
|
69 |
|
64 |
|
- |
|
65 |
@Override
|
70 |
public JFrame createFrame() {
|
66 |
protected JFrame instantiateFrame() {
|
71 |
final JFrame frame = new JFrame("Bons de livraison");
|
67 |
final JFrame frame = new JFrame(String.valueOf(getValue(NAME)));
|
72 |
PredicateRowAction toInvoiceAction = new PredicateRowAction(new AbstractAction() {
|
68 |
PredicateRowAction toInvoiceAction = new PredicateRowAction(new AbstractAction() {
|
73 |
public void actionPerformed(ActionEvent e) {
|
69 |
public void actionPerformed(ActionEvent e) {
|
74 |
transfertFactureClient(IListe.get(e).getSelectedRows());
|
70 |
transfertFactureClient(IListe.get(e).getSelectedRows());
|
75 |
}
|
71 |
}
|
76 |
}, false, "sales.shipment.create.invoice");
|
72 |
}, false, "sales.shipment.create.invoice");
|
77 |
toInvoiceAction.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
73 |
toInvoiceAction.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
|
78 |
|
74 |
|
79 |
// Tabs
|
75 |
// Tabs
|
80 |
final JTabbedPane tabs = new JTabbedPane();
|
76 |
final JTabbedPane tabs = new JTabbedPane();
|
81 |
tabs.addTab("Toutes les livraisons", createAllDeliveryPanel(toInvoiceAction));
|
77 |
tabs.addTab(TM.tr("sales.shipment.allShipments"), createAllDeliveryPanel(toInvoiceAction));
|
82 |
tabs.addTab("Livraisons non facturées", createDeliveryWithoutInvoicePanel(toInvoiceAction));
|
78 |
tabs.addTab(TM.tr("sales.shipment.nonInvoicedShipments"), createDeliveryWithoutInvoicePanel(toInvoiceAction));
|
83 |
tabs.addTab("Livraisons facturées", createDeliveryWithInvoicePanel());
|
79 |
tabs.addTab(TM.tr("sales.shipment.invoicedShipments"), createDeliveryWithInvoicePanel());
|
84 |
frame.setContentPane(tabs);
|
80 |
frame.setContentPane(tabs);
|
85 |
|
81 |
|
86 |
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON");
|
- |
|
87 |
FrameUtil.setBounds(frame);
|
- |
|
88 |
final File file = IListFrame.getConfigFile(eltCmd, frame.getClass());
|
- |
|
89 |
if (file != null)
|
- |
|
90 |
new WindowStateManager(frame, file).loadState();
|
- |
|
91 |
return frame;
|
82 |
return frame;
|
92 |
}
|
83 |
}
|
93 |
|
84 |
|
94 |
private ListeAddPanel getPanel(final SQLElement eltCmd, final SQLTableModelSourceOnline tableSource, final List<RowAction> allowedActions) {
|
85 |
private ListeAddPanel getPanel(final BonDeLivraisonSQLElement eltCmd, final SQLTableModelSourceOnline tableSource, final List<RowAction> allowedActions) {
|
95 |
final ListeAddPanel panel = new ListeAddPanel(eltCmd, new IListe(tableSource));
|
86 |
final ListeAddPanel panel = new ListeAddPanel(eltCmd, new IListe(tableSource));
|
96 |
|
87 |
|
97 |
final List<SQLField> fields = new ArrayList<SQLField>(2);
|
88 |
final List<SQLField> fields = new ArrayList<SQLField>(2);
|
98 |
fields.add(eltCmd.getTable().getField("TOTAL_HT"));
|
89 |
fields.add(eltCmd.getTable().getField("TOTAL_HT"));
|
99 |
final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, "Total des livraisons de la liste");
|
90 |
final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, TM.tr("sales.shipment.listTotal"));
|
100 |
|
91 |
|
101 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
92 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
102 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
93 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
103 |
c.fill = GridBagConstraints.BOTH;
|
94 |
c.fill = GridBagConstraints.BOTH;
|
104 |
c.anchor = GridBagConstraints.EAST;
|
95 |
c.anchor = GridBagConstraints.EAST;
|
Line 113... |
Line 104... |
113 |
public List<RowAction> addToMenu() {
|
104 |
public List<RowAction> addToMenu() {
|
114 |
return allowedActions;
|
105 |
return allowedActions;
|
115 |
}
|
106 |
}
|
116 |
}.getRowActions());
|
107 |
}.getRowActions());
|
117 |
|
108 |
|
- |
|
109 |
panel.getListe().addIListeAction(eltCmd.getCloneAction());
|
- |
|
110 |
|
118 |
datePanel.setFilterOnDefault();
|
111 |
datePanel.setFilterOnDefault();
|
119 |
|
112 |
|
120 |
final JPanel bottomPanel = new JPanel();
|
113 |
final JPanel bottomPanel = new JPanel();
|
121 |
bottomPanel.setLayout(new GridBagLayout());
|
114 |
bottomPanel.setLayout(new GridBagLayout());
|
122 |
bottomPanel.setOpaque(false);
|
115 |
bottomPanel.setOpaque(false);
|
Line 133... |
Line 126... |
133 |
panel.add(bottomPanel, c);
|
126 |
panel.add(bottomPanel, c);
|
134 |
return panel;
|
127 |
return panel;
|
135 |
}
|
128 |
}
|
136 |
|
129 |
|
137 |
JPanel createAllDeliveryPanel(final PredicateRowAction toInvoiceAction) {
|
130 |
JPanel createAllDeliveryPanel(final PredicateRowAction toInvoiceAction) {
|
138 |
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON");
|
131 |
final BonDeLivraisonSQLElement eltCmd = getElem();
|
139 |
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
|
132 |
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
|
140 |
final List<RowAction> allowedActions = new ArrayList<RowAction>();
|
133 |
final List<RowAction> allowedActions = new ArrayList<RowAction>();
|
141 |
allowedActions.add(toInvoiceAction);
|
134 |
allowedActions.add(toInvoiceAction);
|
142 |
BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) {
|
135 |
BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn(eltCmd.getDirectory().getTranslator().getDescFor(eltCmd.getTable(), "invoiceProgress").getTitleLabel(), BigDecimal.class) {
|
143 |
|
136 |
|
144 |
@Override
|
137 |
@Override
|
145 |
protected Object show_(SQLRowAccessor r) {
|
138 |
protected Object show_(SQLRowAccessor r) {
|
146 |
|
139 |
|
147 |
return getAvancement(r);
|
140 |
return getAvancement(r);
|
Line 176... |
Line 169... |
176 |
return BigDecimal.ONE.movePointRight(2);
|
169 |
return BigDecimal.ONE.movePointRight(2);
|
177 |
}
|
170 |
}
|
178 |
}
|
171 |
}
|
179 |
|
172 |
|
180 |
JPanel createDeliveryWithInvoicePanel() {
|
173 |
JPanel createDeliveryWithInvoicePanel() {
|
181 |
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON");
|
174 |
final BonDeLivraisonSQLElement eltCmd = getElem();
|
182 |
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
|
175 |
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
|
183 |
final List<RowAction> allowedActions = new ArrayList<RowAction>();
|
176 |
final List<RowAction> allowedActions = new ArrayList<RowAction>();
|
184 |
|
177 |
|
185 |
// Filter on transfered
|
178 |
// Filter on transfered
|
186 |
final SQLInjector injector = SQLInjector.getInjector(eltCmd.getTable(), eltCmd.getTable().getTable("SAISIE_VENTE_FACTURE"));
|
179 |
final SQLInjector injector = SQLInjector.getInjector(eltCmd.getTable(), eltCmd.getTable().getTable("SAISIE_VENTE_FACTURE"));
|
Line 189... |
Line 182... |
189 |
final ListeAddPanel panel = getPanel(eltCmd, tableSource, allowedActions);
|
182 |
final ListeAddPanel panel = getPanel(eltCmd, tableSource, allowedActions);
|
190 |
return panel;
|
183 |
return panel;
|
191 |
}
|
184 |
}
|
192 |
|
185 |
|
193 |
JPanel createDeliveryWithoutInvoicePanel(PredicateRowAction toInvoiceAction) {
|
186 |
JPanel createDeliveryWithoutInvoicePanel(PredicateRowAction toInvoiceAction) {
|
194 |
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON");
|
187 |
final BonDeLivraisonSQLElement eltCmd = getElem();
|
195 |
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
|
188 |
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
|
196 |
final List<RowAction> allowedActions = new ArrayList<RowAction>();
|
189 |
final List<RowAction> allowedActions = new ArrayList<RowAction>();
|
197 |
allowedActions.add(toInvoiceAction);
|
190 |
allowedActions.add(toInvoiceAction);
|
198 |
|
191 |
|
199 |
// Filter on not transfered
|
192 |
// Filter on not transfered
|