OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 177
Line 32... Line 32...
32
import org.openconcerto.sql.view.list.AutoCompletionManager;
32
import org.openconcerto.sql.view.list.AutoCompletionManager;
33
import org.openconcerto.sql.view.list.RowValuesTable;
33
import org.openconcerto.sql.view.list.RowValuesTable;
34
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
34
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
35
import org.openconcerto.sql.view.list.RowValuesTableModel;
35
import org.openconcerto.sql.view.list.RowValuesTableModel;
36
import org.openconcerto.sql.view.list.SQLTableElement;
36
import org.openconcerto.sql.view.list.SQLTableElement;
37
import org.openconcerto.sql.view.list.TextTableCellEditorWithCompletion;
-
 
38
import org.openconcerto.sql.view.list.ValidStateChecker;
37
import org.openconcerto.sql.view.list.ValidStateChecker;
39
import org.openconcerto.ui.DefaultGridBagConstraints;
38
import org.openconcerto.ui.DefaultGridBagConstraints;
40
import org.openconcerto.ui.JComponentUtils;
39
import org.openconcerto.ui.JComponentUtils;
41
import org.openconcerto.ui.RangedIntegerTableCellEditor;
40
import org.openconcerto.ui.RangedIntegerTableCellEditor;
42
import org.openconcerto.utils.DecimalUtils;
41
import org.openconcerto.utils.DecimalUtils;
Line 46... Line 45...
46
 
45
 
47
import java.awt.GridBagConstraints;
46
import java.awt.GridBagConstraints;
48
import java.awt.GridBagLayout;
47
import java.awt.GridBagLayout;
49
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionListener;
49
import java.awt.event.ActionListener;
-
 
50
import java.awt.event.KeyAdapter;
51
import java.awt.event.KeyEvent;
51
import java.awt.event.KeyEvent;
52
import java.awt.event.KeyListener;
52
import java.awt.event.KeyListener;
53
import java.awt.event.MouseEvent;
53
import java.awt.event.MouseEvent;
54
import java.awt.event.MouseListener;
54
import java.awt.event.MouseListener;
55
import java.beans.PropertyChangeEvent;
55
import java.beans.PropertyChangeEvent;
Line 107... Line 107...
107
        c.weightx = 1;
107
        c.weightx = 1;
108
 
108
 
109
        final SQLElement elt = Configuration.getInstance().getDirectory().getElement("SAISIE_KM_ELEMENT");
109
        final SQLElement elt = Configuration.getInstance().getDirectory().getElement("SAISIE_KM_ELEMENT");
110
 
110
 
111
        // TODO Obligation de choisir un compte correct
111
        // TODO Obligation de choisir un compte correct
112
        final List<SQLTableElement> list = new Vector<SQLTableElement>();
112
        final List<SQLTableElement> list = new Vector<>();
113
        final SQLTable tableElement = elt.getTable();
113
        final SQLTable tableElement = elt.getTable();
114
        final SQLTableElement tableElementJour = new SQLTableElement(tableElement.getField("JOUR"), Integer.class, rangedIntegerTableCellEditor) {
114
        final SQLTableElement tableElementJour = new SQLTableElement(tableElement.getField("JOUR"), Integer.class, this.rangedIntegerTableCellEditor) {
115
            @Override
115
            @Override
116
            public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
116
            public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
117
 
117
 
118
                return super.isCellEditable(vals, rowIndex, columnIndex) && rowIndex == 0;
118
                return super.isCellEditable(vals, rowIndex, columnIndex) && rowIndex == 0;
119
            }
119
            }
Line 156... Line 156...
156
                }
156
                }
157
            });
157
            });
