OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 72 → Rev 73

/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/DepartementSQLElement.java
15,6 → 15,7
 
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
54,7 → 55,7
return new BaseSQLComponent(this) {
public void addViews() {
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridx = GridBagConstraints.RELATIVE;
 
JTextField textNom = new JTextField();
63,8 → 64,11
JLabel labelCode = new JLabel(getLabelFor("NUMERO"));
 
this.add(labelCode, c);
c.weightx = 1;
this.add(textCode, c);
c.weightx = 0;
this.add(labelNom, c);
c.weightx = 1;
this.add(textNom, c);
 
c.gridy++;
72,13 → 76,19
JTextField textRegionAdmin = new JTextField();
JLabel labelChef = new JLabel(getLabelFor("CHEF_LIEU"));
JLabel labelRegionAdmin = new JLabel(getLabelFor("REGION_ADMIN"));
c.weightx = 0;
this.add(labelChef, c);
c.weightx = 1;
this.add(textChef, c);
c.weightx = 0;
this.add(labelRegionAdmin, c);
c.weightx = 1;
this.add(textRegionAdmin, c);
 
this.addSQLObject(textCode, "NUMERO");
this.addSQLObject(textNom, "NOM");
this.addSQLObject(textChef, "CHEF_LIEU");
this.addSQLObject(textRegionAdmin, "REGION_ADMIN");
}
};
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/ComptaSQLConfElement.java
69,13 → 69,17
}
 
public ComptaSQLConfElement(String tableName, String singular, String plural) {
this(tableName, singular, plural, null);
super(singular, plural, getBaseSociete().findTable(tableName, true));
}
 
public ComptaSQLConfElement(String tableName, String singular, String plural, final String id) {
super(singular, plural, getBaseSociete().findTable(tableName, true), id);
public ComptaSQLConfElement(String tableName) {
this(tableName, null);
}
 
public ComptaSQLConfElement(String tableName, String code) {
super(getBaseSociete().findTable(tableName, true), null, code);
}
 
@Override
protected String createCode() {
return createCodeFromPackage();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/NumerotationAutoSQLElement.java
334,18 → 334,32
 
}
 
private static boolean isNumeroExist(SQLElement elt, int num) {
private static boolean isNumeroExist(SQLElement element, int num) {
if (num < 0) {
return true;
}
SQLSelect sel = new SQLSelect(elt.getTable().getBase());
 
String s = map.get(element.getClass());
 
for (Class<? extends SQLElement> e : map.keySet()) {
String prefix = map.get(e);
if (prefix.equals(s)) {
SQLSelect sel = new SQLSelect();
 
SQLElement elt = Configuration.getInstance().getDirectory().getElement(e);
 
sel.addSelect(elt.getTable().getKey());
 
sel.setWhere(new Where(elt.getTable().getField("NUMERO"), "LIKE", getPattern(elt, num)));
System.err.println("NumerotationAutoSQLElement.isNumeroExist() " + sel.asString());
List<SQLRow> liste = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new SQLRowListRSH(elt.getTable(), true));
return liste.size() > 0;
if (liste.size() > 0) {
return true;
}
}
}
return false;
}
 
protected static final SQLTable TABLE_NUM = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("NUMEROTATION_AUTO");
 
444,6 → 458,7
 
SQLRow rowNum = TABLE_NUM.getRow(2);
String s = map.get(elt.getClass());
if (!rowNum.getTable().contains(s + AUTO_MONTH) || !rowNum.getBoolean(s + AUTO_MONTH)) {
int start = rowNum.getInt(s + START);
 
// si le numero precedent n'existe pas
466,6 → 481,7
}
}
}
}
 
private static Map<Class<? extends SQLElement>, String> map = new HashMap<Class<? extends SQLElement>, String>();
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/AdresseSQLElement.java
28,6 → 28,7
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("RUE");
l.add("CODE_POSTAL");
l.add("VILLE");
return l;
}
35,6 → 36,7
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("RUE");
l.add("CODE_POSTAL");
l.add("VILLE");
return l;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/ITextComboVilleTableCellEditor.java
13,7 → 13,10
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.map.model.Ville;
import org.openconcerto.map.ui.ITextComboVilleViewer;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
 
import java.awt.Component;
import java.awt.event.KeyListener;
24,7 → 27,6
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
 
 
public class ITextComboVilleTableCellEditor extends AbstractCellEditor implements TableCellEditor {
 
private ITextComboVilleViewer comboBox;
55,7 → 57,12
 
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
// System.err.println("SQLTextComboEditor.getTableCellEditorComponent()");
this.comboBox.setValue(value.toString());
RowValuesTable rowValuesTable = ((RowValuesTable) table);
SQLRowValues rowVals = rowValuesTable.getRowValuesTableModel().getRowValuesAt(row);
String v = rowVals.getString("VILLE");
String code = rowVals.getString("CODE_POSTAL");
Ville ville = Ville.getVilleFromVilleEtCode(v + " (" + code + ")");
this.comboBox.setValue(ville);
this.comboBox.grabFocus();
return this.comboBox;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCalculator.java
26,13 → 26,15
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
public class TotalCalculator {
 
private static String FIELD_SERVICE = "SERVICE";
private static String FIELD_POIDS = "POIDS";
private static String FIELD_POIDS = "T_POIDS";
private final String fieldHT, fieldHA, fieldDevise;
 
private SQLRowAccessor rowDefaultCptProduit, rowDefaultCptService, rowDefaultCptTVA;
39,7 → 41,7
private static final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
 
double totalPoids;
private double totalPoids;
 
private BigDecimal totalDevise, totalDeviseSel;
private BigDecimal totalHA, totalHASel;
54,7 → 56,7
// Total des TVA par comptes
private Map<SQLRowAccessor, BigDecimal> mapHtTVA = new HashMap<SQLRowAccessor, BigDecimal>();
private Map<SQLRowAccessor, BigDecimal> mapHtTVASel = new HashMap<SQLRowAccessor, BigDecimal>();
int[] selectedRows;
private int[] selectedRows;
 
private Boolean bServiceActive;
private BigDecimal totalHTAvantRemise;
293,11 → 295,17
cpt = compteArticle;
} else {
SQLRowAccessor familleArticle = article.getForeign("ID_FAMILLE_ARTICLE");
if (familleArticle != null && !familleArticle.isUndefined()) {
Set<SQLRowAccessor> unique = new HashSet<SQLRowAccessor>();
while (familleArticle != null && !familleArticle.isUndefined() && !unique.contains(familleArticle)) {
 
unique.add(familleArticle);
SQLRowAccessor compteFamilleArticle = familleArticle.getForeign("ID_COMPTE_PCE");
if (compteFamilleArticle != null && !compteFamilleArticle.isUndefined()) {
cpt = compteFamilleArticle;
break;
}
 
familleArticle = familleArticle.getForeign("ID_FAMILLE_ARTICLE_PERE");
}
}
}
329,7 → 337,7
totalHASel = totalHASel.add(totalHALigne);
 
if (bServiceActive != null && bServiceActive) {
if (service) {
if (service != null && service.booleanValue()) {
totalServiceSel = totalServiceSel.add(totalLineHT);
}
}
339,11 → 347,17
}
}
 
// TODO Ne pas fetcher la TVA pour chaque instance de TotalCalculator utiliser un cache
if (mapTVA == null) {
fetchTVA();
}
addHT(totalLineHT, mapTVA.get(rowAccessorLine.getObject("ID_TAXE")), cpt, selection);
final SQLRowAccessor foreignTVA = rowAccessorLine.getForeign("ID_TAXE");
Integer idTVA = null;
if (foreignTVA != null) {
idTVA = foreignTVA.getID();
}
addHT(totalLineHT, mapTVA.get(idTVA), cpt, selection);
}
 
