OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | 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.payment.element;
14
 package org.openconcerto.erp.core.finance.payment.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.BanqueSQLElement;
17
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
18
import org.openconcerto.erp.core.common.ui.DeviseField;
18
import org.openconcerto.erp.core.common.ui.DeviseField;
19
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeSheet;
19
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeSheet;
20
import org.openconcerto.erp.generationEcritures.GenerationMvtReglementChequeClient;
20
import org.openconcerto.erp.generationEcritures.GenerationMvtReglementChequeClient;
21
import org.openconcerto.sql.Configuration;
21
import org.openconcerto.sql.Configuration;
22
import org.openconcerto.sql.ShowAs;
22
import org.openconcerto.sql.ShowAs;
23
import org.openconcerto.sql.element.BaseSQLComponent;
23
import org.openconcerto.sql.element.BaseSQLComponent;
24
import org.openconcerto.sql.element.SQLComponent;
24
import org.openconcerto.sql.element.SQLComponent;
25
import org.openconcerto.sql.model.SQLRowAccessor;
25
import org.openconcerto.sql.model.SQLRowAccessor;
26
import org.openconcerto.sql.model.SQLTable;
26
import org.openconcerto.sql.model.SQLTable;
27
import org.openconcerto.sql.model.Where;
27
import org.openconcerto.sql.model.Where;
28
import org.openconcerto.sql.sqlobject.ElementComboBox;
28
import org.openconcerto.sql.sqlobject.ElementComboBox;
29
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
29
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
30
import org.openconcerto.ui.DefaultGridBagConstraints;
30
import org.openconcerto.ui.DefaultGridBagConstraints;
31
import org.openconcerto.ui.JDate;
31
import org.openconcerto.ui.JDate;
32
 
32
 
33
import java.awt.GridBagConstraints;
33
import java.awt.GridBagConstraints;
34
import java.awt.GridBagLayout;
34
import java.awt.GridBagLayout;
35
import java.util.ArrayList;
35
import java.util.ArrayList;
36
import java.util.Date;
36
import java.util.Date;
37
import java.util.List;
37
import java.util.List;
38
 
38
 
39
import javax.swing.JLabel;
39
import javax.swing.JLabel;
40
import javax.swing.SwingConstants;
40
import javax.swing.SwingConstants;
41
 
41
 
