OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 177 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
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.finance.accounting.element;
14
 package org.openconcerto.erp.core.finance.accounting.element;
15
 
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
18
import org.openconcerto.erp.core.common.ui.DeviseField;
18
import org.openconcerto.erp.core.common.ui.DeviseField;
19
import org.openconcerto.erp.core.common.ui.PanelFrame;
19
import org.openconcerto.erp.core.common.ui.PanelFrame;
20
import org.openconcerto.erp.core.edm.AttachmentAction;
20
import org.openconcerto.erp.core.edm.AttachmentAction;
21
import org.openconcerto.erp.core.finance.accounting.ui.AssociationAnalytiquePanel;
21
import org.openconcerto.erp.core.finance.accounting.ui.AssociationAnalytiquePanel;
22
import org.openconcerto.erp.core.finance.accounting.ui.ConsultationCompteFrame;
22
import org.openconcerto.erp.core.finance.accounting.ui.ConsultationCompteFrame;
23
import org.openconcerto.erp.core.finance.accounting.ui.LettrageRenderer;
23
import org.openconcerto.erp.core.finance.accounting.ui.LettrageRenderer;
24
import org.openconcerto.erp.core.finance.accounting.ui.ListEcritureRenderer;
24
import org.openconcerto.erp.core.finance.accounting.ui.ListEcritureRenderer;
25
import org.openconcerto.erp.core.finance.accounting.ui.ListeDesEcrituresPanel;
25
import org.openconcerto.erp.core.finance.accounting.ui.ListeDesEcrituresPanel;
26
import org.openconcerto.erp.core.finance.accounting.ui.PointageRenderer;
26
import org.openconcerto.erp.core.finance.accounting.ui.PointageRenderer;
27
import org.openconcerto.erp.core.finance.accounting.ui.SuppressionEcrituresPanel;
27
import org.openconcerto.erp.core.finance.accounting.ui.SuppressionEcrituresPanel;
28
import org.openconcerto.sql.Configuration;
28
import org.openconcerto.sql.Configuration;
29
import org.openconcerto.sql.element.BaseSQLComponent;
29
import org.openconcerto.sql.element.BaseSQLComponent;
30
import org.openconcerto.sql.element.SQLComponent;
30
import org.openconcerto.sql.element.SQLComponent;
31
import org.openconcerto.sql.element.SQLElement;
31
import org.openconcerto.sql.element.SQLElement;
32
import org.openconcerto.sql.element.TreesOfSQLRows;
32
import org.openconcerto.sql.element.TreesOfSQLRows;
33
import org.openconcerto.sql.model.FieldPath;
33
import org.openconcerto.sql.model.FieldPath;
34
import org.openconcerto.sql.model.SQLBase;
34
import org.openconcerto.sql.model.SQLBase;
35
import org.openconcerto.sql.model.SQLRow;
35
import org.openconcerto.sql.model.SQLRow;
36
import org.openconcerto.sql.model.SQLRowAccessor;
36
import org.openconcerto.sql.model.SQLRowAccessor;
37
import org.openconcerto.sql.model.SQLRowValues;
37
import org.openconcerto.sql.model.SQLRowValues;
38
import org.openconcerto.sql.model.SQLSelect;
38
import org.openconcerto.sql.model.SQLSelect;
39
import org.openconcerto.sql.model.SQLTable;
39
import org.openconcerto.sql.model.SQLTable;
40
import org.openconcerto.sql.model.Where;
40
import org.openconcerto.sql.model.Where;
41
import org.openconcerto.sql.model.graph.Path;
41
import org.openconcerto.sql.model.graph.Path;
42
import org.openconcerto.sql.request.ListSQLRequest;
42
import org.openconcerto.sql.request.ListSQLRequest;
43
import org.openconcerto.sql.request.UpdateBuilder;
43
import org.openconcerto.sql.request.UpdateBuilder;
44
import org.openconcerto.sql.sqlobject.ElementComboBox;
44
import org.openconcerto.sql.sqlobject.ElementComboBox;
45
import org.openconcerto.sql.users.UserManager;
45
import org.openconcerto.sql.users.UserManager;
46
import org.openconcerto.sql.utils.SQLUtils;
46
import org.openconcerto.sql.utils.SQLUtils;
47
import org.openconcerto.sql.utils.SQLUtils.SQLFactory;
47
import org.openconcerto.sql.utils.SQLUtils.SQLFactory;
48
import org.openconcerto.sql.view.EditFrame;
48
import org.openconcerto.sql.view.EditFrame;
49
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
49
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
50
import org.openconcerto.sql.view.list.IListe;
50
import org.openconcerto.sql.view.list.IListe;
51
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
51
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
52
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
52
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
53
import org.openconcerto.sql.view.list.SQLTableModelColumn;
53
import org.openconcerto.sql.view.list.SQLTableModelColumn;
54
import org.openconcerto.sql.view.list.SQLTableModelSource;
54
import org.openconcerto.sql.view.list.SQLTableModelSource;
55
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
55
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
56
import org.openconcerto.ui.DefaultGridBagConstraints;
56
import org.openconcerto.ui.DefaultGridBagConstraints;
57
import org.openconcerto.ui.JDate;
57
import org.openconcerto.ui.JDate;
58
import org.openconcerto.ui.component.InteractionMode;
58
import org.openconcerto.ui.component.InteractionMode;
59
import org.openconcerto.utils.CollectionUtils;
59
import org.openconcerto.utils.CollectionUtils;
60
import org.openconcerto.utils.ExceptionHandler;
60
import org.openconcerto.utils.ExceptionHandler;
61
import org.openconcerto.utils.convertor.ValueConvertor;
61
import org.openconcerto.utils.convertor.ValueConvertor;
62
 
62
 
63
import java.awt.GridBagConstraints;
63
import java.awt.GridBagConstraints;
64
import java.awt.GridBagLayout;
64
import java.awt.GridBagLayout;
65
import java.awt.event.ActionEvent;
65
import java.awt.event.ActionEvent;
66
import java.awt.event.KeyAdapter;
66
import java.awt.event.KeyAdapter;
67
import java.awt.event.KeyEvent;
67
import java.awt.event.KeyEvent;
68
import java.awt.event.MouseAdapter;
-
 
69
import java.awt.event.MouseEvent;
-
 
70
import java.math.BigDecimal;
68
import java.math.BigDecimal;
71
import java.math.BigInteger;
69
import java.math.BigInteger;
72
import java.sql.SQLException;
70
import java.sql.SQLException;
73
import java.util.ArrayList;
71
import java.util.ArrayList;
74
import java.util.Collection;
72
import java.util.Collection;
75
import java.util.Date;
73
import java.util.Date;
76
import java.util.List;
74
import java.util.List;
77
import java.util.Set;
75
import java.util.Set;
78
 
76
 
79
import javax.swing.AbstractAction;
77
import javax.swing.AbstractAction;
80
import javax.swing.JFrame;
78
import javax.swing.JFrame;
81
import javax.swing.JLabel;
79
import javax.swing.JLabel;
82
import javax.swing.JOptionPane;
80
import javax.swing.JOptionPane;
83
import javax.swing.JPopupMenu;
-
 
84
import javax.swing.JTextField;
81
import javax.swing.JTextField;
85
import javax.swing.SwingUtilities;
82
import javax.swing.SwingUtilities;
86
 
83
 
87
import org.apache.commons.dbutils.handlers.ArrayListHandler;
84
import org.apache.commons.dbutils.handlers.ArrayListHandler;
88
 
85
 