/**
* Vérifie si ht + tva = ttc
350,16 → 364,13
*/
public void checkResult() {
BigDecimal ht = getTotalHT();
 
BigDecimal tva = getTotalTVA();
 
BigDecimal totalTTC2 = getTotalTTC();
BigDecimal reste = totalTTC2.subtract(ht.add(tva));
if (reste.compareTo(BigDecimal.ZERO) != 0) {
System.err.println("HT " + ht);
System.err.println("TVA " + tva);
System.err.println("TTC " + totalTTC2);
Thread.dumpStack();
System.err.print("Ecarts: " + reste + "(HT:" + ht);
System.err.print(" TVA:" + tva);
System.err.println(" TTC:" + totalTTC2);
SQLRow row = ComptePCESQLElement.getRow("758", "Ecarts arrondis");
// TODO Check if row already exist in MAP ??
this.mapHt.put(row, reste);
412,7 → 423,6
}
 
public BigDecimal getTotalTTC() {
 
return this.totalTTC.setScale(2, RoundingMode.HALF_UP);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractAchatArticleItemTable.java
24,7 → 24,6
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
50,20 → 49,17
 
public abstract class AbstractAchatArticleItemTable extends AbstractArticleItemTable {
 
private AutoCompletionManager m;
private AutoCompletionManager m2, m3;
private AutoCompletionManager m4;
private final SQLTable tableArticle = getSQLElement().getTable().getTable("ARTICLE");
private SQLRowAccessor rowDevise;
private boolean supplierCode;
 
public AbstractAchatArticleItemTable() {
super();
}
 
AutoCompletionManager m;
AutoCompletionManager m2, m3;
AutoCompletionManager m4;
private final SQLTable tableArticle = getSQLElement().getTable().getTable("ARTICLE");
 
private boolean supplierCode;
 
/**
*
*/
protected void init() {
 
final SQLElement e = getSQLElement();
103,6 → 99,10
// Désignation de l'article
final SQLTableElement tableElementNom = new SQLTableElement(e.getTable().getField("NOM"));
list.add(tableElementNom);
if (e.getTable().getFieldsName().contains("DESCRIPTIF")) {
final SQLTableElement tableElementDesc = new SQLTableElement(e.getTable().getField("DESCRIPTIF"));
list.add(tableElementDesc);
}
if (e.getTable().getFieldsName().contains("COLORIS")) {
final SQLTableElement tableElementColoris = new SQLTableElement(e.getTable().getField("COLORIS"));
list.add(tableElementColoris);
116,10 → 116,12
list.add(tableElement_ValeurMetrique1);
// Prix d'achat HT de la métrique 1
final SQLTableElement tableElement_PrixMetrique1_AchatHT = new SQLTableElement(e.getTable().getField("PRIX_METRIQUE_HA_1"), BigDecimal.class);
tableElement_PrixMetrique1_AchatHT.setRenderer(new DeviseTableCellRenderer());
list.add(tableElement_PrixMetrique1_AchatHT);
 
final SQLTableElement tableElement_Devise = new SQLTableElement(e.getTable().getField("ID_DEVISE"));
final SQLTableElement tableElement_PA_Devise = new SQLTableElement(e.getTable().getField("PA_DEVISE"), BigDecimal.class);
tableElement_PA_Devise.setRenderer(new DeviseTableCellRenderer());
if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) {
// Devise
list.add(tableElement_Devise);
133,6 → 135,7
 
// Prix d'achat unitaire HT
this.ha = new SQLTableElement(e.getTable().getField("PA_HT"), BigDecimal.class);
this.ha.setRenderer(new DeviseTableCellRenderer());
list.add(this.ha);
 
SQLTableElement qteU = new SQLTableElement(e.getTable().getField("QTE_UNITAIRE"), BigDecimal.class) {
190,6 → 193,7
if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) {
// Prix d'achat HT devise
this.tableElementTotalDevise = new SQLTableElement(e.getTable().getField("PA_DEVISE_T"), BigDecimal.class);
this.tableElementTotalDevise.setRenderer(new DeviseTableCellRenderer());
list.add(tableElementTotalDevise);
}
 
201,8 → 205,9
 
// Total HT
this.totalHT = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
this.totalHT.setRenderer(new DeviseTableCellRenderer());
this.totalHT.setEditable(false);
if (e.getTable().contains("POURCENT_REMISE")) {
if (e.getTable().contains("POURCENT_REMISE") && tableElementRemise != null) {
tableElementRemise.addModificationListener(this.totalHT);
}
list.add(this.totalHT);
209,6 → 214,7
this.totalHA = this.totalHT;
// Total TTC
this.tableElementTotalTTC = new SQLTableElement(e.getTable().getField("T_PA_TTC"), BigDecimal.class);
this.tableElementTotalTTC.setRenderer(new DeviseTableCellRenderer());
list.add(this.tableElementTotalTTC);
 
this.model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, null);
240,6 → 246,9
if (e.getTable().getFieldsName().contains("COLORIS")) {
completionFields.add("COLORIS");
}
if (e.getTable().getFieldsName().contains("DESCRIPTIF")) {
completionFields.add("DESCRIPTIF");
}
if (e.getTable().getFieldsName().contains("ID_FAMILLE_ARTICLE")) {
completionFields.add("ID_FAMILLE_ARTICLE");
}
337,8 → 346,6
this.totalHT.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(final SQLRowValues row) {
 
// Object qteObject = row.getObject("QTE");
// int qte = (qteObject == null) ? 0 : Integer.parseInt(qteObject.toString());
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal f = (BigDecimal) row.getObject("PA_HT");
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
362,17 → 369,13
qteElement.addModificationListener(this.tableElementTotalDevise);
qteU.addModificationListener(this.tableElementTotalDevise);
tableElement_PA_Devise.addModificationListener(this.tableElementTotalDevise);
if (e.getTable().contains("POURCENT_REMISE")) {
if (e.getTable().contains("POURCENT_REMISE") && tableElementRemise != null) {
tableElementRemise.addModificationListener(this.tableElementTotalDevise);
}
this.tableElementTotalDevise.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(final SQLRowValues row) {
 
// Object qteObject = row.getObject("QTE");
// int qte = (qteObject == null) ? 0 : Integer.parseInt(qteObject.toString());
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal f = (BigDecimal) row.getObject("PA_DEVISE");
// long longValue = (f == null) ? 0 : f.longValue();
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte)), MathContext.DECIMAL128).setScale(tableElementTotalDevise.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
 
397,8 → 400,6
this.tableElementTotalTTC.setModifier(new CellDynamicModifier() {
@Override
public Object computeValueFrom(SQLRowValues row) {
// System.err.println("Calcul du total TTC");
 
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal f = (BigDecimal) row.getObject("PA_HT");
int idTaux = Integer.parseInt(row.getObject("ID_TAXE").toString());
410,10 → 411,8
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), MathContext.DECIMAL128), MathContext.DECIMAL128).setScale(tableElementTotalTTC.getDecimalDigits(),
BigDecimal.ROUND_HALF_UP);
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
 
// System.err.println("Calcul du total TTC : taux " + resultTaux + " : HT " + pHT);
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
// float taux = resultTaux.floatValue();
BigDecimal total = r.multiply(BigDecimal.ONE.add(new BigDecimal(taux / 100f))).setScale(tableElementTotalTTC.getDecimalDigits(), RoundingMode.HALF_UP);
return total;
}
460,13 → 459,10
qteU.addModificationListener(this.tableElementPoidsTotal);
this.tableElementPoidsTotal.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(SQLRowValues row) {
System.err.println("Calcul du poids total ");
// Number f = (Number) row.getObject("POIDS");
 
Number f = (row.getObject("POIDS") == null) ? 0 : (Number) row.getObject("POIDS");
int qte = Integer.parseInt(row.getObject("QTE").toString());
 
// return new Float(f.floatValue() * qte);
//
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
// FIXME convertir en float autrement pour éviter une valeur non transposable
// avec floatValue ou passer POIDS en bigDecimal
522,10 → 518,7
return visibilityMap;
}
 
private SQLRow rowFournisseur;
 
public void setFournisseur(SQLRow rowFournisseur) {
this.rowFournisseur = rowFournisseur;
 
if (getSQLElement().getTable().contains("ID_CODE_FOURNISSEUR") && this.supplierCode) {
 
557,8 → 550,6
return null;
}
 
SQLRowAccessor rowDevise;
 
public SQLRowAccessor getDevise() {
return this.rowDevise;
}
569,12 → 560,7
 
public void setFournisseurFilterOnCompletion(SQLRow row) {
if (row != null && !row.isUndefined()) {
 
Where w = new Where(this.tableArticle.getField("ID_FOURNISSEUR"), "=", row.getID());
// w = w.or(new Where(this.tableArticle.getField("ID_FOURNISSEUR"), "IS", (Object)
// null));
// w = w.or(new Where(this.tableArticle.getField("ID_FOURNISSEUR"), "=",
// getSQLElement().getTable().getTable("FOURNISSEUR").getUndefinedID()));
this.m.setWhere(w);
this.m2.setWhere(w);
this.m3.setWhere(w);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalPanel.java
40,7 → 40,6
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
69,9 → 68,8
private PropertyChangeSupport supp;
private int columnIndexEchHT = -1;
private int columnIndexEchTTC = -1;
SQLTableElement ha;
private SQLTableElement ha;
private SQLRequestComboBox selPortTVA;
private TotalCalculator calc;
 
AbstractArticleItemTable articleTable;
 
388,19 → 386,8
}
 
public void tableChanged(TableModelEvent e) {
int columnIndexForElementHT = this.articleTable.getModel().getColumnIndexForElement(this.articleTable.getPrixTotalHTElement());
int columnIndexForElementTVA = this.articleTable.getModel().getColumnIndexForElement(this.articleTable.getTVAElement());
int columnIndexForElementDevise = this.articleTable.getModel().getColumnIndexForElement(this.articleTable.getTableElementTotalDevise());
 
int columnIndexForElementEchHT = -1;
int columnIndexForElementEchTTC = -1;
 
if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexForElementHT || e.getColumn() == columnIndexForElementTVA || e.getColumn() == columnIndexForElementEchHT
|| e.getColumn() == columnIndexForElementEchTTC || e.getColumn() == columnIndexForElementDevise) {
// System.out.println(e);
updateTotal();
}
}
 
private static String CLEAR = "";
 
478,11 → 465,11
final SQLRow tvaPort = selPortTVA == null ? null : selPortTVA.getSelectedRow();
final SQLRowValues rowValsPort;
// TVA Port inclus
if (tvaPort != null && !valPortHT.equals(BigDecimal.ZERO) && !tvaPort.isUndefined()) {
if (tvaPort != null && valPortHT.signum() != 0 && !tvaPort.isUndefined()) {
rowValsPort = new SQLRowValues(articleTable.getSQLElement().getTable());
rowValsPort.put(articleTable.getPrixTotalHTElement().getField().getName(), valPortHT);
rowValsPort.put("QTE", 1);
rowValsPort.put("ID_TAXE", tvaPort);
rowValsPort.put("ID_TAXE", tvaPort.getIDNumber());
} else {
rowValsPort = null;
}
497,7 → 484,6
 
params.fetchArticle();
 
if (calc == null) {
SQLTableElement tableElementTotalDevise = articleTable.getTableElementTotalDevise();
String fieldDevise = (tableElementTotalDevise == null ? null : tableElementTotalDevise.getField().getName());
 
506,20 → 492,17
SQLTableElement tableElementTotalHT = articleTable.getPrixTotalHTElement();
String fieldHT = (tableElementTotalHT == null ? null : tableElementTotalHT.getField().getName());
 
calc = new TotalCalculator(fieldHA, fieldHT, fieldDevise);
 
}
calc.initValues();
final TotalCalculator calc = new TotalCalculator(fieldHA, fieldHT, fieldDevise);
calc.setSelectedRows(selectedRows);
 
// Calcul avant remise
final BigDecimal totalHTAvtremise;
 
final int size = list.size();
calc.setServiceActive(isServiceActive);
if (valRemiseHT != 0) {
calc.setServiceActive(isServiceActive);
 
for (int i = 0; i < list.size(); i++) {
 
for (int i = 0; i < size; i++) {
SQLRowValues rowVals = list.get(i);
calc.addLine(rowVals, params.getMapArticle().get(rowVals.getInt("ID_ARTICLE")), i, false);
}
538,14 → 521,17
}
 
calc.initValues();
calc.setSelectedRows(selectedRows);
calc.setRemise(valRemiseHT, totalHTAvtremise);
 
 
// Total des elements
int rowCount = list.size();
int rowCount = size;
for (int i = 0; i < rowCount; i++) {
SQLRowValues values = list.get(i);
calc.addLine(values, params.getMapArticle().get(values.getInt("ID_ARTICLE")), i, i == (rowCount - 1));
 
Object id = values.getObject("ID_ARTICLE");
calc.addLine(values, (id == null) ? null : params.getMapArticle().get(id), i, i == (rowCount - 1));
}
 
// TVA Port inclus
589,11 → 575,13
 
BigDecimal m = BigDecimal.ZERO;
BigDecimal d = BigDecimal.ZERO;
if (totalHA.compareTo(BigDecimal.ZERO) > 0) {
if (totalHA.signum() != 0) {
// d = totalHT.subtract(valRemiseHT).subtract(totalHA);
d = totalHT.subtract(totalHA);
if (DefaultNXProps.getInstance().getBooleanValue(MARGE_MARQUE, false)) {
if (totalHT.signum() != 0) {
m = d.divide(totalHT, MathContext.DECIMAL128).movePointRight(2);
}
} else {
m = d.divide(totalHA, MathContext.DECIMAL128).movePointRight(2);
}
631,10 → 619,8
 
}
supp.firePropertyChange("value", null, null);
} catch (InterruptedException e1) {
} catch (Exception e1) {
ExceptionHandler.handle("", e1);
} catch (ExecutionException e1) {
ExceptionHandler.handle("", e1);
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListTotalPanel.java
93,7 → 93,7
c.gridx = GridBagConstraints.RELATIVE;
c.weightx = 0;
if (title != null && title.trim().length() > 0) {
TitledSeparator sep = new TitledSeparator(title);
JLabel sep = new JLabel(title);
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(sep, c);
103,7 → 103,11
// Filtre
for (Tuple2<? extends SQLTableModelColumn, Type> field2 : listField) {
c.weightx = 0;
JLabelBold comp = new JLabelBold(field2.get0().getName());
final SQLTableModelColumn col = field2.get0();
if (col == null) {
throw new IllegalStateException("null SQLTableModelColumn in " + listField);
}
final JLabelBold comp = new JLabelBold(col.getName());
comp.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(comp, c);
JLabelBold textField = new JLabelBold("0");
111,6 → 115,7
this.map.put(field2.get0(), textField);
c.weightx = 1;
this.add(textField, c);
c.weightx = 0;
if (field2.get1() == Type.SOMME || field2.get1() == Type.MOYENNE_DEVISE) {
this.add(new JLabelBold("€"), c);
} else if (field2.get1() == Type.MOYENNE_POURCENT || field2.get1() == Type.MOYENNE_MARGE) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListFilterDatePanel.java
13,8 → 13,10
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.list.IListe;
29,6 → 31,7
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
40,11 → 43,12
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.event.EventListenerList;
 
public class IListFilterDatePanel extends JPanel {
 
private JDate dateDu, dateAu;
 
private static final String CUSTOM_COMBO_ITEM = "Personnalisée";
private Map<IListe, SQLField> mapList;
// Cache des transformers initiaux
private Map<IListe, ITransformer<SQLSelect, SQLSelect>> mapListTransformer;
54,16 → 58,18
 
private JComboBox combo;
 
private final PropertyChangeListener listener = new PropertyChangeListener() {
private EventListenerList listeners = new EventListenerList();
 
private final ActionListener listener = new ActionListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
// TODO Auto-generated method stub
public void actionPerformed(ActionEvent e) {
combo.setSelectedItem(CUSTOM_COMBO_ITEM);
fireDateChanged();
}
};
 
// FIXME Cacher pour ne pas recharger la liste si il n'y a aucune modif
 
public IListFilterDatePanel(IListe l, SQLField fieldDate) {
this(l, fieldDate, null);
if (l.getRequest() == Configuration.getInstance().getDirectory().getElement(l.getSource().getPrimaryTable()).getListRequest()) {
84,12 → 90,18
 
private static void initDefaultMap() {
mapDefault = new LinkedHashMap<String, Tuple2<Date, Date>>();
 
// ALL
Date emptyDate = null;
mapDefault.put("Sans filtrage", Tuple2.create(emptyDate, emptyDate));
 
Calendar c = Calendar.getInstance();
 
// Année courante
clearTimeSchedule(c);
c.set(Calendar.DATE, 1);
c.set(Calendar.MONTH, 0);
Date d1 = c.getTime();
setEndTimeSchedule(c);
c.set(Calendar.DATE, 31);
c.set(Calendar.MONTH, 11);
Date d2 = c.getTime();
96,10 → 108,13
mapDefault.put("Année courante", Tuple2.create(d1, d2));
 
// Année précedente
clearTimeSchedule(c);
c.set(Calendar.DATE, 1);
c.set(Calendar.MONTH, 0);
c.add(Calendar.YEAR, -1);
Date d3 = c.getTime();
 
setEndTimeSchedule(c);
c.set(Calendar.DATE, 31);
c.set(Calendar.MONTH, 11);
Date d4 = c.getTime();
107,39 → 122,62
 
// Mois courant
c = Calendar.getInstance();
clearTimeSchedule(c);
c.set(Calendar.DATE, 1);
Date d5 = c.getTime();
c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE));
setEndTimeSchedule(c);
Date d6 = c.getTime();
mapDefault.put("Mois courant", Tuple2.create(d5, d6));
 
// Mois précédent
c = Calendar.getInstance();
clearTimeSchedule(c);
c.set(Calendar.DATE, 1);
c.add(Calendar.MONTH, -1);
Date d7 = c.getTime();
c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE));
setEndTimeSchedule(c);
Date d8 = c.getTime();
mapDefault.put("Mois précédent", Tuple2.create(d7, d8));
 
// semaine courante
c = Calendar.getInstance();
clearTimeSchedule(c);
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
Date d9 = c.getTime();
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
setEndTimeSchedule(c);
Date d10 = c.getTime();
mapDefault.put("Semaine courante", Tuple2.create(d9, d10));
 
// semaine précédente
c = Calendar.getInstance();
clearTimeSchedule(c);
c.add(Calendar.DATE, -7);
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
Date d11 = c.getTime();
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
setEndTimeSchedule(c);
Date d12 = c.getTime();
mapDefault.put("Semaine précédente", Tuple2.create(d11, d12));
 
// Exercice courant
SQLRow rowEx = ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeignRow("ID_EXERCICE_COMMON");
Calendar c1 = rowEx.getDate("DATE_DEB");
clearTimeSchedule(c1);
Calendar c2 = rowEx.getDate("DATE_FIN");
setEndTimeSchedule(c2);
 
final Tuple2<Date, Date> exerciceTuple = Tuple2.create(c1.getTime(), c2.getTime());
if (findItem(exerciceTuple, mapDefault).equals(CUSTOM_COMBO_ITEM)) {
mapDefault.put("Exercice courant", exerciceTuple);
}
 
// Custom
mapDefault.put(CUSTOM_COMBO_ITEM, null);
}
 
public static void addDefaultValue(String label, Tuple2<Date, Date> period) {
if (mapDefault == null)
initDefaultMap();
169,6 → 207,7
 
this.mapListTransformer = new HashMap<IListe, ITransformer<SQLSelect, SQLSelect>>();
for (IListe l : mapList.keySet()) {
 
this.mapListTransformer.put(l, l.getRequest().getSelectTransf());
}
 
183,7 → 222,7
// Période pédéfini
if (map != null && map.keySet().size() > 0) {
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement("Tous");
 
for (String s : this.map.keySet()) {
model.addElement(s);
}
206,8 → 245,11
this.add(this.dateDu, c);
this.add(new JLabel("Au"), c);
this.add(this.dateAu, c);
this.dateAu.addValueListener(this.listener);
this.dateDu.addValueListener(this.listener);
this.dateAu.addActionListener(this.listener);
this.dateDu.addActionListener(this.listener);
 
IListFilterDateStateManager stateManager = new IListFilterDateStateManager(this, getConfigFile(mapList), true);
stateManager.loadState();
}
 
public void setDateDu(Date d) {
218,6 → 260,14
this.dateAu.setValue(d);
}
 
public Date getFromValue() {
return this.dateDu.getValue();
}
 
public Date getToValue() {
return this.dateAu.getValue();
}
 
private static Tuple2<String, Tuple2<Date, Date>> DEFAULT_FILTER = null;
 
public static void setDefaultFilter(Tuple2<String, Tuple2<Date, Date>> t) {
236,46 → 286,33
}
}
 
/**
*
* @param t do nothing if t is null
*/
public void setPeriode(Tuple2<Date, Date> t) {
if (t == null) {
setPeriode(null, null);
} else {
 
if (t != null) {
setPeriode(t.get0(), t.get1());
}
}
 
public void setPeriode(Date du, Date au) {
this.dateAu.rmValueListener(this.listener);
this.dateDu.rmValueListener(this.listener);
 
setDateAu(au);
setDateDu(du);
 
fireDateChanged();
 
this.dateAu.addValueListener(this.listener);
this.dateDu.addValueListener(this.listener);
}
 
public void fireDateChanged() {
 
System.err.println("FIRE");
if (this.dateAu.getValue() == null && this.dateDu.getValue() == null) {
System.err.println("Null ");
for (IListe list : this.mapList.keySet()) {
 
list.getRequest().setSelectTransf(this.mapListTransformer.get(list));
}
return;
}
 
if (this.dateAu.getValue() == null) {
System.err.println("Du " + this.dateDu.getValue());
} else if (this.dateAu.getValue() == null) {
final Calendar c = Calendar.getInstance();
c.setTime(this.dateDu.getValue());
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.MILLISECOND, 1);
clearTimeSchedule(c);
 
for (final IListe list : this.mapList.keySet()) {
final SQLField filterField = this.mapList.get(list);
282,25 → 319,16
list.getRequest().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
@Override
public SQLSelect transformChecked(SQLSelect input) {
ITransformer<SQLSelect, SQLSelect> t = mapListTransformer.get(list);
if (t != null) {
input = t.transformChecked(input);
Where w = new Where(input.getAlias(filterField), ">=", c.getTime());
return setWhere(input, w, mapListTransformer.get(list));
}
input.andWhere(new Where(input.getAlias(filterField), ">=", c.getTime()));
return input;
}
});
}
return;
}
 
if (this.dateDu.getValue() == null) {
System.err.println("Au " + this.dateAu.getValue());
} else if (this.dateDu.getValue() == null) {
final Calendar c = Calendar.getInstance();
c.setTime(this.dateAu.getValue());
c.set(Calendar.HOUR_OF_DAY, 23);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.MILLISECOND, 59);
setEndTimeSchedule(c);
for (final IListe list : this.mapList.keySet()) {
final SQLField filterField = this.mapList.get(list);
 
307,30 → 335,21
list.getRequest().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
@Override
public SQLSelect transformChecked(SQLSelect input) {
ITransformer<SQLSelect, SQLSelect> t = mapListTransformer.get(list);
if (t != null) {
input = t.transformChecked(input);
Where w = new Where(input.getAlias(filterField), "<=", c.getTime());
return setWhere(input, w, mapListTransformer.get(list));
}
input.andWhere(new Where(input.getAlias(filterField), "<=", c.getTime()));
return input;
}
});
}
return;
}
System.err.println("Between ");
 
} else {
final Calendar c = Calendar.getInstance();
c.setTime(this.dateAu.getValue());
c.set(Calendar.HOUR_OF_DAY, 23);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.MILLISECOND, 59);
setEndTimeSchedule(c);
 
final Calendar c2 = Calendar.getInstance();
c2.setTime(this.dateDu.getValue());
c2.set(Calendar.HOUR_OF_DAY, 0);
c2.set(Calendar.MINUTE, 0);
c2.set(Calendar.MILLISECOND, 1);
clearTimeSchedule(c2);
 
for (final IListe list : this.mapList.keySet()) {
final SQLField filterField = this.mapList.get(list);
 
337,15 → 356,108
list.getRequest().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
@Override
public SQLSelect transformChecked(SQLSelect input) {
ITransformer<SQLSelect, SQLSelect> t = mapListTransformer.get(list);
final Where w = new Where(input.getAlias(filterField), c2.getTime(), c.getTime());
return setWhere(input, w, mapListTransformer.get(list));
}
});
}
}
 
final Tuple2<Date, Date> selectedTuple = Tuple2.create(this.dateDu.getValue(), this.dateAu.getValue());
this.combo.setSelectedItem(findItem(selectedTuple, this.map));
for (PropertyChangeListener l : this.listeners.getListeners(PropertyChangeListener.class)) {
l.propertyChange(new PropertyChangeEvent(this, "valueChanged", null, selectedTuple));
}
}
 
public void addValueListener(PropertyChangeListener l) {
this.listeners.add(PropertyChangeListener.class, l);
}
 
public void rmValueListener(PropertyChangeListener l) {
this.listeners.remove(PropertyChangeListener.class, l);
}
 
private SQLSelect setWhere(SQLSelect input, Where w, ITransformer<SQLSelect, SQLSelect> t) {
if (t != null) {
input = t.transformChecked(input);
}
input.andWhere(new Where(input.getAlias(filterField), c2.getTime(), c.getTime()));
input.andWhere(w);
return input;
}
});
 