42
public class ChequeAEncaisserSQLElement extends ChequeSQLElement {
42
public class ChequeAEncaisserSQLElement extends ChequeSQLElement {
43
 
43
 
44
    public ChequeAEncaisserSQLElement() {
44
    public ChequeAEncaisserSQLElement() {
45
        super("CHEQUE_A_ENCAISSER", "un chéque client", "chéques clients");
45
        super("CHEQUE_A_ENCAISSER", "un chéque client", "chéques clients");
46
    }
46
    }
47
 
47
 
48
    protected List<String> getListFields() {
48
    protected List<String> getListFields() {
49
        final List<String> l = new ArrayList<String>();
49
        final List<String> l = new ArrayList<String>();
50
 
50
 
51
        l.add("ID_MOUVEMENT");
51
        l.add("ID_MOUVEMENT");
52
        l.add("ID_CLIENT");
52
        l.add("ID_CLIENT");
53
        l.add("ID_" + BanqueSQLElement.TABLENAME);
53
        l.add("ID_" + BanqueSQLElement.TABLENAME);
54
        l.add("DATE");
54
        l.add("DATE");
55
        l.add("ETS");
55
        l.add("ETS");
56
        l.add("NUMERO");
56
        l.add("NUMERO");
57
        l.add("DATE_VENTE");
57
        l.add("DATE_VENTE");
58
        l.add("DATE_DEPOT");
58
        l.add("DATE_DEPOT");
59
        l.add("MONTANT");
59
        l.add("MONTANT");
60
        l.add("REG_COMPTA");
60
        l.add("REG_COMPTA");
61
        l.add("ENCAISSE");
61
        l.add("ENCAISSE");
62
        return l;
62
        return l;
63
    }
63
    }
64
 
64
 
65
    @Override
65
    @Override
66
    public String getDoneFieldName() {
66
    public String getDoneFieldName() {
67
        return "ENCAISSE";
67
        return "ENCAISSE";
68
    }
68
    }
69
 
69
 
70
    @Override
70
    @Override
71
    public String getDateFieldName() {
71
    public String getDateFieldName() {
72
        return "DATE_DEPOT";
72
        return "DATE_DEPOT";
73
    }
73
    }
74
 
74
 
75
    @Override
75
    @Override
76
    public String getMinDateFieldName() {
76
    public String getMinDateFieldName() {
77
        return "DATE_MIN_DEPOT";
77
        return "DATE_MIN_DEPOT";
78
    }
78
    }
79
 
79
 
80
    @Override
80
    @Override
81
    public void print(final List<Integer> listeCheque, final boolean preview, final Date d) {
81
    public void print(final List<Integer> listeCheque, final boolean preview, final Date d) {
82
        ReleveChequeSheet sheet = new ReleveChequeSheet(listeCheque, d, preview);
82
        ReleveChequeSheet sheet = new ReleveChequeSheet(listeCheque, d, preview);
83
        sheet.createDocumentAsynchronous();
83
        sheet.createDocumentAsynchronous();
84
        sheet.showPrintAndExportAsynchronous(true, false, true);
84
        sheet.showPrintAndExportAsynchronous(true, false, true);
85
    }
85
    }
86
 
86
 
87
    @Override
87
    @Override
88
    public void handle(SQLRowAccessor rowBanque, SQLRowAccessor rowCheque, Date d, String label) throws Exception {
88
    public void handle(SQLRowAccessor rowBanque, SQLRowAccessor rowCheque, Date d, String label) throws Exception {
89
        GenerationMvtReglementChequeClient gen = new GenerationMvtReglementChequeClient(rowCheque.getForeignID("ID_MOUVEMENT"), rowCheque.getLong("MONTANT"), d, rowCheque.getID(), label, rowBanque);
89
        GenerationMvtReglementChequeClient gen = new GenerationMvtReglementChequeClient(rowCheque.getForeignID("ID_MOUVEMENT"), rowCheque.getLong("MONTANT"), d, rowCheque.getID(), label, rowBanque);
90
        gen.genere();
90
        gen.genere();
91
    }
91
    }
92
 
92
 
93
    @Override
93
    @Override
94
    public SQLTableModelSourceOnline createDepositTableSource() {
94
    public SQLTableModelSourceOnline createDepositTableSource() {
95
        final List<String> l = new ArrayList<String>();
95
        final List<String> l = new ArrayList<String>();
96
        l.add("ETS");
96
        l.add("ETS");
97
        l.add("NUMERO");
97
        l.add("NUMERO");
98
        l.add("DATE");
98
        l.add("DATE");
99
        l.add("ID_MOUVEMENT");
99
        l.add("ID_MOUVEMENT");
100
        l.add("DATE_VENTE");
100
        l.add("DATE_VENTE");
101
        l.add(getMinDateFieldName());
101
        l.add(getMinDateFieldName());
102
        l.add("ID_CLIENT");
102
        l.add("ID_CLIENT");
-
 
103
        final ShowAs showAs = new ShowAs(getTable().getDBRoot());
-
 
104
        if (getTable().contains("ID_BANQUE")) {
-
 
105
            l.add("ID_BANQUE");
-
 
106
            showAs.show(getTable().getForeignTable("ID_BANQUE"), "NOM");
-
 
107
        }
103
        l.add("MONTANT");
108
        l.add("MONTANT");
104
 
109
 
105
        final ShowAs showAs = new ShowAs(getTable().getDBRoot());
-
 
106
 
110
 
107
        final SQLTable mvtT = getTable().getForeignTable("ID_MOUVEMENT");
111
        final SQLTable mvtT = getTable().getForeignTable("ID_MOUVEMENT");
108
        showAs.show(mvtT, "ID_PIECE");
112
        showAs.show(mvtT, "ID_PIECE");
109
        showAs.show(mvtT.getForeignTable("ID_PIECE"), "NOM");
113
        showAs.show(mvtT.getForeignTable("ID_PIECE"), "NOM");
110
 
114
 
111
        final SQLTable clientERP = getTable().getForeignTable("ID_CLIENT");
115
        final SQLTable clientERP = getTable().getForeignTable("ID_CLIENT");
112
        {
116
        {
113
            showAs.show(clientERP, "NOM");
117
            showAs.show(clientERP, "NOM");
114
        }
118
        }
115
 
119
 
116
        return this.createDepositTableSource(l, showAs, new Where(getTable().getField("REG_COMPTA"), "=", Boolean.FALSE));
120
        return this.createDepositTableSource(l, showAs, new Where(getTable().getField("REG_COMPTA"), "=", Boolean.FALSE));
117
    }
121
    }
118
 
122
 
119
    protected List<String> getComboFields() {
123
    protected List<String> getComboFields() {
120
        final List<String> l = new ArrayList<String>();
124
        final List<String> l = new ArrayList<String>();
121
        l.add("DATE_VENTE");
125
        l.add("DATE_VENTE");
122
        l.add("MONTANT");
126
        l.add("MONTANT");
123
        l.add("ID_CLIENT");
127
        l.add("ID_CLIENT");
124
        return l;
128
        return l;
125
    }
129
    }
126
 
130
 
127
    /*
131
    /*
128
     * (non-Javadoc)
132
     * (non-Javadoc)
129
     * 
133
     * 
130
     * @see org.openconcerto.devis.SQLElement#getComponent()
134
     * @see org.openconcerto.devis.SQLElement#getComponent()
131
     */
135
     */
132
    public SQLComponent createComponent() {
136
    public SQLComponent createComponent() {
133
        return new BaseSQLComponent(this) {
137
        return new BaseSQLComponent(this) {
134
 
138
 
135
            private DeviseField textMontant = new DeviseField();
139
            private DeviseField textMontant = new DeviseField();
136
 
140
 
137
            public void addViews() {
141
            public void addViews() {
138
                this.setLayout(new GridBagLayout());
142
                this.setLayout(new GridBagLayout());
139
                final GridBagConstraints c = new DefaultGridBagConstraints();
143
                final GridBagConstraints c = new DefaultGridBagConstraints();
140
 
144
 
141
                // Montant
145
                // Montant
142
                JLabel labelMontant = new JLabel("Montant ");
146
                JLabel labelMontant = new JLabel("Montant ");
143
 
147
 
144
                this.add(labelMontant, c);
148
                this.add(labelMontant, c);
145
                c.gridx++;
149
                c.gridx++;
146
                c.weightx = 1;
150
                c.weightx = 1;
147
                this.add(this.textMontant, c);
151
                this.add(this.textMontant, c);
148
 
152
 
149
                // Date
153
                // Date
150
                JLabel labelDate = new JLabel("Date ");
154
                JLabel labelDate = new JLabel("Date ");
151
                c.weightx = 0;
155
                c.weightx = 0;
152
                c.gridx++;
156
                c.gridx++;
153
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
157
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
154
                this.add(labelDate, c);
158
                this.add(labelDate, c);
155
 
159
 
156
                JDate dateVente = new JDate(true);
160
                JDate dateVente = new JDate(true);
157
                c.gridx++;
161
                c.gridx++;
158
                c.gridwidth = GridBagConstraints.REMAINDER;
162
                c.gridwidth = GridBagConstraints.REMAINDER;
159
                this.add(dateVente, c);
163
                this.add(dateVente, c);
160
 
164
 
161
                // Date echeance
165
                // Date echeance
162
                JLabel labelDateEcheance = new JLabel("Date d'échéance");
166
                JLabel labelDateEcheance = new JLabel("Date d'échéance");
163
                c.weightx = 0;
167
                c.weightx = 0;
164
                c.gridy++;
168
                c.gridy++;
165
                c.gridwidth = 1;
169
                c.gridwidth = 1;
166
                c.gridx = 0;
170
                c.gridx = 0;
167
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
171
                labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
168
                this.add(labelDateEcheance, c);
172
                this.add(labelDateEcheance, c);
169
 
173
 
170
                JDate dateEcheance = new JDate(true);
174
                JDate dateEcheance = new JDate(true);
171
                c.gridx++;
175
                c.gridx++;
172
                c.gridwidth = 1;
176
                c.gridwidth = 1;
173
                this.add(dateEcheance, c);
177
                this.add(dateEcheance, c);
174
 
178
 
175
                c.gridy++;
179
                c.gridy++;
176
                c.gridx = 0;
180
                c.gridx = 0;
177
                JLabel labelClientNom = new JLabel("Client ");
181
                JLabel labelClientNom = new JLabel("Client ");
178
                this.add(labelClientNom, c);
182
                this.add(labelClientNom, c);
179
 
183
 
180
                ElementComboBox nomClient = new ElementComboBox();
184
                ElementComboBox nomClient = new ElementComboBox();
181
                c.gridx++;
185
                c.gridx++;
182
                c.gridwidth = GridBagConstraints.REMAINDER;
186
                c.gridwidth = GridBagConstraints.REMAINDER;
183
                this.add(nomClient, c);
187
                this.add(nomClient, c);
184
 
188
 
185
                this.addRequiredSQLObject(nomClient, "ID_CLIENT");
189
                this.addRequiredSQLObject(nomClient, "ID_CLIENT");
186
                this.addRequiredSQLObject(this.textMontant, "MONTANT");
190
                this.addRequiredSQLObject(this.textMontant, "MONTANT");
187
                this.addRequiredSQLObject(dateVente, "DATE_VENTE");
191
                this.addRequiredSQLObject(dateVente, "DATE_VENTE");
188
                this.addRequiredSQLObject(dateEcheance, "DATE_MIN_DEPOT");
192
                this.addRequiredSQLObject(dateEcheance, "DATE_MIN_DEPOT");
189
            }
193
            }
190
        };
194
        };
191
    }
195
    }
192
 
196
 
193
    @Override
197
    @Override
194
    protected String createCode() {
198
    protected String createCode() {
195
        return createCodeOfPackage() + ".cheque";
199
        return createCodeOfPackage() + ".cheque";
196
    }
200
    }
197
}
201
}