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 | Details | Compare with Previous | Last modification | View Log | RSS feed

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