89
public class EcritureSQLElement extends ComptaSQLConfElement {
86
public class EcritureSQLElement extends ComptaSQLConfElement {
90
 
87
 
91
    public EcritureSQLElement() {
88
    public EcritureSQLElement() {
92
        super("ECRITURE", "une écriture", "écritures");
89
        super("ECRITURE", "une écriture", "écritures");
93
        PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction("ID_MOUVEMENT").getAction(), true);
90
        PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction("ID_MOUVEMENT").getAction(), true);
94
        actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
91
        actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
95
        getRowActions().add(actionAttachment);
92
        getRowActions().add(actionAttachment);
96
 
93
 
97
        PredicateRowAction consult = new PredicateRowAction(new AbstractAction("Consultation du compte") {
94
        PredicateRowAction consult = new PredicateRowAction(new AbstractAction("Consultation du compte") {
98
            public void actionPerformed(ActionEvent event) {
95
            public void actionPerformed(ActionEvent event) {
99
                SQLRowAccessor row = IListe.get(event).getSelectedRow();
96
                SQLRowAccessor row = IListe.get(event).getSelectedRow();
100
                consultationCompte(ComptePCESQLElement.getRow(row.getString("COMPTE_NUMERO"), row.getString("COMPTE_NOM")));
97
                consultationCompte(ComptePCESQLElement.getRow(row.getString("COMPTE_NUMERO"), row.getString("COMPTE_NOM")));
101
            }
98
            }
102
        }, false);
99
        }, false);
103
        consult.setPredicate(IListeEvent.getSingleSelectionPredicate());
100
        consult.setPredicate(IListeEvent.getSingleSelectionPredicate());
104
        getRowActions().add(consult);
101
        getRowActions().add(consult);
105
 
102
 
106
        PredicateRowAction contre = new PredicateRowAction(new AbstractAction("Contrepassation") {
103
        PredicateRowAction contre = new PredicateRowAction(new AbstractAction("Contrepassation") {
107
            public void actionPerformed(ActionEvent event) {
104
            public void actionPerformed(ActionEvent event) {
108
                EcritureSQLElement.contrePassationPiece(IListe.get(event).getSelectedId());
105
                EcritureSQLElement.contrePassationPiece(IListe.get(event).getSelectedId());
109
            }
106
            }
110
        }, false);
107
        }, false);
111
        contre.setPredicate(IListeEvent.getSingleSelectionPredicate());
108
        contre.setPredicate(IListeEvent.getSingleSelectionPredicate());
112
        getRowActions().add(contre);
109
        getRowActions().add(contre);
113
        // menuDroit.add(new AbstractAction("Valider le mouvement") {
110
        // menuDroit.add(new AbstractAction("Valider le mouvement") {
114
        // public void actionPerformed(ActionEvent event) {
111
        // public void actionPerformed(ActionEvent event) {
115
        // if (JOptionPane.showConfirmDialog(null, "Etes vous sûr de vouloir valider le
112
        // if (JOptionPane.showConfirmDialog(null, "Etes vous sûr de vouloir valider le
116
        // mouvement?") == JOptionPane.YES_OPTION) {
113
        // mouvement?") == JOptionPane.YES_OPTION) {
117
        // EcritureSQLElement.validationEcritures(frame.getPanel().getListe().getSelectedRow().getInt("ID_MOUVEMENT"));
114
        // EcritureSQLElement.validationEcritures(frame.getPanel().getListe().getSelectedRow().getInt("ID_MOUVEMENT"));
118
        // }
115
        // }
119
        // }
116
        // }
120
        // });
117
        // });
121
 
118
 
122
        PredicateRowAction clone = new PredicateRowAction(new AbstractAction("Dupliquer") {
119
        PredicateRowAction clone = new PredicateRowAction(new AbstractAction("Dupliquer") {
123
            public void actionPerformed(ActionEvent event) {
120
            public void actionPerformed(ActionEvent event) {
124
                EcritureSQLElement.dupliquer(IListe.get(event).fetchSelectedRow());
121
                EcritureSQLElement.dupliquer(IListe.get(event).fetchSelectedRow());
125
            }
122
            }
126
        }, false);
123
        }, false);
127
        clone.setPredicate(IListeEvent.getSingleSelectionPredicate());
124
        clone.setPredicate(IListeEvent.getSingleSelectionPredicate());
128
        getRowActions().add(clone);
125
        getRowActions().add(clone);
129
 
126
 
130
        PredicateRowAction an = new PredicateRowAction(new AbstractAction("Gérer l'analytique") {
127
        PredicateRowAction an = new PredicateRowAction(new AbstractAction("Gérer l'analytique") {
131
            public void actionPerformed(ActionEvent event) {
128
            public void actionPerformed(ActionEvent event) {
132
                PanelFrame frameAssoc = new PanelFrame(new AssociationAnalytiquePanel(IListe.get(event).getSelectedRow().asRow()), "Association analytique");
129
                PanelFrame frameAssoc = new PanelFrame(new AssociationAnalytiquePanel(IListe.get(event).getSelectedRow().asRow()), "Association analytique");
133
                frameAssoc.setVisible(true);
130
                frameAssoc.setVisible(true);
134
            }
131
            }
135
        }, false);
132
        }, false);
136
        an.setPredicate(IListeEvent.getSingleSelectionPredicate());
133
        an.setPredicate(IListeEvent.getSingleSelectionPredicate());
137
        getRowActions().add(an);
134
        getRowActions().add(an);
138
 
135
 
139
        PredicateRowAction show = new PredicateRowAction(new AbstractAction("Voir la source") {
136
        PredicateRowAction show = new PredicateRowAction(new AbstractAction("Voir la source") {
140
            public void actionPerformed(ActionEvent event) {
137
            public void actionPerformed(ActionEvent event) {
141
 
138
 
142
                SQLRow row = IListe.get(event).fetchSelectedRow();
139
                SQLRow row = IListe.get(event).fetchSelectedRow();
143
 
140
 
144
                MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
141
                MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
145
            }
142
            }
146
        }, false);
143
        }, false);
147
        show.setPredicate(IListeEvent.getSingleSelectionPredicate());
144
        show.setPredicate(IListeEvent.getSingleSelectionPredicate());
148
        getRowActions().add(show);
145
        getRowActions().add(show);
149
    }
146
    }
150
 
147
 
151
    @Override
148
    @Override
152
    protected String getParentFFName() {
149
    protected String getParentFFName() {
153
        return "ID_MOUVEMENT";
150
        return "ID_MOUVEMENT";
154
    }
151
    }
155
 
152
 
-
 
153
    @Override
-
 
154
    public boolean isPrivate() {
-
 
155
        return false;
-
 
156
    }
-
 
157
 
156
    // Impossible de modifier si validée
158
    // Impossible de modifier si validée
157
    // FIXME impossible de saisir une écriture avant la date de debut d'exercice --> de saisir de
159
    // FIXME impossible de saisir une écriture avant la date de debut d'exercice --> de saisir de
158
    // document de gest comm
160
    // document de gest comm
159
 
161
 
160
    public List<String> getListFields() {
162
    public List<String> getListFields() {
161
        final List<String> l = new ArrayList<String>();
163
        final List<String> l = new ArrayList<String>();
162
        l.add("VALIDE");
164
        l.add("VALIDE");
163
        l.add("ID_MOUVEMENT");
165
        l.add("ID_MOUVEMENT");
164
        if (getTable().contains("NOM_PIECE")) {
166
        if (getTable().contains("NOM_PIECE")) {
165
            l.add("NOM_PIECE");
167
            l.add("NOM_PIECE");
166
        }
168
        }
167
        // l.add("ID_COMPTE_PCE");
169
        // l.add("ID_COMPTE_PCE");
168
        l.add("COMPTE_NUMERO");
170
        l.add("COMPTE_NUMERO");
169
        l.add("COMPTE_NOM");
171
        l.add("COMPTE_NOM");
170
        // l.add("ID_JOURNAL");
172
        // l.add("ID_JOURNAL");
171
        l.add("JOURNAL_NOM");
173
        l.add("JOURNAL_NOM");
172
        l.add("NOM");
174
        l.add("NOM");
173
        l.add("DATE");
175
        l.add("DATE");
174
 
176
 
175
        l.add("DEBIT");
177
        l.add("DEBIT");
176
        l.add("CREDIT");
178
        l.add("CREDIT");
177
 
179
 
178
        return l;
180
        return l;
179
    }
181
    }
180
 
182
 
181
    protected List<String> getComboFields() {
183
    protected List<String> getComboFields() {
182
        final List<String> l = new ArrayList<String>();
184
        final List<String> l = new ArrayList<String>();
183
        l.add("NOM");
185
        l.add("NOM");
184
        l.add("DATE");
186
        l.add("DATE");
185
        l.add("DEBIT");
187
        l.add("DEBIT");
186
        l.add("CREDIT");
188
        l.add("CREDIT");
187
        l.add("ID_JOURNAL");
189
        l.add("ID_JOURNAL");
188
        l.add("ID_MOUVEMENT");
190
        l.add("ID_MOUVEMENT");
189
        return l;
191
        return l;
190
    }
192
    }
191
 
193
 
192
    @Override
194
    @Override
193
    protected void _initListRequest(ListSQLRequest req) {
195
    protected void _initListRequest(ListSQLRequest req) {
194
        super._initListRequest(req);
196
        super._initListRequest(req);
195
        req.addToGraphToFetch("VALIDE");
197
        req.addToGraphToFetch("VALIDE");
196
    }
198
    }
197
 
199
 
