Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
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
|
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
|
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.
|
9 |
* language governing permissions and limitations under the License.
|
Line 17... |
Line 17... |
17 |
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
|
17 |
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
|
18 |
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
|
18 |
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
|
19 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
19 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
20 |
import org.openconcerto.utils.GestionDevise;
|
20 |
import org.openconcerto.utils.GestionDevise;
|
21 |
|
21 |
|
- |
|
22 |
import java.text.SimpleDateFormat;
|
22 |
import java.util.Calendar;
|
23 |
import java.util.Calendar;
|
23 |
import java.util.Collection;
|
24 |
import java.util.Collection;
|
24 |
import java.util.HashSet;
|
25 |
import java.util.HashSet;
|
25 |
import java.util.Set;
|
26 |
import java.util.Set;
|
26 |
|
27 |
|
Line 29... |
Line 30... |
29 |
private enum TypeRecapFactureProvider {
|
30 |
private enum TypeRecapFactureProvider {
|
30 |
HT, TTC;
|
31 |
HT, TTC;
|
31 |
};
|
32 |
};
|
32 |
|
33 |
|
33 |
private final TypeRecapFactureProvider type;
|
34 |
private final TypeRecapFactureProvider type;
|
- |
|
35 |
private final boolean withDate, withAvoir;
|
34 |
|
36 |
|
35 |
public RecapFactureProvider(TypeRecapFactureProvider t) {
|
37 |
public RecapFactureProvider(TypeRecapFactureProvider t, boolean withDate, boolean withAvoir) {
|
36 |
this.type = t;
|
38 |
this.type = t;
|
- |
|
39 |
this.withDate = withDate;
|
- |
|
40 |
this.withAvoir = withAvoir;
|
37 |
}
|
41 |
}
|
38 |
|
42 |
|
39 |
public Object getValue(SpreadSheetCellValueContext context) {
|
43 |
public Object getValue(SpreadSheetCellValueContext context) {
|
40 |
SQLRowAccessor row = context.getRow();
|
44 |
SQLRowAccessor row = context.getRow();
|
41 |
Calendar c = row.getDate("DATE");
|
45 |
Calendar c = row.getDate("DATE");
|
Line 53... |
Line 57... |
53 |
return null;
|
57 |
return null;
|
54 |
}
|
58 |
}
|
55 |
}
|
59 |
}
|
56 |
|
60 |
|
57 |
public static void register() {
|
61 |
public static void register() {
|
58 |
SpreadSheetCellValueProviderManager.put("sales.account.history", new RecapFactureProvider(TypeRecapFactureProvider.HT));
|
62 |
SpreadSheetCellValueProviderManager.put("sales.account.history", new RecapFactureProvider(TypeRecapFactureProvider.HT, false, false));
|
59 |
SpreadSheetCellValueProviderManager.put("sales.account.history.ttc", new RecapFactureProvider(TypeRecapFactureProvider.TTC));
|
63 |
SpreadSheetCellValueProviderManager.put("sales.account.history.ttc", new RecapFactureProvider(TypeRecapFactureProvider.TTC, false, false));
|
- |
|
64 |
SpreadSheetCellValueProviderManager.put("sales.account.history.withdate", new RecapFactureProvider(TypeRecapFactureProvider.HT, true, false));
|
- |
|
65 |
SpreadSheetCellValueProviderManager.put("sales.account.history.ttc.withdate", new RecapFactureProvider(TypeRecapFactureProvider.TTC, true, false));
|
- |
|
66 |
SpreadSheetCellValueProviderManager.put("sales.account.history.with.credit", new RecapFactureProvider(TypeRecapFactureProvider.HT, false, true));
|
- |
|
67 |
SpreadSheetCellValueProviderManager.put("sales.account.history.with.credit.ttc", new RecapFactureProvider(TypeRecapFactureProvider.TTC, false, true));
|
- |
|
68 |
SpreadSheetCellValueProviderManager.put("sales.account.history.with.credit.withdate", new RecapFactureProvider(TypeRecapFactureProvider.HT, true, true));
|
- |
|
69 |
SpreadSheetCellValueProviderManager.put("sales.account.history.with.credit.ttc.withdate", new RecapFactureProvider(TypeRecapFactureProvider.TTC, true, true));
|
60 |
}
|
70 |
}
|
61 |
|
71 |
|
62 |
public String getPreviousAcompte(SQLRowAccessor sqlRowAccessor, Set<SQLRowAccessor> alreadyAdded, Calendar c) {
|
72 |
public String getPreviousAcompte(SQLRowAccessor sqlRowAccessor, Set<SQLRowAccessor> alreadyAdded, Calendar c) {
|
63 |
if (sqlRowAccessor == null || sqlRowAccessor.isUndefined()) {
|
73 |
if (sqlRowAccessor == null || sqlRowAccessor.isUndefined()) {
|
64 |
return "";
|
74 |
return "";
|
65 |
}
|
75 |
}
|
66 |
Collection<? extends SQLRowAccessor> rows = sqlRowAccessor.getReferentRows(sqlRowAccessor.getTable().getTable("TR_COMMANDE_CLIENT"));
|
76 |
Collection<? extends SQLRowAccessor> rows = sqlRowAccessor.getReferentRows(sqlRowAccessor.getTable().getTable("TR_COMMANDE_CLIENT"));
|
67 |
StringBuffer result = new StringBuffer();
|
77 |
StringBuffer result = new StringBuffer();
|
- |
|
78 |
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
|
68 |
for (SQLRowAccessor sqlRowAccessor2 : rows) {
|
79 |
for (SQLRowAccessor sqlRowAccessor2 : rows) {
|
69 |
SQLRowAccessor rowFact = sqlRowAccessor2.getForeign("ID_SAISIE_VENTE_FACTURE");
|
80 |
SQLRowAccessor rowFact = sqlRowAccessor2.getForeign("ID_SAISIE_VENTE_FACTURE");
|
70 |
|
81 |
|
71 |
if (rowFact != null && !rowFact.isUndefined() && !alreadyAdded.contains(rowFact) && rowFact.getDate("DATE").before(c)) {
|
82 |
if (rowFact != null && !rowFact.isUndefined() && !alreadyAdded.contains(rowFact) && rowFact.getDate("DATE").before(c)
|
- |
|
83 |
&& (!this.withAvoir || (this.withAvoir && rowFact.isForeignEmpty("ID_AVOIR_CLIENT")))) {
|
72 |
alreadyAdded.add(rowFact);
|
84 |
alreadyAdded.add(rowFact);
|
73 |
final String fieldTotal = this.type == TypeRecapFactureProvider.HT ? "T_HT" : "T_TTC";
|
85 |
final String fieldTotal = this.type == TypeRecapFactureProvider.HT ? "T_HT" : "T_TTC";
|
- |
|
86 |
result.append(rowFact.getString("NUMERO"));
|
- |
|
87 |
result.append(" (");
|
- |
|
88 |
if (this.withDate) {
|
- |
|
89 |
result.append(format.format(rowFact.getDate("DATE").getTime()) + " ");
|
- |
|
90 |
}
|
74 |
result.append(rowFact.getString("NUMERO") + " (" + GestionDevise.currencyToString(rowFact.getLong(fieldTotal)) + "€), ");
|
91 |
result.append(GestionDevise.currencyToString(rowFact.getLong(fieldTotal)) + "€), ");
|
- |
|
92 |
if (this.withDate) {
|
- |
|
93 |
result.append("\n");
|
- |
|
94 |
}
|
75 |
}
|
95 |
}
|
76 |
}
|
96 |
}
|
77 |
|
97 |
|
78 |
return result.toString();
|
98 |
return result.toString();
|
79 |
}
|
99 |
}
|