OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 151 Rev 156
Line 162... Line 162...
162
                this.dernMois = 0;
162
                this.dernMois = 0;
163
                this.dernAnnee = 0;
163
                this.dernAnnee = 0;
164
 
164
 
165
                this.setLayout(new GridBagLayout());
165
                this.setLayout(new GridBagLayout());
166
 
166
 
167
                final GridBagConstraints c = new DefaultGridBagConstraints();
-
 
168
 
-
 
169
                // Tree elt Fiche de Paye On the left
-
 
170
                c.fill = GridBagConstraints.BOTH;
-
 
171
                c.weightx = 1;
-
 
172
                c.weighty = 1;
-
 
173
                c.gridheight = GridBagConstraints.REMAINDER;
-
 
174
                final RubriquePayeTree tree = new RubriquePayeTree();
167
                final RubriquePayeTree tree = new RubriquePayeTree();
175
                tree.expandRow(0);
168
                tree.expandRow(0);
-
 
169
                JPanel panelLeft = new JPanel(new GridBagLayout());
-
 
170
                GridBagConstraints cLeft = new DefaultGridBagConstraints();
-
 
171
                cLeft.fill = GridBagConstraints.BOTH;
-
 
172
                cLeft.weightx = 1;
-
 
173
                cLeft.weighty = 1;
-
 
174
                cLeft.gridheight = GridBagConstraints.REMAINDER;
-
 
175
                panelLeft.add(tree, cLeft);
176
                this.paneTreeLeft = new JScrollPane(tree);
176
                this.paneTreeLeft = new JScrollPane(tree);
177
                // this.add(this.paneTreeLeft, c);
177
                // this.add(this.paneTreeLeft, c);
178
 
178
 
179
                // Panel Fiche paye on the right
179
                // Panel Fiche paye on the right
180
                // Salarie
180
                // Salarie
181
                JPanel panelRight = new JPanel();
181
                JPanel panelRight = new JPanel(new GridBagLayout());
182
                panelRight.setLayout(new GridBagLayout());
182
                final GridBagConstraints c = new DefaultGridBagConstraints();
-
 
183
                // Tree elt Fiche de Paye On the left
183
                c.fill = GridBagConstraints.HORIZONTAL;
184
                c.fill = GridBagConstraints.HORIZONTAL;
184
                c.weightx = 1;
185
                c.weightx = 1;
185
                c.weighty = 0;
186
                c.weighty = 0;
186
                c.gridheight = 1;
187
                c.gridheight = 1;
187
                c.gridwidth = 2;
188
                c.gridwidth = 2;
188
                this.selSalCombo = new ElementComboBox();
189
                this.selSalCombo = new ElementComboBox();
189
                // c.gridx++;
190
                // c.gridx++;
190
                panelRight.add(this.selSalCombo, c);
191
                panelRight.add(this.selSalCombo, c);
191
 
192
 
192
                // Mois
193
                // Mois
193
                c.gridy++;
-
 
194
                // c.gridx++;
-
 
195
                c.fill = GridBagConstraints.HORIZONTAL;
-
 
196
                c.weightx = 1;
-
 
197
                c.weighty = 0;
-
 
198
                c.gridheight = 1;
-
 
199
                c.gridwidth = 3;
-
 
-
 
194
 
200
                JLabel labelMois = new JLabel("Fiche de paye du mois de");
195
                JLabel labelMois = new JLabel("Fiche de paye du mois de");
201
                this.selMois = new ElementComboBox(true, 20);
196
                this.selMois = new ElementComboBox(true, 20);
202
                JLabel labelDu = new JLabel("Du");
197
                JLabel labelDu = new JLabel("Du");
203
                JLabel labelAu = new JLabel("Au");
198
                JLabel labelAu = new JLabel("Au");
204
                this.dateDu = new JDate();
199
                this.dateDu = new JDate();
Line 206... Line 201...
206
 
201
 
207
                // JTextField textMois = new JTextField();
202
                // JTextField textMois = new JTextField();
208
                JLabel labelAnnee = new JLabel("Année");
203
                JLabel labelAnnee = new JLabel("Année");
209
                this.textAnnee = new JTextField();