198
    public void consultationCompte(SQLRowAccessor rowCpt) {
200
    public void consultationCompte(SQLRowAccessor rowCpt) {
199
        final ConsultationCompteFrame f = new ConsultationCompteFrame(new ListeDesEcrituresPanel(), "Consultation compte n°" + rowCpt.getString("NUMERO") + " " + rowCpt.getString("NOM"));
-
 
200
 
-
 
201
        f.getPanel().getListe().getJTable().addMouseListener(new MouseAdapter() {
-
 
202
 
-
 
203
            public void mousePressed(final MouseEvent mE) {
-
 
204
 
-
 
205
                if (mE.getButton() == MouseEvent.BUTTON3) {
-
 
206
                    JPopupMenu menuDroit = new JPopupMenu();
-
 
207
 
-
 
208
                    menuDroit.add(new AbstractAction("Voir les ecritures du journal") {
201
        final ListeDesEcrituresPanel panel = new ListeDesEcrituresPanel();
209
 
-
 
210
                        public void actionPerformed(ActionEvent e) {
-
 
211
                            int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
-
 
212
                            // int id = f.getPanel().getListe().getSelectedId();
-
 
213
 
-
 
214
                            SQLTable ecrTable = getTable().getTable("ECRITURE");
-
 
215
 
-
 
216
                            System.err.println("Ecritures ID ::: " + id);
-
 
217
                            SQLRow rowEcr = ecrTable.getRow(id);
-
 
218
 
-
 
219
                            System.err.println("Ecritures ID ::: " + id + " --> ID_JOURNAL = " + rowEcr.getInt("ID_JOURNAL"));
-
 
220
 
-
 
221
                            ConsultationCompteFrame f2 = new ConsultationCompteFrame(new ListeDesEcrituresPanel(),
202
        final ConsultationCompteFrame f = new ConsultationCompteFrame(panel, rowCpt);
222
                                    "Consultation du journal " + getTable().getTable("JOURNAL").getRow(rowEcr.getInt("ID_JOURNAL")).getString("NOM"));
-
 
223
 
-
 
224
                            Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", rowEcr.getInt("ID_JOURNAL"));
-
 
225
 
-
 
226
                            f2.getPanel().getListe().getRequest().setWhere(w);
-
 
227
                            f2.getPanel().getListe().setModificationAllowed(false);
-
 
228
                            f2.pack();
-
 
229
                            f2.setVisible(true);
-
 
230
                        }
-
 
231
                    });
-
 
232
 
-
 
233
                    menuDroit.add(new AbstractAction("Voir la source") {
-
 
234
 
-
 
235
                        public void actionPerformed(ActionEvent e) {
-
 
236
 
-
 
237
                            // int id = f.getPanel().getListe().getSelectedId();
-
 
238
                            int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
-
 
239
                            System.err.println("ID COMPTE SELECTED " + id);
-
 
240
                            SQLRow rowEcr = getTable().getTable("ECRITURE").getRow(id);
-
 
241
 
-
 
242
                            System.out.println("MOUVEMENT VALIDE ------------->>>>>>>>>>>>>> " + MouvementSQLElement.isEditable(rowEcr.getInt("ID_MOUVEMENT")));
-
 
243
 
-
 
244
                            MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT"));
-
 
245
 
-
 
246
                            System.out.println("Mouvement Numero : " + rowEcr.getInt("ID_MOUVEMENT"));
-
 
247
                        }
-
 
248
                    });
-
 
249
 
-
 
250
                    menuDroit.show(mE.getComponent(), mE.getX(), mE.getY());
-
 
251
                }
-
 
252
            }
-
 
253
        });
-
 
254
 
-
 
255
        SQLTable ecrTable = getTable().getTable("ECRITURE");
-
 
256
 
-
 
257
        Where w = new Where(ecrTable.getField("ID_COMPTE_PCE"), "=", rowCpt.getID());
-
 
258
        f.getPanel().getListe().getRequest().setWhere(w);
-
 
259
 
203
 
260
        f.getPanel().getListe().setModificationAllowed(false);
204
        f.getPanel().getListe().setModificationAllowed(false);
261
        f.pack();
205
        f.pack();
262
        f.setVisible(true);
206
        f.setVisible(true);
263
    }
207
    }
264
 
208
 
265
    @Override
209
    @Override
266
    protected void _initTableSource(SQLTableModelSource res) {
210
    protected void _initTableSource(SQLTableModelSource res) {
267
        super._initTableSource(res);
211
        super._initTableSource(res);
268
        BaseSQLTableModelColumn analytique = new BaseSQLTableModelColumn("Poste analytique", String.class) {
212
        BaseSQLTableModelColumn analytique = new BaseSQLTableModelColumn("Poste analytique", String.class) {
269
 
213
 
270
            @Override
214
            @Override
271
            protected Object show_(SQLRowAccessor r) {
215
            protected Object show_(SQLRowAccessor r) {
272
                Collection<? extends SQLRowAccessor> assocs = r.getReferentRows(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
216
                Collection<? extends SQLRowAccessor> assocs = r.getReferentRows(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
273
                StringBuffer res = new StringBuffer();
217
                StringBuffer res = new StringBuffer();
274
 
218
 
275
                for (SQLRowAccessor sqlRowAccessor : assocs) {
219
                for (SQLRowAccessor sqlRowAccessor : assocs) {
276
                    res.append(sqlRowAccessor.getForeign("ID_POSTE_ANALYTIQUE").getString("NOM"));
220
                    res.append(sqlRowAccessor.getForeign("ID_POSTE_ANALYTIQUE").getString("NOM"));
277
                    res.append(", ");
221
                    res.append(", ");
278
                }
222
                }
279
 
223
 
280
                return res.toString();
224
                return res.toString();
281
            }
225
            }
282
 
226
 
283
            @Override
227
            @Override
284
            public Set<FieldPath> getPaths() {
228
            public Set<FieldPath> getPaths() {
285
                Path p = new Path(getTable());
229
                Path p = new Path(getTable());
286
                p = p.add(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
230
                p = p.add(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
287
                p = p.add(p.getLast().getForeignTable("ID_POSTE_ANALYTIQUE"));
231
                p = p.add(p.getLast().getForeignTable("ID_POSTE_ANALYTIQUE"));
288
                return CollectionUtils.createSet(new FieldPath(p, "NOM"));
232
                return CollectionUtils.createSet(new FieldPath(p, "NOM"));
289
            }
233
            }
290
        };
234
        };
291
        res.getColumns().add(analytique);
235
        res.getColumns().add(analytique);
292
        for (SQLTableModelColumn col : res.getColumns()) {
236
        for (SQLTableModelColumn col : res.getColumns()) {
293
            col.setRenderer(ListEcritureRenderer.UTILS.getRenderer(col.getRenderer()));
237
            col.setRenderer(ListEcritureRenderer.UTILS.getRenderer(col.getRenderer()));
294
        }
238
        }
295
    }
239
    }
296
 
240
 
297
    public final SQLTableModelSourceOnline createPointageTableSource() {
241
    public final SQLTableModelSourceOnline createPointageTableSource() {
298
        final List<String> listEcriture = new ArrayList<String>();
242
        final List<String> listEcriture = new ArrayList<String>();
299
        listEcriture.add("POINTEE");
243
        listEcriture.add("POINTEE");
300
        listEcriture.add("DATE_POINTEE");
244
        listEcriture.add("DATE_POINTEE");
301
        listEcriture.add("ID_MOUVEMENT");
245
        listEcriture.add("ID_MOUVEMENT");
302
        listEcriture.add("NOM");
246
        listEcriture.add("NOM");
303
        listEcriture.add("DATE");
247
        listEcriture.add("DATE");
304
        listEcriture.add("DEBIT");
248
        listEcriture.add("DEBIT");
305
        listEcriture.add("CREDIT");
249
        listEcriture.add("CREDIT");
306
        final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
250
        final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
307
        for (SQLTableModelColumn col : res.getColumns()) {
251
        for (SQLTableModelColumn col : res.getColumns()) {
308
            if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
252
            if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
309
                col.setConverter(new ValueConvertor<Number, BigDecimal>() {
253
                col.setConverter(new ValueConvertor<Number, BigDecimal>() {
310
                    @Override
254
                    @Override
311
                    public BigDecimal convert(Number o) {
255
                    public BigDecimal convert(Number o) {
312
                        if (o == null) {
256
                        if (o == null) {
313
                            return BigDecimal.ZERO;
257
                            return BigDecimal.ZERO;
314
                        }
258
                        }
315
                        return new BigDecimal(o.longValue()).movePointLeft(2);
259
                        return new BigDecimal(o.longValue()).movePointLeft(2);
316
                    }
260
                    }
317
 
261
 
318
                    @Override
262
                    @Override
319
                    public Number unconvert(BigDecimal o) {
263
                    public Number unconvert(BigDecimal o) {
320
 
264
 
321
                        if (o == null) {
265
                        if (o == null) {
322
                            return 0;
266
                            return 0;
323
                        }
267
                        }
324
                        return o.movePointRight(2);
268
                        return o.movePointRight(2);
325
                    }
269
                    }
326
                }, BigDecimal.class);
270
                }, BigDecimal.class);
327
                col.setRenderer(CURRENCY_RENDERER);
271
                col.setRenderer(CURRENCY_RENDERER);
328
            }
272
            }
329
 
273
 
330
            col.setRenderer(PointageRenderer.UTILS.getRenderer(col.getRenderer()));
274
            col.setRenderer(PointageRenderer.UTILS.getRenderer(col.getRenderer()));
331
        }
275
        }
332
        return this.initTableSource(res, true);
276
        return this.initTableSource(res, true);
333
    }
277
    }
334
 
278
 
335
    public final SQLTableModelSourceOnline createLettrageTableSource() {
279
    public final SQLTableModelSourceOnline createLettrageTableSource() {
336
        final List<String> listEcriture = new ArrayList<String>();
280
        final List<String> listEcriture = new ArrayList<String>();
337
        listEcriture.add("LETTRAGE");
281
        listEcriture.add("LETTRAGE");
338
        listEcriture.add("ID_COMPTE_PCE");
282
        listEcriture.add("ID_COMPTE_PCE");
339
        listEcriture.add("ID_MOUVEMENT");
283
        listEcriture.add("ID_MOUVEMENT");
340
        if (getTable().contains("NOM_PIECE")) {
284
        if (getTable().contains("NOM_PIECE")) {
341
            listEcriture.add("NOM_PIECE");
285
            listEcriture.add("NOM_PIECE");
342
        }
286
        }
343
        listEcriture.add("NOM");
287
        listEcriture.add("NOM");
344
        listEcriture.add("DATE_LETTRAGE");
288
        listEcriture.add("DATE_LETTRAGE");
345
        listEcriture.add("DATE");
289
        listEcriture.add("DATE");
346
        listEcriture.add("DEBIT");
290
        listEcriture.add("DEBIT");
347
        listEcriture.add("CREDIT");
291
        listEcriture.add("CREDIT");
348
        final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
292
        final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
349
        for (SQLTableModelColumn col : res.getColumns()) {
293
        for (SQLTableModelColumn col : res.getColumns()) {
350
            if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
294
            if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
351
                col.setConverter(new ValueConvertor<Number, BigDecimal>() {
295
                col.setConverter(new ValueConvertor<Number, BigDecimal>() {
352
                    @Override
296
                    @Override
353
                    public BigDecimal convert(Number o) {
297
                    public BigDecimal convert(Number o) {
354
                        if (o == null) {
298
                        if (o == null) {
355
                            return BigDecimal.ZERO;
299
                            return BigDecimal.ZERO;
356
                        }
300
                        }
357
                        return new BigDecimal(o.longValue()).movePointLeft(2);
301
                        return new BigDecimal(o.longValue()).movePointLeft(2);
358
                    }
302
                    }
359
 
303
 
360
                    @Override
304
                    @Override
361
                    public Number unconvert(BigDecimal o) {
305
                    public Number unconvert(BigDecimal o) {
362
 
306
 
363
                        if (o == null) {
307
                        if (o == null) {
364
                            return 0;
308
                            return 0;
365
                        }
309
                        }
366
                        return o.movePointRight(2);
310
                        return o.movePointRight(2);
367
                    }
311
                    }
368
                }, BigDecimal.class);
312
                }, BigDecimal.class);
369
                col.setRenderer(CURRENCY_RENDERER);
313
                col.setRenderer(CURRENCY_RENDERER);
370
            }
314
            }
371
            col.setRenderer(LettrageRenderer.UTILS.getRenderer(col.getRenderer()));
315
            col.setRenderer(LettrageRenderer.UTILS.getRenderer(col.getRenderer()));
372
        }
316
        }
373
        return this.initTableSource(res, true);
317
        return this.initTableSource(res, true);
374
    }
318
    }
