OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
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.sales.shipment.element;
14
 package org.openconcerto.erp.core.sales.shipment.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.erp.core.common.ui.DeviseField;
17
import org.openconcerto.erp.core.common.ui.DeviseField;
18
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
18
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
19
import org.openconcerto.sql.element.SQLComponent;
19
import org.openconcerto.sql.element.SQLComponent;
20
import org.openconcerto.sql.element.UISQLComponent;
20
import org.openconcerto.sql.element.UISQLComponent;
21
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.model.SQLRow;
22
import org.openconcerto.sql.model.SQLRowValues;
22
import org.openconcerto.sql.model.SQLRowValues;
23
import org.openconcerto.sql.sqlobject.ElementComboBox;
23
import org.openconcerto.sql.sqlobject.ElementComboBox;
24
import org.openconcerto.utils.ListMap;
24
import org.openconcerto.utils.ListMap;
25
 
25
 
26
import java.sql.SQLException;
26
import java.sql.SQLException;
27
import java.util.ArrayList;
27
import java.util.ArrayList;
28
import java.util.List;
28
import java.util.List;
29
 
29
 
30
import javax.swing.JTextField;
30
import javax.swing.JTextField;
31
 
31
 
32
public class BonDeLivraisonItemSQLElement extends ComptaSQLConfElement {
32
public class BonDeLivraisonItemSQLElement extends ComptaSQLConfElement {
33
 
33
 
34
    public BonDeLivraisonItemSQLElement() {
34
    public BonDeLivraisonItemSQLElement() {
35
        super("BON_DE_LIVRAISON_ELEMENT", "un element de bon de livraison", "éléments de bon de livraison");
35
        super("BON_DE_LIVRAISON_ELEMENT", "un element de bon de livraison", "éléments de bon de livraison");
36
    }
36
    }
37
 
37
 
38
    protected List<String> getListFields() {
38
    protected List<String> getListFields() {
39
        final List<String> l = new ArrayList<String>();
39
        final List<String> l = new ArrayList<String>();
-
 
40
        l.add("ID_BON_DE_LIVRAISON");
40
        l.add("CODE");
41
        l.add("CODE");
41
        l.add("NOM");
42
        l.add("NOM");
42
        l.add("PA_HT");
43
        l.add("PA_HT");
43
        l.add("PV_HT");
44
        l.add("PV_HT");
44
        l.add("QTE");
45
        l.add("QTE");
45
        l.add("QTE_LIVREE");
46
        l.add("QTE_LIVREE");
46
        l.add("QTE_A_LIVRER");
47
        l.add("QTE_A_LIVRER");
47
        l.add("ID_TAXE");
48
        l.add("ID_TAXE");
48
        l.add("POIDS");
49
        l.add("POIDS");
49
        l.add("T_PA_HT");
50
        l.add("T_PA_HT");
50
        l.add("T_PV_HT");
51
        l.add("T_PV_HT");
51
        return l;
52
        return l;
52
    }
53
    }
53
 
54
 
54
    protected List<String> getComboFields() {
55
    protected List<String> getComboFields() {
55
        final List<String> l = new ArrayList<String>();
56
        final List<String> l = new ArrayList<String>();
56
        l.add("CODE");
57
        l.add("CODE");
57
        l.add("NOM");
58
        l.add("NOM");
58
        l.add("PV_HT");
59
        l.add("PV_HT");
59
        l.add("QTE");
60
        l.add("QTE");
60
        return l;
61
        return l;
61
    }
62
    }
62
 
63
 
63
    @Override
64
    @Override
64
    protected String getParentFFName() {
65
    protected String getParentFFName() {
65
        return "ID_BON_DE_LIVRAISON";
66
        return "ID_BON_DE_LIVRAISON";
66
    }
67
    }
67
 
68
 
68
    @Override
69
    @Override
69
    public ListMap<String, String> getShowAs() {
70
    public ListMap<String, String> getShowAs() {
70
        final ListMap<String, String> res = new ListMap<String, String>();
71
        final ListMap<String, String> res = new ListMap<String, String>();
71
        res.putCollection("ID_BON_DE_LIVRAISON", "NUMERO");
72
        res.putCollection("ID_BON_DE_LIVRAISON", "NUMERO");
72
        return res;
73
        return res;
73
    }
74
    }
74
 
75
 
75
    /*
76
    /*
76
     * (non-Javadoc)
77
     * (non-Javadoc)
77
     * 
78
     * 
78
     * @see org.openconcerto.devis.SQLElement#getComponent()
79
     * @see org.openconcerto.devis.SQLElement#getComponent()
79
     */
80
     */
80
    public SQLComponent createComponent() {
81
    public SQLComponent createComponent() {
81
        return new UISQLComponent(this) {
82
        return new UISQLComponent(this) {
82
 
83
 
83
            public void addViews() {
84
            public void addViews() {
84
 
85
 
85
                this.addRequiredSQLObject(new JTextField(), "NOM", "left");
86
                this.addRequiredSQLObject(new JTextField(), "NOM", "left");
86
                this.addRequiredSQLObject(new JTextField(), "CODE", "right");
87
                this.addRequiredSQLObject(new JTextField(), "CODE", "right");
87
 
88
 
88
                this.addSQLObject(new ElementComboBox(), "ID_BON_DE_LIVRAISON", "left");
89
                this.addSQLObject(new ElementComboBox(), "ID_BON_DE_LIVRAISON", "left");
89
 
90
 
90
                this.addRequiredSQLObject(new DeviseField(), "PV_HT", "left");
91
                this.addRequiredSQLObject(new DeviseField(), "PV_HT", "left");
91
                this.addSQLObject(new JTextField(), "QTE", "right");
92
                this.addSQLObject(new JTextField(), "QTE", "right");
92
 
93
 
93
                this.addSQLObject(new JTextField(), "POIDS", "left");
94
                this.addSQLObject(new JTextField(), "POIDS", "left");
94
                this.addSQLObject(new ElementComboBox(), "ID_TAXE", "right");
95
                this.addSQLObject(new ElementComboBox(), "ID_TAXE", "right");
95
            }
96
            }
96
 
97
 
97
            public int insert(SQLRow order) {
98
            public int insert(SQLRow order) {
98
                int id = super.insert(order);
99
                int id = super.insert(order);
99
 
100
 
100
                SQLRow rowBon = getTable().getRow(id);
101
                SQLRow rowBon = getTable().getRow(id);
101
                SQLRow rowFact = getTable().getBase().getTable("BON_DE_LIVRAISON_ELEMENT").getRow(rowBon.getInt("ID_BON_DE_LIVRAISON_ELEMENT"));
102
                SQLRow rowFact = getTable().getBase().getTable("BON_DE_LIVRAISON_ELEMENT").getRow(rowBon.getInt("ID_BON_DE_LIVRAISON_ELEMENT"));
102
 
103
 
103
                int qteLivree = rowFact.getInt("QTE_LIVREE") + rowFact.getInt("QTE_LIVREE");
104
                int qteLivree = rowFact.getInt("QTE_LIVREE") + rowFact.getInt("QTE_LIVREE");
104
 
105
 
105
                SQLRowValues rowVals = new SQLRowValues(getDirectory().getElement(SaisieVenteFactureItemSQLElement.class).getTable());
106
                SQLRowValues rowVals = new SQLRowValues(getDirectory().getElement(SaisieVenteFactureItemSQLElement.class).getTable());
106
                rowVals.put("QTE_LIVREE", new Integer(qteLivree));
107
                rowVals.put("QTE_LIVREE", new Integer(qteLivree));
107
 
108
 
108
                try {
109
                try {
109
                    rowVals.update(rowFact.getID());
110
                    rowVals.update(rowFact.getID());
110
                } catch (SQLException e) {
111
                } catch (SQLException e) {
111
 
112
 
112
                    e.printStackTrace();
113
                    e.printStackTrace();
113
                }
114
                }
114
 
115
 
115
                return id;
116
                return id;
116
            }
117
            }
117
        };
118
        };
118
 
119
 
119
    }
120
    }
120
 
121
 
121
    @Override
122
    @Override
122
    protected String createCode() {
123
    protected String createCode() {
123
        return createCodeOfPackage() + ".item";
124
        return createCodeOfPackage() + ".item";
124
    }
125
    }
125
}
126
}