204
                this.textAnnee = new JTextField();
210
                {
205
                {
211
                    this.pDate = new JPanel();
206
                    this.pDate = new JPanel(new GridBagLayout());
-
 
207
                    GridBagConstraints cDate = new DefaultGridBagConstraints();
-
 
208
                    cDate.weightx = 0;
-
 
209
                    cDate.gridx = GridBagConstraints.RELATIVE;
212
                    this.pDate.setOpaque(false);
210
                    this.pDate.setOpaque(false);
213
                    this.pDate.add(labelMois);
211
                    this.pDate.add(labelMois, cDate);
-
 
212
                    cDate.weightx = 1;
214
                    this.pDate.add(this.selMois);
213
                    this.pDate.add(this.selMois, cDate);
-
 
214
                    cDate.weightx = 0;
215
                    this.pDate.add(labelAnnee);
215
                    this.pDate.add(labelAnnee, cDate);
-
 
216
                    cDate.weightx = 1;
216
                    this.pDate.add(this.textAnnee);
217
                    this.pDate.add(this.textAnnee, cDate);
-
 
218
                    cDate.weightx = 0;
217
                    this.pDate.add(labelDu);
219
                    this.pDate.add(labelDu, cDate);
-
 
220
                    cDate.weightx = 0;
218
                    this.pDate.add(this.dateDu);
221
                    this.pDate.add(this.dateDu, cDate);
-
 
222
                    cDate.weightx = 0;
219
                    this.pDate.add(labelAu);
223
                    this.pDate.add(labelAu, cDate);
-
 
224
                    cDate.weightx = 0;
220
                    this.pDate.add(this.dateAu);
225
                    this.pDate.add(this.dateAu, cDate);
-
 
226
 
-
 
227
                    c.gridy++;
-
 
228
                    // c.gridx++;
-
 
229
                    c.fill = GridBagConstraints.HORIZONTAL;
-
 
230
                    c.weightx = 1;
-
 
231
                    c.weighty = 0;
-
 
232
                    c.gridheight = 1;
-
 
233
                    c.gridwidth = 2;
221
                    panelRight.add(this.pDate, c);
234
                    panelRight.add(this.pDate, c);
222
                }
235
                }
223
                c.gridx += 2;
236
                // c.gridx += 2;
224
                c.weightx = 1;
237
                // c.weightx = 1;
225
                c.gridwidth = 1;
238
                // c.gridwidth = 1;
226
                c.fill = GridBagConstraints.HORIZONTAL;
239
                // c.fill = GridBagConstraints.HORIZONTAL;
227
                panelRight.add(new JPanel(), c);
240
                // panelRight.add(new JPanel(), c);
228
 
241
 
229
                // Action Button
242
                // Action Button
230
                c.gridx++;
-
 
231
                c.fill = GridBagConstraints.HORIZONTAL;
-
 
232
                c.weightx = 0;
-
 
233
                c.weighty = 0;
-
 
234
 
243
 
235
                JPanel pButtons = new JPanel();
244
                JPanel pButtons = new JPanel(new GridBagLayout());
236
                pButtons.setOpaque(false);
245
                pButtons.setOpaque(false);
237
                JButton buttonUp = new JNiceButton(IListFrame.class.getResource("fleche_haut.png"));
246
                JButton buttonUp = new JNiceButton(IListFrame.class.getResource("fleche_haut.png"));
238
                JButton buttonDown = new JNiceButton(IListFrame.class.getResource("fleche_bas.png"));
247
                JButton buttonDown = new JNiceButton(IListFrame.class.getResource("fleche_bas.png"));
239
                JButton buttonRemove = new JNiceButton(SQLComponent.class.getResource("delete.png"));
248
                JButton buttonRemove = new JNiceButton(SQLComponent.class.getResource("delete.png"));
240
                {
249
                {
-
 
250
                    GridBagConstraints cButtons = new DefaultGridBagConstraints();
-
 
251
                    cButtons.weightx = 0;
-
 
252
                    cButtons.fill = GridBagConstraints.NONE;
-
 
253
                    cButtons.gridx = GridBagConstraints.RELATIVE;
241
                    pButtons.add(buttonUp);
254
                    pButtons.add(buttonUp, cButtons);
242
                    pButtons.add(buttonDown);
255
                    pButtons.add(buttonDown, cButtons);
243
                    pButtons.add(buttonRemove);
256
                    pButtons.add(buttonRemove, cButtons);
244
                }
257
                }
