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.ui;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
|
|
17 |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
|
94 |
ilm |
18 |
import org.openconcerto.erp.core.common.ui.Acompte;
|
|
|
19 |
import org.openconcerto.erp.core.common.ui.AcompteCellEditor;
|
142 |
ilm |
20 |
import org.openconcerto.erp.core.common.ui.DeviseNumericCellEditor;
|
73 |
ilm |
21 |
import org.openconcerto.erp.core.common.ui.DeviseNumericHTConvertorCellEditor;
|
|
|
22 |
import org.openconcerto.erp.core.common.ui.DeviseTableCellRenderer;
|
|
|
23 |
import org.openconcerto.erp.core.common.ui.QteCellEditor;
|
94 |
ilm |
24 |
import org.openconcerto.erp.core.common.ui.Remise;
|
93 |
ilm |
25 |
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
|
18 |
ilm |
26 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
142 |
ilm |
27 |
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
|
|
|
28 |
import org.openconcerto.erp.core.sales.pos.ui.BarcodeListener;
|
18 |
ilm |
29 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
|
|
30 |
import org.openconcerto.erp.core.sales.product.ui.ArticleRowValuesRenderer;
|
142 |
ilm |
31 |
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
|
|
|
32 |
import org.openconcerto.erp.core.sales.product.ui.DeliveredQtyRowValuesRenderer;
|
61 |
ilm |
33 |
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
|
142 |
ilm |
34 |
import org.openconcerto.erp.core.sales.product.ui.QtyToDeliverRowValuesRenderer;
|
|
|
35 |
import org.openconcerto.erp.core.sales.product.ui.ReliquatRowValuesTable;
|
18 |
ilm |
36 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
61 |
ilm |
37 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
18 |
ilm |
38 |
import org.openconcerto.sql.Configuration;
|
|
|
39 |
import org.openconcerto.sql.element.SQLElement;
|
67 |
ilm |
40 |
import org.openconcerto.sql.model.SQLField;
|
73 |
ilm |
41 |
import org.openconcerto.sql.model.SQLRow;
|
61 |
ilm |
42 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
142 |
ilm |
43 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
18 |
ilm |
44 |
import org.openconcerto.sql.model.SQLRowValues;
|
142 |
ilm |
45 |
import org.openconcerto.sql.model.SQLSelect;
|
61 |
ilm |
46 |
import org.openconcerto.sql.model.SQLTable;
|
80 |
ilm |
47 |
import org.openconcerto.sql.model.UndefinedRowValuesCache;
|
61 |
ilm |
48 |
import org.openconcerto.sql.model.Where;
|
|
|
49 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
132 |
ilm |
50 |
import org.openconcerto.sql.sqlobject.ITextArticleWithCompletionCellEditor;
|
61 |
ilm |
51 |
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
|
142 |
ilm |
52 |
import org.openconcerto.sql.users.rights.UserRights;
|
|
|
53 |
import org.openconcerto.sql.users.rights.UserRightsManager;
|
18 |
ilm |
54 |
import org.openconcerto.sql.view.list.AutoCompletionManager;
|
|
|
55 |
import org.openconcerto.sql.view.list.CellDynamicModifier;
|
|
|
56 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
|
|
57 |
import org.openconcerto.sql.view.list.RowValuesTableModel;
|
|
|
58 |
import org.openconcerto.sql.view.list.SQLTableElement;
|
93 |
ilm |
59 |
import org.openconcerto.sql.view.list.SQLTextComboTableCellEditor;
|
65 |
ilm |
60 |
import org.openconcerto.sql.view.list.ValidStateChecker;
|
18 |
ilm |
61 |
import org.openconcerto.ui.table.XTableColumnModel;
|
90 |
ilm |
62 |
import org.openconcerto.utils.DecimalUtils;
|
142 |
ilm |
63 |
import org.openconcerto.utils.Tuple3;
|
151 |
ilm |
64 |
import org.openconcerto.utils.cc.ITransformer;
|
142 |
ilm |
65 |
import org.openconcerto.utils.i18n.TranslationManager;
|
18 |
ilm |
66 |
|
94 |
ilm |
67 |
import java.awt.Component;
|
142 |
ilm |
68 |
import java.awt.event.ActionEvent;
|
|
|
69 |
import java.awt.event.HierarchyEvent;
|
|
|
70 |
import java.awt.event.HierarchyListener;
|
|
|
71 |
import java.awt.event.KeyEvent;
|
|
|
72 |
import java.awt.event.MouseAdapter;
|
|
|
73 |
import java.awt.event.MouseEvent;
|
61 |
ilm |
74 |
import java.math.BigDecimal;
|
67 |
ilm |
75 |
import java.math.RoundingMode;
|
18 |
ilm |
76 |
import java.util.ArrayList;
|
93 |
ilm |
77 |
import java.util.Date;
|
18 |
ilm |
78 |
import java.util.List;
|
|
|
79 |
import java.util.Vector;
|
|
|
80 |
|
142 |
ilm |
81 |
import javax.swing.AbstractAction;
|
18 |
ilm |
82 |
import javax.swing.JButton;
|
142 |
ilm |
83 |
import javax.swing.JFrame;
|
94 |
ilm |
84 |
import javax.swing.JLabel;
|
142 |
ilm |
85 |
import javax.swing.JPopupMenu;
|
94 |
ilm |
86 |
import javax.swing.JTable;
|
142 |
ilm |
87 |
import javax.swing.SwingUtilities;
|
18 |
ilm |
88 |
import javax.swing.ToolTipManager;
|
94 |
ilm |
89 |
import javax.swing.table.DefaultTableCellRenderer;
|
18 |
ilm |
90 |
import javax.swing.table.TableCellRenderer;
|
|
|
91 |
|
|
|
92 |
public class BonDeLivraisonItemTable extends AbstractVenteArticleItemTable {
|
|
|
93 |
|
|
|
94 |
// private final Map<Integer, Boolean> map = new HashMap<Integer, Boolean>();
|
|
|
95 |
|
|
|
96 |
private SQLTableElement tableElementPoidsTotalLivree;
|
61 |
ilm |
97 |
private SQLTable tableArticle = Configuration.getInstance().getBase().getTable("ARTICLE");
|
142 |
ilm |
98 |
private ReliquatRowValuesTable reliquatTable;
|
18 |
ilm |
99 |
|
|
|
100 |
public BonDeLivraisonItemTable(List<JButton> l) {
|
|
|
101 |
super(l);
|
|
|
102 |
}
|
|
|
103 |
|
142 |
ilm |
104 |
public void setReliquatTable(ReliquatRowValuesTable reliquatTable) {
|
|
|
105 |
this.reliquatTable = reliquatTable;
|
|
|
106 |
}
|
|
|
107 |
|
18 |
ilm |
108 |
@Override
|
|
|
109 |
protected void init() {
|
|
|
110 |
final SQLElement e = getSQLElement();
|
|
|
111 |
|
61 |
ilm |
112 |
SQLPreferences prefs = new SQLPreferences(getSQLElement().getTable().getDBRoot());
|
|
|
113 |
final boolean selectArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.USE_CREATED_ARTICLE, false);
|
|
|
114 |
final boolean createAuto = prefs.getBoolean(GestionArticleGlobalPreferencePanel.CREATE_ARTICLE_AUTO, true);
|
93 |
ilm |
115 |
final boolean filterFamilleArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.FILTER_BY_FAMILY, false);
|
142 |
ilm |
116 |
final boolean showEco = prefs.getBoolean(AbstractVenteArticleItemTable.SHOW_ECO_CONTRIBUTION_COLUMNS, false);
|
156 |
ilm |
117 |
final boolean showDevise = prefs.getBoolean(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false);
|
61 |
ilm |
118 |
|
142 |
ilm |
119 |
final UserRights rights = UserRightsManager.getCurrentUserRights();
|
|
|
120 |
final boolean editVTPrice = rights.haveRight(EDIT_PRIX_VENTE_CODE);
|
|
|
121 |
final boolean showHAPrice = rights.haveRight(SHOW_PRIX_ACHAT_CODE);
|
|
|
122 |
final boolean lockVTMinPrice = rights.haveRight(LOCK_PRIX_MIN_VENTE_CODE);
|
|
|
123 |
|
18 |
ilm |
124 |
final List<SQLTableElement> list = new Vector<SQLTableElement>();
|
|
|
125 |
list.add(new SQLTableElement(e.getTable().getField("ID_STYLE")));
|
61 |
ilm |
126 |
|
93 |
ilm |
127 |
final SQLTableElement tableFamille = new SQLTableElement(e.getTable().getField("ID_FAMILLE_ARTICLE"));
|
|
|
128 |
list.add(tableFamille);
|
142 |
ilm |
129 |
// Article
|
|
|
130 |
final SQLTableElement tableElementArticle = new SQLTableElement(e.getTable().getField("ID_ARTICLE"), true, true, true) {
|
|
|
131 |
@Override
|
|
|
132 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
|
|
133 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
|
|
134 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
|
|
135 |
boolean noCmdElt = vals.getObject("ID_COMMANDE_CLIENT_ELEMENT") == null || vals.isForeignEmpty("ID_COMMANDE_CLIENT_ELEMENT");
|
|
|
136 |
return b && noCmdElt;
|
|
|
137 |
} else {
|
|
|
138 |
return b;
|
|
|
139 |
}
|
93 |
ilm |
140 |
|
142 |
ilm |
141 |
}
|
|
|
142 |
};
|
61 |
ilm |
143 |
list.add(tableElementArticle);
|
|
|
144 |
|
142 |
ilm |
145 |
if (e.getTable().getFieldsName().contains("ID_ECO_CONTRIBUTION")) {
|
|
|
146 |
this.tableElementEcoID = new SQLTableElement(e.getTable().getField("ID_ECO_CONTRIBUTION"));
|
|
|
147 |
list.add(this.tableElementEcoID);
|
|
|
148 |
}
|
|
|
149 |
|
18 |
ilm |
150 |
// Code article
|
132 |
ilm |
151 |
final SQLTableElement tableElementCode = new SQLTableElement(e.getTable().getField("CODE"), String.class,
|
142 |
ilm |
152 |
new ITextArticleWithCompletionCellEditor(e.getTable().getTable("ARTICLE"), e.getTable().getTable("ARTICLE_FOURNISSEUR"))) {
|
|
|
153 |
@Override
|
|
|
154 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
|
|
155 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
|
|
156 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
|
|
157 |
boolean noCmdElt = vals.getObject("ID_COMMANDE_CLIENT_ELEMENT") == null || vals.isForeignEmpty("ID_COMMANDE_CLIENT_ELEMENT");
|
|
|
158 |
return b && noCmdElt;
|
|
|
159 |
} else {
|
|
|
160 |
return b;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
}
|
|
|
164 |
};
|
18 |
ilm |
165 |
list.add(tableElementCode);
|
|
|
166 |
// Désignation de l'article
|
142 |
ilm |
167 |
final SQLTableElement tableElementNom = new SQLTableElement(e.getTable().getField("NOM")) {
|
|
|
168 |
@Override
|
|
|
169 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
|
|
170 |
|
|
|
171 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
|
|
172 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
|
|
173 |
boolean noCmdElt = vals.getObject("ID_COMMANDE_CLIENT_ELEMENT") == null || vals.isForeignEmpty("ID_COMMANDE_CLIENT_ELEMENT");
|
|
|
174 |
return b && noCmdElt;
|
|
|
175 |
} else {
|
|
|
176 |
return b;
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
}
|
|
|
180 |
};
|
18 |
ilm |
181 |
list.add(tableElementNom);
|
94 |
ilm |
182 |
|
|
|
183 |
// Désignation de l'article
|
|
|
184 |
final SQLTableElement tableElementDesc = new SQLTableElement(e.getTable().getField("DESCRIPTIF"));
|
|
|
185 |
list.add(tableElementDesc);
|
|
|
186 |
|
151 |
ilm |
187 |
if (e.getTable().getFieldsName().contains("DELAI")) {
|
|
|
188 |
final SQLTableElement tableElementDelai = new SQLTableElement(e.getTable().getField("DELAI"));
|
|
|
189 |
list.add(tableElementDelai);
|
|
|
190 |
}
|
|
|
191 |
|
18 |
ilm |
192 |
// Valeur des métriques
|
|
|
193 |
final SQLTableElement tableElement_ValeurMetrique2 = new SQLTableElement(e.getTable().getField("VALEUR_METRIQUE_2"), Float.class) {
|
|
|
194 |
@Override
|
132 |
ilm |
195 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
18 |
ilm |
196 |
Number modeNumber = (Number) vals.getObject("ID_MODE_VENTE_ARTICLE");
|
|
|
197 |
// int mode = vals.getInt("ID_MODE_VENTE_ARTICLE");
|
94 |
ilm |
198 |
if (modeNumber != null && (modeNumber.intValue() == ReferenceArticleSQLElement.A_LA_PIECE || modeNumber.intValue() == ReferenceArticleSQLElement.AU_POID_METRECARRE
|
|
|
199 |
|| modeNumber.intValue() == ReferenceArticleSQLElement.AU_METRE_LONGUEUR)) {
|
18 |
ilm |
200 |
return false;
|
|
|
201 |
} else {
|
132 |
ilm |
202 |
return super.isCellEditable(vals, rowIndex, columnIndex);
|
18 |
ilm |
203 |
}
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
@Override
|
|
|
207 |
public TableCellRenderer getTableCellRenderer() {
|
|
|
208 |
|
|
|
209 |
return new ArticleRowValuesRenderer(null);
|
|
|
210 |
}
|
|
|
211 |
};
|
|
|
212 |
|
|
|
213 |
list.add(tableElement_ValeurMetrique2);
|
|
|
214 |
final SQLTableElement tableElement_ValeurMetrique3 = new SQLTableElement(e.getTable().getField("VALEUR_METRIQUE_3"), Float.class) {
|
|
|
215 |
@Override
|
132 |
ilm |
216 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
18 |
ilm |
217 |
|
|
|
218 |
Number modeNumber = (Number) vals.getObject("ID_MODE_VENTE_ARTICLE");
|
|
|
219 |
if (modeNumber != null && (!(modeNumber.intValue() == ReferenceArticleSQLElement.AU_POID_METRECARRE))) {
|
|
|
220 |
return false;
|
|
|
221 |
} else {
|
132 |
ilm |
222 |
return super.isCellEditable(vals, rowIndex, columnIndex);
|
18 |
ilm |
223 |
}
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
@Override
|
|
|
227 |
public TableCellRenderer getTableCellRenderer() {
|
|
|
228 |
|
|
|
229 |
return new ArticleRowValuesRenderer(null);
|
|
|
230 |
}
|
|
|
231 |
};
|
|
|
232 |
|
|
|
233 |
list.add(tableElement_ValeurMetrique3);
|
|
|
234 |
final SQLTableElement tableElement_ValeurMetrique1 = new SQLTableElement(e.getTable().getField("VALEUR_METRIQUE_1"), Float.class) {
|
|
|
235 |
@Override
|
132 |
ilm |
236 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
18 |
ilm |
237 |
|
|
|
238 |
Number modeNumber = (Number) vals.getObject("ID_MODE_VENTE_ARTICLE");
|
94 |
ilm |
239 |
if (modeNumber != null && (modeNumber.intValue() == ReferenceArticleSQLElement.A_LA_PIECE || modeNumber.intValue() == ReferenceArticleSQLElement.AU_POID_METRECARRE
|
|
|
240 |
|| modeNumber.intValue() == ReferenceArticleSQLElement.AU_METRE_LARGEUR)) {
|
18 |
ilm |
241 |
return false;
|
|
|
242 |
} else {
|
132 |
ilm |
243 |
return super.isCellEditable(vals, rowIndex, columnIndex);
|
18 |
ilm |
244 |
}
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
@Override
|
|
|
248 |
public TableCellRenderer getTableCellRenderer() {
|
|
|
249 |
|
|
|
250 |
return new ArticleRowValuesRenderer(null);
|
|
|
251 |
}
|
|
|
252 |
};
|
|
|
253 |
|
|
|
254 |
list.add(tableElement_ValeurMetrique1);
|
142 |
ilm |
255 |
|
|
|
256 |
// Prix d'achat HT de la métrique 1
|
|
|
257 |
final SQLTableElement tableElement_PrixMetrique1_AchatHT = new SQLTableElement(e.getTable().getField("PRIX_METRIQUE_HA_1"), BigDecimal.class) {
|
|
|
258 |
protected Object getDefaultNullValue() {
|
|
|
259 |
return BigDecimal.ZERO;
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
@Override
|
|
|
263 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
|
|
264 |
return isCellNiveauEditable(vals, rowIndex, columnIndex);
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
};
|
|
|
268 |
tableElement_PrixMetrique1_AchatHT.setRenderer(new CurrencyWithSymbolRenderer());
|
|
|
269 |
list.add(tableElement_PrixMetrique1_AchatHT);
|
|
|
270 |
|
18 |
ilm |
271 |
// Prix de vente HT de la métrique 1
|
67 |
ilm |
272 |
SQLField field = e.getTable().getField("PRIX_METRIQUE_VT_1");
|
73 |
ilm |
273 |
final DeviseNumericHTConvertorCellEditor editorPVHT = new DeviseNumericHTConvertorCellEditor(field);
|
67 |
ilm |
274 |
final SQLTableElement tableElement_PrixMetrique1_VenteHT = new SQLTableElement(field, BigDecimal.class, editorPVHT);
|
73 |
ilm |
275 |
tableElement_PrixMetrique1_VenteHT.setRenderer(new DeviseTableCellRenderer());
|
67 |
ilm |
276 |
// {
|
|
|
277 |
// @Override
|
|
|
278 |
// public TableCellRenderer getTableCellRenderer() {
|
|
|
279 |
//
|
|
|
280 |
// List<Integer> l = new ArrayList<Integer>();
|
|
|
281 |
// l.add(Integer.valueOf(ReferenceArticleSQLElement.AU_METRE_CARRE));
|
|
|
282 |
// l.add(Integer.valueOf(ReferenceArticleSQLElement.AU_METRE_LARGEUR));
|
|
|
283 |
// l.add(Integer.valueOf(ReferenceArticleSQLElement.AU_METRE_LONGUEUR));
|
|
|
284 |
// l.add(Integer.valueOf(ReferenceArticleSQLElement.AU_POID_METRECARRE));
|
|
|
285 |
// return new ArticleRowValuesRenderer(l);
|
|
|
286 |
// }
|
|
|
287 |
// };
|
18 |
ilm |
288 |
list.add(tableElement_PrixMetrique1_VenteHT);
|
|
|
289 |
|
|
|
290 |
// Prix de vente HT de la métrique 3
|
|
|
291 |
// final SQLTableElement tableElement_PrixMetrique3_VenteHT = new
|
|
|
292 |
// SQLTableElement(e.getTable().getField("PRIX_METRIQUE_VT_3"), Long.class, new
|
|
|
293 |
// DeviseCellEditor());
|
|
|
294 |
// list.add(tableElement_PrixMetrique3_VenteHT);
|
|
|
295 |
// Prix d'achat HT de la métrique 3
|
|
|
296 |
// final SQLTableElement tableElement_PrixMetrique3_AchatHT = new
|
|
|
297 |
// SQLTableElement(e.getTable().getField("PRIX_METRIQUE_HA_3"), Long.class, new
|
|
|
298 |
// DeviseCellEditor());
|
|
|
299 |
// list.add(tableElement_PrixMetrique3_AchatHT);
|
|
|
300 |
|
142 |
ilm |
301 |
if (e.getTable().getFieldsName().contains("ECO_CONTRIBUTION")) {
|
|
|
302 |
this.tableElementEco = new SQLTableElement(e.getTable().getField("ECO_CONTRIBUTION"));
|
|
|
303 |
list.add(this.tableElementEco);
|
|
|
304 |
}
|
|
|
305 |
|
93 |
ilm |
306 |
SQLTableElement eltDevise = null;
|
|
|
307 |
SQLTableElement eltUnitDevise = null;
|
156 |
ilm |
308 |
if (showDevise) {
|
93 |
ilm |
309 |
// Devise
|
|
|
310 |
eltDevise = new SQLTableElement(e.getTable().getField("ID_DEVISE"));
|
|
|
311 |
list.add(eltDevise);
|
|
|
312 |
|
|
|
313 |
// Prix vente devise
|
|
|
314 |
eltUnitDevise = new SQLTableElement(e.getTable().getField("PV_U_DEVISE"), BigDecimal.class) {
|
|
|
315 |
@Override
|
132 |
ilm |
316 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
|
|
317 |
return isCellNiveauEditable(vals, rowIndex, columnIndex);
|
93 |
ilm |
318 |
}
|
|
|
319 |
};
|
|
|
320 |
eltUnitDevise.setRenderer(new DeviseTableCellRenderer());
|
|
|
321 |
list.add(eltUnitDevise);
|
|
|
322 |
}
|
|
|
323 |
|
61 |
ilm |
324 |
SQLTableElement qteU = new SQLTableElement(e.getTable().getField("QTE_UNITAIRE"), BigDecimal.class) {
|
|
|
325 |
@Override
|
132 |
ilm |
326 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
61 |
ilm |
327 |
|
|
|
328 |
SQLRowAccessor row = vals.getForeign("ID_UNITE_VENTE");
|
|
|
329 |
if (row != null && !row.isUndefined() && row.getBoolean("A_LA_PIECE")) {
|
|
|
330 |
return false;
|
|
|
331 |
} else {
|
132 |
ilm |
332 |
return super.isCellEditable(vals, rowIndex, columnIndex);
|
61 |
ilm |
333 |
}
|
|
|
334 |
}
|
|
|
335 |
|
67 |
ilm |
336 |
protected Object getDefaultNullValue() {
|
|
|
337 |
return BigDecimal.ZERO;
|
|
|
338 |
}
|
|
|
339 |
|
61 |
ilm |
340 |
@Override
|
|
|
341 |
public TableCellRenderer getTableCellRenderer() {
|
|
|
342 |
return new QteUnitRowValuesRenderer();
|
|
|
343 |
}
|
|
|
344 |
};
|
|
|
345 |
list.add(qteU);
|
|
|
346 |
|
|
|
347 |
SQLTableElement uniteVente = new SQLTableElement(e.getTable().getField("ID_UNITE_VENTE"));
|
|
|
348 |
list.add(uniteVente);
|
|
|
349 |
|
18 |
ilm |
350 |
// Quantité
|
73 |
ilm |
351 |
this.qte = new SQLTableElement(e.getTable().getField("QTE"), Integer.class, new QteCellEditor()) {
|
|
|
352 |
protected Object getDefaultNullValue() {
|
|
|
353 |
return Integer.valueOf(0);
|
|
|
354 |
}
|
142 |
ilm |
355 |
|
|
|
356 |
@Override
|
|
|
357 |
public TableCellRenderer getTableCellRenderer() {
|
|
|
358 |
|
|
|
359 |
return new QtyToDeliverRowValuesRenderer();
|
|
|
360 |
}
|
|
|
361 |
|
73 |
ilm |
362 |
};
|
61 |
ilm |
363 |
list.add(this.qte);
|
18 |
ilm |
364 |
|
|
|
365 |
// Mode de vente
|
|
|
366 |
final SQLTableElement tableElement_ModeVente = new SQLTableElement(e.getTable().getField("ID_MODE_VENTE_ARTICLE"));
|
|
|
367 |
list.add(tableElement_ModeVente);
|
142 |
ilm |
368 |
final SQLField prixAchatHTField = e.getTable().getField("PA_HT");
|
|
|
369 |
final DeviseNumericCellEditor editorPAchatHT = new DeviseNumericCellEditor(prixAchatHTField);
|
18 |
ilm |
370 |
|
142 |
ilm |
371 |
this.ha = new SQLTableElement(prixAchatHTField, BigDecimal.class, editorPAchatHT) {
|
|
|
372 |
protected Object getDefaultNullValue() {
|
|
|
373 |
return BigDecimal.ZERO;
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
@Override
|
|
|
377 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
|
|
378 |
return isCellNiveauEditable(vals, rowIndex, columnIndex);
|
|
|
379 |
}
|
|
|
380 |
};
|
|
|
381 |
this.ha.setRenderer(new CurrencyWithSymbolRenderer());
|
|
|
382 |
|
|
|
383 |
list.add(this.ha);
|
|
|
384 |
|
18 |
ilm |
385 |
// Prix d'achat unitaire HT
|
|
|
386 |
// final SQLTableElement tableElement_PrixAchat_HT = new
|
|
|
387 |
// SQLTableElement(e.getTable().getField("PA_HT"), Long.class, new DeviseCellEditor());
|
|
|
388 |
// list.add(tableElement_PrixAchat_HT);
|
|
|
389 |
// Prix de vente unitaire HT
|
67 |
ilm |
390 |
final SQLTableElement tableElement_PrixVente_HT = new SQLTableElement(e.getTable().getField("PV_HT"), BigDecimal.class);
|
|
|
391 |
// , new DeviseCellEditor()) {
|
|
|
392 |
// @Override
|
|
|
393 |
// public TableCellRenderer getTableCellRenderer() {
|
|
|
394 |
// List<Integer> l = new ArrayList<Integer>();
|
|
|
395 |
// l.add(Integer.valueOf(ReferenceArticleSQLElement.A_LA_PIECE));
|
|
|
396 |
// return new ArticleRowValuesRenderer(l);
|
|
|
397 |
// }
|
|
|
398 |
// };
|
73 |
ilm |
399 |
tableElement_PrixVente_HT.setRenderer(new DeviseTableCellRenderer());
|
18 |
ilm |
400 |
list.add(tableElement_PrixVente_HT);
|
|
|
401 |
|
|
|
402 |
// TVA
|
61 |
ilm |
403 |
this.tableElementTVA = new SQLTableElement(e.getTable().getField("ID_TAXE"));
|
|
|
404 |
list.add(this.tableElementTVA);
|
18 |
ilm |
405 |
|
|
|
406 |
// Quantité Livrée
|
142 |
ilm |
407 |
final SQLTableElement tableElement_QuantiteLivree = new SQLTableElement(e.getTable().getField("QTE_LIVREE"), Integer.class) {
|
|
|
408 |
@Override
|
|
|
409 |
public TableCellRenderer getTableCellRenderer() {
|
|
|
410 |
|
|
|
411 |
return new DeliveredQtyRowValuesRenderer();
|
|
|
412 |
}
|
151 |
ilm |
413 |
|
|
|
414 |
protected Object getDefaultNullValue() {
|
|
|
415 |
return Integer.valueOf(0);
|
|
|
416 |
}
|
142 |
ilm |
417 |
};
|
18 |
ilm |
418 |
list.add(tableElement_QuantiteLivree);
|
|
|
419 |
|
|
|
420 |
// Poids piece
|
|
|
421 |
SQLTableElement tableElementPoids = new SQLTableElement(e.getTable().getField("POIDS"), Float.class);
|
|
|
422 |
list.add(tableElementPoids);
|
|
|
423 |
|
|
|
424 |
// Poids total
|
|
|
425 |
this.tableElementPoidsTotal = new SQLTableElement(e.getTable().getField("T_POIDS"), Float.class);
|
|
|
426 |
list.add(this.tableElementPoidsTotal);
|
|
|
427 |
|
|
|
428 |
// Poids total Livré
|
|
|
429 |
this.tableElementPoidsTotalLivree = new SQLTableElement(e.getTable().getField("T_POIDS_LIVREE"), Float.class);
|
|
|
430 |
list.add(this.tableElementPoidsTotalLivree);
|
|
|
431 |
|
80 |
ilm |
432 |
// Packaging
|
|
|
433 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
|
|
|
434 |
|
|
|
435 |
SQLTableElement poidsColis = new SQLTableElement(e.getTable().getField("POIDS_COLIS_NET"), BigDecimal.class);
|
|
|
436 |
list.add(poidsColis);
|
|
|
437 |
|
|
|
438 |
SQLTableElement nbColis = new SQLTableElement(e.getTable().getField("NB_COLIS"), Integer.class);
|
|
|
439 |
list.add(nbColis);
|
|
|
440 |
|
|
|
441 |
final SQLTableElement totalPoidsColis = new SQLTableElement(e.getTable().getField("T_POIDS_COLIS_NET"), BigDecimal.class);
|
|
|
442 |
list.add(totalPoidsColis);
|
|
|
443 |
|
|
|
444 |
poidsColis.addModificationListener(totalPoidsColis);
|
|
|
445 |
nbColis.addModificationListener(totalPoidsColis);
|
|
|
446 |
totalPoidsColis.setModifier(new CellDynamicModifier() {
|
93 |
ilm |
447 |
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
|
80 |
ilm |
448 |
final Object o2 = row.getObject("POIDS_COLIS_NET");
|
|
|
449 |
final Object o3 = row.getObject("NB_COLIS");
|
|
|
450 |
if (o2 != null && o3 != null) {
|
|
|
451 |
BigDecimal poids = (BigDecimal) o2;
|
|
|
452 |
int nb = (Integer) o3;
|
90 |
ilm |
453 |
return poids.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION).setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
|
80 |
ilm |
454 |
} else {
|
|
|
455 |
return row.getObject("T_POIDS_COLIS_NET");
|
|
|
456 |
}
|
|
|
457 |
}
|
|
|
458 |
});
|
|
|
459 |
|
|
|
460 |
}
|
|
|
461 |
|
18 |
ilm |
462 |
// Service
|
|
|
463 |
// this.service = new SQLTableElement(e.getTable().getField("SERVICE"), Boolean.class);
|
|
|
464 |
// list.add(this.service);
|
93 |
ilm |
465 |
|
156 |
ilm |
466 |
if (showDevise) {
|
93 |
ilm |
467 |
// Total HT
|
|
|
468 |
this.tableElementTotalDevise = new SQLTableElement(e.getTable().getField("PV_T_DEVISE"), BigDecimal.class) {
|
|
|
469 |
@Override
|
132 |
ilm |
470 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
|
|
471 |
return isCellNiveauEditable(vals, rowIndex, columnIndex);
|
93 |
ilm |
472 |
}
|
|
|
473 |
};
|
|
|
474 |
this.tableElementTotalDevise.setRenderer(new DeviseTableCellRenderer());
|
|
|
475 |
list.add(tableElementTotalDevise);
|
|
|
476 |
}
|
|
|
477 |
|
94 |
ilm |
478 |
final SQLField fieldRemise = e.getTable().getField("POURCENT_REMISE");
|
|
|
479 |
|
|
|
480 |
if (e.getTable().getFieldsName().contains("MONTANT_REMISE")) {
|
|
|
481 |
tableElementRemise = new SQLTableElement(e.getTable().getField("POURCENT_REMISE"), Acompte.class, new AcompteCellEditor("POURCENT_REMISE", "MONTANT_REMISE")) {
|
|
|
482 |
@Override
|
|
|
483 |
public void setValueFrom(SQLRowValues row, Object value) {
|
|
|
484 |
|
|
|
485 |
if (value != null) {
|
|
|
486 |
Acompte a = (Acompte) value;
|
|
|
487 |
row.put("MONTANT_REMISE", a.getMontant());
|
|
|
488 |
row.put("POURCENT_REMISE", a.getPercent());
|
|
|
489 |
} else {
|
|
|
490 |
row.put("MONTANT_REMISE", null);
|
|
|
491 |
row.put("POURCENT_REMISE", BigDecimal.ZERO);
|
|
|
492 |
}
|
|
|
493 |
fireModification(row);
|
|
|
494 |
}
|
|
|
495 |
};
|
|
|
496 |
tableElementRemise.setRenderer(new DefaultTableCellRenderer() {
|
|
|
497 |
@Override
|
|
|
498 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
|
|
499 |
SQLRowValues rowVals = ((RowValuesTable) table).getRowValuesTableModel().getRowValuesAt(row);
|
|
|
500 |
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
|
501 |
BigDecimal percent = rowVals.getBigDecimal("POURCENT_REMISE");
|
|
|
502 |
BigDecimal amount = rowVals.getBigDecimal("MONTANT_REMISE");
|
|
|
503 |
Remise a = new Remise(percent, amount);
|
132 |
ilm |
504 |
label.setText(a.toPlainString(true));
|
94 |
ilm |
505 |
return label;
|
|
|
506 |
}
|
|
|
507 |
});
|
|
|
508 |
} else {
|
|
|
509 |
tableElementRemise = new SQLTableElement(fieldRemise) {
|
|
|
510 |
protected Object getDefaultNullValue() {
|
|
|
511 |
return BigDecimal.ZERO;
|
|
|
512 |
}
|
|
|
513 |
};
|
|
|
514 |
}
|
|
|
515 |
list.add(tableElementRemise);
|
|
|
516 |
|
18 |
ilm |
517 |
// Total HT
|
142 |
ilm |
518 |
this.totalHA = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
|
|
|
519 |
this.totalHA.setRenderer(new CurrencyWithSymbolRenderer());
|
|
|
520 |
this.totalHA.setEditable(false);
|
|
|
521 |
list.add(this.totalHA);
|
|
|
522 |
|
67 |
ilm |
523 |
this.totalHT = new SQLTableElement(e.getTable().getField("T_PV_HT"), BigDecimal.class);
|
73 |
ilm |
524 |
this.totalHT.setRenderer(new DeviseTableCellRenderer());
|
142 |
ilm |
525 |
|
|
|
526 |
// Marge HT
|
|
|
527 |
if (e.getTable().getFieldsName().contains("MARGE_HT")) {
|
|
|
528 |
|
|
|
529 |
final SQLTableElement marge = new SQLTableElement(e.getTable().getField("MARGE_HT"), BigDecimal.class) {
|
|
|
530 |
protected Object getDefaultNullValue() {
|
|
|
531 |
return BigDecimal.ZERO;
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
@Override
|
|
|
535 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
|
|
536 |
return isCellNiveauEditable(vals, rowIndex, columnIndex);
|
|
|
537 |
}
|
|
|
538 |
|
|
|
539 |
};
|
|
|
540 |
marge.setRenderer(new CurrencyWithSymbolRenderer());
|
|
|
541 |
marge.setEditable(false);
|
|
|
542 |
list.add(marge);
|
|
|
543 |
this.totalHT.addModificationListener(marge);
|
|
|
544 |
this.totalHA.addModificationListener(marge);
|
|
|
545 |
marge.setModifier(new CellDynamicModifier() {
|
|
|
546 |
@Override
|
|
|
547 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
|
|
548 |
|
|
|
549 |
BigDecimal vt = (BigDecimal) row.getObject("T_PV_HT");
|
|
|
550 |
|
|
|
551 |
BigDecimal ha = (BigDecimal) row.getObject("T_PA_HT");
|
|
|
552 |
|
|
|
553 |
final BigDecimal acomptePercent = row.getBigDecimal("POURCENT_FACTURABLE");
|
|
|
554 |
final BigDecimal acompteMontant = row.getBigDecimal("MONTANT_FACTURABLE");
|
|
|
555 |
Acompte acompte = new Acompte(acomptePercent, acompteMontant);
|
|
|
556 |
ha = acompte.getResultFrom(ha);
|
|
|
557 |
vt = acompte.getResultFrom(vt);
|
|
|
558 |
|
|
|
559 |
return vt.subtract(ha).setScale(marge.getDecimalDigits(), RoundingMode.HALF_UP);
|
|
|
560 |
}
|
|
|
561 |
|
|
|
562 |
});
|
|
|
563 |
|
|
|
564 |
}
|
|
|
565 |
|
|
|
566 |
if (e.getTable().getFieldsName().contains("T_ECO_CONTRIBUTION")) {
|
|
|
567 |
this.tableElementEcoTotal = new SQLTableElement(e.getTable().getField("T_ECO_CONTRIBUTION"));
|
|
|
568 |
list.add(this.tableElementEcoTotal);
|
|
|
569 |
}
|
|
|
570 |
|
|
|
571 |
// Total HT
|
18 |
ilm |
572 |
list.add(this.totalHT);
|
|
|
573 |
// Total TTC
|
67 |
ilm |
574 |
this.tableElementTotalTTC = new SQLTableElement(e.getTable().getField("T_PV_TTC"), BigDecimal.class);
|
73 |
ilm |
575 |
this.tableElementTotalTTC.setRenderer(new DeviseTableCellRenderer());
|
18 |
ilm |
576 |
list.add(this.tableElementTotalTTC);
|
|
|
577 |
|
142 |
ilm |
578 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
|
|
579 |
final SQLTableElement tableCmdElt = new SQLTableElement(e.getTable().getField("ID_COMMANDE_CLIENT_ELEMENT"));
|
|
|
580 |
list.add(tableCmdElt);
|
|
|
581 |
}
|
|
|
582 |
|
80 |
ilm |
583 |
SQLRowValues defautRow = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
|
|
|
584 |
defautRow.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
|
83 |
ilm |
585 |
defautRow.put("CODE", "");
|
|
|
586 |
defautRow.put("NOM", "");
|
156 |
ilm |
587 |
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, defautRow) {
|
|
|
588 |
@Override
|
|
|
589 |
public void commitData() {
|
|
|
590 |
int size = getRowCount();
|
|
|
591 |
for (int i = 0; i < size; i++) {
|
|
|
592 |
SQLRowValues rowVals = getRowValuesAt(i);
|
|
|
593 |
if (rowVals.getObject("PV_U_DEVISE") == null) {
|
|
|
594 |
rowVals.put("PV_U_DEVISE", rowVals.getObject("PRIX_METRIQUE_VT_1"));
|
|
|
595 |
final BigDecimal globalQty = rowVals.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(rowVals.getInt("QTE")));
|
|
|
596 |
rowVals.put("PV_T_DEVISE", rowVals.getBigDecimal("PRIX_METRIQUE_VT_1").multiply(globalQty));
|
|
|
597 |
}
|
|
|
598 |
}
|
|
|
599 |
super.commitData();
|
|
|
600 |
}
|
|
|
601 |
};
|
93 |
ilm |
602 |
this.setModel(model);
|
18 |
ilm |
603 |
this.table = new RowValuesTable(model, getConfigurationFile());
|
|
|
604 |
ToolTipManager.sharedInstance().unregisterComponent(this.table);
|
|
|
605 |
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
|
|
|
606 |
|
93 |
ilm |
607 |
if (filterFamilleArticle) {
|
|
|
608 |
((SQLTextComboTableCellEditor) tableElementArticle.getTableCellEditor(this.table)).setDynamicWhere(e.getTable().getTable("ARTICLE").getField("ID_FAMILLE_ARTICLE"));
|
|
|
609 |
}
|
|
|
610 |
|
61 |
ilm |
611 |
List<String> completionField = new ArrayList<String>();
|
93 |
ilm |
612 |
final SQLTable sqlTableArticle = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("ARTICLE");
|
156 |
ilm |
613 |
if (showDevise) {
|
61 |
ilm |
614 |
completionField.add("CODE_DOUANIER");
|
|
|
615 |
completionField.add("ID_PAYS");
|
|
|
616 |
}
|
142 |
ilm |
617 |
if (e.getTable().getFieldsName().contains("ID_ECO_CONTRIBUTION")) {
|
|
|
618 |
completionField.add("ID_ECO_CONTRIBUTION");
|
|
|
619 |
}
|
174 |
ilm |
620 |
completionField.add("POURCENT_REMISE");
|
61 |
ilm |
621 |
completionField.add("ID_UNITE_VENTE");
|
156 |
ilm |
622 |
completionField.add("QTE_UNITAIRE");
|
61 |
ilm |
623 |
completionField.add("PA_HT");
|
|
|
624 |
completionField.add("PV_HT");
|
|
|
625 |
completionField.add("ID_TAXE");
|
|
|
626 |
completionField.add("POIDS");
|
|
|
627 |
completionField.add("PRIX_METRIQUE_HA_1");
|
|
|
628 |
completionField.add("PRIX_METRIQUE_HA_2");
|
|
|
629 |
completionField.add("PRIX_METRIQUE_HA_3");
|
|
|
630 |
completionField.add("VALEUR_METRIQUE_1");
|
|
|
631 |
completionField.add("VALEUR_METRIQUE_2");
|
|
|
632 |
completionField.add("VALEUR_METRIQUE_3");
|
|
|
633 |
completionField.add("ID_MODE_VENTE_ARTICLE");
|
|
|
634 |
completionField.add("PRIX_METRIQUE_VT_1");
|
|
|
635 |
completionField.add("PRIX_METRIQUE_VT_2");
|
|
|
636 |
completionField.add("PRIX_METRIQUE_VT_3");
|
|
|
637 |
completionField.add("SERVICE");
|
93 |
ilm |
638 |
completionField.add("ID_FAMILLE_ARTICLE");
|
61 |
ilm |
639 |
if (getSQLElement().getTable().getFieldsName().contains("DESCRIPTIF")) {
|
|
|
640 |
completionField.add("DESCRIPTIF");
|
|
|
641 |
}
|
156 |
ilm |
642 |
if (showDevise) {
|
61 |
ilm |
643 |
completionField.add("ID_DEVISE");
|
|
|
644 |
completionField.add("PV_U_DEVISE");
|
|
|
645 |
}
|
|
|
646 |
if (getSQLElement().getTable().getFieldsName().contains("QTE_ACHAT") && sqlTableArticle.getTable().getFieldsName().contains("QTE_ACHAT")) {
|
|
|
647 |
completionField.add("QTE_ACHAT");
|
|
|
648 |
}
|
|
|
649 |
|
18 |
ilm |
650 |
// Autocompletion
|
|
|
651 |
final AutoCompletionManager m = new AutoCompletionManager(tableElementCode, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.CODE"), this.table,
|
73 |
ilm |
652 |
this.table.getRowValuesTableModel()) {
|
|
|
653 |
@Override
|
93 |
ilm |
654 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
|
|
655 |
Object res = tarifCompletion(row, field, rowDest, true);
|
73 |
ilm |
656 |
if (res == null) {
|
174 |
ilm |
657 |
res = super.getValueFrom(row, field, rowDest);
|
|
|
658 |
}
|
|
|
659 |
if (field.equals("POURCENT_REMISE")) {
|
|
|
660 |
return getRemiseClient(row);
|
73 |
ilm |
661 |
}
|
174 |
ilm |
662 |
return res;
|
73 |
ilm |
663 |
}
|
|
|
664 |
};
|
18 |
ilm |
665 |
m.fill("NOM", "NOM");
|
61 |
ilm |
666 |
m.fill("ID", "ID_ARTICLE");
|
|
|
667 |
for (String string : completionField) {
|
|
|
668 |
m.fill(string, string);
|
|
|
669 |
}
|
151 |
ilm |
670 |
// final Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
|
|
|
671 |
// m.setWhere(w);
|
|
|
672 |
ITransformer<SQLSelect, SQLSelect> selTrans = new ITransformer<SQLSelect, SQLSelect>() {
|
|
|
673 |
@Override
|
|
|
674 |
public SQLSelect transformChecked(SQLSelect input) {
|
61 |
ilm |
675 |
|
151 |
ilm |
676 |
// FIXME utiliser le stock sélectionné sur la ligne et non le stock par défaut de
|
|
|
677 |
// l'article
|
|
|
678 |
final SQLTable tableStock = sqlTableArticle.getTable("STOCK");
|
|
|
679 |
input.andWhere(new Where(tableStock.getKey(), "=", sqlTableArticle.getField("ID_STOCK")));
|
|
|
680 |
input.setExcludeUndefined(false, tableStock);
|
|
|
681 |
Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE).or(new Where(input.getAlias(tableStock.getKey()), "=", tableStock.getUndefinedID()))
|
|
|
682 |
.or(new Where(input.getAlias(tableStock.getField("QTE_REEL")), ">", 0));
|
|
|
683 |
|
|
|
684 |
if (input.getWhere() != null) {
|
|
|
685 |
input.setWhere(input.getWhere().and(w));
|
|
|
686 |
} else {
|
|
|
687 |
input.setWhere(w);
|
|
|
688 |
}
|
|
|
689 |
input.asString();
|
|
|
690 |
return input;
|
|
|
691 |
}
|
|
|
692 |
};
|
|
|
693 |
|
|
|
694 |
m.setSelectTransformer(selTrans);
|
|
|
695 |
|
142 |
ilm |
696 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.CAN_EXPAND_NOMENCLATURE_VT, true)) {
|
|
|
697 |
|
|
|
698 |
table.addMouseListener(new MouseAdapter() {
|
|
|
699 |
|
|
|
700 |
@Override
|
|
|
701 |
public void mousePressed(MouseEvent e) {
|
|
|
702 |
|
|
|
703 |
handlePopup(e);
|
|
|
704 |
}
|
|
|
705 |
|
|
|
706 |
@Override
|
|
|
707 |
public void mouseReleased(MouseEvent e) {
|
|
|
708 |
|
|
|
709 |
handlePopup(e);
|
|
|
710 |
}
|
|
|
711 |
|
|
|
712 |
public void handlePopup(MouseEvent e) {
|
|
|
713 |
final int rowindex = table.getSelectedRow();
|
|
|
714 |
if (rowindex < 0)
|
|
|
715 |
return;
|
|
|
716 |
if (e.isPopupTrigger() && e.getComponent() instanceof JTable) {
|
|
|
717 |
JPopupMenu popup = new JPopupMenu();
|
|
|
718 |
popup.add(new AbstractAction(TranslationManager.getInstance().getTranslationForItem("product.bom.expand")) {
|
|
|
719 |
|
|
|
720 |
@Override
|
|
|
721 |
public void actionPerformed(ActionEvent arg0) {
|
|
|
722 |
expandNomenclature(rowindex, m, EXPAND_TYPE.EXPAND);
|
|
|
723 |
}
|
|
|
724 |
});
|
|
|
725 |
popup.add(new AbstractAction(TranslationManager.getInstance().getTranslationForItem("product.bom.expose")) {
|
|
|
726 |
|
|
|
727 |
@Override
|
|
|
728 |
public void actionPerformed(ActionEvent arg0) {
|
|
|
729 |
expandNomenclature(rowindex, m, EXPAND_TYPE.VIEW_ONLY);
|
|
|
730 |
}
|
|
|
731 |
});
|
|
|
732 |
|
|
|
733 |
for (AbstractAction action : getAdditionnalMouseAction(rowindex)) {
|
|
|
734 |
popup.add(action);
|
|
|
735 |
}
|
|
|
736 |
|
|
|
737 |
popup.show(e.getComponent(), e.getX(), e.getY());
|
|
|
738 |
}
|
|
|
739 |
}
|
|
|
740 |
});
|
|
|
741 |
}
|
|
|
742 |
|
18 |
ilm |
743 |
final AutoCompletionManager m2 = new AutoCompletionManager(tableElementNom, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.NOM"), this.table,
|
73 |
ilm |
744 |
this.table.getRowValuesTableModel()) {
|
|
|
745 |
@Override
|
93 |
ilm |
746 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
|
|
747 |
Object res = tarifCompletion(row, field, rowDest, true);
|
73 |
ilm |
748 |
if (res == null) {
|
174 |
ilm |
749 |
res = super.getValueFrom(row, field, rowDest);
|
|
|
750 |
}
|
|
|
751 |
if (field.equals("POURCENT_REMISE")) {
|
|
|
752 |
return getRemiseClient(row);
|
73 |
ilm |
753 |
}
|
174 |
ilm |
754 |
return res;
|
73 |
ilm |
755 |
}
|
|
|
756 |
};
|
18 |
ilm |
757 |
m2.fill("CODE", "CODE");
|
61 |
ilm |
758 |
m2.fill("ID", "ID_ARTICLE");
|
|
|
759 |
for (String string : completionField) {
|
|
|
760 |
m2.fill(string, string);
|
|
|
761 |
}
|
18 |
ilm |
762 |
|
151 |
ilm |
763 |
// m2.setWhere(w);
|
|
|
764 |
m2.setSelectTransformer(selTrans);
|
61 |
ilm |
765 |
|
|
|
766 |
final AutoCompletionManager m3 = new AutoCompletionManager(tableElementArticle, sqlTableArticle.getField("NOM"), this.table, this.table.getRowValuesTableModel(),
|
73 |
ilm |
767 |
ITextWithCompletion.MODE_CONTAINS, true, true, new ValidStateChecker()) {
|
|
|
768 |
@Override
|
93 |
ilm |
769 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
|
|
770 |
Object res = tarifCompletion(row, field, rowDest, true);
|
73 |
ilm |
771 |
if (res == null) {
|
174 |
ilm |
772 |
res = super.getValueFrom(row, field, rowDest);
|
|
|
773 |
}
|
|
|
774 |
if (field.equals("POURCENT_REMISE")) {
|
|
|
775 |
return getRemiseClient(row);
|
73 |
ilm |
776 |
}
|
174 |
ilm |
777 |
return res;
|
73 |
ilm |
778 |
}
|
|
|
779 |
};
|
61 |
ilm |
780 |
m3.fill("CODE", "CODE");
|
|
|
781 |
m3.fill("NOM", "NOM");
|
|
|
782 |
for (String string : completionField) {
|
|
|
783 |
m3.fill(string, string);
|
|
|
784 |
}
|
|
|
785 |
|
151 |
ilm |
786 |
// m3.setWhere(w);
|
|
|
787 |
m3.setSelectTransformer(selTrans);
|
61 |
ilm |
788 |
|
142 |
ilm |
789 |
// ECO Contribution
|
|
|
790 |
if (this.tableElementEco != null && this.tableElementEcoTotal != null && this.tableElementEcoID != null) {
|
|
|
791 |
this.qte.addModificationListener(this.tableElementEcoTotal);
|
|
|
792 |
this.tableElementEco.addModificationListener(this.tableElementEcoTotal);
|
|
|
793 |
this.tableElementEcoTotal.setModifier(new CellDynamicModifier() {
|
|
|
794 |
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
|
|
|
795 |
|
|
|
796 |
int qte = Integer.parseInt(row.getObject("QTE").toString());
|
|
|
797 |
BigDecimal f = (row.getObject("ECO_CONTRIBUTION") == null) ? BigDecimal.ZERO : (BigDecimal) row.getObject("ECO_CONTRIBUTION");
|
|
|
798 |
return f.multiply(new BigDecimal(qte));
|
|
|
799 |
}
|
|
|
800 |
|
|
|
801 |
});
|
|
|
802 |
this.tableElementEcoID.addModificationListener(this.tableElementEco);
|
|
|
803 |
this.tableElementEco.setModifier(new CellDynamicModifier() {
|
|
|
804 |
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
|
|
|
805 |
|
|
|
806 |
if (source != null && source.equals(tableElementEcoID)) {
|
|
|
807 |
return row.getForeign("ID_ECO_CONTRIBUTION").getBigDecimal("TAUX");
|
|
|
808 |
} else {
|
|
|
809 |
return row.getObject("ECO_CONTRIBUTION");
|
|
|
810 |
}
|
|
|
811 |
}
|
|
|
812 |
});
|
|
|
813 |
}
|
|
|
814 |
|
18 |
ilm |
815 |
// Calcul automatique du total HT
|
142 |
ilm |
816 |
tableElement_QuantiteLivree.addModificationListener(tableElement_PrixMetrique1_VenteHT);
|
|
|
817 |
tableElement_QuantiteLivree.addModificationListener(totalHT);
|
|
|
818 |
tableElement_QuantiteLivree.addModificationListener(totalHA);
|
61 |
ilm |
819 |
qteU.addModificationListener(totalHT);
|
142 |
ilm |
820 |
qteU.addModificationListener(totalHA);
|
|
|
821 |
this.ha.addModificationListener(this.totalHA);
|
94 |
ilm |
822 |
tableElementRemise.addModificationListener(this.totalHT);
|
18 |
ilm |
823 |
tableElement_PrixVente_HT.addModificationListener(totalHT);
|
|
|
824 |
this.totalHT.setModifier(new CellDynamicModifier() {
|
93 |
ilm |
825 |
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
|
151 |
ilm |
826 |
final Object qteL = row.getObject("QTE_LIVREE");
|
|
|
827 |
int qte = qteL == null ? 0 : Integer.parseInt(qteL.toString());
|
67 |
ilm |
828 |
BigDecimal f = (BigDecimal) row.getObject("PV_HT");
|
18 |
ilm |
829 |
System.out.println("Qte:" + qte + " et PV_HT:" + f);
|
61 |
ilm |
830 |
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
|
90 |
ilm |
831 |
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), DecimalUtils.HIGH_PRECISION).setScale(totalHT.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
|
94 |
ilm |
832 |
|
|
|
833 |
if (row.getTable().getFieldsName().contains("MONTANT_REMISE")) {
|
|
|
834 |
final BigDecimal acomptePercent = row.getBigDecimal("POURCENT_REMISE");
|
|
|
835 |
final BigDecimal acompteMontant = row.getBigDecimal("MONTANT_REMISE");
|
|
|
836 |
Remise remise = new Remise(acomptePercent, acompteMontant);
|
|
|
837 |
r = remise.getResultFrom(r);
|
|
|
838 |
}
|
67 |
ilm |
839 |
return r;
|
18 |
ilm |
840 |
}
|
|
|
841 |
|
|
|
842 |
});
|
142 |
ilm |
843 |
this.totalHA.setModifier(new CellDynamicModifier() {
|
|
|
844 |
public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
|
151 |
ilm |
845 |
final Object qteL = row.getObject("QTE_LIVREE");
|
|
|
846 |
int qte = qteL == null ? 0 : Integer.parseInt(qteL.toString());
|
142 |
ilm |
847 |
BigDecimal f = (BigDecimal) row.getObject("PA_HT");
|
|
|
848 |
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
|
|
|
849 |
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), DecimalUtils.HIGH_PRECISION).setScale(totalHA.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
|
|
|
850 |
return r;
|
|
|
851 |
}
|
|
|
852 |
|
|
|
853 |
});
|
18 |
ilm |
854 |
// Calcul automatique du total TTC
|
142 |
ilm |
855 |
tableElement_QuantiteLivree.addModificationListener(tableElementTotalTTC);
|
61 |
ilm |
856 |
qteU.addModificationListener(tableElementTotalTTC);
|
18 |
ilm |
857 |
tableElement_PrixVente_HT.addModificationListener(tableElementTotalTTC);
|
61 |
ilm |
858 |
this.tableElementTVA.addModificationListener(tableElementTotalTTC);
|
18 |
ilm |
859 |
this.tableElementTotalTTC.setModifier(new CellDynamicModifier() {
|
|
|
860 |
@Override
|
93 |
ilm |
861 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
61 |
ilm |
862 |
|
67 |
ilm |
863 |
BigDecimal f = (BigDecimal) row.getObject("T_PV_HT");
|
18 |
ilm |
864 |
int idTaux = Integer.parseInt(row.getObject("ID_TAXE").toString());
|
|
|
865 |
|
|
|
866 |
Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
|
|
|
867 |
|
67 |
ilm |
868 |
// PrixHT pHT = new PrixHT(f.longValue());
|
18 |
ilm |
869 |
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
|
67 |
ilm |
870 |
// Long r = new Long(pHT.calculLongTTC(taux / 100f));
|
73 |
ilm |
871 |
editorPVHT.setTaxe(taux);
|
90 |
ilm |
872 |
BigDecimal r = f.multiply(BigDecimal.ONE.add(BigDecimal.valueOf(taux).movePointLeft(2)), DecimalUtils.HIGH_PRECISION).setScale(6, BigDecimal.ROUND_HALF_UP);
|
67 |
ilm |
873 |
|
73 |
ilm |
874 |
return r.setScale(tableElementTotalTTC.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
|
18 |
ilm |
875 |
}
|
|
|
876 |
|
|
|
877 |
});
|
|
|
878 |
// Calcul automatique du poids unitaire
|
|
|
879 |
tableElement_ValeurMetrique1.addModificationListener(tableElementPoids);
|
|
|
880 |
tableElement_ValeurMetrique2.addModificationListener(tableElementPoids);
|
|
|
881 |
tableElement_ValeurMetrique3.addModificationListener(tableElementPoids);
|
|
|
882 |
tableElementPoids.setModifier(new CellDynamicModifier() {
|
93 |
ilm |
883 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
18 |
ilm |
884 |
return new Float(ReferenceArticleSQLElement.getPoidsFromDetails(row));
|
|
|
885 |
}
|
|
|
886 |
|
|
|
887 |
});
|
|
|
888 |
// Calcul automatique du poids total
|
|
|
889 |
tableElementPoids.addModificationListener(this.tableElementPoidsTotal);
|
61 |
ilm |
890 |
this.qte.addModificationListener(this.tableElementPoidsTotal);
|
|
|
891 |
qteU.addModificationListener(this.tableElementPoidsTotal);
|
18 |
ilm |
892 |
this.tableElementPoidsTotal.setModifier(new CellDynamicModifier() {
|
93 |
ilm |
893 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
18 |
ilm |
894 |
Number f = (Number) row.getObject("POIDS");
|
|
|
895 |
int qte = Integer.parseInt(row.getObject("QTE").toString());
|
61 |
ilm |
896 |
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
|
|
|
897 |
// FIXME convertir en float autrement pour éviter une valeur non valeur transposable
|
|
|
898 |
// avec floatValue ou passer POIDS en bigDecimal
|
|
|
899 |
return b.multiply(new BigDecimal(f.floatValue() * qte)).floatValue();
|
18 |
ilm |
900 |
}
|
|
|
901 |
|
|
|
902 |
});
|
|
|
903 |
|
|
|
904 |
// Calcul automatique du poids total livrée
|
|
|
905 |
tableElementPoids.addModificationListener(this.tableElementPoidsTotalLivree);
|
|
|
906 |
tableElement_QuantiteLivree.addModificationListener(this.tableElementPoidsTotalLivree);
|
|
|
907 |
this.tableElementPoidsTotalLivree.setModifier(new CellDynamicModifier() {
|
93 |
ilm |
908 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
18 |
ilm |
909 |
|
|
|
910 |
Number f = (Number) row.getObject("POIDS");
|
|
|
911 |
|
|
|
912 |
Object qteOb = row.getObject("QTE_LIVREE");
|
|
|
913 |
int qte = (qteOb == null) ? 0 : Integer.parseInt(qteOb.toString());
|
|
|
914 |
|
|
|
915 |
float fValue = (f == null) ? 0.0F : f.floatValue();
|
61 |
ilm |
916 |
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
|
|
|
917 |
// FIXME convertir en float autrement pour éviter une valeur non transposable
|
|
|
918 |
// avec floatValue ou passer POIDS en bigDecimal
|
|
|
919 |
return b.multiply(new BigDecimal(fValue * qte)).floatValue();
|
18 |
ilm |
920 |
}
|
|
|
921 |
});
|
|
|
922 |
|
93 |
ilm |
923 |
tableElement_PrixMetrique1_VenteHT.setModifier(new CellDynamicModifier() {
|
|
|
924 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
|
|
925 |
if (source != null && source.getField().getName().equals("PRIX_METRIQUE_VT_1")) {
|
|
|
926 |
return row.getObject("PRIX_METRIQUE_VT_1");
|
|
|
927 |
} else {
|
|
|
928 |
if (source != null && source.getField().getName().equals("PV_U_DEVISE")) {
|
|
|
929 |
if (!row.isForeignEmpty("ID_DEVISE")) {
|
|
|
930 |
String devCode = row.getForeign("ID_DEVISE").getString("CODE");
|
|
|
931 |
BigDecimal bigDecimal = (BigDecimal) row.getObject("PV_U_DEVISE");
|
|
|
932 |
CurrencyConverter c = new CurrencyConverter();
|
|
|
933 |
BigDecimal result = c.convert(bigDecimal, devCode, c.getCompanyCurrencyCode(), new Date(), true);
|
|
|
934 |
return result;
|
|
|
935 |
} else {
|
|
|
936 |
return row.getObject("PRIX_METRIQUE_VT_1");
|
|
|
937 |
}
|
|
|
938 |
}
|
151 |
ilm |
939 |
// On ne recalcule pas le tarif si la ligne vient d'une commande
|
|
|
940 |
boolean noCmdElt = row.getObject("ID_COMMANDE_CLIENT_ELEMENT") == null || row.isForeignEmpty("ID_COMMANDE_CLIENT_ELEMENT");
|
|
|
941 |
if (!noCmdElt) {
|
|
|
942 |
return row.getObject("PRIX_METRIQUE_VT_1");
|
|
|
943 |
}
|
93 |
ilm |
944 |
return tarifCompletion(row.getForeign("ID_ARTICLE"), "PRIX_METRIQUE_VT_1", row);
|
|
|
945 |
}
|
|
|
946 |
}
|
|
|
947 |
|
|
|
948 |
});
|
|
|
949 |
|
156 |
ilm |
950 |
if (showDevise) {
|
93 |
ilm |
951 |
if (eltUnitDevise != null) {
|
|
|
952 |
eltUnitDevise.addModificationListener(tableElement_PrixMetrique1_VenteHT);
|
|
|
953 |
}
|
|
|
954 |
|
|
|
955 |
if (eltUnitDevise != null) {
|
|
|
956 |
tableElement_PrixMetrique1_VenteHT.addModificationListener(eltUnitDevise);
|
94 |
ilm |
957 |
tableElementRemise.addModificationListener(this.tableElementTotalDevise);
|
93 |
ilm |
958 |
eltUnitDevise.setModifier(new CellDynamicModifier() {
|
|
|
959 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
|
|
960 |
if (source != null && source.getField().getName().equals("PV_U_DEVISE")) {
|
|
|
961 |
return row.getObject("PV_U_DEVISE");
|
|
|
962 |
} else {
|
|
|
963 |
if (!row.isForeignEmpty("ID_DEVISE")) {
|
|
|
964 |
String devCode = row.getForeign("ID_DEVISE").getString("CODE");
|
|
|
965 |
BigDecimal bigDecimal = (BigDecimal) row.getObject("PRIX_METRIQUE_VT_1");
|
|
|
966 |
CurrencyConverter c = new CurrencyConverter();
|
|
|
967 |
BigDecimal result = c.convert(bigDecimal, c.getCompanyCurrencyCode(), devCode, new Date(), true);
|
|
|
968 |
return result;
|
|
|
969 |
} else if (source != null && source.getField().getName().equalsIgnoreCase("PRIX_METRIQUE_VT_1")) {
|
|
|
970 |
return row.getObject("PRIX_METRIQUE_VT_1");
|
|
|
971 |
}
|
151 |
ilm |
972 |
// On ne recalcule pas le tarif si la ligne vient d'une commande
|
|
|
973 |
boolean noCmdElt = row.getObject("ID_COMMANDE_CLIENT_ELEMENT") == null || row.isForeignEmpty("ID_COMMANDE_CLIENT_ELEMENT");
|
|
|
974 |
if (!noCmdElt) {
|
|
|
975 |
return row.getObject("PV_U_DEVISE");
|
|
|
976 |
}
|
93 |
ilm |
977 |
return row.getObject("PV_U_DEVISE");
|
|
|
978 |
}
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
});
|
94 |
ilm |
982 |
tableElementRemise.addModificationListener(this.tableElementTotalDevise);
|
|
|
983 |
tableElementTotalDevise.setModifier(new CellDynamicModifier() {
|
|
|
984 |
@Override
|
|
|
985 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
142 |
ilm |
986 |
int qte = row.getInt("QTE_LIVREE");
|
94 |
ilm |
987 |
BigDecimal prixDeVenteUnitaireDevise = (row.getObject("PV_U_DEVISE") == null) ? BigDecimal.ZERO : (BigDecimal) row.getObject("PV_U_DEVISE");
|
|
|
988 |
BigDecimal qUnitaire = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
|
|
|
989 |
// r = prixUnitaire x qUnitaire x qte
|
|
|
990 |
BigDecimal prixVente = qUnitaire.multiply(prixDeVenteUnitaireDevise.multiply(BigDecimal.valueOf(qte), DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION);
|
|
|
991 |
|
|
|
992 |
if (row.getTable().getFieldsName().contains("MONTANT_REMISE")) {
|
|
|
993 |
final BigDecimal acomptePercent = row.getBigDecimal("POURCENT_REMISE");
|
|
|
994 |
final BigDecimal acompteMontant = row.getBigDecimal("MONTANT_REMISE");
|
|
|
995 |
Remise remise = new Remise(acomptePercent, acompteMontant);
|
|
|
996 |
prixVente = remise.getResultFrom(prixVente);
|
|
|
997 |
}
|
|
|
998 |
|
|
|
999 |
// if (lremise.compareTo(BigDecimal.ZERO) > 0 &&
|
|
|
1000 |
// lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
|
|
|
1001 |
// r = r.multiply(BigDecimal.valueOf(100).subtract(lremise),
|
|
|
1002 |
// DecimalUtils.HIGH_PRECISION).movePointLeft(2);
|
|
|
1003 |
// }
|
|
|
1004 |
return prixVente.setScale(tableElementTotalDevise.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
|
|
|
1005 |
}
|
|
|
1006 |
});
|
93 |
ilm |
1007 |
}
|
|
|
1008 |
}
|
|
|
1009 |
|
18 |
ilm |
1010 |
// Calcul automatique du prix de vente unitaire HT
|
|
|
1011 |
tableElement_ValeurMetrique1.addModificationListener(tableElement_PrixVente_HT);
|
|
|
1012 |
tableElement_ValeurMetrique2.addModificationListener(tableElement_PrixVente_HT);
|
|
|
1013 |
tableElement_ValeurMetrique3.addModificationListener(tableElement_PrixVente_HT);
|
|
|
1014 |
tableElement_PrixMetrique1_VenteHT.addModificationListener(tableElement_PrixVente_HT);
|
|
|
1015 |
tableElement_PrixVente_HT.setModifier(new CellDynamicModifier() {
|
93 |
ilm |
1016 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
18 |
ilm |
1017 |
if (row.getInt("ID_MODE_VENTE_ARTICLE") == ReferenceArticleSQLElement.A_LA_PIECE) {
|
|
|
1018 |
System.err.println("Don't computeValue PV_HT --> " + row.getObject("PV_HT") + row);
|
67 |
ilm |
1019 |
return row.getObject("PRIX_METRIQUE_VT_1");
|
18 |
ilm |
1020 |
} else {
|
|
|
1021 |
|
67 |
ilm |
1022 |
final BigDecimal prixVTFromDetails = ReferenceArticleSQLElement.getPrixVTFromDetails(row);
|
18 |
ilm |
1023 |
System.out.println("Prix de vente calculé au détail:" + prixVTFromDetails);
|
67 |
ilm |
1024 |
return prixVTFromDetails.setScale(tableElement_PrixVente_HT.getDecimalDigits(), RoundingMode.HALF_UP);
|
18 |
ilm |
1025 |
}
|
|
|
1026 |
}
|
|
|
1027 |
});
|
|
|
1028 |
|
142 |
ilm |
1029 |
// Calcul automatique du prix de achat unitaire HT
|
|
|
1030 |
tableElement_ValeurMetrique1.addModificationListener(ha);
|
|
|
1031 |
tableElement_ValeurMetrique2.addModificationListener(ha);
|
|
|
1032 |
tableElement_ValeurMetrique3.addModificationListener(ha);
|
|
|
1033 |
tableElement_PrixMetrique1_AchatHT.addModificationListener(ha);
|
|
|
1034 |
this.ha.setModifier(new CellDynamicModifier() {
|
|
|
1035 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
|
|
1036 |
if (row.isForeignEmpty("ID_MODE_VENTE_ARTICLE") || row.getInt("ID_MODE_VENTE_ARTICLE") == ReferenceArticleSQLElement.A_LA_PIECE) {
|
|
|
1037 |
return row.getObject("PRIX_METRIQUE_HA_1");
|
|
|
1038 |
} else {
|
|
|
1039 |
|
|
|
1040 |
final BigDecimal prixHAFromDetails = ReferenceArticleSQLElement.getPrixHAFromDetails(row);
|
|
|
1041 |
return prixHAFromDetails.setScale(ha.getDecimalDigits(), RoundingMode.HALF_UP);
|
|
|
1042 |
}
|
|
|
1043 |
}
|
|
|
1044 |
});
|
|
|
1045 |
|
18 |
ilm |
1046 |
this.table.readState();
|
|
|
1047 |
|
93 |
ilm |
1048 |
tableFamille.addModificationListener(tableElementArticle);
|
61 |
ilm |
1049 |
tableElementCode.addModificationListener(tableElementArticle);
|
|
|
1050 |
tableElementArticle.setModifier(new CellDynamicModifier() {
|
|
|
1051 |
@Override
|
93 |
ilm |
1052 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
|
|
1053 |
|
132 |
ilm |
1054 |
if (filterFamilleArticle) {
|
93 |
ilm |
1055 |
|
132 |
ilm |
1056 |
if (row.isForeignEmpty("ID_FAMILLE_ARTICLE")) {
|
151 |
ilm |
1057 |
m.setWhere(null);
|
|
|
1058 |
m2.setWhere(null);
|
132 |
ilm |
1059 |
|
|
|
1060 |
} else {
|
151 |
ilm |
1061 |
m.setWhere(new Where(sqlTableArticle.getField("ID_FAMILLE_ARTICLE"), "=", row.getForeignID("ID_FAMILLE_ARTICLE")));
|
|
|
1062 |
m2.setWhere(new Where(sqlTableArticle.getField("ID_FAMILLE_ARTICLE"), "=", row.getForeignID("ID_FAMILLE_ARTICLE")));
|
132 |
ilm |
1063 |
}
|
93 |
ilm |
1064 |
}
|
61 |
ilm |
1065 |
SQLRowAccessor foreign = row.getForeign("ID_ARTICLE");
|
|
|
1066 |
if (foreign != null && !foreign.isUndefined() && foreign.getObject("CODE") != null && foreign.getString("CODE").equals(row.getString("CODE"))) {
|
|
|
1067 |
return foreign.getID();
|
|
|
1068 |
} else {
|
|
|
1069 |
return tableArticle.getUndefinedID();
|
|
|
1070 |
}
|
|
|
1071 |
}
|
|
|
1072 |
});
|
|
|
1073 |
|
18 |
ilm |
1074 |
// Mode Gestion article avancé
|
|
|
1075 |
String valModeAvanceVt = DefaultNXProps.getInstance().getStringProperty("ArticleModeVenteAvance");
|
|
|
1076 |
Boolean bModeAvance = Boolean.valueOf(valModeAvanceVt);
|
|
|
1077 |
if (bModeAvance != null && !bModeAvance.booleanValue()) {
|
|
|
1078 |
hideColumn(model.getColumnForField("VALEUR_METRIQUE_1"));
|
|
|
1079 |
hideColumn(model.getColumnForField("VALEUR_METRIQUE_2"));
|
|
|
1080 |
hideColumn(model.getColumnForField("VALEUR_METRIQUE_3"));
|
|
|
1081 |
hideColumn(model.getColumnForField("PV_HT"));
|
142 |
ilm |
1082 |
hideColumn(model.getColumnForField("PA_HT"));
|
18 |
ilm |
1083 |
hideColumn(model.getColumnForField("ID_MODE_VENTE_ARTICLE"));
|
|
|
1084 |
}
|
61 |
ilm |
1085 |
|
80 |
ilm |
1086 |
// Packaging
|
|
|
1087 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
|
93 |
ilm |
1088 |
setColumnVisible(model.getColumnForField("T_POIDS_COLIS_NET"), false);
|
80 |
ilm |
1089 |
}
|
|
|
1090 |
|
93 |
ilm |
1091 |
setColumnVisible(model.getColumnForField("ID_ARTICLE"), selectArticle);
|
|
|
1092 |
setColumnVisible(model.getColumnForField("CODE"), !selectArticle || (selectArticle && createAuto));
|
|
|
1093 |
setColumnVisible(model.getColumnForField("NOM"), !selectArticle || (selectArticle && createAuto));
|
61 |
ilm |
1094 |
|
93 |
ilm |
1095 |
setColumnVisible(getModel().getColumnForField("ID_FAMILLE_ARTICLE"), filterFamilleArticle);
|
|
|
1096 |
|
142 |
ilm |
1097 |
if (this.tableElementEco != null && this.tableElementEcoTotal != null && this.tableElementEcoID != null) {
|
|
|
1098 |
setColumnVisible(model.getColumnForField("ID_ECO_CONTRIBUTION"), showEco);
|
|
|
1099 |
setColumnVisible(model.getColumnForField("ECO_CONTRIBUTION"), showEco);
|
|
|
1100 |
setColumnVisible(model.getColumnForField("T_ECO_CONTRIBUTION"), showEco);
|
|
|
1101 |
}
|
|
|
1102 |
|
61 |
ilm |
1103 |
// Gestion des unités de vente
|
|
|
1104 |
final boolean gestionUV = prefs.getBoolean(GestionArticleGlobalPreferencePanel.UNITE_VENTE, true);
|
93 |
ilm |
1105 |
setColumnVisible(model.getColumnForField("QTE_UNITAIRE"), gestionUV);
|
|
|
1106 |
setColumnVisible(model.getColumnForField("ID_UNITE_VENTE"), gestionUV);
|
61 |
ilm |
1107 |
|
142 |
ilm |
1108 |
setColumnVisible(model.getColumnForField("PRIX_METRIQUE_HA_1"), showHAPrice);
|
156 |
ilm |
1109 |
setColumnVisible(model.getColumnForField("MARGE_HT"), showHAPrice);
|
142 |
ilm |
1110 |
setColumnVisible(model.getColumnForField("T_PA_HT"), showHAPrice);
|
|
|
1111 |
|
|
|
1112 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
|
|
1113 |
setColumnVisible(model.getColumnForField("ID_COMMANDE_CLIENT_ELEMENT"), false);
|
|
|
1114 |
}
|
|
|
1115 |
// Barcode reader
|
|
|
1116 |
final BarcodeReader barcodeReader = ComptaPropsConfiguration.getInstanceCompta().getBarcodeReader();
|
|
|
1117 |
if (barcodeReader != null) {
|
|
|
1118 |
|
|
|
1119 |
final BarcodeListener l = new BarcodeListener() {
|
|
|
1120 |
|
|
|
1121 |
@Override
|
|
|
1122 |
public void keyReceived(KeyEvent ee) {
|
|
|
1123 |
// TODO Auto-generated method stub
|
|
|
1124 |
}
|
|
|
1125 |
|
|
|
1126 |
@Override
|
|
|
1127 |
public void barcodeRead(String code) {
|
|
|
1128 |
if (((JFrame) SwingUtilities.getRoot(getRowValuesTable())).isActive()) {
|
|
|
1129 |
final SQLSelect selArticle = new SQLSelect();
|
|
|
1130 |
final SQLTable tableArticle = getSQLElement().getForeignElement("ID_ARTICLE").getTable();
|
|
|
1131 |
selArticle.addSelectStar(tableArticle);
|
|
|
1132 |
Where w = new Where(tableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
|
|
|
1133 |
w = w.and(new Where(tableArticle.getField("CODE_BARRE"), "=", code));
|
|
|
1134 |
selArticle.setWhere(w);
|
|
|
1135 |
List<SQLRow> l2 = SQLRowListRSH.execute(selArticle);
|
|
|
1136 |
if (l2.size() > 0) {
|
|
|
1137 |
System.err.println("ARTICLE " + l2.get(0).getString("NOM"));
|
|
|
1138 |
Tuple3<Double, String, String> art = Tuple3.create(1.0D, l2.get(0).getString("CODE"), l2.get(0).getString("NOM"));
|
|
|
1139 |
List<Tuple3<Double, String, String>> l = new ArrayList<Tuple3<Double, String, String>>();
|
|
|
1140 |
l.add(art);
|
|
|
1141 |
insertFromDrop(l, m);
|
|
|
1142 |
} else {
|
|
|
1143 |
System.err.println("ARTICLE NOT FOUND !");
|
|
|
1144 |
}
|
|
|
1145 |
}
|
|
|
1146 |
|
|
|
1147 |
}
|
|
|
1148 |
};
|
|
|
1149 |
getRowValuesTable().addHierarchyListener(new HierarchyListener() {
|
|
|
1150 |
public void hierarchyChanged(HierarchyEvent e) {
|
|
|
1151 |
if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0)
|
|
|
1152 |
if (getRowValuesTable().isDisplayable()) {
|
|
|
1153 |
barcodeReader.addBarcodeListener(l);
|
|
|
1154 |
} else {
|
|
|
1155 |
barcodeReader.removeBarcodeListener(l);
|
|
|
1156 |
}
|
|
|
1157 |
}
|
|
|
1158 |
});
|
|
|
1159 |
|
|
|
1160 |
}
|
|
|
1161 |
|
18 |
ilm |
1162 |
// On réécrit la configuration au cas ou les preferences aurait changé
|
|
|
1163 |
this.table.writeState();
|
|
|
1164 |
|
|
|
1165 |
}
|
|
|
1166 |
|
|
|
1167 |
@Override
|
|
|
1168 |
public float getPoidsTotal() {
|
|
|
1169 |
|
|
|
1170 |
float poids = 0.0F;
|
93 |
ilm |
1171 |
int poidsTColIndex = getModel().getColumnIndexForElement(this.tableElementPoidsTotalLivree);
|
18 |
ilm |
1172 |
if (poidsTColIndex >= 0) {
|
|
|
1173 |
for (int i = 0; i < table.getRowCount(); i++) {
|
93 |
ilm |
1174 |
Number tmp = (Number) getModel().getValueAt(i, poidsTColIndex);
|
18 |
ilm |
1175 |
if (tmp != null) {
|
|
|
1176 |
poids += tmp.floatValue();
|
|
|
1177 |
}
|
|
|
1178 |
}
|
|
|
1179 |
}
|
|
|
1180 |
return poids;
|
|
|
1181 |
}
|
|
|
1182 |
|
|
|
1183 |
@Override
|
|
|
1184 |
protected String getConfigurationFileName() {
|
|
|
1185 |
return "Table_Bon_Livraison.xml";
|
|
|
1186 |
}
|
|
|
1187 |
|
|
|
1188 |
@Override
|
|
|
1189 |
public SQLElement getSQLElement() {
|
|
|
1190 |
return Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON_ELEMENT");
|
|
|
1191 |
}
|
|
|
1192 |
|
142 |
ilm |
1193 |
@Override
|
|
|
1194 |
protected List<AbstractAction> getAdditionnalMouseAction(final int rowIndex) {
|
|
|
1195 |
List<AbstractAction> actions = new ArrayList<AbstractAction>();
|
|
|
1196 |
actions.addAll(super.getAdditionnalMouseAction(rowIndex));
|
|
|
1197 |
actions.add(new AbstractAction("Ajouter un reliquat") {
|
|
|
1198 |
|
|
|
1199 |
@Override
|
|
|
1200 |
public void actionPerformed(ActionEvent e) {
|
|
|
1201 |
if (reliquatTable != null) {
|
|
|
1202 |
SQLRowAccessor sqlRowArticleChildElement = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(rowIndex);
|
|
|
1203 |
final SQLRowValues row2Insert = new SQLRowValues(reliquatTable.getDefaultRowValues());
|
|
|
1204 |
|
|
|
1205 |
row2Insert.put("ID_BON_DE_LIVRAISON_ELEMENT", sqlRowArticleChildElement);
|
|
|
1206 |
|
|
|
1207 |
row2Insert.put("QTE", 1);
|
|
|
1208 |
row2Insert.put("QTE_UNITAIRE", BigDecimal.ONE);
|
|
|
1209 |
|
|
|
1210 |
reliquatTable.getRowValuesTable().getRowValuesTableModel().addRow(row2Insert);
|
|
|
1211 |
}
|
|
|
1212 |
}
|
|
|
1213 |
});
|
|
|
1214 |
return actions;
|
|
|
1215 |
}
|
|
|
1216 |
|
18 |
ilm |
1217 |
private void hideColumn(int col) {
|
|
|
1218 |
if (col >= 0) {
|
|
|
1219 |
// this.table.getColumnModel().getColumn(col).setResizable(false);
|
|
|
1220 |
// this.table.getColumnModel().getColumn(col).setMinWidth(0);
|
|
|
1221 |
// this.table.getColumnModel().getColumn(col).setMaxWidth(0);
|
|
|
1222 |
// this.table.getColumnModel().getColumn(col).setPreferredWidth(0);
|
|
|
1223 |
// this.table.getColumnModel().getColumn(col).setWidth(0);
|
|
|
1224 |
// this.table.getMaskTableModel().hideColumn(col);
|
|
|
1225 |
XTableColumnModel columnModel = this.table.getColumnModel();
|
|
|
1226 |
|
|
|
1227 |
columnModel.setColumnVisible(columnModel.getColumnByModelIndex(col), false);
|
|
|
1228 |
|
|
|
1229 |
}
|
|
|
1230 |
}
|
|
|
1231 |
}
|