158
            final MultiLineTableCellEditor multiLineTableCellEditor = new MultiLineTableCellEditor((RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable);
158
            final MultiLineTableCellEditor multiLineTableCellEditor = new MultiLineTableCellEditor((RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable);
159
 
159
 
160
            SQLTableElement eltPourcentAnalytique = new SQLTableElement(tableElement.getField("ANALYTIQUE"), String.class, multiLineTableCellEditor) {
160
            SQLTableElement eltPourcentAnalytique = new SQLTableElement(tableElement.getField("ANALYTIQUE"), String.class, multiLineTableCellEditor) {
-
 
161
                @Override
161
                public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
162
                public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
162
                    return vals.getString("NUMERO") != null && (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"));
163
                    return vals.getString("NUMERO") != null && (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"));
163
                };
164
                };
164
            };
165
            };
165
            list.add(eltPourcentAnalytique);
166
            list.add(eltPourcentAnalytique);
Line 171... Line 172...
171
                super.setValueAt(aValue, rowIndex, columnIndex);
172
                super.setValueAt(aValue, rowIndex, columnIndex);
172
 
173
 
173
                final int debitIndex = getColumnIndexForElement(SaisieJournalItemTable.this.debit);
174
                final int debitIndex = getColumnIndexForElement(SaisieJournalItemTable.this.debit);
174
                final int creditIndex = getColumnIndexForElement(SaisieJournalItemTable.this.credit);
175
                final int creditIndex = getColumnIndexForElement(SaisieJournalItemTable.this.credit);
175
 
176
 
176
                // float debitVal = ((Float) model.getValueAt(rowIndex, debitIndex);
-
 
177
 
-
 
178
                if (debitIndex == columnIndex && ((Long) aValue).longValue() != 0 && ((Long) getValueAt(rowIndex, creditIndex)).longValue() != 0) {
177
                if (debitIndex == columnIndex && ((Number) aValue).longValue() != 0 && ((Number) getValueAt(rowIndex, creditIndex)).longValue() != 0) {
179
                    setValueAt(Long.valueOf(0), rowIndex, creditIndex);
178
                    setValueAt(Long.valueOf(0), rowIndex, creditIndex);
180
                } else {
179
                } else {
181
                    if (creditIndex == columnIndex && ((Long) aValue).longValue() != 0 && ((Long) getValueAt(rowIndex, debitIndex)).longValue() != 0) {
180
                    if (creditIndex == columnIndex && ((Number) aValue).longValue() != 0 && ((Number) getValueAt(rowIndex, debitIndex)).longValue() != 0) {
182
                        setValueAt(Long.valueOf(0), rowIndex, debitIndex);
181
                        setValueAt(Long.valueOf(0), rowIndex, debitIndex);
183
                    }
182
                    }
184
                }
183
                }
185
            }
184
            }
186
        };
185
        };
187
 
186
 
188
        this.table = new RowValuesTable(model, null);
187
        this.table = new RowValuesTable(model, null);
189
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
188
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
190
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
189
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
191
 
190
 
192
        tableElementNomEcriture.getTableCellEditor(table).addCellEditorListener(new CellEditorListener() {
191
        tableElementNomEcriture.getTableCellEditor(this.table).addCellEditorListener(new CellEditorListener() {
193
 
192
 
194
            @Override
193
            @Override
195
            public void editingStopped(ChangeEvent e) {
194
            public void editingStopped(ChangeEvent e) {
196
                e.getSource();
195
                e.getSource();
197
                int row = table.getSelectedRow();
196
                int row = SaisieJournalItemTable.this.table.getSelectedRow();
198
                int col = 4;
197
                int col = 4;
199
                if (table.getValueAt(row, col) != null) {
198
                if (SaisieJournalItemTable.this.table.getValueAt(row, col) != null) {
200
                    defaultRowVals.put("NOM_ECRITURE", table.getValueAt(row, col));
199
                    defaultRowVals.put("NOM_ECRITURE", SaisieJournalItemTable.this.table.getValueAt(row, col));
201
                }
200
                }
202
                // defaultRowVals.put
-
 
-
 
201
 
203
            }
202
            }
204
 
203
 
205
            @Override
204
            @Override
206
            public void editingCanceled(ChangeEvent e) {
205
            public void editingCanceled(ChangeEvent e) {
207
                // TODO Auto-generated method stub
206
                //
208
 
207
 
209
            }
208
            }
210
        });
209
        });