public static String findItem(Tuple2<Date, Date> t, Map<String, Tuple2<Date, Date>> mapItem) {
 
Date d1 = t.get0();
Date d2 = t.get1();
Calendar c1 = getCalendarFromDate(d1);
Calendar c2 = getCalendarFromDate(d2);
 
for (String label : mapItem.keySet()) {
Tuple2<Date, Date> t2 = mapItem.get(label);
if (t2 != null) {
final Date get0 = t2.get0();
final Date get1 = t2.get1();
Calendar cGet0 = getCalendarFromDate(get0);
Calendar cGet1 = getCalendarFromDate(get1);
 
if (isDateEquals(c1, cGet0) && isDateEquals(c2, cGet1)) {
return label;
}
}
}
return CUSTOM_COMBO_ITEM;
}
 
private static Calendar getCalendarFromDate(final Date d) {
Calendar cal = null;
if (d != null) {
cal = Calendar.getInstance();
cal.setTime(d);
}
return cal;
}
 
public static boolean isDateEquals(Calendar d1, Calendar d2) {
boolean b = false;
if (d1 == null && d2 == null) {
b = true;
} else if (d1 != null && d2 != null) {
b = d1.get(Calendar.DAY_OF_MONTH) == d2.get(Calendar.DAY_OF_MONTH) && d2.get(Calendar.YEAR) == d1.get(Calendar.YEAR) && d1.get(Calendar.MONTH) == d2.get(Calendar.MONTH);
} else {
b = false;
}
return b;
}
 