375
 
319
 
376
    /*
320
    /*
377
     * (non-Javadoc)
321
     * (non-Javadoc)
378
     * 
322
     * 
379
     * @see org.openconcerto.devis.SQLElement#getComponent()
323
     * @see org.openconcerto.devis.SQLElement#getComponent()
380
     */
324
     */
381
    public SQLComponent createComponent() {
325
    public SQLComponent createComponent() {
382
        return new BaseSQLComponent(this) {
326
        return new BaseSQLComponent(this) {
383
 
327
 
384
            private JTextField nom;
328
            private JTextField nom;
385
            private DeviseField debit;
329
            private DeviseField debit;
386
            private DeviseField credit;
330
            private DeviseField credit;
387
            private JDate date;
331
            private JDate date;
388
            private ElementComboBox journal;
332
            private ElementComboBox journal;
389
 
333
 
390
            public void addViews() {
334
            public void addViews() {
391
                this.setLayout(new GridBagLayout());
335
                this.setLayout(new GridBagLayout());
392
                final GridBagConstraints c = new DefaultGridBagConstraints();
336
                final GridBagConstraints c = new DefaultGridBagConstraints();
393
 
337
 
394
                this.nom = new JTextField();
338
                this.nom = new JTextField();
395
                this.debit = new DeviseField();
339
                this.debit = new DeviseField();
396
                this.credit = new DeviseField();
340
                this.credit = new DeviseField();
397
                this.date = new JDate();
341
                this.date = new JDate();
398
                this.journal = new ElementComboBox();
342
                this.journal = new ElementComboBox();
399
                // Mouvement
343
                // Mouvement
400
                /*
344
                /*
401
                 * JLabel labelMouvement = new JLabel("Mouvement"); this.add(labelMouvement, c);
345
                 * JLabel labelMouvement = new JLabel("Mouvement"); this.add(labelMouvement, c);
402
                 * 
346
                 * 
403
                 * c.gridx ++; c.weightx = 1; this.add(idMouvement, c);
347
                 * c.gridx ++; c.weightx = 1; this.add(idMouvement, c);
404
                 */
348
                 */
405
 
349
 
406
                // Journal
350
                // Journal
407
                JLabel labelJournal = new JLabel("Journal");
351
                JLabel labelJournal = new JLabel("Journal");
408
                c.gridx = 0;
352
                c.gridx = 0;
409
                this.add(labelJournal, c);
353
                this.add(labelJournal, c);
410
 
354
 
411
                c.gridx++;
355
                c.gridx++;
412
                c.weightx = 1;
356
                c.weightx = 1;
413
                this.add(this.journal, c);
357
                this.add(this.journal, c);
414
 
358
 
415
                // Date
359
                // Date
416
                JLabel labelDate = new JLabel("Date");
360
                JLabel labelDate = new JLabel("Date");
417
                c.gridx++;
361
                c.gridx++;
418
                this.add(labelDate, c);
362
                this.add(labelDate, c);
419
 
363
 
420
                c.gridx++;
364
                c.gridx++;
421
                c.weightx = 1;
365
                c.weightx = 1;
422
                this.add(this.date, c);
366
                this.add(this.date, c);
423
 
367
 
424
                // libellé
368
                // libellé
425
                JLabel labelNom = new JLabel("Libellé");
369
                JLabel labelNom = new JLabel("Libellé");
426
                c.gridy++;
370
                c.gridy++;
427
                c.gridx = 0;
371
                c.gridx = 0;
428
                this.add(labelNom, c);
372
                this.add(labelNom, c);
429
 
373
 
430
                c.gridx++;
374
                c.gridx++;
431
                c.weightx = 1;
375
                c.weightx = 1;
432
                c.gridwidth = GridBagConstraints.REMAINDER;
376
                c.gridwidth = GridBagConstraints.REMAINDER;
433
                this.add(this.nom, c);
377
                this.add(this.nom, c);
434
 
378
 
435
                // debit
379
                // debit
436
                c.gridwidth = 1;
380
                c.gridwidth = 1;
437
                JLabel labelDebit = new JLabel("Debit");
381
                JLabel labelDebit = new JLabel("Debit");
438
                c.gridy++;
382
                c.gridy++;
439
                c.gridx = 0;
383
                c.gridx = 0;
440
                this.add(labelDebit, c);
384
                this.add(labelDebit, c);
441
 
385
 
442
                c.gridx++;
386
                c.gridx++;
443
                c.weightx = 1;
387
                c.weightx = 1;
444
                this.add(this.debit, c);
388
                this.add(this.debit, c);
445
                this.debit.addKeyListener(new KeyAdapter() {
389
                this.debit.addKeyListener(new KeyAdapter() {
446
                    public void keyReleased(KeyEvent e) {
390
                    public void keyReleased(KeyEvent e) {
447
                        if ((credit.getText().trim().length() != 0) && (debit.getText().trim().length() != 0)) {
391
                        if ((credit.getText().trim().length() != 0) && (debit.getText().trim().length() != 0)) {
448
                            credit.setText("");
392
                            credit.setText("");
449
                        }
393
                        }
450
                    }
394
                    }
451
                });
395
                });
452
 
396
 
453
                // Credit
397
                // Credit
454
                JLabel labelCredit = new JLabel("Credit");
398
                JLabel labelCredit = new JLabel("Credit");
455
                c.gridx++;
399
                c.gridx++;
456
                this.add(labelCredit, c);
400
                this.add(labelCredit, c);
457
 
401
 
458
                c.gridx++;
402
                c.gridx++;
459
                c.weightx = 1;
403
                c.weightx = 1;
460
                this.add(this.credit, c);
404
                this.add(this.credit, c);
461
 
405
 
462
                this.credit.addKeyListener(new KeyAdapter() {
406
                this.credit.addKeyListener(new KeyAdapter() {
463
                    public void keyReleased(KeyEvent e) {
407
                    public void keyReleased(KeyEvent e) {
464
                        if ((debit.getText().trim().length() != 0) && (credit.getText().trim().length() != 0)) {
408
                        if ((debit.getText().trim().length() != 0) && (credit.getText().trim().length() != 0)) {
465
                            debit.setText("");
409
                            debit.setText("");
466
                        }
410
                        }
467
                    }
411
                    }
468
                });
412
                });
469
 
413
 
470
                this.addSQLObject(this.nom, "NOM");
414
                this.addSQLObject(this.nom, "NOM");
471
                this.addSQLObject(this.debit, "DEBIT");
415
                this.addSQLObject(this.debit, "DEBIT");
472
                this.addSQLObject(this.credit, "CREDIT");
416
                this.addSQLObject(this.credit, "CREDIT");
473
                this.addRequiredSQLObject(this.date, "DATE");
417
                this.addRequiredSQLObject(this.date, "DATE");
474
                this.addRequiredSQLObject(this.journal, "ID_JOURNAL");
418
                this.addRequiredSQLObject(this.journal, "ID_JOURNAL");
475
            }
419
            }
476
 
420
 
477
            @Override
421
            @Override
478
            public void select(SQLRowAccessor r) {
422
            public void select(SQLRowAccessor r) {
479
                super.select(r);
423
                super.select(r);
480
 
424
 
481
                if (r != null && r.getBoolean("VALIDE")) {
425
                if (r != null && r.getBoolean("VALIDE")) {
482
                    this.nom.setEnabled(false);
426
                    this.nom.setEnabled(false);
483
                    this.debit.setEnabled(false);
427
                    this.debit.setEnabled(false);
484
                    this.credit.setEnabled(false);
428
                    this.credit.setEnabled(false);
485
                    this.date.setInteractionMode(InteractionMode.DISABLED);
429
                    this.date.setInteractionMode(InteractionMode.DISABLED);
486
                    this.journal.setEnabled(false);
430
                    this.journal.setEnabled(false);
487
                }
431
                }
488
 
432
 
489
            }
433
            }
490
 
434
 
491
            public void update() {
435
            public void update() {
492
                SQLRow row = EcritureSQLElement.this.getTable().getRow(getSelectedID());
436
                SQLRow row = EcritureSQLElement.this.getTable().getRow(getSelectedID());
493
                if (row.getBoolean("VALIDE")) {
437
                if (row.getBoolean("VALIDE")) {
494
                    System.out.println("Impossible de modifier une ecriture validée");
438
                    System.out.println("Impossible de modifier une ecriture validée");
495
                } else {
439
                } else {
496
                    super.update();
440
                    super.update();
497
                }
441
                }
498
            }
442
            }
499
 
443
 
500
        };
444
        };
501
    }
445
    }
