OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
144 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.sales.order.element;
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.erp.core.common.ui.DeviseTableCellRenderer;
18
import org.openconcerto.sql.element.SQLComponent;
19
import org.openconcerto.sql.element.UISQLComponent;
177 ilm 20
import org.openconcerto.sql.view.list.SQLTableModelColumn;
144 ilm 21
import org.openconcerto.sql.view.list.SQLTableModelSource;
22
import org.openconcerto.utils.ListMap;
23
 
24
import java.util.ArrayList;
177 ilm 25
import java.util.HashSet;
144 ilm 26
import java.util.List;
177 ilm 27
import java.util.Set;
144 ilm 28
 
29
public class ChiffrageCommandeClientSQLElement extends ComptaSQLConfElement {
30
 
31
    public ChiffrageCommandeClientSQLElement() {
32
        super("CHIFFRAGE_COMMANDE_CLIENT", "un chiffrage de commande client", "chffrages commandes clients");
33
 
34
    }
35
 
177 ilm 36
    @Override
37
    public Set<String> getReadOnlyFields() {
38
        Set<String> s = new HashSet<>();
39
        s.add("NOM");
40
        s.add("ID_FAMILLE_ARTICLE");
41
        s.add("PA_HT");
42
        s.add("PV_HT");
43
        s.add("QTE");
44
        s.add("ID_UNITE_VENTE");
45
        s.add("T_PA_HT");
46
        s.add("T_PV_HT");
47
        return s;
48
    }
49
 
144 ilm 50
    /*
51
     * (non-Javadoc)
52
     *
53
     * @see org.openconcerto.devis.BaseSQLElement#getComboFields()
54
     */
55
    protected List<String> getComboFields() {
56
        final List<String> l = new ArrayList<String>();
149 ilm 57
        // remove id_commande_client for CIM
58
        if (!getTable().getDBRoot().contains("ID_AFFAIRE")) {
59
            l.add("ID_COMMANDE_CLIENT");
60
        }
144 ilm 61
        l.add("NOM");
62
        return l;
63
    }
64
 
65
    @Override
66
    protected String getParentFFName() {
67
        return "ID_COMMANDE_CLIENT";
68
    }
69
 
70
    @Override
71
    protected void _initTableSource(SQLTableModelSource res) {
72
        super._initTableSource(res);
149 ilm 73
 
177 ilm 74
        SQLTableModelColumn columnQte = res.getColumn(getTable().getField("QTE"));
75
        if (columnQte != null) {
76
            columnQte.setRenderer(new DeviseTableCellRenderer());
77
        }
78
 
79
        if (getTable().contains("ANT")) {
80
            final SQLTableModelColumn columnAnt = res.getColumn(getTable().getField("ANT"));
81
            if (columnAnt != null) {
82
                columnAnt.setRenderer(new DeviseTableCellRenderer());
83
            }
84
        }
85
 
86
        final SQLTableModelColumn columnPA = res.getColumn(getTable().getField("PA_HT"));
87
        if (columnPA != null) {
88
            columnPA.setRenderer(new DeviseTableCellRenderer());
89
        }
90
        final SQLTableModelColumn columnmarge = res.getColumn(getTable().getField("MARGE"));
91
        if (columnmarge != null) {
92
            columnmarge.setRenderer(new DeviseTableCellRenderer());
93
        }
94
        SQLTableModelColumn column = res.getColumn(getTable().getField("T_PA_HT"));
95
        if (column != null) {
96
            column.setRenderer(new DeviseTableCellRenderer());
97
        }
144 ilm 98
    }
99
 
100
    /*
101
     * (non-Javadoc)
102
     *
103
     * @see org.openconcerto.devis.BaseSQLElement#getListFields()
104
     */
105
    protected List<String> getListFields() {
106
        final List<String> l = new ArrayList<String>();
107
        l.add("ID_COMMANDE_CLIENT");
108
        l.add("NOM");
109
        l.add("ID_FAMILLE_ARTICLE");
110
        l.add("PA_HT");
111
        l.add("QTE");
112
        l.add("ID_UNITE_VENTE");
113
        l.add("T_PA_HT");
114
        l.add("MARGE");
115
        return l;
116
    }
117
 
118
    @Override
119
    public ListMap<String, String> getShowAs() {
120
        // TODO Auto-generated method stub
121
        ListMap<String, String> l = new ListMap<String, String>();
122
        l.putCollection(null, "ID_COMMANDE_CLIENT", "NOM", "ID_FAMILLE_ARTICLE", "PA_HT", "QTE", "T_PA_HT");
123
        return l;
124
    }
125
 
126
    /*
127
     * (non-Javadoc)
128
     *
129
     * @see org.openconcerto.devis.SQLElement#getComponent()
130
     */
131
    public SQLComponent createComponent() {
177 ilm 132
        return new UISQLComponent(this, 3) {
144 ilm 133
            public void addViews() {
177 ilm 134
                this.addView("NOM", "1");
135
                this.addView("ID_FAMILLE_ARTICLE", "1");
136
                this.addView("PA_HT", "1");
137
                this.addView("PV_HT", "1");
138
                this.addView("QTE", "1");
139
                if (getTable().contains("RESTANT")) {
140
                    this.addView("RESTANT", "1");
141
                }
142
                this.addView("ID_UNITE_VENTE", "1");
143
                this.addView("T_PA_HT", "1");
144
                this.addView("T_PV_HT", "1");
145
                if (getTable().contains("ANT")) {
146
                    this.addView("ANT", "1");
147
                }
148
                if (getTable().contains("MOTIF")) {
149
                    this.addView("MOTIF", "1");
150
                }
144 ilm 151
            }
152
        };
153
    }
154
 
155
    @Override
156
    protected String createCode() {
156 ilm 157
        return createCodeOfPackage() + ".chiffrage";
144 ilm 158
    }
159
 
160
}