OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 177 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 180
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 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.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.core.finance.payment.element;
14
 package org.openconcerto.erp.core.finance.payment.element;
15
 
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.sql.element.SQLComponent;
17
import org.openconcerto.sql.element.SQLComponent;
18
import org.openconcerto.sql.model.FieldPath;
18
import org.openconcerto.sql.model.FieldPath;
19
import org.openconcerto.sql.model.SQLRowAccessor;
19
import org.openconcerto.sql.model.SQLRowAccessor;
20
import org.openconcerto.sql.model.graph.Path;
20
import org.openconcerto.sql.model.graph.Path;
21
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
21
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
22
import org.openconcerto.sql.view.list.SQLTableModelSource;
22
import org.openconcerto.sql.view.list.SQLTableModelSource;
23
import org.openconcerto.utils.CollectionUtils;
23
import org.openconcerto.utils.CollectionUtils;
24
 
24
 
25
import java.util.ArrayList;
25
import java.util.ArrayList;
-
 
26
import java.util.Collection;
26
import java.util.List;
27
import java.util.List;
27
import java.util.Set;
28
import java.util.Set;
28
 
29
 
29
public class ReglerMontantSQLElement extends ComptaSQLConfElement {
30
public class ReglerMontantSQLElement extends ComptaSQLConfElement {
30
 
31
 
31
    public ReglerMontantSQLElement() {
32
    public ReglerMontantSQLElement() {
32
        super("REGLER_MONTANT", "un règlement à un fournisseur", "règlements aux fournisseurs");
33
        super("REGLER_MONTANT", "un règlement à un fournisseur", "règlements aux fournisseurs");
33
    }
34
    }
34
 
35
 
35
    protected List<String> getListFields() {
36
    protected List<String> getListFields() {
36
        final List<String> l = new ArrayList<String>();
37
        final List<String> l = new ArrayList<String>();
37
        l.add("DATE");
38
        l.add("DATE");
38
        l.add("ID_FOURNISSEUR");
39
        l.add("ID_FOURNISSEUR");
39
        l.add("ID_MODE_REGLEMENT");
40
        l.add("ID_MODE_REGLEMENT");
40
        l.add("MONTANT");
41
        l.add("MONTANT");
41
        return l;
42
        return l;
42
    }
43
    }
43
 
44
 
44
    protected List<String> getComboFields() {
45
    protected List<String> getComboFields() {
45
        final List<String> l = new ArrayList<String>();
46
        final List<String> l = new ArrayList<String>();
46
        l.add("DATE");
47
        l.add("DATE");
47
        l.add("MONTANT");
48
        l.add("MONTANT");
48
        return l;
49
        return l;
49
    }
50
    }
50
 
51
 
51
    @Override
52
    @Override
52
    protected void _initTableSource(SQLTableModelSource res) {
53
    protected void _initTableSource(SQLTableModelSource res) {
53
        super._initTableSource(res);
54
        super._initTableSource(res);
-
 
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
 
54
        final BaseSQLTableModelColumn racCol = new BaseSQLTableModelColumn("Report échéance", Boolean.class) {
87
        final BaseSQLTableModelColumn racCol = new BaseSQLTableModelColumn("Report échéance", Boolean.class) {
55
            @Override
88
            @Override
56
            protected Object show_(SQLRowAccessor r) {
89
            protected Object show_(SQLRowAccessor r) {
57
 
90
 
58
                return !r.getForeign("ID_MODE_REGLEMENT").getBoolean("COMPTANT");
91
                return !r.getForeign("ID_MODE_REGLEMENT").getBoolean("COMPTANT");
59
            }
92
            }
60
 
93
 
61
            @Override
94
            @Override
62
            public Set<FieldPath> getPaths() {
95
            public Set<FieldPath> getPaths() {
63
                Path p = new Path(getTable());
96
                Path p = new Path(getTable());
64
                Path p2 = p.add(p.getLast().getField("ID_MODE_REGLEMENT"));
97
                Path p2 = p.add(p.getLast().getField("ID_MODE_REGLEMENT"));
65
                return CollectionUtils.createSet(new FieldPath(p2, "COMPTANT"));
98
                return CollectionUtils.createSet(new FieldPath(p2, "COMPTANT"));
66
            }
99
            }
67
        };
100
        };
68
 
101
 
69
        res.getColumns().add(racCol);
102
        res.getColumns().add(racCol);
70
    }
103
    }
71
 
104
 
72
    public SQLComponent createComponent() {
105
    public SQLComponent createComponent() {
73
        return new ReglerMontantSQLComponent(this);
106
        return new ReglerMontantSQLComponent(this);
74
    };
107
    };
75
 
108
 
76
    @Override
109
    @Override
77
    protected String createCode() {
110
    protected String createCode() {
78
        return createCodeOfPackage() + ".regulation";
111
        return createCodeOfPackage() + ".regulation";
79
    }
112
    }
80
}
113
}