502
 
446
 
503
    /**
447
    /**
504
     * Validation d'un mouvement, implique la validation de l'ensemble de la piece
448
     * Validation d'un mouvement, implique la validation de l'ensemble de la piece
505
     * 
449
     * 
506
     * @param idMvt
450
     * @param idMvt
507
     */
451
     */
508
    private static void validerMouvement(int idMvt) {
452
    private static void validerMouvement(int idMvt) {
509
 
453
 
510
        if (idMvt == 1) {
454
        if (idMvt == 1) {
511
            return;
455
            return;
512
        }
456
        }
513
 
457
 
514
        SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
458
        SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
515
        SQLRow rowMvt = tableMvt.getRow(idMvt);
459
        SQLRow rowMvt = tableMvt.getRow(idMvt);
516
 
460
 
517
        // On parcourt en profondeur
461
        // On parcourt en profondeur
518
        if (rowMvt.getInt("ID_MOUVEMENT_PERE") > 1) {
462
        if (rowMvt.getInt("ID_MOUVEMENT_PERE") > 1) {
519
            validerMouvement(rowMvt.getInt("ID_MOUVEMENT_PERE"));
463
            validerMouvement(rowMvt.getInt("ID_MOUVEMENT_PERE"));
520
        } else {
464
        } else {
521
            validerMouvementProfondeur(idMvt);
465
            validerMouvementProfondeur(idMvt);
522
        }
466
        }
523
    }
467
    }
524
 
468
 
525
    /**
469
    /**
526
     * Valider l'ensemble des mouvements formés par le sous arbre de du mouvement d'id idMvtPere
470
     * Valider l'ensemble des mouvements formés par le sous arbre de du mouvement d'id idMvtPere
527
     * 
471
     * 
528
     * @param idMvtPere
472
     * @param idMvtPere
529
     */
473
     */
530
    private static void validerMouvementProfondeur(int idMvtPere) {
474
    private static void validerMouvementProfondeur(int idMvtPere) {
531
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
475
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
532
        SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
476
        SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
533
 
477
 
534
        SQLSelect selectFils = new SQLSelect();
478
        SQLSelect selectFils = new SQLSelect();
535
        selectFils.addSelect(tableMvt.getField("ID"));
479
        selectFils.addSelect(tableMvt.getField("ID"));
536
        selectFils.setWhere(tableMvt.getField("ID_MOUVEMENT_PERE"), "=", idMvtPere);
480
        selectFils.setWhere(tableMvt.getField("ID_MOUVEMENT_PERE"), "=", idMvtPere);
537
 
481
 
538
        List l = (List) base.getDataSource().execute(selectFils.asString(), new ArrayListHandler());
482
        List l = (List) base.getDataSource().execute(selectFils.asString(), new ArrayListHandler());
539
 
483
 
540
        // valide mouvements fils
484
        // valide mouvements fils
541
        for (int i = 0; i < l.size(); i++) {
485
        for (int i = 0; i < l.size(); i++) {
542
            Object[] tmp = (Object[]) l.get(i);
486
            Object[] tmp = (Object[]) l.get(i);
543
            validerMouvementProfondeur(Integer.parseInt(tmp[0].toString()));
487
            validerMouvementProfondeur(Integer.parseInt(tmp[0].toString()));
544
        }
488
        }
545
 
489
 
546
        // valide mouvement
490
        // valide mouvement
547
        validationEcritures(idMvtPere);
491
        validationEcritures(idMvtPere);
548
    }
492
    }
549
 
493
 
550
    /**
494
    /**
551
     * Valide l'ensemble des ecritures du mouvement
495
     * Valide l'ensemble des ecritures du mouvement
552
     * 
496
     * 
553
     * @param idMvt Id du mouvement à valider
497
     * @param idMvt Id du mouvement à valider
554
     */
498
     */