private static void clearTimeSchedule(final Calendar c) {
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
}
 
private static void setEndTimeSchedule(final Calendar c) {
c.set(Calendar.HOUR_OF_DAY, 23);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.SECOND, 59);
c.set(Calendar.MILLISECOND, 59);
}
 
static private final File getConfigFile(Map<IListe, SQLField> mapList) {
final Configuration conf = Configuration.getInstance();
if (conf == null)
return null;
 
String name = null;
for (IListe l : mapList.keySet()) {
String confName = l.getConfigFile().getName();
if (name == null) {
name = confName;
} else if (name.compareTo(confName) > 0) {
name = confName;
}
}
return new File(conf.getConfDir(), "DateRanges" + File.separator + name);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseNumericCellEditor.java
17,7 → 17,6
 
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
24,15 → 23,12
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.EventObject;
 
import javax.swing.AbstractAction;
import javax.swing.AbstractCellEditor;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;
43,12 → 39,17
* long representant des cents
*
*/
public class DeviseNumericCellEditor extends AbstractCellEditor implements TableCellEditor, MouseListener {
private JTextField textField = new JTextField();
private float taxe = 19.6F;
private int precision;
public class DeviseNumericCellEditor extends AbstractCellEditor implements TableCellEditor {
protected JTextField textField = new JTextField();
 
protected int precision;
protected final DecimalFormat decimalFormat = new DecimalFormat("##,##0.00#######");
 
public DeviseNumericCellEditor(SQLField field) {
final DecimalFormatSymbols symbol = DecimalFormatSymbols.getInstance();
symbol.setDecimalSeparator('.');
decimalFormat.setDecimalFormatSymbols(symbol);
 
// Mimic JTable.GenericEditor behavior
this.textField.setBorder(new LineBorder(Color.black));
this.textField.setHorizontalAlignment(JTextField.RIGHT);
66,7 → 67,6
int pointPosition = textField.getText().indexOf('.');
if (Character.isDigit(keychar)) {
if (pointPosition > -1) {
// System.err.println("Text Selected :: " + textField.getSelectedText());
if (textField.getSelectedText() == null) {
if (textField.getCaretPosition() <= pointPosition) {
return;
95,18 → 95,30
// on sélectionne tout lors de la selection
textField.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
 
// Force lineborder to black (may be red if a wrong value was previously hit)
textField.setBorder(new LineBorder(Color.black));
textField.selectAll();
}
});
}
 
@Override
public boolean stopCellEditing() {
// Check if the value is correct (may be wrong if we use copy/paste)
try {
getCellEditorValue();
} catch (Exception e) {
this.textField.setBorder(new LineBorder(Color.RED));
return false;
}
return super.stopCellEditing();
}
 
public void addKeyListener(KeyListener l) {
this.textField.addKeyListener(l);
}
 
public boolean isCellEditable(EventObject e) {
 
if (e instanceof MouseEvent) {
return ((MouseEvent) e).getClickCount() >= 2;
}
114,7 → 126,6
}
 
public Object getCellEditorValue() {
 
if (this.textField.getText().trim().length() > 0) {
return new BigDecimal(this.textField.getText());
} else {
122,22 → 133,7
}
}
 
public void setConvertToTTCEnable(boolean b) {
if (b) {
this.textField.addMouseListener(this);
} else {
this.textField.removeMouseListener(this);
}
}
 
public void setTaxe(float d) {
this.taxe = d;
}
 
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
 
// System.err.println("Devise cell editor get Component " + value);
 
this.textField.setText((value == null ? "0" : ((BigDecimal) value).toString()));
this.textField.selectAll();
this.textField.grabFocus();
144,47 → 140,4
return this.textField;
}
 
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
 
}
 
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
 
}
 
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
 
}
 
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
if (textField.getText().trim().length() > 0 && e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
menuDroit.add(new AbstractAction("Convertir en HT (TVA " + taxe + ")") {
 
public void actionPerformed(ActionEvent e) {
 
String s = textField.getText().trim();
if (s.length() > 0) {
BigDecimal taux = new BigDecimal(taxe).movePointLeft(2).add(BigDecimal.ONE);
BigDecimal prixTTC = new BigDecimal(s);
BigDecimal divide = prixTTC.divide(taux, MathContext.DECIMAL128);
divide = divide.setScale(precision, RoundingMode.HALF_UP);
textField.setText(divide.toString());
}
}
});
menuDroit.pack();
menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
menuDroit.setVisible(true);
}
}
 
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/VilleRowItemView.java
New file
0,0 → 1,63
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.map.model.Ville;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.sqlobject.itemview.VWRowItemView;
import org.openconcerto.ui.valuewrapper.ValueWrapper;
 
