OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 177
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.humanresources.payroll.element;
14
 package org.openconcerto.erp.core.humanresources.payroll.element;
15
 
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
17
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
18
import org.openconcerto.erp.model.ISQLCompteSelector;
18
import org.openconcerto.erp.model.ISQLCompteSelector;
19
import org.openconcerto.sql.element.BaseSQLComponent;
19
import org.openconcerto.sql.element.BaseSQLComponent;
20
import org.openconcerto.sql.element.SQLComponent;
20
import org.openconcerto.sql.element.SQLComponent;
21
import org.openconcerto.sql.model.SQLRowValues;
21
import org.openconcerto.sql.model.SQLRowValues;
22
import org.openconcerto.sql.sqlobject.SQLTextCombo;
22
import org.openconcerto.sql.sqlobject.SQLTextCombo;
23
import org.openconcerto.sql.ui.RadioButtons;
23
import org.openconcerto.sql.ui.RadioButtons;
24
import org.openconcerto.ui.DefaultGridBagConstraints;
24
import org.openconcerto.ui.DefaultGridBagConstraints;
25
 
25
 
26
import java.awt.FlowLayout;
26
import java.awt.FlowLayout;
27
import java.awt.GridBagConstraints;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
28
import java.awt.GridBagLayout;
29
import java.awt.event.ActionEvent;
29
import java.awt.event.ActionEvent;
30
import java.awt.event.ActionListener;
30
import java.awt.event.ActionListener;
31
import java.util.ArrayList;
31
import java.util.ArrayList;
32
import java.util.List;
32
import java.util.List;
33
 
33
 
34
import javax.swing.BorderFactory;
34
import javax.swing.BorderFactory;
35
import javax.swing.ButtonGroup;
35
import javax.swing.ButtonGroup;
36
import javax.swing.JLabel;
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
37
import javax.swing.JPanel;
38
import javax.swing.JRadioButton;
38
import javax.swing.JRadioButton;
39
import javax.swing.JTextField;
39
import javax.swing.JTextField;
40
import javax.swing.SwingConstants;
40
import javax.swing.SwingConstants;
41
 
41
 