-
 
258
                c.gridx += 2;
-
 
259
                c.fill = GridBagConstraints.NONE;
-
 
260
                c.weightx = 0;
-
 
261
                c.weighty = 0;
-
 
262
                c.gridwidth = 1;
245
                panelRight.add(pButtons, c);
263
                panelRight.add(pButtons, c);
246
 
264
 
247
                // Table
265
                // Table
248
                c.fill = GridBagConstraints.BOTH;
266
                c.fill = GridBagConstraints.BOTH;
249
                c.weightx = 1;
267
                c.weightx = 1;
250
                c.weighty = 1;
268
                c.weighty = 1;
251
                c.gridx = 1;
269
                c.gridx = 0;
252
                c.gridy++;
270
                c.gridy++;
253
                c.gridwidth = GridBagConstraints.REMAINDER;
271
                c.gridwidth = GridBagConstraints.REMAINDER;
254
                this.model = new FichePayeModel(1);
272
                this.model = new FichePayeModel(1);
255
                final JTable table = new JTable(this.model);
273
                final JTable table = new JTable(this.model);
256
                panelRight.add(new JScrollPane(table), c);
274
                panelRight.add(new JScrollPane(table), c);
257
                FichePayeRenderer rend = new FichePayeRenderer();
275
                FichePayeRenderer rend = new FichePayeRenderer();
258
                table.setDefaultRenderer(String.class, rend);
276
                table.setDefaultRenderer(String.class, rend);
259
                table.setDefaultRenderer(Float.class, rend);
277
                table.setDefaultRenderer(Float.class, rend);
260
 
278
 
261
                // Import profil
279
                // Import profil
262
                c.gridx = 1;
280
                c.gridx = 0;
263
                c.gridy++;
281
                c.gridy++;
264
                c.weightx = 0;
282
                c.weightx = 0;
265
                c.weighty = 0;
283
                c.weighty = 0;
266
                c.gridwidth = 1;
284
                c.gridwidth = 1;
267
                c.fill = GridBagConstraints.HORIZONTAL;
285
                c.fill = GridBagConstraints.HORIZONTAL;
268
                JLabel labelProfil = new JLabel("Importer depuis un profil prédéfini");
286
                JLabel labelProfil = new JLabel("Lié à un profil prédéfini");
269
                panelRight.add(labelProfil, c);
287
                panelRight.add(labelProfil, c);
270
                c.gridwidth = 1;
288
                c.gridwidth = 1;
271
 
-
 
272
                this.comboSelProfil = new ElementComboBox();
289
                this.comboSelProfil = new ElementComboBox();
273
                // this.comboSelProfil = new ElementComboBox();
290
                // this.comboSelProfil = new ElementComboBox();
274
                this.comboSelProfil.setListIconVisible(false);
291
                this.comboSelProfil.setListIconVisible(false);
275
                c.gridx++;
292
                c.gridx++;
276
                c.gridwidth = 1;
293
                c.gridwidth = 1;
-
 
294
                c.weightx = 1;
277
 
295
 
278
                // this.comboSelProfil.init(eltProfil.getTable().getField("NOM"), null);
296
                // this.comboSelProfil.init(eltProfil.getTable().getField("NOM"), null);
279
                panelRight.add(this.comboSelProfil, c);
297
                panelRight.add(this.comboSelProfil, c);
280
 
298
 
281
                JButton buttonImportProfil = new JButton("Importer");
299
                JButton buttonImportProfil = new JButton("Importer");
282
                c.gridx++;
300
                c.gridx++;
-
 
301
                c.weightx = 0;
283
                panelRight.add(buttonImportProfil, c);
302
                panelRight.add(buttonImportProfil, c);
284
 
303
 
285
                // Total Periode
304
                // Total Periode
286
                JPanel panelTotal = new JPanel();
305
                JPanel panelTotal = new JPanel(new GridBagLayout());
