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.model;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
|
|
17 |
import org.openconcerto.erp.core.common.ui.SQLJavaEditor;
|
|
|
18 |
import org.openconcerto.erp.core.humanresources.payroll.element.PeriodeValiditeSQLElement;
|
|
|
19 |
import org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement;
|
|
|
20 |
import org.openconcerto.sql.Configuration;
|
|
|
21 |
import org.openconcerto.sql.model.SQLBase;
|
|
|
22 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
23 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
24 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
25 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
26 |
import org.openconcerto.sql.model.Where;
|
|
|
27 |
|
|
|
28 |
import java.sql.SQLException;
|
|
|
29 |
import java.util.Date;
|
|
|
30 |
import java.util.HashMap;
|
|
|
31 |
import java.util.List;
|
|
|
32 |
import java.util.Map;
|
|
|
33 |
import java.util.Vector;
|
|
|
34 |
|
|
|
35 |
import javax.swing.table.AbstractTableModel;
|
|
|
36 |
|
|
|
37 |
import org.apache.commons.dbutils.handlers.ArrayListHandler;
|
|
|
38 |
|
|
|
39 |
// TODO gestion de la place des rubriques dans l'ordre brut - cot - net et comm everywhere
|
|
|
40 |
// FIXME Thread pour le calcul
|
|
|
41 |
public class FichePayeModel extends AbstractTableModel {
|
|
|
42 |
|
|
|
43 |
// Rubrique
|
|
|
44 |
private Vector<SQLRowValues> vectRubrique;
|
|
|
45 |
private Vector<SQLRowValues> vectRowValsToDelete;
|
|
|
46 |
|
|
|
47 |
// table des rubriques
|
|
|
48 |
private final Map<String, SQLTable> mapTableSource = new HashMap<String, SQLTable>();
|
|
|
49 |
|
|
|
50 |
// Id de la fiche de paye concernee
|
|
|
51 |
private int idFiche;
|
|
|
52 |
|
|
|
53 |
private String[] title;
|
|
|
54 |
|
|
|
55 |
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
56 |
private final static SQLTable tableProfilElt = Configuration.getInstance().getBase().getTable("PROFIL_PAYE_ELEMENT");
|
|
|
57 |
private final static SQLTable tableFichePayeElt = base.getTable("FICHE_PAYE_ELEMENT");
|
|
|
58 |
private final static SQLTable tableFichePaye = base.getTable("FICHE_PAYE");
|
|
|
59 |
private final static SQLTable tableValidite = Configuration.getInstance().getBase().getTable("PERIODE_VALIDITE");
|
|
|
60 |
|
|
|
61 |
private SQLJavaEditor javaEdit = new SQLJavaEditor(VariablePayeSQLElement.getMapTree());
|
|
|
62 |
|
|
|
63 |
// liste des variable de paye à calculer
|
|
|
64 |
private float salBrut, cotPat, cotSal, netImp, netAPayer, csg;
|
|
|
65 |
private Map<Integer, String> mapField;
|
|
|
66 |
|
|
|
67 |
public FichePayeModel(int idFiche) {
|
|
|
68 |
|
|
|
69 |
System.err.println("NEW FICHE PAYE MODEL");
|
|
|
70 |
|
|
|
71 |
this.idFiche = idFiche;
|
|
|
72 |
this.vectRubrique = new Vector<SQLRowValues>();
|
|
|
73 |
this.vectRowValsToDelete = new Vector<SQLRowValues>();
|
|
|
74 |
|
|
|
75 |
// Titres des colonnes
|
|
|
76 |
this.title = new String[9];
|
|
|
77 |
this.title[0] = "Libellé";
|
|
|
78 |
this.title[1] = "Base";
|
|
|
79 |
this.title[2] = "Taux sal.";
|
|
|
80 |
this.title[3] = "Montant sal. à ajouter";
|
|
|
81 |
this.title[4] = "Montant sal. à déduire";
|
|
|
82 |
this.title[5] = "Taux pat.";
|
|
|
83 |
this.title[6] = "Montant pat.";
|
|
|
84 |
this.title[7] = "Impression";
|
|
|
85 |
this.title[8] = "Dans la Période";
|
|
|
86 |
|
|
|
87 |
SQLTable tableNet = Configuration.getInstance().getBase().getTable("RUBRIQUE_NET");
|
|
|
88 |
SQLTable tableBrut = Configuration.getInstance().getBase().getTable("RUBRIQUE_BRUT");
|
|
|
89 |
SQLTable tableCotis = Configuration.getInstance().getBase().getTable("RUBRIQUE_COTISATION");
|
|
|
90 |
SQLTable tableComm = Configuration.getInstance().getBase().getTable("RUBRIQUE_COMM");
|
|
|
91 |
this.mapTableSource.put(tableNet.getName(), tableNet);
|
|
|
92 |
this.mapTableSource.put(tableBrut.getName(), tableBrut);
|
|
|
93 |
this.mapTableSource.put(tableCotis.getName(), tableCotis);
|
|
|
94 |
this.mapTableSource.put(tableComm.getName(), tableComm);
|
|
|
95 |
|
|
|
96 |
this.mapField = new HashMap<Integer, String>();
|
|
|
97 |
this.mapField.put(new Integer(0), "NOM");
|
|
|
98 |
this.mapField.put(new Integer(1), "NB_BASE");
|
|
|
99 |
this.mapField.put(new Integer(2), "TAUX_SAL");
|
|
|
100 |
this.mapField.put(new Integer(3), "MONTANT_SAL_AJ");
|
|
|
101 |
this.mapField.put(new Integer(4), "MONTANT_SAL_DED");
|
|
|
102 |
this.mapField.put(new Integer(5), "TAUX_PAT");
|
|
|
103 |
this.mapField.put(new Integer(6), "MONTANT_PAT");
|
|
|
104 |
this.mapField.put(new Integer(7), "IMPRESSION");
|
|
|
105 |
this.mapField.put(new Integer(8), "IN_PERIODE");
|
|
|
106 |
|
|
|
107 |
// loadElement();
|
|
|
108 |
// methodeTmp();
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
private void resetValueFiche() {
|
|
|
112 |
|
|
|
113 |
/*
|
|
|
114 |
* if (this.threadUpdate != null && this.threadUpdate.isAlive()) { this.threadUpdate.stop();
|
|
|
115 |
* }
|
|
|
116 |
*/
|
|
|
117 |
|
|
|
118 |
this.salBrut = 0.0F;
|
|
|
119 |
this.cotPat = 0.0F;
|
|
|
120 |
this.cotSal = 0.0F;
|
|
|
121 |
this.netAPayer = 0.0F;
|
|
|
122 |
this.netImp = 0.0F;
|
|
|
123 |
this.csg = 0.0F;
|
|
|
124 |
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public void loadAllElements() {
|
|
|
128 |
|
|
|
129 |
System.err.println("Start At " + new Date());
|
|
|
130 |
if (this.idFiche <= 1) {
|
|
|
131 |
System.err.println("Aucune fiche associée");
|
|
|
132 |
return;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
// RAZ
|
|
|
136 |
resetValueFiche();
|
|
|
137 |
|
|
|
138 |
/*
|
|
|
139 |
* this.threadUpdate = new Thread("Update Fiche Paye") { public void run() {
|
|
|
140 |
*/
|
|
|
141 |
this.vectRubrique = new Vector<SQLRowValues>();
|
|
|
142 |
|
|
|
143 |
SQLRow rowFiche = tableFichePaye.getRow(this.idFiche);
|
|
|
144 |
|
|
|
145 |
this.javaEdit.setSalarieID(rowFiche.getInt("ID_SALARIE"));
|
|
|
146 |
|
|
|
147 |
// éléments de la fiche de paye
|
|
|
148 |
SQLSelect selAllIDFicheElt = new SQLSelect(base);
|
|
|
149 |
|
|
|
150 |
selAllIDFicheElt.addSelect(tableFichePayeElt.getField("ID"));
|
|
|
151 |
selAllIDFicheElt.addSelect(tableFichePayeElt.getField("POSITION"));
|
|
|
152 |
selAllIDFicheElt.setWhere(new Where(tableFichePayeElt.getField("ID_FICHE_PAYE"), "=", this.idFiche));
|
|
|
153 |
|
|
|
154 |
selAllIDFicheElt.setDistinct(true);
|
|
|
155 |
|
|
|
156 |
selAllIDFicheElt.addRawOrder("\"FICHE_PAYE_ELEMENT\".\"POSITION\"");
|
|
|
157 |
String reqAllIDFichelElt = selAllIDFicheElt.asString();
|
|
|
158 |
|
|
|
159 |
System.err.println("Request " + reqAllIDFichelElt);
|
|
|
160 |
|
|
|
161 |
Object[] objIDFicheElt = ((List) base.getDataSource().execute(reqAllIDFichelElt, new ArrayListHandler())).toArray();
|
|
|
162 |
|
|
|
163 |
System.err.println(objIDFicheElt.length + " elements to load");
|
|
|
164 |
|
|
|
165 |
for (int i = 0; i < objIDFicheElt.length; i++) {
|
|
|
166 |
SQLRow row = tableFichePayeElt.getRow(Integer.parseInt(((Object[]) objIDFicheElt[i])[0].toString()));
|
|
|
167 |
|
|
|
168 |
String source = row.getString("SOURCE");
|
|
|
169 |
int idSource = row.getInt("IDSOURCE");
|
|
|
170 |
|
|
|
171 |
if (source.trim().length() != 0) {
|
|
|
172 |
|
|
|
173 |
// System.err.println("Source != null");
|
|
|
174 |
|
|
|
175 |
if (this.mapTableSource.get(source) != null) {
|
|
|
176 |
SQLRow rowSource = this.mapTableSource.get(source).getRow(idSource);
|
|
|
177 |
|
|
|
178 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
179 |
loadElementBrut(rowSource, row);
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_COTISATION")) {
|
|
|
183 |
loadElementCotisation(rowSource, row);
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
187 |
loadElementNet(rowSource, row);
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
191 |
loadElementComm(rowSource, row);
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
} else {
|
|
|
195 |
System.err.println("Table " + source + " non référencée");
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
}
|
|
|
199 |
System.err.println(this.vectRubrique.size() + " elements ADDed ");
|
|
|
200 |
|
|
|
201 |
fireTableDataChanged();
|
|
|
202 |
/*
|
|
|
203 |
* } }; this.threadUpdate.start();
|
|
|
204 |
*/
|
|
|
205 |
|
|
|
206 |
System.err.println("End At " + new Date());
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
public String getColumnName(int column) {
|
|
|
210 |
|
|
|
211 |
return this.title[column];
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
public int getRowCount() {
|
|
|
215 |
|
|
|
216 |
return this.vectRubrique.size();
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
public int getColumnCount() {
|
|
|
220 |
|
|
|
221 |
return this.title.length;
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
public Object getValueAt(int rowIndex, int columnIndex) {
|
|
|
225 |
|
|
|
226 |
SQLRowValues row = this.vectRubrique.get(rowIndex);
|
|
|
227 |
Object o = null;
|
|
|
228 |
|
|
|
229 |
if (row != null) {
|
|
|
230 |
o = row.getObject(this.mapField.get(new Integer(columnIndex)).toString());
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
return o;
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
public Class<?> getColumnClass(int columnIndex) {
|
|
|
237 |
Class<?> cl = tableFichePayeElt.getField(this.mapField.get(new Integer(columnIndex))).getType().getJavaType();
|
|
|
238 |
return cl;
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
/*
|
|
|
242 |
* public boolean isCellEditable(int rowIndex, int columnIndex) {
|
|
|
243 |
*
|
|
|
244 |
* if (columnIndex == 0) { return true; }
|
|
|
245 |
*
|
|
|
246 |
* SQLRowValues rowVals = (SQLRowValues) this.vectRubrique.get(rowIndex);
|
|
|
247 |
*
|
|
|
248 |
* Object ob = rowVals.getObject("SOURCE"); String source = (ob == null) ? "" : ob.toString();
|
|
|
249 |
*
|
|
|
250 |
* if ((source.trim().length() != 0) && (!source.equalsIgnoreCase("RUBRIQUE_COTISATION"))) {
|
|
|
251 |
*
|
|
|
252 |
* if (!source.equalsIgnoreCase("RUBRIQUE_COMM")) { if (columnIndex > 5) { return false; } else
|
|
|
253 |
* {
|
|
|
254 |
*
|
|
|
255 |
* if (columnIndex == 1 || columnIndex == 2) { return true; }
|
|
|
256 |
*
|
|
|
257 |
* if (source.equalsIgnoreCase("RUBRIQUE_COT") && (columnIndex == 5)) {
|
|
|
258 |
*
|
|
|
259 |
* return true; } } } } return false; }
|
|
|
260 |
*
|
|
|
261 |
* public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
|
|
262 |
*
|
|
|
263 |
* System.err.println("_______***$$$$ " + this.mapField.get(new
|
|
|
264 |
* Integer(columnIndex)).toString()); SQLRowValues rowVals = (SQLRowValues)
|
|
|
265 |
* this.vectRubrique.get(rowIndex); rowVals.put(this.mapField.get(new
|
|
|
266 |
* Integer(columnIndex)).toString(), aValue); rowVals.put("VALIDE", Boolean.TRUE);
|
|
|
267 |
*
|
|
|
268 |
* try { rowVals.update(); } catch (SQLException e) { e.printStackTrace(); }
|
|
|
269 |
*
|
|
|
270 |
* calculValue(); }
|
|
|
271 |
*/
|
|
|
272 |
public boolean containValueAt(int rowIndex, int columnIndex) {
|
|
|
273 |
|
|
|
274 |
if (columnIndex == 0) {
|
|
|
275 |
return true;
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
SQLRowValues rowVals = this.vectRubrique.get(rowIndex);
|
|
|
279 |
|
|
|
280 |
Object ob = rowVals.getObject("SOURCE");
|
|
|
281 |
String source = (ob == null) ? "" : ob.toString();
|
|
|
282 |
|
|
|
283 |
Object obId = rowVals.getObject("IDSOURCE");
|
|
|
284 |
int idSource = (obId == null) ? 1 : rowVals.getInt("IDSOURCE");
|
|
|
285 |
|
|
|
286 |
if ((source.trim().length() != 0) && (!source.equalsIgnoreCase("RUBRIQUE_COTISATION"))) {
|
|
|
287 |
/*
|
|
|
288 |
* if (source.equalsIgnoreCase("RUBRIQUE_COMM")) { return true; } else {
|
|
|
289 |
*/
|
|
|
290 |
|
|
|
291 |
if (columnIndex > 4) {
|
|
|
292 |
return false;
|
|
|
293 |
} else {
|
|
|
294 |
SQLRow row = this.mapTableSource.get(source).getRow(idSource);
|
|
|
295 |
if (source.equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
296 |
if ((row.getInt("ID_TYPE_RUBRIQUE_BRUT") == 2) && (columnIndex == 4)) {
|
|
|
297 |
return false;
|
|
|
298 |
}
|
|
|
299 |
if ((row.getInt("ID_TYPE_RUBRIQUE_BRUT") == 3) && (columnIndex == 3)) {
|
|
|
300 |
return false;
|
|
|
301 |
}
|
|
|
302 |
} else {
|
|
|
303 |
if (source.equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
304 |
if ((row.getInt("ID_TYPE_RUBRIQUE_NET") == 2) && (columnIndex == 4)) {
|
|
|
305 |
return false;
|
|
|
306 |
}
|
|
|
307 |
if ((row.getInt("ID_TYPE_RUBRIQUE_NET") == 3) && (columnIndex == 3)) {
|
|
|
308 |
return false;
|
|
|
309 |
}
|
|
|
310 |
} else {
|
|
|
311 |
return false;
|
|
|
312 |
}
|
|
|
313 |
}
|
|
|
314 |
// }
|
|
|
315 |
}
|
|
|
316 |
} else {
|
|
|
317 |
if (columnIndex == 3) {
|
|
|
318 |
return false;
|
|
|
319 |
}
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
return true;
|
|
|
323 |
}
|
|
|
324 |
|
|
|
325 |
public void loadFromProfil(final int idProfil) {
|
|
|
326 |
|
|
|
327 |
System.err.println("Load from profil");
|
|
|
328 |
|
|
|
329 |
resetValueFiche();
|
|
|
330 |
|
|
|
331 |
/*
|
|
|
332 |
* this.threadUpdate = new Thread("Update Fiche Paye") { public void run() {
|
|
|
333 |
*/
|
|
|
334 |
// On supprime les anciennes lignes de la fiche
|
|
|
335 |
while (this.vectRubrique.size() > 0) {
|
|
|
336 |
|
|
|
337 |
this.vectRowValsToDelete.add(this.vectRubrique.remove(0));
|
|
|
338 |
}
|
|
|
339 |
|
|
|
340 |
// this.vectRubrique = new Vector();
|
|
|
341 |
|
|
|
342 |
// Listes des rubriques du profil
|
|
|
343 |
SQLSelect selAllIDProfilElt = new SQLSelect(Configuration.getInstance().getBase());
|
|
|
344 |
|
|
|
345 |
selAllIDProfilElt.addSelect(tableProfilElt.getField("ID"));
|
|
|
346 |
selAllIDProfilElt.addSelect(tableProfilElt.getField("POSITION"));
|
|
|
347 |
selAllIDProfilElt.setWhere(new Where(tableProfilElt.getField("ID_PROFIL_PAYE"), "=", idProfil));
|
|
|
348 |
selAllIDProfilElt.addRawOrder("\"PROFIL_PAYE_ELEMENT\".\"POSITION\"");
|
|
|
349 |
|
|
|
350 |
String reqAllIDProfilElt = selAllIDProfilElt.asString();
|
|
|
351 |
|
|
|
352 |
Object[] objIDProfilElt = ((List) Configuration.getInstance().getBase().getDataSource().execute(reqAllIDProfilElt, new ArrayListHandler())).toArray();
|
|
|
353 |
|
|
|
354 |
for (int i = 0; i < objIDProfilElt.length; i++) {
|
|
|
355 |
SQLRow rowTmp = tableProfilElt.getRow(Integer.parseInt(((Object[]) objIDProfilElt[i])[0].toString()));
|
|
|
356 |
|
|
|
357 |
String source = rowTmp.getString("SOURCE");
|
|
|
358 |
int idSource = rowTmp.getInt("IDSOURCE");
|
|
|
359 |
|
|
|
360 |
if (this.mapTableSource.get(source) != null) {
|
|
|
361 |
SQLRow row = this.mapTableSource.get(source).getRow(idSource);
|
|
|
362 |
|
|
|
363 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
364 |
loadElementBrut(row, null);
|
|
|
365 |
}
|
|
|
366 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COTISATION")) {
|
|
|
367 |
loadElementCotisation(row, null);
|
|
|
368 |
}
|
|
|
369 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
370 |
loadElementNet(row, null);
|
|
|
371 |
}
|
|
|
372 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
373 |
loadElementComm(row, null);
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
} else {
|
|
|
377 |
System.err.println("FichePayeModel.java --> Table non référencée dans la Map. Table name : " + source);
|
|
|
378 |
}
|
|
|
379 |
}
|
|
|
380 |
|
|
|
381 |
// this.vectRubrique = new Vector();
|
|
|
382 |
|
|
|
383 |
// updateFields(this.idFiche);
|
|
|
384 |
fireTableDataChanged();
|
|
|
385 |
|
|
|
386 |
/*
|
|
|
387 |
* } }; this.threadUpdate.start();
|
|
|
388 |
*/
|
|
|
389 |
}
|
|
|
390 |
|
|
|
391 |
public String getSourceAt(int rowIndex) {
|
|
|
392 |
return this.vectRubrique.get(rowIndex).getString("SOURCE");
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
public int upRow(int rowIndex) {
|
|
|
396 |
// On vérifie qu'il est possible de remonter la ligne
|
|
|
397 |
if ((this.vectRubrique.size() > 1) && (rowIndex > 0)) {
|
|
|
398 |
System.err.println("UP");
|
|
|
399 |
SQLRowValues tmp = this.vectRubrique.get(rowIndex);
|
|
|
400 |
this.vectRubrique.set(rowIndex, this.vectRubrique.get(rowIndex - 1));
|
|
|
401 |
this.vectRubrique.set(rowIndex - 1, tmp);
|
|
|
402 |
this.fireTableDataChanged();
|
|
|
403 |
return rowIndex - 1;
|
|
|
404 |
}
|
|
|
405 |
System.err.println("can't up!!");
|
|
|
406 |
return rowIndex;
|
|
|
407 |
}
|
|
|
408 |
|
|
|
409 |
public int downRow(int rowIndex) {
|
|
|
410 |
// On vérifie qu'il est possible de descendre la ligne
|
|
|
411 |
if ((rowIndex >= 0) && (this.vectRubrique.size() > 1) && (rowIndex + 1 < this.vectRubrique.size())) {
|
|
|
412 |
|
|
|
413 |
System.err.println("DOWN");
|
|
|
414 |
SQLRowValues tmp = this.vectRubrique.get(rowIndex);
|
|
|
415 |
this.vectRubrique.set(rowIndex, this.vectRubrique.get(rowIndex + 1));
|
|
|
416 |
this.vectRubrique.set(rowIndex + 1, tmp);
|
|
|
417 |
this.fireTableDataChanged();
|
|
|
418 |
return rowIndex + 1;
|
|
|
419 |
}
|
|
|
420 |
|
|
|
421 |
System.err.println("can't down!!!");
|
|
|
422 |
return rowIndex;
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
public void setLastRowAT(int rowIndex) {
|
|
|
426 |
|
|
|
427 |
// On vérifie qu'il est possible de descendre la ligne
|
|
|
428 |
if ((rowIndex > 0) && (rowIndex < this.vectRubrique.size())) {
|
|
|
429 |
this.vectRubrique.add(rowIndex, this.vectRubrique.remove(this.vectRubrique.size() - 1));
|
|
|
430 |
}
|
|
|
431 |
this.fireTableDataChanged();
|
|
|
432 |
}
|
|
|
433 |
|
|
|
434 |
public void setFicheID(int id) {
|
|
|
435 |
this.idFiche = id;
|
|
|
436 |
|
|
|
437 |
// this.javaEdit.setSalarieID(this.tableFichePaye.getRow(this.idFiche).getInt("ID_SALARIE"));
|
|
|
438 |
this.loadAllElements();
|
|
|
439 |
}
|
|
|
440 |
|
|
|
441 |
/***********************************************************************************************
|
|
|
442 |
* Ajouter une ligne
|
|
|
443 |
*
|
|
|
444 |
* @param row SQLRow RUBRIQUE_BRUT, RUBRIQUE_COTISATION, RUBRIQUE_NET, RUBRIQUE_COMM
|
|
|
445 |
* @param index index ou doit etre insere la row
|
|
|
446 |
*/
|
|
|
447 |
public void addRowAt(SQLRow row, int index) {
|
|
|
448 |
|
|
|
449 |
int size = this.vectRubrique.size();
|
|
|
450 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
451 |
this.loadElementBrut(row, null);
|
|
|
452 |
} else {
|
|
|
453 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COTISATION")) {
|
|
|
454 |
this.loadElementCotisation(row, null);
|
|
|
455 |
} else {
|
|
|
456 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
457 |
this.loadElementNet(row, null);
|
|
|
458 |
} else {
|
|
|
459 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
460 |
this.loadElementComm(row, null);
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
}
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
if (size != this.vectRubrique.size()) {
|
|
|
467 |
setLastRowAT(index);
|
|
|
468 |
}
|
|
|
469 |
if (!row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
470 |
calculValue();
|
|
|
471 |
}
|
|
|
472 |
this.fireTableDataChanged();
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
public void removeRow(int rowIndex) {
|
|
|
476 |
// System.err.println("_________________________________REMOVE");
|
|
|
477 |
if (rowIndex >= 0) {
|
|
|
478 |
|
|
|
479 |
SQLRowValues rowVals = this.vectRubrique.remove(rowIndex);
|
|
|
480 |
this.vectRowValsToDelete.add(rowVals);
|
|
|
481 |
|
|
|
482 |
if (!rowVals.getString("SOURCE").equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
483 |
calculValue();
|
|
|
484 |
}
|
|
|
485 |
this.fireTableDataChanged();
|
|
|
486 |
}
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
public void updateFields(int idFiche) {
|
|
|
490 |
|
|
|
491 |
// System.err.println("UPDATE FIELDS");
|
|
|
492 |
|
|
|
493 |
for (int i = 0; i < this.vectRowValsToDelete.size(); i++) {
|
|
|
494 |
SQLRowValues rowVals = this.vectRowValsToDelete.get(i);
|
|
|
495 |
|
|
|
496 |
if (rowVals.getID() != SQLRow.NONEXISTANT_ID) {
|
|
|
497 |
|
|
|
498 |
rowVals.put("ARCHIVE", 1);
|
|
|
499 |
try {
|
|
|
500 |
rowVals.update();
|
|
|
501 |
} catch (SQLException e) {
|
|
|
502 |
|
|
|
503 |
e.printStackTrace();
|
|
|
504 |
}
|
|
|
505 |
}
|
|
|
506 |
}
|
|
|
507 |
|
|
|
508 |
this.vectRowValsToDelete = new Vector<SQLRowValues>();
|
|
|
509 |
|
|
|
510 |
for (int i = 0; i < this.vectRubrique.size(); i++) {
|
|
|
511 |
SQLRowValues rowVals = this.vectRubrique.get(i);
|
|
|
512 |
rowVals.put("ID_FICHE_PAYE", idFiche);
|
|
|
513 |
rowVals.put("POSITION", i);
|
|
|
514 |
|
|
|
515 |
try {
|
|
|
516 |
rowVals.commit();
|
|
|
517 |
} catch (SQLException e) {
|
|
|
518 |
|
|
|
519 |
e.printStackTrace();
|
|
|
520 |
}
|
|
|
521 |
}
|
|
|
522 |
}
|
|
|
523 |
|
|
|
524 |
public void showData() {
|
|
|
525 |
|
|
|
526 |
if (this.vectRubrique.size() == 0) {
|
|
|
527 |
System.err.println("Vecteur contains no value.");
|
|
|
528 |
}
|
|
|
529 |
for (int i = 0; i < this.vectRubrique.size(); i++) {
|
|
|
530 |
System.err.println(this.vectRubrique.get(i));
|
|
|
531 |
}
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
public Object getVectorObjectAt(int index) {
|
|
|
535 |
return this.vectRubrique.get(index);
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
private boolean isEltInPeriod(SQLRow rowSource) {
|
|
|
539 |
SQLRow rowFiche = tableFichePaye.getRow(this.idFiche);
|
|
|
540 |
int mois = rowFiche.getInt("ID_MOIS") - 1;
|
|
|
541 |
|
|
|
542 |
Object ob = PeriodeValiditeSQLElement.mapTranslate().get(Integer.valueOf(mois));
|
|
|
543 |
|
|
|
544 |
if (ob == null) {
|
|
|
545 |
return false;
|
|
|
546 |
}
|
|
|
547 |
String moisName = ob.toString();
|
|
|
548 |
|
|
|
549 |
SQLRow rowPeriodeValid = tableValidite.getRow(rowSource.getInt("ID_PERIODE_VALIDITE"));
|
|
|
550 |
|
|
|
551 |
return (rowPeriodeValid.getBoolean(moisName));
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
private boolean isEltImprimable(SQLRow rowSource, SQLRowValues row) {
|
|
|
555 |
|
|
|
556 |
int impression = rowSource.getInt("ID_IMPRESSION_RUBRIQUE");
|
|
|
557 |
|
|
|
558 |
if (impression == 3) {
|
|
|
559 |
return true;
|
|
|
560 |
} else {
|
|
|
561 |
if (impression == 4) {
|
|
|
562 |
return false;
|
|
|
563 |
} else {
|
|
|
564 |
if (impression == 2) {
|
|
|
565 |
|
|
|
566 |
Object montantSalAjOb = row.getObject("MONTANT_SAL_AJ");
|
|
|
567 |
float montantSalAj = (montantSalAjOb == null) ? 0.0F : Float.valueOf(montantSalAjOb.toString()).floatValue();
|
|
|
568 |
|
|
|
569 |
Object montantSalDedOb = row.getObject("MONTANT_SAL_DED");
|
|
|
570 |
float montantSalDed = (montantSalDedOb == null) ? 0.0F : Float.valueOf(montantSalDedOb.toString()).floatValue();
|
|
|
571 |
|
|
|
572 |
Object montantPatOb = row.getObject("MONTANT_PAT");
|
|
|
573 |
float montantPat = (montantPatOb == null) ? 0.0F : Float.valueOf(montantPatOb.toString()).floatValue();
|
|
|
574 |
|
|
|
575 |
if (montantSalAj == 0 && montantSalDed == 0 && montantPat == 0) {
|
|
|
576 |
return false;
|
|
|
577 |
}
|
|
|
578 |
return true;
|
|
|
579 |
|
|
|
580 |
}
|
|
|
581 |
}
|
|
|
582 |
}
|
|
|
583 |
return true;
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
/**
|
|
|
587 |
* charge un élément de la fiche dans rowVals, dont la rubrique source est rowSource et
|
|
|
588 |
* l'élément row si l'élément existe déja
|
|
|
589 |
*
|
|
|
590 |
* @param rowVals
|
|
|
591 |
* @param rowSource
|
|
|
592 |
* @param row
|
|
|
593 |
* @return true si on doit calculer les valeurs
|
|
|
594 |
*/
|
|
|
595 |
private boolean loadElement(SQLRowValues rowVals, SQLRow rowSource, SQLRow row) {
|
|
|
596 |
|
|
|
597 |
if (row != null) {
|
|
|
598 |
rowVals.loadAbsolutelyAll(row);
|
|
|
599 |
}
|
|
|
600 |
|
|
|
601 |
// on vérifie que la rubrique s'applique pour le mois concerné
|
|
|
602 |
// if (!isEltInPeriod(rowSource)) {
|
|
|
603 |
// System.err.println("Not In periode");
|
|
|
604 |
rowVals.put("IN_PERIODE", Boolean.valueOf(isEltInPeriod(rowSource)));
|
|
|
605 |
// }
|
|
|
606 |
|
|
|
607 |
rowVals.put("SOURCE", rowSource.getTable().getName());
|
|
|
608 |
rowVals.put("IDSOURCE", rowSource.getID());
|
|
|
609 |
|
|
|
610 |
Object ob = rowVals.getObject("VALIDE");
|
|
|
611 |
boolean b = (ob == null) ? false : new Boolean(ob.toString()).booleanValue();
|
|
|
612 |
|
|
|
613 |
return b;
|
|
|
614 |
}
|
|
|
615 |
|
|
|
616 |
private void updateValueFiche() {
|
|
|
617 |
|
|
|
618 |
SQLRowValues rowValsFiche = new SQLRowValues(tableFichePaye);
|
|
|
619 |
rowValsFiche.put("SAL_BRUT", Float.valueOf(this.salBrut));
|
|
|
620 |
rowValsFiche.put("NET_IMP", Float.valueOf(this.netImp + this.salBrut));
|
|
|
621 |
rowValsFiche.put("NET_A_PAYER", Float.valueOf(this.netAPayer + this.salBrut));
|
|
|
622 |
rowValsFiche.put("COT_SAL", Float.valueOf(this.cotSal));
|
|
|
623 |
rowValsFiche.put("COT_PAT", Float.valueOf(this.cotPat));
|
|
|
624 |
rowValsFiche.put("CSG", Float.valueOf((this.salBrut + this.csg) * 0.97F));
|
|
|
625 |
|
|
|
626 |
try {
|
|
|
627 |
rowValsFiche.update(this.idFiche);
|
|
|
628 |
} catch (SQLException e) {
|
|
|
629 |
e.printStackTrace();
|
|
|
630 |
}
|
|
|
631 |
}
|
|
|
632 |
|
|
|
633 |
/***********************************************************************************************
|
|
|
634 |
* Charge un élément d'une rubrique de brut
|
|
|
635 |
*
|
|
|
636 |
* @param rowSource row de la rubrique source
|
|
|
637 |
* @param row row de l'élément de la fiche
|
|
|
638 |
**********************************************************************************************/
|
|
|
639 |
private void loadElementBrut(SQLRow rowSource, SQLRow row) {
|
|
|
640 |
|
|
|
641 |
// System.err.println("________________________LOAD ELT BRUT");
|
|
|
642 |
SQLRowValues rowVals = new SQLRowValues(tableFichePayeElt);
|
|
|
643 |
|
|
|
644 |
if (!loadElement(rowVals, rowSource, row)) {
|
|
|
645 |
|
|
|
646 |
// System.err.println("________________________Recalcul des ELT BRUT ");
|
|
|
647 |
Object baseOb = this.javaEdit.checkFormule(rowSource.getString("BASE"), "BASE");
|
|
|
648 |
Object tauxSalOb = this.javaEdit.checkFormule(rowSource.getString("TAUX"), "TAUX");
|
|
|
649 |
rowVals.put("NOM", rowSource.getString("NOM"));
|
|
|
650 |
|
|
|
651 |
rowVals.put("NB_BASE", (baseOb == null) ? null : Float.valueOf(Math.round(Float.valueOf(baseOb.toString()).floatValue() * 100.0F) / 100.0F));
|
|
|
652 |
rowVals.put("TAUX_SAL", (tauxSalOb == null) ? null : Float.valueOf(Float.valueOf(tauxSalOb.toString()).floatValue()));
|
|
|
653 |
}
|
|
|
654 |
|
|
|
655 |
calculBrut(rowSource, rowVals);
|
|
|
656 |
|
|
|
657 |
boolean b = isEltImprimable(rowSource, rowVals);
|
|
|
658 |
// System.err.println("Impression --- > " + b);
|
|
|
659 |
rowVals.put("IMPRESSION", Boolean.valueOf(b));
|
|
|
660 |
|
|
|
661 |
this.vectRubrique.add(rowVals);
|
|
|
662 |
}
|
|
|
663 |
|
|
|
664 |
/**
|
|
|
665 |
* Calcul le montant d'une rubrique de brut et met à jour les variables du salarié
|
|
|
666 |
*
|
|
|
667 |
* @param rowSource
|
|
|
668 |
* @param rowVals
|
|
|
669 |
*/
|
|
|
670 |
private void calculBrut(SQLRow rowSource, SQLRowValues rowVals) {
|
|
|
671 |
|
|
|
672 |
if (((Boolean) rowVals.getObject("IN_PERIODE")).booleanValue()) {
|
|
|
673 |
|
|
|
674 |
Object baseOb = rowVals.getObject("NB_BASE");
|
|
|
675 |
Object tauxSalOb = rowVals.getObject("TAUX_SAL");
|
|
|
676 |
|
|
|
677 |
float base = 0.0F;
|
|
|
678 |
if ((baseOb != null) && (baseOb.toString().trim().length() != 0)) {
|
|
|
679 |
base = Float.valueOf(baseOb.toString()).floatValue();
|
|
|
680 |
}
|
|
|
681 |
|
|
|
682 |
float tauxSal = 0.0F;
|
|
|
683 |
if ((tauxSalOb != null) && (tauxSalOb.toString().trim().length() != 0)) {
|
|
|
684 |
tauxSal = Float.valueOf(tauxSalOb.toString()).floatValue();
|
|
|
685 |
}
|
|
|
686 |
|
|
|
687 |
// Calcul du montant
|
|
|
688 |
String formuleMontant = rowSource.getString("MONTANT");
|
|
|
689 |
|
|
|
690 |
float montant = 0.0F;
|
|
|
691 |
if (formuleMontant.trim().length() == 0) {
|
|
|
692 |
montant = Math.round(base * tauxSal * 100.0F) / 100.0F;
|
|
|
693 |
} else {
|
|
|
694 |
Object montantNet = this.javaEdit.checkFormule(rowSource.getString("MONTANT"), "MONTANT");
|
|
|
695 |
String montantNetS = (montantNet == null) ? "0.0" : montantNet.toString();
|
|
|
696 |
montant = Math.round(Float.valueOf(montantNetS).floatValue() * 100.0F) / 100.0F;
|
|
|
697 |
}
|
|
|
698 |
|
|
|
699 |
// Retenue
|
|
|
700 |
if (rowSource.getInt("ID_TYPE_RUBRIQUE_BRUT") == 3) {
|
|
|
701 |
|
|
|
702 |
rowVals.put("MONTANT_SAL_DED", Float.valueOf(montant));
|
|
|
703 |
this.salBrut -= montant;
|
|
|
704 |
}// Gain
|
|
|
705 |
else {
|
|
|
706 |
|
|
|
707 |
rowVals.put("MONTANT_SAL_AJ", Float.valueOf(montant));
|
|
|
708 |
this.salBrut += montant;
|
|
|
709 |
}
|
|
|
710 |
|
|
|
711 |
// Mis a jour du salaire brut
|
|
|
712 |
updateValueFiche();
|
|
|
713 |
}
|
|
|
714 |
}
|
|
|
715 |
|
|
|
716 |
private void calculNet(SQLRow rowSource, SQLRowValues rowVals) {
|
|
|
717 |
|
|
|
718 |
if (((Boolean) rowVals.getObject("IN_PERIODE")).booleanValue()) {
|
|
|
719 |
|
|
|
720 |
Object baseOb = rowVals.getObject("NB_BASE");
|
|
|
721 |
Object tauxSalOb = rowVals.getObject("TAUX_SAL");
|
|
|
722 |
|
|
|
723 |
float base = 0.0F;
|
|
|
724 |
if ((baseOb != null) && (baseOb.toString().trim().length() != 0)) {
|
|
|
725 |
base = ((Float) baseOb).floatValue();
|
|
|
726 |
}
|
|
|
727 |
|
|
|
728 |
float tauxSal = 0.0F;
|
|
|
729 |
if ((tauxSalOb != null) && (tauxSalOb.toString().trim().length() != 0)) {
|
|
|
730 |
tauxSal = ((Float) tauxSalOb).floatValue();
|
|
|
731 |
}
|
|
|
732 |
|
|
|
733 |
// Calcul du montant
|
|
|
734 |
String formuleMontant = rowSource.getString("MONTANT");
|
|
|
735 |
|
|
|
736 |
float montant = 0.0F;
|
|
|
737 |
if (formuleMontant.trim().length() == 0) {
|
|
|
738 |
montant = Math.round(base * tauxSal * 100.0F) / 100.0F;
|
|
|
739 |
} else {
|
|
|
740 |
Object montantNet = this.javaEdit.checkFormule(rowSource.getString("MONTANT"), "MONTANT");
|
|
|
741 |
if (montantNet != null) {
|
|
|
742 |
montant = Math.round(Float.valueOf(montantNet.toString()).floatValue() * 100.0F) / 100.0F;
|
|
|
743 |
}
|
|
|
744 |
}
|
|
|
745 |
|
|
|
746 |
// Retenue
|
|
|
747 |
if (rowSource.getInt("ID_TYPE_RUBRIQUE_NET") == 3) {
|
|
|
748 |
|
|
|
749 |
rowVals.put("MONTANT_SAL_DED", Float.valueOf(montant));
|
|
|
750 |
|
|
|
751 |
if (rowSource.getBoolean("IMPOSABLE")) {
|
|
|
752 |
this.netAPayer -= montant;
|
|
|
753 |
} else {
|
|
|
754 |
this.netAPayer -= montant;
|
|
|
755 |
this.netImp -= montant;
|
|
|
756 |
}
|
|
|
757 |
|
|
|
758 |
}// Gain
|
|
|
759 |
else {
|
|
|
760 |
|
|
|
761 |
rowVals.put("MONTANT_SAL_AJ", Float.valueOf(montant));
|
|
|
762 |
|
|
|
763 |
if (rowSource.getBoolean("IMPOSABLE")) {
|
|
|
764 |
this.netAPayer += montant;
|
|
|
765 |
|
|
|
766 |
} else {
|
|
|
767 |
this.netAPayer += montant;
|
|
|
768 |
this.netImp += montant;
|
|
|
769 |
}
|
|
|
770 |
}
|
|
|
771 |
|
|
|
772 |
// Mis a jour du salaire net
|
|
|
773 |
updateValueFiche();
|
|
|
774 |
}
|
|
|
775 |
}
|
|
|
776 |
|
|
|
777 |
private void loadElementNet(SQLRow rowSource, SQLRow row) {
|
|
|
778 |
SQLRowValues rowVals = new SQLRowValues(tableFichePayeElt);
|
|
|
779 |
// System.err.println("________________________LOAD ELT NET");
|
|
|
780 |
|
|
|
781 |
if (!loadElement(rowVals, rowSource, row)) {
|
|
|
782 |
|
|
|
783 |
Object baseOb = this.javaEdit.checkFormule(rowSource.getString("BASE"), "BASE");
|
|
|
784 |
Object tauxSalOb = this.javaEdit.checkFormule(rowSource.getString("TAUX"), "TAUX");
|
|
|
785 |
rowVals.put("NOM", rowSource.getString("NOM"));
|
|
|
786 |
rowVals.put("NB_BASE", (baseOb == null) ? null : Float.valueOf(Math.round(Float.valueOf(baseOb.toString()).floatValue() * 100.0F) / 100.0F));
|
|
|
787 |
rowVals.put("TAUX_SAL", (tauxSalOb == null) ? null : Float.valueOf(Float.valueOf(tauxSalOb.toString()).floatValue()));
|
|
|
788 |
}
|
|
|
789 |
|
|
|
790 |
calculNet(rowSource, rowVals);
|
|
|
791 |
|
|
|
792 |
boolean b = isEltImprimable(rowSource, rowVals);
|
|
|
793 |
// System.err.println("Impression --- > " + b);
|
|
|
794 |
rowVals.put("IMPRESSION", Boolean.valueOf(b));
|
|
|
795 |
|
|
|
796 |
this.vectRubrique.add(rowVals);
|
|
|
797 |
}
|
|
|
798 |
|
|
|
799 |
private void calculCotisation(SQLRow rowSource, SQLRowValues rowVals) {
|
|
|
800 |
|
|
|
801 |
if (((Boolean) rowVals.getObject("IN_PERIODE")).booleanValue()) {
|
|
|
802 |
|
|
|
803 |
Object baseOb = rowVals.getObject("NB_BASE");
|
|
|
804 |
Object tauxSalOb = rowVals.getObject("TAUX_SAL");
|
|
|
805 |
Object tauxPatOb = rowVals.getObject("TAUX_PAT");
|
|
|
806 |
|
|
|
807 |
float base = 0.0F;
|
|
|
808 |
if ((baseOb != null) && (baseOb.toString().trim().length() != 0)) {
|
|
|
809 |
base = ((Number) baseOb).floatValue();
|
|
|
810 |
}
|
|
|
811 |
|
|
|
812 |
float tauxSal = 0.0F;
|
|
|
813 |
if ((tauxSalOb != null) && (tauxSalOb.toString().trim().length() != 0)) {
|
|
|
814 |
tauxSal = ((Number) tauxSalOb).floatValue() / 100.0F;
|
|
|
815 |
}
|
|
|
816 |
|
|
|
817 |
float tauxPat = 0.0F;
|
|
|
818 |
if ((tauxPatOb != null) && (tauxPatOb.toString().trim().length() != 0)) {
|
|
|
819 |
tauxPat = ((Number) tauxPatOb).floatValue() / 100.0F;
|
|
|
820 |
}
|
|
|
821 |
|
|
|
822 |
// Calcul du montant
|
|
|
823 |
float montantSal = 0.0F;
|
|
|
824 |
montantSal = Math.round(base * tauxSal * 100.0F) / 100.0F;
|
|
|
825 |
float montantPat = 0.0F;
|
|
|
826 |
montantPat = Math.round(base * tauxPat * 100.0F) / 100.0F;
|
|
|
827 |
|
|
|
828 |
rowVals.put("MONTANT_SAL_DED", new Float(montantSal));
|
|
|
829 |
rowVals.put("MONTANT_PAT", new Float(montantPat));
|
|
|
830 |
|
|
|
831 |
if (rowSource.getBoolean("IMPOSABLE")) {
|
|
|
832 |
this.netAPayer -= montantSal;
|
|
|
833 |
|
|
|
834 |
} else {
|
|
|
835 |
this.netAPayer -= montantSal;
|
|
|
836 |
this.netImp -= montantSal;
|
|
|
837 |
}
|
|
|
838 |
|
|
|
839 |
if (rowSource.getBoolean("PART_CSG")) {
|
|
|
840 |
this.csg += montantPat;
|
|
|
841 |
}
|
|
|
842 |
|
|
|
843 |
this.cotSal += montantSal;
|
|
|
844 |
this.cotPat += montantPat;
|
|
|
845 |
|
|
|
846 |
// Mis a jour des cotisations
|
|
|
847 |
updateValueFiche();
|
|
|
848 |
}
|
|
|
849 |
}
|
|
|
850 |
|
|
|
851 |
private void loadElementCotisation(SQLRow rowSource, SQLRow row) {
|
|
|
852 |
SQLRowValues rowVals = new SQLRowValues(tableFichePayeElt);
|
|
|
853 |
// System.err.println("________________________LOAD ELT COTISATION");
|
|
|
854 |
|
|
|
855 |
if (!loadElement(rowVals, rowSource, row)) {
|
|
|
856 |
|
|
|
857 |
// On calcule les valeurs
|
|
|
858 |
Object baseOb = this.javaEdit.checkFormule(rowSource.getString("BASE"), "BASE");
|
|
|
859 |
Object tauxSalOb = this.javaEdit.checkFormule(rowSource.getString("TX_SAL"), "TX_SAL");
|
|
|
860 |
Object tauxPatOb = this.javaEdit.checkFormule(rowSource.getString("TX_PAT"), "TX_PAT");
|
|
|
861 |
rowVals.put("NOM", rowSource.getString("NOM"));
|
|
|
862 |
rowVals.put("NB_BASE", (baseOb == null) ? null : Float.valueOf(Math.round(Float.valueOf(baseOb.toString()).floatValue() * 100.0F) / 100.0F));
|
|
|
863 |
rowVals.put("TAUX_SAL", (tauxSalOb == null) ? null : Float.valueOf(Float.valueOf(tauxSalOb.toString()).floatValue()));
|
|
|
864 |
rowVals.put("TAUX_PAT", (tauxPatOb == null) ? null : Float.valueOf(Float.valueOf(tauxPatOb.toString()).floatValue()));
|
|
|
865 |
}
|
|
|
866 |
|
|
|
867 |
calculCotisation(rowSource, rowVals);
|
|
|
868 |
|
|
|
869 |
boolean b = isEltImprimable(rowSource, rowVals);
|
|
|
870 |
// System.err.println("Impression --- > " + b);
|
|
|
871 |
rowVals.put("IMPRESSION", Boolean.valueOf(b));
|
|
|
872 |
|
|
|
873 |
this.vectRubrique.add(rowVals);
|
|
|
874 |
}
|
|
|
875 |
|
|
|
876 |
public void loadElementComm(SQLRow rowSource, SQLRow row) {
|
|
|
877 |
SQLRowValues rowVals = new SQLRowValues(tableFichePayeElt);
|
|
|
878 |
// System.err.println("________________________LOAD ELT COMM");
|
|
|
879 |
|
|
|
880 |
if (loadElement(rowVals, rowSource, row)) {
|
|
|
881 |
this.vectRubrique.add(rowVals);
|
|
|
882 |
return;
|
|
|
883 |
}
|
|
|
884 |
|
|
|
885 |
Object baseOb = this.javaEdit.checkFormule(rowSource.getString("NB_BASE"), "BASE");
|
|
|
886 |
Object tauxSalOb = this.javaEdit.checkFormule(rowSource.getString("TAUX_SAL"), "SAL");
|
|
|
887 |
Object tauxPatOb = this.javaEdit.checkFormule(rowSource.getString("TAUX_PAT"), "PAT");
|
|
|
888 |
Object montantPatOb = this.javaEdit.checkFormule(rowSource.getString("MONTANT_PAT"), "MONTANT");
|
|
|
889 |
Object montantAdOb = this.javaEdit.checkFormule(rowSource.getString("MONTANT_SAL_AJ"), "MONTANT");
|
|
|
890 |
Object montantDedOb = this.javaEdit.checkFormule(rowSource.getString("MONTANT_SAL_DED"), "MONTANT");
|
|
|
891 |
rowVals.put("NOM", rowSource.getBoolean("NOM_VISIBLE") ? rowSource.getString("NOM") : "");
|
|
|
892 |
rowVals.put("NB_BASE", baseOb);
|
|
|
893 |
rowVals.put("TAUX_SAL", tauxSalOb);
|
|
|
894 |
rowVals.put("TAUX_PAT", tauxPatOb);
|
|
|
895 |
rowVals.put("MONTANT_PAT", montantPatOb);
|
|
|
896 |
rowVals.put("MONTANT_SAL_AJ", montantAdOb);
|
|
|
897 |
rowVals.put("MONTANT_SAL_DED", montantDedOb);
|
|
|
898 |
|
|
|
899 |
boolean b = isEltImprimable(rowSource, rowVals);
|
|
|
900 |
// System.err.println("Impression --- > " + b);
|
|
|
901 |
rowVals.put("IMPRESSION", Boolean.valueOf(b));
|
|
|
902 |
|
|
|
903 |
this.vectRubrique.add(rowVals);
|
|
|
904 |
}
|
|
|
905 |
|
|
|
906 |
private void calculValue() {
|
|
|
907 |
|
|
|
908 |
System.err.println("Start calculValue At " + new Date());
|
|
|
909 |
|
|
|
910 |
resetValueFiche();
|
|
|
911 |
|
|
|
912 |
/*
|
|
|
913 |
* this.threadUpdate = new Thread("Update Fiche Paye") { public void run() {
|
|
|
914 |
*/
|
|
|
915 |
Vector<SQLRowValues> vectTmp = new Vector<SQLRowValues>(this.vectRubrique);
|
|
|
916 |
|
|
|
917 |
this.vectRubrique = new Vector<SQLRowValues>();
|
|
|
918 |
for (int i = 0; i < vectTmp.size(); i++) {
|
|
|
919 |
|
|
|
920 |
SQLRowValues rowVals = vectTmp.get(i);
|
|
|
921 |
String source = rowVals.getString("SOURCE");
|
|
|
922 |
int idSource = rowVals.getInt("IDSOURCE");
|
|
|
923 |
SQLRow row = tableFichePayeElt.getRow(rowVals.getID());
|
|
|
924 |
|
|
|
925 |
if (source.trim().length() != 0) {
|
|
|
926 |
|
|
|
927 |
// System.err.println("Source != null");
|
|
|
928 |
|
|
|
929 |
if (this.mapTableSource.get(source) != null) {
|
|
|
930 |
SQLRow rowSource = this.mapTableSource.get(source).getRow(idSource);
|
|
|
931 |
|
|
|
932 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
933 |
loadElementBrut(rowSource, row);
|
|
|
934 |
}
|
|
|
935 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_COTISATION")) {
|
|
|
936 |
loadElementCotisation(rowSource, row);
|
|
|
937 |
}
|
|
|
938 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
939 |
loadElementNet(rowSource, row);
|
|
|
940 |
}
|
|
|
941 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
942 |
loadElementComm(rowSource, row);
|
|
|
943 |
}
|
|
|
944 |
} else {
|
|
|
945 |
System.err.println("Table " + source + " non référencée");
|
|
|
946 |
}
|
|
|
947 |
}
|
|
|
948 |
}
|
|
|
949 |
System.err.println(this.vectRubrique.size() + " elements ADDed ");
|
|
|
950 |
|
|
|
951 |
fireTableDataChanged();
|
|
|
952 |
/*
|
|
|
953 |
* } }; this.threadUpdate.start();
|
|
|
954 |
*/
|
|
|
955 |
|
|
|
956 |
System.err.println("End calculValue At " + new Date());
|
|
|
957 |
}
|
|
|
958 |
|
|
|
959 |
public void validElt() {
|
|
|
960 |
|
|
|
961 |
System.err.println("Validation des éléments de la fiche.");
|
|
|
962 |
for (int i = 0; i < this.vectRubrique.size(); i++) {
|
|
|
963 |
SQLRowValues rowVals = this.vectRubrique.get(i);
|
|
|
964 |
rowVals.put("VALIDE", Boolean.valueOf(true));
|
|
|
965 |
|
|
|
966 |
try {
|
|
|
967 |
rowVals.commit();
|
|
|
968 |
} catch (SQLException e) {
|
|
|
969 |
e.printStackTrace();
|
|
|
970 |
}
|
|
|
971 |
}
|
|
|
972 |
System.err.println("Validation terminée.");
|
|
|
973 |
}
|
|
|
974 |
}
|