211
        tableElementNomPiece.getTableCellEditor(table).addCellEditorListener(new CellEditorListener() {
210
        tableElementNomPiece.getTableCellEditor(this.table).addCellEditorListener(new CellEditorListener() {
212
 
211
 
213
            @Override
212
            @Override
214
            public void editingStopped(ChangeEvent e) {
213
            public void editingStopped(ChangeEvent e) {
215
                e.getSource();
214
                e.getSource();
216
                int row = table.getSelectedRow();
215
                int row = SaisieJournalItemTable.this.table.getSelectedRow();
217
                int col = 3;
216
                int col = 3;
218
                if (table.getValueAt(row, col) != null) {
217
                if (SaisieJournalItemTable.this.table.getValueAt(row, col) != null) {
219
                    defaultRowVals.put("NOM_PIECE", table.getValueAt(row, col));
218
                    defaultRowVals.put("NOM_PIECE", SaisieJournalItemTable.this.table.getValueAt(row, col));
220
                }
219
                }
221
                // defaultRowVals.put
-
 
-
 
220
 
222
            }
221
            }
223
 
222
 
224
            @Override
223
            @Override
225
            public void editingCanceled(ChangeEvent e) {
224
            public void editingCanceled(ChangeEvent e) {
226
                // TODO Auto-generated method stub
225
                //
227
 
226
 
228
            }
227
            }
229
        });
228
        });
230
 
229
 
231
        tableElementJour.getTableCellEditor(table).addCellEditorListener(new CellEditorListener() {
230
        tableElementJour.getTableCellEditor(this.table).addCellEditorListener(new CellEditorListener() {
232
 
231
 
233
            @Override
232
            @Override
234
            public void editingStopped(ChangeEvent e) {
233
            public void editingStopped(ChangeEvent e) {
235
                final Object valueAt = table.getValueAt(0, 0);
234
                final Object valueAt = SaisieJournalItemTable.this.table.getValueAt(0, 0);
236
                defaultRowVals.put("JOUR", valueAt);
235
                defaultRowVals.put("JOUR", valueAt);
237
                if (table.getRowCount() > 1) {
236
                if (SaisieJournalItemTable.this.table.getRowCount() > 1) {
238
                    for (int i = 1; i < table.getRowCount(); i++) {
237
                    for (int i = 1; i < SaisieJournalItemTable.this.table.getRowCount(); i++) {
239
                        table.getRowValuesTableModel().putValue(valueAt, i, "JOUR");
238
                        SaisieJournalItemTable.this.table.getRowValuesTableModel().putValue(valueAt, i, "JOUR");
240
                    }
239
                    }
241
                }
240
                }
242
            }
241
            }
243
 
242
 
244
            @Override
243
            @Override
245
            public void editingCanceled(ChangeEvent e) {
244
            public void editingCanceled(ChangeEvent e) {
246
                // TODO Auto-generated method stub
245
                //
247
 
-
 
248
            }
246
            }
249
        });
247
        });
250
        ;
-
 
251
 
-
 
252
        final KeyListener keyListenerContrepartie = new KeyListener() {
-
 
253
 
-
 
254
            @Override
-
 
255
            public void keyTyped(KeyEvent e) {
-
 
256
 
248
 
257
            }
-
 
258
 
-
 
259
            @Override
-
 
260
            public void keyReleased(KeyEvent e) {
249
        final KeyListener keyListenerContrepartie = new KeyAdapter() {
261
 
-
 
262
            }
-
 
263
 
250
 
264
            @Override
251
            @Override
265
            public void keyPressed(KeyEvent e) {
252
            public void keyPressed(KeyEvent e) {
266
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
253
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
267
                    montantValid(defaultRowVals, false, textField);
254
                    montantValid(defaultRowVals, false, textField);
Line 279... Line 266...
279
                    ComptePCESQLElement elt = Configuration.getInstance().getDirectory().getElement(ComptePCESQLElement.class);
266
                    ComptePCESQLElement elt = Configuration.getInstance().getDirectory().getElement(ComptePCESQLElement.class);
280
 
267
 
281
                    @Override
268
                    @Override
282
                    public ValidState getValidState(Object o) {
269
                    public ValidState getValidState(Object o) {
283
                        if (o != null) {
270
                        if (o != null) {
284
                            return elt.getCompteNumeroValidState(o.toString());
271
                            return this.elt.getCompteNumeroValidState(o.toString());
285
                        }
272
                        }
286
                        return super.getValidState(o);
273
                        return super.getValidState(o);
287
                    }
274
                    }
288
                });
275
                });
289
        m.fill("NOM", "NOM");
276
        m.fill("NOM", "NOM");
Line 296... Line 283...
296
                this.table, this.table.getRowValuesTableModel(), ITextWithCompletion.MODE_CONTAINS, true);
283
                this.table, this.table.getRowValuesTableModel(), ITextWithCompletion.MODE_CONTAINS, true);
297
        m2.fill("NUMERO", "NUMERO");