public class VilleRowItemView extends VWRowItemView<Ville> {
 
public VilleRowItemView(ValueWrapper<Ville> wrapper) {
super(wrapper);
}
 
public SQLField getField() {
return this.getFields().get(0);
}
 
protected final SQLTable getTable() {
return this.getField().getTable();
}
 
public void setEditable(boolean b) {
if (this.getComp() != null)
this.getComp().setEnabled(b);
}
 
@SuppressWarnings("unchecked")
public void show(SQLRowAccessor r) {
if (r.getFields().contains(this.getField().getName())) {
String cp = r.getString(getFields().get(0).getName());
String name = r.getString(getFields().get(1).getName());
final Ville villeFromVilleEtCode = Ville.getVilleFromVilleEtCode(name + " (" + cp + ")");
// get a matching Ville
if (villeFromVilleEtCode != null) {
this.getWrapper().setValue(villeFromVilleEtCode);
} else {
this.getWrapper().setValue(new Ville(name, 0, 0, 0, cp));
}
}
}
 
public void update(SQLRowValues vals) {
vals.put(getFields().get(1).getName(), this.isEmpty() ? SQLRowValues.SQL_DEFAULT : this.getWrapper().getValue().getName());
vals.put(getFields().get(0).getName(), this.isEmpty() ? SQLRowValues.SQL_DEFAULT : this.getWrapper().getValue().getCodepostal());
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseNumericRemiseCellEditor.java
New file
0,0 → 1,105
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.sql.model.SQLField;
 
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
 
import javax.swing.AbstractAction;
import javax.swing.JPopupMenu;
 
public class DeviseNumericRemiseCellEditor extends DeviseNumericCellEditor implements MouseListener {
private BigDecimal ht = BigDecimal.ZERO;
private BigDecimal ttc = BigDecimal.ZERO;
 
public DeviseNumericRemiseCellEditor(SQLField field) {
super(field);
this.textField.addMouseListener(this);
}
 
public void setHT(BigDecimal d) {
this.ht = d;
}
 
public void setTTC(BigDecimal d) {
this.ttc = d;
}
 
public void mousePressed(MouseEvent e) {
if (textField.getText().trim().length() > 0 && e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
final AbstractAction htToPercent = new AbstractAction("Convertir le montant HT en %") {
 
public void actionPerformed(ActionEvent e) {
 
String s = textField.getText().trim();
if (s.length() > 0) {
 
BigDecimal prixHTRemise = new BigDecimal(s);
BigDecimal divide = prixHTRemise.divide(ht, MathContext.DECIMAL128).movePointRight(2);
divide = divide.setScale(precision, RoundingMode.HALF_UP);
textField.setText(divide.toString());
}
}
};
htToPercent.setEnabled(ht.signum() != 0);
menuDroit.add(htToPercent);
 
final AbstractAction ttcToPercent = new AbstractAction("Convertir le montant TTC en %") {
 
public void actionPerformed(ActionEvent e) {
 
String s = textField.getText().trim();
if (s.length() > 0) {
 
BigDecimal prixTTCRemise = new BigDecimal(s);
BigDecimal divide = prixTTCRemise.divide(ttc, MathContext.DECIMAL128).movePointRight(2);
divide = divide.setScale(precision, RoundingMode.HALF_UP);
textField.setText(divide.toString());
}
}
};
ttcToPercent.setEnabled(ttc.signum() != 0);
menuDroit.add(ttcToPercent);
 
menuDroit.pack();
menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
menuDroit.setVisible(true);
}
}
 
public void mouseReleased(MouseEvent e) {
}
 
@Override
public void mouseClicked(MouseEvent e) {
 
}
 
@Override
public void mouseEntered(MouseEvent e) {
 
}
 
@Override
public void mouseExited(MouseEvent e) {
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListFilterDateStateManager.java
New file
0,0 → 1,113
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.ui.state.ListenerXMLStateManager;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Tuple2;
 
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
 
import org.w3c.dom.Document;
import org.w3c.dom.Node;
 
public class IListFilterDateStateManager extends ListenerXMLStateManager<IListFilterDatePanel, PropertyChangeListener> {
 
public IListFilterDateStateManager(IListFilterDatePanel p, File f) {
this(p, f, true);
}
 
public IListFilterDateStateManager(IListFilterDatePanel p, File f, boolean autosave) {
super(p, f, autosave);
}
 
@Override
protected void addListener(PropertyChangeListener l) {
this.getSrc().addValueListener(l);
}
 
@Override
protected PropertyChangeListener createListener() {
return new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
save();
}
};
}
 
@Override
protected void rmListener(PropertyChangeListener l) {
this.getSrc().rmValueListener(l);
}
 
protected final void save() {
try {
saveState();
} catch (IOException exn) {
ExceptionHandler.handle(this.getSrc(), "Impossible de sauvegarder l'état du filtre de période.", exn);
}
}
 
DateFormat format = DateFormat.getDateInstance(DateFormat.FULL);
 
@Override
protected void writeState(BufferedWriter out) throws IOException {
out.write("<filter>\n");
// Taille
out.write("<value");
final Date fromValue = this.getSrc().getFromValue();
out.write(" from=\"" + (fromValue == null ? "" : format.format(fromValue)) + "\"");
final Date toValue = this.getSrc().getToValue();
out.write(" to=\"" + (toValue == null ? "" : format.format(toValue)) + "\"");
out.write("/>\n");
 
out.write("</filter>\n");
}
 
@Override
protected boolean readState(Document doc) {
Tuple2<Date, Date> period;
try {
period = this.getPeriod(doc);
} catch (ParseException e) {
e.printStackTrace();
return false;
}
 
this.getSrc().setPeriode(period);
return true;
}
 
private Tuple2<Date, Date> getPeriod(Document doc) throws ParseException {
Node filter = doc.getElementsByTagName("value").item(0);
// from
final String sDate1 = (filter.getAttributes().getNamedItem("from").getNodeValue());
Date d1 = (sDate1 == null || sDate1.trim().length() == 0) ? null : format.parse(sDate1);
 
// To
final String sDate2 = (filter.getAttributes().getNamedItem("to").getNodeValue());
Date d2 = (sDate2 == null || sDate2.trim().length() == 0) ? null : format.parse(sDate2);
 
return Tuple2.create(d1, d2);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/ReminderDialog.java
20,8 → 20,6
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JCheckBox;
93,17 → 91,4
}
 
}
 
public static void resetMessageStates() {
assert !SwingUtilities.isEventDispatchThread();
final List<Object> keys = new ArrayList<Object>();
keys.addAll(UserProps.getInstance().getProps().keySet());
for (Object object : keys) {
final String key = object.toString();
if (key.startsWith("hide.")) {
UserProps.getInstance().setProperty(key, null);
}
}
UserProps.getInstance().store();
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractVenteArticleItemTable.java
19,7 → 19,6
import org.openconcerto.erp.core.sales.product.ui.ArticleRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.QteMultipleRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
import org.openconcerto.erp.model.PrixHT;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
import org.openconcerto.sql.Configuration;
76,11 → 75,7
 
private SQLTable tableArticleTarif = Configuration.getInstance().getBase().getTable("ARTICLE_TARIF");
private SQLTable tableArticle = Configuration.getInstance().getBase().getTable("ARTICLE");
private SQLTable tableTarif = Configuration.getInstance().getBase().getTable("TARIF");
 
/**
*
*/
protected void init() {
 
SQLPreferences prefs = SQLPreferences.getMemCached(getSQLElement().getTable().getDBRoot());
192,14 → 187,12
}
 
// Prix d'achat HT de la métrique 1
final SQLTableElement tableElement_PrixMetrique1_AchatHT = new SQLTableElement(e.getTable().getField("PRIX_METRIQUE_HA_1"), BigDecimal.class);
// @Override
// public boolean isCellEditable(SQLRowValues vals) {
// // TODO Raccord de méthode auto-généré
// return !(selectArticle && !createAuto);
// }
// };
// tableElement_PrixMetrique1_AchatHT.setRenderer(new DeviseNiceTableCellRenderer());
final SQLTableElement tableElement_PrixMetrique1_AchatHT = new SQLTableElement(e.getTable().getField("PRIX_METRIQUE_HA_1"), BigDecimal.class) {
protected Object getDefaultNullValue() {
return BigDecimal.ZERO;
}
};
tableElement_PrixMetrique1_AchatHT.setRenderer(new DeviseTableCellRenderer());
list.add(tableElement_PrixMetrique1_AchatHT);
 
SQLTableElement eltDevise = null;
211,23 → 204,19
 
// Prix vente devise
eltUnitDevise = new SQLTableElement(e.getTable().getField("PV_U_DEVISE"), BigDecimal.class);
eltUnitDevise.setRenderer(new DeviseTableCellRenderer());
list.add(eltUnitDevise);
}
// Prix de vente HT de la métrique 1
// final DeviseCellEditor editorPVHT = new DeviseCellEditor();
// editorPVHT.setConvertToTTCEnable(true);
 
SQLField field = e.getTable().getField("PRIX_METRIQUE_VT_1");
final DeviseNumericCellEditor editorPVHT = new DeviseNumericCellEditor(field);
editorPVHT.setConvertToTTCEnable(true);
final DeviseNumericHTConvertorCellEditor editorPVHT = new DeviseNumericHTConvertorCellEditor(field);
 
final SQLTableElement tableElement_PrixMetrique1_VenteHT = new SQLTableElement(field, BigDecimal.class, editorPVHT);
tableElement_PrixMetrique1_VenteHT.setRenderer(new DeviseTableCellRenderer());
list.add(tableElement_PrixMetrique1_VenteHT);
 
// // Prix d'achat HT de la métrique 1
// final SQLTableElement tableElement_PrixMetrique1_AchatHT = new
// SQLTableElement(e.getTable().getField("PRIX_METRIQUE_HA_1"), Long.class, new
// DeviseCellEditor());
// list.add(tableElement_PrixMetrique1_AchatHT);
 
SQLTableElement qteU = new SQLTableElement(e.getTable().getField("QTE_UNITAIRE"), BigDecimal.class) {
@Override
277,11 → 266,24
list.add(tableElement_ModeVente);
 
// // Prix d'achat unitaire HT
this.ha = new SQLTableElement(e.getTable().getField("PA_HT"), BigDecimal.class);
 
final SQLField prixAchatHTField = e.getTable().getField("PA_HT");
final DeviseNumericCellEditor editorPAchatHT = new DeviseNumericCellEditor(prixAchatHTField);
this.ha = new SQLTableElement(e.getTable().getField("PA_HT"), BigDecimal.class, editorPAchatHT) {
protected Object getDefaultNullValue() {
return BigDecimal.ZERO;
}
};
this.ha = new SQLTableElement(prixAchatHTField, BigDecimal.class, editorPAchatHT);
this.ha.setRenderer(new DeviseTableCellRenderer());
 
list.add(this.ha);
 
// Prix de vente unitaire HT
final SQLTableElement tableElement_PrixVente_HT = new SQLTableElement(e.getTable().getField("PV_HT"), BigDecimal.class);
final SQLField prixVenteHTField = e.getTable().getField("PV_HT");
final DeviseNumericCellEditor editorPVenteHT = new DeviseNumericCellEditor(prixAchatHTField);
final SQLTableElement tableElement_PrixVente_HT = new SQLTableElement(prixVenteHTField, BigDecimal.class, editorPVenteHT);
tableElement_PrixVente_HT.setRenderer(new DeviseTableCellRenderer());
list.add(tableElement_PrixVente_HT);
 
// TVA
304,6 → 306,7
}
 
this.totalHT = new SQLTableElement(e.getTable().getField("T_PV_HT"), BigDecimal.class);
this.totalHT.setRenderer(new DeviseTableCellRenderer());
this.totalHT.setEditable(false);
if (e.getTable().getFieldsName().contains("POURCENT_ACOMPTE")) {
SQLTableElement tableElementAcompte = new SQLTableElement(e.getTable().getField("POURCENT_ACOMPTE"));
310,7 → 313,9
list.add(tableElementAcompte);
tableElementAcompte.addModificationListener(this.totalHT);
}
SQLTableElement tableElementRemise = new SQLTableElement(e.getTable().getField("POURCENT_REMISE"));
 
final SQLField field2 = e.getTable().getField("POURCENT_REMISE");
SQLTableElement tableElementRemise = new SQLTableElement(field2);
list.add(tableElementRemise);
 
SQLTableElement tableElementRG = null;
321,6 → 326,7
 
// Total HT
this.totalHA = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
this.totalHA.setRenderer(new DeviseTableCellRenderer());
this.totalHA.setEditable(false);
list.add(this.totalHA);
 
327,6 → 333,7
if (DefaultNXProps.getInstance().getBooleanValue(ARTICLE_SHOW_DEVISE, false)) {
// Total HT
this.tableElementTotalDevise = new SQLTableElement(e.getTable().getField("PV_T_DEVISE"), BigDecimal.class);
this.tableElementTotalDevise.setRenderer(new DeviseTableCellRenderer());
list.add(tableElementTotalDevise);
}
 
334,6 → 341,7
if (e.getTable().getFieldsName().contains("MARGE_HT")) {
 
final SQLTableElement marge = new SQLTableElement(e.getTable().getField("MARGE_HT"), BigDecimal.class);
marge.setRenderer(new DeviseTableCellRenderer());
marge.setEditable(false);
list.add(marge);
this.totalHT.addModificationListener(marge);
353,7 → 361,6
vt = vt.multiply(lA, MathContext.DECIMAL128).movePointLeft(2);
}
 
// Long r = Long.valueOf(vt - ha);
return vt.subtract(ha).setScale(marge.getDecimalDigits(), RoundingMode.HALF_UP);
}
 
384,7 → 391,6
vt = vt.multiply(lA, MathContext.DECIMAL128).movePointLeft(2);
}
 