555
    public static final void validationEcritures(int idMvt) {
499
    public static final void validationEcritures(int idMvt) {
556
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
500
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
557
        SQLTable tableEcriture = base.getTable("ECRITURE");
501
        SQLTable tableEcriture = base.getTable("ECRITURE");
558
 
502
 
559
        SQLSelect selEcriture = new SQLSelect(base);
503
        SQLSelect selEcriture = new SQLSelect(base);
560
        selEcriture.addSelect(tableEcriture.getField("ID"));
504
        selEcriture.addSelect(tableEcriture.getField("ID"));
561
 
505
 
562
        Where w = new Where(tableEcriture.getField("ID_MOUVEMENT"), "=", idMvt);
506
        Where w = new Where(tableEcriture.getField("ID_MOUVEMENT"), "=", idMvt);
563
 
507
 
564
        selEcriture.setWhere(w);
508
        selEcriture.setWhere(w);
565
 
509
 
566
        String reqEcriture = selEcriture.asString();
510
        String reqEcriture = selEcriture.asString();
567
 
511
 
568
        Object obEcriture = base.getDataSource().execute(reqEcriture, new ArrayListHandler());
512
        Object obEcriture = base.getDataSource().execute(reqEcriture, new ArrayListHandler());
569
 
513
 
570
        List myListEcriture = (List) obEcriture;
514
        List myListEcriture = (List) obEcriture;
571
 
515
 
572
        if (myListEcriture.size() != 0) {
516
        if (myListEcriture.size() != 0) {
573
 
517
 
574
            for (int i = 0; i < myListEcriture.size(); i++) {
518
            for (int i = 0; i < myListEcriture.size(); i++) {
575
                Object[] objTmp = (Object[]) myListEcriture.get(i);
519
                Object[] objTmp = (Object[]) myListEcriture.get(i);
576
                valideEcriture(Integer.parseInt(objTmp[0].toString()));
520
                valideEcriture(Integer.parseInt(objTmp[0].toString()));
577
            }
521
            }
578
        }
522
        }
579
    }
523
    }
580
 
524
 
581
    /**
525
    /**
582
     * Validation des ecritures avant la date d
526
     * Validation des ecritures avant la date d
583
     * 
527
     * 
584
     * @param d date
528
     * @param d date
585
     * @param cloture
529
     * @param cloture
586
     */
530
     */
587
    public static final void validationEcrituresBefore(Date d, boolean cloture) {
531
    public static final void validationEcrituresBefore(Date d, boolean cloture) {
588
 
532
 
589
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
533
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
590
        SQLTable tableEcriture = base.getTable("ECRITURE");
534
        SQLTable tableEcriture = base.getTable("ECRITURE");
591
 
535
 
592
        // on recupere l'ensemble des mouvements à valider
536
        // on recupere l'ensemble des mouvements à valider
593
        SQLSelect selEcriture = new SQLSelect(base);
537
        SQLSelect selEcriture = new SQLSelect(base);
594
        selEcriture.addSelect(tableEcriture.getField("ID_MOUVEMENT"));
538
        selEcriture.addSelect(tableEcriture.getField("ID_MOUVEMENT"));
595
        selEcriture.setDistinct(true);
539
        selEcriture.setDistinct(true);
596
        Where w1 = new Where(tableEcriture.getField("DATE"), "<=", d);
540
        Where w1 = new Where(tableEcriture.getField("DATE"), "<=", d);
597
        Where w2 = new Where(tableEcriture.getField("VALIDE"), "=", Boolean.FALSE);
541
        Where w2 = new Where(tableEcriture.getField("VALIDE"), "=", Boolean.FALSE);
598
        selEcriture.setWhere(w1.and(w2));
542
        selEcriture.setWhere(w1.and(w2));
599
        List l = (List) base.getDataSource().execute(selEcriture.asString(), new ArrayListHandler());
543
        List l = (List) base.getDataSource().execute(selEcriture.asString(), new ArrayListHandler());
600
 
544
 
601
        // validation de tous les mouvements
545
        // validation de tous les mouvements
602
        for (int i = 0; i < l.size(); i++) {
546
        for (int i = 0; i < l.size(); i++) {
603
            Object[] tmp = (Object[]) l.get(i);
547
            Object[] tmp = (Object[]) l.get(i);
604
            System.err.println("Validation du mouvement " + tmp[0]);
548
            System.err.println("Validation du mouvement " + tmp[0]);
605
            validationEcritures(Integer.parseInt(tmp[0].toString()));
549
            validationEcritures(Integer.parseInt(tmp[0].toString()));
606
        }
550
        }
607
 
551
 
608
        if (cloture) {
552
        if (cloture) {
609
 
553
 
610
            SQLTable tableExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON");
554
            SQLTable tableExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON");
611
 
555
 
612
            SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
556
            SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
613
            SQLRow rowExercice = tableExercice.getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
557
            SQLRow rowExercice = tableExercice.getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
614
            Date dateCloture = (Date) rowExercice.getObject("DATE_CLOTURE");
558
            Date dateCloture = (Date) rowExercice.getObject("DATE_CLOTURE");
615
 
559
 
616
            if (dateCloture == null || dateCloture.before(d)) {
560
            if (dateCloture == null || dateCloture.before(d)) {
617
 
561
 
618
                SQLRowValues rowVals = new SQLRowValues(tableExercice);
562
                SQLRowValues rowVals = new SQLRowValues(tableExercice);
619
                rowVals.put("DATE_CLOTURE", new java.sql.Date(d.getTime()));
563
                rowVals.put("DATE_CLOTURE", new java.sql.Date(d.getTime()));
620
                try {
564
                try {
621
                    rowVals.update(rowExercice.getID());
565
                    rowVals.update(rowExercice.getID());
622
                } catch (SQLException e) {
566
                } catch (SQLException e) {
623
                    e.printStackTrace();
567
                    e.printStackTrace();
624
                }
568
                }
625
            }
569
            }
626
        }
570
        }
627
    }
571
    }
628
 
572
 
629
    private static final void valideEcriture(int id) {
573
    private static final void valideEcriture(int id) {
630
        SQLTable tableEcriture = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("ECRITURE");
574
        SQLTable tableEcriture = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("ECRITURE");
631
        SQLRowValues rowVals = new SQLRowValues(tableEcriture);
575
        SQLRowValues rowVals = new SQLRowValues(tableEcriture);
632
        rowVals.put("VALIDE", Boolean.TRUE);
576
        rowVals.put("VALIDE", Boolean.TRUE);
633
        rowVals.put("DATE_VALIDE", new java.sql.Date(new Date().getTime()));
577
        rowVals.put("DATE_VALIDE", new java.sql.Date(new Date().getTime()));
634
        rowVals.put("IDUSER_VALIDE", UserManager.getInstance().getCurrentUser().getId());
578
        rowVals.put("IDUSER_VALIDE", UserManager.getInstance().getCurrentUser().getId());
635
 
579
 
636
        try {
580
        try {
637
            rowVals.update(id);
581
            rowVals.update(id);
638
        } catch (SQLException e) {
582
        } catch (SQLException e) {
639
            e.printStackTrace();
583
            e.printStackTrace();
640
        }
584
        }
641
    }
585
    }
642
 
586
 
643
    public void archiveMouvement(int idMvt) {
587
    public void archiveMouvement(int idMvt) {
644
        SQLTable tableMouvement = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
588
        SQLTable tableMouvement = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
645
        SQLRow rowMvt = tableMouvement.getRow(idMvt);
589
        SQLRow rowMvt = tableMouvement.getRow(idMvt);
646
 
590
 
647
        if (rowMvt.getInt("ID_MOUVEMENT_PERE") > 1) {
591
        if (rowMvt.getInt("ID_MOUVEMENT_PERE") > 1) {
648
            archiveMouvement(rowMvt.getInt("ID_MOUVEMENT_PERE"));
592
            archiveMouvement(rowMvt.getInt("ID_MOUVEMENT_PERE"));
649
        } else {
593
        } else {
650
            archiveMouvementProfondeur(idMvt, true);
594
            archiveMouvementProfondeur(idMvt, true);
651
        }
595
        }
652
    }
596
    }
653
 
597
 
654
    /**
598
    /**
655
     * Archivage de l'ensemble des opérations liés au mouvement passé en parametre
599
     * Archivage de l'ensemble des opérations liés au mouvement passé en parametre
656
     * 
600
     * 
657
     * @param idMvtPere mouvement racine
601
     * @param idMvtPere mouvement racine
658
     * @param dropPere suppression du mouvement pere
602
     * @param dropPere suppression du mouvement pere
659
     */
603
     */