284
        m2.fill("NUMERO", "NUMERO");
298
        m2.setFillWithField("NOM");
285
        m2.setFillWithField("NOM");
299
        m2.setWhere(w);
286
        m2.setWhere(w);
300
 
287
 
301
        TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
-
 
302
 
-
 
303
        JButton buttonClone = new JButton(TM.tr("duplicateLine"));
288
        JButton buttonClone = new JButton(TM.tr(Configuration.getInstance().getLocale(), "duplicateLine"));
304
        buttonClone.addActionListener(new ActionListener() {
289
        buttonClone.addActionListener(new ActionListener() {
305
            public void actionPerformed(ActionEvent event) {
290
            public void actionPerformed(ActionEvent event) {
306
                cloneLine(table.getSelectedRow());
291
                cloneLine(SaisieJournalItemTable.this.table.getSelectedRow());
307
            }
292
            }
308
        });
293
        });
309
        buttonClone.setEnabled(false);
294
        buttonClone.setEnabled(false);
310
        c.gridx++;
295
        c.gridx++;
311
        JComponentUtils.setMinimumWidth(buttonClone, 95);
296
        JComponentUtils.setMinimumWidth(buttonClone, 95);
Line 330... Line 315...
330
 
315
 
331
            @Override
316
            @Override
332
            public void tableChanged(TableModelEvent e) {
317
            public void tableChanged(TableModelEvent e) {
333
                // Sélectionne automatiquement la ligne ajoutée
318
                // Sélectionne automatiquement la ligne ajoutée
334
                if (e.getType() == TableModelEvent.INSERT) {
319
                if (e.getType() == TableModelEvent.INSERT) {
335
                    if (table.getRowCount() == 1) {
320
                    if (SaisieJournalItemTable.this.table.getRowCount() == 1) {
336
                        editCellAt(e.getFirstRow(), 0);
321
                        editCellAt(e.getFirstRow(), 0);
337
                    } else {
322
                    } else {
338
                        editCellAt(e.getFirstRow(), 1);
323
                        editCellAt(e.getFirstRow(), 1);
339
                    }
324
                    }
340
                }
325
                }
Line 395... Line 380...
395
        this.panel = panel;
380
        this.panel = panel;
396
 
381
 
397
        final PropertyChangeListener lActiveAddButton = new PropertyChangeListener() {
382
        final PropertyChangeListener lActiveAddButton = new PropertyChangeListener() {
398
            @Override
383
            @Override
399
            public void propertyChange(PropertyChangeEvent evt) {
384
            public void propertyChange(PropertyChangeEvent evt) {
400
                controlPanel.setButtonAjouterEnabled(!panel.getBoxJournal().isEmpty() && !panel.getBoxMois().isEmpty());
385
                SaisieJournalItemTable.this.controlPanel.setButtonAjouterEnabled(!panel.getBoxJournal().isEmpty() && !panel.getBoxMois().isEmpty());
401
            }
386
            }
402
        };
387
        };
403
        panel.getBoxJournal().addModelListener("wantedID", lActiveAddButton);
388
        panel.getBoxJournal().addModelListener("wantedID", lActiveAddButton);
404
        panel.getBoxMois().addModelListener("wantedID", lActiveAddButton);
389
        panel.getBoxMois().addModelListener("wantedID", lActiveAddButton);
405
 
390
 
Line 412... Line 397...
412
                    if (selectedRow != null && !selectedRow.isUndefined()) {
397
                    if (selectedRow != null && !selectedRow.isUndefined()) {
413
                        Calendar c = Calendar.getInstance();
398
                        Calendar c = Calendar.getInstance();
414
                        c.set(Calendar.DAY_OF_MONTH, 1);
399
                        c.set(Calendar.DAY_OF_MONTH, 1);
415
                        c.set(Calendar.YEAR, (Integer) SaisieJournalItemTable.this.panel.spin.getValue());
400
                        c.set(Calendar.YEAR, (Integer) SaisieJournalItemTable.this.panel.spin.getValue());
416
                        c.set(Calendar.MONTH, SaisieJournalItemTable.this.panel.getSelectedMonth());
401
                        c.set(Calendar.MONTH, SaisieJournalItemTable.this.panel.getSelectedMonth());
417
                        rangedIntegerTableCellEditor.setMax(c.getActualMaximum(Calendar.DAY_OF_MONTH));
402
                        SaisieJournalItemTable.this.rangedIntegerTableCellEditor.setMax(c.getActualMaximum(Calendar.DAY_OF_MONTH));
418
                    }
403
                    }
419
                }
404
                }