// Long r = Long.valueOf(vt - ha);
return vt.subtract(ha).setScale(marge.getDecimalDigits(), RoundingMode.HALF_UP);
}
 
393,7 → 399,7
}
 
// Total HT
// this.totalHT.setRenderer(new DeviseNiceTableCellRenderer());
 
this.totalHT.setEditable(false);
list.add(this.totalHT);
// Total TTC
400,6 → 406,7
// FIXME add a modifier -> T_TTC modify P_VT_METRIQUE_1 + fix CellDynamicModifier not fire
// if value not changed
this.tableElementTotalTTC = new SQLTableElement(e.getTable().getField("T_PV_TTC"), BigDecimal.class);
this.tableElementTotalTTC.setRenderer(new DeviseTableCellRenderer());
this.tableElementTotalTTC.setEditable(false);
list.add(this.tableElementTotalTTC);
 
571,7 → 578,7
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal f = (BigDecimal) row.getObject("PA_HT");
BigDecimal r = b.multiply(new BigDecimal(f.longValue() * qte), MathContext.DECIMAL128).setScale(6, BigDecimal.ROUND_HALF_UP);
BigDecimal r = b.multiply(new BigDecimal(qte), MathContext.DECIMAL128).multiply(f, MathContext.DECIMAL128).setScale(6, BigDecimal.ROUND_HALF_UP);
return r.setScale(totalHA.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
}
});
599,8 → 606,7
});
}
// Calcul automatique du total TTC
// tableElement_Quantite.addModificationListener(tableElement_TotalTTC);
// tableElement_PrixVente_HT.addModificationListener(tableElement_TotalTTC);
 
this.totalHT.addModificationListener(this.tableElementTotalTTC);
this.tableElementTVA.addModificationListener(this.tableElementTotalTTC);
this.tableElementTotalTTC.setModifier(new CellDynamicModifier() {
607,7 → 613,7
@Override
public Object computeValueFrom(SQLRowValues row) {
 
BigDecimal f = (BigDecimal) row.getObject("T_PV_HT");
BigDecimal ht = (BigDecimal) row.getObject("T_PV_HT");
int idTaux = Integer.parseInt(row.getObject("ID_TAXE").toString());
 
Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
624,12 → 630,12
}
}
 
// PrixHT pHT = new PrixHT(f.longValue());
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
// editorPVHT.setTaxe(resultTaux);
// Long r = Long.valueOf(pHT.calculLongTTC(taux / 100f));
BigDecimal r = f.multiply(BigDecimal.valueOf(taux).movePointLeft(2).add(BigDecimal.ONE), MathContext.DECIMAL128);
return r.setScale(tableElementTotalTTC.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
editorPVHT.setTaxe(taux);
 
BigDecimal r = ht.multiply(BigDecimal.valueOf(taux).movePointLeft(2).add(BigDecimal.ONE), MathContext.DECIMAL128);
final BigDecimal resultTTC = r.setScale(tableElementTotalTTC.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
return resultTTC;
}
 
});
778,10 → 784,9
return null;
}
 
