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