420
            }
405
            }
421
 
406
 
422
        };
407
        };
Line 427... Line 412...
427
    public void refreshTotal() {
412
    public void refreshTotal() {
428
 
413
 
429
        long totalD = 0L;
414
        long totalD = 0L;
430
        long totalC = 0L;
415
        long totalC = 0L;
431
 
416
 
432
        for (int i = 0; i < table.getRowCount(); i++) {
417
        for (int i = 0; i < this.table.getRowCount(); i++) {
433
            Long c = (Long) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("DEBIT"));
418
            Number c = (Number) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("DEBIT"));
434
            Long d = (Long) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("CREDIT"));
419
            Number d = (Number) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("CREDIT"));
435
            if (c != null) {
420
            if (c != null) {
436
                totalC += c;
421
                totalC += c.longValue();
437
            }
422
            }
438
            if (d != null) {
423
            if (d != null) {
439
                totalD += d;
424
                totalD += d.longValue();
440
            }
425
            }
441
 
426
 
442
        }
427
        }
443
        this.labelTotalCredit.setText(GestionDevise.currencyToString(totalC));
428
        this.labelTotalCredit.setText(GestionDevise.currencyToString(totalC));
444
        this.labelTotalDebit.setText(GestionDevise.currencyToString(totalD));
429
        this.labelTotalDebit.setText(GestionDevise.currencyToString(totalD));
Line 451... Line 436...
451
 
436
 
452
        long totalD = 0L;
437
        long totalD = 0L;
453
        long totalC = 0L;
438
        long totalC = 0L;
454
        boolean cptOK = true;
439
        boolean cptOK = true;
455
        String lib = null;
440
        String lib = null;
456
        for (int i = 0; i < table.getRowCount(); i++) {
441
        for (int i = 0; i < this.table.getRowCount(); i++) {
457
            Long c = (Long) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("DEBIT"));
442
            Number c = (Number) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("DEBIT"));
458
            Long d = (Long) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("CREDIT"));
443
            Number d = (Number) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("CREDIT"));
459
            if (c != null) {
444
            if (c != null) {
460
                totalC += c;
445
                totalC += c.longValue();
461
            }
446
            }
462
            if (d != null) {
447
            if (d != null) {
463
                totalD += d;
448
                totalD += d.longValue();
464
            }
449
            }
465
            if (lib == null) {
450
            if (lib == null) {
466
                lib = (String) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("NOM"));
451
                lib = (String) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("NOM"));
467
            }
452
            }
468
            String cptNUmber = (String) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("NUMERO"));
453
            String cptNUmber = (String) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("NUMERO"));
469
            cptOK = cptOK && cptNUmber != null && ComptePCESQLElement.isExist(cptNUmber);
454
            cptOK = cptOK && cptNUmber != null && ComptePCESQLElement.isExist(cptNUmber);
470
        }
455
        }
471
        return totalD + totalC != 0 && totalD == totalC && cptOK;
456
        return totalD + totalC != 0 && totalD == totalC && cptOK;
472
    }
457
    }
473
 
458
 
474
    private Tuple2<Date, String> getDateAndLabelFromSaisie() {
459
    private Tuple2<Date, String> getDateAndLabelFromSaisie() {
475
        int day = 1;
460
        int day = 1;
476
        String lib = null;
461
        String lib = null;
477
 
462
 
478
        for (int i = 0; i < table.getRowCount(); i++) {
463
        for (int i = 0; i < this.table.getRowCount(); i++) {
479
            day = (Integer) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("JOUR"));
464
            day = (Integer) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("JOUR"));
480
            if (lib == null) {
465
            if (lib == null) {
481
                lib = (String) table.getRowValuesTableModel().getValueAt(i, table.getRowValuesTableModel().getColumnForField("NOM"));
466
                lib = (String) this.table.getRowValuesTableModel().getValueAt(i, this.table.getRowValuesTableModel().getColumnForField("NOM"));
482
            }
467
            }
483
        }
468
        }
484
        // Create saisieKM
469
        // Create saisieKM
485
        Calendar c = Calendar.getInstance();