287
                panelTotal.setBorder(BorderFactory.createTitledBorder("Total période"));
306
                panelTotal.setBorder(BorderFactory.createTitledBorder("Total période"));
288
                panelTotal.setLayout(new GridBagLayout());
-
 
-
 
307
 
289
                GridBagConstraints cPanel = new DefaultGridBagConstraints();
308
                GridBagConstraints cPanel = new DefaultGridBagConstraints();
290
 
309
 
291
                JLabel labelInfosConges = new JLabel(getLabelFor("DETAILS_CONGES"));
310
                JLabel labelInfosConges = new JLabel(getLabelFor("DETAILS_CONGES"));
292
                panelTotal.add(labelInfosConges, cPanel);
311
                panelTotal.add(labelInfosConges, cPanel);
293
                ITextArea textConges = new ITextArea();
312
                ITextArea textConges = new ITextArea();
Line 387... Line 406...
387
                panelTotal.add(textCice, cPanel);
406
                panelTotal.add(textCice, cPanel);
388
                textCice.setEditable(false);
407
                textCice.setEditable(false);
389
                textCice.setEnabled(false);
408
                textCice.setEnabled(false);
390
                this.addSQLObject(textCice, "CICE");
409
                this.addSQLObject(textCice, "CICE");
391
 
410
 
392
                c.gridx = 1;
411
                c.gridx = 0;
393
                c.gridy++;
412
                c.gridy++;
-
 
413
                c.fill = GridBagConstraints.HORIZONTAL;
-
 
414
                c.weightx = 1;
-
 
415
                c.weighty = 0;
394
                c.gridwidth = GridBagConstraints.REMAINDER;
416
                c.gridwidth = GridBagConstraints.REMAINDER;
395
                panelRight.add(panelTotal, c);
417
                panelRight.add(panelTotal, c);
396
 
418
 
397
                // Cumuls
419
                // Cumuls
398
 
420
 
Line 406... Line 428...
406
                c.gridx++;
428
                c.gridx++;
407
                c.gridwidth = 1;
429
                c.gridwidth = 1;
408
                this.buttonGenCompta = new JButton("Generer la comptabilité");
430
                this.buttonGenCompta = new JButton("Generer la comptabilité");
409
                // panelRight.add(buttonGenCompta, c);
431
                // panelRight.add(buttonGenCompta, c);
410
 
432
 
-
 
433
                GridBagConstraints cGlobal = new DefaultGridBagConstraints();
411
                c.gridx = 0;
434
                cGlobal.gridx = 0;
412
                c.gridy = 0;
435
                cGlobal.gridy = 0;
413
                c.gridwidth = 1;
436
                cGlobal.gridwidth = 1;
414
                c.gridheight = 1;
437
                cGlobal.gridheight = 1;
415
                c.fill = GridBagConstraints.BOTH;
438
                cGlobal.fill = GridBagConstraints.BOTH;
416
                c.weightx = 1;
439
                cGlobal.weightx = 1;
417
                c.weighty = 1;
440
                cGlobal.weighty = 1;
418
                this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), c);
441
                this.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.paneTreeLeft, panelRight), cGlobal);
419
 
442
 
420
                // Listeners
443
                // Listeners
