OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 73 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.finance.accounting.ui;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.finance.accounting.report.BalanceAgeeListeSheetXML;
18
import org.openconcerto.sql.Configuration;
19
import org.openconcerto.sql.model.SQLRow;
20
import org.openconcerto.ui.DefaultGridBagConstraints;
21
import org.openconcerto.ui.JDate;
80 ilm 22
import org.openconcerto.utils.ExceptionHandler;
18 ilm 23
 
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28
import java.util.Calendar;
29
 
30
import javax.swing.JButton;
73 ilm 31
import javax.swing.JCheckBox;
18 ilm 32
import javax.swing.JLabel;
33
import javax.swing.JPanel;
34
 
35
public class BalanceAgeePanel extends JPanel {
36
 
37
    public BalanceAgeePanel() {
38
        super(new GridBagLayout());
39
 
80 ilm 40
        JLabel label = new JLabel("Balance âgée client pour la période du ");
18 ilm 41
 
42
        SQLRow rowExercice = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete().getForeignRow("ID_EXERCICE_COMMON");
43
        Calendar dDebut = rowExercice.getDate("DATE_DEB");
44
        final JDate dateDeb = new JDate();
45
        dateDeb.setDate(dDebut.getTime());
46
        final JDate dateFin = new JDate(true);
47
 
48
        DefaultGridBagConstraints c = new DefaultGridBagConstraints();
49
        c.gridx = GridBagConstraints.RELATIVE;
50
        this.add(label, c);
51
        this.add(dateDeb, c);
52
        this.add(new JLabel("au"), c);
53
        this.add(dateFin, c);
54
 
55
        c.gridy++;
73 ilm 56
        c.gridx = 0;
18 ilm 57
        c.gridwidth = GridBagConstraints.REMAINDER;
73 ilm 58
        final JCheckBox boxExcludeEcr = new JCheckBox("Exclure les écritures de clotures");
59
        boxExcludeEcr.setSelected(true);
60
        this.add(boxExcludeEcr, c);
61
 
62
        c.gridy++;
63
        c.gridwidth = GridBagConstraints.REMAINDER;
18 ilm 64
        c.anchor = GridBagConstraints.EAST;
65
        c.fill = GridBagConstraints.NONE;
66
        JButton gen = new JButton("Créer");
67
 
68
        this.add(gen, c);
69
 
70
        gen.addActionListener(new ActionListener() {
71
 
72
            @Override
73
            public void actionPerformed(ActionEvent e) {
73 ilm 74
                BalanceAgeeListeSheetXML l = new BalanceAgeeListeSheetXML(dateDeb.getDate(), dateFin.getDate(), boxExcludeEcr.isSelected());
18 ilm 75
 
76
                try {
25 ilm 77
                    l.createDocument();
78
                    l.openDocument(false);
80 ilm 79
                } catch (Exception originalExn) {
80
                    ExceptionHandler.handle("Impossible de créer la balance âgée", originalExn);
18 ilm 81
                }
82
            }
83
        });
84
    }
85
}