private Object tarifCompletion(SQLRowAccessor row, String field) {
protected Object tarifCompletion(SQLRowAccessor row, String field) {
 
if (getTarif() != null && getTarif().getID() > tableTarif.getUndefinedID()) {
// SQLRow rowTarifSelect = tableTarif.getRow(getTarif());
if (getTarif() != null && !getTarif().isUndefined()) {
Collection<? extends SQLRowAccessor> rows = row.getReferentRows(tableArticleTarif);
 
SQLRowAccessor rowTarif = null;
833,16 → 838,14
 
@Override
public void setTarif(SQLRowAccessor rowValuesTarif, boolean ask) {
// TODO Raccord de méthode auto-généré
if (rowValuesTarif == null || getTarif() == null || rowValuesTarif.getID() != getTarif().getID()) {
super.setTarif(rowValuesTarif, ask);
if (ask && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client?") == JOptionPane.YES_OPTION) {
if (ask && getRowValuesTable().getRowCount() > 0 && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) {
int nbRows = this.table.getRowCount();
for (int i = 0; i < nbRows; i++) {
SQLRowValues rowVals = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(i);
 
// on récupére l'article qui lui correspond
 
SQLRowValues rowValsArticle = new SQLRowValues(tableArticle);
for (SQLField field : tableArticle.getFields()) {
if (rowVals.getTable().getFieldsName().contains(field.getName())) {
849,11 → 852,10
rowValsArticle.put(field.getName(), rowVals.getObject(field.getName()));
}
}
// rowArticle.loadAllSafe(rowEltFact);
 
int idArticle = ReferenceArticleSQLElement.getIdForCNM(rowValsArticle, true);
SQLRow rowArticle = tableArticle.getRow(idArticle);
// SQLRowAccessor rowArticle = rowVals.getForeign("ID_ARTICLE");
 
Collection<? extends SQLRowAccessor> rows = rowArticle.getReferentRows(tableArticleTarif);
boolean tarifFind = false;
if (getTarif() != null) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseNumericHTConvertorCellEditor.java
New file
0,0 → 1,81
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.sql.model.SQLField;
 
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
 
import javax.swing.AbstractAction;
import javax.swing.JPopupMenu;
 
public class DeviseNumericHTConvertorCellEditor extends DeviseNumericCellEditor implements MouseListener {
 
private float taxe = 19.6F;
 
public DeviseNumericHTConvertorCellEditor(SQLField field) {
super(field);
this.textField.addMouseListener(this);
}
 
public void setTaxe(float d) {
this.taxe = d;
}
 
public void mousePressed(MouseEvent e) {
if (textField.getText().trim().length() > 0 && e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
menuDroit.add(new AbstractAction("Convertir en HT (TVA " + taxe + ")") {
 
public void actionPerformed(ActionEvent e) {
 
String s = textField.getText().trim();
if (s.length() > 0) {
BigDecimal taux = new BigDecimal(taxe).movePointLeft(2).add(BigDecimal.ONE);
BigDecimal prixTTC = new BigDecimal(s);
BigDecimal divide = prixTTC.divide(taux, MathContext.DECIMAL128);
divide = divide.setScale(precision, RoundingMode.HALF_UP);
textField.setText(divide.toString());
}
}
});
menuDroit.pack();
menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
menuDroit.setVisible(true);
}
}
 
public void mouseReleased(MouseEvent e) {
}
 
@Override
public void mouseClicked(MouseEvent e) {
 
}
 
@Override
public void mouseEntered(MouseEvent e) {
 
}
 
@Override
public void mouseExited(MouseEvent e) {
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/VilleTableCellRenderer.java
New file
0,0 → 1,47
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.map.model.Ville;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.ui.table.TableCellRendererUtils;
 
import java.awt.Component;
 
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
 
public class VilleTableCellRenderer extends DefaultTableCellRenderer {
 
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
 
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
 
TableCellRendererUtils.setColors(this, table, isSelected);
 
this.setHorizontalAlignment(SwingConstants.LEFT);
 
RowValuesTable rowValuesTable = ((RowValuesTable) table);
SQLRowValues rowVals = rowValuesTable.getRowValuesTableModel().getRowValuesAt(row);
String v = rowVals.getString("VILLE");
String code = rowVals.getString("CODE_POSTAL");
Ville ville = Ville.getVilleFromVilleEtCode(v + " (" + code + ")");
 
this.setText(ville == null ? "" : ville.toString());
 
return this;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseTableCellRenderer.java
New file
0,0 → 1,53
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.ui.table.TableCellRendererUtils;
 
import java.awt.Component;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
 
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
 
public class DeviseTableCellRenderer extends DefaultTableCellRenderer {
private final DecimalFormat decimalFormat = new DecimalFormat("##,##0.00#");
private final DecimalFormat decimalFormat2 = new DecimalFormat("##,##0.00#######");
private BigDecimal oneCents = new BigDecimal(0.01f);
 
public DeviseTableCellRenderer() {
final DecimalFormatSymbols symbol = DecimalFormatSymbols.getInstance();
symbol.setDecimalSeparator('.');
decimalFormat.setDecimalFormatSymbols(symbol);
decimalFormat2.setDecimalFormatSymbols(symbol);
}
 
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
TableCellRendererUtils.setColors(this, table, isSelected);
this.setHorizontalAlignment(SwingConstants.RIGHT);
if (table.getColumnClass(column) != BigDecimal.class) {
throw new IllegalStateException("Value is not a BigDecimal :" + table.getColumnClass(column));
}
if (((BigDecimal) value).compareTo(oneCents) < 0)
this.setText(decimalFormat2.format(value));
else
this.setText(decimalFormat.format(value));
return this;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCalculatorParameters.java
13,7 → 13,8
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
34,10 → 35,10
private long remiseHT;
private BigDecimal portHT;
private SQLRowAccessor tvaPort;
private Map<Integer, SQLRowAccessor> mapArticle = new HashMap<Integer, SQLRowAccessor>();
 
public TotalCalculatorParameters(List<? extends SQLRowAccessor> values) {
this.values = values;
this.remiseHT = 0;
this.portHT = BigDecimal.ZERO;
}
 
77,46 → 78,44
return tvaPort;
}
 
private Map<Integer, SQLRowAccessor> mapArticle = new HashMap<Integer, SQLRowAccessor>();
 
final SQLTable articleTable = Configuration.getInstance().getRoot().findTable("ARTICLE");
final SQLTable compteTable = Configuration.getInstance().getRoot().findTable("COMPTE_PCE");
final SQLTable familleArticleTable = Configuration.getInstance().getRoot().findTable("FAMILLE_ARTICLE");
 
public void fetchArticle() {
final List<Integer> l = new ArrayList<Integer>(values.size());
for (SQLRowAccessor r : values) {
l.add(r.getID());
}
SQLRowValues rowVals = new SQLRowValues(articleTable);
SQLRowValues rowValsF = new SQLRowValues(familleArticleTable);
rowValsF.put("NOM", null);
rowValsF.put("ID", null);
SQLRowValues rowValsC1 = new SQLRowValues(compteTable);
final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
final SQLTable articleTable = root.getTable("ARTICLE");
final SQLTable compteTable = root.getTable("COMPTE_PCE");
final SQLTable familleArticleTable = root.getTable("FAMILLE_ARTICLE");
 
final SQLRowValues rowValsC1 = new SQLRowValues(compteTable);
rowValsC1.put("NUMERO", null);
rowValsC1.put("ID", null);
SQLRowValues rowValsC2 = new SQLRowValues(compteTable);
 
final SQLRowValues rowValsC2 = new SQLRowValues(compteTable);
rowValsC2.put("NUMERO", null);
rowValsC2.put("ID", null);
 
final SQLRowValues rowValsF = new SQLRowValues(familleArticleTable);
rowValsF.put("NOM", null);
rowValsF.put("ID", null);
rowValsF.put("ID_COMPTE_PCE", rowValsC2);
 
final SQLRowValues rowVals = new SQLRowValues(articleTable);
rowVals.put("ID", null);
rowValsF.put("ID_COMPTE_PCE", rowValsC2);
rowVals.put("ID_FAMILLE_ARTICLE", rowValsF);
rowVals.put("ID_COMPTE_PCE", rowValsC1);
 
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
final SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
fetch.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
 
input.andWhere(new Where(articleTable.getKey(), l));
return input;
}
});
System.err.println(fetch.getReq().asString());
List<SQLRowValues> rowValsList = fetch.fetch();
 
final List<SQLRowValues> rowValsList = fetch.fetch();
for (SQLRowValues sqlRowValues : rowValsList) {
mapArticle.put(sqlRowValues.getID(), sqlRowValues);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseField.java
14,21 → 14,15
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.request.MutableRowItemView;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.sql.request.SQLRowItemView;
import org.openconcerto.sql.sqlobject.itemview.RowItemViewComponent;
import org.openconcerto.ui.valuewrapper.ValueWrapper;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.checks.EmptyListener;
import org.openconcerto.utils.checks.EmptyObject;
import org.openconcerto.utils.checks.EmptyObjectHelper;
import org.openconcerto.utils.checks.ValidListener;
import org.openconcerto.utils.checks.ValidState;
import org.openconcerto.utils.doc.Documented;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.Component;
import java.awt.Font;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
38,32 → 32,20
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Set;
import java.util.Vector;
 
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
 
import org.apache.commons.collections.Predicate;
 
/**
* Field permettant de stocker les devises au format 2 chiffres apres la virgule sous forme de long
* dans la base, utiliser un champ de type BigInt signed sous mysql bigInt unsigned -->
* java.math.BigInteger bigInt signed --> java.lang.Long
*/
public class DeviseField extends JTextField implements EmptyObject, MutableRowItemView, Documented {
private boolean completing = false;
private final boolean autoCompletion;
public class DeviseField extends JTextField implements ValueWrapper<Long>, Documented, RowItemViewComponent {
 
private SQLField field;
private String sqlName;
 
private List<String> items;
 
private EmptyObjectHelper helper;
private final PropertyChangeSupport supp;
// does this component just gained focus
private boolean gained;
74,11 → 56,11
private boolean authorizedNegative = false;
 
public DeviseField() {
this(15, false, false);
this(false);
}
 
public DeviseField(boolean bold) {
this(15, false, bold);
this(15, bold);
}
 
public DeviseField(int columns) {
85,11 → 67,7
this(columns, false);
}
 
private DeviseField(int columns, boolean autoCompletion) {
this(columns, autoCompletion, false);
}
 
private DeviseField(int columns, boolean autoCompletion, boolean bold) {
private DeviseField(int columns, boolean bold) {
super(columns);
if (bold) {
this.setFont(getFont().deriveFont(Font.BOLD));
96,12 → 74,12
}
this.supp = new PropertyChangeSupport(this);
this.gained = false;
this.autoCompletion = autoCompletion;
this.getDocument().addDocumentListener(new SimpleDocumentListener() {
public void update(DocumentEvent e) {
DeviseField.this.textModified();
}
});
this.init();
}
 
/**
108,25 → 86,15
* Methode appelée quand le texte est modifié
*/
protected void textModified() {
// execute la completion
if (this.autoCompletion)
complete();
this.supp.firePropertyChange("value", null, this.getUncheckedValue());
this.supp.firePropertyChange("value", null, this.getValue());
}
 
@Override
public void init(String sqlName, Set<SQLField> fields) {
this.field = CollectionUtils.getSole(fields);
this.sqlName = sqlName;
this.helper = new EmptyObjectHelper(this, new Predicate() {
public boolean evaluate(Object object) {
return object == null;
 
// final String val = GestionDevise.currencyToString(((Long)
// object).longValue());
public void init(SQLRowItemView v) {
this.field = v.getField();
}
});
 
private void init() {
// TODO use JFormattedTextField => conflit getValue()
// DefaultFormatterFactory NumberFormatter (getAllowsInvalid) NumberFormat
 
220,11 → 188,17
});
}
 
@Override
public final void resetValue() {
this.setValue("");
this.setValue((Long) null);
}
 
public final void setValue(String val) {
@Override
public void setValue(Long val) {
this.setValue(val == null ? "" : GestionDevise.currencyToString(val.longValue()));
}
 
private final void setValue(String val) {
if (!this.getText().equals(val))
this.setText(val);
}
233,141 → 207,31
this.setFont(getFont().deriveFont(Font.BOLD));
}
 
public Object getUncheckedValue() {
@Override
public String toString() {
return this.getClass().getSimpleName() + " authorizedNegative: " + this.isAuthorizedNegative();
}
 
@Override
public Long getValue() {
if (this.getText().trim().length() == 0) {
return null;
} else {
return new Long(GestionDevise.parseLongCurrency(this.getText()));
return Long.valueOf(GestionDevise.parseLongCurrency(this.getText()));
}
// return this.getText();
}
 
public final SQLTable getTable() {
return this.field.getTable();
@Override
public void addValueListener(PropertyChangeListener l) {
this.supp.addPropertyChangeListener(l);
}
 
public String toString() {
return this.getClass().getSimpleName() + " on " + this.field;
@Override
public void rmValueListener(PropertyChangeListener l) {
this.supp.removePropertyChangeListener(l);
}
 
/**
* Recherche si on peut completer la string avec les items de completion
*
* @param string
* @return nulll si pas trouve, sinon le mot complet
*/
private String getCompletion(String string) {
int c = 0;
if (string.length() < 1) {
return null;
}
String result = null;
for (int i = 0; i < this.items.size(); i++) {
String obj = (String) this.items.get(i);
if (obj.startsWith(string)) {
c++;
result = obj;
}
}
if (c == 1)
return result;
else
return null;
}
 
/**
* @param string
*/
private final void addItem(String string) {
if (!this.items.contains(string) && string.length() > 1) {
 
this.items.add(string);
writeToCache(string);
 
}
}
 
// charge les elements de completion si besoin
private final void checkCache() {
if (this.items == null) {
this.items = new Vector(20);
readCache();
}
}
 
synchronized final void complete() {
checkCache();
if (!this.completing) {
this.completing = true;
String originalText = this.getText();
// ne completer que si le texte fait plus de 2 char et n'est pas que des chiffres
if (originalText.length() > 2 && !originalText.matches("^\\d*$")) {
String completion = this.getCompletion(originalText);
if (completion != null && !this.getText().trim().equalsIgnoreCase(completion.trim())) {
this.setText(completion);
this.setSelectionStart(originalText.length());
this.setSelectionEnd(completion.length());
}
}
this.completing = false;
}
}
 
// public void addTextModifiedListener(TextModifiedListener l) {
// if (this.listeners == null) {
// this.listeners = new Vector(1);
// }
// if (!listeners.contains(l)) {
// listeners.addElement(l);
// }
// }
 
protected final void addToCache(String s) {
if (s != null) {
if (s.length() > 0 && !this.items.contains(s))
this.items.add(s);
}
}
 
// A sous classer pour avoir un autre comportement:
 
/**
* Methode a sous classer pour remplir le cache doit appeller addToCache
*/
protected void readCache() {
String req = "SELECT * FROM COMPLETION WHERE CHAMP=\"" + this.field.getFullName() + "\"";
ResultSet rs = this.getTable().getBase().execute(req);
try {
while (rs.next()) {
addToCache(rs.getString("LABEL"));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
 
protected void writeToCache(String string) {
String req = "INSERT INTO COMPLETION (CHAMP,LABEL) VALUES (\"" + this.field.getFullName() + "\",\"" + string + "\")";
this.getField().getTable().getBase().execute(req);
}
 
public Object getValue() {
return this.helper.getValue();
}
 
public boolean isEmpty() {
return this.helper.isEmpty();
}
 
public void addEmptyListener(EmptyListener l) {
this.helper.addListener(l);
}
 
public void addValueListener(PropertyChangeListener l) {
this.supp.addPropertyChangeListener(l);
}
 
public SQLField getField() {
return this.field;
}
379,6 → 243,7
return ValidState.getTrueInstance();
}
 
@Override
public void addValidListener(ValidListener l) {
// FIXME
}
388,26 → 253,8
// FIXME
}
 
public void show(SQLRowAccessor r) {
if (r.getFields().contains(this.getField().getName())) {
Object o = r.getObject(this.getField().getName());
this.setValue(GestionDevise.currencyToString(((Number) o).longValue()));
}
}
 
public void insert(SQLRowValues vals) {
this.update(vals);
}
 
public void update(SQLRowValues vals) {
vals.put(this.getField().getName(), this.isEmpty() ? SQLRowValues.SQL_DEFAULT : this.getUncheckedValue());
}
 
public String getSQLName() {
return this.sqlName;
}
 
public Component getComp() {
@Override
public JComponent getComp() {
return this;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/component/TransfertBaseSQLComponent.java
13,17 → 13,39
package org.openconcerto.erp.core.common.component;
 
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValues.ForeignCopyMode;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.cc.ITransformer;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
 
import javax.swing.ImageIcon;
 
public abstract class TransfertBaseSQLComponent extends BaseSQLComponent {
protected SQLRowAccessor selectedRow;
private List<SQLRowValues> sourceRows;
 
public TransfertBaseSQLComponent(SQLElement element) {
super(element);
38,7 → 60,6
* @param itemsElt elements des items de la source (ex : BL_ELEMENT)
*/
public void loadItem(AbstractArticleItemTable table, SQLElement elt, int id, SQLElement itemsElt) {
 
loadItem(table, elt, id, itemsElt, true);
}
 
46,8 → 67,7
List<SQLRow> myListItem = elt.getTable().getRow(id).getReferentRows(itemsElt.getTable());
 
if (myListItem.size() != 0) {
SQLInjector injector = SQLInjector.createDefaultInjector(itemsElt.getTable(), table.getSQLElement().getTable());
 
SQLInjector injector = SQLInjector.getInjector(itemsElt.getTable(), table.getSQLElement().getTable());
if (clear) {
table.getModel().clearRows();
}
72,4 → 92,102
table.getModel().fireTableDataChanged();
table.repaint();
}
 
public void importFrom(List<SQLRowValues> rows) {
this.sourceRows = rows;
if (rows.size() > 0) {
final SQLInjector injector = SQLInjector.getInjector(rows.get(0).getTable(), this.getTable());
final SQLRowValues rValues = injector.createRowValuesFrom(rows);
select(rValues);
} else {
select(null);
}
}
 
@Override
public int insert(SQLRow order) {
// TODO: Pour l'instant appelé dans Swing, mais cela va changer...
final int insertedId = super.insert(order);
if (insertedId != SQLRow.NONEXISTANT_ID && sourceRows != null && !sourceRows.isEmpty()) {
final SQLInjector injector = SQLInjector.getInjector(sourceRows.get(0).getTable(), this.getTable());
try {
injector.commitTransfert(sourceRows, insertedId);
} catch (Exception e) {
ExceptionHandler.handle("Unable to insert transfert", e);
}
}
return insertedId;
}
 
@Override
public void select(SQLRowAccessor r) {
if (r == null) {
super.select(null);
return;
}
// remove foreign and replace rowvalues by id
final SQLRowValues singleRowValues = new SQLRowValues(r.asRowValues(), ForeignCopyMode.COPY_ID_OR_RM);
super.select(singleRowValues);
final RowValuesTable table = this.getRowValuesTable();
if (table != null) {
table.clear();
table.insertFrom(r);
}
}
 
protected RowValuesTable getRowValuesTable() {
return null;
}
 
public static void openTransfertFrame(List<SQLRowValues> sourceRows, String destTableName) {
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(destTableName);
final EditFrame editFrame = new EditFrame(elt);
editFrame.setIconImage(new ImageIcon(Gestion.class.getResource("frameicon.png")).getImage());
final SQLComponent sqlComponent = editFrame.getSQLComponent();
if (sqlComponent instanceof TransfertBaseSQLComponent) {
final TransfertBaseSQLComponent comp = (TransfertBaseSQLComponent) sqlComponent;
 
if (!sourceRows.isEmpty()) {
// fetch all fields of all table to avoid 1 request by referent row
final List<Number> ids = new ArrayList<Number>(sourceRows.size());
for (SQLRowValues sqlRowValues : sourceRows) {
ids.add(sqlRowValues.getIDNumber());
}
final SQLRowValues row = sourceRows.get(0).deepCopy();
// FIXME don't work in the general case
for (final SQLField rk : row.getTable().getDBSystemRoot().getGraph().getReferentKeys(row.getTable())) {
final Set<SQLRowValues> referentRows = row.getReferentRows(rk);
if (referentRows.size() > 1) {
final Iterator<SQLRowValues> iter = new ArrayList<SQLRowValues>(referentRows).iterator();
// keep the first
iter.next();
while (iter.hasNext()) {
final SQLRowValues ref = iter.next();
ref.remove(rk.getName());
}
}
}
for (SQLRowValues r : row.getGraph().getItems()) {
final Set<String> fields = new HashSet<String>(r.getTable().getFieldsName());
fields.removeAll(r.getFields());
r.putNulls(fields, false);
}
final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(row);
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
input.setWhere(new Where(row.getTable().getKey(), ids));
return input;
}
});
 
final List<SQLRowValues> result = fetcher.fetch();
comp.importFrom(result);
FrameUtil.show(editFrame);
}
} else {
throw new IllegalArgumentException("Table " + destTableName + " SQLComponent is not a TransfertBaseSQLComponent");
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/component/AdresseSQLComponent.java
13,6 → 13,7
package org.openconcerto.erp.core.common.component;
 
import org.openconcerto.erp.core.common.ui.VilleRowItemView;
import org.openconcerto.map.ui.ITextComboVilleViewer;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLElement;
103,7 → 104,7
this.add(pays, c);
 
this.addSQLObject(textRue, "RUE");
this.addView(textVille, "VILLE", REQ);
this.addView(new VilleRowItemView(textVille), "CODE_POSTAL,VILLE", REQ);
this.addView(cedex, "CEDEX");
this.addView(destinataire, "DEST");
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/component/SocieteCommonSQLElement.java
206,7 → 206,7
this.add(fieldRCS, c);
this.addView(fieldRCS, "RCS");
 
// Numero APE
// Capital
c.gridx++;
c.weightx = 0;
JLabel labelCapital = new JLabel(getLabelFor("CAPITAL"));
219,6 → 219,22
this.add(fieldCapital, c);
this.addView(fieldCapital, "CAPITAL");
 
// Assurance
if (getTable().contains("NUMERO_POLICE")) {
c.gridy++;
c.gridx = 0;
c.weightx = 0;
JLabel labelPolice = new JLabel(getLabelFor("NUMERO_POLICE"));
labelPolice.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelPolice, c);
 
c.gridx++;
c.weightx = 1;
JTextField fieldPolice = new JTextField();
this.add(fieldPolice, c);
this.addView(fieldPolice, "NUMERO_POLICE");
}
 
// Adresse
final TitledSeparator sepAdresse = new TitledSeparator(getLabelFor("ID_ADRESSE_COMMON"));
c.gridx = 0;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/component/AdresseCommonSQLComponent.java
13,6 → 13,7
package org.openconcerto.erp.core.common.component;
 
import org.openconcerto.erp.core.common.ui.VilleRowItemView;
import org.openconcerto.map.ui.ITextComboVilleViewer;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLElement;
30,7 → 31,6
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
 
public class AdresseCommonSQLComponent extends BaseSQLComponent {
 
public AdresseCommonSQLComponent(SQLElement elt) {
88,7 → 88,7
this.add(pays, c);
 
this.addSQLObject(textRue, "RUE");
this.addView(textVille, "VILLE", REQ);
this.addView(new VilleRowItemView(textVille), "CODE_POSTAL,VILLE", REQ);
this.addView(cedex, "CEDEX");
this.addView(checkCedex, "HAS_CEDEX");
this.addRequiredSQLObject(pays, "PAYS");