Line 14... |
Line 14... |
14 |
package org.openconcerto.erp.generationEcritures;
|
14 |
package org.openconcerto.erp.generationEcritures;
|
15 |
|
15 |
|
16 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
16 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
17 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
|
17 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
|
18 |
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
|
18 |
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
|
- |
|
19 |
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
|
19 |
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
|
20 |
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
|
20 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
21 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
- |
|
22 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
21 |
import org.openconcerto.erp.model.PrixTTC;
|
23 |
import org.openconcerto.erp.model.PrixTTC;
|
22 |
import org.openconcerto.sql.model.SQLRow;
|
24 |
import org.openconcerto.sql.model.SQLRow;
|
23 |
import org.openconcerto.sql.model.SQLRowValues;
|
25 |
import org.openconcerto.sql.model.SQLRowValues;
|
24 |
import org.openconcerto.sql.model.SQLTable;
|
26 |
import org.openconcerto.sql.model.SQLTable;
|
25 |
import org.openconcerto.utils.ExceptionHandler;
|
27 |
import org.openconcerto.utils.ExceptionHandler;
|
26 |
|
28 |
|
27 |
import java.sql.SQLException;
|
29 |
import java.sql.SQLException;
|
- |
|
30 |
import java.sql.Timestamp;
|
28 |
import java.text.DateFormat;
|
31 |
import java.text.DateFormat;
|
29 |
import java.text.SimpleDateFormat;
|
32 |
import java.text.SimpleDateFormat;
|
- |
|
33 |
import java.util.ArrayList;
|
30 |
import java.util.Calendar;
|
34 |
import java.util.Calendar;
|
31 |
import java.util.Date;
|
35 |
import java.util.Date;
|
32 |
import java.util.HashMap;
|
36 |
import java.util.HashMap;
|
- |
|
37 |
import java.util.List;
|
33 |
import java.util.Map;
|
38 |
import java.util.Map;
|
34 |
|
39 |
|
35 |
// FIXME mettre toute les generations dans des threads à part
|
40 |
// FIXME mettre toute les generations dans des threads à part
|
36 |
public final class GenerationMvtReglementFactureFournisseur extends GenerationEcritures implements Runnable {
|
41 |
public final class GenerationMvtReglementFactureFournisseur extends GenerationEcritures implements Runnable {
|
37 |
|
42 |
|
Line 76... |
Line 81... |
76 |
this.date = (Date) saisieRow.getObject("DATE");
|
81 |
this.date = (Date) saisieRow.getObject("DATE");
|
77 |
SQLRow rowFournisseur = base.getTable("FOURNISSEUR").getRow(saisieRow.getInt("ID_FOURNISSEUR"));
|
82 |
SQLRow rowFournisseur = base.getTable("FOURNISSEUR").getRow(saisieRow.getInt("ID_FOURNISSEUR"));
|
78 |
this.nom = "Règlement Achat : " + rowFournisseur.getString("NOM") + " Facture : " + saisieRow.getObject("NUMERO").toString() + " (" + typeRegRow.getString("NOM") + ")";
|
83 |
this.nom = "Règlement Achat : " + rowFournisseur.getString("NOM") + " Facture : " + saisieRow.getObject("NUMERO").toString() + " (" + typeRegRow.getString("NOM") + ")";
|
79 |
|
84 |
|
80 |
// si paiement comptant
|
85 |
// si paiement comptant
|
81 |
if ((modeRegRow.getInt("AJOURS") == 0) && (modeRegRow.getInt("LENJOUR") == 0)) {
|
86 |
if ((modeRegRow.getInt("AJOURS") == 0) && (modeRegRow.getInt("LENJOUR") == 0) && !typeRegRow.getBoolean("ECHEANCE")) {
|
82 |
|
87 |
|
83 |
System.out.println("Règlement Comptant");
|
88 |
System.out.println("Règlement Comptant");
|
84 |
// test Cheque
|
89 |
// test Cheque
|
85 |
if (typeRegRow.getID() == 2) {
|
90 |
if (typeRegRow.getID() == 2) {
|
86 |
Calendar c = modeRegRow.getDate("DATE_DEPOT");
|
91 |
Calendar c = modeRegRow.getDate("DATE_DEPOT");
|
Line 132... |
Line 137... |
132 |
}
|
137 |
}
|
133 |
this.putValue("DEBIT", Long.valueOf(0));
|
138 |
this.putValue("DEBIT", Long.valueOf(0));
|
134 |
this.putValue("CREDIT", Long.valueOf(prixTTC.getLongValue()));
|
139 |
this.putValue("CREDIT", Long.valueOf(prixTTC.getLongValue()));
|
135 |
ajoutEcriture();
|
140 |
ajoutEcriture();
|
136 |
}
|
141 |
}
|
- |
|
142 |
setDateReglement(saisieRow, this.date);
|
137 |
} else {
|
143 |
} else {
|
138 |
|
144 |
|
139 |
Date dateEch = ModeDeReglementSQLElement.calculDate(modeRegRow.getInt("AJOURS"), modeRegRow.getInt("LENJOUR"), this.date);
|
145 |
Date dateEch = ModeDeReglementSQLElement.calculDate(modeRegRow.getInt("AJOURS"), modeRegRow.getInt("LENJOUR"), this.date);
|
140 |
DateFormat dateFormat = new SimpleDateFormat();
|
146 |
DateFormat dateFormat = new SimpleDateFormat();
|
141 |
System.out.println("Date d'échéance " + dateFormat.format(dateEch));
|
147 |
System.out.println("Date d'échéance " + dateFormat.format(dateEch));
|
Line 149... |
Line 155... |
149 |
} else {
|
155 |
} else {
|
150 |
|
156 |
|
151 |
// Ajout dans echeance
|
157 |
// Ajout dans echeance
|
152 |
Map<String, Object> mEcheance = new HashMap<String, Object>();
|
158 |
Map<String, Object> mEcheance = new HashMap<String, Object>();
|
153 |
|
159 |
|
- |
|
160 |
SQLTable echeanceTable = base.getTable("ECHEANCE_FOURNISSEUR");
|
154 |
SQLRow rowMvtPere = tableMouvement.getRow(this.idPere);
|
161 |
SQLRow rowMvtPere = tableMouvement.getRow(this.idPere);
|
155 |
this.idMvt = getNewMouvement("ECHEANCE_FOURNISSEUR", 1, this.idPere, rowMvtPere.getInt("ID_PIECE"));
|
162 |
this.idMvt = getNewMouvement("ECHEANCE_FOURNISSEUR", 1, this.idPere, rowMvtPere.getInt("ID_PIECE"));
|
156 |
|
163 |
|
157 |
mEcheance.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
|
164 |
mEcheance.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
|
158 |
mEcheance.put("DATE", new java.sql.Date(dateEch.getTime()));
|
165 |
mEcheance.put("DATE", new java.sql.Date(dateEch.getTime()));
|
159 |
mEcheance.put("MONTANT", Long.valueOf(prixTTC.getLongValue()));
|
166 |
mEcheance.put("MONTANT", Long.valueOf(prixTTC.getLongValue()));
|
160 |
mEcheance.put("ID_FOURNISSEUR", Integer.valueOf(saisieRow.getInt("ID_FOURNISSEUR")));
|
167 |
mEcheance.put("ID_FOURNISSEUR", saisieRow.getForeignID("ID_FOURNISSEUR"));
|
- |
|
168 |
mEcheance.put("ID_FACTURE_FOURNISSEUR", saisieRow.getID());
|
- |
|
169 |
if (saisieRow.getTable().contains("ID_AFFAIRE") && echeanceTable.contains("ID_AFFAIRE")) {
|
- |
|
170 |
if (!saisieRow.isForeignEmpty("ID_AFFAIRE")) {
|
- |
|
171 |
mEcheance.put("ID_AFFAIRE", saisieRow.getForeignID("ID_AFFAIRE"));
|
- |
|
172 |
}
|
- |
|
173 |
}
|
161 |
|
174 |
|
162 |
SQLTable echeanceTable = base.getTable("ECHEANCE_FOURNISSEUR");
|
- |
|
163 |
SQLRowValues valEcheance = new SQLRowValues(echeanceTable, mEcheance);
|
175 |
SQLRowValues valEcheance = new SQLRowValues(echeanceTable, mEcheance);
|
164 |
|
176 |
|
165 |
if (valEcheance.getInvalid() == null) {
|
177 |
if (valEcheance.getInvalid() == null) {
|
166 |
// ajout de l'ecriture
|
178 |
// ajout de l'ecriture
|
167 |
SQLRow row = valEcheance.insert();
|
179 |
SQLRow row = valEcheance.insert();
|
Line 225... |
Line 237... |
225 |
rowVals.update(this.idMvt);
|
237 |
rowVals.update(this.idMvt);
|
226 |
}
|
238 |
}
|
227 |
|
239 |
|
228 |
}
|
240 |
}
|
229 |
|
241 |
|
- |
|
242 |
private void setDateReglement(SQLRow source, Date d) throws SQLException {
|
- |
|
243 |
|
- |
|
244 |
SQLRowValues rowValsUpdateVF = source.createEmptyUpdateRow();
|
- |
|
245 |
rowValsUpdateVF.put("DATE_REGLEMENT", d);
|
- |
|
246 |
rowValsUpdateVF.update();
|
- |
|
247 |
|
- |
|
248 |
}
|
- |
|
249 |
|
230 |
public void run() {
|
250 |
public void run() {
|
231 |
try {
|
251 |
try {
|
232 |
genereReglement();
|
252 |
genereReglement();
|
233 |
} catch (Exception e) {
|
253 |
} catch (Exception e) {
|
234 |
ExceptionHandler.handle("Erreur pendant la générations des écritures comptables", e);
|
254 |
ExceptionHandler.handle("Erreur pendant la générations des écritures comptables", e);
|