421
                this.buttonGenCompta.addActionListener(new ActionListener() {
444
                this.buttonGenCompta.addActionListener(new ActionListener() {
422
                    public void actionPerformed(ActionEvent e) {
445
                    public void actionPerformed(ActionEvent e) {
423
                        try {
446
                        try {
Line 740... Line 763...
740
                        e.printStackTrace();
763
                        e.printStackTrace();
741
                    }
764
                    }
742
 
765
 
743
                    // Calcul des congés
766
                    // Calcul des congés
744
                    SQLRow rowCumulConge = rowSal.getForeignRow("ID_CUMULS_CONGES");
767
                    SQLRow rowCumulConge = rowSal.getForeignRow("ID_CUMULS_CONGES");
-
 
768
                    SQLRow rowVarSalFiche = row.getForeignRow("ID_VARIABLE_SALARIE");
745
                    SQLRow rowVarSal = row.getForeignRow("ID_VARIABLE_SALARIE");
769
                    SQLRow rowVarSal = rowSal.getForeignRow("ID_VARIABLE_SALARIE");
746
                    float congeCumule = rowCumulConge.getFloat("ACQUIS");
770
                    float congeCumule = rowCumulConge.getFloat("ACQUIS");
747
                    float congeRestant = rowCumulConge.getFloat("RESTANT");
771
                    float congeRestant = rowCumulConge.getFloat("RESTANT");
748
 
772
 
749
                    float prisPeriode = rowVarSal.getFloat("CONGES_PRIS");
773
                    float prisPeriode = rowVarSalFiche.getFloat("CONGES_PRIS");
750
 
774
 
751
                    congeRestant += prisPeriode;
775
                    congeRestant += prisPeriode;
752
                    congeCumule -= row.getFloat("CONGES_ACQUIS");
776
                    congeCumule -= row.getFloat("CONGES_ACQUIS");
753
 
777
 
754
                    SQLRowValues rowValsCumulsConges = new SQLRowValues(rowCumulConge.getTable());
778
                    SQLRowValues rowValsCumulsConges = new SQLRowValues(rowCumulConge.getTable());
Line 759... Line 783...
759
                        rowValsCumulsConges.update(rowCumulConge.getID());
783
                        rowValsCumulsConges.update(rowCumulConge.getID());
760
                    } catch (SQLException e) {
784
                    } catch (SQLException e) {
761
                        e.printStackTrace();
785
                        e.printStackTrace();
762
                    }
786
                    }
763
 
787
 
-
 
788
                    // Annulation du cumul des variables
-
 
789
                    final SQLRowValues rowVals = rowVarSal.asRowValues();
-
 
790
                    for (final SQLField field : rowVarSalFiche.getTable().getContentFields()) {
-
 
791
                        if (!field.getName().endsWith("_DEFAULT_VAL") && !field.getName().endsWith("_CUMUL_VAL")) {
-
 
792
                            if (rowVarSalFiche.getTable().contains(field.getName() + "_CUMUL_VAL")) {
-
 
793
                                final float valPeriode = rowVarSalFiche.getObject(field.getName()) == null ? 0.0F : rowVarSalFiche.getFloat(field.getName());
-
 
794
                                final float valCumul = rowVarSal.getObject(field.getName() + "_CUMUL_VAL") == null ? 0.0F : rowVarSal.getFloat(field.getName() + "_CUMUL_VAL");
-
 
795
                                rowVals.put(field.getName() + "_CUMUL_VAL", valCumul - valPeriode);
-
 
796
                            }
-
 
797
 
-
 
798
                        }
-
 
799
                    }
-
 
800
                    try {
-
 
801
                        rowVals.update();
-
 
802
                    } catch (SQLException e) {
-
 
803
                        e.printStackTrace();
-
 
804
                    }
764
                }
805
                }
765
            }
806
            }
766
        }
807
        }
767
    }
808
    }
768
 
809
 
Line 956... Line 997...
956
            }
997
            }
957
        });
998
        });
958
        // Remise à 0 des variables sal
999
        // Remise à 0 des variables sal
959
        final SQLRowValues rowVals = new SQLRowValues(tableVariableSal);
1000
        final SQLRowValues rowVals = new SQLRowValues(tableVariableSal);