470
        Calendar c = Calendar.getInstance();
486
        c.set(Calendar.YEAR, SaisieJournalItemTable.this.panel.getSelectedYear());
471
        c.set(Calendar.YEAR, SaisieJournalItemTable.this.panel.getSelectedYear());
Line 488... Line 473...
488
        c.set(Calendar.DAY_OF_MONTH, day);
473
        c.set(Calendar.DAY_OF_MONTH, day);
489
        return Tuple2.create(c.getTime(), lib);
474
        return Tuple2.create(c.getTime(), lib);
490
    }
475
    }
491
 
476
 
492
    public void montantValid(final SQLRowValues defaultRowVals, final boolean fromAnalytique, final JTextField textPiece) {
477
    public void montantValid(final SQLRowValues defaultRowVals, final boolean fromAnalytique, final JTextField textPiece) {
493
        System.err.println("Enter");
-
 
494
        final SQLRowValues vals = SaisieJournalItemTable.this.table.getSelectedRowValues();
478
        final SQLRowValues vals = SaisieJournalItemTable.this.table.getSelectedRowValues();
495
        final int selectedRow = SaisieJournalItemTable.this.table.getSelectedRow();
479
        final int selectedRow = SaisieJournalItemTable.this.table.getSelectedRow();
496
        SwingUtilities.invokeLater(new Runnable() {
480
        SwingUtilities.invokeLater(new Runnable() {
497
            public void run() {
481
            public void run() {
498
 
482
 
499
                if (boxAutoInsert.isSelected() && isSaisieValid()) {
483
                if (SaisieJournalItemTable.this.boxAutoInsert.isSelected() && isSaisieValid()) {
500
                    if (SaisieJournalItemTable.this.panel.getSelectedJournal() == SQLRow.NONEXISTANT_ID || SaisieJournalItemTable.this.panel.getSelectedMonth() == -1) {
484
                    if (SaisieJournalItemTable.this.panel.getSelectedJournal() == SQLRow.NONEXISTANT_ID || SaisieJournalItemTable.this.panel.getSelectedMonth() == -1) {
501
                        JOptionPane.showMessageDialog(SaisieJournalItemTable.this.panel, "Impossible de créer la saisie si aucun journal ou aucun mois n'est sélectionné!");
485
                        JOptionPane.showMessageDialog(SaisieJournalItemTable.this.panel, "Impossible de créer la saisie si aucun journal ou aucun mois n'est sélectionné!");
502
                    } else {
486
                    } else {
503
                        createSaisie(defaultRowVals, textPiece);
487
                        createSaisie(defaultRowVals, textPiece);
504
                    }
488
                    }
505
                } else {
489
                } else {
-
 
490
                    if (!fromAnalytique && !SaisieJournalItemTable.this.hideAnalytique && vals.getString("NUMERO") != null
506
                    if (!fromAnalytique && !hideAnalytique && vals.getString("NUMERO") != null && (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"))) {
491
                            && (vals.getString("NUMERO").startsWith("6") || vals.getString("NUMERO").startsWith("7"))) {
507
 
492
 
508
                        // Update montant
493
                        // Update montant
509
                        Collection<SQLRowValues> rowsLinked = vals.getReferentRows(vals.getTable().getTable("ASSOCIATION_ANALYTIQUE"));
494
                        Collection<SQLRowValues> rowsLinked = vals.getReferentRows(vals.getTable().getTable("ASSOCIATION_ANALYTIQUE"));
510
                        long montant = vals.getLong("DEBIT") - vals.getLong("CREDIT");
495
                        long montant = vals.getLong("DEBIT") - vals.getLong("CREDIT");
511
                        for (SQLRowValues sqlRowValues : rowsLinked) {
496
                        for (SQLRowValues sqlRowValues : rowsLinked) {
512
                            sqlRowValues.put("MONTANT", sqlRowValues.getBigDecimal("POURCENT").movePointLeft(2).multiply(new BigDecimal(montant), DecimalUtils.HIGH_PRECISION)
497
                            sqlRowValues.put("MONTANT", sqlRowValues.getBigDecimal("POURCENT").movePointLeft(2).multiply(new BigDecimal(montant), DecimalUtils.HIGH_PRECISION)
513
                                    .setScale(0, RoundingMode.HALF_UP).longValue());
498
                                    .setScale(0, RoundingMode.HALF_UP).longValue());
514
                        }
499
                        }
515
 
500
 
516
                        editCellAt(selectedRow, table.getRowValuesTableModel().getColumnForField("ANALYTIQUE"));
501
                        editCellAt(selectedRow, SaisieJournalItemTable.this.table.getRowValuesTableModel().getColumnForField("ANALYTIQUE"));
517
                    } else {
502
                    } else {
518
 
503
 
519
                        long l = getContrepartie();
504
                        long l = getContrepartie();
520
                        SQLRowValues rowVals = new SQLRowValues(defaultRowVals);
505
                        SQLRowValues rowVals = new SQLRowValues(defaultRowVals);
521
                        if (l > 0) {
506
                        if (l > 0) {
Line 549... Line 534...
549
        rowVAlsKM.put("ID_JOURNAL", SaisieJournalItemTable.this.panel.getSelectedJournal());
534
        rowVAlsKM.put("ID_JOURNAL", SaisieJournalItemTable.this.panel.getSelectedJournal());
550
        int id;
535
        int id;
551
        try {
536
        try {
552
            id = rowVAlsKM.insert().getID();
537
            id = rowVAlsKM.insert().getID();
553
 
538
 
554
            table.updateField("ID_SAISIE_KM", id);
539
            this.table.updateField("ID_SAISIE_KM", id);
555
            table.clear();
540
            this.table.clear();
556
            GenerationMvtSaisieKm gen = new GenerationMvtSaisieKm(id);
541
            GenerationMvtSaisieKm gen = new GenerationMvtSaisieKm(id);
557
            int idMvt = gen.genereMouvement();
542
            int idMvt = gen.genereMouvement();
558
 
543
 
559
            // maj de l'id du mouvement correspondant
544
            // maj de l'id du mouvement correspondant
560
            SQLRowValues rowValsKMMvt = new SQLRowValues(SaisieJournalItemTable.this.table.getRowValuesTableModel().getSQLElement().getTable().getForeignTable("ID_SAISIE_KM"));
545
            SQLRowValues rowValsKMMvt = new SQLRowValues(SaisieJournalItemTable.this.table.getRowValuesTableModel().getSQLElement().getTable().getForeignTable("ID_SAISIE_KM"));
561
            rowValsKMMvt.put("ID_MOUVEMENT", new Integer(idMvt));
546
            rowValsKMMvt.put("ID_MOUVEMENT", Integer.valueOf(idMvt));
562
            rowValsKMMvt.update(id);
547
            rowValsKMMvt.update(id);
563
 
548
 
564
            defaultRowVals.put("NOM_PIECE", "");
549
            defaultRowVals.put("NOM_PIECE", "");
565
            defaultRowVals.put("NOM_ECRITURE", "");
550
            defaultRowVals.put("NOM_ECRITURE", "");
566
            table.getRowValuesTableModel().addNewRow();
551
            this.table.getRowValuesTableModel().addNewRow();
567
            pieceText.setText("");
552
            pieceText.setText("");
568
        } catch (SQLException e) {
553
        } catch (SQLException e) {
569
            e.printStackTrace();
554
            e.printStackTrace();
570
        }
555
        }
571
 
556
 
Line 624... Line 609...
624
        final RowValuesTableModel model = this.table.getRowValuesTableModel();
609
        final RowValuesTableModel model = this.table.getRowValuesTableModel();
625
        final int creditIndex = model.getColumnIndexForElement(getCreditElement());
610
        final int creditIndex = model.getColumnIndexForElement(getCreditElement());
626
        final int debitIndex = model.getColumnIndexForElement(getDebitElement());
611
        final int debitIndex = model.getColumnIndexForElement(getDebitElement());
627
        for (int i = 0; i < this.table.getRowCount(); i++) {
612
        for (int i = 0; i < this.table.getRowCount(); i++) {
628
            if (model.isRowValid(i)) {
613
            if (model.isRowValid(i)) {
629
                final Long fTc = (Long) model.getValueAt(i, creditIndex);
614
                final Number fTc = (Number) model.getValueAt(i, creditIndex);
630
                if (fTc != null) {
615
                if (fTc != null) {
631
                    totalCred += fTc.longValue();
616
                    totalCred += fTc.longValue();
632
                }
617
                }
633
                final Long fTd = (Long) model.getValueAt(i, debitIndex);
618
                final Number fTd = (Number) model.getValueAt(i, debitIndex);
634
                if (fTd != null) {
619
                if (fTd != null) {
635
                    totalDeb += fTd.longValue();
620
                    totalDeb += fTd.longValue();
636
                }
621
                }
637
            }
622
            }
638
        }
623
        }
Line 651... Line 636...
651
 
636
 
652
    public void fillEmptyEntryLabel(String previousText, String text) {
637
    public void fillEmptyEntryLabel(String previousText, String text) {
653
        assert SwingUtilities.isEventDispatchThread();
638
        assert SwingUtilities.isEventDispatchThread();
654
        if (text == null)
639
        if (text == null)
655
            return;
640
            return;
656
        RowValuesTableModel model = table.getRowValuesTableModel();
641
        RowValuesTableModel model = this.table.getRowValuesTableModel();
657
        int size = model.getRowCount();
642
        int size = model.getRowCount();
658
        for (int i = 0; i < size; i++) {
643
        for (int i = 0; i < size; i++) {
659
            SQLRowValues r = model.getRowValuesAt(i);
644
            SQLRowValues r = model.getRowValuesAt(i);
660
            if (r.getString("NOM_ECRITURE") == null || r.getString("NOM_ECRITURE").trim().isEmpty() || r.getString("NOM_ECRITURE").trim().equals(previousText)) {
645
            if (r.getString("NOM_ECRITURE") == null || r.getString("NOM_ECRITURE").trim().isEmpty() || r.getString("NOM_ECRITURE").trim().equals(previousText)) {
661
                r.put("NOM_ECRITURE", text);
646
                r.put("NOM_ECRITURE", text);
662
            }
647
            }
663
        }
648
        }
664
        model.fireTableDataChanged();
649
        model.fireTableDataChanged();
665
    }
650
    }
666
 
651
 
-
 
652
    @Override
667
    public void mousePressed(final MouseEvent e) {
653
    public void mousePressed(final MouseEvent e) {
668
        final int rowSel = this.table.getSelectedRow();
654
        final int rowSel = this.table.getSelectedRow();
669
        if (e.getButton() == MouseEvent.BUTTON3 && rowSel >= 0 && rowSel < this.table.getRowCount()) {
655
        if (e.getButton() == MouseEvent.BUTTON3 && rowSel >= 0 && rowSel < this.table.getRowCount()) {
670
            final JPopupMenu menuDroit = new JPopupMenu();
656
            final JPopupMenu menuDroit = new JPopupMenu();
671
 
657
 
Line 690... Line 676...
690
            menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
676
            menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
691
            menuDroit.setVisible(true);
677
            menuDroit.setVisible(true);
692
        }
678
        }
693
    }
679
    }
694
 
680
 
-
 
681
    @Override
695
    public void mouseReleased(final MouseEvent e) {
682
    public void mouseReleased(final MouseEvent e) {
-
 
683
        // Nothing
696
    }
684
    }
697
 
685
 
-
 
686
    @Override
698
    public void mouseClicked(final MouseEvent e) {
687
    public void mouseClicked(final MouseEvent e) {
-
 
688
        // Nothing
699
    }
689
    }
700
 
690
 
-
 
691
    @Override
701
    public void mouseEntered(final MouseEvent e) {
692
    public void mouseEntered(final MouseEvent e) {
-
 
693
        // Nothing
702
    }
694
    }
703
 
695
 
-
 
696
    @Override
704
    public void mouseExited(final MouseEvent e) {
697
    public void mouseExited(final MouseEvent e) {
-
 
698
        // Nothing
705
    }
699
    }
706
 
700
 
707
    private void cloneLine(int row) {
701
    private void cloneLine(int row) {
708
        if (row < 0) {
702
        if (row < 0) {
709
            System.err.println("RowValuesTableControlPanel.cloneLine() wrong selected line, index = " + row);
-
 
710
            Thread.dumpStack();
-
 
711
            return;
703
            return;
712
        }
704
        }
713
        SQLRowValues rowVals = this.table.getRowValuesTableModel().getRowValuesAt(row);
705
        SQLRowValues rowVals = this.table.getRowValuesTableModel().getRowValuesAt(row);
714
 
706
 
715
        SQLRowValues rowValsBis = rowVals.deepCopy();
707
        SQLRowValues rowValsBis = rowVals.deepCopy();