42
public class ReglementPayeSQLElement extends ComptaSQLConfElement {
42
public class ReglementPayeSQLElement extends ComptaSQLConfElement {
43
 
43
 
44
    public ReglementPayeSQLElement() {
44
    public ReglementPayeSQLElement() {
45
        super("REGLEMENT_PAYE", "un règlement de paye", "règlements de paye");
45
        super("REGLEMENT_PAYE", "un règlement de paye", "règlements de paye");
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
        l.add("NOM_BANQUE");
50
        l.add("NOM_BANQUE");
51
        l.add("RIB");
51
        l.add("RIB");
52
        l.add("ID_COMPTE_PCE");
52
        l.add("ID_COMPTE_PCE");
53
        l.add("ID_MODE_REGLEMENT_PAYE");
53
        l.add("ID_MODE_REGLEMENT_PAYE");
54
        l.add("LE");
54
        l.add("LE");
55
        return l;
55
        return l;
56
    }
56
    }
57
 
57
 
58
    protected List<String> getComboFields() {
58
    protected List<String> getComboFields() {
59
        final List<String> l = new ArrayList<String>();
59
        final List<String> l = new ArrayList<String>();
60
        l.add("NOM_BANQUE");
60
        l.add("IBAN");
61
        l.add("RIB");
61
        l.add("BIC");
62
        return l;
62
        return l;
63
    }
63
    }
64
 
64
 
65
    @Override
65
    @Override
66
    public boolean isPrivate() {
66
    public boolean isPrivate() {
67
        return true;
67
        return true;
68
    }
68
    }
69
 
69
 
70
    /*
70
    /*
71
     * protected List getPrivateFields() { final List l = new ArrayList();
71
     * protected List getPrivateFields() { final List l = new ArrayList();
72
     * l.add("ID_MODE_REGLEMENT"); return l; }
72
     * l.add("ID_MODE_REGLEMENT"); return l; }
73
     */
73
     */
74
 
74
 
75
    /*
75
    /*
76
     * (non-Javadoc)
76
     * (non-Javadoc)
77
     * 
77
     * 
78
     * @see org.openconcerto.devis.SQLElement#getComponent()
78
     * @see org.openconcerto.devis.SQLElement#getComponent()
79
     */
79
     */
80
    public SQLComponent createComponent() {
80
    public SQLComponent createComponent() {
81
        return new BaseSQLComponent(this) {
81
        return new BaseSQLComponent(this) {
82
 
82
 
83
            public void addViews() {
83
            public void addViews() {
84
 
84
 
85
                this.setLayout(new GridBagLayout());
85
                this.setLayout(new GridBagLayout());
86
                final GridBagConstraints c = new DefaultGridBagConstraints();
86
                final GridBagConstraints c = new DefaultGridBagConstraints();
87
 
87
 
88
                /***********************************************************************************
88
                /***********************************************************************************
89
                 * COORDONNEES DE LA BANQUE
89
                 * COORDONNEES DE LA BANQUE
90
                 **********************************************************************************/
90
                 **********************************************************************************/
91
                JPanel panelBanque = new JPanel();
91
                JPanel panelBanque = new JPanel();
92
                panelBanque.setOpaque(false);
92
                panelBanque.setOpaque(false);
93
                panelBanque.setBorder(BorderFactory.createTitledBorder("Coordonnées bancaires"));
93
                panelBanque.setBorder(BorderFactory.createTitledBorder("Coordonnées bancaires"));
94
                panelBanque.setLayout(new GridBagLayout());
94
                panelBanque.setLayout(new GridBagLayout());
95
 
95
 
96
                // Nom Banque
96
                // Nom Banque
97
                JLabel labelNomBq = new JLabel(getLabelFor("NOM_BANQUE"));
97
                JLabel labelNomBq = new JLabel(getLabelFor("NOM_BANQUE"));
98
                labelNomBq.setHorizontalAlignment(SwingConstants.RIGHT);
98
                labelNomBq.setHorizontalAlignment(SwingConstants.RIGHT);
99
                SQLTextCombo textNomBq = new SQLTextCombo();
99
                SQLTextCombo textNomBq = new SQLTextCombo();
100
                c.weightx = 0;
100
                c.weightx = 0;
101
                panelBanque.add(labelNomBq, c);
101
                panelBanque.add(labelNomBq, c);
102
                c.gridx++;
102
                c.gridx++;
103
                c.weightx = 1;
103
                c.weightx = 1;
104
                panelBanque.add(textNomBq, c);
104
                panelBanque.add(textNomBq, c);
105
                c.weightx = 0;
105
                c.weightx = 0;
106
 
106
 
107
                // IBAN
107
                // IBAN
108
                JLabel labelIBAN = new JLabel(getLabelFor("IBAN"));
108
                JLabel labelIBAN = new JLabel(getLabelFor("IBAN"));
109
                labelIBAN.setHorizontalAlignment(SwingConstants.RIGHT);
109
                labelIBAN.setHorizontalAlignment(SwingConstants.RIGHT);
110
                JTextField textIBAN = new JTextField();
110
                JTextField textIBAN = new JTextField();
111
 
111
 
112
                c.gridy++;
112
                c.gridy++;
113
                c.gridx = 0;
113
                c.gridx = 0;
114
                c.weightx = 0;
114
                c.weightx = 0;
115
                panelBanque.add(labelIBAN, c);
115
                panelBanque.add(labelIBAN, c);
116
                c.gridx++;
116
                c.gridx++;
117
                c.weightx = 1;
117
                c.weightx = 1;
118
                panelBanque.add(textIBAN, c);
118
                panelBanque.add(textIBAN, c);
119
 
119
 
120
                // BIC
120
                // BIC
121
                JLabel labelBIC = new JLabel(getLabelFor("BIC"));
121
                JLabel labelBIC = new JLabel(getLabelFor("BIC"));
122
                labelBIC.setHorizontalAlignment(SwingConstants.RIGHT);
122
                labelBIC.setHorizontalAlignment(SwingConstants.RIGHT);
123
                JTextField textBIC = new JTextField();
123
                JTextField textBIC = new JTextField();
124
 
124
 
125
                c.gridy++;
125
                c.gridy++;
126
                c.gridx = 0;
126
                c.gridx = 0;
127
                c.weightx = 0;
127
                c.weightx = 0;
128
                panelBanque.add(labelBIC, c);
128
                panelBanque.add(labelBIC, c);
129
                c.gridx++;
129
                c.gridx++;
130
                c.weightx = 1;
130
                c.weightx = 1;
131
                panelBanque.add(textBIC, c);
131
                panelBanque.add(textBIC, c);
132
 
132
 
133
                // RIB
133
                // RIB
134
                JLabel labelRIB = new JLabel(getLabelFor("RIB"));
134
                JLabel labelRIB = new JLabel(getLabelFor("RIB"));
135
                labelRIB.setHorizontalAlignment(SwingConstants.RIGHT);
135
                labelRIB.setHorizontalAlignment(SwingConstants.RIGHT);
136
                JTextField textRIB = new JTextField();
136
                JTextField textRIB = new JTextField();
137
 
137
 
138
                c.gridy++;
138
                c.gridy++;
139
                c.gridx = 0;
139
                c.gridx = 0;
140
                panelBanque.add(labelRIB, c);
140
                panelBanque.add(labelRIB, c);
141
                c.gridx++;
141
                c.gridx++;
142
                c.weightx = 1;
142
                c.weightx = 1;
143
                panelBanque.add(textRIB, c);
143
                panelBanque.add(textRIB, c);
144
                c.weightx = 0;
144
                c.weightx = 0;
145
 
145
 
146
                c.gridx = 0;
146
                c.gridx = 0;
147
                c.gridy = 0;
147
                c.gridy = 0;
148
                c.anchor = GridBagConstraints.NORTHWEST;
148
                c.anchor = GridBagConstraints.NORTHWEST;
149
                c.weightx = 1;
149
                c.weightx = 1;
150
                this.add(panelBanque, c);
150
                this.add(panelBanque, c);
151
                c.weightx = 0;
151
                c.weightx = 0;
152
                c.anchor = GridBagConstraints.WEST;
152
                c.anchor = GridBagConstraints.WEST;
153
 
153
 
154
                /***********************************************************************************
154
                /***********************************************************************************
155
                 * Mode de reglement
155
                 * Mode de reglement
156
                 **********************************************************************************/
156
                 **********************************************************************************/
157
                JPanel panelReglement = new JPanel();
157
                JPanel panelReglement = new JPanel();
158
                // panelReglement.setOpaque(false);
158
                // panelReglement.setOpaque(false);
159
                panelReglement.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_MODE_REGLEMENT_PAYE")));
159
                panelReglement.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_MODE_REGLEMENT_PAYE")));
160
                panelReglement.setLayout(new GridBagLayout());
160
                panelReglement.setLayout(new GridBagLayout());
161
 
161
 
162
                // Mode
162
                // Mode
163
                RadioButtons typeRegl = new RadioButtons("NOM");
163
                RadioButtons typeRegl = new RadioButtons("NOM");
164
                typeRegl.setLayout(new FlowLayout(FlowLayout.LEFT));
164
                typeRegl.setLayout(new FlowLayout(FlowLayout.LEFT));
165
                c.gridy = 0;
165
                c.gridy = 0;
166
                c.gridx = 0;
166
                c.gridx = 0;
167
                c.gridwidth = GridBagConstraints.REMAINDER;
167
                c.gridwidth = GridBagConstraints.REMAINDER;
168
                c.weightx = 1;
168
                c.weightx = 1;
169
                panelReglement.add(typeRegl, c);
169
                panelReglement.add(typeRegl, c);
170
 
170
 
171
                // Date de paiement
171
                // Date de paiement
172
                final JRadioButton radioLe = new JRadioButton("Le");
172
                final JRadioButton radioLe = new JRadioButton("Le");
173
                final JTextField textLe = new JTextField(2);
173
                final JTextField textLe = new JTextField(2);
174
                JLabel labelDu = new JLabel("du mois.");
174
                JLabel labelDu = new JLabel("du mois.");
175
                final JRadioButton radioFin = new JRadioButton("Fin de mois");
175
                final JRadioButton radioFin = new JRadioButton("Fin de mois");
176
 
176
 
177
                c.gridwidth = 1;
177
                c.gridwidth = 1;
178
                c.weightx = 0;
178
                c.weightx = 0;
179
                c.gridy++;
179
                c.gridy++;
180
                panelReglement.add(radioLe, c);
180
                panelReglement.add(radioLe, c);
181
                c.gridx++;
181
                c.gridx++;
182
                c.weightx = 1;
182
                c.weightx = 1;
183
                panelReglement.add(textLe, c);
183
                panelReglement.add(textLe, c);
184
                textLe.setText("31");
184
                textLe.setText("31");
185
                c.gridx++;
185
                c.gridx++;
186
                c.weightx = 0;
186
                c.weightx = 0;
187
                panelReglement.add(labelDu, c);
187
                panelReglement.add(labelDu, c);
188
                c.weightx = 1;
188
                c.weightx = 1;
189
 
189
 
190
                c.gridy++;
190
                c.gridy++;
191
                c.gridx = 0;
191
                c.gridx = 0;
192
                c.gridwidth = GridBagConstraints.REMAINDER;
192
                c.gridwidth = GridBagConstraints.REMAINDER;
193
                panelReglement.add(radioFin, c);
193
                panelReglement.add(radioFin, c);
194
                radioFin.addActionListener(new ActionListener() {
194
                radioFin.addActionListener(new ActionListener() {
195
                    public void actionPerformed(ActionEvent e) {
195
                    public void actionPerformed(ActionEvent e) {
196
                        textLe.setText("31");
196
                        textLe.setText("31");
197
                        textLe.setEditable(false);
197
                        textLe.setEditable(false);
198
                        textLe.setEnabled(false);
198
                        textLe.setEnabled(false);
199
                    }
199
                    }
200
                });
200
                });
201
 
201
 
202
                radioLe.addActionListener(new ActionListener() {
202
                radioLe.addActionListener(new ActionListener() {
203
                    public void actionPerformed(ActionEvent e) {
203
                    public void actionPerformed(ActionEvent e) {
204
                        textLe.setEditable(true);
204
                        textLe.setEditable(true);
205
                        textLe.setEnabled(true);
205
                        textLe.setEnabled(true);
206
                    }
206
                    }
207
                });
207
                });
208
                ButtonGroup groupDate = new ButtonGroup();
208
                ButtonGroup groupDate = new ButtonGroup();
209
                groupDate.add(radioLe);
209
                groupDate.add(radioLe);
210
                groupDate.add(radioFin);
210
                groupDate.add(radioFin);
211
                radioFin.setSelected(true);
211
                radioFin.setSelected(true);
212
                textLe.setEditable(false);
212
                textLe.setEditable(false);
213
                textLe.setEnabled(false);
213
                textLe.setEnabled(false);
214
 
214
 
215
                c.weightx = 0;
215
                c.weightx = 0;
216
                c.gridwidth = 1;
216
                c.gridwidth = 1;
217
 
217
 
218
                c.gridx = 1;
218
                c.gridx = 1;
219
                c.gridy = 0;
219
                c.gridy = 0;
220
                c.anchor = GridBagConstraints.NORTHWEST;
220
                c.anchor = GridBagConstraints.NORTHWEST;
221
                c.fill = GridBagConstraints.HORIZONTAL;
221
                c.fill = GridBagConstraints.HORIZONTAL;
222
                this.add(panelReglement, c);
222
                this.add(panelReglement, c);
223
                c.anchor = GridBagConstraints.WEST;
223
                c.anchor = GridBagConstraints.WEST;
224
 
224
 
225
                /***********************************************************************************
225
                /***********************************************************************************
226
                 * Comptabilite
226
                 * Comptabilite
227
                 **********************************************************************************/
227
                 **********************************************************************************/
228
                JPanel panelCompta = new JPanel();
228
                JPanel panelCompta = new JPanel();
229
                panelCompta.setOpaque(false);
229
                panelCompta.setOpaque(false);
230
                panelCompta.setBorder(BorderFactory.createTitledBorder("Comptabilité"));
230
                panelCompta.setBorder(BorderFactory.createTitledBorder("Comptabilité"));
231
                panelCompta.setLayout(new GridBagLayout());
231
                panelCompta.setLayout(new GridBagLayout());
232
 
232
 
233
                // Compte du salarié
233
                // Compte du salarié
234
                JLabel labelCompteSal = new JLabel(getLabelFor("ID_COMPTE_PCE"));
234
                JLabel labelCompteSal = new JLabel(getLabelFor("ID_COMPTE_PCE"));
235
                labelCompteSal.setHorizontalAlignment(SwingConstants.RIGHT);
235
                labelCompteSal.setHorizontalAlignment(SwingConstants.RIGHT);
236
                ISQLCompteSelector compteSal = new ISQLCompteSelector();
236
                ISQLCompteSelector compteSal = new ISQLCompteSelector();
237
 
237
 
238
                c.gridx = 0;
238
                c.gridx = 0;
239
                c.gridy = 0;
239
                c.gridy = 0;
240
                c.gridwidth = 1;
240
                c.gridwidth = 1;
241
                c.weightx = 0;
241
                c.weightx = 0;
242
                panelCompta.add(labelCompteSal, c);
242
                panelCompta.add(labelCompteSal, c);
243
                c.gridx++;
243
                c.gridx++;
244
                c.weightx = 1;
244
                c.weightx = 1;
245
                panelCompta.add(compteSal, c);
245
                panelCompta.add(compteSal, c);
246
 
246
 
247
                c.gridx = 0;
247
                c.gridx = 0;
248
                c.gridy = 1;
248
                c.gridy = 1;
249
                c.weighty = 1;
249
                c.weighty = 1;
250
                c.weightx = 1;
250
                c.weightx = 1;
251
                c.gridwidth = GridBagConstraints.REMAINDER;
251
                c.gridwidth = GridBagConstraints.REMAINDER;
252
                c.anchor = GridBagConstraints.NORTHWEST;
252
                c.anchor = GridBagConstraints.NORTHWEST;
253
                this.add(panelCompta, c);
253
                this.add(panelCompta, c);
254
 
254
 
255
                this.addSQLObject(textNomBq, "NOM_BANQUE");
255
                this.addSQLObject(textNomBq, "NOM_BANQUE");
256
                this.addSQLObject(textRIB, "RIB");
256
                this.addSQLObject(textRIB, "RIB");
257
                this.addSQLObject(textIBAN, "IBAN");
257
                this.addSQLObject(textIBAN, "IBAN");
258
                this.addSQLObject(textBIC, "BIC");
258
                this.addSQLObject(textBIC, "BIC");
259
                this.addRequiredSQLObject(typeRegl, "ID_MODE_REGLEMENT_PAYE");
259
                this.addRequiredSQLObject(typeRegl, "ID_MODE_REGLEMENT_PAYE");
260
                this.addRequiredSQLObject(textLe, "LE");
260
                this.addRequiredSQLObject(textLe, "LE");
261
                this.addRequiredSQLObject(compteSal, "ID_COMPTE_PCE");
261
                this.addRequiredSQLObject(compteSal, "ID_COMPTE_PCE");
262
                // compteSal.init();
262
                // compteSal.init();
263
            }
263
            }
264
 
264
 
265
            protected SQLRowValues createDefaults() {
265
            protected SQLRowValues createDefaults() {
266
 
266
 
267
                SQLRowValues rowVals = new SQLRowValues(getTable());
267
                SQLRowValues rowVals = new SQLRowValues(getTable());
268
                rowVals.put("ID_MODE_REGLEMENT_PAYE", Integer.valueOf(2));
268
                rowVals.put("ID_MODE_REGLEMENT_PAYE", Integer.valueOf(2));
269
                rowVals.put("ID_COMPTE_PCE", ComptePCESQLElement.getId("421"));
269
                rowVals.put("ID_COMPTE_PCE", ComptePCESQLElement.getId("421"));
270
                rowVals.put("LE", 31);
270
                rowVals.put("LE", 31);
271
                return rowVals;
271
                return rowVals;
272
            }
272
            }
273
        };
273
        };
274
    }
274
    }
275
 
275
 
276
    @Override
276
    @Override
277
    protected String createCode() {
277
    protected String createCode() {
278
        return createCodeOfPackage() + ".payment";
278
        return createCodeOfPackage() + ".payment";
279
    }
279
    }
280
}
280
}