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>();
|
|
|
40 |
l.add("CODE");
|
|
|
41 |
l.add("NOM");
|
156 |
ilm |
42 |
l.add("PA_HT");
|
18 |
ilm |
43 |
l.add("PV_HT");
|
|
|
44 |
l.add("QTE");
|
|
|
45 |
l.add("QTE_LIVREE");
|
|
|
46 |
l.add("QTE_A_LIVRER");
|
|
|
47 |
l.add("ID_TAXE");
|
|
|
48 |
l.add("POIDS");
|
156 |
ilm |
49 |
l.add("T_PA_HT");
|
|
|
50 |
l.add("T_PV_HT");
|
18 |
ilm |
51 |
return l;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
protected List<String> getComboFields() {
|
|
|
55 |
final List<String> l = new ArrayList<String>();
|
|
|
56 |
l.add("CODE");
|
|
|
57 |
l.add("NOM");
|
|
|
58 |
l.add("PV_HT");
|
|
|
59 |
l.add("QTE");
|
|
|
60 |
return l;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
@Override
|
132 |
ilm |
64 |
protected String getParentFFName() {
|
|
|
65 |
return "ID_BON_DE_LIVRAISON";
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
@Override
|
|
|
69 |
public ListMap<String, String> getShowAs() {
|
|
|
70 |
final ListMap<String, String> res = new ListMap<String, String>();
|
|
|
71 |
res.putCollection("ID_BON_DE_LIVRAISON", "NUMERO");
|
18 |
ilm |
72 |
return res;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/*
|
|
|
76 |
* (non-Javadoc)
|
|
|
77 |
*
|
|
|
78 |
* @see org.openconcerto.devis.SQLElement#getComponent()
|
|
|
79 |
*/
|
|
|
80 |
public SQLComponent createComponent() {
|
|
|
81 |
return new UISQLComponent(this) {
|
|
|
82 |
|
|
|
83 |
public void addViews() {
|
|
|
84 |
|
|
|
85 |
this.addRequiredSQLObject(new JTextField(), "NOM", "left");
|
|
|
86 |
this.addRequiredSQLObject(new JTextField(), "CODE", "right");
|
|
|
87 |
|
|
|
88 |
this.addSQLObject(new ElementComboBox(), "ID_BON_DE_LIVRAISON", "left");
|
|
|
89 |
|
|
|
90 |
this.addRequiredSQLObject(new DeviseField(), "PV_HT", "left");
|
|
|
91 |
this.addSQLObject(new JTextField(), "QTE", "right");
|
|
|
92 |
|
|
|
93 |
this.addSQLObject(new JTextField(), "POIDS", "left");
|
|
|
94 |
this.addSQLObject(new ElementComboBox(), "ID_TAXE", "right");
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
public int insert(SQLRow order) {
|
|
|
98 |
int id = super.insert(order);
|
|
|
99 |
|
|
|
100 |
SQLRow rowBon = getTable().getRow(id);
|
|
|
101 |
SQLRow rowFact = getTable().getBase().getTable("BON_DE_LIVRAISON_ELEMENT").getRow(rowBon.getInt("ID_BON_DE_LIVRAISON_ELEMENT"));
|
|
|
102 |
|
|
|
103 |
int qteLivree = rowFact.getInt("QTE_LIVREE") + rowFact.getInt("QTE_LIVREE");
|
|
|
104 |
|
80 |
ilm |
105 |
SQLRowValues rowVals = new SQLRowValues(getDirectory().getElement(SaisieVenteFactureItemSQLElement.class).getTable());
|
18 |
ilm |
106 |
rowVals.put("QTE_LIVREE", new Integer(qteLivree));
|
|
|
107 |
|
|
|
108 |
try {
|
|
|
109 |
rowVals.update(rowFact.getID());
|
|
|
110 |
} catch (SQLException e) {
|
|
|
111 |
|
|
|
112 |
e.printStackTrace();
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
return id;
|
|
|
116 |
}
|
|
|
117 |
};
|
|
|
118 |
|
|
|
119 |
}
|
|
|
120 |
|
57 |
ilm |
121 |
@Override
|
|
|
122 |
protected String createCode() {
|
156 |
ilm |
123 |
return createCodeOfPackage() + ".item";
|
57 |
ilm |
124 |
}
|
18 |
ilm |
125 |
}
|