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.core.finance.accounting.report;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
|
|
17 |
import org.openconcerto.erp.config.Gestion;
|
|
|
18 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
|
|
|
19 |
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte;
|
|
|
20 |
import org.openconcerto.erp.preferences.TemplateNXProps;
|
|
|
21 |
import org.openconcerto.map.model.Ville;
|
|
|
22 |
import org.openconcerto.sql.Configuration;
|
|
|
23 |
import org.openconcerto.sql.model.SQLBase;
|
|
|
24 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
25 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
26 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
27 |
import org.openconcerto.utils.GestionDevise;
|
|
|
28 |
|
|
|
29 |
import java.io.File;
|
|
|
30 |
import java.text.DateFormat;
|
|
|
31 |
import java.text.SimpleDateFormat;
|
|
|
32 |
import java.util.Calendar;
|
|
|
33 |
import java.util.Date;
|
|
|
34 |
import java.util.HashMap;
|
|
|
35 |
import java.util.Map;
|
|
|
36 |
|
|
|
37 |
import javax.swing.JOptionPane;
|
|
|
38 |
import javax.swing.JProgressBar;
|
|
|
39 |
import javax.swing.SwingUtilities;
|
|
|
40 |
|
|
|
41 |
public class Map3310 extends Thread {
|
|
|
42 |
|
|
|
43 |
private Map<String, Object> m;
|
|
|
44 |
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
|
|
|
45 |
private JProgressBar bar;
|
|
|
46 |
private Date dateDebut, dateFin;
|
|
|
47 |
|
|
|
48 |
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
49 |
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
|
|
|
50 |
private static final SQLTable tableCompte = Configuration.getInstance().getRoot().findTable("COMPTE_PCE");
|
|
|
51 |
private SQLRowValues rowPrefCompteVals = new SQLRowValues(tablePrefCompte);
|
|
|
52 |
SommeCompte sommeCompte;
|
|
|
53 |
|
|
|
54 |
private static String getVille(final String name) {
|
|
|
55 |
|
|
|
56 |
Ville ville = Ville.getVilleFromVilleEtCode(name);
|
|
|
57 |
if (ville == null) {
|
|
|
58 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
59 |
public void run() {
|
|
|
60 |
JOptionPane.showMessageDialog(null, "La ville " + "\"" + name + "\"" + " est introuvable! Veuillez corriger l'erreur!");
|
|
|
61 |
}
|
|
|
62 |
});
|
|
|
63 |
return null;
|
|
|
64 |
}
|
|
|
65 |
return ville.getName();
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
private static String getVilleCP(String name) {
|
|
|
69 |
Ville ville = Ville.getVilleFromVilleEtCode(name);
|
|
|
70 |
if (ville == null) {
|
|
|
71 |
|
|
|
72 |
return null;
|
|
|
73 |
}
|
|
|
74 |
return ville.getCodepostal();
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
// TODO if value = 0.0 ne pas mettre -0.0
|
|
|
78 |
|
|
|
79 |
public void run() {
|
|
|
80 |
|
|
|
81 |
SQLRow rowPrefCompte = tablePrefCompte.getRow(2);
|
|
|
82 |
this.rowPrefCompteVals.loadAbsolutelyAll(rowPrefCompte);
|
|
|
83 |
// TVA Coll
|
|
|
84 |
int idCompteTVACol = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_TVA_VENTE");
|
|
|
85 |
if (idCompteTVACol <= 1) {
|
|
|
86 |
String compte;
|
|
|
87 |
try {
|
|
|
88 |
compte = ComptePCESQLElement.getComptePceDefault("TVACollectee");
|
|
|
89 |
idCompteTVACol = ComptePCESQLElement.getId(compte);
|
|
|
90 |
} catch (Exception e) {
|
|
|
91 |
e.printStackTrace();
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
SQLRow rowCompteTVACol = tableCompte.getRow(idCompteTVACol);
|
|
|
95 |
|
|
|
96 |
// TVA Ded
|
|
|
97 |
int idCompteTVADed = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_TVA_ACHAT");
|
|
|
98 |
if (idCompteTVADed <= 1) {
|
|
|
99 |
try {
|
|
|
100 |
String compte = ComptePCESQLElement.getComptePceDefault("TVADeductible");
|
|
|
101 |
idCompteTVADed = ComptePCESQLElement.getId(compte);
|
|
|
102 |
} catch (Exception e) {
|
|
|
103 |
e.printStackTrace();
|
|
|
104 |
}
|
|
|
105 |
}
|
|
|
106 |
SQLRow rowCompteTVADed = tableCompte.getRow(idCompteTVADed);
|
|
|
107 |
|
|
|
108 |
// TVA intracomm
|
|
|
109 |
int idCompteTVAIntra = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_TVA_INTRA");
|
|
|
110 |
if (idCompteTVAIntra <= 1) {
|
|
|
111 |
try {
|
|
|
112 |
String compte = ComptePCESQLElement.getComptePceDefault("TVAIntraComm");
|
|
|
113 |
idCompteTVAIntra = ComptePCESQLElement.getId(compte);
|
|
|
114 |
} catch (Exception e) {
|
|
|
115 |
e.printStackTrace();
|
|
|
116 |
}
|
|
|
117 |
}
|
|
|
118 |
SQLRow rowCompteTVAIntra = tableCompte.getRow(idCompteTVAIntra);
|
|
|
119 |
|
|
|
120 |
// Achats intracomm
|
|
|
121 |
int idCompteAchatsIntra = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_ACHAT_INTRA");
|
|
|
122 |
if (idCompteAchatsIntra <= 1) {
|
|
|
123 |
try {
|
|
|
124 |
String compte = ComptePCESQLElement.getComptePceDefault("AchatsIntra");
|
|
|
125 |
idCompteAchatsIntra = ComptePCESQLElement.getId(compte);
|
|
|
126 |
} catch (Exception e) {
|
|
|
127 |
e.printStackTrace();
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
SQLRow rowCompteAchatIntra = tableCompte.getRow(idCompteAchatsIntra);
|
|
|
131 |
|
|
|
132 |
// TVA immo
|
|
|
133 |
int idCompteTVAImmo = this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_TVA_IMMO");
|
|
|
134 |
if (idCompteTVAImmo <= 1) {
|
|
|
135 |
try {
|
|
|
136 |
String compte = ComptePCESQLElement.getComptePceDefault("TVAImmo");
|
|
|
137 |
idCompteTVAImmo = ComptePCESQLElement.getId(compte);
|
|
|
138 |
} catch (Exception e) {
|
|
|
139 |
e.printStackTrace();
|
|
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
SQLRow rowCompteTVAImmo = tableCompte.getRow(idCompteTVAImmo);
|
|
|
143 |
|
|
|
144 |
PdfGenerator_3310 p = new PdfGenerator_3310();
|
|
|
145 |
this.m = new HashMap<String, Object>();
|
|
|
146 |
|
|
|
147 |
long v010 = -this.sommeCompte.soldeCompte(70, 70, true, this.dateDebut, this.dateFin);
|
21 |
ilm |
148 |
this.m.put("A01", GestionDevise.round(v010));
|
18 |
ilm |
149 |
|
|
|
150 |
// long vA02 = this.sommeCompte.soldeCompte(70, 70, true, this.dateDebut, this.dateFin);
|
|
|
151 |
this.m.put("A02", "");
|
41 |
ilm |
152 |
long tvaIntra = -this.sommeCompte.sommeCompteFils(rowCompteTVAIntra.getString("NUMERO"), this.dateDebut, this.dateFin);
|
18 |
ilm |
153 |
long achatsIntra = this.sommeCompte.sommeCompteFils(rowCompteAchatIntra.getString("NUMERO"), this.dateDebut, this.dateFin);
|
21 |
ilm |
154 |
this.m.put("A03", GestionDevise.round(achatsIntra));
|
18 |
ilm |
155 |
this.m.put("A04", "");
|
|
|
156 |
this.m.put("A05", "");
|
|
|
157 |
this.m.put("A06", "");
|
|
|
158 |
this.m.put("A07", "");
|
|
|
159 |
|
41 |
ilm |
160 |
long tvaCol = -this.sommeCompte.sommeCompteFils(rowCompteTVACol.getString("NUMERO"), this.dateDebut, this.dateFin) + tvaIntra;
|
21 |
ilm |
161 |
this.m.put("B08", GestionDevise.round(tvaCol));
|
|
|
162 |
this.m.put("B08HT", GestionDevise.round(Math.round(tvaCol / 0.196)));
|
18 |
ilm |
163 |
this.m.put("B09", "");
|
|
|
164 |
this.m.put("B09HT", "");
|
|
|
165 |
this.m.put("B09B", "");
|
|
|
166 |
this.m.put("B09BHT", "");
|
|
|
167 |
|
|
|
168 |
this.m.put("B10", "");
|
|
|
169 |
this.m.put("B10HT", "");
|
|
|
170 |
this.m.put("B11", "");
|
|
|
171 |
this.m.put("B11HT", "");
|
|
|
172 |
this.m.put("B12", "");
|
|
|
173 |
this.m.put("B12HT", "");
|
|
|
174 |
this.m.put("B13", "");
|
|
|
175 |
this.m.put("B13HT", "");
|
|
|
176 |
this.m.put("B14", "");
|
|
|
177 |
this.m.put("B14HT", "");
|
|
|
178 |
|
|
|
179 |
this.m.put("B15", "");
|
21 |
ilm |
180 |
this.m.put("B16", GestionDevise.round(tvaCol));
|
|
|
181 |
this.m.put("B17", GestionDevise.round(tvaIntra));
|
18 |
ilm |
182 |
this.m.put("B18", "");
|
41 |
ilm |
183 |
long tvaImmo = this.sommeCompte.sommeCompteFils(rowCompteTVAImmo.getString("NUMERO"), this.dateDebut, this.dateFin);
|
21 |
ilm |
184 |
this.m.put("B19", GestionDevise.round(tvaImmo));
|
18 |
ilm |
185 |
|
41 |
ilm |
186 |
long tvaAutre = this.sommeCompte.sommeCompteFils(rowCompteTVADed.getString("NUMERO"), this.dateDebut, this.dateFin);
|
21 |
ilm |
187 |
this.m.put("B20", GestionDevise.round(tvaAutre));
|
18 |
ilm |
188 |
this.m.put("B21", "");
|
|
|
189 |
this.m.put("B22", "");
|
|
|
190 |
this.m.put("B23", "");
|
21 |
ilm |
191 |
long tvaDed = tvaAutre + tvaImmo;
|
|
|
192 |
this.m.put("B24", GestionDevise.round(tvaDed));
|
18 |
ilm |
193 |
|
|
|
194 |
this.m.put("C25", "");
|
|
|
195 |
this.m.put("C26", "");
|
|
|
196 |
this.m.put("C27", "");
|
21 |
ilm |
197 |
this.m.put("C28", GestionDevise.round(tvaCol - tvaDed));
|
18 |
ilm |
198 |
this.m.put("C29", "");
|
|
|
199 |
this.m.put("C30", "");
|
|
|
200 |
this.m.put("C31", "");
|
21 |
ilm |
201 |
this.m.put("C32", GestionDevise.round(tvaCol - tvaDed));
|
18 |
ilm |
202 |
|
|
|
203 |
p.generateFrom(this.m);
|
|
|
204 |
|
|
|
205 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
206 |
public void run() {
|
|
|
207 |
Map3310.this.bar.setValue(95);
|
|
|
208 |
}
|
|
|
209 |
});
|
|
|
210 |
|
|
|
211 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
212 |
public void run() {
|
|
|
213 |
|
|
|
214 |
String file = TemplateNXProps.getInstance().getStringProperty("Location3310PDF") + File.separator + String.valueOf(Calendar.getInstance().get(Calendar.YEAR)) + File.separator
|
|
|
215 |
+ "result_3310_2.pdf";
|
|
|
216 |
System.err.println(file);
|
|
|
217 |
File f = new File(file);
|
|
|
218 |
Gestion.openPDF(f);
|
|
|
219 |
Map3310.this.bar.setValue(100);
|
|
|
220 |
}
|
|
|
221 |
});
|
|
|
222 |
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
public Map3310(JProgressBar bar, Date dateDeb, Date dateFin) {
|
|
|
226 |
|
|
|
227 |
this.bar = bar;
|
|
|
228 |
|
|
|
229 |
if (dateDeb == null && dateFin == null) {
|
|
|
230 |
SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
|
|
|
231 |
SQLRow rowExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON").getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
|
|
|
232 |
dateFin = (Date) rowExercice.getObject("DATE_FIN");
|
|
|
233 |
dateDeb = (Date) rowExercice.getObject("DATE_DEB");
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
this.dateDebut = dateDeb;
|
|
|
237 |
this.dateFin = dateFin;
|
|
|
238 |
this.sommeCompte = new SommeCompte();
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
public Map3310(JProgressBar bar) {
|
|
|
242 |
|
|
|
243 |
this(bar, null, null);
|
|
|
244 |
}
|
|
|
245 |
|
|
|
246 |
public void generateMap2033A() {
|
|
|
247 |
this.start();
|
|
|
248 |
}
|
|
|
249 |
}
|