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.payment.element;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
|
|
17 |
import org.openconcerto.sql.element.SQLComponent;
|
177 |
ilm |
18 |
import org.openconcerto.sql.model.FieldPath;
|
|
|
19 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
20 |
import org.openconcerto.sql.model.graph.Path;
|
|
|
21 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
|
|
22 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
|
|
23 |
import org.openconcerto.utils.CollectionUtils;
|
18 |
ilm |
24 |
|
|
|
25 |
import java.util.ArrayList;
|
180 |
ilm |
26 |
import java.util.Collection;
|
18 |
ilm |
27 |
import java.util.List;
|
177 |
ilm |
28 |
import java.util.Set;
|
18 |
ilm |
29 |
|
|
|
30 |
public class ReglerMontantSQLElement extends ComptaSQLConfElement {
|
|
|
31 |
|
|
|
32 |
public ReglerMontantSQLElement() {
|
|
|
33 |
super("REGLER_MONTANT", "un règlement à un fournisseur", "règlements aux fournisseurs");
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
protected List<String> getListFields() {
|
|
|
37 |
final List<String> l = new ArrayList<String>();
|
|
|
38 |
l.add("DATE");
|
177 |
ilm |
39 |
l.add("ID_FOURNISSEUR");
|
18 |
ilm |
40 |
l.add("ID_MODE_REGLEMENT");
|
|
|
41 |
l.add("MONTANT");
|
|
|
42 |
return l;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
protected List<String> getComboFields() {
|
|
|
46 |
final List<String> l = new ArrayList<String>();
|
|
|
47 |
l.add("DATE");
|
|
|
48 |
l.add("MONTANT");
|
|
|
49 |
return l;
|
|
|
50 |
}
|
|
|
51 |
|
177 |
ilm |
52 |
@Override
|
|
|
53 |
protected void _initTableSource(SQLTableModelSource res) {
|
|
|
54 |
super._initTableSource(res);
|
180 |
ilm |
55 |
|
|
|
56 |
final BaseSQLTableModelColumn racColFact = new BaseSQLTableModelColumn("Factures associées", String.class) {
|
|
|
57 |
@Override
|
|
|
58 |
protected Object show_(SQLRowAccessor r) {
|
|
|
59 |
|
|
|
60 |
Collection<? extends SQLRowAccessor> l = r.getReferentRows(r.getTable().getTable("REGLER_MONTANT_ELEMENT"));
|
|
|
61 |
String s = "";
|
|
|
62 |
for (SQLRowAccessor sqlRowAccessor : l) {
|
|
|
63 |
if (!sqlRowAccessor.isForeignEmpty("ID_MOUVEMENT_ECHEANCE")) {
|
|
|
64 |
SQLRowAccessor rMvt = sqlRowAccessor.getForeign("ID_MOUVEMENT_ECHEANCE");
|
|
|
65 |
if (!rMvt.isForeignEmpty("ID_PIECE")) {
|
|
|
66 |
SQLRowAccessor rP = rMvt.getForeign("ID_PIECE");
|
|
|
67 |
s += (s.trim().length() > 0 ? ", " : "") + rP.getString("NOM");
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
return s;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
@Override
|
|
|
76 |
public Set<FieldPath> getPaths() {
|
|
|
77 |
Path p = new Path(getTable());
|
|
|
78 |
Path p2 = p.add(p.getLast().getTable("REGLER_MONTANT_ELEMENT"));
|
|
|
79 |
Path p3 = p2.add(p2.getLast().getField("ID_MOUVEMENT_ECHEANCE"));
|
|
|
80 |
Path p4 = p3.add(p3.getLast().getField("ID_PIECE"));
|
|
|
81 |
return CollectionUtils.createSet(new FieldPath(p4, "NOM"));
|
|
|
82 |
}
|
|
|
83 |
};
|
|
|
84 |
|
|
|
85 |
res.getColumns().add(racColFact);
|
|
|
86 |
|
177 |
ilm |
87 |
final BaseSQLTableModelColumn racCol = new BaseSQLTableModelColumn("Report échéance", Boolean.class) {
|
|
|
88 |
@Override
|
|
|
89 |
protected Object show_(SQLRowAccessor r) {
|
|
|
90 |
|
|
|
91 |
return !r.getForeign("ID_MODE_REGLEMENT").getBoolean("COMPTANT");
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
@Override
|
|
|
95 |
public Set<FieldPath> getPaths() {
|
|
|
96 |
Path p = new Path(getTable());
|
|
|
97 |
Path p2 = p.add(p.getLast().getField("ID_MODE_REGLEMENT"));
|
|
|
98 |
return CollectionUtils.createSet(new FieldPath(p2, "COMPTANT"));
|
|
|
99 |
}
|
|
|
100 |
};
|
|
|
101 |
|
|
|
102 |
res.getColumns().add(racCol);
|
|
|
103 |
}
|
|
|
104 |
|
18 |
ilm |
105 |
public SQLComponent createComponent() {
|
80 |
ilm |
106 |
return new ReglerMontantSQLComponent(this);
|
18 |
ilm |
107 |
};
|
57 |
ilm |
108 |
|
|
|
109 |
@Override
|
|
|
110 |
protected String createCode() {
|
156 |
ilm |
111 |
return createCodeOfPackage() + ".regulation";
|
57 |
ilm |
112 |
}
|
18 |
ilm |
113 |
}
|