660
    public void archiveMouvementProfondeur(int idMvtPere, boolean dropPere) {
604
    public void archiveMouvementProfondeur(int idMvtPere, boolean dropPere) {
661
        if (idMvtPere > 1) {
605
        if (idMvtPere > 1) {
662
            SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
606
            SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
663
            SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
607
            SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
664
 
608
 
665
            SQLSelect selectFils = new SQLSelect();
609
            SQLSelect selectFils = new SQLSelect();
666
            selectFils.addSelect(tableMvt.getField("ID"));
610
            selectFils.addSelect(tableMvt.getField("ID"));
667
            selectFils.setWhere(tableMvt.getField("ID_MOUVEMENT_PERE"), "=", idMvtPere);
611
            selectFils.setWhere(tableMvt.getField("ID_MOUVEMENT_PERE"), "=", idMvtPere);
668
 
612
 
669
            List l = (List) base.getDataSource().execute(selectFils.asString(), new ArrayListHandler());
613
            List l = (List) base.getDataSource().execute(selectFils.asString(), new ArrayListHandler());
670
 
614
 
671
            // archive mouvements fils
615
            // archive mouvements fils
672
            for (int i = 0; i < l.size(); i++) {
616
            for (int i = 0; i < l.size(); i++) {
673
                Object[] tmp = (Object[]) l.get(i);
617
                Object[] tmp = (Object[]) l.get(i);
674
                archiveMouvementProfondeur(Integer.parseInt(tmp[0].toString()), true);
618
                archiveMouvementProfondeur(Integer.parseInt(tmp[0].toString()), true);
675
            }
619
            }
676
 
620
 
677
            // archive mouvement
621
            // archive mouvement
678
            archiveEcritures(idMvtPere, dropPere);
622
            archiveEcritures(idMvtPere, dropPere);
679
 
623
 
680
        } else {
624
        } else {
681
 
625
 
682
            System.err.println("Suppression du mouvement d'id 1 impossible.");
626
            System.err.println("Suppression du mouvement d'id 1 impossible.");
683
            JOptionPane.showMessageDialog(null, "Impossible d'archiver, le mouvement est indéfini.");
627
            JOptionPane.showMessageDialog(null, "Impossible d'archiver, le mouvement est indéfini.");
684
        }
628
        }
685
    }
629
    }
686
 
630
 
687
    // Suppression des ecritures associées à un mouvement
631
    // Suppression des ecritures associées à un mouvement
688
    public synchronized void archiveEcritures(final int idMvt, final boolean dropMvt) {
632
    public synchronized void archiveEcritures(final int idMvt, final boolean dropMvt) {
689
        final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
633
        final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
690
        final SQLTable tableMvt = base.getTable("MOUVEMENT");
634
        final SQLTable tableMvt = base.getTable("MOUVEMENT");
691
        final SQLTable tableEcriture = base.getTable("ECRITURE");
635
        final SQLTable tableEcriture = base.getTable("ECRITURE");
692
        final SQLRow rowMvt = tableMvt.getRow(idMvt);
636
        final SQLRow rowMvt = tableMvt.getRow(idMvt);
693
 
637
 
694
        // on verifie que le mouvement n'est pas validé
638
        // on verifie que le mouvement n'est pas validé
695
        if (MouvementSQLElement.isEditable(idMvt)) {
639
        if (MouvementSQLElement.isEditable(idMvt)) {
696
 
640
 
697
            // on archive le mouvement
641
            // on archive le mouvement
698
            if (dropMvt) {
642
            if (dropMvt) {
-
 
643
 
699
                SQLElement elt = Configuration.getInstance().getDirectory().getElement(tableMvt);
644
                SQLElement elt = getDirectory().getElement(tableMvt);
-
 
645
 
700
                try {
646
                try {
701
                    elt.archive(idMvt);
647
                    elt.archive(idMvt);
702
                } catch (SQLException e) {
648
                } catch (SQLException e) {
703
                    ExceptionHandler.handle("Erreur lors de la suppression du mouvement d'id [" + idMvt + "]", e);
649
                    ExceptionHandler.handle("Erreur lors de la suppression du mouvement d'id [" + idMvt + "]", e);
704
                    e.printStackTrace();
650
                    e.printStackTrace();
705
                }
651
                }
706
            } else {
652
            } else {
707
 
653
 
708
                SQLFactory<Object> sqlFactory = new SQLFactory<Object>() {
654
                SQLFactory<Object> sqlFactory = new SQLFactory<Object>() {
709
                    @Override
655
                    @Override
710
                    public Object create() throws SQLException {
656
                    public Object create() throws SQLException {
711
                        // on recupere l'ensemble des ecritures associées au mouvement
657
                        // on recupere l'ensemble des ecritures associées au mouvement
712
                        SQLSelect selEcritures = new SQLSelect();
658
                        SQLSelect selEcritures = new SQLSelect();
713
                        selEcritures.addSelect(tableEcriture.getField("ID"));
659
                        selEcritures.addSelect(tableEcriture.getField("ID"));
714
                        selEcritures.setWhere(tableEcriture.getField("ID_MOUVEMENT"), "=", idMvt);
660
                        selEcritures.setWhere(tableEcriture.getField("ID_MOUVEMENT"), "=", idMvt);
715
 
661
 
716
                        List l = (List) base.getDataSource().execute(selEcritures.asString(), new ArrayListHandler());
662
                        List l = (List) base.getDataSource().execute(selEcritures.asString(), new ArrayListHandler());
717
                        for (int i = 0; i < l.size(); i++) {
663
                        for (int i = 0; i < l.size(); i++) {
718
                            Object[] tmp = (Object[]) l.get(i);
664
                            Object[] tmp = (Object[]) l.get(i);
719
                            archiveEcriture(tableEcriture.getRow(Integer.parseInt(tmp[0].toString())));
665
                            archiveEcriture(tableEcriture.getRow(Integer.parseInt(tmp[0].toString())));
720
                        }
666
                        }
721
 
667
 
722
                        return null;
668
                        return null;
723
                    }
669
                    }
724
                };
670
                };
725
 
671
 
726
                try {
672
                try {
727
                    SQLUtils.executeAtomic(base.getDataSource(), sqlFactory);
673
                    SQLUtils.executeAtomic(base.getDataSource(), sqlFactory);
728
                } catch (SQLException e) {
674
                } catch (SQLException e) {
729
 
675
 
730
                    ExceptionHandler.handle("Une erreur est survenue lors de la suppression des écritures.", e);
676
                    ExceptionHandler.handle("Une erreur est survenue lors de la suppression des écritures.", e);
731
                }
677
                }
732
            }
678
            }
733
 
679
 
734
        } else {
680
        } else {
735
            JOptionPane.showMessageDialog(null, "Impossible de supprimer le mouvement n°" + rowMvt.getInt("NUMERO") + " car il est validé.");
681
            JOptionPane.showMessageDialog(null, "Impossible de supprimer le mouvement n°" + rowMvt.getInt("NUMERO") + " car il est validé.");
736
        }
682
        }
737
    }
683
    }
738
 
684
 
739
    @Override
685
    @Override
740
    protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
686
    protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
741
        for (SQLRow row : trees.getRows()) {
687
        for (SQLRow row : trees.getRows()) {
742
            // Si on supprime une ecriture on doit supprimer toutes les ecritures du mouvement
688
            // Si on supprime une ecriture on doit supprimer toutes les ecritures du mouvement
743
            // associé
689
            // associé
744
            System.err.println("Archivage des écritures");
690
            System.err.println("Archivage des écritures");
745
            // archiveMouvement(row.getInt("ID_MOUVEMENT"));
691
            // archiveMouvement(row.getInt("ID_MOUVEMENT"));
746
            JFrame frame = new PanelFrame(new SuppressionEcrituresPanel(row.getInt("ID_MOUVEMENT")), "Suppression d'ecritures");
692
            JFrame frame = new PanelFrame(new SuppressionEcrituresPanel(row.getInt("ID_MOUVEMENT")), "Suppression d'ecritures");
747
            frame.pack();
693
            frame.pack();
748
            frame.setResizable(false);
694
            frame.setResizable(false);
749
            frame.setLocationRelativeTo(null);
695
            frame.setLocationRelativeTo(null);
750
            frame.setVisible(true);
696
            frame.setVisible(true);
751
        }
697
        }
752
    }
698
    }
753
 
699
 
754
    /**
700
    /**
755
     * Permet d'archiver une ecriture seule attention méthode à utiliser en vérifiant que la balance
701
     * Permet d'archiver une ecriture seule attention méthode à utiliser en vérifiant que la balance
756
     * est respectée
702
     * est respectée
757
     * 
703
     * 
758
     * @param row
704
     * @param row
759
     * @throws SQLException
705
     * @throws SQLException
760
     */
706
     */