960
        for (final SQLField field : tableVariableSal.getContentFields()) {
1001
        for (final SQLField field : tableVariableSal.getContentFields()) {
961
            if (!field.getName().endsWith("_DEFAULT_VAL")) {
1002
            if (!field.getName().endsWith("_DEFAULT_VAL") && !field.getName().endsWith("_CUMUL_VAL")) {
-
 
1003
                if (tableVariableSal.contains(field.getName() + "_CUMUL_VAL")) {
-
 
1004
                    final float valPeriode = rowVarSal.getObject(field.getName()) == null ? 0.0F : rowVarSal.getFloat(field.getName());
-
 
1005
                    final float valCumul = rowVarSal.getObject(field.getName() + "_CUMUL_VAL") == null ? 0.0F : rowVarSal.getFloat(field.getName() + "_CUMUL_VAL");
-
 
1006
                    rowVals.put(field.getName() + "_CUMUL_VAL", valCumul + valPeriode);
-
 
1007
                }
962
                if (tableVariableSal.contains(field.getName() + "_DEFAULT_VAL")) {
1008
                if (tableVariableSal.contains(field.getName() + "_DEFAULT_VAL")) {
963
                    rowVals.put(field.getName(), rowVarSal.getObject(field.getName() + "_DEFAULT_VAL"));
1009
                    rowVals.put(field.getName(), rowVarSal.getObject(field.getName() + "_DEFAULT_VAL"));
964
                } else {
1010
                } else {
965
                    if (field.getType().getJavaType() == Integer.class) {
1011
                    if (field.getType().getJavaType() == Integer.class) {
966
                        rowVals.put(field.getName(), 0);
1012
                        rowVals.put(field.getName(), 0);
967
                    } else {
1013
                    } else {
968
                        rowVals.put(field.getName(), Float.valueOf(0));
1014
                        rowVals.put(field.getName(), Float.valueOf(0));
969
                    }
1015
                    }
970
                }
1016
                }
-
 
1017
 
971
            }
1018
            }
972
        }
1019
        }
973
        rowVals.put("HEURE_TRAV", rowSalInfosPaye.getObject("DUREE_MOIS"));
1020
        rowVals.put("HEURE_TRAV", rowSalInfosPaye.getObject("DUREE_MOIS"));
974
 
1021
 
975
        if (tableVariableSal.contains("NB_JOUR_MOIS")) {
1022
        if (tableVariableSal.contains("NB_JOUR_MOIS")) {
Line 1023... Line 1070...
1023
        final SQLTable tableFiche = conf.getRootSociete().getTable("FICHE_PAYE");
1070
        final SQLTable tableFiche = conf.getRootSociete().getTable("FICHE_PAYE");
1024
        final SQLRow rowFiche = tableFiche.getRow(id);
1071
        final SQLRow rowFiche = tableFiche.getRow(id);
1025
        final SQLRow rowSal = rowFiche.getForeignRow("ID_SALARIE");
1072
        final SQLRow rowSal = rowFiche.getForeignRow("ID_SALARIE");
1026
 
1073
 
1027
        final SQLRowValues rowValsFiche = new SQLRowValues(tableFiche);
1074
        final SQLRowValues rowValsFiche = new SQLRowValues(tableFiche);
1028
        for (final String fk : Arrays.asList("ID_VARIABLE_SALARIE", "ID_CUMULS_CONGES", "ID_CUMULS_PAYE", "ID_REGLEMENT_PAYE")) {
1075
        for (final String fk : Arrays.asList("ID_PAS", "ID_VARIABLE_SALARIE", "ID_CUMULS_CONGES", "ID_CUMULS_PAYE", "ID_REGLEMENT_PAYE")) {
1029
            final SQLRow fRow = rowSal.getForeignRow(fk);
1076
            final SQLRow fRow = rowSal.getForeignRow(fk);
1030
            final SQLRowValues copy = dir.getElement(fRow.getTable()).createCopy(fRow, null);
1077
            final SQLRowValues copy = dir.getElement(fRow.getTable()).createCopy(fRow, null);
1031
            // make sure the copy will be inserted by the update()
1078
            // make sure the copy will be inserted by the update()
1032
            assert copy.getIDNumber() == null;
1079
            assert copy.getIDNumber() == null;
1033
            rowValsFiche.put(fk, copy);
1080
            rowValsFiche.put(fk, copy);
Line 1073... Line 1120...
1073
        return ((anneeClot == 0) ? true : annee > anneeClot) || ((moisClot == 0 || moisClot == 13) ? true : mois > moisClot);
1120
        return ((anneeClot == 0) ? true : annee > anneeClot) || ((moisClot == 0 || moisClot == 13) ? true : mois > moisClot);
1074
    }
1121
    }
1075
 
1122
 
1076
    @Override
1123
    @Override
1077
    protected String createCode() {
1124
    protected String createCode() {
1078
        return createCodeFromPackage() + ".payslip";
1125
        return createCodeOfPackage() + ".payslip";
1079
    }
1126
    }
1080
}
1127
}