18 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
185 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
18 |
ilm |
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;
|
73 |
ilm |
20 |
import org.openconcerto.erp.preferences.PayeGlobalPreferencePanel;
|
18 |
ilm |
21 |
import org.openconcerto.sql.Configuration;
|
144 |
ilm |
22 |
import org.openconcerto.sql.model.DBRoot;
|
|
|
23 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
18 |
ilm |
24 |
import org.openconcerto.sql.model.SQLBase;
|
|
|
25 |
import org.openconcerto.sql.model.SQLRow;
|
144 |
ilm |
26 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
18 |
ilm |
27 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
28 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
29 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
30 |
import org.openconcerto.sql.model.Where;
|
73 |
ilm |
31 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
144 |
ilm |
32 |
import org.openconcerto.utils.DecimalUtils;
|
18 |
ilm |
33 |
|
132 |
ilm |
34 |
import java.math.BigDecimal;
|
|
|
35 |
import java.math.RoundingMode;
|
18 |
ilm |
36 |
import java.sql.SQLException;
|
|
|
37 |
import java.util.Date;
|
|
|
38 |
import java.util.HashMap;
|
|
|
39 |
import java.util.List;
|
|
|
40 |
import java.util.Map;
|
|
|
41 |
import java.util.Vector;
|
|
|
42 |
|
132 |
ilm |
43 |
import javax.swing.JOptionPane;
|
|
|
44 |
import javax.swing.SwingUtilities;
|
18 |
ilm |
45 |
import javax.swing.table.AbstractTableModel;
|
|
|
46 |
|
|
|
47 |
import org.apache.commons.dbutils.handlers.ArrayListHandler;
|
|
|
48 |
|
|
|
49 |
// TODO gestion de la place des rubriques dans l'ordre brut - cot - net et comm everywhere
|
|
|
50 |
// FIXME Thread pour le calcul
|
|
|
51 |
public class FichePayeModel extends AbstractTableModel {
|
|
|
52 |
|
|
|
53 |
// Rubrique
|
|
|
54 |
private Vector<SQLRowValues> vectRubrique;
|
|
|
55 |
private Vector<SQLRowValues> vectRowValsToDelete;
|
|
|
56 |
|
|
|
57 |
// table des rubriques
|
|
|
58 |
private final Map<String, SQLTable> mapTableSource = new HashMap<String, SQLTable>();
|
|
|
59 |
|
|
|
60 |
// Id de la fiche de paye concernee
|
|
|
61 |
private int idFiche;
|
|
|
62 |
|
|
|
63 |
private String[] title;
|
|
|
64 |
|
|
|
65 |
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
66 |
private final static SQLTable tableProfilElt = Configuration.getInstance().getBase().getTable("PROFIL_PAYE_ELEMENT");
|
|
|
67 |
private final static SQLTable tableFichePayeElt = base.getTable("FICHE_PAYE_ELEMENT");
|
|
|
68 |
private final static SQLTable tableFichePaye = base.getTable("FICHE_PAYE");
|
144 |
ilm |
69 |
// private final static SQLTable tableValidite =
|
|
|
70 |
// Configuration.getInstance().getBase().getTable("PERIODE_VALIDITE");
|
18 |
ilm |
71 |
|
|
|
72 |
private SQLJavaEditor javaEdit = new SQLJavaEditor(VariablePayeSQLElement.getMapTree());
|
|
|
73 |
|
|
|
74 |
// liste des variable de paye à calculer
|
177 |
ilm |
75 |
private BigDecimal salBrut, salBrutCSG, salBrutCSGReduite, salBrutBase, salBrutCotis, salBrutTaxable, cotPat, cotSal, taxCmPat, taxCmSal, netImp, pas, netAPayer, csg, csgSansAbattement, cice,
|
|
|
76 |
allegmentCotisation, avantage, reduction;
|
132 |
ilm |
77 |
|
18 |
ilm |
78 |
private Map<Integer, String> mapField;
|
|
|
79 |
|
132 |
ilm |
80 |
private final BigDecimal tauxCSG;
|
73 |
ilm |
81 |
|
144 |
ilm |
82 |
private boolean isValidated = false;
|
|
|
83 |
private int mois;
|
|
|
84 |
|
18 |
ilm |
85 |
public FichePayeModel(int idFiche) {
|
|
|
86 |
System.err.println("NEW FICHE PAYE MODEL");
|
144 |
ilm |
87 |
this.javaEdit.setModel(this);
|
18 |
ilm |
88 |
this.idFiche = idFiche;
|
|
|
89 |
this.vectRubrique = new Vector<SQLRowValues>();
|
|
|
90 |
this.vectRowValsToDelete = new Vector<SQLRowValues>();
|
|
|
91 |
|
144 |
ilm |
92 |
final SQLRow rowFiche = tableFichePaye.getRow(idFiche);
|
|
|
93 |
this.isValidated = rowFiche.getBoolean("VALIDE");
|
|
|
94 |
this.mois = rowFiche.getInt("ID_MOIS") - 1;
|
|
|
95 |
|
18 |
ilm |
96 |
// Titres des colonnes
|
|
|
97 |
this.title = new String[9];
|
|
|
98 |
this.title[0] = "Libellé";
|
|
|
99 |
this.title[1] = "Base";
|
|
|
100 |
this.title[2] = "Taux sal.";
|
|
|
101 |
this.title[3] = "Montant sal. à ajouter";
|
|
|
102 |
this.title[4] = "Montant sal. à déduire";
|
|
|
103 |
this.title[5] = "Taux pat.";
|
|
|
104 |
this.title[6] = "Montant pat.";
|
|
|
105 |
this.title[7] = "Impression";
|
|
|
106 |
this.title[8] = "Dans la Période";
|
|
|
107 |
|
|
|
108 |
SQLTable tableNet = Configuration.getInstance().getBase().getTable("RUBRIQUE_NET");
|
|
|
109 |
SQLTable tableBrut = Configuration.getInstance().getBase().getTable("RUBRIQUE_BRUT");
|
|
|
110 |
SQLTable tableCotis = Configuration.getInstance().getBase().getTable("RUBRIQUE_COTISATION");
|
|
|
111 |
SQLTable tableComm = Configuration.getInstance().getBase().getTable("RUBRIQUE_COMM");
|
|
|
112 |
this.mapTableSource.put(tableNet.getName(), tableNet);
|
|
|
113 |
this.mapTableSource.put(tableBrut.getName(), tableBrut);
|
|
|
114 |
this.mapTableSource.put(tableCotis.getName(), tableCotis);
|
|
|
115 |
this.mapTableSource.put(tableComm.getName(), tableComm);
|
|
|
116 |
|
|
|
117 |
this.mapField = new HashMap<Integer, String>();
|
|
|
118 |
this.mapField.put(new Integer(0), "NOM");
|
|
|
119 |
this.mapField.put(new Integer(1), "NB_BASE");
|
|
|
120 |
this.mapField.put(new Integer(2), "TAUX_SAL");
|
|
|
121 |
this.mapField.put(new Integer(3), "MONTANT_SAL_AJ");
|
|
|
122 |
this.mapField.put(new Integer(4), "MONTANT_SAL_DED");
|
|
|
123 |
this.mapField.put(new Integer(5), "TAUX_PAT");
|
|
|
124 |
this.mapField.put(new Integer(6), "MONTANT_PAT");
|
|
|
125 |
this.mapField.put(new Integer(7), "IMPRESSION");
|
|
|
126 |
this.mapField.put(new Integer(8), "IN_PERIODE");
|
|
|
127 |
|
73 |
ilm |
128 |
SQLPreferences prefs = new SQLPreferences(tableFichePaye.getTable().getDBRoot());
|
132 |
ilm |
129 |
this.tauxCSG = new BigDecimal(prefs.getDouble(PayeGlobalPreferencePanel.ASSIETTE_CSG, 0.9825D));
|
151 |
ilm |
130 |
final SQLTable tableValidite = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("PERIODE_VALIDITE");
|
|
|
131 |
SQLBackgroundTableCache.getInstance().getCacheForTable(tableValidite).reloadFromDbIfNeeded();
|
73 |
ilm |
132 |
|
18 |
ilm |
133 |
// loadElement();
|
|
|
134 |
// methodeTmp();
|
|
|
135 |
}
|
|
|
136 |
|
144 |
ilm |
137 |
public int getMois() {
|
|
|
138 |
return mois;
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
public BigDecimal getCotPat() {
|
|
|
142 |
return cotPat;
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
public BigDecimal getCotSal() {
|
|
|
146 |
return cotSal;
|
|
|
147 |
}
|
|
|
148 |
|
177 |
ilm |
149 |
public BigDecimal getCsgReduite() {
|
|
|
150 |
return this.salBrutCSGReduite.multiply(this.tauxCSG);
|
|
|
151 |
}
|
|
|
152 |
|
144 |
ilm |
153 |
public BigDecimal getCsgTotal() {
|
177 |
ilm |
154 |
return this.salBrutCSG.add(this.csg).multiply(this.tauxCSG).add(this.csgSansAbattement);
|
144 |
ilm |
155 |
}
|
|
|
156 |
|
|
|
157 |
public BigDecimal getCsgSansAbattement() {
|
|
|
158 |
return csgSansAbattement;
|
|
|
159 |
}
|
|
|
160 |
|
156 |
ilm |
161 |
public BigDecimal getPas() {
|
|
|
162 |
return pas;
|
|
|
163 |
}
|
|
|
164 |
|
177 |
ilm |
165 |
public BigDecimal getSalBrutCSG() {
|
|
|
166 |
return salBrutCSG;
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
public BigDecimal getSalBrutCSGReduite() {
|
|
|
170 |
return salBrutCSGReduite;
|
|
|
171 |
}
|
|
|
172 |
|
144 |
ilm |
173 |
public BigDecimal getNetAPayerTotal() {
|
|
|
174 |
return netAPayer.add(this.salBrut);
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
public BigDecimal getNetImpTotal() {
|
156 |
ilm |
178 |
return netImp.add(this.salBrutTaxable);
|
144 |
ilm |
179 |
}
|
|
|
180 |
|
156 |
ilm |
181 |
public BigDecimal getNetAvantPas() {
|
|
|
182 |
return getNetAPayerTotal().subtract(this.pas);
|
|
|
183 |
}
|
|
|
184 |
|
144 |
ilm |
185 |
public BigDecimal getSalBrut() {
|
|
|
186 |
return salBrut;
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
public BigDecimal getSalBrutBase() {
|
|
|
190 |
return salBrutBase;
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
public BigDecimal getSalBrutCotis() {
|
|
|
194 |
return salBrutCotis;
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
public BigDecimal getSalBrutTaxable() {
|
|
|
198 |
return salBrutTaxable;
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
public BigDecimal getTaxCmPat() {
|
|
|
202 |
return taxCmPat;
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
public BigDecimal getTaxCmSal() {
|
|
|
206 |
return taxCmSal;
|
|
|
207 |
}
|
|
|
208 |
|
18 |
ilm |
209 |
private void resetValueFiche() {
|
|
|
210 |
|
|
|
211 |
/*
|
|
|
212 |
* if (this.threadUpdate != null && this.threadUpdate.isAlive()) { this.threadUpdate.stop();
|
|
|
213 |
* }
|
144 |
ilm |
214 |
*
|
18 |
ilm |
215 |
*/
|
144 |
ilm |
216 |
this.cice = null;
|
|
|
217 |
this.allegmentCotisation = BigDecimal.ZERO;
|
151 |
ilm |
218 |
this.reduction = BigDecimal.ZERO;
|
144 |
ilm |
219 |
this.avantage = BigDecimal.ZERO;
|
132 |
ilm |
220 |
this.salBrut = BigDecimal.ZERO;
|
177 |
ilm |
221 |
this.salBrutCSG = BigDecimal.ZERO;
|
|
|
222 |
this.salBrutCSGReduite = BigDecimal.ZERO;
|
144 |
ilm |
223 |
this.salBrutCotis = BigDecimal.ZERO;
|
|
|
224 |
this.salBrutBase = BigDecimal.ZERO;
|
|
|
225 |
this.salBrutTaxable = BigDecimal.ZERO;
|
132 |
ilm |
226 |
this.cotPat = BigDecimal.ZERO;
|
|
|
227 |
this.cotSal = BigDecimal.ZERO;
|
144 |
ilm |
228 |
this.taxCmPat = BigDecimal.ZERO;
|
|
|
229 |
this.taxCmSal = BigDecimal.ZERO;
|
132 |
ilm |
230 |
this.netAPayer = BigDecimal.ZERO;
|
156 |
ilm |
231 |
this.pas = BigDecimal.ZERO;
|
132 |
ilm |
232 |
this.netImp = BigDecimal.ZERO;
|
|
|
233 |
this.csg = BigDecimal.ZERO;
|
|
|
234 |
this.csgSansAbattement = BigDecimal.ZERO;
|
18 |
ilm |
235 |
}
|
|
|
236 |
|
|
|
237 |
public void loadAllElements() {
|
|
|
238 |
|
|
|
239 |
System.err.println("Start At " + new Date());
|
|
|
240 |
if (this.idFiche <= 1) {
|
|
|
241 |
System.err.println("Aucune fiche associée");
|
|
|
242 |
return;
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
// RAZ
|
|
|
246 |
resetValueFiche();
|
|
|
247 |
|
|
|
248 |
/*
|
|
|
249 |
* this.threadUpdate = new Thread("Update Fiche Paye") { public void run() {
|
|
|
250 |
*/
|
|
|
251 |
this.vectRubrique = new Vector<SQLRowValues>();
|
|
|
252 |
|
|
|
253 |
SQLRow rowFiche = tableFichePaye.getRow(this.idFiche);
|
|
|
254 |
|
|
|
255 |
this.javaEdit.setSalarieID(rowFiche.getInt("ID_SALARIE"));
|
144 |
ilm |
256 |
this.javaEdit.setDateDebut(rowFiche.getDate("DU"));
|
18 |
ilm |
257 |
// éléments de la fiche de paye
|
73 |
ilm |
258 |
SQLSelect selAllIDFicheElt = new SQLSelect();
|
18 |
ilm |
259 |
|
144 |
ilm |
260 |
selAllIDFicheElt.addSelectStar(tableFichePayeElt);
|
|
|
261 |
// selAllIDFicheElt.addSelect(tableFichePayeElt.getField("POSITION"));
|
18 |
ilm |
262 |
selAllIDFicheElt.setWhere(new Where(tableFichePayeElt.getField("ID_FICHE_PAYE"), "=", this.idFiche));
|
|
|
263 |
|
|
|
264 |
selAllIDFicheElt.setDistinct(true);
|
|
|
265 |
|
|
|
266 |
selAllIDFicheElt.addRawOrder("\"FICHE_PAYE_ELEMENT\".\"POSITION\"");
|
|
|
267 |
String reqAllIDFichelElt = selAllIDFicheElt.asString();
|
|
|
268 |
|
|
|
269 |
System.err.println("Request " + reqAllIDFichelElt);
|
|
|
270 |
|
144 |
ilm |
271 |
// Object[] objIDFicheElt = ((List) base.getDataSource().execute(reqAllIDFichelElt, new
|
|
|
272 |
// ArrayListHandler())).toArray();
|
|
|
273 |
List<SQLRow> result = SQLRowListRSH.execute(selAllIDFicheElt);
|
18 |
ilm |
274 |
|
144 |
ilm |
275 |
// System.err.println(objIDFicheElt.length + " elements to load");
|
|
|
276 |
System.err.println(result.size() + " elements to load");
|
18 |
ilm |
277 |
|
144 |
ilm |
278 |
// for (int i = 0; i < objIDFicheElt.length; i++) {
|
|
|
279 |
for (SQLRow row : result) {
|
18 |
ilm |
280 |
|
144 |
ilm |
281 |
// SQLRow row = tableFichePayeElt.getRow(Integer.parseInt(((Object[])
|
|
|
282 |
// objIDFicheElt[i])[0].toString()));
|
|
|
283 |
|
18 |
ilm |
284 |
String source = row.getString("SOURCE");
|
|
|
285 |
int idSource = row.getInt("IDSOURCE");
|
|
|
286 |
|
|
|
287 |
if (source.trim().length() != 0) {
|
|
|
288 |
|
|
|
289 |
// System.err.println("Source != null");
|
|
|
290 |
|
|
|
291 |
if (this.mapTableSource.get(source) != null) {
|
|
|
292 |
SQLRow rowSource = this.mapTableSource.get(source).getRow(idSource);
|
|
|
293 |
|
|
|
294 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
295 |
loadElementBrut(rowSource, row);
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_COTISATION")) {
|
|
|
299 |
loadElementCotisation(rowSource, row);
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
303 |
loadElementNet(rowSource, row);
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
307 |
loadElementComm(rowSource, row);
|
|
|
308 |
}
|
|
|
309 |
|
|
|
310 |
} else {
|
|
|
311 |
System.err.println("Table " + source + " non référencée");
|
|
|
312 |
}
|
|
|
313 |
}
|
|
|
314 |
}
|
|
|
315 |
System.err.println(this.vectRubrique.size() + " elements ADDed ");
|
144 |
ilm |
316 |
updateValueFiche();
|
18 |
ilm |
317 |
fireTableDataChanged();
|
|
|
318 |
/*
|
|
|
319 |
* } }; this.threadUpdate.start();
|
|
|
320 |
*/
|
|
|
321 |
|
|
|
322 |
System.err.println("End At " + new Date());
|
|
|
323 |
}
|
|
|
324 |
|
|
|
325 |
public String getColumnName(int column) {
|
|
|
326 |
|
|
|
327 |
return this.title[column];
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
public int getRowCount() {
|
|
|
331 |
|
|
|
332 |
return this.vectRubrique.size();
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
public int getColumnCount() {
|
|
|
336 |
|
|
|
337 |
return this.title.length;
|
|
|
338 |
}
|
|
|
339 |
|
|
|
340 |
public Object getValueAt(int rowIndex, int columnIndex) {
|
|
|
341 |
|
|
|
342 |
SQLRowValues row = this.vectRubrique.get(rowIndex);
|
|
|
343 |
Object o = null;
|
|
|
344 |
|
|
|
345 |
if (row != null) {
|
|
|
346 |
o = row.getObject(this.mapField.get(new Integer(columnIndex)).toString());
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
return o;
|
|
|
350 |
}
|
|
|
351 |
|
|
|
352 |
public Class<?> getColumnClass(int columnIndex) {
|
|
|
353 |
Class<?> cl = tableFichePayeElt.getField(this.mapField.get(new Integer(columnIndex))).getType().getJavaType();
|
|
|
354 |
return cl;
|
|
|
355 |
}
|
|
|
356 |
|
|
|
357 |
/*
|
|
|
358 |
* public boolean isCellEditable(int rowIndex, int columnIndex) {
|
|
|
359 |
*
|
|
|
360 |
* if (columnIndex == 0) { return true; }
|
|
|
361 |
*
|
|
|
362 |
* SQLRowValues rowVals = (SQLRowValues) this.vectRubrique.get(rowIndex);
|
|
|
363 |
*
|
|
|
364 |
* Object ob = rowVals.getObject("SOURCE"); String source = (ob == null) ? "" : ob.toString();
|
|
|
365 |
*
|
|
|
366 |
* if ((source.trim().length() != 0) && (!source.equalsIgnoreCase("RUBRIQUE_COTISATION"))) {
|
|
|
367 |
*
|
|
|
368 |
* if (!source.equalsIgnoreCase("RUBRIQUE_COMM")) { if (columnIndex > 5) { return false; } else
|
|
|
369 |
* {
|
|
|
370 |
*
|
|
|
371 |
* if (columnIndex == 1 || columnIndex == 2) { return true; }
|
|
|
372 |
*
|
|
|
373 |
* if (source.equalsIgnoreCase("RUBRIQUE_COT") && (columnIndex == 5)) {
|
|
|
374 |
*
|
|
|
375 |
* return true; } } } } return false; }
|
|
|
376 |
*
|
|
|
377 |
* public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
|
|
378 |
*
|
|
|
379 |
* System.err.println("_______***$$$$ " + this.mapField.get(new
|
|
|
380 |
* Integer(columnIndex)).toString()); SQLRowValues rowVals = (SQLRowValues)
|
|
|
381 |
* this.vectRubrique.get(rowIndex); rowVals.put(this.mapField.get(new
|
|
|
382 |
* Integer(columnIndex)).toString(), aValue); rowVals.put("VALIDE", Boolean.TRUE);
|
|
|
383 |
*
|
|
|
384 |
* try { rowVals.update(); } catch (SQLException e) { e.printStackTrace(); }
|
|
|
385 |
*
|
|
|
386 |
* calculValue(); }
|
|
|
387 |
*/
|
|
|
388 |
public boolean containValueAt(int rowIndex, int columnIndex) {
|
|
|
389 |
|
|
|
390 |
if (columnIndex == 0) {
|
|
|
391 |
return true;
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
SQLRowValues rowVals = this.vectRubrique.get(rowIndex);
|
|
|
395 |
|
|
|
396 |
Object ob = rowVals.getObject("SOURCE");
|
|
|
397 |
String source = (ob == null) ? "" : ob.toString();
|
|
|
398 |
|
|
|
399 |
Object obId = rowVals.getObject("IDSOURCE");
|
|
|
400 |
int idSource = (obId == null) ? 1 : rowVals.getInt("IDSOURCE");
|
|
|
401 |
|
|
|
402 |
if ((source.trim().length() != 0) && (!source.equalsIgnoreCase("RUBRIQUE_COTISATION"))) {
|
|
|
403 |
/*
|
|
|
404 |
* if (source.equalsIgnoreCase("RUBRIQUE_COMM")) { return true; } else {
|
|
|
405 |
*/
|
|
|
406 |
|
|
|
407 |
if (columnIndex > 4) {
|
|
|
408 |
return false;
|
|
|
409 |
} else {
|
|
|
410 |
SQLRow row = this.mapTableSource.get(source).getRow(idSource);
|
|
|
411 |
if (source.equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
412 |
if ((row.getInt("ID_TYPE_RUBRIQUE_BRUT") == 2) && (columnIndex == 4)) {
|
|
|
413 |
return false;
|
|
|
414 |
}
|
|
|
415 |
if ((row.getInt("ID_TYPE_RUBRIQUE_BRUT") == 3) && (columnIndex == 3)) {
|
|
|
416 |
return false;
|
|
|
417 |
}
|
|
|
418 |
} else {
|
|
|
419 |
if (source.equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
420 |
if ((row.getInt("ID_TYPE_RUBRIQUE_NET") == 2) && (columnIndex == 4)) {
|
|
|
421 |
return false;
|
|
|
422 |
}
|
|
|
423 |
if ((row.getInt("ID_TYPE_RUBRIQUE_NET") == 3) && (columnIndex == 3)) {
|
|
|
424 |
return false;
|
|
|
425 |
}
|
|
|
426 |
} else {
|
|
|
427 |
return false;
|
|
|
428 |
}
|
|
|
429 |
}
|
|
|
430 |
// }
|
|
|
431 |
}
|
|
|
432 |
} else {
|
|
|
433 |
if (columnIndex == 3) {
|
|
|
434 |
return false;
|
|
|
435 |
}
|
|
|
436 |
}
|
|
|
437 |
|
|
|
438 |
return true;
|
|
|
439 |
}
|
|
|
440 |
|
|
|
441 |
public void loadFromProfil(final int idProfil) {
|
|
|
442 |
|
|
|
443 |
System.err.println("Load from profil");
|
|
|
444 |
|
|
|
445 |
resetValueFiche();
|
|
|
446 |
|
|
|
447 |
/*
|
|
|
448 |
* this.threadUpdate = new Thread("Update Fiche Paye") { public void run() {
|
|
|
449 |
*/
|
|
|
450 |
// On supprime les anciennes lignes de la fiche
|
|
|
451 |
while (this.vectRubrique.size() > 0) {
|
|
|
452 |
|
|
|
453 |
this.vectRowValsToDelete.add(this.vectRubrique.remove(0));
|
|
|
454 |
}
|
|
|
455 |
|
|
|
456 |
// this.vectRubrique = new Vector();
|
|
|
457 |
|
|
|
458 |
// Listes des rubriques du profil
|
73 |
ilm |
459 |
SQLSelect selAllIDProfilElt = new SQLSelect();
|
18 |
ilm |
460 |
|
|
|
461 |
selAllIDProfilElt.addSelect(tableProfilElt.getField("ID"));
|
|
|
462 |
selAllIDProfilElt.addSelect(tableProfilElt.getField("POSITION"));
|
|
|
463 |
selAllIDProfilElt.setWhere(new Where(tableProfilElt.getField("ID_PROFIL_PAYE"), "=", idProfil));
|
|
|
464 |
selAllIDProfilElt.addRawOrder("\"PROFIL_PAYE_ELEMENT\".\"POSITION\"");
|
|
|
465 |
|
|
|
466 |
String reqAllIDProfilElt = selAllIDProfilElt.asString();
|
|
|
467 |
|
|
|
468 |
Object[] objIDProfilElt = ((List) Configuration.getInstance().getBase().getDataSource().execute(reqAllIDProfilElt, new ArrayListHandler())).toArray();
|
|
|
469 |
|
|
|
470 |
for (int i = 0; i < objIDProfilElt.length; i++) {
|
|
|
471 |
SQLRow rowTmp = tableProfilElt.getRow(Integer.parseInt(((Object[]) objIDProfilElt[i])[0].toString()));
|
|
|
472 |
|
|
|
473 |
String source = rowTmp.getString("SOURCE");
|
|
|
474 |
int idSource = rowTmp.getInt("IDSOURCE");
|
|
|
475 |
|
|
|
476 |
if (this.mapTableSource.get(source) != null) {
|
|
|
477 |
SQLRow row = this.mapTableSource.get(source).getRow(idSource);
|
|
|
478 |
|
|
|
479 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
480 |
loadElementBrut(row, null);
|
|
|
481 |
}
|
|
|
482 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COTISATION")) {
|
|
|
483 |
loadElementCotisation(row, null);
|
|
|
484 |
}
|
|
|
485 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
486 |
loadElementNet(row, null);
|
|
|
487 |
}
|
|
|
488 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
489 |
loadElementComm(row, null);
|
|
|
490 |
}
|
|
|
491 |
|
|
|
492 |
} else {
|
|
|
493 |
System.err.println("FichePayeModel.java --> Table non référencée dans la Map. Table name : " + source);
|
|
|
494 |
}
|
|
|
495 |
}
|
|
|
496 |
|
|
|
497 |
// this.vectRubrique = new Vector();
|
144 |
ilm |
498 |
updateValueFiche();
|
18 |
ilm |
499 |
// updateFields(this.idFiche);
|
|
|
500 |
fireTableDataChanged();
|
|
|
501 |
|
|
|
502 |
/*
|
|
|
503 |
* } }; this.threadUpdate.start();
|
|
|
504 |
*/
|
|
|
505 |
}
|
|
|
506 |
|
|
|
507 |
public String getSourceAt(int rowIndex) {
|
|
|
508 |
return this.vectRubrique.get(rowIndex).getString("SOURCE");
|
|
|
509 |
}
|
|
|
510 |
|
|
|
511 |
public int upRow(int rowIndex) {
|
|
|
512 |
// On vérifie qu'il est possible de remonter la ligne
|
|
|
513 |
if ((this.vectRubrique.size() > 1) && (rowIndex > 0)) {
|
|
|
514 |
System.err.println("UP");
|
|
|
515 |
SQLRowValues tmp = this.vectRubrique.get(rowIndex);
|
|
|
516 |
this.vectRubrique.set(rowIndex, this.vectRubrique.get(rowIndex - 1));
|
|
|
517 |
this.vectRubrique.set(rowIndex - 1, tmp);
|
|
|
518 |
this.fireTableDataChanged();
|
|
|
519 |
return rowIndex - 1;
|
|
|
520 |
}
|
|
|
521 |
System.err.println("can't up!!");
|
|
|
522 |
return rowIndex;
|
|
|
523 |
}
|
|
|
524 |
|
|
|
525 |
public int downRow(int rowIndex) {
|
|
|
526 |
// On vérifie qu'il est possible de descendre la ligne
|
|
|
527 |
if ((rowIndex >= 0) && (this.vectRubrique.size() > 1) && (rowIndex + 1 < this.vectRubrique.size())) {
|
|
|
528 |
|
|
|
529 |
System.err.println("DOWN");
|
|
|
530 |
SQLRowValues tmp = this.vectRubrique.get(rowIndex);
|
|
|
531 |
this.vectRubrique.set(rowIndex, this.vectRubrique.get(rowIndex + 1));
|
|
|
532 |
this.vectRubrique.set(rowIndex + 1, tmp);
|
|
|
533 |
this.fireTableDataChanged();
|
|
|
534 |
return rowIndex + 1;
|
|
|
535 |
}
|
|
|
536 |
|
|
|
537 |
System.err.println("can't down!!!");
|
|
|
538 |
return rowIndex;
|
|
|
539 |
}
|
|
|
540 |
|
|
|
541 |
public void setLastRowAT(int rowIndex) {
|
|
|
542 |
|
|
|
543 |
// On vérifie qu'il est possible de descendre la ligne
|
|
|
544 |
if ((rowIndex > 0) && (rowIndex < this.vectRubrique.size())) {
|
|
|
545 |
this.vectRubrique.add(rowIndex, this.vectRubrique.remove(this.vectRubrique.size() - 1));
|
|
|
546 |
}
|
|
|
547 |
this.fireTableDataChanged();
|
|
|
548 |
}
|
|
|
549 |
|
|
|
550 |
public void setFicheID(int id) {
|
|
|
551 |
this.idFiche = id;
|
144 |
ilm |
552 |
SQLRow rowFiche = tableFichePaye.getRow(this.idFiche);
|
|
|
553 |
this.mois = rowFiche.getInt("ID_MOIS") - 1;
|
|
|
554 |
this.isValidated = rowFiche.getBoolean("VALIDE");
|
18 |
ilm |
555 |
|
|
|
556 |
// this.javaEdit.setSalarieID(this.tableFichePaye.getRow(this.idFiche).getInt("ID_SALARIE"));
|
|
|
557 |
this.loadAllElements();
|
|
|
558 |
}
|
|
|
559 |
|
|
|
560 |
/***********************************************************************************************
|
|
|
561 |
* Ajouter une ligne
|
|
|
562 |
*
|
|
|
563 |
* @param row SQLRow RUBRIQUE_BRUT, RUBRIQUE_COTISATION, RUBRIQUE_NET, RUBRIQUE_COMM
|
|
|
564 |
* @param index index ou doit etre insere la row
|
|
|
565 |
*/
|
|
|
566 |
public void addRowAt(SQLRow row, int index) {
|
|
|
567 |
|
|
|
568 |
int size = this.vectRubrique.size();
|
|
|
569 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
570 |
this.loadElementBrut(row, null);
|
|
|
571 |
} else {
|
|
|
572 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COTISATION")) {
|
|
|
573 |
this.loadElementCotisation(row, null);
|
|
|
574 |
} else {
|
|
|
575 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
576 |
this.loadElementNet(row, null);
|
|
|
577 |
} else {
|
|
|
578 |
if (row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
579 |
this.loadElementComm(row, null);
|
|
|
580 |
}
|
|
|
581 |
}
|
|
|
582 |
}
|
|
|
583 |
}
|
|
|
584 |
|
|
|
585 |
if (size != this.vectRubrique.size()) {
|
|
|
586 |
setLastRowAT(index);
|
|
|
587 |
}
|
|
|
588 |
if (!row.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
589 |
calculValue();
|
|
|
590 |
}
|
|
|
591 |
this.fireTableDataChanged();
|
|
|
592 |
}
|
|
|
593 |
|
|
|
594 |
public void removeRow(int rowIndex) {
|
|
|
595 |
// System.err.println("_________________________________REMOVE");
|
|
|
596 |
if (rowIndex >= 0) {
|
|
|
597 |
|
|
|
598 |
SQLRowValues rowVals = this.vectRubrique.remove(rowIndex);
|
|
|
599 |
this.vectRowValsToDelete.add(rowVals);
|
|
|
600 |
|
|
|
601 |
if (!rowVals.getString("SOURCE").equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
602 |
calculValue();
|
|
|
603 |
}
|
|
|
604 |
this.fireTableDataChanged();
|
|
|
605 |
}
|
|
|
606 |
}
|
|
|
607 |
|
|
|
608 |
public void updateFields(int idFiche) {
|
|
|
609 |
|
|
|
610 |
// System.err.println("UPDATE FIELDS");
|
|
|
611 |
|
|
|
612 |
for (int i = 0; i < this.vectRowValsToDelete.size(); i++) {
|
|
|
613 |
SQLRowValues rowVals = this.vectRowValsToDelete.get(i);
|
|
|
614 |
|
|
|
615 |
if (rowVals.getID() != SQLRow.NONEXISTANT_ID) {
|
|
|
616 |
|
|
|
617 |
rowVals.put("ARCHIVE", 1);
|
|
|
618 |
try {
|
|
|
619 |
rowVals.update();
|
|
|
620 |
} catch (SQLException e) {
|
|
|
621 |
|
|
|
622 |
e.printStackTrace();
|
|
|
623 |
}
|
|
|
624 |
}
|
|
|
625 |
}
|
|
|
626 |
|
|
|
627 |
this.vectRowValsToDelete = new Vector<SQLRowValues>();
|
|
|
628 |
|
|
|
629 |
for (int i = 0; i < this.vectRubrique.size(); i++) {
|
|
|
630 |
SQLRowValues rowVals = this.vectRubrique.get(i);
|
|
|
631 |
rowVals.put("ID_FICHE_PAYE", idFiche);
|
|
|
632 |
rowVals.put("POSITION", i);
|
|
|
633 |
|
|
|
634 |
try {
|
|
|
635 |
rowVals.commit();
|
|
|
636 |
} catch (SQLException e) {
|
|
|
637 |
|
|
|
638 |
e.printStackTrace();
|
|
|
639 |
}
|
|
|
640 |
}
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
public void showData() {
|
|
|
644 |
|
|
|
645 |
if (this.vectRubrique.size() == 0) {
|
|
|
646 |
System.err.println("Vecteur contains no value.");
|
|
|
647 |
}
|
|
|
648 |
for (int i = 0; i < this.vectRubrique.size(); i++) {
|
|
|
649 |
System.err.println(this.vectRubrique.get(i));
|
|
|
650 |
}
|
|
|
651 |
}
|
|
|
652 |
|
|
|
653 |
public Object getVectorObjectAt(int index) {
|
|
|
654 |
return this.vectRubrique.get(index);
|
|
|
655 |
}
|
|
|
656 |
|
|
|
657 |
private boolean isEltInPeriod(SQLRow rowSource) {
|
|
|
658 |
|
144 |
ilm |
659 |
Object ob = PeriodeValiditeSQLElement.mapTranslate().get(Integer.valueOf(this.mois));
|
18 |
ilm |
660 |
|
|
|
661 |
if (ob == null) {
|
|
|
662 |
return false;
|
|
|
663 |
}
|
|
|
664 |
String moisName = ob.toString();
|
149 |
ilm |
665 |
final SQLTable tableValidite = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("PERIODE_VALIDITE");
|
|
|
666 |
final int idPeriode = rowSource.getInt("ID_PERIODE_VALIDITE");
|
|
|
667 |
SQLRow rowPeriodeValid = SQLBackgroundTableCache.getInstance().getCacheForTable(tableValidite).getRowFromId(idPeriode);
|
|
|
668 |
if (rowPeriodeValid == null) {
|
|
|
669 |
rowPeriodeValid = tableValidite.getRow(idPeriode);
|
|
|
670 |
if (rowPeriodeValid == null) {
|
|
|
671 |
System.err.println("FichePayeModel.isEltInPeriod() impossible de vérifier la validité de l'id " + idPeriode + " depuis la table PERIODE_VALIDITE");
|
|
|
672 |
return true;
|
|
|
673 |
}
|
|
|
674 |
}
|
18 |
ilm |
675 |
|
|
|
676 |
return (rowPeriodeValid.getBoolean(moisName));
|
|
|
677 |
}
|
|
|
678 |
|
|
|
679 |
private boolean isEltImprimable(SQLRow rowSource, SQLRowValues row) {
|
|
|
680 |
|
|
|
681 |
int impression = rowSource.getInt("ID_IMPRESSION_RUBRIQUE");
|
|
|
682 |
|
|
|
683 |
if (impression == 3) {
|
|
|
684 |
return true;
|
|
|
685 |
} else {
|
|
|
686 |
if (impression == 4) {
|
|
|
687 |
return false;
|
|
|
688 |
} else {
|
|
|
689 |
if (impression == 2) {
|
|
|
690 |
|
132 |
ilm |
691 |
BigDecimal montantSalAjOb = row.getBigDecimal("MONTANT_SAL_AJ");
|
|
|
692 |
BigDecimal montantSalAj = (montantSalAjOb == null) ? BigDecimal.ZERO : montantSalAjOb;
|
18 |
ilm |
693 |
|
132 |
ilm |
694 |
BigDecimal montantSalDedOb = row.getBigDecimal("MONTANT_SAL_DED");
|
|
|
695 |
BigDecimal montantSalDed = (montantSalDedOb == null) ? BigDecimal.ZERO : montantSalDedOb;
|
18 |
ilm |
696 |
|
132 |
ilm |
697 |
BigDecimal montantPatOb = row.getBigDecimal("MONTANT_PAT");
|
|
|
698 |
BigDecimal montantPat = (montantPatOb == null) ? BigDecimal.ZERO : montantPatOb;
|
18 |
ilm |
699 |
|
132 |
ilm |
700 |
if (montantSalAj.signum() == 0 && montantSalDed.signum() == 0 && montantPat.signum() == 0) {
|
18 |
ilm |
701 |
return false;
|
|
|
702 |
}
|
|
|
703 |
return true;
|
|
|
704 |
|
|
|
705 |
}
|
|
|
706 |
}
|
|
|
707 |
}
|
|
|
708 |
return true;
|
|
|
709 |
}
|
|
|
710 |
|
|
|
711 |
/**
|
|
|
712 |
* charge un élément de la fiche dans rowVals, dont la rubrique source est rowSource et
|
|
|
713 |
* l'élément row si l'élément existe déja
|
|
|
714 |
*
|
|
|
715 |
* @param rowVals
|
|
|
716 |
* @param rowSource
|
|
|
717 |
* @param row
|
|
|
718 |
* @return true si on doit calculer les valeurs
|
|
|
719 |
*/
|
|
|
720 |
private boolean loadElement(SQLRowValues rowVals, SQLRow rowSource, SQLRow row) {
|
|
|
721 |
|
|
|
722 |
if (row != null) {
|
|
|
723 |
rowVals.loadAbsolutelyAll(row);
|
|
|
724 |
}
|
|
|
725 |
|
|
|
726 |
// on vérifie que la rubrique s'applique pour le mois concerné
|
|
|
727 |
// if (!isEltInPeriod(rowSource)) {
|
|
|
728 |
// System.err.println("Not In periode");
|
|
|
729 |
rowVals.put("IN_PERIODE", Boolean.valueOf(isEltInPeriod(rowSource)));
|
|
|
730 |
// }
|
|
|
731 |
|
|
|
732 |
rowVals.put("SOURCE", rowSource.getTable().getName());
|
|
|
733 |
rowVals.put("IDSOURCE", rowSource.getID());
|
|
|
734 |
|
|
|
735 |
Object ob = rowVals.getObject("VALIDE");
|
|
|
736 |
boolean b = (ob == null) ? false : new Boolean(ob.toString()).booleanValue();
|
|
|
737 |
|
144 |
ilm |
738 |
if (rowVals.getObject("ID_FICHE_PAYE") != null && !rowVals.isForeignEmpty("ID_FICHE_PAYE") && isValidated) {
|
142 |
ilm |
739 |
b = true;
|
|
|
740 |
}
|
|
|
741 |
|
18 |
ilm |
742 |
return b;
|
|
|
743 |
}
|
|
|
744 |
|
144 |
ilm |
745 |
private float smicHoraire = 0;
|
|
|
746 |
|
|
|
747 |
private float getSmicHoraire(DBRoot root) {
|
|
|
748 |
if (smicHoraire != 0) {
|
|
|
749 |
return smicHoraire;
|
|
|
750 |
}
|
|
|
751 |
SQLTable table = root.findTable("VARIABLE_PAYE");
|
|
|
752 |
SQLSelect sel = new SQLSelect();
|
|
|
753 |
sel.addSelectStar(table);
|
|
|
754 |
sel.setWhere(new Where(table.getField("NOM"), "=", "SMIC"));
|
|
|
755 |
List<SQLRow> result = SQLRowListRSH.execute(sel);
|
|
|
756 |
if (result.size() > 0) {
|
|
|
757 |
smicHoraire = result.get(0).getFloat("VALEUR");
|
|
|
758 |
} else {
|
|
|
759 |
smicHoraire = 0;
|
|
|
760 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
761 |
|
|
|
762 |
@Override
|
|
|
763 |
public void run() {
|
|
|
764 |
JOptionPane.showMessageDialog(null,
|
|
|
765 |
"Une variable est manquante pour compléter votre DSN.\nLa variable de paye SMIC n'existe pas, correspondant au SMIC horaire. Ajoutez la dans la liste!");
|
|
|
766 |
}
|
|
|
767 |
});
|
|
|
768 |
}
|
|
|
769 |
return smicHoraire;
|
|
|
770 |
}
|
|
|
771 |
|
18 |
ilm |
772 |
private void updateValueFiche() {
|
|
|
773 |
|
144 |
ilm |
774 |
if (!isValidated && this.idFiche > tableFichePaye.getUndefinedID()) {
|
142 |
ilm |
775 |
SQLRowValues rowValsFiche = new SQLRowValues(tableFichePaye);
|
144 |
ilm |
776 |
rowValsFiche.put(tableFichePaye.getKey().getName(), this.idFiche);
|
142 |
ilm |
777 |
rowValsFiche.put("SAL_BRUT", this.salBrut);
|
144 |
ilm |
778 |
rowValsFiche.put("SAL_BASE_BRUT", this.salBrutBase);
|
|
|
779 |
rowValsFiche.put("SAL_BRUT_COTISABLE", this.salBrutCotis);
|
|
|
780 |
rowValsFiche.put("SAL_BRUT_TAXABLE", this.salBrutTaxable);
|
|
|
781 |
rowValsFiche.put("NET_IMP", getNetImpTotal());
|
|
|
782 |
rowValsFiche.put("NET_A_PAYER", getNetAPayerTotal());
|
156 |
ilm |
783 |
rowValsFiche.put("NET_AVANT_PAS", getNetAvantPas());
|
142 |
ilm |
784 |
rowValsFiche.put("COT_SAL", this.cotSal);
|
|
|
785 |
rowValsFiche.put("COT_PAT", this.cotPat);
|
144 |
ilm |
786 |
rowValsFiche.put("TAXE_CM_PAT", this.taxCmPat);
|
|
|
787 |
rowValsFiche.put("TAXE_CM_SAL", this.taxCmSal);
|
|
|
788 |
rowValsFiche.put("CSG", getCsgTotal());
|
177 |
ilm |
789 |
rowValsFiche.put("CSG_REDUITE", getCsgReduite());
|
|
|
790 |
rowValsFiche.put("SAL_BRUT_CSG", getSalBrutCSG());
|
|
|
791 |
rowValsFiche.put("SAL_BRUT_CSG_REDUITE", getSalBrutCSGReduite());
|
|
|
792 |
|
144 |
ilm |
793 |
rowValsFiche.put("HEURE_TRAV", getHeureTrav());
|
156 |
ilm |
794 |
rowValsFiche.put("TOTAL_PAS", getPas());
|
|
|
795 |
|
144 |
ilm |
796 |
if (this.cice == null) {
|
|
|
797 |
if (salBrut.signum() > 0
|
|
|
798 |
&& salBrut.compareTo(new BigDecimal(getSmicHoraire(tableFichePaye.getDBRoot())).multiply(getHeureTrav()).multiply(new BigDecimal(2.5), DecimalUtils.HIGH_PRECISION)) <= 0) {
|
|
|
799 |
this.cice = salBrut;
|
|
|
800 |
} else {
|
|
|
801 |
this.cice = BigDecimal.ZERO;
|
|
|
802 |
}
|
|
|
803 |
}
|
|
|
804 |
rowValsFiche.put("CICE", this.cice);
|
|
|
805 |
rowValsFiche.put("ALLEGEMENT_COTISATION", this.allegmentCotisation);
|
151 |
ilm |
806 |
rowValsFiche.put("REDUCTION_GVT", this.reduction);
|
144 |
ilm |
807 |
rowValsFiche.put("AVANTAGE_NATURE", this.avantage);
|
142 |
ilm |
808 |
try {
|
|
|
809 |
rowValsFiche.update(this.idFiche);
|
144 |
ilm |
810 |
// rowValsFiche.getGraph().store(StoreMode.COMMIT, false);
|
142 |
ilm |
811 |
} catch (SQLException e) {
|
|
|
812 |
e.printStackTrace();
|
|
|
813 |
}
|
18 |
ilm |
814 |
}
|
144 |
ilm |
815 |
|
18 |
ilm |
816 |
}
|
|
|
817 |
|
144 |
ilm |
818 |
private BigDecimal getHeureTrav() {
|
|
|
819 |
final SQLRow rowFiche = tableFichePaye.getRow(idFiche);
|
|
|
820 |
return new BigDecimal(rowFiche.getForeign("ID_SALARIE").getForeign("ID_VARIABLE_SALARIE").getFloat("HEURE_TRAV"));
|
|
|
821 |
|
|
|
822 |
}
|
|
|
823 |
|
18 |
ilm |
824 |
/***********************************************************************************************
|
|
|
825 |
* Charge un élément d'une rubrique de brut
|
|
|
826 |
*
|
|
|
827 |
* @param rowSource row de la rubrique source
|
|
|
828 |
* @param row row de l'élément de la fiche
|
|
|
829 |
**********************************************************************************************/
|
|
|
830 |
private void loadElementBrut(SQLRow rowSource, SQLRow row) {
|
|
|
831 |
|
|
|
832 |
// System.err.println("________________________LOAD ELT BRUT");
|
|
|
833 |
SQLRowValues rowVals = new SQLRowValues(tableFichePayeElt);
|
|
|
834 |
|
|
|
835 |
if (!loadElement(rowVals, rowSource, row)) {
|
|
|
836 |
|
|
|
837 |
// System.err.println("________________________Recalcul des ELT BRUT ");
|
|
|
838 |
Object baseOb = this.javaEdit.checkFormule(rowSource.getString("BASE"), "BASE");
|
|
|
839 |
Object tauxSalOb = this.javaEdit.checkFormule(rowSource.getString("TAUX"), "TAUX");
|
|
|
840 |
rowVals.put("NOM", rowSource.getString("NOM"));
|
|
|
841 |
|
132 |
ilm |
842 |
rowVals.put("NB_BASE", (baseOb == null) ? null : new BigDecimal(baseOb.toString()));
|
|
|
843 |
rowVals.put("TAUX_SAL", (tauxSalOb == null) ? null : new BigDecimal(tauxSalOb.toString()));
|
18 |
ilm |
844 |
}
|
|
|
845 |
|
|
|
846 |
calculBrut(rowSource, rowVals);
|
|
|
847 |
|
|
|
848 |
boolean b = isEltImprimable(rowSource, rowVals);
|
|
|
849 |
// System.err.println("Impression --- > " + b);
|
|
|
850 |
rowVals.put("IMPRESSION", Boolean.valueOf(b));
|
|
|
851 |
|
|
|
852 |
this.vectRubrique.add(rowVals);
|
|
|
853 |
}
|
|
|
854 |
|
|
|
855 |
/**
|
|
|
856 |
* Calcul le montant d'une rubrique de brut et met à jour les variables du salarié
|
|
|
857 |
*
|
|
|
858 |
* @param rowSource
|
|
|
859 |
* @param rowVals
|
|
|
860 |
*/
|
|
|
861 |
private void calculBrut(SQLRow rowSource, SQLRowValues rowVals) {
|
|
|
862 |
|
132 |
ilm |
863 |
if (rowVals.getBoolean("IN_PERIODE")) {
|
18 |
ilm |
864 |
|
132 |
ilm |
865 |
BigDecimal baseOb = rowVals.getBigDecimal("NB_BASE");
|
|
|
866 |
BigDecimal tauxSalOb = rowVals.getBigDecimal("TAUX_SAL");
|
18 |
ilm |
867 |
|
132 |
ilm |
868 |
BigDecimal base = (baseOb == null) ? BigDecimal.ZERO : baseOb;
|
|
|
869 |
BigDecimal tauxSal = (tauxSalOb == null) ? BigDecimal.ZERO : tauxSalOb;
|
18 |
ilm |
870 |
|
|
|
871 |
// Calcul du montant
|
|
|
872 |
String formuleMontant = rowSource.getString("MONTANT");
|
|
|
873 |
|
144 |
ilm |
874 |
if (!isValidated) {
|
|
|
875 |
BigDecimal montant = BigDecimal.ZERO;
|
|
|
876 |
if (formuleMontant.trim().length() == 0) {
|
|
|
877 |
montant = base.multiply(tauxSal).setScale(2, RoundingMode.HALF_UP);
|
|
|
878 |
} else {
|
|
|
879 |
Object montantNet = this.javaEdit.checkFormule(rowSource.getString("MONTANT"), "MONTANT");
|
|
|
880 |
BigDecimal montantNetS = (montantNet == null) ? BigDecimal.ZERO : new BigDecimal(montantNet.toString());
|
|
|
881 |
montant = montantNetS;
|
|
|
882 |
}
|
18 |
ilm |
883 |
|
144 |
ilm |
884 |
// Retenue
|
|
|
885 |
if (rowSource.getInt("ID_TYPE_RUBRIQUE_BRUT") == 3) {
|
18 |
ilm |
886 |
|
144 |
ilm |
887 |
rowVals.put("MONTANT_SAL_DED", montant);
|
|
|
888 |
this.salBrut = this.salBrut.subtract(montant);
|
|
|
889 |
if (rowSource.getBoolean("TAXABLE_CM")) {
|
|
|
890 |
this.salBrutTaxable = this.salBrutTaxable.subtract(montant);
|
|
|
891 |
}
|
|
|
892 |
if (rowSource.getBoolean("COTISABLE")) {
|
|
|
893 |
this.salBrutCotis = this.salBrutCotis.subtract(montant);
|
|
|
894 |
}
|
|
|
895 |
if (rowSource.getBoolean("PART_BRUT")) {
|
|
|
896 |
this.salBrutBase = this.salBrutBase.subtract(montant);
|
|
|
897 |
}
|
177 |
ilm |
898 |
|
|
|
899 |
if (rowSource.getBoolean("CSG_NORMAL")) {
|
|
|
900 |
this.salBrutCSG = this.salBrutCSG.subtract(montant);
|
|
|
901 |
}
|
|
|
902 |
if (rowSource.getBoolean("CSG_REDUIT")) {
|
|
|
903 |
this.salBrutCSGReduite = this.salBrutCSGReduite.subtract(montant);
|
|
|
904 |
}
|
185 |
ilm |
905 |
if (rowSource.getBoolean("PART_CSG_SANS_ABATTEMENT")) {
|
|
|
906 |
this.csgSansAbattement = this.csgSansAbattement.subtract(montant);
|
|
|
907 |
}
|
144 |
ilm |
908 |
} // Gain
|
|
|
909 |
else {
|
18 |
ilm |
910 |
|
144 |
ilm |
911 |
rowVals.put("MONTANT_SAL_AJ", montant);
|
|
|
912 |
this.salBrut = this.salBrut.add(montant);
|
|
|
913 |
if (rowSource.getBoolean("TAXABLE_CM")) {
|
|
|
914 |
this.salBrutTaxable = this.salBrutTaxable.add(montant);
|
|
|
915 |
}
|
|
|
916 |
if (rowSource.getBoolean("COTISABLE")) {
|
|
|
917 |
this.salBrutCotis = this.salBrutCotis.add(montant);
|
|
|
918 |
}
|
|
|
919 |
if (rowSource.getBoolean("PART_BRUT")) {
|
|
|
920 |
this.salBrutBase = this.salBrutBase.add(montant);
|
|
|
921 |
}
|
|
|
922 |
if (rowSource.getBoolean("AVANTAGE_NATURE")) {
|
|
|
923 |
this.avantage = this.avantage.add(montant);
|
|
|
924 |
}
|
177 |
ilm |
925 |
if (rowSource.getBoolean("CSG_NORMAL")) {
|
|
|
926 |
this.salBrutCSG = this.salBrutCSG.add(montant);
|
|
|
927 |
}
|
|
|
928 |
if (rowSource.getBoolean("CSG_REDUIT")) {
|
|
|
929 |
this.salBrutCSGReduite = this.salBrutCSGReduite.add(montant);
|
|
|
930 |
}
|
185 |
ilm |
931 |
if (rowSource.getBoolean("PART_CSG_SANS_ABATTEMENT")) {
|
|
|
932 |
this.csgSansAbattement = this.csgSansAbattement.add(montant);
|
|
|
933 |
}
|
144 |
ilm |
934 |
}
|
|
|
935 |
|
|
|
936 |
// Mis a jour du salaire brut
|
|
|
937 |
// updateValueFiche();
|
|
|
938 |
} else {
|
|
|
939 |
BigDecimal ded = rowVals.getBigDecimal("MONTANT_SAL_DED");
|
|
|
940 |
if (ded != null) {
|
|
|
941 |
this.salBrut = this.salBrut.subtract(ded);
|
|
|
942 |
if (rowSource.getBoolean("TAXABLE_CM")) {
|
|
|
943 |
this.salBrutTaxable = this.salBrutTaxable.subtract(ded);
|
|
|
944 |
}
|
|
|
945 |
if (rowSource.getBoolean("COTISABLE")) {
|
|
|
946 |
this.salBrutCotis = this.salBrutCotis.subtract(ded);
|
|
|
947 |
}
|
|
|
948 |
if (rowSource.getBoolean("PART_BRUT")) {
|
|
|
949 |
this.salBrutBase = this.salBrutBase.subtract(ded);
|
|
|
950 |
}
|
177 |
ilm |
951 |
if (rowSource.getBoolean("CSG_NORMAL")) {
|
|
|
952 |
this.salBrutCSG = this.salBrutCSG.subtract(ded);
|
|
|
953 |
}
|
|
|
954 |
if (rowSource.getBoolean("CSG_REDUIT")) {
|
|
|
955 |
this.salBrutCSGReduite = this.salBrutCSGReduite.subtract(ded);
|
|
|
956 |
}
|
185 |
ilm |
957 |
if (rowSource.getBoolean("PART_CSG_SANS_ABATTEMENT")) {
|
|
|
958 |
this.csgSansAbattement = this.csgSansAbattement.subtract(ded);
|
|
|
959 |
}
|
144 |
ilm |
960 |
}
|
|
|
961 |
BigDecimal add = rowVals.getBigDecimal("MONTANT_SAL_AJ");
|
|
|
962 |
if (add != null) {
|
|
|
963 |
this.salBrut = this.salBrut.add(add);
|
|
|
964 |
if (rowSource.getBoolean("AVANTAGE_NATURE")) {
|
|
|
965 |
this.avantage = this.avantage.add(add);
|
|
|
966 |
}
|
|
|
967 |
if (rowSource.getBoolean("TAXABLE_CM")) {
|
|
|
968 |
this.salBrutTaxable = this.salBrutTaxable.add(add);
|
|
|
969 |
}
|
|
|
970 |
if (rowSource.getBoolean("COTISABLE")) {
|
|
|
971 |
this.salBrutCotis = this.salBrutCotis.add(add);
|
|
|
972 |
}
|
|
|
973 |
if (rowSource.getBoolean("PART_BRUT")) {
|
|
|
974 |
this.salBrutBase = this.salBrutBase.add(add);
|
|
|
975 |
}
|
177 |
ilm |
976 |
if (rowSource.getBoolean("CSG_NORMAL")) {
|
|
|
977 |
this.salBrutCSG = this.salBrutCSG.add(add);
|
|
|
978 |
}
|
|
|
979 |
if (rowSource.getBoolean("CSG_REDUIT")) {
|
|
|
980 |
this.salBrutCSGReduite = this.salBrutCSGReduite.add(add);
|
|
|
981 |
}
|
185 |
ilm |
982 |
if (rowSource.getBoolean("PART_CSG_SANS_ABATTEMENT")) {
|
|
|
983 |
this.csgSansAbattement = this.csgSansAbattement.add(add);
|
|
|
984 |
}
|
144 |
ilm |
985 |
}
|
18 |
ilm |
986 |
}
|
|
|
987 |
}
|
|
|
988 |
}
|
|
|
989 |
|
|
|
990 |
private void calculNet(SQLRow rowSource, SQLRowValues rowVals) {
|
|
|
991 |
|
132 |
ilm |
992 |
if (rowVals.getBoolean("IN_PERIODE")) {
|
18 |
ilm |
993 |
|
132 |
ilm |
994 |
BigDecimal baseOb = rowVals.getBigDecimal("NB_BASE");
|
|
|
995 |
BigDecimal tauxSalOb = rowVals.getBigDecimal("TAUX_SAL");
|
18 |
ilm |
996 |
|
132 |
ilm |
997 |
BigDecimal base = baseOb == null ? BigDecimal.ZERO : baseOb;
|
|
|
998 |
BigDecimal tauxSal = tauxSalOb == null ? BigDecimal.ZERO : tauxSalOb;
|
18 |
ilm |
999 |
|
144 |
ilm |
1000 |
if (!isValidated) {
|
|
|
1001 |
// Calcul du montant
|
|
|
1002 |
String formuleMontant = rowSource.getString("MONTANT");
|
18 |
ilm |
1003 |
|
144 |
ilm |
1004 |
BigDecimal montant = BigDecimal.ZERO;
|
|
|
1005 |
if (formuleMontant.trim().length() == 0) {
|
|
|
1006 |
montant = base.multiply(tauxSal).setScale(2, RoundingMode.HALF_UP);
|
|
|
1007 |
} else {
|
|
|
1008 |
Object montantNet = this.javaEdit.checkFormule(rowSource.getString("MONTANT"), "MONTANT");
|
|
|
1009 |
if (montantNet != null) {
|
|
|
1010 |
montant = new BigDecimal(montantNet.toString());
|
|
|
1011 |
}
|
18 |
ilm |
1012 |
}
|
|
|
1013 |
|
144 |
ilm |
1014 |
// Retenue
|
|
|
1015 |
if (rowSource.getInt("ID_TYPE_RUBRIQUE_NET") == 3) {
|
18 |
ilm |
1016 |
|
144 |
ilm |
1017 |
rowVals.put("MONTANT_SAL_DED", montant);
|
18 |
ilm |
1018 |
|
144 |
ilm |
1019 |
this.netAPayer = this.netAPayer.subtract(montant);
|
|
|
1020 |
if (rowSource.getBoolean("IMPOSABLE")) {
|
|
|
1021 |
this.netImp = this.netImp.subtract(montant);
|
|
|
1022 |
}
|
156 |
ilm |
1023 |
if (rowSource.getBoolean("PAS")) {
|
|
|
1024 |
this.pas = this.pas.subtract(montant);
|
|
|
1025 |
}
|
18 |
ilm |
1026 |
|
144 |
ilm |
1027 |
} // Gain
|
|
|
1028 |
else {
|
18 |
ilm |
1029 |
|
144 |
ilm |
1030 |
rowVals.put("MONTANT_SAL_AJ", montant);
|
18 |
ilm |
1031 |
|
144 |
ilm |
1032 |
this.netAPayer = this.netAPayer.add(montant);
|
|
|
1033 |
if (rowSource.getBoolean("IMPOSABLE")) {
|
|
|
1034 |
this.netImp = this.netImp.add(montant);
|
|
|
1035 |
}
|
156 |
ilm |
1036 |
if (rowSource.getBoolean("PAS")) {
|
|
|
1037 |
this.pas = this.pas.add(montant);
|
|
|
1038 |
}
|
18 |
ilm |
1039 |
}
|
144 |
ilm |
1040 |
|
|
|
1041 |
// Mis a jour du salaire net
|
|
|
1042 |
// updateValueFiche();
|
|
|
1043 |
} else {
|
|
|
1044 |
BigDecimal ded = rowVals.getBigDecimal("MONTANT_SAL_DED");
|
|
|
1045 |
if (ded != null) {
|
|
|
1046 |
this.netAPayer = this.netAPayer.subtract(ded);
|
|
|
1047 |
if (rowSource.getBoolean("IMPOSABLE")) {
|
|
|
1048 |
this.netImp = this.netImp.subtract(ded);
|
|
|
1049 |
}
|
156 |
ilm |
1050 |
if (rowSource.getBoolean("PAS")) {
|
|
|
1051 |
this.pas = this.pas.subtract(ded);
|
|
|
1052 |
}
|
144 |
ilm |
1053 |
}
|
|
|
1054 |
BigDecimal add = rowVals.getBigDecimal("MONTANT_SAL_AJ");
|
|
|
1055 |
if (add != null) {
|
|
|
1056 |
this.netAPayer = this.netAPayer.add(add);
|
|
|
1057 |
if (rowSource.getBoolean("IMPOSABLE")) {
|
|
|
1058 |
this.netImp = this.netImp.add(add);
|
|
|
1059 |
}
|
156 |
ilm |
1060 |
if (rowSource.getBoolean("IMPOSABLE")) {
|
|
|
1061 |
this.pas = this.pas.add(add);
|
|
|
1062 |
}
|
144 |
ilm |
1063 |
}
|
18 |
ilm |
1064 |
}
|
|
|
1065 |
}
|
|
|
1066 |
}
|
|
|
1067 |
|
|
|
1068 |
private void loadElementNet(SQLRow rowSource, SQLRow row) {
|
|
|
1069 |
SQLRowValues rowVals = new SQLRowValues(tableFichePayeElt);
|
|
|
1070 |
// System.err.println("________________________LOAD ELT NET");
|
|
|
1071 |
|
|
|
1072 |
if (!loadElement(rowVals, rowSource, row)) {
|
|
|
1073 |
|
|
|
1074 |
Object baseOb = this.javaEdit.checkFormule(rowSource.getString("BASE"), "BASE");
|
|
|
1075 |
Object tauxSalOb = this.javaEdit.checkFormule(rowSource.getString("TAUX"), "TAUX");
|
|
|
1076 |
rowVals.put("NOM", rowSource.getString("NOM"));
|
132 |
ilm |
1077 |
rowVals.put("NB_BASE", (baseOb == null) ? null : new BigDecimal(baseOb.toString()));
|
|
|
1078 |
rowVals.put("TAUX_SAL", (tauxSalOb == null) ? null : new BigDecimal(tauxSalOb.toString()));
|
18 |
ilm |
1079 |
}
|
|
|
1080 |
|
|
|
1081 |
calculNet(rowSource, rowVals);
|
|
|
1082 |
|
|
|
1083 |
boolean b = isEltImprimable(rowSource, rowVals);
|
|
|
1084 |
// System.err.println("Impression --- > " + b);
|
|
|
1085 |
rowVals.put("IMPRESSION", Boolean.valueOf(b));
|
|
|
1086 |
|
|
|
1087 |
this.vectRubrique.add(rowVals);
|
|
|
1088 |
}
|
|
|
1089 |
|
|
|
1090 |
private void calculCotisation(SQLRow rowSource, SQLRowValues rowVals) {
|
|
|
1091 |
|
|
|
1092 |
if (((Boolean) rowVals.getObject("IN_PERIODE")).booleanValue()) {
|
|
|
1093 |
|
132 |
ilm |
1094 |
BigDecimal baseOb = rowVals.getBigDecimal("NB_BASE");
|
|
|
1095 |
BigDecimal tauxSalOb = rowVals.getBigDecimal("TAUX_SAL");
|
|
|
1096 |
BigDecimal tauxPatOb = rowVals.getBigDecimal("TAUX_PAT");
|
18 |
ilm |
1097 |
|
132 |
ilm |
1098 |
BigDecimal base = baseOb == null ? BigDecimal.ZERO : baseOb;
|
|
|
1099 |
BigDecimal tauxSal = tauxSalOb == null ? BigDecimal.ZERO : tauxSalOb;
|
|
|
1100 |
BigDecimal tauxPat = tauxPatOb == null ? BigDecimal.ZERO : tauxPatOb;
|
18 |
ilm |
1101 |
|
|
|
1102 |
// Calcul du montant
|
132 |
ilm |
1103 |
BigDecimal montantSal = base.multiply(tauxSal).movePointLeft(2).setScale(2, RoundingMode.HALF_UP);
|
|
|
1104 |
BigDecimal montantPat = base.multiply(tauxPat).movePointLeft(2).setScale(2, RoundingMode.HALF_UP);
|
18 |
ilm |
1105 |
|
132 |
ilm |
1106 |
rowVals.put("MONTANT_SAL_DED", montantSal);
|
|
|
1107 |
rowVals.put("MONTANT_PAT", montantPat);
|
18 |
ilm |
1108 |
|
132 |
ilm |
1109 |
this.netAPayer = this.netAPayer.subtract(montantSal);
|
|
|
1110 |
if (!rowSource.getBoolean("IMPOSABLE")) {
|
|
|
1111 |
this.netImp = this.netImp.subtract(montantSal);
|
18 |
ilm |
1112 |
}
|
|
|
1113 |
|
144 |
ilm |
1114 |
if (rowSource.getBoolean("ALLEGEMENT_COTISATION")) {
|
|
|
1115 |
this.allegmentCotisation = this.allegmentCotisation.add(montantPat);
|
|
|
1116 |
}
|
|
|
1117 |
|
94 |
ilm |
1118 |
if (rowSource.getBoolean("PART_PAT_IMPOSABLE")) {
|
132 |
ilm |
1119 |
this.netImp = this.netImp.add(montantPat);
|
94 |
ilm |
1120 |
}
|
|
|
1121 |
|
132 |
ilm |
1122 |
if (rowSource.getBoolean("PART_CSG")) {
|
|
|
1123 |
this.csg = this.csg.add(montantPat);
|
|
|
1124 |
}
|
94 |
ilm |
1125 |
if (rowSource.getBoolean("PART_CSG_SANS_ABATTEMENT")) {
|
132 |
ilm |
1126 |
this.csgSansAbattement = this.csgSansAbattement.add(montantPat);
|
94 |
ilm |
1127 |
}
|
144 |
ilm |
1128 |
if (rowSource.getBoolean("TAXABLE_CM")) {
|
|
|
1129 |
this.taxCmSal = this.taxCmSal.add(montantSal);
|
|
|
1130 |
this.taxCmPat = this.taxCmPat.add(montantPat);
|
|
|
1131 |
} else {
|
|
|
1132 |
this.cotSal = this.cotSal.add(montantSal);
|
|
|
1133 |
this.cotPat = this.cotPat.add(montantPat);
|
|
|
1134 |
}
|
94 |
ilm |
1135 |
|
144 |
ilm |
1136 |
// CICE
|
|
|
1137 |
int codeTP = rowSource.getForeignID("ID_CODE_CAISSE_TYPE_RUBRIQUE");
|
156 |
ilm |
1138 |
String codeStringTP = "";
|
|
|
1139 |
if (rowSource.getForeign("ID_CODE_CAISSE_TYPE_RUBRIQUE") != null && !rowSource.isForeignEmpty("ID_CODE_CAISSE_TYPE_RUBRIQUE")) {
|
|
|
1140 |
codeStringTP = rowSource.getForeign("ID_CODE_CAISSE_TYPE_RUBRIQUE").getString("CODE");
|
|
|
1141 |
}
|
|
|
1142 |
|
|
|
1143 |
if (codeTP == 298 || codeStringTP.equals("400")) {
|
144 |
ilm |
1144 |
this.cice = rowVals.getBigDecimal("NB_BASE");
|
|
|
1145 |
}
|
18 |
ilm |
1146 |
|
|
|
1147 |
// Mis a jour des cotisations
|
144 |
ilm |
1148 |
// updateValueFiche();
|
18 |
ilm |
1149 |
}
|
156 |
ilm |
1150 |
|
18 |
ilm |
1151 |
}
|
|
|
1152 |
|
132 |
ilm |
1153 |
private void loadElementCotisation(final SQLRow rowSource, SQLRow row) {
|
18 |
ilm |
1154 |
SQLRowValues rowVals = new SQLRowValues(tableFichePayeElt);
|
|
|
1155 |
// System.err.println("________________________LOAD ELT COTISATION");
|
|
|
1156 |
|
|
|
1157 |
if (!loadElement(rowVals, rowSource, row)) {
|
|
|
1158 |
|
|
|
1159 |
// On calcule les valeurs
|
|
|
1160 |
Object baseOb = this.javaEdit.checkFormule(rowSource.getString("BASE"), "BASE");
|
132 |
ilm |
1161 |
if (!this.javaEdit.isCodeValid()) {
|
|
|
1162 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
1163 |
|
|
|
1164 |
@Override
|
|
|
1165 |
public void run() {
|
|
|
1166 |
JOptionPane.showMessageDialog(null, "La formule BASE pour la rubrique " + rowSource.getString("CODE") + " n'est pas correcte!");
|
|
|
1167 |
}
|
|
|
1168 |
});
|
|
|
1169 |
}
|
18 |
ilm |
1170 |
Object tauxSalOb = this.javaEdit.checkFormule(rowSource.getString("TX_SAL"), "TX_SAL");
|
132 |
ilm |
1171 |
if (!this.javaEdit.isCodeValid()) {
|
|
|
1172 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
1173 |
|
|
|
1174 |
@Override
|
|
|
1175 |
public void run() {
|
|
|
1176 |
JOptionPane.showMessageDialog(null, "La formule TX_SAL pour la rubrique " + rowSource.getString("CODE") + " n'est pas correcte!");
|
|
|
1177 |
}
|
|
|
1178 |
});
|
|
|
1179 |
}
|
18 |
ilm |
1180 |
Object tauxPatOb = this.javaEdit.checkFormule(rowSource.getString("TX_PAT"), "TX_PAT");
|
132 |
ilm |
1181 |
if (!this.javaEdit.isCodeValid()) {
|
|
|
1182 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
1183 |
|
|
|
1184 |
@Override
|
|
|
1185 |
public void run() {
|
|
|
1186 |
JOptionPane.showMessageDialog(null, "La formule TX_PAT pour la rubrique " + rowSource.getString("CODE") + " n'est pas correcte!");
|
|
|
1187 |
}
|
|
|
1188 |
});
|
|
|
1189 |
}
|
18 |
ilm |
1190 |
rowVals.put("NOM", rowSource.getString("NOM"));
|
132 |
ilm |
1191 |
rowVals.put("NB_BASE", (baseOb == null) ? null : new BigDecimal(baseOb.toString()));
|
|
|
1192 |
rowVals.put("TAUX_SAL", (tauxSalOb == null) ? null : new BigDecimal(tauxSalOb.toString()));
|
|
|
1193 |
rowVals.put("TAUX_PAT", (tauxPatOb == null) ? null : new BigDecimal(tauxPatOb.toString()));
|
18 |
ilm |
1194 |
}
|
|
|
1195 |
|
|
|
1196 |
calculCotisation(rowSource, rowVals);
|
|
|
1197 |
|
|
|
1198 |
boolean b = isEltImprimable(rowSource, rowVals);
|
|
|
1199 |
// System.err.println("Impression --- > " + b);
|
|
|
1200 |
rowVals.put("IMPRESSION", Boolean.valueOf(b));
|
|
|
1201 |
|
|
|
1202 |
this.vectRubrique.add(rowVals);
|
|
|
1203 |
}
|
|
|
1204 |
|
|
|
1205 |
public void loadElementComm(SQLRow rowSource, SQLRow row) {
|
|
|
1206 |
SQLRowValues rowVals = new SQLRowValues(tableFichePayeElt);
|
|
|
1207 |
// System.err.println("________________________LOAD ELT COMM");
|
|
|
1208 |
|
|
|
1209 |
if (loadElement(rowVals, rowSource, row)) {
|
|
|
1210 |
this.vectRubrique.add(rowVals);
|
|
|
1211 |
return;
|
|
|
1212 |
}
|
|
|
1213 |
|
156 |
ilm |
1214 |
try {
|
|
|
1215 |
Object baseOb = this.javaEdit.checkFormule(rowSource.getString("NB_BASE"), "BASE");
|
|
|
1216 |
Object tauxSalOb = this.javaEdit.checkFormule(rowSource.getString("TAUX_SAL"), "SAL");
|
|
|
1217 |
Object tauxPatOb = this.javaEdit.checkFormule(rowSource.getString("TAUX_PAT"), "PAT");
|
|
|
1218 |
Object montantPatOb = this.javaEdit.checkFormule(rowSource.getString("MONTANT_PAT"), "MONTANT");
|
|
|
1219 |
Object montantAdOb = this.javaEdit.checkFormule(rowSource.getString("MONTANT_SAL_AJ"), "MONTANT");
|
|
|
1220 |
Object montantDedOb = this.javaEdit.checkFormule(rowSource.getString("MONTANT_SAL_DED"), "MONTANT");
|
|
|
1221 |
rowVals.put("NOM", rowSource.getBoolean("NOM_VISIBLE") ? rowSource.getString("NOM") : "");
|
|
|
1222 |
rowVals.put("NB_BASE", (baseOb == null) ? null : new BigDecimal(baseOb.toString()));
|
|
|
1223 |
rowVals.put("TAUX_SAL", (tauxSalOb == null) ? null : new BigDecimal(tauxSalOb.toString()));
|
|
|
1224 |
rowVals.put("TAUX_PAT", (tauxPatOb == null) ? null : new BigDecimal(tauxPatOb.toString()));
|
|
|
1225 |
rowVals.put("MONTANT_PAT", (montantPatOb == null) ? null : new BigDecimal(montantPatOb.toString()));
|
|
|
1226 |
final BigDecimal montantAj = (montantAdOb == null) ? null : new BigDecimal(montantAdOb.toString());
|
|
|
1227 |
rowVals.put("MONTANT_SAL_AJ", montantAj);
|
|
|
1228 |
final BigDecimal montantDed = (montantDedOb == null) ? null : new BigDecimal(montantDedOb.toString());
|
|
|
1229 |
rowVals.put("MONTANT_SAL_DED", montantDed);
|
18 |
ilm |
1230 |
|
156 |
ilm |
1231 |
boolean b = isEltImprimable(rowSource, rowVals);
|
|
|
1232 |
rowVals.put("IMPRESSION", Boolean.valueOf(b));
|
18 |
ilm |
1233 |
|
156 |
ilm |
1234 |
if (rowSource.getBoolean("REDUCTION_GVT_COM")) {
|
|
|
1235 |
if (montantAj != null) {
|
|
|
1236 |
this.reduction = this.reduction.subtract(montantAj);
|
|
|
1237 |
}
|
|
|
1238 |
if (montantDed != null) {
|
|
|
1239 |
this.reduction = this.reduction.add(montantDed);
|
|
|
1240 |
}
|
151 |
ilm |
1241 |
}
|
156 |
ilm |
1242 |
|
|
|
1243 |
this.vectRubrique.add(rowVals);
|
|
|
1244 |
} catch (NumberFormatException e) {
|
|
|
1245 |
JOptionPane.showMessageDialog(null, "Une des formules de la rubrique de commentaire " + rowSource.getString("CODE") + " -- " + rowSource.getString("NOM") + " n'est pas correcte!");
|
151 |
ilm |
1246 |
}
|
18 |
ilm |
1247 |
}
|
|
|
1248 |
|
|
|
1249 |
private void calculValue() {
|
|
|
1250 |
|
|
|
1251 |
System.err.println("Start calculValue At " + new Date());
|
|
|
1252 |
|
|
|
1253 |
resetValueFiche();
|
|
|
1254 |
|
|
|
1255 |
Vector<SQLRowValues> vectTmp = new Vector<SQLRowValues>(this.vectRubrique);
|
|
|
1256 |
|
|
|
1257 |
this.vectRubrique = new Vector<SQLRowValues>();
|
|
|
1258 |
for (int i = 0; i < vectTmp.size(); i++) {
|
|
|
1259 |
|
|
|
1260 |
SQLRowValues rowVals = vectTmp.get(i);
|
|
|
1261 |
String source = rowVals.getString("SOURCE");
|
|
|
1262 |
int idSource = rowVals.getInt("IDSOURCE");
|
|
|
1263 |
SQLRow row = tableFichePayeElt.getRow(rowVals.getID());
|
|
|
1264 |
|
|
|
1265 |
if (source.trim().length() != 0) {
|
|
|
1266 |
|
|
|
1267 |
if (this.mapTableSource.get(source) != null) {
|
|
|
1268 |
SQLRow rowSource = this.mapTableSource.get(source).getRow(idSource);
|
|
|
1269 |
|
|
|
1270 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_BRUT")) {
|
|
|
1271 |
loadElementBrut(rowSource, row);
|
|
|
1272 |
}
|
|
|
1273 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_COTISATION")) {
|
|
|
1274 |
loadElementCotisation(rowSource, row);
|
|
|
1275 |
}
|
|
|
1276 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_NET")) {
|
|
|
1277 |
loadElementNet(rowSource, row);
|
|
|
1278 |
}
|
|
|
1279 |
if (rowSource.getTable().getName().equalsIgnoreCase("RUBRIQUE_COMM")) {
|
|
|
1280 |
loadElementComm(rowSource, row);
|
|
|
1281 |
}
|
|
|
1282 |
} else {
|
|
|
1283 |
System.err.println("Table " + source + " non référencée");
|
|
|
1284 |
}
|
|
|
1285 |
}
|
|
|
1286 |
}
|
|
|
1287 |
System.err.println(this.vectRubrique.size() + " elements ADDed ");
|
144 |
ilm |
1288 |
updateValueFiche();
|
18 |
ilm |
1289 |
fireTableDataChanged();
|
|
|
1290 |
|
|
|
1291 |
System.err.println("End calculValue At " + new Date());
|
|
|
1292 |
}
|
|
|
1293 |
|
|
|
1294 |
public void validElt() {
|
|
|
1295 |
|
|
|
1296 |
System.err.println("Validation des éléments de la fiche.");
|
|
|
1297 |
for (int i = 0; i < this.vectRubrique.size(); i++) {
|
|
|
1298 |
SQLRowValues rowVals = this.vectRubrique.get(i);
|
|
|
1299 |
rowVals.put("VALIDE", Boolean.valueOf(true));
|
|
|
1300 |
|
|
|
1301 |
try {
|
|
|
1302 |
rowVals.commit();
|
|
|
1303 |
} catch (SQLException e) {
|
|
|
1304 |
e.printStackTrace();
|
|
|
1305 |
}
|
|
|
1306 |
}
|
|
|
1307 |
System.err.println("Validation terminée.");
|
|
|
1308 |
}
|
|
|
1309 |
}
|