761
    public void archiveEcriture(SQLRow row) throws SQLException {
707
    public void archiveEcriture(SQLRow row) throws SQLException {
762
 
708
 
763
        if (!row.getBoolean("VALIDE")) {
709
        if (!row.getBoolean("VALIDE")) {
764
 
710
 
765
            SQLRowValues rowVals = new SQLRowValues(this.getTable());
711
            SQLRowValues rowVals = new SQLRowValues(this.getTable());
766
            rowVals.put("IDUSER_DELETE", UserManager.getInstance().getCurrentUser().getId());
712
            rowVals.put("IDUSER_DELETE", UserManager.getInstance().getCurrentUser().getId());
767
            rowVals.put("ARCHIVE", 1);
713
            rowVals.put("ARCHIVE", 1);
768
            rowVals.update(row.getID());
714
            rowVals.update(row.getID());
769
 
715
 
770
            // Annulation du lettrage si l'ecriture est lettrée pour ne pas avoir de lettrage
716
            // Annulation du lettrage si l'ecriture est lettrée pour ne pas avoir de lettrage
771
            // déséquilibré
717
            // déséquilibré
772
            final String codeLettrage = row.getString("LETTRAGE");
718
            final String codeLettrage = row.getString("LETTRAGE");
773
            if (codeLettrage != null && codeLettrage.trim().length() > 0) {
719
            if (codeLettrage != null && codeLettrage.trim().length() > 0) {
774
                UpdateBuilder builder = new UpdateBuilder(getTable());
720
                UpdateBuilder builder = new UpdateBuilder(getTable());
775
                builder.setObject("LETTRAGE", "");
721
                builder.setObject("LETTRAGE", "");
776
                builder.setObject("DATE_LETTRAGE", null);
722
                builder.setObject("DATE_LETTRAGE", null);
777
                builder.setWhere(new Where(getTable().getField("LETTRAGE"), "=", codeLettrage));
723
                builder.setWhere(new Where(getTable().getField("LETTRAGE"), "=", codeLettrage));
778
                getTable().getDBSystemRoot().getDataSource().execute(builder.asString());
724
                getTable().getDBSystemRoot().getDataSource().execute(builder.asString());
779
            }
725
            }
780
 
726
 
781
            // super.archive(row, true);
727
            // super.archive(row, true);
782
        } else {
728
        } else {
783
            System.err.println("Impossible de supprimer une ecriture validée");
729
            System.err.println("Impossible de supprimer une ecriture validée");
784
            JOptionPane.showMessageDialog(null, "Impossible de supprimer une ecriture validée. \n" + row);
730
            JOptionPane.showMessageDialog(null, "Impossible de supprimer une ecriture validée. \n" + row);
785
        }
731
        }
786
    }
732
    }
787
 
733
 
788
    private static EditFrame frameSaisieKm = null;
734
    private static EditFrame frameSaisieKm = null;
789
 
735
 
790
    /**
736
    /**
791
     * Contrepassation d'un piece comptable à partir de l'id d'une écriture. Chargement d'un panel
737
     * Contrepassation d'un piece comptable à partir de l'id d'une écriture. Chargement d'un panel
792
     * Saisie au Km avec les ecritures inversées
738
     * Saisie au Km avec les ecritures inversées
793
     * 
739
     * 
794
     * @param id
740
     * @param id
795
     */
741
     */
796
    public static void contrePassationPiece(int id) {
742
    public static void contrePassationPiece(int id) {
797
 
743
 
798
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
744
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
799
 
745
 
800
        SQLTable tableEcriture = base.getTable("ECRITURE");
746
        SQLTable tableEcriture = base.getTable("ECRITURE");
801
        SQLRow rowEcr = tableEcriture.getRow(id);
747
        SQLRow rowEcr = tableEcriture.getRow(id);
802
        final int idMvt = rowEcr.getInt("ID_MOUVEMENT");
748
        final int idMvt = rowEcr.getInt("ID_MOUVEMENT");
803
        System.err.println("ID MOUVEMENT --> " + idMvt);
749
        System.err.println("ID MOUVEMENT --> " + idMvt);
804
        if (frameSaisieKm == null) {
750
        if (frameSaisieKm == null) {
805
            frameSaisieKm = new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_KM"));
751
            frameSaisieKm = new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_KM"));
806
        }
752
        }
807
 
753
 
808
        SwingUtilities.invokeLater(new Runnable() {
754
        SwingUtilities.invokeLater(new Runnable() {
809
            public void run() {
755
            public void run() {
810
                SaisieKmSQLElement.loadContrePassation(frameSaisieKm.getSQLComponent(), idMvt);
756
                SaisieKmSQLElement.loadContrePassation(frameSaisieKm.getSQLComponent(), idMvt);
811
            }
757
            }
812
        });
758
        });
813
        frameSaisieKm.setVisible(true);
759
        frameSaisieKm.setVisible(true);
814
    }
760
    }
815
 
761
 
816
    @Override
762
    @Override
817
    protected String createCode() {
763
    protected String createCode() {
818
        return createCodeOfPackage() + ".entry.item";
764
        return createCodeOfPackage() + ".entry.item";
819
    }
765
    }
820
 
766
 
821
    public static void dupliquer(SQLRow selectedRow) {
767
    public static void dupliquer(SQLRow selectedRow) {
822
 
768
 
823
        final SQLRow foreignMvt = selectedRow.getForeign("ID_MOUVEMENT");
769
        final SQLRow foreignMvt = selectedRow.getForeign("ID_MOUVEMENT");
824
        if (foreignMvt.getString("SOURCE").equalsIgnoreCase("SAISIE_KM")) {
770
        if (foreignMvt.getString("SOURCE").equalsIgnoreCase("SAISIE_KM")) {
825
            final SQLElement elementSaisieKm = Configuration.getInstance().getDirectory().getElement("SAISIE_KM");
771
            final SQLElement elementSaisieKm = Configuration.getInstance().getDirectory().getElement("SAISIE_KM");
826
            final SQLElement elementSaisieKmItem = Configuration.getInstance().getDirectory().getElement("SAISIE_KM_ELEMENT");
772
            final SQLElement elementSaisieKmItem = Configuration.getInstance().getDirectory().getElement("SAISIE_KM_ELEMENT");
827
            final EditFrame frameCloneSaisieKm = new EditFrame(elementSaisieKm);
773
            final EditFrame frameCloneSaisieKm = new EditFrame(elementSaisieKm);
828
            int idSource = foreignMvt.getInt("IDSOURCE");
774
            int idSource = foreignMvt.getInt("IDSOURCE");
829
            SQLRow rowKm = elementSaisieKm.getTable().getRow(idSource);
775
            SQLRow rowKm = elementSaisieKm.getTable().getRow(idSource);
830
            final SQLRowValues rowVals = elementSaisieKm.createCopy(idSource);
776
            final SQLRowValues rowVals = elementSaisieKm.createCopy(idSource);
831
            rowVals.put("ID_MOUVEMENT", null);
777
            rowVals.put("ID_MOUVEMENT", null);
832
            Collection<SQLRow> items = rowKm.getReferentRows(elementSaisieKm.getTable().getTable("SAISIE_KM_ELEMENT"));
778
            Collection<SQLRow> items = rowKm.getReferentRows(elementSaisieKm.getTable().getTable("SAISIE_KM_ELEMENT"));
833
            for (SQLRow sqlRow : items) {
779
            for (SQLRow sqlRow : items) {
834
                SQLRowValues sqlRowValues = elementSaisieKmItem.createCopy(sqlRow.getID());
780
                SQLRowValues sqlRowValues = elementSaisieKmItem.createCopy(sqlRow.getID());
835
                sqlRowValues.put("ID_ECRITURE", null);
781
                sqlRowValues.put("ID_ECRITURE", null);
836
                sqlRowValues.put("ID_SAISIE_KM", rowVals);
782
                sqlRowValues.put("ID_SAISIE_KM", rowVals);
837
                System.err.println("ADD ELEMENT KM :: " + sqlRowValues.getID());
783
                System.err.println("ADD ELEMENT KM :: " + sqlRowValues.getID());
838
            }
784
            }
839
 
785
 
840
            SwingUtilities.invokeLater(new Runnable() {
786
            SwingUtilities.invokeLater(new Runnable() {
841
                public void run() {
787
                public void run() {
842
                    frameCloneSaisieKm.getSQLComponent().select(rowVals);
788
                    frameCloneSaisieKm.getSQLComponent().select(rowVals);
843
                }
789
                }
844
            });
790
            });
845
            frameCloneSaisieKm.setVisible(true);
791
            frameCloneSaisieKm.setVisible(true);
846
        } else {
792
        } else {
847
            SwingUtilities.invokeLater(new Runnable() {
793
            SwingUtilities.invokeLater(new Runnable() {
848
                public void run() {
794
                public void run() {
849
                    JOptionPane.showMessageDialog(null, "La duplication n'est possible que sur les saisies au kilomètre");
795
                    JOptionPane.showMessageDialog(null, "La duplication n'est possible que sur les saisies au kilomètre");
850
                }
796
                }
851
            });
797
            });
852
        }
798
        }
853
    }
799
    }
854
}
800
}