OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 79 → Rev 80

/trunk/OpenConcerto/.classpath
20,16 → 20,17
<classpathentry exported="true" kind="lib" path="lib/ognl-2.6.5.jar"/>
<classpathentry exported="true" kind="lib" path="lib/resolver.jar"/>
<classpathentry exported="true" kind="lib" path="lib/RXTXcomm.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xercesImpl.jar"/>
<classpathentry exported="true" kind="lib" path="lib/poi-3.8-beta3-20110606.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jsch-0.1.44.jar"/>
<classpathentry kind="lib" path="lib/jcip-annotations.jar"/>
<classpathentry kind="lib" path="lib/fb-annotations-2.0.0.jar"/>
<classpathentry kind="lib" path="lib/jOpenDocument-1.3b2.jar"/>
<classpathentry kind="lib" path="lib/h2-1.3.168.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-dbcp-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-pool-1.6.jar"/>
<classpathentry kind="lib" path="lib/icu4j-51_2.jar"/>
<classpathentry kind="lib" path="lib/postgresql-9.2-1003.jdbc4.jar"/>
<classpathentry kind="lib" path="lib/h2-1.3.175.jar"/>
<classpathentry kind="lib" path="lib/icu4j-51_2-data-western_europe.jar"/>
<classpathentry kind="lib" path="lib/icu4j-51_2-module_format.jar"/>
<classpathentry kind="lib" path="lib/jOpenDocument-1.3.jar"/>
<classpathentry kind="lib" path="lib/xercesImpl-2.9.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/OpenConcerto/lib/icu4j-51_2.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/h2-1.3.168.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/jOpenDocument-1.3b2.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/xercesImpl.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/icu4j-51_2-data-western_europe.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/icu4j-51_2-data-western_europe.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/xercesImpl-2.9.1.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/xercesImpl-2.9.1.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/h2-1.3.175.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/h2-1.3.175.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/jOpenDocument-1.3.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/jOpenDocument-1.3.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/icu4j-51_2-module_format.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/icu4j-51_2-module_format.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/jdesktop/swingx/calendar/JXMonthView.java
171,7 → 171,7
private int _monthBoxHeight;
private int _calendarWidth;
private int _calendarHeight;
private int _firstDayOfWeek = Calendar.getInstance().getFirstDayOfWeek();
private int _firstDayOfWeek;
private int _startX;
private int _startY;
private int _dropShadowMask = 0;
224,7 → 224,7
 
// Set up calendar instance.
_cal = Calendar.getInstance(getLocale());
_cal.setFirstDayOfWeek(_firstDayOfWeek);
_firstDayOfWeek = _cal.getFirstDayOfWeek();
_cal.setMinimalDaysInFirstWeek(1);
 
// Keep track of today.
/trunk/OpenConcerto/src/org/jdesktop/swingx/plaf/basic/BasicDatePickerUI.java
148,6 → 148,9
this.popupButton.removeMouseListener(this.mouseListener);
this.popupButton.removeMouseMotionListener(this.mouseMotionListener);
}
if (this.popup != null) {
this.datePicker.getMonthView().removeActionListener(this.popup);
}
 
this.propertyChangeListener = null;
this.mouseListener = null;
/trunk/OpenConcerto/src/org/jopenchart/sample/devguide/GuideFrame.java
3,6 → 3,7
import java.awt.Container;
import java.awt.Dimension;
 
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
50,7 → 51,7
guidePanel2
.addURL("http://chart.apis.google.com/chart?cht=s&chd=s:984sttvuvkQIBLKNCAIi,DEJPgq0uov17zwopQODS,AFLPTXaflptx159gsDrn&chxt=x,y&chxl=0:|0|2|3|4|5|6|7|8|9|10|1:|0|25|50|75|100&chs=200x125");
JScrollPane scrollPane = new JScrollPane(guidePanel2);
scrollPane.setBorder(null);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
tabbedPane.add("Charts type", scrollPane);
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/DefaultCloudTemplateProvider.java
14,6 → 14,7
package org.openconcerto.erp.generationDoc;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Log;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.sync.FileProperty;
69,8 → 70,11
}
}
 
private SyncClient createSyncClient(ComptaPropsConfiguration config) {
final SyncClient client = new SyncClient("https://" + config.getStorageServer());
private SyncClient createSyncClient(ComptaPropsConfiguration configuration) {
if (configuration == null) {
throw new NullPointerException("null configuration");
}
final SyncClient client = new SyncClient("https://" + configuration.getStorageServer());
client.setVerifyHost(false);
return client;
}
77,13 → 81,19
 
@Override
public boolean isSynced(String templateId, String language, String type) {
if (templateId == null) {
throw new NullPointerException("null templateId");
}
return !getLocalFile(templateId + ".ods", language, type).exists();
}
 
@Override
public File getTemplateFromLocalFile(String templateIdWithExtension, String language, String type) {
if (templateIdWithExtension == null) {
throw new NullPointerException("null templateIdWithExtension");
}
File f = getLocalFile(templateIdWithExtension, language, type);
if (!f.exists()) {
if (f == null || !f.exists()) {
f = getCloudFile(templateIdWithExtension, language, type);
}
return f;
91,7 → 101,9
 
private File getLocalFile(String templateIdWithExtension, String language, String type) {
String path = templateIdWithExtension;
 
if (templateIdWithExtension == null) {
throw new NullPointerException("null templateIdWithExtension");
}
if (type != null) {
path = insertBeforeExtenstion(path, type);
}
98,7 → 110,10
if (language != null && language.trim().length() > 0) {
path = language + "/" + path;
}
 
if (path == null) {
Log.get().info("null path for " + templateIdWithExtension + " " + language + " " + type);
return null;
}
File dir = getLocalDir();
File out = new File(dir, path);
 
114,6 → 129,10
if (language != null && language.trim().length() > 0) {
path = language + "/" + path;
}
if (path == null) {
Log.get().info("null path for " + templateIdWithExtension + " " + language + " " + type);
return null;
}
 
File dir = getCloudDir();
File out = new File(dir, path);
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLElement.java
16,9 → 16,12
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.GestionDevise;
 
import java.text.DateFormat;
69,6 → 72,12
 
if (type.equalsIgnoreCase("TotalHTTable")) {
res = getTotalHTTable(row);
} else if (type.equalsIgnoreCase("sql.function")) {
String field = this.elt.getAttributeValue("field");
String table = this.elt.getAttributeValue("table");
String function = this.elt.getAttributeValue("function");
SQLTable referentTable = this.row.getTable().getTable(table);
return getFromSQLFunction(referentTable.getField(field), function);
} else if (type.equalsIgnoreCase("DateEcheance")) {
int idModeReglement = row.getInt("ID_MODE_REGLEMENT");
Date d = (Date) row.getObject("DATE");
118,7 → 127,15
return res;
}
 
private Object getFromSQLFunction(SQLField field, String function) {
SQLSelect sel = new SQLSelect();
sel.addSelect(field, function);
Where w = new Where(field.getTable().getField("ID_" + this.row.getTable().getName()), "=", this.row.getID());
sel.setWhere(w);
return Configuration.getInstance().getBase().getDataSource().executeScalar(sel.asString());
}
 
 
public static DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
 
protected String getStringProposition(SQLRowAccessor rowProp) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/FormatedGlobalQtyTotalProvider.java
New file
0,0 → 1,65
/*
* 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.generationDoc.provider;
 
import org.openconcerto.erp.core.common.ui.NumericFormat;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.math.BigDecimal;
 
public class FormatedGlobalQtyTotalProvider implements SpreadSheetCellValueProvider {
 
private final boolean shortName;
 
private FormatedGlobalQtyTotalProvider(boolean shortName) {
this.shortName = shortName;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
final SQLRowAccessor row = context.getRow();
final BigDecimal pv = row.getBigDecimal("PV_HT");
if (pv.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
 
final int qte = row.getInt("QTE");
 
if (row.getInt("ID_UNITE_VENTE") == UniteVenteArticleSQLElement.A_LA_PIECE) {
return String.valueOf(qte);
}
String result = "";
if (qte > 1) {
result += qte + " x ";
}
final BigDecimal qteUV = row.getBigDecimal("QTE_UNITAIRE");
 
result += NumericFormat.getQtyDecimalFormat().format(qteUV);
final SQLRowAccessor rMode = row.getForeign("ID_UNITE_VENTE");
result += " " + ((this.shortName) ? rMode.getString("CODE") : rMode.getString("NOM"));
// 3 x 5.5 meters
// 1 x 6.3 meters -> 6.3 meters
return result;
 
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.short", new FormatedGlobalQtyTotalProvider(true));
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit", new FormatedGlobalQtyTotalProvider(false));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/MergedGlobalQtyTotalProvider.java
New file
0,0 → 1,61
/*
* 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.generationDoc.provider;
 
import org.openconcerto.erp.core.common.ui.NumericFormat;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.math.BigDecimal;
 
public class MergedGlobalQtyTotalProvider implements SpreadSheetCellValueProvider {
 
private final boolean shortName;
 
public MergedGlobalQtyTotalProvider(boolean shortName) {
this.shortName = shortName;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
final SQLRowAccessor row = context.getRow();
final BigDecimal pv = row.getBigDecimal("PV_HT");
if (pv.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
 
final int qte = row.getInt("QTE");
if (row.getInt("ID_UNITE_VENTE") == UniteVenteArticleSQLElement.A_LA_PIECE) {
return String.valueOf(qte);
}
 
final BigDecimal qteUV = row.getBigDecimal("QTE_UNITAIRE");
final BigDecimal mergedQty = qteUV.multiply(new BigDecimal(qte));
String result = NumericFormat.getQtyDecimalFormat().format(mergedQty);
 
final SQLRowAccessor rMode = row.getForeign("ID_UNITE_VENTE");
result += " " + ((this.shortName) ? rMode.getString("CODE") : rMode.getString("NOM"));
// 3 x 5.5 meters -> 16.5 meters
return result;
 
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.merged", new MergedGlobalQtyTotalProvider(false));
SpreadSheetCellValueProviderManager.put("supplychain.element.qtyunit.merged.short", new MergedGlobalQtyTotalProvider(true));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/TotalCommandeClientProvider.java
New file
0,0 → 1,43
/*
* 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.generationDoc.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.math.BigDecimal;
import java.util.Collection;
 
public class TotalCommandeClientProvider implements SpreadSheetCellValueProvider {
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
Collection<? extends SQLRowAccessor> rows = row.getReferentRows(row.getTable().getTable("TR_COMMANDE_CLIENT"));
long total = 0;
for (SQLRowAccessor sqlRowAccessor : rows) {
if (!sqlRowAccessor.isForeignEmpty("ID_COMMANDE_CLIENT")) {
SQLRowAccessor rowCmd = sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT");
total += rowCmd.getLong("T_HT");
}
}
return new BigDecimal(total).movePointLeft(2);
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.command.total", new TotalCommandeClientProvider());
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/TotalAcompteProvider.java
New file
0,0 → 1,65
/*
* 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.generationDoc.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
 
public class TotalAcompteProvider implements SpreadSheetCellValueProvider {
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
Calendar c = row.getDate("DATE");
 
Collection<? extends SQLRowAccessor> rows = row.getReferentRows(row.getTable().getTable("TR_COMMANDE_CLIENT"));
long total = 0;
Set<SQLRowAccessor> facture = new HashSet<SQLRowAccessor>();
facture.add(row);
for (SQLRowAccessor sqlRowAccessor : rows) {
total += getPreviousAcompte(sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT"), facture, c);
}
 
return new BigDecimal(total).movePointLeft(2);
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.total", new TotalAcompteProvider());
}
 
public long getPreviousAcompte(SQLRowAccessor sqlRowAccessor, Set<SQLRowAccessor> alreadyAdded, Calendar c) {
if (sqlRowAccessor == null || sqlRowAccessor.isUndefined()) {
return 0L;
}
Collection<? extends SQLRowAccessor> rows = sqlRowAccessor.getReferentRows(sqlRowAccessor.getTable().getTable("TR_COMMANDE_CLIENT"));
long l = 0;
for (SQLRowAccessor sqlRowAccessor2 : rows) {
SQLRowAccessor rowFact = sqlRowAccessor2.getForeign("ID_SAISIE_VENTE_FACTURE");
 
if (rowFact != null && !rowFact.isUndefined() && !alreadyAdded.contains(rowFact) && rowFact.getDate("DATE").before(c)) {
alreadyAdded.add(rowFact);
l += rowFact.getLong("T_HT");
}
}
return l;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/AdresseFullClientValueProvider.java
15,7 → 15,6
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.map.model.Ville;
import org.openconcerto.sql.model.SQLRowAccessor;
 
public class AdresseFullClientValueProvider extends AdresseClientProvider {
28,7 → 27,7
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor r = getAdresse(context.getRow(), this.type);
final SQLRowAccessor r = getAdresse(context.getRow(), this.type);
 
String result = r.getString("RUE");
result += "\n" + r.getString("CODE_POSTAL");
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/FacturableValueProvider.java
New file
0,0 → 1,38
/*
* 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.generationDoc.provider;
 
import org.openconcerto.erp.core.common.ui.Acompte;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.math.BigDecimal;
 
public class FacturableValueProvider implements SpreadSheetCellValueProvider {
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
BigDecimal percent = row.getBigDecimal("POURCENT_FACTURABLE");
BigDecimal amount = row.getBigDecimal("MONTANT_FACTURABLE");
Acompte a = new Acompte(percent, amount);
return a.toPlainString();
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.partial.value", new FacturableValueProvider());
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/LabelAccountInvoiceProvider.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.generationDoc.provider;
 
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.util.Collection;
 
public class LabelAccountInvoiceProvider implements SpreadSheetCellValueProvider {
 
public Object getValue(SpreadSheetCellValueContext context) {
final SQLRowAccessor row = context.getRow();
final Collection<? extends SQLRowAccessor> rows = row.getReferentRows(row.getTable().getTable("TR_COMMANDE_CLIENT"));
String result;
if (row.getBoolean("PARTIAL")) {
result = "Facturation intermédiaire, commande N°";
} else {
result = "Solde, commande N°";
}
for (SQLRowAccessor sqlRowAccessor : rows) {
if (!sqlRowAccessor.isForeignEmpty("ID_COMMANDE_CLIENT")) {
final SQLRowAccessor rowCmd = sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT");
result += rowCmd.getString("NUMERO");
}
}
return result;
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.label", new LabelAccountInvoiceProvider());
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationListeXML.java
59,6 → 59,9
final SAXBuilder builder = new SAXBuilder();
try {
InputStream xmlConfiguration = TemplateManager.getInstance().getTemplateConfiguration(templateId, rowLanguage != null ? rowLanguage.getString("CHEMIN") : null, null);
if (xmlConfiguration == null) {
throw new IllegalStateException("Template configuration " + templateId + " not found");
}
Document doc = builder.build(xmlConfiguration);
 
// On initialise un nouvel élément racine avec l'élément racine du
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/SpreadSheetGeneratorCompta.java
45,9 → 45,8
 
final Map<String, Map<Integer, String>> mapStyleDef = StyleSQLElement.getMapAllStyle();
 
System.err.println("GET first sheet");
final Sheet sheet = ssheet.getSheet(0);
System.err.println("get sheet 0, print ranges --> " + sheet.getPrintRanges());
 
// on parcourt chaque ligne de la feuille pour recuperer les styles
String s = (sheet.getPrintRanges() == null) ? "" : sheet.getPrintRanges().toString();
String[] range = s.split(":");
68,13 → 67,12
}
searchStyle(sheet, mapStyleDef, colEnd, rowEnd);
 
System.err.println("Duplicate page Nombre de page : " + this.nbPage + " nombre de rows par page " + this.nbRowsPerPage);
if (colEnd > 0) {
System.err.println("Set Column Count to :: " + (colEnd + 1));
sheet.setColumnCount(colEnd + 1);
}
sheet.duplicateFirstRows(this.nbRowsPerPage, this.nbPage);
System.err.println("End Duplicate");
 
Object printRangeObj = sheet.getPrintRanges();
if (printRangeObj != null) {
String[] range2 = printRangeObj.toString().split(":");
99,8 → 97,6
// on place les valeurs
fill(sheet, mapStyleDef);
 
System.err.println("SAVE");
 
return save(ssheet);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/AbstractLocalTemplateProvider.java
25,6 → 25,9
 
@Override
public InputStream getTemplate(String templateId, String language, String type) {
if (templateId == null) {
throw new NullPointerException("null templateId");
}
final File file = getFileTemplate(templateId, language, type);
return (file == null ? null : getInputStream(file));
}
40,6 → 43,9
}
 
public File getFileTemplate(String templateId, String language, String type) {
if (templateId == null) {
throw new NullPointerException("null templateId");
}
File templateFile = getTemplateFromLocalFile(templateId, language, type);
if (templateFile != null && templateFile.exists()) {
return templateFile;
57,11 → 63,17
 
@Override
public InputStream getTemplatePrintConfiguration(String templateId, String language, String type) {
if (templateId == null) {
throw new NullPointerException("null templateId");
}
final File file = getFileTemplatePrintConfiguration(templateId, language, type);
return getInputStream(file);
}
 
public File getFileTemplatePrintConfiguration(String templateId, String language, String type) {
if (templateId == null) {
throw new NullPointerException("null templateId");
}
final File file = getTemplateFromLocalFile(templateId + ".odsp", language, type);
return file;
}
68,11 → 80,17
 
@Override
public InputStream getTemplateConfiguration(String templateId, String language, String type) {
if (templateId == null) {
throw new NullPointerException("null templateId");
}
final File file = getFileTemplateConfiguration(templateId, language, type);
return getInputStream(file);
}
 
public File getFileTemplateConfiguration(String templateId, String language, String type) {
if (templateId == null) {
throw new NullPointerException("null templateId");
}
final File file = getTemplateFromLocalFile(templateId + ".xml", language, type);
return file;
}
83,6 → 101,13
public abstract String getTemplatePath(String templateId, String language, String type);
 
public static String insertBeforeExtenstion(String fileName, String text) {
if (fileName == null) {
throw new NullPointerException("null fileName");
}
if (text == null) {
throw new NullPointerException("null text");
}
 
final int index = fileName.lastIndexOf('.');
if (index < 0) {
return null;
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/SheetXml.java
205,35 → 205,39
}
 
public static void createPDF(final File generatedFile, final File pdfFile, final OpenDocument doc, String storagePath) {
if (pdfFile == null) {
throw new IllegalArgumentException("null PDF file");
}
try {
SheetUtils.convert2PDF(doc, pdfFile);
 
} catch (Throwable e) {
ExceptionHandler.handle("Impossible de créer le PDF.", e);
ExceptionHandler.handle("Impossible de créer le PDF " + pdfFile.getAbsolutePath(), e);
}
if (!pdfFile.canRead()) {
ExceptionHandler.handle("Le fichier PDF " + pdfFile.getAbsolutePath() + " ne peut être lu.");
}
List<StorageEngine> engines = StorageEngines.getInstance().getActiveEngines();
for (StorageEngine storageEngine : engines) {
if (storageEngine.isConfigured() && storageEngine.allowAutoStorage()) {
final String path = storagePath;
try {
storageEngine.connect();
final BufferedInputStream inStream = new BufferedInputStream(new FileInputStream(pdfFile));
final String path = storagePath;
storageEngine.store(inStream, path, pdfFile.getName(), true);
inStream.close();
storageEngine.disconnect();
} catch (IOException e) {
ExceptionHandler.handle("Impossible de sauvegarder le PDF", e);
ExceptionHandler.handle("Impossible de sauvegarder le PDF " + pdfFile.getAbsolutePath() + " vers " + path + "(" + storageEngine + ")", e);
}
if (storageEngine instanceof CloudStorageEngine) {
try {
storageEngine.connect();
final BufferedInputStream inStream = new BufferedInputStream(new FileInputStream(generatedFile));
final String path = storagePath;
storageEngine.store(inStream, path, generatedFile.getName(), true);
inStream.close();
storageEngine.disconnect();
} catch (IOException e) {
ExceptionHandler.handle("Impossible de sauvegarder le fichier généré", e);
ExceptionHandler.handle("Impossible de sauvegarder le fichier généré " + generatedFile.getAbsolutePath() + " vers " + path + "(" + storageEngine + ")", e);
}
}
}
470,7 → 474,7
 
} catch (Exception e) {
 
ExceptionHandler.handle("Impossible de charger le document OpentOffice", e);
ExceptionHandler.handle("Impossible de charger le document OpenOffice", e);
e.printStackTrace();
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/EtatVentesXmlSheet.java
58,21 → 58,23
public EtatVentesXmlSheet(Date du, Date au) {
super();
this.printer = PrinterNXProps.getInstance().getStringProperty("BonPrinter");
if (du != null) {
final Calendar c1 = Calendar.getInstance();
c1.setTime(du);
c1.set(Calendar.HOUR_OF_DAY, 0);
c1.set(Calendar.MINUTE, 0);
c1.set(Calendar.SECOND, 0);
 
this.du = new Timestamp(c1.getTimeInMillis());
}
if (au != null) {
final Calendar c2 = Calendar.getInstance();
c2.setTime(au);
c2.set(Calendar.HOUR_OF_DAY, 23);
c2.set(Calendar.MINUTE, 59);
c2.set(Calendar.SECOND, 59);
this.du = new Timestamp(c1.getTimeInMillis());
this.au = new Timestamp(c2.getTimeInMillis());
 
}
}
 
@Override
public String getDefaultTemplateId() {
136,7 → 138,10
 
Where w3 = new Where(tableTicket.getField("DATE"), this.du, this.au);
Where w4 = new Where(tableFacture.getField("DATE"), this.du, this.au);
if (this.du != null && this.au != null) {
sel.setWhere(w3.or(w4));
}
// FIXME traiter le cas du!=null et au==null et vice versa
sel.addGroupBy(tableFactureElement.getField("NOM"));
sel.addGroupBy(tableFactureElement.getField("CODE"));
System.err.println(sel.asString());
151,7 → 156,9
selQte.addSelect(tableFactureElement.getField("T_PV_TTC"), "SUM");
selQte.addJoin("LEFT", tableFactureElement.getField("ID_SAISIE_VENTE_FACTURE")).setWhere(w);
selQte.addJoin("LEFT", tableFactureElement.getField("ID_TICKET_CAISSE"), "ticket").setWhere(w2);
selQte.setWhere(w3.or(w4));
if (this.du != null && this.au != null) {
selQte.setWhere(w3.or(w4)); // FIXME traiter le cas du!=null et au==null et vice versa
}
selQte.addGroupBy(tableFactureElement.getField("NOM"));
selQte.addGroupBy(tableFactureElement.getField("CODE"));
 
211,9 → 218,15
selVC.addSelect(venteComptoirT.getField("MONTANT_HT"), "SUM");
selVC.addSelect(venteComptoirT.getField("MONTANT_TTC"), "SUM");
selVC.addSelect(venteComptoirT.getField("NOM"), "COUNT");
 
if (this.du != null && this.au != null) {
Where wVC = new Where(venteComptoirT.getField("DATE"), this.du, this.au);
wVC = wVC.and(new Where(venteComptoirT.getField("ID_ARTICLE"), "=", venteComptoirT.getForeignTable("ID_ARTICLE").getKey()));
selVC.setWhere(wVC);
} else {
selVC.setWhere(new Where(venteComptoirT.getField("ID_ARTICLE"), "=", venteComptoirT.getForeignTable("ID_ARTICLE").getKey()));
}
// FIXME traiter le cas du!=null et au==null et vice versa
selVC.addGroupBy(venteComptoirT.getField("NOM"));
List<Object[]> listVC = (List<Object[]>) venteComptoirT.getDBSystemRoot().getDataSource().execute(selVC.asString(), new ArrayListHandler());
long totalVCInCents = 0;
335,8 → 348,15
valuesE.put("TOTAL_GLOBAL", totalTPVTTC.add(new BigDecimal(totalAchatInCents).movePointLeft(2)));
values.put("TOTAL_PA", totalTPA);
values.put("TOTAL_PV_TTC", totalTPVTTC);
String periode = "";
if (this.du != null && this.au != null) {
periode = "Période du " + DATE_FORMAT.format(this.du) + " au " + DATE_FORMAT.format(this.au);
} else if (du == null && au != null) {
periode = "Période jusqu'au " + DATE_FORMAT.format(this.au);
} else if (du != null && du != null) {
periode = "Période depuis le " + DATE_FORMAT.format(this.du);
}
 
String periode = "Période Du " + DATE_FORMAT.format(this.du) + " au " + DATE_FORMAT.format(this.au);
values.put("DATE", periode);
valuesAchat.put("DATE", periode);
valuesE.put("DATE", periode);
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/ODTPrinterNX.java
38,6 → 38,7
public void print(final String printerName, final int copies) {
final PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
printJob.setCopies(copies);
 
// Set the printer
PrintService myService = null;
74,7 → 75,7
public void run() {
if (printJob.printDialog(pras)) {
try {
printJob.print();
printJob.print(pras);
} catch (PrinterException e) {
e.printStackTrace();
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationXML.java
352,6 → 352,27
}
List<Element> listElts = tableau.getChildren("element");
 
if (row.getTable().contains("ID_TAXE_PORT") && row.getTable().contains("PORT_HT")) {
 
SQLRowAccessor rowTaxe = getForeignRow(row, row.getTable().getField("ID_TAXE_PORT"));
BigDecimal ht = BigDecimal.ZERO;
if (row.getTable().getFieldRaw("PORT_HT") != null) {
ht = new BigDecimal((Long) row.getObject("PORT_HT")).movePointLeft(2);
if (ht.signum() != 0) {
if (taxe.get(rowTaxe) != null) {
 
final Object object = taxe.get(rowTaxe).get("MONTANT_HT");
BigDecimal montant = (object == null) ? BigDecimal.ZERO : (BigDecimal) object;
taxe.get(rowTaxe).put("MONTANT_HT", montant.add(ht));
} else {
Map<String, Object> m = new HashMap<String, Object>();
m.put("MONTANT_HT", ht);
taxe.put(rowTaxe, m);
}
}
}
}
 
// on remplit chaque ligne à partir des rows recuperées
int numeroRef = 0;
for (SQLRowAccessor rowElt : rowsEltCache.get(ref)) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirFournisseur.java
142,6 → 142,7
if (valAvoir.getInvalid() == null) {
 
valAvoir.update(this.idAvoirFourn);
displayMvtNumber();
}
 
// if (avoirRow.getInt("ID_MODE_REGLEMENT") > 1) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieVenteFacture.java
252,6 → 252,7
 
if (valSasieVF.getInvalid() == null) {
valSasieVF.update(this.idSaisieVenteFacture);
displayMvtNumber();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieVenteComptoir.java
73,8 → 73,8
// on calcule le nouveau numero de mouvement
if (this.idMvt == 1) {
this.idMvt = getNewMouvement(GenerationMvtSaisieVenteComptoir.source, this.idSaisieVenteComptoir, 1, string);
}
this.mEcritures.put("ID_MOUVEMENT", new Integer(this.idMvt));
}
 
// generation des ecritures + maj des totaux du compte associe
 
158,6 → 158,7
if (valSaisieVC.getInvalid() == null) {
// ajout de l'ecriture
valSaisieVC.update(this.idSaisieVenteComptoir);
displayMvtNumber();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementAchat.java
26,6 → 26,7
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class GenerationReglementAchat extends GenerationEcritures {
40,9 → 41,7
 
SQLRow regMontantRow = base.getTable("REGLER_MONTANT").getRow(idRegMontant);
 
int idEchFourn = regMontantRow.getInt("ID_ECHEANCE_FOURNISSEUR");
SQLRow echeanceRow = base.getTable("ECHEANCE_FOURNISSEUR").getRow(idEchFourn);
SQLRow rowFournisseur = base.getTable("FOURNISSEUR").getRow(echeanceRow.getInt("ID_FOURNISSEUR"));
SQLRow rowFournisseur = regMontantRow.getForeign("ID_FOURNISSEUR");
 
System.err.println("Génération des ecritures du reglement du mouvement " + this.idMvt);
 
59,6 → 58,20
// "Règlement achat" + SOURCE.getNom() ??
this.nom = "Règlement achat " + rowFournisseur.getString("NOM") + " (" + typeRegRow.getString("NOM") + ")";
 
List<SQLRow> l = regMontantRow.getReferentRows(regMontantRow.getTable().getTable("REGLER_MONTANT_ELEMENT"));
int mvtSource = -1;
for (SQLRow sqlRow : l) {
SQLRow mvtEch = sqlRow.getForeignRow("ID_MOUVEMENT_ECHEANCE");
if (mvtEch.getID() != mvtSource) {
getNewMouvement("REGLER_MONTANT", idRegMontant, mvtEch.getID(), mvtEch.getInt("ID_PIECE"));
if (mvtSource == -1) {
mvtSource = mvtEch.getID();
}
}
}
 
SQLRow rowMvtSource = tableMouvement.getRow(mvtSource);
 
// si paiement comptant
if ((modeRegRow.getInt("AJOURS") == 0) && (modeRegRow.getInt("LENJOUR") == 0)) {
 
67,7 → 80,7
if (typeRegRow.getID() == 2) {
 
// Ajout dans cheque fournisseur
paiementCheque(this.date, idEchFourn, idRegMontant);
paiementCheque(this.date, rowMvtSource, rowFournisseur.getID(), idRegMontant);
} else {
 
if (typeRegRow.getID() == 4) {
77,9 → 90,9
}
 
// SQLRow echeanceRow = base.getTable("ECHEANCE_FOURNISSEUR").getRow(idEchFourn);
SQLRow rowMouv = tableMouvement.getRow(echeanceRow.getInt("ID_MOUVEMENT"));
this.idMvt = getNewMouvement("REGLER_MONTANT", idRegMontant, rowMouv.getID(), rowMouv.getInt("ID_PIECE"));
 
this.idMvt = getNewMouvement("REGLER_MONTANT", idRegMontant, rowMvtSource.getID(), rowMvtSource.getInt("ID_PIECE"));
 
this.mEcritures.put("DATE", this.date);
this.mEcritures.put("NOM", this.nom);
this.mEcritures.put("ID_MOUVEMENT", new Integer(this.idMvt));
126,21 → 139,19
if (typeRegRow.getID() == 2) {
 
// Ajout dans cheque fournisseur
paiementCheque(dateEch, idEchFourn, idRegMontant);
paiementCheque(dateEch, rowMvtSource, rowFournisseur.getID(), idRegMontant);
} else {
 
// Ajout dans echeance
Map<String, Object> mEcheance = new HashMap<String, Object>();
SQLRow rowMouv = tableMouvement.getRow(echeanceRow.getInt("ID_MOUVEMENT"));
this.idMvt = getNewMouvement("ECHEANCE_FOURNISSEUR", 1, rowMouv.getID(), rowMouv.getInt("ID_PIECE"));
 
this.idMvt = getNewMouvement("ECHEANCE_FOURNISSEUR", 1, rowMvtSource.getID(), rowMvtSource.getInt("ID_PIECE"));
mEcheance.put("ID_MOUVEMENT", new Integer(this.idMvt));
 
mEcheance.put("DATE", dateEch);
mEcheance.put("MONTANT", new Long(prixTTC.getLongValue()));
 
if (idEchFourn > 1) {
mEcheance.put("ID_FOURNISSEUR", new Integer(echeanceRow.getInt("ID_FOURNISSEUR")));
}
mEcheance.put("ID_FOURNISSEUR", rowFournisseur.getID());
 
SQLRowValues valEcheance = new SQLRowValues(base.getTable("ECHEANCE_FOURNISSEUR"), mEcheance);
if (valEcheance.getInvalid() == null) {
155,21 → 166,18
}
}
 
private void paiementCheque(Date dateEch, int idEchFourn, int idRegMontant) throws SQLException {
private void paiementCheque(Date dateEch, SQLRow rowMvtSource, int idFourn, int idRegMontant) throws SQLException {
 
SQLRow regMontantRow = base.getTable("REGLER_MONTANT").getRow(idRegMontant);
SQLRow echeanceRow = base.getTable("ECHEANCE_FOURNISSEUR").getRow(idEchFourn);
PrixTTC prixTTC = new PrixTTC(((Long) regMontantRow.getObject("MONTANT")).longValue());
 
SQLRowValues valCheque = new SQLRowValues(base.getTable("CHEQUE_FOURNISSEUR"));
 
if (idEchFourn > 1) {
valCheque.put("ID_FOURNISSEUR", new Integer(echeanceRow.getInt("ID_FOURNISSEUR")));
}
valCheque.put("ID_FOURNISSEUR", idFourn);
valCheque.put("DATE_ACHAT", this.date);
valCheque.put("DATE_MIN_DECAISSE", dateEch);
SQLRow rowMvtPere = tableMouvement.getRow(echeanceRow.getInt("ID_MOUVEMENT"));
this.idMvt = getNewMouvement("CHEQUE_FOURNISSEUR", 1, rowMvtPere.getID(), rowMvtPere.getInt("ID_PIECE"));
 
this.idMvt = getNewMouvement("CHEQUE_FOURNISSEUR", 1, rowMvtSource.getID(), rowMvtSource.getInt("ID_PIECE"));
valCheque.put("ID_MOUVEMENT", new Integer(this.idMvt));
valCheque.put("MONTANT", new Long(prixTTC.getLongValue()));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtFactureFournisseur.java
New file
0,0 → 1,176
/*
* 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.generationEcritures;
 
import org.openconcerto.erp.core.common.ui.TotalCalculator;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.ExceptionHandler;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.Map;
 
public class GenerationMvtFactureFournisseur extends GenerationEcritures implements Runnable {
 
public static final String ID = "accounting.records.supply.order";
 
private int idFacture;
private static final String source = "FACTURE_FOURNISSEUR";
private static final Integer journal = new Integer(JournalSQLElement.ACHATS);
private static final SQLTable tableFacture = base.getTable("FACTURE_FOURNISSEUR");
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
private static final SQLTable tableFournisseur = base.getTable("FOURNISSEUR");
private static final SQLTable tableMvt = base.getTable("MOUVEMENT");
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
 
public GenerationMvtFactureFournisseur(int idFacture, int idMvt) {
this.idFacture = idFacture;
this.idMvt = idMvt;
(new Thread(GenerationMvtFactureFournisseur.this)).start();
}
 
public GenerationMvtFactureFournisseur(int idFacture) {
 
this.idFacture = idFacture;
this.idMvt = 1;
(new Thread(GenerationMvtFactureFournisseur.this)).start();
}
 
public void genereMouvement() throws Exception {
 
SQLRow saisieRow = tableFacture.getRow(this.idFacture);
// SQLRow taxeRow = base.getTable("TAXE").getRow(saisieRow.getInt("ID_TAXE"));
 
SQLRow rowFournisseur = tableFournisseur.getRow(saisieRow.getInt("ID_FOURNISSEUR"));
 
// iniatilisation des valeurs de la map
this.date = (Date) saisieRow.getObject("DATE");
this.nom = "Achat : " + rowFournisseur.getString("NOM") + " Facture : " + saisieRow.getObject("NUMERO").toString() + " " + saisieRow.getObject("NOM").toString();
this.mEcritures.put("DATE", this.date);
// AccountingRecordsProvider provider = AccountingRecordsProviderManager.get(ID);
// provider.putLabel(saisieRow, this.mEcritures);
this.mEcritures.put("NOM", nom);
this.mEcritures.put("ID_JOURNAL", GenerationMvtFactureFournisseur.journal);
this.mEcritures.put("ID_MOUVEMENT", new Integer(1));
 
// on calcule le nouveau numero de mouvement
if (this.idMvt == 1) {
SQLRowValues rowValsPiece = new SQLRowValues(pieceTable);
// provider.putPieceLabel(saisieRow, rowValsPiece);
rowValsPiece.put("NOM", saisieRow.getObject("NUMERO").toString());
getNewMouvement(GenerationMvtFactureFournisseur.source, this.idFacture, 1, rowValsPiece);
} else {
SQLRowValues rowValsPiece = pieceTable.getTable("MOUVEMENT").getRow(idMvt).getForeign("ID_PIECE").asRowValues();
// provider.putPieceLabel(saisieRow, rowValsPiece);
rowValsPiece.put("NOM", saisieRow.getObject("NUMERO").toString());
rowValsPiece.update();
 
this.mEcritures.put("ID_MOUVEMENT", new Integer(this.idMvt));
}
 
// generation des ecritures + maj des totaux du compte associe
 
// compte Achat
SQLRow rowCompteAchat = saisieRow.getForeign("ID_COMPTE_PCE");
 
if (rowCompteAchat == null || rowCompteAchat.isUndefined()) {
rowCompteAchat = rowPrefsCompte.getForeign("ID_COMPTE_PCE_ACHAT");
if (rowCompteAchat == null || rowCompteAchat.isUndefined()) {
rowCompteAchat = ComptePCESQLElement.getRowComptePceDefault("Achats");
}
}
 
TotalCalculator calc = getValuesFromElement(true, "T_PA_HT", saisieRow, saisieRow.getTable().getTable("FACTURE_FOURNISSEUR_ELEMENT"), BigDecimal.ZERO, null, null, rowCompteAchat);
 
long ttcLongValue = calc.getTotalTTC().movePointRight(2).longValue();
long htLongValue = calc.getTotalHT().movePointRight(2).longValue();
 
for (SQLRowAccessor row : calc.getMapHt().keySet()) {
long b = calc.getMapHt().get(row).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
if (b != 0) {
this.mEcritures.put("ID_COMPTE_PCE", Integer.valueOf(row.getID()));
this.mEcritures.put("CREDIT", Long.valueOf(0));
this.mEcritures.put("DEBIT", Long.valueOf(b));
int idEcr = ajoutEcriture();
}
}
 
Map<SQLRowAccessor, BigDecimal> tvaMap = calc.getMapHtTVA();
for (SQLRowAccessor rowAc : tvaMap.keySet()) {
long longValue = tvaMap.get(rowAc).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
if (longValue != 0) {
this.mEcritures.put("ID_COMPTE_PCE", rowAc.getID());
this.mEcritures.put("CREDIT", Long.valueOf(0));
this.mEcritures.put("DEBIT", longValue);
ajoutEcriture();
 
if (rowFournisseur.getBoolean("UE")) {
int idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
if (idCompteTVAIntra <= 1) {
idCompteTVAIntra = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
}
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVAIntra));
this.mEcritures.put("DEBIT", new Long(0));
this.mEcritures.put("CREDIT", new Long(longValue));
ajoutEcriture();
}
}
}
 
// compte Fournisseurs
int idCompteFourn = rowFournisseur.getInt("ID_COMPTE_PCE");
 
if (idCompteFourn <= 1) {
idCompteFourn = rowPrefsCompte.getInt("ID_COMPTE_PCE_FOURNISSEUR");
if (idCompteFourn <= 1) {
idCompteFourn = ComptePCESQLElement.getIdComptePceDefault("Fournisseurs");
}
}
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteFourn));
this.mEcritures.put("DEBIT", new Long(0));
if (rowFournisseur.getBoolean("UE")) {
this.mEcritures.put("CREDIT", new Long(htLongValue));
} else {
this.mEcritures.put("CREDIT", new Long(ttcLongValue));
}
ajoutEcriture();
 
new GenerationMvtReglementFactureFournisseur(this.idFacture, this.idMvt);
 
// Mise à jour de la clef etrangere mouvement sur la saisie achat
SQLRowValues valEcriture = new SQLRowValues(tableFacture);
valEcriture.put("ID_MOUVEMENT", new Integer(this.idMvt));
 
if (valEcriture.getInvalid() == null) {
// ajout de l'ecriture
valEcriture.update(this.idFacture);
displayMvtNumber();
}
 
}
 
public void run() {
try {
genereMouvement();
} catch (Exception e) {
ExceptionHandler.handle("Erreur pendant la générations des écritures comptables", e);
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtReglementFactureFournisseur.java
New file
0,0 → 1,228
/*
* 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.generationEcritures;
 
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
import org.openconcerto.erp.model.PrixTTC;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.ExceptionHandler;
 
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
 
// FIXME mettre toute les generations dans des threads à part
public final class GenerationMvtReglementFactureFournisseur extends GenerationEcritures implements Runnable {
 
private int idfacture;
 
// Journal Caisse
private static final Integer journalCaisse = Integer.valueOf(JournalSQLElement.CAISSES);
 
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
private static final SQLTable tableMouvement = base.getTable("MOUVEMENT");
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
private int idPere = 1; // Id du mouvement pere
 
public GenerationMvtReglementFactureFournisseur(int idFacture, int idMvt) {
this.idfacture = idFacture;
this.idPere = idMvt;
new Thread(GenerationMvtReglementFactureFournisseur.this).start();
}
 
private void genereReglement() throws Exception {
 
System.out.println("Génération des ecritures du reglement du mouvement " + this.idMvt);
 
SQLRow saisieRow = base.getTable("FACTURE_FOURNISSEUR").getRow(this.idfacture);
SQLRow modeRegRow = base.getTable("MODE_REGLEMENT").getRow(saisieRow.getInt("ID_MODE_REGLEMENT"));
SQLRow typeRegRow = base.getTable("TYPE_REGLEMENT").getRow(modeRegRow.getInt("ID_TYPE_REGLEMENT"));
 
System.out.println("Mode de reglement " + saisieRow.getInt("ID_MODE_REGLEMENT"));
 
// PrixTTC prixTTC = new PrixTTC(((Long) saisieRow.getObject("MONTANT_TTC")).longValue());
 
PrixTTC prixTTC;
// int idAvoir = saisieRow.getInt("ID_AVOIR_FOURNISSEUR");
// if (idAvoir > 1) {
// SQLRow avoirRow = base.getTable("AVOIR_FOURNISSEUR").getRow(idAvoir);
// long l = ((Number) avoirRow.getObject("MONTANT_TTC")).longValue();
// prixTTC = new PrixTTC(((Long) saisieRow.getObject("T_TTC")).longValue() - l);
// } else {
prixTTC = new PrixTTC(((Long) saisieRow.getObject("T_TTC")).longValue());
// }
 
this.date = (Date) saisieRow.getObject("DATE");
SQLRow rowFournisseur = base.getTable("FOURNISSEUR").getRow(saisieRow.getInt("ID_FOURNISSEUR"));
this.nom = "Règlement Achat : " + rowFournisseur.getString("NOM") + " Facture : " + saisieRow.getObject("NUMERO").toString() + " (" + typeRegRow.getString("NOM") + ")";
 
// si paiement comptant
if ((modeRegRow.getInt("AJOURS") == 0) && (modeRegRow.getInt("LENJOUR") == 0)) {
 
System.out.println("Règlement Comptant");
// test Cheque
if (typeRegRow.getID() == 2) {
Calendar c = modeRegRow.getDate("DATE_DEPOT");
if (c != null) {
paiementCheque(c.getTime());
} else {
paiementCheque(this.date);
}
} else {
 
this.idMvt = this.idPere;
 
// iniatilisation des valeurs de la map
this.mEcritures.put("DATE", new java.sql.Date(this.date.getTime()));
this.mEcritures.put("NOM", this.nom);
this.mEcritures.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
 
if (typeRegRow.getID() == 4) {
this.mEcritures.put("ID_JOURNAL", GenerationMvtReglementFactureFournisseur.journalCaisse);
} else {
 
this.mEcritures.put("ID_JOURNAL", JournalSQLElement.BANQUES);
 
 
}
 
// compte Fournisseurs
int compteFourn = rowFournisseur.getInt("ID_COMPTE_PCE");
if (compteFourn <= 1) {
compteFourn = rowPrefsCompte.getInt("ID_COMPTE_PCE_FOURNISSEUR");
if (compteFourn <= 1) {
compteFourn = ComptePCESQLElement.getIdComptePceDefault("Fournisseurs");
}
}
 
this.mEcritures.put("ID_COMPTE_PCE", Integer.valueOf(compteFourn));
this.mEcritures.put("DEBIT", Long.valueOf(prixTTC.getLongValue()));
this.mEcritures.put("CREDIT", Long.valueOf(0));
ajoutEcriture();
 
// compte de reglement, caisse, CB, ...
int idCompteRegl = typeRegRow.getInt("ID_COMPTE_PCE_FOURN");
if (idCompteRegl <= 1) {
idCompteRegl = ComptePCESQLElement.getIdComptePceDefault("VenteCB");
}
this.mEcritures.put("ID_COMPTE_PCE", Integer.valueOf(idCompteRegl));
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", Long.valueOf(prixTTC.getLongValue()));
ajoutEcriture();
}
} else {
 
Date dateEch = ModeDeReglementSQLElement.calculDate(modeRegRow.getInt("AJOURS"), modeRegRow.getInt("LENJOUR"), this.date);
DateFormat dateFormat = new SimpleDateFormat();
System.out.println("Date d'échéance " + dateFormat.format(dateEch));
// System.out.println("Echeance" + dateEch);
 
// Cheque
if (typeRegRow.getID() == 2) {
 
// Ajout dans cheque fournisseur
paiementCheque(dateEch);
} else {
 
// Ajout dans echeance
Map<String, Object> mEcheance = new HashMap<String, Object>();
 
SQLRow rowMvtPere = tableMouvement.getRow(this.idPere);
this.idMvt = getNewMouvement("ECHEANCE_FOURNISSEUR", 1, this.idPere, rowMvtPere.getInt("ID_PIECE"));
 
mEcheance.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
mEcheance.put("DATE", new java.sql.Date(dateEch.getTime()));
mEcheance.put("MONTANT", Long.valueOf(prixTTC.getLongValue()));
mEcheance.put("ID_FOURNISSEUR", Integer.valueOf(saisieRow.getInt("ID_FOURNISSEUR")));
 
SQLTable echeanceTable = base.getTable("ECHEANCE_FOURNISSEUR");
SQLRowValues valEcheance = new SQLRowValues(echeanceTable, mEcheance);
 
if (valEcheance.getInvalid() == null) {
// ajout de l'ecriture
SQLRow row = valEcheance.insert();
SQLRowValues rowVals = new SQLRowValues(tableMouvement);
rowVals.put("IDSOURCE", row.getID());
rowVals.update(this.idMvt);
}
 
}
}
}
 
/**
* Reglement par cheque. Crée un cheque fournisseur à décaisser.
*
* @param dateEch date d'echeance d'encaissement du cheque
* @throws SQLException
*/
private void paiementCheque(Date dateEch) throws SQLException {
 
SQLRow saisieRow = base.getTable("FACTURE_FOURNISSEUR").getRow(this.idfacture);
// PrixTTC prixTTC = new PrixTTC(((Long) saisieRow.getObject("MONTANT_TTC")).longValue());
 
PrixTTC prixTTC;
// int idAvoir = saisieRow.getInt("ID_AVOIR_FOURNISSEUR");
// if (idAvoir > 1) {
// SQLRow avoirRow = base.getTable("AVOIR_FOURNISSEUR").getRow(idAvoir);
// long l = ((Number) avoirRow.getObject("MONTANT_TTC")).longValue();
// prixTTC = new PrixTTC(((Long) saisieRow.getObject("T_TTC")).longValue() - l);
// } else {
prixTTC = new PrixTTC(((Long) saisieRow.getObject("T_TTC")).longValue());
// }
 
// Ajout dans cheque fournisseur
Map<String, Object> mEncaisse = new HashMap<String, Object>();
mEncaisse.put("ID_FOURNISSEUR", Integer.valueOf(saisieRow.getInt("ID_FOURNISSEUR")));
mEncaisse.put("DATE_ACHAT", new java.sql.Date(this.date.getTime()));
mEncaisse.put("DATE_MIN_DECAISSE", new java.sql.Date(dateEch.getTime()));
mEncaisse.put("MONTANT", Long.valueOf(prixTTC.getLongValue()));
SQLRow rowMvtPere = tableMouvement.getRow(this.idPere);
this.idMvt = getNewMouvement("CHEQUE_FOURNISSEUR", 1, this.idPere, rowMvtPere.getInt("ID_PIECE"));
 
mEncaisse.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
 
SQLTable chqFournTable = base.getTable("CHEQUE_FOURNISSEUR");
 
SQLRowValues valDecaisse = new SQLRowValues(chqFournTable, mEncaisse);
 
if (valDecaisse.getInvalid() == null) {
 
// ajout de l'ecriture
SQLRow row = valDecaisse.insert();
 
SQLRowValues rowVals = new SQLRowValues(tableMouvement);
rowVals.put("IDSOURCE", row.getID());
rowVals.update(this.idMvt);
}
 
}
 
public void run() {
try {
genereReglement();
} catch (Exception e) {
ExceptionHandler.handle("Erreur pendant la générations des écritures comptables", e);
e.printStackTrace();
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtReglementChequeClient.java
39,10 → 39,16
this.date = d;
this.idMvt = idMvt;
this.idCheque = idCheque;
SQLRow chequeRow = base.getTable("CHEQUE_A_ENCAISSER").getRow(this.idCheque);
String num = "";
if (chequeRow != null && !chequeRow.isUndefined() && chequeRow.getString("NUMERO").trim().length() > 0) {
num = " N° " + chequeRow.getString("NUMERO");
}
 
if (s != null && s.trim().length() > 0) {
this.nom = s;
this.nom = s + (num.trim().length() > 0 ? " - Cheque" + num : "");
} else {
this.nom = "Reglement cheque client";
this.nom = "Reglement cheque client" + num;
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationEcritures.java
16,6 → 16,7
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.TotalCalculator;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.GestionPieceCommercialePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
32,10 → 33,9
import java.util.List;
import java.util.Map;
 
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
/**
* Generation des ecritures comptables, permet l'ajout d'ecriture, la creation des mouvements
*
49,6 → 49,7
protected static final SQLTable journalTable = base.getTable("JOURNAL");
protected static final SQLTable ecritureTable = base.getTable("ECRITURE");
protected static final SQLTable pieceTable = base.getTable("PIECE");
protected static final SQLTable mouvementTable = base.getTable("MOUVEMENT");
 
protected int idMvt;
protected int idPiece;
285,8 → 286,13
}
 
protected TotalCalculator getValuesFromElement(SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon) {
return getValuesFromElement(false, "T_PV_HT", row, foreign, portHT, rowTVAPort, tableEchantillon, null);
}
 
TotalCalculator calc = new TotalCalculator("T_PA_HT", "T_PV_HT", null);
protected TotalCalculator getValuesFromElement(boolean achat, String fieldTotalHT, SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon,
SQLRow defaultCompte) {
 
TotalCalculator calc = new TotalCalculator("T_PA_HT", fieldTotalHT, null, achat, defaultCompte);
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
Boolean bServiceActive = Boolean.valueOf(val);
calc.setServiceActive(bServiceActive != null && bServiceActive);
387,4 → 393,18
 
return this.idMvt;
}
 
protected void displayMvtNumber() {
if (DefaultNXProps.getInstance().getBooleanValue(GestionPieceCommercialePanel.SHOW_MOUVEMENT_NUMBER, false)) {
final int numero = mouvementTable.getRow(idMvt).getInt("NUMERO");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(null, "N° de mouvement associé : " + numero);
}
});
}
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieAchat.java
161,6 → 161,7
if (valEcriture.getInvalid() == null) {
// ajout de l'ecriture
valEcriture.update(this.idSaisieAchat);
displayMvtNumber();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirClient.java
172,6 → 172,7
} else {
valAvoir.put("SOLDE", Boolean.FALSE);
valAvoir.update(this.idAvoirClient);
displayMvtNumber();
}
 
return this.idMvt;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/action/ListeDesCommandesClientAction.java
16,18 → 16,25
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
import org.openconcerto.erp.core.common.component.TransfertGroupSQLComponent;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent;
import org.openconcerto.erp.core.sales.account.VenteFactureSoldeSQLComponent;
import org.openconcerto.erp.core.sales.order.element.CommandeClientSQLElement;
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
36,21 → 43,28
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.state.WindowStateManager;
import org.openconcerto.ui.table.PercentTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.NumberUtils;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.io.File;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
 
public class ListeDesCommandesClientAction extends CreateFrameAbstractAction {
 
62,6 → 76,20
public JFrame createFrame() {
final JFrame frame = new JFrame("Commandes clients");
// Actions
 
frame.getContentPane().add(createAllOrderPanel());
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
FrameUtil.setBounds(frame);
final File file = IListFrame.getConfigFile(eltCmd, frame.getClass());
if (file != null)
new WindowStateManager(frame, file).loadState();
return frame;
}
 
JPanel createAllOrderPanel() {
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
final List<RowAction> allowedActions = new ArrayList<RowAction>();
// Transfert vers facture
PredicateRowAction bonAction = new PredicateRowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
70,12 → 98,63
}, false, "sales.order.create.deliverynote");
 
// Transfert vers facture
PredicateRowAction factureAction = new PredicateRowAction(new AbstractAction() {
RowAction factureAction = new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
transfertFactureClient(IListe.get(e).copySelectedRows());
}
}, false, "sales.order.create.invoice");
}, false, "sales.order.create.invoice") {
 
@Override
public boolean enabledFor(List<SQLRowAccessor> selection) {
if (selection.isEmpty()) {
return false;
} else if (selection.size() > 1) {
return true;
} else {
BigDecimal d = getAvancement(selection.get(0));
return d.signum() == 0;
}
}
};
 
// Transfert vers facture intermédiaire
RowAction acompteAction = new RowAction(new AbstractAction("Créer une facture intermédiaire") {
public void actionPerformed(ActionEvent e) {
transfertAcompteClient(IListe.get(e).copySelectedRows());
}
}, false, "sales.order.create.account") {
BigDecimal cent = BigDecimal.ONE.movePointRight(2);
 
@Override
public boolean enabledFor(List<SQLRowAccessor> selection) {
if (selection.isEmpty() || selection.size() > 1) {
return false;
} else {
BigDecimal d = getAvancement(selection.get(0));
return NumberUtils.compare(d, cent) != 0;
}
}
};
 
// Transfert vers facture solde
RowAction soldeAction = new RowAction(new AbstractAction("Facturer le solde") {
public void actionPerformed(ActionEvent e) {
transfertSoldeClient(IListe.get(e).copySelectedRows());
}
}, false, "sales.order.create.account.solde") {
BigDecimal cent = BigDecimal.ONE.movePointRight(2);
 
@Override
public boolean enabledFor(List<SQLRowAccessor> selection) {
if (selection.isEmpty() || selection.size() > 1) {
return false;
} else {
BigDecimal d = getAvancement(selection.get(0));
return NumberUtils.compare(d, cent) != 0 && NumberUtils.compare(d, BigDecimal.ZERO) != 0;
}
}
};
 
// Transfert vers commande
PredicateRowAction cmdAction = new PredicateRowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
95,38 → 174,90
}, false, "sales.order.create.supplier.order");
 
cmdAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
factureAction.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
 
bonAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
allowedActions.add(bonAction);
allowedActions.add(factureAction);
allowedActions.add(acompteAction);
allowedActions.add(soldeAction);
allowedActions.add(cmdAction);
 
// Tabs
final JTabbedPane tabs = new JTabbedPane();
tabs.addTab("Commandes non facturées", createOrderWithoutInvoicePanel(cmdAction, factureAction, bonAction));
tabs.addTab("Commandes facturées", createOrderWithInvoicePanel(cmdAction, bonAction));
tabs.addTab("Toutes les commandes", createAllOrderPanel(cmdAction, factureAction, bonAction));
frame.setContentPane(tabs);
final BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) {
 
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
FrameUtil.setBounds(frame);
final File file = IListFrame.getConfigFile(eltCmd, frame.getClass());
if (file != null)
new WindowStateManager(frame, file).loadState();
return frame;
@Override
protected Object show_(SQLRowAccessor r) {
 
return getAvancement(r);
}
 
JPanel createAllOrderPanel(final PredicateRowAction cmdAction, final PredicateRowAction factureAction, final PredicateRowAction bonAction) {
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
final List<RowAction> allowedActions = new ArrayList<RowAction>();
allowedActions.add(bonAction);
allowedActions.add(factureAction);
allowedActions.add(cmdAction);
@Override
public Set<FieldPath> getPaths() {
final Path p = new PathBuilder(eltCmd.getTable()).addTable("TR_COMMANDE_CLIENT").addTable("SAISIE_VENTE_FACTURE").build();
return CollectionUtils.createSet(new FieldPath(p, "T_HT"));
}
};
tableSource.getColumns().add(colAvancement);
colAvancement.setRenderer(new PercentTableCellRenderer());
final ListeAddPanel panel = getPanel(eltCmd, tableSource, allowedActions);
return panel;
}
 
private BigDecimal getAvancement(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_COMMANDE_CLIENT"));
long totalFact = 0;
long total = r.getLong("T_HT");
for (SQLRowAccessor row : rows) {
if (!row.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) {
SQLRowAccessor rowFact = row.getForeign("ID_SAISIE_VENTE_FACTURE");
Long l = rowFact.getLong("T_HT");
totalFact += l;
}
}
if (total > 0) {
return new BigDecimal(totalFact).divide(new BigDecimal(total), MathContext.DECIMAL128).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
} else {
return BigDecimal.ONE.movePointRight(2);
}
}
 
private ListeAddPanel getPanel(final SQLElement eltCmd, final SQLTableModelSourceOnline tableSource, final List<RowAction> allowedActions) {
final ListeAddPanel panel = new ListeAddPanel(eltCmd, new IListe(tableSource));
final ListeAddPanel panel = new ListeAddPanel(eltCmd, new IListe(tableSource)) {
@Override
protected void createUI() {
super.createUI();
this.btnMngr.setAdditional(this.buttonEffacer, new ITransformer<JButton, String>() {
 
@Override
public String transformChecked(JButton input) {
 
SQLRowAccessor row = getListe().fetchSelectedRow();
 
BigDecimal b = getAvancement(row);
 
if (b.signum() != 0) {
return "Vous ne pouvez pas supprimer une commande facturée !";
}
return null;
}
});
this.btnMngr.setAdditional(this.buttonModifier, new ITransformer<JButton, String>() {
 
@Override
public String transformChecked(JButton input) {
 
SQLRowAccessor row = getListe().fetchSelectedRow();
 
BigDecimal b = getAvancement(row);
 
if (b.signum() != 0) {
return "Vous ne pouvez pas modifier une commande facturée !";
}
return null;
}
});
}
};
 
final List<SQLField> fields = new ArrayList<SQLField>(2);
fields.add(eltCmd.getTable().getField("T_HT"));
final IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), fields, "Total des commandes de la liste");
167,37 → 298,6
return panel;
}
 
JPanel createOrderWithInvoicePanel(PredicateRowAction cmdAction, PredicateRowAction bonAction) {
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
final List<RowAction> allowedActions = new ArrayList<RowAction>();
allowedActions.add(bonAction);
allowedActions.add(cmdAction);
 
// Filter on transfered
final SQLInjector injector = SQLInjector.getInjector(eltCmd.getTable(), eltCmd.getTable().getTable("SAISIE_VENTE_FACTURE"));
injector.setOnlyTransfered(tableSource);
 
final ListeAddPanel panel = getPanel(eltCmd, tableSource, allowedActions);
return panel;
}
 
JPanel createOrderWithoutInvoicePanel(PredicateRowAction cmdAction, PredicateRowAction factureAction, PredicateRowAction bonAction) {
final SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
final SQLTableModelSourceOnline tableSource = eltCmd.getTableSource(true);
final List<RowAction> allowedActions = new ArrayList<RowAction>();
allowedActions.add(bonAction);
allowedActions.add(factureAction);
allowedActions.add(cmdAction);
 
// Filter on not transfered
final SQLInjector injector = SQLInjector.getInjector(eltCmd.getTable(), eltCmd.getTable().getTable("SAISIE_VENTE_FACTURE"));
injector.setOnlyNotTransfered(tableSource);
 
final ListeAddPanel panel = getPanel(eltCmd, tableSource, allowedActions);
return panel;
}
 
/**
* Transfert en BL
*
216,4 → 316,22
TransfertBaseSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE");
 
}
 
/**
* Transfert en Facture
*
* @param row
*/
private void transfertAcompteClient(List<SQLRowValues> rows) {
TransfertGroupSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE", VenteFactureSituationSQLComponent.ID);
}
 
/**
* Transfert en Facture
*
* @param row
*/
private void transfertSoldeClient(List<SQLRowValues> rows) {
TransfertGroupSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE", VenteFactureSoldeSQLComponent.ID);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/VenteFactureSoldeEditGroup.java
New file
0,0 → 1,54
/*
* 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.sales.account;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class VenteFactureSoldeEditGroup extends Group {
 
public VenteFactureSoldeEditGroup() {
super("sales.invoice.partial.balance");
final Group g = new Group("sales.invoice.partial.balance.identifier");
g.addItem("sales.invoice.number");
g.addItem("DATE");
g.addItem("NOM", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
g.addItem("ID_COMMERCIAL");
g.addItem("sales.invoice.partial.amount");
 
this.add(g);
 
final Group gCustomer = new Group("sales.invoice.partial.balance.customer");
gCustomer.addItem("sales.invoice.customer", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
add(gCustomer);
 
final Group gElements = new Group("sales.invoice.partial.balance.items");
gElements.addItem("sales.invoice.partial.items.list", LayoutHints.DEFAULT_LIST_HINTS);
add(gElements);
 
final Group gMdr = new Group("sales.invoice.partial.balance.payment");
gMdr.addItem("ID_MODE_REGLEMENT");
add(gMdr);
 
final Group gTotal = new Group("sales.invoice.partial.balance.total");
gTotal.addItem("sales.invoice.partial.total.amount");
add(gTotal);
 
final Group gInfos = new Group("sales.invoice.partial.balance.infos");
gInfos.addItem("INFOS", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
add(gInfos);
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/VenteFactureSoldeSQLComponent.java
New file
0,0 → 1,108
/*
* 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.sales.account;
 
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.Acompte;
import org.openconcerto.erp.core.common.ui.AcompteField;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.erp.core.sales.invoice.ui.FactureSituationItemTable;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.utils.Tuple2;
 
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.JCheckBox;
 
public class VenteFactureSoldeSQLComponent extends VenteFactureSituationSQLComponent {
public static final String ID = "sales.invoice.partial.balance";
 
public VenteFactureSoldeSQLComponent(SQLElement element) {
super(element, new VenteFactureSoldeEditGroup());
}
 
@Override
protected void addViews() {
 
super.addViews();
getEditor("sales.invoice.partial.amount").setEnabled(false);
JCheckBox box = new JCheckBox("Solde");
box.setSelected(true);
this.addView(box, "SOLDE");
 
}
 
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
rowVals.put("SOLDE", Boolean.TRUE);
return rowVals;
}
 
@Override
public int insert(SQLRow order) {
return super.insert(order);
}
 
@Override
public void importFrom(List<SQLRowValues> rows) {
 
super.importFrom(rows);
AcompteField field = (AcompteField) getEditor("sales.invoice.partial.amount");
 
Tuple2<Long, Long> t = getTotalFacture(rows);
final Acompte a = new Acompte(null, new BigDecimal(t.get0() - t.get1()).movePointLeft(2));
field.setValue(a);
final FactureSituationItemTable table = ((FactureSituationItemTable) getEditor("sales.invoice.partial.items.list"));
table.calculPourcentage(a);
}
 
public Tuple2<Long, Long> getTotalFacture(List<SQLRowValues> context) {
 
long totalFacture = 0;
long totalCommande = 0;
Set<SQLRowAccessor> facture = new HashSet<SQLRowAccessor>();
for (SQLRowAccessor sqlRowAccessor : context) {
totalFacture += getFacture(sqlRowAccessor, facture);
totalCommande += sqlRowAccessor.getLong("T_HT");
}
 
return Tuple2.create(totalCommande, totalFacture);
}
 
public long getFacture(SQLRowAccessor sqlRowAccessor, Set<SQLRowAccessor> alreadyAdded) {
Collection<? extends SQLRowAccessor> rows = sqlRowAccessor.getReferentRows(sqlRowAccessor.getTable().getTable("TR_COMMANDE_CLIENT"));
long l = 0;
for (SQLRowAccessor sqlRowAccessor2 : rows) {
if (!sqlRowAccessor2.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) {
SQLRowAccessor rowFacture = sqlRowAccessor2.getForeign("ID_SAISIE_VENTE_FACTURE");
if (!alreadyAdded.contains(rowFacture)) {
alreadyAdded.add(rowFacture);
l += rowFacture.getLong("T_HT");
}
}
}
return l;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/PartialInvoiceEditGroup.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.sales.account;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class PartialInvoiceEditGroup extends Group {
 
public PartialInvoiceEditGroup() {
super("sales.invoice.partial");
final Group g = new Group("sales.invoice.partial.identifier");
g.addItem("sales.invoice.number");
g.addItem("DATE");
g.addItem("NOM", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
g.addItem("ID_COMMERCIAL");
g.addItem("sales.invoice.partial.amount");
 
this.add(g);
 
final Group gCustomer = new Group("sales.invoice.customer");
gCustomer.addItem("sales.invoice.customer", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
add(gCustomer);
 
final Group gElements = new Group("sales.invoice.partial.items");
gElements.addItem("sales.invoice.partial.items.list", LayoutHints.DEFAULT_LIST_HINTS);
add(gElements);
 
final Group gMdr = new Group("sales.invoice.partial.payment");
gMdr.addItem("ID_MODE_REGLEMENT");
add(gMdr);
 
final Group gTotal = new Group("sales.invoice.partial.total");
gTotal.addItem("sales.invoice.partial.total.amount");
add(gTotal);
 
final Group gInfos = new Group("sales.account.infos");
gInfos.addItem("INFOS", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
add(gInfos);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/VenteFactureSituationSQLComponent.java
New file
0,0 → 1,301
/*
* 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.sales.account;
 
import org.openconcerto.erp.core.common.component.TransfertGroupSQLComponent;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
import org.openconcerto.erp.core.common.ui.Acompte;
import org.openconcerto.erp.core.common.ui.AcompteField;
import org.openconcerto.erp.core.common.ui.AcompteRowItemView;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
import org.openconcerto.erp.core.sales.invoice.ui.FactureSituationItemTable;
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.group.Group;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.Component;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
 
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
 
public class VenteFactureSituationSQLComponent extends TransfertGroupSQLComponent {
public static final String ID = "sales.invoice.partial";
 
public VenteFactureSituationSQLComponent(SQLElement element) {
super(element, new PartialInvoiceEditGroup());
}
 
public VenteFactureSituationSQLComponent(SQLElement element, Group p) {
super(element, p);
}
 
@Override
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<String>(1);
s.add("ID_CLIENT");
s.add("NUMERO");
s.add("DATE");
s.add("MONTANT_FACTURABLE");
s.add("ID_MODE_REGLEMENT");
return s;
}
 
@Override
protected RowValuesTable getRowValuesTable() {
 
return ((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).getRowValuesTable();
}
 
JCheckBox box = new JCheckBox("partial");
 
@Override
protected void addViews() {
 
super.addViews();
 
box.setSelected(true);
this.addView(box, "PARTIAL", REQ);
 
final DeviseField totalHT = (DeviseField) getEditor("T_HT");
final DeviseField totalService = (DeviseField) getEditor("T_SERVICE");
final DeviseField totalSupply = (DeviseField) getEditor("T_HA");
final DeviseField totalDevise = (DeviseField) getEditor("T_DEVISE");
final JTextField totalWeight = (JTextField) getEditor("T_POIDS");
final DeviseField totalTTC = (DeviseField) getEditor("T_TTC");
final DeviseField totalTVA = (DeviseField) getEditor("T_TVA");
final DeviseField totalRemise = (DeviseField) getEditor("REMISE_HT");
final DeviseField totalPORT = (DeviseField) getEditor("PORT_HT");
this.addView(totalPORT, "PORT_HT");
this.addView(totalRemise, "REMISE_HT");
this.addView(totalTVA, "T_TVA");
this.addView(totalTTC, "T_TTC");
this.addView(totalWeight, "T_POIDS");
this.addView(totalDevise, "T_DEVISE");
this.addView(totalSupply, "T_HA");
this.addView(totalService, "T_SERVICE");
this.addView(totalHT, "T_HT");
 
final SQLRequestComboBox sqlRequestComboBox = (SQLRequestComboBox) getEditor("sales.invoice.customer");
sqlRequestComboBox.addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
 
SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
final SQLRow client = sqlRequestComboBox.getSelectedRow();
if (client != null && !client.isUndefined()) {
int idModeRegl = client.getInt("ID_MODE_REGLEMENT");
if (idModeRegl > 1) {
SQLRow rowModeRegl = sqleltModeRegl.getTable().getRow(idModeRegl);
SQLRowValues rowValsModeRegl = rowModeRegl.createUpdateRow();
rowValsModeRegl.clearPrimaryKeys();
((ElementSQLObject) getEditor("ID_MODE_REGLEMENT")).setValue(rowValsModeRegl);
}
}
 
}
});
sqlRequestComboBox.setEnabled(false);
 
final AcompteField acompteField = ((AcompteField) getEditor("sales.invoice.partial.amount"));
final FactureSituationItemTable table = ((FactureSituationItemTable) getEditor("sales.invoice.partial.items.list"));
acompteField.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void update(DocumentEvent e) {
Acompte a = acompteField.getValue();
table.calculPourcentage(a);
}
});
final TotalPanel total = ((TotalPanel) getEditor("sales.invoice.partial.total.amount"));
total.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
acompteField.setTotal(new BigDecimal(total.getTotalHT()).movePointLeft(2));
 
}
});
 
}
 
@Override
public JComponent getLabel(String id) {
if (id.equals("sales.invoice.partial.amount")) {
final JLabel jLabel = new JLabel("Montant à facturer");
jLabel.setHorizontalAlignment(SwingConstants.RIGHT);
return jLabel;
} else if (id.equals("sales.invoice.partial.total.amount")) {
return new JLabel();
} else {
return super.getLabel(id);
}
}
 
JUniqueTextField numberField;
 
@Override
public JComponent createEditor(String id) {
 
if (id.equals("sales.invoice.number")) {
this.numberField = new JUniqueTextField(20);
return this.numberField;
} else if (id.equals("INFOS")) {
final ITextArea jTextArea = new ITextArea();
jTextArea.setFont(new JLabel().getFont());
return jTextArea;
} else if (id.equals("sales.invoice.partial.items.list")) {
return new FactureSituationItemTable();
} else if (id.equals("DATE")) {
return new JDate(true);
} else if (id.equals("T_POIDS")) {
return new JTextField();
} else if (id.equals("sales.invoice.partial.total.amount")) {
final AbstractArticleItemTable items = (AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list");
// Set only VAT Editable
for (int i = 0; i < items.getRowValuesTable().getColumnModel().getColumnCount(false); i++) {
final SQLTableElement sqlTableElementAt = items.getRowValuesTable().getRowValuesTableModel().getSQLTableElementAt(i);
if (sqlTableElementAt.getField() == null || !sqlTableElementAt.getField().getName().equalsIgnoreCase("ID_TAXE")) {
sqlTableElementAt.setEditable(false);
} else {
sqlTableElementAt.setEditable(true);
}
}
 
final DeviseField totalHT = (DeviseField) getEditor("T_HT");
final DeviseField totalService = (DeviseField) getEditor("T_SERVICE");
final DeviseField totalSupply = (DeviseField) getEditor("T_HA");
final DeviseField totalDevise = (DeviseField) getEditor("T_DEVISE");
final JTextField totalWeight = (JTextField) getEditor("T_POIDS");
final DeviseField totalTTC = (DeviseField) getEditor("T_TTC");
final DeviseField totalTVA = (DeviseField) getEditor("T_TVA");
final DeviseField totalRemise = (DeviseField) getEditor("REMISE_HT");
final DeviseField totalPORT = (DeviseField) getEditor("PORT_HT");
 
return new TotalPanel(items, totalHT, totalTVA, totalTTC, totalRemise, totalPORT, totalService, totalSupply, totalDevise, totalWeight, null);
} else if (id.startsWith("T_")) {
return new DeviseField();
} else if (id.equals("REMISE_HT") || id.equals("PORT_HT")) {
return new DeviseField();
} else if (id.equals("sales.invoice.partial.amount")) {
return new AcompteField();
}
return super.createEditor(id);
}
 
private final SQLTable tableNum = getElement().getTable().getTable("NUMEROTATION_AUTO");
 
@Override
public int insert(SQLRow order) {
 
int idSaisieVF = SQLRow.NONEXISTANT_ID;
 
if (this.numberField.checkValidation()) {
 
idSaisieVF = super.insert(order);
SQLRow rowFacture = getTable().getRow(idSaisieVF);
// incrémentation du numéro auto
if (NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, rowFacture.getDate("DATE").getTime()).equalsIgnoreCase(this.numberField.getText().trim())) {
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
 
String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(SaisieVenteFactureSQLElement.class);
int val = this.tableNum.getRow(2).getInt(labelNumberFor);
val++;
rowVals.put(labelNumberFor, Integer.valueOf(val));
try {
rowVals.update(2);
} catch (SQLException e1) {
e1.printStackTrace();
}
 
((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).updateField("ID_SAISIE_VENTE_FACTURE", idSaisieVF);
 
new GenerationMvtSaisieVenteFacture(idSaisieVF);
 
try {
VenteFactureXmlSheet sheet = new VenteFactureXmlSheet(rowFacture);
sheet.createDocument();
sheet.showPrintAndExport(true, false, false);
} catch (Exception e) {
ExceptionHandler.handle("Une erreur est survenue lors de la création du document.", e);
}
 
}
} else {
ExceptionHandler.handle("Impossible d'ajouter, numéro de facture existant.");
Object root = SwingUtilities.getRoot(this);
if (root instanceof EditFrame) {
EditFrame frame = (EditFrame) root;
frame.getPanel().setAlwaysVisible(true);
}
}
return idSaisieVF;
}
 
@Override
public void update() {
 
super.update();
int id = getSelectedID();
((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).updateField("ID_SAISIE_VENTE_FACTURE", id);
 
}
 
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
rowVals.put("PARTIAL", Boolean.TRUE);
return rowVals;
}
 
@Override
public Component addView(JComponent comp, String id) {
if (id.equals("sales.invoice.partial.amount")) {
return super.addView(new AcompteRowItemView((AcompteField) comp), "MONTANT_FACTURABLE,POURCENT_FACTURABLE", REQ);
} else {
return super.addView(comp, id);
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/component/SaisieVenteFactureSQLComponent.java
347,10 → 347,12
c.gridx = 0;
c.gridwidth = 1;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
labelAdresse.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelAdresse, c);
 
c.gridx++;
c.fill = GridBagConstraints.NONE;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
this.add(this.comboAdresse, c);
447,10 → 449,11
c.weightx = 0;
c.weighty = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel("Tarif à appliquer", SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
 
c.fill = GridBagConstraints.NONE;
c.weightx = 1;
this.add(boxTarif, c);
this.addView(boxTarif, "ID_TARIF");
572,6 → 575,7
addRequiredSQLObject(fieldService, "T_SERVICE");
JTextField poids = new JTextField();
addSQLObject(poids, "T_POIDS");
 
totalTTC = new TotalPanel(this.tableFacture, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT, this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null, (getTable().contains(
"ID_TAXE_PORT") ? boxTaxePort : null));
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
767,13 → 771,13
SaisieVenteFactureSQLComponent.this.defaultContactRowValues.put("ID_CLIENT", row.getIDNumber());
if (SaisieVenteFactureSQLComponent.this.client.getTable().contains("ID_TARIF")) {
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
if (foreignRow != null && !foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
&& JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client?") == JOptionPane.YES_OPTION) {
boxTarif.setValue(foreignRow.getID());
// SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
// true);
} else {
boxTarif.setValue(foreignRow.getID());
boxTarif.setValue(foreignRow);
}
 
}
879,7 → 883,7
return commit(order);
}
 
private void createCompteServiceAuto(int id) {
private void createCompteServiceAuto(int id) throws SQLException {
SQLRow rowPole = this.comboCommercial.getSelectedRow();
SQLRow rowVerif = this.comboVerificateur.getSelectedRow();
String verifInitiale = getInitialesFromVerif(rowVerif);
886,15 → 890,26
int idCpt = ComptePCESQLElement.getId("706" + rowPole.getString("CODE") + verifInitiale, "Service " + rowPole.getString("NOM") + " " + rowVerif.getString("NOM"));
SQLRowValues rowVals = this.getTable().getRow(id).createEmptyUpdateRow();
rowVals.put("ID_COMPTE_PCE_SERVICE", idCpt);
try {
rowVals.update();
} catch (SQLException e) {
e.printStackTrace();
}
}
 
@Override
public void select(SQLRowAccessor r) {
 
boolean isPartial = false;
if (r != null && r.getBoolean("PARTIAL") != null) {
isPartial = r.getBoolean("PARTIAL").booleanValue();
}
 
boolean isSolde = false;
if (r != null && r.getBoolean("SOLDE") != null) {
isSolde = r.getBoolean("SOLDE").booleanValue();
}
 
if (r != null && !r.isUndefined() && (isPartial || isSolde)) {
throw new IllegalArgumentException("Impossible de modifier une facturation intermédiaire");
}
 
if (compteSel != null) {
this.compteSel.rmValueListener(this.changeCompteListener);
}
903,8 → 918,31
this.rowSelected = r;
if (r != null) {
this.textNumeroUnique.setIdSelected(r.getID());
if (!r.isUndefined() && r.getObject("ID_MOUVEMENT") != null && !r.isForeignEmpty("ID_MOUVEMENT")) {
SQLSelect sel = new SQLSelect();
SQLTable tableEcr = getTable().getTable("ECRITURE");
SQLTable tableMvt = getTable().getTable("MOUVEMENT");
SQLTable tablePiece = getTable().getTable("PIECE");
sel.addSelect(tableEcr.getKey(), "COUNT");
int idPiece = r.getForeign("ID_MOUVEMENT").getInt("ID_PIECE");
Where w = new Where(tableMvt.getKey(), "=", tableEcr.getField("ID_MOUVEMENT"));
w = w.and(new Where(tablePiece.getKey(), "=", tableMvt.getField("ID_PIECE")));
w = w.and(new Where(tablePiece.getKey(), "=", idPiece));
w = w.and(new Where(tableEcr.getField("POINTEE"), "!=", "").or(new Where(tableEcr.getField("LETTRAGE"), "!=", "")));
sel.setWhere(w);
Object o = Configuration.getInstance().getRoot().getBase().getDataSource().executeScalar(sel.asString());
if (o != null && ((Number) o).longValue() > 0) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
JOptionPane.showMessageDialog(null, "Attention cette facture est pointée ou lettrée en comptabilité. \nToute modification écrasera ces informations comptables.");
}
});
}
 
}
}
super.select(r);
 
if (r != null) {
1013,9 → 1051,7
 
int idMvt = -1;
if (getMode() == Mode.MODIFICATION) {
 
idMvt = rowFacture.getInt("ID_MOUVEMENT");
 
// on supprime tout ce qui est lié à la facture
System.err.println("Archivage des fils");
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE");
1377,11 → 1413,9
}
}
if (getTable().contains("ID_TAXE_PORT")) {
Integer idFromTaux = TaxeCache.getCache().getIdFromTaux(19.6F);
if (idFromTaux != null) {
vals.put("ID_TAXE_PORT", idFromTaux);
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
vals.put("ID_TAXE_PORT", taxeDefault.getID());
}
}
vals.put("ID_COMPTE_PCE_SERVICE", idCompteVenteService);
System.err.println("Defaults " + vals);
return vals;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/SaisieVenteFactureSQLElement.java
20,6 → 20,8
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent;
import org.openconcerto.erp.core.sales.account.VenteFactureSoldeSQLComponent;
import org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent;
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
56,6 → 58,8
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.CollectionMap;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.cc.ITransformer;
import org.openconcerto.utils.i18n.TranslationManager;
 
import java.awt.GridBagConstraints;
101,6 → 105,24
 
public SaisieVenteFactureSQLElement() {
super(TABLENAME, "une facture", "factures");
 
addComponentFactory(VenteFactureSituationSQLComponent.ID, new ITransformer<Tuple2<SQLElement, String>, SQLComponent>() {
 
@Override
public SQLComponent transformChecked(Tuple2<SQLElement, String> input) {
 
return new VenteFactureSituationSQLComponent(SaisieVenteFactureSQLElement.this);
}
});
addComponentFactory(VenteFactureSoldeSQLComponent.ID, new ITransformer<Tuple2<SQLElement, String>, SQLComponent>() {
 
@Override
public SQLComponent transformChecked(Tuple2<SQLElement, String> input) {
 
return new VenteFactureSoldeSQLComponent(SaisieVenteFactureSQLElement.this);
}
});
 
final boolean affact = UserManager.getInstance().getCurrentUser().getRights().haveRight(NXRights.ACCES_RETOUR_AFFACTURAGE.getCode());
List<RowAction> l = new ArrayList<RowAction>(5);
PredicateRowAction actionBL = new PredicateRowAction(new AbstractAction() {
117,7 → 139,7
}, false, "sales.invoice.create.credit");
actionAvoir.setPredicate(IListeEvent.getSingleSelectionPredicate());
l.add(actionAvoir);
PredicateRowAction actionClone = new PredicateRowAction(new AbstractAction() {
RowAction actionClone = new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
 
SQLElement eltFact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
126,8 → 148,17
((SaisieVenteFactureSQLComponent) editFrame.getSQLComponent()).loadFactureExistante(IListe.get(e).getSelectedId());
editFrame.setVisible(true);
}
}, false, "sales.invoice.clone");
actionClone.setPredicate(IListeEvent.getSingleSelectionPredicate());
}, false, "sales.invoice.clone") {
public boolean enabledFor(IListeEvent evt) {
List<SQLRowAccessor> l = evt.getSelectedRows();
if (l != null && l.size() == 1) {
SQLRowAccessor r = l.get(0);
return !r.getBoolean("PARTIAL") && !r.getBoolean("SOLDE");
}
return false;
}
};
 
l.add(actionClone);
getRowActions().addAll(l);
 
140,7 → 171,7
if (edit == null) {
edit = new EditFrame(eltClient, EditMode.READONLY);
}
edit.selectionId(IListe.get(e).getSelectedRow().getInt("ID_CLIENT"));
edit.selectionId(IListe.get(e).fetchSelectedRow().getInt("ID_CLIENT"));
edit.setVisible(true);
}
}, false, "sales.invoice.info.show");
195,6 → 226,8
protected void customizeToFetch(SQLRowValues graphToFetch) {
super.customizeToFetch(graphToFetch);
graphToFetch.put("ACOMPTE", null);
graphToFetch.put("PARTIAL", null);
graphToFetch.put("SOLDE", null);
graphToFetch.put("COMPLEMENT", null);
 
graphToFetch.put("PREVISIONNELLE", null);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/EcheanceClientSQLElement.java
22,6 → 22,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
28,16 → 29,21
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.EmailComposer;
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.GestionDevise;
 
import java.awt.GridBagConstraints;
71,7 → 77,7
@Override
public void actionPerformed(ActionEvent arg0) {
 
SQLRow row = IListe.get(arg0).getSelectedRow();
SQLRow row = IListe.get(arg0).fetchSelectedRow();
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
}
}, false);
85,7 → 91,7
@Override
public void actionPerformed(ActionEvent arg0) {
 
SQLRow row = IListe.get(arg0).getSelectedRow();
SQLRow row = IListe.get(arg0).fetchSelectedRow();
sendMail(row);
}
}, false);
100,7 → 106,7
 
int answer = JOptionPane.showConfirmDialog(null, "Etes vous sûr de vouloir annuler la régularisation ?");
if (answer == JOptionPane.YES_OPTION) {
SQLRow row = IListe.get(e).getSelectedRow();
SQLRow row = IListe.get(e).getSelectedRow().asRow();
SQLRowValues rowVals = row.createEmptyUpdateRow();
rowVals.put("REG_COMPTA", Boolean.FALSE);
try {
128,7 → 134,7
 
public void actionPerformed(ActionEvent e) {
 
SQLRow row = IListe.get(e).getSelectedRow();
SQLRow row = IListe.get(e).fetchSelectedRow();
String price = GestionDevise.currencyToString(row.getLong("MONTANT"));
SQLRow rowClient = row.getForeignRow("ID_CLIENT");
String nomClient = rowClient.getString("NOM");
168,6 → 174,7
 
}
 
 
private void sendMail(SQLRow row) {
 
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
293,6 → 300,7
l.add("DATE");
l.add("MONTANT");
l.add("ID_CLIENT");
l.add("ID_SAISIE_VENTE_FACTURE");
l.add("NOMBRE_RELANCE");
l.add("INFOS");
l.add("DATE_LAST_RELANCE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/ListeDebiteursXmlSheet.java
21,6 → 21,7
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.GestionDevise;
 
63,12 → 64,15
protected void createListeValues() {
 
// On récupére les échéances en cours
SQLSelect sel = new SQLSelect(eltEch.getTable().getBase());
sel.addSelectStar(eltEch.getTable());
Where w = new Where(eltEch.getTable().getField("REGLE"), "=", Boolean.FALSE);
w = w.and(new Where(eltEch.getTable().getField("REG_COMPTA"), "=", Boolean.FALSE));
SQLSelect sel = new SQLSelect();
final SQLTable echTable = eltEch.getTable();
final SQLTable clientTable = echTable.getForeignTable("ID_CLIENT");
sel.addSelectStar(echTable);
Where w = new Where(echTable.getField("REGLE"), "=", Boolean.FALSE);
w = w.and(new Where(echTable.getField("REG_COMPTA"), "=", Boolean.FALSE));
w = w.and(new Where(clientTable.getKey(), "=", echTable.getField("ID_CLIENT")));
sel.setWhere(w);
sel.addFieldOrder(eltEch.getTable().getField("ID_CLIENT"));
sel.addFieldOrder(clientTable.getField("NOM"));
List<SQLRow> l = (List<SQLRow>) eltEch.getTable().getBase().getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
 
List<Map<String, Object>> listValues = new ArrayList<Map<String, Object>>();
77,6 → 81,7
Map<String, Object> mValues = new HashMap<String, Object>();
int idMouvement = MouvementSQLElement.getSourceId(sqlRow.getInt("ID_MOUVEMENT"));
SQLRow rowMvt = eltMvt.getTable().getRow(idMouvement);
mValues.put("DATE_ECHEANCE", dateFormat.format(sqlRow.getDate("DATE").getTime()));
if (rowMvt.getString("SOURCE").equalsIgnoreCase(eltVf.getTable().getName())) {
SQLRow rowVf = eltVf.getTable().getRow(rowMvt.getInt("IDSOURCE"));
mValues.put("NUMERO_FACTURE", rowVf.getString("NUMERO"));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/VenteFactureXmlSheet.java
69,6 → 69,8
type = "Complement";
} else if (row.getBoolean("ACOMPTE")) {
type = "Acompte";
} else if (row.getBoolean("PARTIAL") || row.getBoolean("SOLDE")) {
type = "Situation";
} else {
type = null;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/EtatVenteAction.java
28,7 → 28,10
}
 
public JFrame createFrame() {
return new PanelFrame(new EtatVentesPanel(), "Etat des ventes");
final PanelFrame panelFrame = new PanelFrame(new EtatVentesPanel(), "Etat des ventes");
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/GenListeVenteAction.java
20,16 → 20,15
import javax.swing.Action;
import javax.swing.JFrame;
 
 
public class GenListeVenteAction extends CreateFrameAbstractAction {
public GenListeVenteAction() {
super();
this.putValue(Action.NAME, "Journal des ventes");
}
 
public JFrame createFrame() {
 
return new PanelFrame(new GenListeVentePanel(), "Journal des ventes");
 
final PanelFrame panelFrame = new PanelFrame(new GenListeVentePanel(), "Journal des ventes");
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListPanelEcheancesClients.java
77,7 → 77,7
this.editFrame.pack();
this.editFrame.setVisible(true);
 
SQLRow ecritureRow = new EcritureSQLElement().getTable().getRow(this.getListe().getSelectedId());
SQLRow ecritureRow = Configuration.getInstance().getDirectory().getElement(EcritureSQLElement.class).getTable().getRow(this.getListe().getSelectedId());
 
MouvementSQLElement.showSource(ecritureRow.getInt("ID_MOUVEMENT"));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListEcheanceClientRenderer.java
28,6 → 28,7
import java.util.Locale;
 
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
 
public class ListEcheanceClientRenderer extends DefaultTableCellRenderer {
74,6 → 75,7
&& (value.getClass() == Long.class || value.getClass() == BigInteger.class)) {
 
this.setText(GestionDevise.currencyToString(((Long) value).longValue()));
this.setHorizontalAlignment(SwingConstants.RIGHT);
}
 
final ListSQLLine line = ITableModel.getLine(table.getModel(), row);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListeDesEcheancesClientsPanel.java
233,7 → 233,7
// Mise à jour de l'echeance sur la frame de reglement
// si cette derniere est cree
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLRow row = panelEcheances.getListe().getSelectedRow();
final SQLRow row = panelEcheances.getListe().getSelectedRow().asRow();
if (mE.getButton() == MouseEvent.BUTTON1) {
 
if (ListeDesEcheancesClientsPanel.this.editEncaisse != null) {
284,7 → 284,7
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
SQLElement relanceElt = Configuration.getInstance().getDirectory().getElement("RELANCE");
 
this.rowSource = this.panelEcheances.getListe().getSelectedRow();
this.rowSource = this.panelEcheances.getListe().fetchSelectedRow();
 
if (this.rowSource != null) {
int idMvtSource = MouvementSQLElement.getSourceId(rowSource.getInt("ID_MOUVEMENT"));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/FactureSituationItemTable.java
New file
0,0 → 1,51
/*
* 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.sales.invoice.ui;
 
import java.util.HashMap;
import java.util.Map;
 
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
 
public class FactureSituationItemTable extends AbstractVenteArticleItemTable {
 
public FactureSituationItemTable() {
super();
this.control.setVisible(false);
}
 
@Override
protected String getConfigurationFileName() {
return "Table_Facture_Situation.xml";
}
 
@Override
public SQLElement getSQLElement() {
return Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
}
 
protected Map<String, Boolean> getCustomVisibilityMap() {
Map<String, Boolean> map = new HashMap<String, Boolean>();
map.put("CODE", Boolean.FALSE);
map.put("POURCENT_FACTURABLE", Boolean.TRUE);
map.put("CODE_DOUANIER", Boolean.FALSE);
map.put("ID_PAYS", Boolean.FALSE);
map.put("T_DEVISE", Boolean.FALSE);
map.put("P_HA", Boolean.FALSE);
 
return map;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListeDesVentesPanel.java
24,6 → 24,7
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.EditFrame;
86,11 → 87,15
 
JTabbedPane tabbedPane = new JTabbedPane();
 
final SQLElement elementVF = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
// tab Vente facture
final SQLElement eltFacture = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
final SQLElement eltFacture = elementVF;
final SQLTableModelSourceOnline src = eltFacture.getTableSource(true);
// Filter
final Where wPrev = new Where(eltFacture.getTable().getField("PREVISIONNELLE"), "=", Boolean.FALSE);
Where wPrev = new Where(eltFacture.getTable().getField("PREVISIONNELLE"), "=", Boolean.FALSE);
if (src.getReq().getWhere() != null) {
wPrev = wPrev.and(src.getReq().getWhere());
}
src.getReq().setWhere(wPrev);
 
final ListeFactureRenderer rend = new ListeFactureRenderer();
189,8 → 194,15
public void selectionId(int id, int field) {
ListeDesVentesPanel.this.buttonEnvoye.setEnabled(id > 1);
ListeDesVentesPanel.this.buttonRegle.setEnabled(id > 1);
ListeDesVentesPanel.this.buttonDupliquer.setEnabled(id > 1);
if (id > 1) {
final ITableModel model = ListeDesVentesPanel.this.listeFact.getListe().getModel();
 
SQLRowAccessor r = model.getRow(model.indexFromID(id)).getRow();
ListeDesVentesPanel.this.buttonDupliquer.setEnabled(!r.getBoolean("PARTIAL") && !r.getBoolean("SOLDE"));
} else {
ListeDesVentesPanel.this.buttonDupliquer.setEnabled(false);
}
}
});
 
 
200,7 → 212,7
@Override
protected void handleAction(JButton source, ActionEvent evt) {
if (source == this.buttonModifier) {
new PanelFrame(new TextAreaTicketPanel(this.getListe().getSelectedRow()), "Ticket").setVisible(true);
new PanelFrame(new TextAreaTicketPanel(this.getListe().fetchSelectedRow()), "Ticket").setVisible(true);
} else {
super.handleAction(source, evt);
}
282,7 → 294,7
 
public void actionPerformed(ActionEvent e) {
 
final SQLRow selectedRow = this.listeFact.getListe().getSelectedRow();
final SQLRow selectedRow = this.listeFact.getListe().getSelectedRow().asRow();
if (e.getSource() == this.buttonEnvoye) {
SQLRowValues rowVals = selectedRow.createEmptyUpdateRow();
rowVals.put("DATE_ENVOI", new Date());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListeFactureRenderer.java
13,6 → 13,7
package org.openconcerto.erp.core.sales.invoice.ui;
 
import org.openconcerto.erp.core.finance.payment.component.ModeDeReglementSQLComponent;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
102,8 → 103,8
int ajours = (foreignRow.getObject("AJOURS") == null) ? 0 : foreignRow.getInt("AJOURS");
int njour = (foreignRow.getObject("LENJOUR") == null) ? 0 : foreignRow.getInt("LENJOUR");
 
if (ajours == 0 && njour == 0) {
if (foreignRow.getObject("COMPTANT") != null && !foreignRow.getBoolean("COMPTANT")) {
if (ajours == 0 && njour == ModeDeReglementSQLComponent.AT_INVOICE_DATE) {
if (foreignRow.getBoolean("COMPTANT") == Boolean.FALSE) {
label.setText("Date de facture");
} else {
label.setText("Comptant");
113,15 → 114,13
if (ajours != 0) {
s.append(ajours + ((ajours > 1) ? " jours" : " jour"));
}
if (njour > 0 && njour < 31) {
s.append(" le " + njour);
} else {
if (njour == 0) {
if (njour == ModeDeReglementSQLComponent.AT_INVOICE_DATE) {
s.append(" date de facture");
} else if (njour == ModeDeReglementSQLComponent.MONTH_END) {
s.append(" fin de mois");
} else {
s.append(" fin de mois");
s.append(" le " + njour);
}
}
label.setText(s.toString());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/EtatVentesPanel.java
20,6 → 20,7
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.Tuple2;
 
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
26,7 → 27,6
import java.awt.event.ActionListener;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.ExecutionException;
 
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
46,7 → 46,7
super(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.CENTER;
c.anchor = GridBagConstraints.EAST;
this.add(new JLabelBold("Etat des Ventes"), c);
 
c.gridwidth = 1;
56,8 → 56,9
// Période pédéfini
final Map<String, Tuple2<Date, Date>> map = IListFilterDatePanel.getDefaultMap();
if (map != null && map.keySet().size() > 0) {
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement("Tous");
final JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 1));
final DefaultComboBoxModel model = new DefaultComboBoxModel();
for (String s : map.keySet()) {
model.addElement(s);
}
64,8 → 65,12
 
final JComboBox combo = new JComboBox(model);
c.weightx = 0;
this.add(combo, c);
 
c.gridwidth = 4;
p.add(new JLabel("Période "));
p.add(combo);
c.fill = GridBagConstraints.NONE;
this.add(p, c);
c.gridy++;
combo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
74,19 → 79,23
}
});
}
c.gridwidth = 1;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel("Du"), c);
 
c.gridx++;
this.add(new JLabel("du"), c);
 
c.gridx++;
this.du = new JDate(true);
c.weightx = 1;
this.du = new JDate(false);
this.add(this.du, c);
 
c.gridx++;
c.weightx = 0;
this.add(new JLabel("au"), c);
 
c.gridx++;
this.au = new JDate(true);
c.weightx = 1;
this.au = new JDate(false);
this.add(this.au, c);
 
c.gridy++;
97,8 → 106,8
panelButton.add(this.buttonClose);
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
c.weightx = 0;
c.anchor = GridBagConstraints.SOUTHEAST;
c.weightx = 1;
this.add(panelButton, c);
this.buttonGen.addActionListener(this);
this.buttonClose.addActionListener(this);
108,25 → 117,27
if (t == null) {
setPeriode(null, null);
} else {
 
setPeriode(t.get0(), t.get1());
}
}
 
public void setDateDu(Date d) {
if (d != null) {
d.setHours(0);
d.setMinutes(0);
}
this.du.setValue(d);
}
 
public void setDateAu(Date d) {
if (d != null) {
d.setHours(23);
d.setMinutes(59);
}
this.au.setValue(d);
}
 
private void setPeriode(Date du, Date au) {
 
setDateAu(au);
setDateDu(du);
}
134,8 → 145,9
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.buttonGen) {
 
EtatVentesXmlSheet sheet = new EtatVentesXmlSheet(this.du.getDate(), this.au.getDate());
final Date start = this.du.getDate();
final Date stop = this.au.getDate();
final EtatVentesXmlSheet sheet = new EtatVentesXmlSheet(start, stop);
try {
// FIXME probleme de rendu avec le viewer
sheet.createDocumentAsynchronous().get();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/element/DevisSQLElement.java
18,7 → 18,6
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent;
import org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent;
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
import org.openconcerto.erp.core.sales.quote.component.DevisSQLComponent;
import org.openconcerto.erp.core.sales.quote.report.DevisXmlSheet;
30,8 → 29,12
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.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
38,6 → 41,8
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.utils.CollectionMap;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.event.ActionEvent;
import java.math.BigDecimal;
51,6 → 56,8
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
 
public class DevisSQLElement extends ComptaSQLConfElement {
 
116,7 → 123,7
private EditFrame editFrame;
 
public void actionPerformed(ActionEvent e) {
SQLRow selectedRow = IListe.get(e).getSelectedRow();
SQLRowAccessor selectedRow = IListe.get(e).getSelectedRow();
 
if (this.editFrame == null) {
SQLElement eltFact = Configuration.getInstance().getDirectory().getElement("DEVIS");
136,7 → 143,7
public RowAction getRefuseAction() {
return new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
SQLRowValues rowVals = IListe.get(e).getSelectedRow().createEmptyUpdateRow();
SQLRowValues rowVals = IListe.get(e).getSelectedRow().asRow().createEmptyUpdateRow();
rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.REFUSE);
try {
rowVals.update();
144,7 → 151,6
// TODO Auto-generated catch block
e1.printStackTrace();
}
IListe.get(e).getSelectedRow().getTable().fireTableModified(IListe.get(e).getSelectedId());
}
}, false, "sales.quote.refuse") {
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowAccessor> selection) {
161,7 → 167,7
public RowAction getAcceptAction() {
return new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
SQLRow selectedRow = IListe.get(e).getSelectedRow();
SQLRow selectedRow = IListe.get(e).getSelectedRow().asRow();
SQLRowValues rowVals = selectedRow.createEmptyUpdateRow();
rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.ACCEPTE);
try {
170,7 → 176,6
// TODO Auto-generated catch block
e1.printStackTrace();
}
selectedRow.getTable().fireTableModified(IListe.get(e).getSelectedId());
}
}, false, "sales.quote.accept") {
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowAccessor> selection) {
204,7 → 209,7
public RowAction getDevis2CmdFournAction() {
return new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
final SQLRow selectedRow = IListe.get(e).getSelectedRow();
final SQLRow selectedRow = IListe.get(e).fetchSelectedRow();
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
@Override
230,8 → 235,11
public RowAction getDevis2CmdCliAction() {
return new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
TransfertBaseSQLComponent.openTransfertFrame(IListe.get(e).copySelectedRows(), "COMMANDE_CLIENT");
 
final List<SQLRowValues> copySelectedRows = IListe.get(e).copySelectedRows();
transfertCommandeClient(copySelectedRows);
}
 
}, true, "sales.quote.create.customer.order") {
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowAccessor> selection) {
if (selection != null && selection.size() == 1) {
247,18 → 255,16
public RowAction getAcceptAndCmdClientAction() {
return new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
SQLRow selectedRow = IListe.get(e).getSelectedRow();
SQLRow selectedRow = IListe.get(e).fetchSelectedRow();
SQLRowValues rowVals = selectedRow.createEmptyUpdateRow();
rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.ACCEPTE);
try {
rowVals.update();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
ExceptionHandler.handle("Erreur la de la mise à jour de l'état du devis!", e1);
 
}
selectedRow.getTable().fireTableModified(IListe.get(e).getSelectedId());
DevisSQLElement elt = (DevisSQLElement) Configuration.getInstance().getDirectory().getElement("DEVIS");
elt.transfertCommandeClient(selectedRow.getID());
transfertCommandeClient(IListe.get(e).copySelectedRows());
}
}, false, "sales.quote.accept.create.customer.order") {
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowAccessor> selection) {
272,6 → 278,79
};
}
 
private void transfertCommandeClient(final List<SQLRowValues> copySelectedRows) {
 
SwingWorker<Boolean, Object> worker = new SwingWorker<Boolean, Object>() {
@Override
protected Boolean doInBackground() throws Exception {
 
final SQLTable tableTransfert = getTable().getTable("TR_DEVIS");
SQLRowValues rowVals = new SQLRowValues(tableTransfert);
rowVals.put("ID_DEVIS", new SQLRowValues(getTable()).put("NUMERO", null));
rowVals.put("ID_COMMANDE", null);
rowVals.put("ID", null);
 
final List<Number> lID = new ArrayList<Number>();
for (SQLRowValues sqlRowValues : copySelectedRows) {
lID.add(sqlRowValues.getID());
}
 
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
fetch.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
Where w = new Where(tableTransfert.getField("ID_DEVIS"), lID);
w = w.and(new Where(tableTransfert.getField("ID_COMMANDE_CLIENT"), "IS NOT", (Object) null));
input.setWhere(w);
return input;
}
});
 
List<SQLRowValues> rows = fetch.fetch();
if (rows != null && rows.size() > 0) {
String numero = "";
 
for (SQLRowValues sqlRow : rows) {
numero += sqlRow.getForeign("ID_DEVIS").getString("NUMERO") + " ,";
}
 
numero = numero.substring(0, numero.length() - 2);
String label = "Attention ";
if (rows.size() > 1) {
label += " les devis " + numero + " ont déjà été transféré en commande!";
} else {
label += " le devis " + numero + " a déjà été transféré en commande!";
}
label += "\n Voulez vous continuer?";
 
int ans = JOptionPane.showConfirmDialog(null, label, "Transfert devis en commande", JOptionPane.YES_NO_OPTION);
if (ans == JOptionPane.NO_OPTION) {
return Boolean.FALSE;
}
 
}
return Boolean.TRUE;
 
}
 
@Override
protected void done() {
 
try {
Boolean b = get();
if (b != null && b) {
TransfertBaseSQLComponent.openTransfertFrame(copySelectedRows, "COMMANDE_CLIENT");
}
} catch (Exception e) {
ExceptionHandler.handle("Erreur lors du transfert des devis en commande!", e);
}
super.done();
}
};
worker.execute();
}
 
protected List<String> getComboFields() {
List<String> l = new ArrayList<String>();
l.add("NUMERO");
386,48 → 465,4
editFactureFrame.setVisible(true);
}
 
// /**
// * Transfert d'un devis en commande
// *
// * @param devisID
// * @deprecated
// */
// public void transfertCommande(int devisID) {
//
// SQLElement elt = Configuration.getInstance().getDirectory().getElement("COMMANDE");
// EditFrame editFactureFrame = new EditFrame(elt);
// editFactureFrame.setIconImage(new
// ImageIcon(Gestion.class.getResource("frameicon.png")).getImage());
//
// CommandeSQLComponent comp = (CommandeSQLComponent) editFactureFrame.getSQLComponent();
//
// comp.setDefaults();
// comp.loadDevis(devisID);
//
// editFactureFrame.pack();
// editFactureFrame.setState(JFrame.NORMAL);
// editFactureFrame.setVisible(true);
// }
 
/**
* Transfert d'un devis en commande
*
* @param devisID
*/
public void transfertCommandeClient(int devisID) {
 
SQLElement elt = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
EditFrame editFactureFrame = new EditFrame(elt);
editFactureFrame.setIconImage(new ImageIcon(Gestion.class.getResource("frameicon.png")).getImage());
 
CommandeClientSQLComponent comp = (CommandeClientSQLComponent) editFactureFrame.getSQLComponent();
 
comp.setDefaults();
comp.loadDevis(devisID);
 
editFactureFrame.pack();
editFactureFrame.setState(JFrame.NORMAL);
editFactureFrame.setVisible(true);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/action/ListeDesDevisAction.java
94,7 → 94,7
int selectedId = this.frame.getPanel().getListe().getSelectedId();
if (selectedId > 1 && e.getButton() == MouseEvent.BUTTON3) {
 
final SQLRow row = this.frame.getPanel().getListe().getSelectedRow();
final SQLRow row = this.frame.getPanel().getListe().fetchSelectedRow();
JPopupMenu menu = new JPopupMenu();
final DevisTextSheet s = new DevisTextSheet(row);
 
145,7 → 145,7
 
AbstractAction actionAcc = new AbstractAction("Marquer comme accepté") {
public void actionPerformed(ActionEvent e) {
SQLRowValues rowVals = IListe.get(e).getSelectedRow().createEmptyUpdateRow();
SQLRowValues rowVals = IListe.get(e).fetchSelectedRow().createEmptyUpdateRow();
rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.ACCEPTE);
try {
rowVals.update();
153,7 → 153,7
// TODO Auto-generated catch block
e1.printStackTrace();
}
IListe.get(e).getSelectedRow().getTable().fireTableModified(IListe.get(e).getSelectedId());
IListe.get(e).fetchSelectedRow().getTable().fireTableModified(IListe.get(e).getSelectedId());
}
};
menu.add(actionAcc);
160,7 → 160,7
 
AbstractAction actionRefus = new AbstractAction("Marquer comme refusé") {
public void actionPerformed(ActionEvent e) {
SQLRowValues rowVals = IListe.get(e).getSelectedRow().createEmptyUpdateRow();
SQLRowValues rowVals = IListe.get(e).fetchSelectedRow().createEmptyUpdateRow();
rowVals.put("ID_ETAT_DEVIS", EtatDevisSQLElement.REFUSE);
try {
rowVals.update();
168,7 → 168,7
// TODO Auto-generated catch block
e1.printStackTrace();
}
IListe.get(e).getSelectedRow().getTable().fireTableModified(IListe.get(e).getSelectedId());
IListe.get(e).fetchSelectedRow().getTable().fireTableModified(IListe.get(e).getSelectedId());
}
};
menu.add(actionRefus);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/ListeDesArticlesAction.java
77,16 → 77,14
// DeviseNiceTableCellRenderer());
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(this.sqlTableArticle);
final SQLTableModelSourceOnline createTableSource = elt.createTableSource(getWhere(panelFam));
createTableSource.getColumns().add(new BaseSQLTableModelColumn("Valeur HT du stock", Double.class) {
createTableSource.getColumns().add(new BaseSQLTableModelColumn("Valeur HT du stock", BigDecimal.class) {
 
Double zero = new Double(0D);
 
@Override
protected Object show_(SQLRowAccessor r) {
 
SQLRowAccessor stock = r.getForeign("ID_STOCK");
if (stock == null || stock.isUndefined()) {
return zero;
return BigDecimal.ZERO;
} else {
float qte = stock.getFloat("QTE_REEL");
BigDecimal ha = r.getBigDecimal("PA_HT");
104,8 → 102,7
public Set<FieldPath> getPaths() {
final SQLTable table = elt.getTable();
Path p = new Path(table);
Path p2 = new Path(table);
p2.add(table.getField("ID_STOCK"));
Path p2 = new Path(table).addForeignField("ID_STOCK");
return CollectionUtils.createSet(new FieldPath(p, "PA_HT"), new FieldPath(p2, "QTE_REEL"));
}
});
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/ProductGoupSQLComponent.java
New file
0,0 → 1,27
/*
* 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.sales.product.ui;
 
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.ui.group.Group;
 
public class ProductGoupSQLComponent extends GroupSQLComponent {
 
public ProductGoupSQLComponent(SQLElement element) {
super(element, new ProductEditGroup());
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/ArticleTarifTable.java
13,7 → 13,6
package org.openconcerto.erp.core.sales.product.ui;
 
import org.openconcerto.erp.core.common.ui.DeviseNumericCellEditor;
import org.openconcerto.erp.core.common.ui.DeviseNumericHTConvertorCellEditor;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.sales.product.component.ReferenceArticleSQLComponent;
21,6 → 20,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
29,7 → 29,6
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.RowValuesTablePanel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.utils.ExceptionHandler;
 
import java.math.BigDecimal;
import java.math.MathContext;
160,16 → 159,10
Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
 
if (resultTaux == null) {
 
Integer i = TaxeCache.getCache().getFirstTaxe();
if (i == null) {
ExceptionHandler.handle("Aucune taxe définie!");
System.err.println("Aucune Taxe");
} else {
rowValuesArticleCompile.put("ID_TAXE", i);
resultTaux = TaxeCache.getCache().getTauxFromId(i.intValue());
final SQLRow i = TaxeCache.getCache().getFirstTaxe();
rowValuesArticleCompile.put("ID_TAXE", i.getID());
resultTaux = i.getFloat("TAUX");
}
}
 
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
editorPVHT.setTaxe(taux);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/ProductEditGroup.java
New file
0,0 → 1,92
/*
* 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.sales.product.ui;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class ProductEditGroup extends Group {
 
public ProductEditGroup() {
super("sales.product");
final Group g = new Group("sales.quote.identifier");
g.addItem("sales.product.code");
g.addItem("sales.product.family");
g.addItem("sales.product.label", LayoutHints.DEFAULT_VERY_LARGE_FIELD_HINTS);
g.addItem("sales.product.barcode");
 
this.add(g);
 
final Group gSales = new Group("sales.product.sales");
gSales.addItem("sales.product.sales.price");
gSales.addItem("sales.product.tax");
gSales.addItem("sales.product.sales.price.total");
gSales.addItem("sales.product.sales.unit");
 
gSales.addItem("sales.product.margin.min", LayoutHints.DEFAULT_VERY_LARGE_FIELD_HINTS);
gSales.addItem("sales.product.sales.shipment", LayoutHints.DEFAULT_VERY_LARGE_FIELD_HINTS);
gSales.addItem("sales.product.pricelist.items", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
add(gSales);
 
final Group gPurchase = new Group("sales.product.purchase");
// gPurchase.addItem("sales.product.purchase.unit");
gPurchase.addItem("sales.product.purchase.price");
gPurchase.addItem("sales.product.purchase.frombom");
gPurchase.addItem("sales.product.supplier");
gPurchase.addItem("sales.product.purchase.quantity");
gPurchase.addItem("sales.product.purchase.shipment");
 
add(gPurchase);
 
final Group gInventory = new Group("sales.product.inventory");
gInventory.addItem("sales.product.stockable", LayoutHints.DEFAULT_VERY_LARGE_FIELD_HINTS);
gInventory.addItem("sales.product.quantity.min");
gInventory.addItem("sales.product.quantity.max");
add(gInventory);
 
final Group gDesc = new Group("sales.product.description");
gDesc.addItem("sales.product.description.text", new LayoutHints(true, true, true, true, true, true, true, true));
add(gDesc);
 
final Group gInternationalization = new Group("sales.product.i18n");
gInternationalization.addItem("sales.product.i18n.items", new LayoutHints(true, true, true, true, true, true, true, true));
add(gInternationalization);
final Group gAccounting = new Group("sales.product.accounting");
gAccounting.addItem("sales.product.sales.account", LayoutHints.DEFAULT_VERY_LARGE_FIELD_HINTS);
gAccounting.addItem("sales.product.purchase.account", LayoutHints.DEFAULT_VERY_LARGE_FIELD_HINTS);
gAccounting.addItem("sales.product.service");
add(gAccounting);
 
final Group gBom = new Group("sales.product.bom");
gBom.addItem("sales.product.bom.merge");
gBom.addItem("sales.product.bom.items", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
add(gBom);
 
final Group gInfo = new Group("sales.product.information");
gInfo.addItem("sales.product.deprecated");
gInfo.addItem("sales.product.needserial");
 
final Group gDimension = new Group("sales.product.dimension", LayoutHints.DEFAULT_NOLABEL_SEPARATED_GROUP_HINTS);
gDimension.addItem("sales.product.length");
gDimension.addItem("sales.product.width");
gDimension.addItem("sales.product.weight");
final Group gExport = new Group("sales.product.info.export", LayoutHints.DEFAULT_NOLABEL_SEPARATED_GROUP_HINTS);
gExport.addItem("sales.product.customs.code");
gInfo.add(gDimension);
gInfo.add(gExport);
gInfo.addItem("sales.product.comment", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
add(gInfo);
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/component/ReferenceArticleSQLComponent.java
45,6 → 45,7
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
301,9 → 302,12
this.add(new JLabel(getLabelFor("ID_UNITE_VENTE"), SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
ElementComboBox boxUnite = new ElementComboBox();
DefaultGridBagConstraints.lockMinimumSize(boxUnite);
this.add(boxUnite, c);
this.addView(boxUnite, "ID_UNITE_VENTE");
c.fill = GridBagConstraints.HORIZONTAL;
}
DefaultProps props = DefaultNXProps.getInstance();
 
780,11 → 784,16
}
 
protected void getMontantPanel(final GridBagConstraints c, DefaultProps props) {
 
c.gridx = 0;
c.gridy++;
c.gridwidth = 1;
// PA devise
JPanel pDevise = new JPanel(new GridBagLayout());
GridBagConstraints cDevise = new DefaultGridBagConstraints();
pDevise.add(new JLabel("Devise du fournisseur"), cDevise);
cDevise.insets = new Insets(0, 0, 0, 4);
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel("Devise du fournisseur"), c);
final ElementComboBox boxDevise = new ElementComboBox(true, 15);
cDevise.gridx++;
cDevise.weightx = 1;
802,8 → 811,7
this.addView(fieldHAD, "PA_DEVISE");
DefaultGridBagConstraints.lockMinimumSize(fieldHAD);
 
c.gridx = 0;
c.gridy++;
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.WEST;
c.weightx = 1;
831,7 → 839,13
// PA
JPanel p = new JPanel(new GridBagLayout());
GridBagConstraints cAchat = new DefaultGridBagConstraints();
p.add(new JLabel(getLabelFor("PA_HT")), cAchat);
cAchat.insets = new Insets(0, 0, 0, 4);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel(getLabelFor("PA_HT"), SwingConstants.RIGHT), c);
cAchat.gridx++;
cAchat.weightx = 1;
p.add(this.textPAHT, cAchat);
869,8 → 883,7
p.add(this.boxService, cAchat);
}
 
c.gridx = 0;
c.gridy++;
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.WEST;
c.weightx = 1;
879,11 → 892,20
this.add(p, c);
 
// PV HT
c.gridx = 0;
c.gridy++;
 
JPanel p2 = new JPanel(new GridBagLayout());
GridBagConstraints cVT = new DefaultGridBagConstraints();
p2.add(new JLabel(getLabelFor("PV_HT")), cVT);
cVT.insets = new Insets(0, 0, 0, 4);
 
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
this.add(new JLabel(getLabelFor("PV_HT"), SwingConstants.RIGHT), c);
cVT.gridx++;
cVT.weightx = 1;
 
p2.add(this.textPVHT, cVT);
 
// Taxe
904,8 → 926,8
cVT.gridx++;
cVT.weightx = 1;
p2.add(this.textPVTTC, cVT);
c.gridx = 0;
c.gridy++;
c.gridx = 1;
 
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.WEST;
c.weightx = 1;
917,6 → 939,7
DefaultGridBagConstraints.lockMinimumSize(this.textPVHT);
this.addRequiredSQLObject(this.comboSelTaxe, "ID_TAXE");
DefaultGridBagConstraints.lockMinimumSize(this.comboSelTaxe);
DefaultGridBagConstraints.lockMaximumSize(this.comboSelTaxe);
this.addRequiredSQLObject(this.textPVTTC, "PV_TTC");
DefaultGridBagConstraints.lockMinimumSize(this.textPVTTC);
DefaultGridBagConstraints.lockMinimumSize(this.textPAHT);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/Caisse.java
25,6 → 25,7
import org.openconcerto.erp.core.sales.pos.io.TicketPrinter;
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.Paiement;
import org.openconcerto.erp.core.sales.pos.model.ReceiptCode;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.erp.core.sales.pos.model.TicketLine;
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
52,6 → 53,7
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
154,6 → 156,7
SQLElement eltEnc = Configuration.getInstance().getDirectory().getElement("ENCAISSER_MONTANT");
SQLElement eltMode = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
SQLElement eltArticle = Configuration.getInstance().getDirectory().getElement("ARTICLE");
int imported = 0;
for (Ticket ticket : tickets) {
SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
sel.addSelect(elt.getTable().getField("NUMERO"));
233,6 → 236,7
}
 
SQLRow rowFinal = rowVals.insert();
imported++;
GenerationMvtTicketCaisse mvt = new GenerationMvtTicketCaisse(rowFinal);
final Integer idMvt;
try {
270,11 → 274,30
 
}
}
// mark imported
for (Ticket ticket : tickets) {
final ReceiptCode code = ticket.getReceiptCode();
try {
// it's OK if some files cannot be moved, the next call will try again
// (the above code doesn't import duplicates)
code.markImported();
} catch (IOException e) {
e.printStackTrace();
}
}
// archive to avoid parsing more and more receipts
try {
// it's OK if some files cannot be moved, the next call will try again
ReceiptCode.archiveCompletelyImported();
} catch (IOException e) {
e.printStackTrace();
}
final String count = imported + "/" + tickets.size();
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
JOptionPane.showMessageDialog(null, "Clôture de la caisse terminée.");
JOptionPane.showMessageDialog(null, count + " ticket(s) importé(s). Clôture de la caisse terminée.");
}
});
return null;
351,17 → 374,8
 
public static List<Ticket> allTickets() {
final List<Ticket> l = new ArrayList<Ticket>();
final Ticket t = new Ticket(Caisse.getID());
final String[] names = t.getCompatibleFileNames();
 
for (int i = 0; i < names.length; i++) {
String code = names[i];
int indexExtension = code.indexOf(".xml");
if (indexExtension > 0) {
code = code.substring(0, indexExtension);
}
final Ticket ticket = Ticket.getTicketFromCode(code);
 
for (final File f : ReceiptCode.getReceiptsToImport(Caisse.getID())) {
final Ticket ticket = Ticket.parseFile(f);
if (ticket != null) {
l.add(ticket);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/CaisseLauncher.java
New file
0,0 → 1,42
/*
* 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.sales.pos;
 
import org.openconcerto.erp.config.GestionLauncher;
import org.openconcerto.erp.core.sales.pos.ui.CaisseFrame;
 
import java.io.IOException;
import java.util.Arrays;
 
public class CaisseLauncher extends GestionLauncher {
/**
* Launch Caisse.
*
* @param args the one-time arguments.
* @throws IOException if the launch failed.
*/
public static void main(String[] args) throws IOException {
new CaisseLauncher().launch(CaisseFrame.class.getName(), Arrays.asList(args));
}
 
@Override
protected int getInitialMemory() {
return 64;
}
 
@Override
protected int getMaxMemory() {
return 512;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/element/SaisieVenteComptoirSQLElement.java
17,6 → 17,7
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteComptoir;
import org.openconcerto.erp.model.PrixTTC;
34,7 → 35,7
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.ISQLElementWithCodeSelector;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.TitledSeparator;
65,8 → 66,10
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.JCheckBox;
import javax.swing.JLabel;
90,6 → 93,7
l.add("DATE");
l.add("NOM");
l.add("ID_CLIENT");
l.add("ID_MODE_REGLEMENT");
l.add("MONTANT_HT");
l.add("MONTANT_TTC");
return l;
115,8 → 119,8
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
private SQLTextCombo textNom;
private final JCheckBox checkService = new JCheckBox("dont ");
private SQLSearchableTextCombo textNom;
private DeviseField textMontantTTC;
private DeviseField textMontantService;
private ElementComboBox comboFournisseur;
142,7 → 146,7
 
public void propertyChange(PropertyChangeEvent evt) {
 
if ((nomArticle.getValidState().isValid()) && (!nomArticle.isEmpty())) {
if ((nomArticle.getValidState().isValid()) && (!nomArticle.isEmpty()) && !isFilling()) {
int idArticle = nomArticle.getValue().intValue();
 
SQLTable tableArticle = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("ARTICLE");
195,7 → 199,7
c.weightx = 0;
this.add(labelNom, c);
 
this.textNom = new SQLTextCombo();
this.textNom = new SQLSearchableTextCombo();
c.gridx++;
c.weightx = 1;
c.gridwidth = 2;
206,7 → 210,9
 
this.dateSaisie = new JDate(true);
c.gridwidth = 1;
c.gridx += 2;
// c.gridx += 2;
c.gridx = 0;
c.gridy++;
c.weightx = 0;
labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelDate, c);
225,12 → 231,12
JLabel labelNomArticle = new JLabel(getLabelFor("ID_ARTICLE"));
c.weightx = 0;
labelNomArticle.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelNomArticle, c);
// this.add(labelNomArticle, c);
 
c.gridx++;
c.weightx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(this.nomArticle, c);
// this.add(this.nomArticle, c);
 
this.nomArticle.addValueListener(this.propertyChangeListener);
 
270,12 → 276,12
c.gridwidth = 1;
c.weightx = 0;
labelAvoirClient.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelAvoirClient, c);
// this.add(labelAvoirClient, c);
 
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 0;
this.add(this.comboAvoir, c);
// this.add(this.comboAvoir, c);
 
/***********************************************************************************
* * MONTANT
291,53 → 297,34
 
c.gridwidth = 1;
 
// Montant TTC
JLabel labelMontantTTC = new JLabel(getLabelFor("MONTANT_TTC"));
c.gridy++;
c.gridx = 0;
c.weightx = 0;
final JLabel labelMontantHT = new JLabel(getLabelFor("MONTANT_HT"));
labelMontantHT.setHorizontalAlignment(SwingConstants.RIGHT);
this.textMontantHT = new DeviseField();
this.textMontantHT.setEditable(false);
this.textMontantHT.setEnabled(false);
this.textMontantHT.setFocusable(false);
 
final JLabel labelMontantTTC = new JLabel(getLabelFor("MONTANT_TTC"));
labelMontantTTC.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelMontantTTC, c);
 
this.textMontantTTC = new DeviseField();
c.gridx++;
c.weightx = 0;
this.add(this.textMontantTTC, c);
 
this.textMontantTTC.getDocument().addDocumentListener(this.docTTCListen);
 
// Choix TVA
c.gridx++;
c.weightx = 0;
c.gridwidth = 1;
this.comboTaxe = new ElementComboBox(false);
 
c.fill = GridBagConstraints.NONE;
 
this.add(this.comboTaxe, c);
 
// Montant HT
c.fill = GridBagConstraints.HORIZONTAL;
JLabel labelMontantHT = new JLabel(getLabelFor("MONTANT_HT"));
c.weightx = 0;
c.gridy++;
c.gridx = 0;
c.gridwidth = 1;
labelMontantHT.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelMontantHT, c);
 
this.textMontantHT = new DeviseField();
c.gridx++;
c.weightx = 1;
this.add(this.textMontantHT, c);
 
this.textMontantHT.setEditable(false);
this.textMontantHT.setEnabled(false);
// Montant Service
 
// Montant Service
final JCheckBox checkService = new JCheckBox("dont ");
c.gridx = 0;
c.gridy++;
c.gridx++;
 
c.weightx = 0;
this.add(checkService, c);
 
344,13 → 331,18
checkService.addActionListener(new ActionListener() {
 
public void actionPerformed(java.awt.event.ActionEvent e) {
if (isFilling())
return;
boolean b = checkService.isSelected();
textMontantService.setEditable(b);
textMontantService.setEnabled(b);
textMontantService.setFocusable(b);
 
if (!b) {
textMontantService.setText("");
// montantServiceValide = true;
} else {
textMontantService.setText(textMontantHT.getText());
}
};
});
370,6 → 362,35
this.add(this.labelWarning, c);
this.labelWarning.setVisible(false);
 
// Choix TVA
c.gridy++;
c.gridx = 0;
c.weightx = 0;
c.gridwidth = 1;
 
final JLabel labelTaxe = new JLabel(getLabelFor("ID_TAXE"));
labelTaxe.setHorizontalAlignment(SwingUtilities.RIGHT);
this.add(labelTaxe, c);
 
c.gridx++;
this.comboTaxe = new ElementComboBox(false);
 
c.fill = GridBagConstraints.NONE;
 
this.add(this.comboTaxe, c);
 
c.fill = GridBagConstraints.HORIZONTAL;
 
// Montant TTC
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelMontantTTC, c);
 
c.gridx++;
c.weightx = 0;
this.add(this.textMontantTTC, c);
 
/***********************************************************************************
* * MODE DE REGLEMENT
**********************************************************************************/
405,7 → 426,7
c.gridy++;
c.weightx = 0;
c.gridwidth = 2;
this.add(this.checkCommande, c);
// this.add(this.checkCommande, c);
 
this.checkCommande.addActionListener(new ActionListener() {
 
427,7 → 448,8
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
this.add(labelFournisseur, c);
labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT);
// this.add(labelFournisseur, c);
 
this.comboFournisseur = new ElementComboBox();
 
434,7 → 456,7
c.gridx++;
c.weightx = 1;
c.gridwidth = 4;
this.add(this.comboFournisseur, c);
// this.add(this.comboFournisseur, c);
 
// Echeance
JLabel labelEcheance = new JLabel("Echeance");
443,12 → 465,12
c.weightx = 0;
c.gridwidth = 1;
labelEcheance.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelEcheance, c);
// this.add(labelEcheance, c);
 
c.gridx++;
c.weightx = 1;
this.textEcheance = new JTextField();
this.add(this.textEcheance, c);
// this.add(this.textEcheance, c);
this.textEcheance.addKeyListener(new KeyAdapter() {
 
public void keyReleased(KeyEvent e) {
458,7 → 480,7
 
c.gridx++;
c.weightx = 0;
this.add(this.labelEcheancejours, c);
// this.add(this.labelEcheancejours, c);
 
/***********************************************************************************
* * INFORMATIONS COMPLEMENTAIRES
468,7 → 490,7
c.gridy++;
sep = new TitledSeparator("Informations complémentaires");
c.insets = new Insets(10, 2, 1, 2);
this.add(sep, c);
// this.add(sep, c);
c.insets = new Insets(2, 2, 1, 2);
 
ITextArea textInfos = new ITextArea();
480,7 → 502,7
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
this.add(textInfos, c);
// this.add(textInfos, c);
 
this.addSQLObject(this.textNom, "NOM");
this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");
542,8 → 564,22
 
}
 
@Override
public Set<String> getPartialResetNames() {
Set<String> s = new HashSet<String>();
s.addAll(super.getPartialResetNames());
s.add("MONTANT_TTC");
s.add("NOM");
s.add("ID_AVOIR_CLIENT");
s.add("ID_ARTICLE");
s.add("INFOS");
return s;
}
 
private void calculMontant() {
 
if (!isFilling()) {
 
float taux;
// PrixHT pHT;
PrixTTC pTTC;
571,6 → 607,7
}
}
}
}
 
private boolean isMontantServiceValid() {
String montant = this.textMontantService.getText().trim();
715,8 → 752,8
createArticle();
}
 
if (this.textNom.getTextComp().getText().trim().length() <= 0) {
this.textNom.getTextComp().setText(this.nomArticle.getTextMain());
if (this.textNom.getValue() == null || this.textNom.getValue().trim().length() <= 0) {
this.textNom.setValue(this.nomArticle.getTextMain());
}
final int id = super.insert(order);
// on verifie si le produit est à commander
724,6 → 761,8
createCommande(id);
}
 
SQLRow rowArt = getTable().getRow(id).getForeignRow("ID_ARTICLE");
if (rowArt != null && !rowArt.isUndefined() && rowArt.getBoolean("GESTION_STOCK")) {
Configuration.getInstance().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
@Override
745,13 → 784,15
CollectionMap<SQLRow, List<SQLRowValues>> map = ((MouvementStockSQLElement) Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK")).updateStock(
Arrays.asList(row.getID()), false);
MouvementStockSQLElement.createCommandeF(map, null);
new GenerationMvtSaisieVenteComptoir(id);
 
} catch (SQLException e) {
ExceptionHandler.handle("Erreur lors de la création des mouvements", e);
ExceptionHandler.handle("Erreur lors de la création des mouvements de stock", e);
}
}
});
 
}
new GenerationMvtSaisieVenteComptoir(id);
return id;
}
 
790,12 → 831,18
private void createArticle() {
System.out.println("Création de l'article");
 
SQLTable articleTable = getTable().getBase().getTable("ARTICLE");
String tNomArticle = this.nomArticle.getTextMain();
String codeArticle = this.nomArticle.getTextOpt();
 
if (tNomArticle.trim().length() == 0 && codeArticle.trim().length() == 0) {
return;
}
 
SQLTable articleTable = getTable().getBase().getTable("ARTICLE");
 
int idTaxe = this.comboTaxe.getSelectedId();
BigDecimal prix = new BigDecimal(this.textMontantHT.getText());
BigDecimal prixTTC = new BigDecimal(this.textMontantTTC.getText());
BigDecimal prix = new BigDecimal(this.textMontantHT.getText().replaceAll(",", "."));
BigDecimal prixTTC = new BigDecimal(this.textMontantTTC.getText().replaceAll(",", "."));
 
if (tNomArticle.trim().length() == 0) {
tNomArticle = "Nom Indefini";
809,9 → 856,13
vals.put("CODE", codeArticle);
vals.put("PA_HT", prix);
vals.put("PV_HT", prix);
vals.put("PRIX_METRIQUE_VT_1", prix);
vals.put("PRIX_METRIQUE_HA_1", prix);
vals.put("PV_TTC", prixTTC);
vals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE);
vals.put("ID_TAXE", new Integer(idTaxe));
vals.put("CREATION_AUTO", Boolean.TRUE);
vals.put("GESTION_STOCK", Boolean.FALSE);
 
try {
SQLRow row = vals.insert();
827,10 → 878,11
 
if (JOptionPane.showConfirmDialog(this, "Attention en modifiant cette vente comptoir, vous supprimerez les chéques et les échéances associés. Continuer?",
"Modification de vente comptoir", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
 
// on efface les mouvements de stocks associés
SQLRow row = getTable().getRow(this.getSelectedID());
SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK");
SQLSelect sel = new SQLSelect(eltMvtStock.getTable().getBase());
SQLSelect sel = new SQLSelect();
sel.addSelect(eltMvtStock.getTable().getField("ID"));
Where w = new Where(eltMvtStock.getTable().getField("IDSOURCE"), "=", row.getID());
Where w2 = new Where(eltMvtStock.getTable().getField("SOURCE"), "=", getTable().getName());
848,8 → 900,8
}
}
 
if (this.textNom.getTextComp().getText().trim().length() <= 0) {
this.textNom.getTextComp().setText(this.nomArticle.getTextMain());
if (this.textNom.getValue().trim().length() <= 0) {
this.textNom.setValue(this.nomArticle.getTextMain());
}
 
// On teste si l'article n'existe pas, on le crée
869,6 → 921,8
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE");
eltEcr.archiveMouvementProfondeur(idMvt, false);
 
SQLRow rowArt = row.getForeignRow("ID_ARTICLE");
if (rowArt != null && !rowArt.isUndefined() && rowArt.getBoolean("GESTION_STOCK")) {
// Mise à jour des stocks
SQLRowValues rowVals = new SQLRowValues(eltMvtStock.getTable());
rowVals.put("QTE", -1);
879,16 → 933,26
rowVals.put("DATE", row.getObject("DATE"));
try {
SQLRow rowNew = rowVals.insert();
CollectionMap<SQLRow, List<SQLRowValues>> map = ((MouvementStockSQLElement) Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK")).updateStock(
final CollectionMap<SQLRow, List<SQLRowValues>> map = ((MouvementStockSQLElement) Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK")).updateStock(
Arrays.asList(rowNew.getID()), false);
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
@Override
public void run() {
MouvementStockSQLElement.createCommandeF(map, null);
}
});
} catch (SQLException e) {
e.printStackTrace();
}
 
}
if (idMvt > 1) {
new GenerationMvtSaisieVenteComptoir(this.getSelectedID(), idMvt);
} else {
new GenerationMvtSaisieVenteComptoir(this.getSelectedID());
}
}
}
 
@Override
public void select(SQLRowAccessor r) {
897,6 → 961,8
 
super.select(r);
 
checkService.setSelected(r != null && r.getLong("MONTANT_SERVICE") > 0);
 
this.textMontantTTC.getDocument().addDocumentListener(this.docTTCListen);
this.nomArticle.addValueListener(this.propertyChangeListener);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/action/ListeDesTicketsAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TextAreaTicketPanel.java
78,7 → 78,7
private Ticket createTicket(SQLRow row) {
Ticket t = new Ticket(row.getInt("ID_CAISSE"));
// t.setNumber(Integer.valueOf(row.getString("NUMERO")));
t.setDate(row.getDate("DATE").getTime());
t.setCreationCal(row.getDate("DATE"));
 
SQLElement eltEncaisser = Configuration.getInstance().getDirectory().getElement("ENCAISSER_MONTANT");
List<SQLRow> l = row.getReferentRows(eltEncaisser.getTable());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ConfigCaissePanel.java
13,16 → 13,14
package org.openconcerto.erp.core.sales.pos.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.ServerFinderConfig;
import org.openconcerto.erp.config.ServerFinderPanel;
import org.openconcerto.erp.core.sales.pos.Caisse;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.DBSystemRoot;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLServer;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
 
288,25 → 286,18
return;
}
 
System.out.println("Reloading POS information from: " + config);
ComptaPropsConfiguration conf = config.createConf();
try {
System.out.println("Reloading POS information from: " + config);
SQLServer server = config.createServer("Common");
DBSystemRoot r = server.getSystemRoot(config.getSystemRoot());
DBRoot root = r.getRoot("Common");
// Sociétés
final SQLTable societeT = root.getTable("SOCIETE_COMMON");
final SQLRow societe = societeT.getValidRow(id);
server.destroy();
conf.setUpSocieteStructure(id);
final SQLRow societe = conf.getRowSociete();
if (societe != null) {
final String name = societe.getString("DATABASE_NAME");
server = config.createServer(name);
r = server.getSystemRoot(config.getSystemRoot());
root = r.getRoot(name);
// Caisses
SQLSelect sel = new SQLSelect(root.getBase());
sel.addSelectStar(root.getTable("CAISSE"));
final SQLSelect sel = new SQLSelect();
sel.addSelectStar(conf.getRootSociete().getTable("CAISSE"));
final List<SQLRow> caisses = SQLRowListRSH.execute(sel);
server.destroy();
// Stock l'id de la caisse pour que la reslectionne soit correcte
final int idCaisseToSelect = this.caisseId;
SwingUtilities.invokeLater(new Runnable() {
339,9 → 330,10
} else {
JOptionPane.showMessageDialog(this, "Impossible de trouver la société d'ID " + id);
}
 
} catch (final Exception e) {
e.printStackTrace();
} finally {
conf.destroy();
}
}
 
389,23 → 381,20
JOptionPane.showMessageDialog(ConfigCaissePanel.this, "Impossible de se connecter au serveur");
return;
}
final ComptaPropsConfiguration server = config.createConf();
try {
final DBRoot root = server.getRoot();
 
final SQLServer server = config.createServer("Common");
final DBSystemRoot r = server.getSystemRoot(config.getSystemRoot());
final DBRoot root = r.getRoot("Common");
// Sociétés
SQLSelect sel = new SQLSelect(root.getBase());
sel.addSelectStar(root.getTable("SOCIETE_COMMON"));
SQLSelect sel = new SQLSelect();
sel.addSelectStar(root.findTable("SOCIETE_COMMON"));
final List<SQLRow> societes = SQLRowListRSH.execute(sel);
 
// Utilisateurs
sel = new SQLSelect(root.getBase());
sel.addSelectStar(root.getTable("USER_COMMON"));
sel = new SQLSelect();
sel.addSelectStar(root.findTable("USER_COMMON"));
final List<SQLRow> utilisateurs = SQLRowListRSH.execute(sel);
 
server.destroy();
 
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
459,8 → 448,9
 
} catch (final Exception e) {
e.printStackTrace();
} finally {
server.destroy();
}
 
}
});
t.setDaemon(true);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ListeDesTicketsPanel.java
18,6 → 18,7
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.ui.DefaultListModel;
import org.openconcerto.ui.touch.ScrollableList;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Color;
import java.awt.Component;
31,6 → 32,7
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.util.Vector;
 
import javax.swing.ImageIcon;
190,8 → 192,13
if (selectedValue != null) {
ticketLlistModel.removeElement(selectedValue);
ticketList.clearSelection();
((Ticket) selectedValue).deleteTicket();
final Ticket receipt = (Ticket) selectedValue;
try {
receipt.deleteTicket();
} catch (IOException e1) {
ExceptionHandler.handle(this, "Impossible d'effacer le ticket " + receipt.getCode(), e1);
}
}
} else if (selectedIndex == 3) {
// Retour
frame.showMenu();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseControler.java
25,6 → 25,8
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JOptionPane;
 
public class CaisseControler implements BarcodeListener {
 
private Article articleSelected;
191,6 → 193,8
Ticket t = Ticket.getTicketFromCode(code);
if (t != null) {
caisseFrame.showTickets(t);
} else {
JOptionPane.showMessageDialog(this.caisseFrame, "Ticket " + code + " introuvable, peut-être a-t-il été importé ou effacé.");
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseFrame.java
21,7 → 21,6
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.utils.ClassPathLoader;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ProductInfo;
 
import java.awt.Dimension;
import java.awt.Toolkit;
55,11 → 54,10
 
ExceptionHandler.setForceUI(true);
ExceptionHandler.setForumURL("http://www.openconcerto.org/forum");
ProductInfo.setInstance(new ProductInfo("OpenConcerto"));
 
// SpeedUp Linux
System.setProperty("sun.java2d.pmoffscreen", "false");
System.setProperty("org.openconcerto.sql.structure.useXML", "true");
System.setProperty(SQLBase.STRUCTURE_USE_XML, "true");
System.setProperty(PropsConfiguration.REDIRECT_TO_FILE, "true");
if (Caisse.isUsingJPos()) {
ClassPathLoader c = ClassPathLoader.getInstance();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ArticleSelector.java
147,8 → 147,8
Object sel = list.getSelectedValue();
if (sel != null && !e.getValueIsAdjusting()) {
Article article = (Article) sel;
controller.setArticleSelected(article);
controller.addArticle(article);
controller.setArticleSelected(article);
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaissePanel.java
13,6 → 13,7
package org.openconcerto.erp.core.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.Caisse;
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.Categorie;
import org.openconcerto.sql.Configuration;
65,7 → 66,10
// Valider
try {
CaissePanel.this.controler.printTicket();
if (Caisse.isCopyActive())
CaissePanel.this.controler.printTicket();
} catch (UnsatisfiedLinkError ex) {
ExceptionHandler.handle("Erreur de configuration de la liaison à l'imprimante", ex);
} catch (Throwable ex) {
ExceptionHandler.handle("Erreur d'impression du ticket", ex);
}
114,6 → 118,7
this.controler.addCaisseListener(this);
}
 
@SuppressWarnings("unchecked")
private void loadArticles() {
 
Map<Integer, Categorie> m = new HashMap<Integer, Categorie>();
145,17 → 150,22
selArticle.addSelectStar(eltArticle.getTable());
List<SQLRow> l2 = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(selArticle.asString(), SQLRowListRSH.createFromSelect(selArticle, eltArticle.getTable()));
 
final Categorie cUnclassified = new Categorie("Non classés", true);
for (SQLRow row : l2) {
 
final Categorie s1 = m.get(row.getInt("ID_FAMILLE_ARTICLE"));
if (s1 != null) {
Article a = new Article(s1, row.getString("NOM"), row.getID());
Categorie s1 = m.get(row.getInt("ID_FAMILLE_ARTICLE"));
if (s1 == null) {
s1 = cUnclassified;
m.put(row.getID(), cUnclassified);
}
final String name = row.getString("NOM").trim();
if (name.length() > 0) {
final Article a = new Article(s1, name, row.getID());
a.setBarCode(row.getString("CODE_BARRE"));
a.setCode(row.getString("CODE"));
a.setIdTaxe(row.getInt("ID_TAXE"));
a.setPriceHTInCents((BigDecimal) row.getObject("PV_HT"));
a.setPriceInCents((BigDecimal) row.getObject("PV_TTC"));
 
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/Ticket.java
21,16 → 21,13
import org.openconcerto.erp.core.sales.pos.io.TicketPrinter;
import org.openconcerto.erp.core.sales.pos.ui.TicketCellRenderer;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.TemplateNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Pair;
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.MathContext;
50,69 → 47,57
import org.jdom.output.XMLOutputter;
 
public class Ticket {
static public Calendar getCalendar() {
return Calendar.getInstance();
}
 
private static boolean inited = false;
// Propre a ticket
private List<Paiement> paiements = new ArrayList<Paiement>();
private final List<Pair<Article, Integer>> items = new ArrayList<Pair<Article, Integer>>();
private Date date;
private Calendar creationCal;
private int number;
 
// Propre à la caisse
private int caisseNumber;
private final int caisseNumber;
 
private static final SQLTable tableArticle = Configuration.getInstance().getRoot().findTable("ARTICLE");
 
@SuppressWarnings("unchecked")
public static Ticket getTicketFromCode(String code) {
// Code: 01_05042011_00002
// filtre les chiffres
final StringBuilder b = new StringBuilder();
for (int i = 0; i < code.length(); i++) {
final char c = code.charAt(i);
if (Character.isDigit(c)) {
b.append(c);
try {
// Loading file
return parseFile(new ReceiptCode(code).getFile());
} catch (Exception e) {
System.err.println("Error with ticket code : " + code);
e.printStackTrace();
return null;
}
}
code = b.toString();
// Code: 010504201100002
// n°caisse sur 2 caracteres
// date jour mois année JJMMAAAA
// numero de ticket formaté sur 5 caractères
 
final Ticket t = new Ticket(-1);
Calendar c = Calendar.getInstance();
try {
int nCaisse = Integer.parseInt(code.substring(0, 2));
int nJ = Integer.parseInt(code.substring(2, 4));
int nM = Integer.parseInt(code.substring(4, 6));
int nA = 2000 + Integer.parseInt(code.substring(6, 8));
int nNumber = Integer.parseInt(code.substring(8, 13));
 
c.setTimeInMillis(0);
c.set(nA, nM - 1, nJ, 0, 0, 0);
 
// Set fields
t.caisseNumber = nCaisse;
t.date.setTime(c.getTimeInMillis());
t.number = nNumber;
 
// Loading file
File dir = t.getOutputDir();
File file = new File(dir, getFileName(code));
public static Ticket parseFile(final File file) {
if (!file.exists()) {
return null;
}
 
try {
// XML Reading
 
final SAXBuilder sxb = new SAXBuilder();
final Document document = sxb.build(file);
final Element root = document.getRootElement();
final ReceiptCode receiptCode = new ReceiptCode(root.getAttributeValue("code"));
final String h = root.getAttributeValue("hour");
final String m = root.getAttributeValue("minute");
c.set(nA, nM - 1, nJ, Integer.parseInt(h), Integer.parseInt(m), 0);
t.date.setTime(c.getTimeInMillis());
final Calendar c = (Calendar) receiptCode.getDay().clone();
c.set(Calendar.HOUR_OF_DAY, Integer.parseInt(h));
c.set(Calendar.MINUTE, Integer.parseInt(m));
final Ticket t = new Ticket(receiptCode.getCaisseNb());
t.setCreationCal(c);
t.setNumber(receiptCode.getDayIndex());
 
// article
List<Element> children = root.getChildren("article");
@SuppressWarnings("unchecked")
final List<Element> children = root.getChildren("article");
for (Element element : children) {
int qte = Integer.parseInt(element.getAttributeValue("qte"));
BigDecimal prix_unitaire_cents_ht = new BigDecimal(element.getAttributeValue("prixHT"));
138,8 → 123,9
 
}
// paiement
children = root.getChildren("paiement");
for (Element element : children) {
@SuppressWarnings("unchecked")
final List<Element> payChildren = root.getChildren("paiement");
for (Element element : payChildren) {
 
String type = element.getAttributeValue("type");
int montant_cents = Integer.parseInt(element.getAttributeValue("montant"));
158,25 → 144,18
}
}
 
return t;
} catch (Exception e) {
System.err.println("Error with ticket code : " + code);
System.err.println("Error with ticket : " + file);
e.printStackTrace();
return null;
}
 
return t;
 
}
 
private static String getFileName(String code) {
return code.replace(' ', '_') + ".xml";
}
 
public Ticket(int caisse) {
this.caisseNumber = caisse;
this.date = Calendar.getInstance().getTime();
this.creationCal = getCalendar();
initNumber();
 
}
 
public void setNumber(int i) {
183,54 → 162,24
this.number = i;
}
 
public void setDate(Date d) {
this.date = d;
}
 
private void initNumber() {
if (!inited) {
this.number = 1;
String[] files = getCompatibleFileNames();
for (int i = 0; i < files.length; i++) {
String name = files[i];
String nb = name.substring(8, 13);
System.out.println("Found:" + nb);
int n = Integer.parseInt(nb);
if (n >= this.number) {
this.number = n + 1;
int max = 0;
for (final ReceiptCode c : this.getReceiptCode().getSameDayCodes(true)) {
if (c.getDayIndex() > max)
max = c.getDayIndex();
}
this.setNumber(max + 1);
}
}
}
 
public String[] getCompatibleFileNames() {
final File dir = getOutputDir();
final String codeStart = getPrefixCode();
final String[] files = dir.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith(codeStart) && name.endsWith(".xml");
public final ReceiptCode getReceiptCode() {
// TODO replace our fields by one ReceiptCode
return new ReceiptCode(this.getCaisseNumber(), this.getCreationCal(), this.getNumber());
}
});
return files;
}
 
String getPrefixCode() {
Calendar cal = Calendar.getInstance();
cal.setTime(this.date);
int j = cal.get(Calendar.DAY_OF_MONTH);
int m = cal.get(Calendar.MONTH) + 1;
int a = cal.get(Calendar.YEAR) - 2000;
String code = "";
code += format(2, this.getCaisseNumber());
code += format(2, j) + format(2, m) + format(2, a);
return code;
}
 
public String getCode() {
String code = getPrefixCode();
code += format(5, this.getNumber());
return code;
return getReceiptCode().getCode();
}
 
/**
243,18 → 192,17
/**
* Numero de la caisse, de 1 à n
*/
private int getCaisseNumber() {
final int getCaisseNumber() {
return this.caisseNumber;
}
 
public void save() {
// Update Hour & Minute
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
int minute = Calendar.getInstance().get(Calendar.MINUTE);
int hour = getCalendar().get(Calendar.HOUR_OF_DAY);
int minute = getCalendar().get(Calendar.MINUTE);
 
// Hierarchie: 2010/04/05/01_05042010_00002.xml
File dir = getOutputDir();
File f = new File(dir, getFileName(getCode()));
final File f = getFile();
Element topLevel = new Element("ticket");
topLevel.setAttribute(new Attribute("code", this.getCode()));
topLevel.setAttribute("hour", String.valueOf(hour));
394,57 → 342,21
}
}
 
private File getOutputDir() {
Calendar cal = Calendar.getInstance();
cal.setTime(this.date);
int j = cal.get(Calendar.DAY_OF_MONTH);
int m = cal.get(Calendar.MONTH) + 1;
int a = cal.get(Calendar.YEAR);
TemplateNXProps nxprops = (TemplateNXProps) TemplateNXProps.getInstance();
final String defaultLocation = nxprops.getDefaultStringValue();
File defaultDir = new File(defaultLocation);
File outputDir = new File(defaultDir, "Tickets");
if (!outputDir.exists()) {
outputDir.mkdirs();
private File getFile() {
return getReceiptCode().getFile();
}
File outputDirYear = new File(outputDir, format(4, a));
if (!outputDirYear.exists()) {
outputDirYear.mkdir();
}
File outputDirMonth = new File(outputDirYear, format(2, m));
if (!outputDirMonth.exists()) {
outputDirMonth.mkdir();
}
File outputDirDay = new File(outputDirMonth, format(2, j));
if (!outputDirDay.exists()) {
outputDirDay.mkdir();
}
if (!outputDirDay.exists()) {
ExceptionHandler.handle("Impossible de créer le dossier des tickets.\n\n" + outputDirDay.getAbsolutePath());
}
return outputDirDay;
}
 
public Date getCreationDate() {
return this.date;
return this.getCreationCal().getTime();
}
 
private static String format(int l, int value) {
return format(l, String.valueOf(value));
public Calendar getCreationCal() {
return this.creationCal;
}
 
private static String format(int l, String string) {
if (string.length() > l) {
string = string.substring(0, l);
public void setCreationCal(final Calendar cal) {
this.creationCal = (Calendar) cal.clone();
}
final StringBuffer str = new StringBuffer(l);
final int stop = l - string.length();
for (int i = 0; i < stop; i++) {
str.append('0');
}
str.append(string);
return str.toString();
}
 
public void addPaiement(Paiement p1) {
this.paiements.add(p1);
599,10 → 511,7
return getCode().hashCode();
}
 
public void deleteTicket() {
File dir = this.getOutputDir();
String name = getFileName(this.getCode());
File f = new File(dir, name);
f.renameTo(new File(dir, name + "_deleted"));
public void deleteTicket() throws IOException {
getReceiptCode().markDeleted();
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/ReceiptCode.java
New file
0,0 → 1,276
/*
* 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.sales.pos.model;
 
import org.openconcerto.erp.preferences.TemplateNXProps;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
 
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.Format;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
 
public class ReceiptCode {
 
// year/month/day
static private final int DIR_DEPTH = 3;
static private final int FILE_DEPTH = DIR_DEPTH + 1;
static private final String EXT = ".xml";
static private final String DELETED_SUFFIX = "_deleted";
static private final String DELETED_EXT = EXT + DELETED_SUFFIX;
static private final String IMPORTED_SUFFIX = "_imported";
static private final String IMPORTED_EXT = EXT + IMPORTED_SUFFIX;
 
static public final File getRootDir() {
return getRootDir(false);
}
 
static public final File getRootDir(final boolean archived) {
final TemplateNXProps nxprops = (TemplateNXProps) TemplateNXProps.getInstance();
return new File(nxprops.getDefaultStringValue(), archived ? "Tickets archivés" : "Tickets");
}
 
static public final File getDayDir(final Calendar cal, final boolean create) {
final int j = cal.get(Calendar.DAY_OF_MONTH);
final int m = cal.get(Calendar.MONTH) + 1;
final int a = cal.get(Calendar.YEAR);
final List<String> dirs = Arrays.asList(DIGIT4_FORMAT.format(a), DIGIT2_FORMAT.format(m), DIGIT2_FORMAT.format(j));
assert dirs.size() == DIR_DEPTH;
File res = getRootDir();
for (final String dir : dirs) {
res = new File(res, dir);
}
if (create) {
try {
FileUtils.mkdir_p(res);
} catch (IOException e) {
ExceptionHandler.handle("Impossible de créer le dossier des tickets.\n\n" + res.getAbsolutePath());
}
}
return res;
}
 
static public final List<File> getReceiptsToImport(final int caisseNb) {
return FileUtils.list(getRootDir(), FILE_DEPTH, createFF(DIGIT2_FORMAT.format(caisseNb), false, false));
}
 
protected static FileFilter createFF(final String prefix, final boolean includeDeleted, final boolean includeImported) {
return new FileFilter() {
@Override
public boolean accept(File f) {
if (!f.isFile() || !f.getName().startsWith(prefix))
return false;
return f.getName().endsWith(EXT) || (includeDeleted && f.getName().endsWith(DELETED_EXT)) || (includeImported && f.getName().endsWith(IMPORTED_EXT));
}
};
}
 
static private final String getEnd(final String s, final List<String> candidates) {
for (final String candidate : candidates)
if (s.endsWith(candidate))
return candidate;
return null;
}
 
static public final ReceiptCode fromFile(final File f) {
final String name = f.getName();
final String toRm = getEnd(name, Arrays.asList(EXT, DELETED_EXT, IMPORTED_EXT));
if (toRm == null)
return null;
try {
return new ReceiptCode(name.substring(0, name.length() - toRm.length()));
} catch (ParseException e) {
return null;
}
}
 
static public void archiveCompletelyImported() throws IOException {
final File archiveDir = getRootDir(true);
FileUtils.mkdir_p(archiveDir);
final File rootDir = getRootDir(false);
final List<File> dirs = FileUtils.list(rootDir, DIR_DEPTH, FileUtils.DIR_FILTER);
// don't archive today otherwise number will be wrong (see Ticket.initNumber())
final File todayDir = getDayDir(Ticket.getCalendar(), false);
for (final File dir : dirs) {
// if all receipts are deleted or imported : archive
if (!todayDir.equals(dir) && dir.listFiles(createFF("", false, false)).length == 0) {
final File destDir = new File(archiveDir, FileUtils.relative(rootDir, dir));
FileUtils.mkParentDirs(destDir);
if (!destDir.exists()) {
// move
final String err = FileUtils.mv(dir, destDir);
if (err != null)
throw new IOException(err);
} else {
// merge
for (final File f : dir.listFiles()) {
FileUtils.mv(f, destDir);
}
FileUtils.rm(dir);
}
assert !dir.exists();
}
}
}
 
static private final DecimalFormat DIGIT2_FORMAT = new DecimalFormat("00");
static private final DecimalFormat DIGIT4_FORMAT = new DecimalFormat("0000");
static private final DecimalFormat INDEX_FORMAT = new DecimalFormat("00000");
 
static {
DIGIT2_FORMAT.setMaximumIntegerDigits(DIGIT2_FORMAT.getMinimumIntegerDigits());
DIGIT4_FORMAT.setMaximumIntegerDigits(DIGIT4_FORMAT.getMinimumIntegerDigits());
INDEX_FORMAT.setMaximumIntegerDigits(INDEX_FORMAT.getMinimumIntegerDigits());
}
 
static private Number parse(final DecimalFormat f, final String s, final ParsePosition pos) throws ParseException {
return (Number) parse(f, s, pos, f.getMaximumIntegerDigits());
}
 
static private Date parse(final SimpleDateFormat f, final String s, final ParsePosition pos) throws ParseException {
// only works for fixed width pattern
return (Date) parse(f, s, pos, f.toPattern().length());
}
 
// formats almost always try to parse to the end of the string, this method prevents that
static private Object parse(final Format f, final String s, final ParsePosition pos, final int maxChar) throws ParseException {
return f.parseObject(s.substring(0, pos.getIndex() + maxChar), pos);
}
 
private final int caisseNb;
private final Calendar day;
private final int dayIndex;
private final String code;
 
private SimpleDateFormat dateFormat;
 
public ReceiptCode(String code) throws ParseException {
super();
// Code: 01_05042011_00002
// filtre les chiffres
final StringBuilder b = new StringBuilder();
for (int i = 0; i < code.length(); i++) {
final char c = code.charAt(i);
if (Character.isDigit(c)) {
b.append(c);
}
}
code = b.toString();
// Code: 010504201100002
this.code = code;
this.setCalendar(Ticket.getCalendar());
 
// Code: 0105041300002
// n°caisse sur 2 caracteres
// date jour mois année JJMMAA
// numero de ticket formaté sur 5 caractères
final ParsePosition pos = new ParsePosition(0);
this.caisseNb = parse(DIGIT2_FORMAT, code, pos).intValue();
this.day = getCalendar();
this.day.setTime(parse(this.dateFormat, code, pos));
this.dayIndex = parse(INDEX_FORMAT, code, pos).intValue();
}
 
public ReceiptCode(final int caisseNb, final Calendar cal, final int dayIndex) {
super();
this.setCalendar(cal);
this.caisseNb = caisseNb;
this.day = (Calendar) cal.clone();
this.dayIndex = dayIndex;
this.code = DIGIT2_FORMAT.format(this.caisseNb) + this.dateFormat.format(this.day.getTime()) + INDEX_FORMAT.format(this.dayIndex);
}
 
public final void setCalendar(final Calendar newCal) {
final Calendar cal = (Calendar) newCal.clone();
this.dateFormat = new SimpleDateFormat("ddMMyy");
this.dateFormat.setCalendar(cal);
cal.clear();
cal.set(2000, 0, 1);
this.dateFormat.set2DigitYearStart(cal.getTime());
}
 
public final Calendar getCalendar() {
return (Calendar) this.dateFormat.getCalendar().clone();
}
 
public final int getCaisseNb() {
return this.caisseNb;
}
 
public final Calendar getDay() {
return this.day;
}
 
public final int getDayIndex() {
return this.dayIndex;
}
 
public final String getCodePrefix() {
return this.code.substring(0, this.code.length() - INDEX_FORMAT.getMinimumIntegerDigits());
}
 
public final String getCode() {
return this.code;
}
 
public final File getDir(final boolean create) {
return getDayDir(getDay(), create);
}
 
public final File getFile() {
return new File(getDir(true), getFileName());
}
 
public final String getFileName() {
return getCode().replace(' ', '_') + EXT;
}
 
public void markDeleted() throws IOException {
mark(DELETED_SUFFIX);
}
 
public void markImported() throws IOException {
mark(IMPORTED_SUFFIX);
}
 
private final void mark(final String suffix) throws IOException {
final File f = getFile();
if (!f.renameTo(new File(f.getParentFile(), f.getName() + suffix)))
throw new IOException("Couldn't rename " + f);
}
 
public final List<ReceiptCode> getSameDayCodes(final boolean includeAll) {
final File dir = getDir(false);
final File[] listFiles = dir.listFiles(createFF(getCodePrefix(), includeAll, includeAll));
if (listFiles == null)
return Collections.emptyList();
 
final List<ReceiptCode> res = new ArrayList<ReceiptCode>(listFiles.length);
for (final File f : listFiles) {
res.add(fromFile(f));
}
return res;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/element/BonDeLivraisonItemSQLElement.java
95,7 → 95,7
 
int qteLivree = rowFact.getInt("QTE_LIVREE") + rowFact.getInt("QTE_LIVREE");
 
SQLRowValues rowVals = new SQLRowValues(new SaisieVenteFactureItemSQLElement().getTable());
SQLRowValues rowVals = new SQLRowValues(getDirectory().getElement(SaisieVenteFactureItemSQLElement.class).getTable());
rowVals.put("QTE_LIVREE", new Integer(qteLivree));
 
try {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/ui/BonDeLivraisonItemTable.java
32,6 → 32,7
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
259,6 → 260,36
this.tableElementPoidsTotalLivree = new SQLTableElement(e.getTable().getField("T_POIDS_LIVREE"), Float.class);
list.add(this.tableElementPoidsTotalLivree);
 
// Packaging
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
 
SQLTableElement poidsColis = new SQLTableElement(e.getTable().getField("POIDS_COLIS_NET"), BigDecimal.class);
list.add(poidsColis);
 
SQLTableElement nbColis = new SQLTableElement(e.getTable().getField("NB_COLIS"), Integer.class);
list.add(nbColis);
 
final SQLTableElement totalPoidsColis = new SQLTableElement(e.getTable().getField("T_POIDS_COLIS_NET"), BigDecimal.class);
list.add(totalPoidsColis);
 
poidsColis.addModificationListener(totalPoidsColis);
nbColis.addModificationListener(totalPoidsColis);
totalPoidsColis.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(final SQLRowValues row) {
final Object o2 = row.getObject("POIDS_COLIS_NET");
final Object o3 = row.getObject("NB_COLIS");
if (o2 != null && o3 != null) {
BigDecimal poids = (BigDecimal) o2;
int nb = (Integer) o3;
return poids.multiply(new BigDecimal(nb), MathContext.DECIMAL128).setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
} else {
return row.getObject("T_POIDS_COLIS_NET");
}
}
});
 
}
 
// Service
// this.service = new SQLTableElement(e.getTable().getField("SERVICE"), Boolean.class);
// list.add(this.service);
271,7 → 302,9
this.tableElementTotalTTC.setRenderer(new DeviseTableCellRenderer());
list.add(this.tableElementTotalTTC);
 
model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"));
SQLRowValues defautRow = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
defautRow.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, defautRow);
 
this.table = new RowValuesTable(model, getConfigurationFile());
ToolTipManager.sharedInstance().unregisterComponent(this.table);
505,6 → 538,11
hideColumn(model.getColumnForField("ID_MODE_VENTE_ARTICLE"));
}
 
// Packaging
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
setColumnVisible(this.model.getColumnForField("T_POIDS_COLIS_NET"), false);
}
 
setColumnVisible(this.model.getColumnForField("ID_ARTICLE"), selectArticle);
setColumnVisible(this.model.getColumnForField("CODE"), !selectArticle || (selectArticle && createAuto));
setColumnVisible(this.model.getColumnForField("NOM"), !selectArticle || (selectArticle && createAuto));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/ComptaSQLConfElement.java
14,6 → 14,7
package org.openconcerto.erp.core.common.element;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.DBRoot;
25,6 → 26,7
import org.openconcerto.utils.convertor.ValueConvertor;
 
import java.awt.Component;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.math.BigInteger;
 
68,6 → 70,10
return baseSociete;
}
 
{
this.setL18nLocation(Gestion.class);
}
 
public ComptaSQLConfElement(String tableName, String singular, String plural) {
super(singular, plural, getBaseSociete().findTable(tableName, true));
}
85,8 → 91,39
return createCodeFromPackage();
}
 
protected String createCodeFromPackage() {
String canonicalName = getClass().getName();
/**
* Return a code that doesn't change when subclassing to allow to easily change a SQLElement
* while keeping the same code. To achieve that, the code isn't
* {@link #createCodeFromPackage(Class) computed} with <code>this.getClass()</code>. We iterate
* up through our superclass chain, and as soon as we find an abstract class, we stop and use
* the previous class (i.e. non abstract). E.g. any direct subclass of
* {@link ComptaSQLConfElement} will still use <code>this.getClass()</code>, but so is one of
* its subclass.
*
* @return a code computed from the superclass just under the first abstract superclass.
* @see #createCodeFromPackage(Class)
*/
protected final String createCodeFromPackage() {
return createCodeFromPackage(getLastNonAbstractClass());
}
 
private final Class<? extends ComptaSQLConfElement> getLastNonAbstractClass() {
Class<?> prev = null;
Class<?> cl = this.getClass();
// test loop
assert !Modifier.isAbstract(cl.getModifiers()) && ComptaSQLConfElement.class.isAssignableFrom(cl) && Modifier.isAbstract(ComptaSQLConfElement.class.getModifiers());
while (!Modifier.isAbstract(cl.getModifiers())) {
prev = cl;
cl = cl.getSuperclass();
}
assert ComptaSQLConfElement.class.isAssignableFrom(prev);
@SuppressWarnings("unchecked")
final Class<? extends ComptaSQLConfElement> res = (Class<? extends ComptaSQLConfElement>) prev;
return res;
}
 
static protected String createCodeFromPackage(final Class<? extends ComptaSQLConfElement> cl) {
String canonicalName = cl.getName();
if (canonicalName.contains("erp.core") && canonicalName.contains(".element")) {
int i = canonicalName.indexOf("erp.core") + 9;
int j = canonicalName.indexOf(".element");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/NumerotationAutoSQLElement.java
15,6 → 15,7
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.image.ImageIconWarning;
import org.openconcerto.erp.core.customerrelationship.customer.element.ClientNormalSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CourrierClientSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.RelanceSQLElement;
import org.openconcerto.erp.core.humanresources.payroll.element.SalarieSQLElement;
125,6 → 126,9
c.weightx = 0;
added.add(prefix);
SQLElement elt = Configuration.getInstance().getDirectory().getElement(class1);
if (elt == null) {
throw new IllegalArgumentException("Element null for class " + class1);
}
// Avoir
JLabel labelAvoirFormat = new JLabel(StringUtils.firstUp(elt.getPluralName()) + " " + getLabelFor(prefix + FORMAT), SwingConstants.RIGHT);
this.add(labelAvoirFormat, c);
491,6 → 495,9
map.put(AvoirClientSQLElement.class, "AVOIR");
map.put(AvoirFournisseurSQLElement.class, "AVOIR_F");
map.put(DevisSQLElement.class, "DEVIS");
 
map.put(ClientNormalSQLElement.class, "CLIENT");
 
map.put(BonDeLivraisonSQLElement.class, "BON_L");
map.put(BonReceptionSQLElement.class, "BON_R");
map.put(CommandeClientSQLElement.class, "COMMANDE_CLIENT");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/Acompte.java
New file
0,0 → 1,94
/*
* 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 java.math.BigDecimal;
import java.math.MathContext;
import java.text.DecimalFormat;
 
public class Acompte {
private BigDecimal montant;
private BigDecimal percent;
 
public final static Acompte HUNDRED_PERCENT = new Acompte(new BigDecimal(100), null);
 
// FIXME use precision of digits
 
public BigDecimal getMontant() {
return montant;
}
 
public BigDecimal getPercent() {
return percent;
}
 
public Acompte(BigDecimal percent, BigDecimal montant) {
this.montant = montant;
this.percent = percent;
}
 
public String toPlainString() {
if (percent != null) {
DecimalFormat format = new DecimalFormat("###.00");
return format.format(percent) + "%";
} else if (montant != null) {
DecimalFormat format = new DecimalFormat("###,###.00");
return format.format(montant);
} else {
return "";
}
}
 
@Override
public String toString() {
if (percent != null) {
return percent.toString() + "%";
} else if (montant != null) {
return montant.toString();
} else {
return "";
}
}
 
public BigDecimal getResultFrom(BigDecimal montant) {
 
if (this.percent != null) {
return montant.multiply(percent.movePointLeft(2), MathContext.DECIMAL128);
} else if (this.getMontant() == null) {
return montant;
} else {
return this.getMontant();
}
}
 
public static Acompte fromString(String s) {
 
if (s == null || s.trim().length() == 0) {
return null;
}
final Acompte a;
if (s.contains("%")) {
final String replace = s.replace("%", "");
BigDecimal percent = BigDecimal.ZERO;
if (replace.trim().length() != 0) {
percent = new BigDecimal(replace);
}
 
a = new Acompte(percent, null);
} else {
a = new Acompte(null, new BigDecimal(s));
}
return a;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AcompteField.java
New file
0,0 → 1,257
/*
* 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 org.openconcerto.sql.request.SQLRowItemView;
import org.openconcerto.sql.sqlobject.itemview.RowItemViewComponent;
import org.openconcerto.ui.valuewrapper.ValueWrapper;
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.Font;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.math.BigDecimal;
 
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
 
public class AcompteField extends JTextField implements ValueWrapper<Acompte>, Documented, RowItemViewComponent {
 
private SQLField field;
 
private BigDecimal total;
 
private final PropertyChangeSupport supp;
// does this component just gained focus
private boolean gained;
private boolean mousePressed;
// the content of this text field when it gained focus
private String initialText;
 
public AcompteField() {
this(15);
}
 
private AcompteField(int columns) {
super(columns);
 
this.supp = new PropertyChangeSupport(this);
this.gained = false;
this.getDocument().addDocumentListener(new SimpleDocumentListener() {
public void update(DocumentEvent e) {
AcompteField.this.textModified();
}
});
this.init();
}
 
public void setTotal(BigDecimal total) {
this.total = total;
}
 
public BigDecimal getTotal() {
return total;
}
 
/**
* Methode appelée quand le texte est modifié
*/
protected void textModified() {
this.supp.firePropertyChange("value", null, this.getValue());
}
 
@Override
public void init(SQLRowItemView v) {
this.field = v.getField();
}
 
private void init() {
// TODO use JFormattedTextField => conflit getValue()
// DefaultFormatterFactory NumberFormatter (getAllowsInvalid) NumberFormat
 
addFilteringKeyListener(this);
 
// select all on focus gained
// except if the user is selecting with the mouse
this.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
AcompteField.this.gained = true;
AcompteField.this.initialText = getText();
if (!AcompteField.this.mousePressed) {
selectAll();
}
}
});
this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
AcompteField.this.mousePressed = true;
}
 
public void mouseReleased(MouseEvent e) {
// don't override the user selection
if (AcompteField.this.gained && getSelectedText() == null) {
selectAll();
}
// don't select all for each mouse released
AcompteField.this.gained = false;
AcompteField.this.mousePressed = false;
}
});
this.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent keyEvent) {
// Sert a annuler une saisie
if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) {
AcompteField.this.setValue(AcompteField.this.initialText);
selectAll();
}
}
});
}
 
public static void addFilteringKeyListener(final AcompteField textField) {
 
textField.addKeyListener(new KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent keyEvent) {
 
final char keychar = keyEvent.getKeyChar();
 
if (keychar == KeyEvent.VK_BACK_SPACE) {
return;
}
 
// pas plus de 2 chiffres apres la virgule
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;
} else {
if (textField.getText().substring(pointPosition).length() <= 2) {
return;
}
}
} else {
return;
}
} else {
return;
}
}
 
if (keychar == KeyEvent.VK_PERIOD && textField.getText().indexOf('.') < 0)
return;
 
if (keychar == '%' && (textField.getText().indexOf('%') < 0) && textField.getCaretPosition() > 0 && textField.getCaretPosition() == textField.getText().length())
return;
 
keyEvent.consume();
}
});
}
 
@Override
public final void resetValue() {
this.setValue((Acompte) null);
}
 
@Override
public void setValue(Acompte val) {
this.setValue(val == null ? "" : val.toString());
}
 
private final void setValue(String val) {
if (!this.getText().equals(val))
this.setText(val);
}
 
public void setBold() {
this.setFont(getFont().deriveFont(Font.BOLD));
}
 
@Override
public String toString() {
return this.getClass().getSimpleName();
}
 
@Override
public Acompte getValue() {
return Acompte.fromString(this.getText().trim());
}
 
@Override
public void addValueListener(PropertyChangeListener l) {
this.supp.addPropertyChangeListener(l);
}
 
@Override
public void rmValueListener(PropertyChangeListener l) {
this.supp.removePropertyChangeListener(l);
}
 
public SQLField getField() {
return this.field;
}
 
@Override
public ValidState getValidState() {
// TODO
// return "La valeur saisie n'est pas correcte";
return ValidState.getTrueInstance();
}
 
@Override
public void addValidListener(ValidListener l) {
// FIXME
}
 
@Override
public void removeValidListener(ValidListener l) {
// FIXME
}
 
@Override
public JComponent getComp() {
return this;
}
 
public String getDocId() {
return "ACOMPTE";
}
 
public String getGenericDoc() {
return "";
}
 
public boolean onScreen() {
return true;
}
 
public boolean isDocTransversable() {
return false;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AcompteCellEditor.java
New file
0,0 → 1,74
/*
* 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.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
 
import java.awt.Component;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.EventObject;
 
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
 
public class AcompteCellEditor extends AbstractCellEditor implements TableCellEditor {
 
private AcompteField acompteField;
 
private String fieldNamePercent, fieldNameMontant;
 
public AcompteCellEditor(String fieldNamePercent, String fieldNameMontant) {
super();
 
this.acompteField = new AcompteField();
this.fieldNamePercent = fieldNamePercent;
this.fieldNameMontant = fieldNameMontant;
}
 
public void addKeyListener(KeyListener l) {
this.acompteField.addKeyListener(l);
}
 
public boolean isCellEditable(EventObject e) {
 
if (e instanceof MouseEvent) {
return ((MouseEvent) e).getClickCount() >= 2;
}
return super.isCellEditable(e);
}
 
public Object getCellEditorValue() {
 
return this.acompteField.getValue();
}
 
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
RowValuesTable rowValuesTable = ((RowValuesTable) table);
SQLRowValues rowVals = rowValuesTable.getRowValuesTableModel().getRowValuesAt(row);
 
BigDecimal montant = rowVals.getBigDecimal(this.fieldNameMontant);
BigDecimal percent = rowVals.getBigDecimal(this.fieldNamePercent);
 
Acompte a = new Acompte(percent, montant);
 
this.acompteField.setValue(a);
this.acompteField.grabFocus();
return this.acompteField;
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractVenteArticleItemTable.java
28,6 → 28,7
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
37,8 → 38,8
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Component;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
50,8 → 51,12
import java.util.Vector;
 
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
 
public abstract class AbstractVenteArticleItemTable extends AbstractArticleItemTable {
67,6 → 72,79
super(buttons);
}
 
SQLTableElement tableElementFacturable;
 
public void calculPourcentage(final Acompte a) {
Runnable r = new Runnable() {
 
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
if (a == null) {
for (int i = 0; i < model.getRowCount(); i++) {
model.putValue(null, i, "POURCENT_FACTURABLE");
model.putValue(null, i, "MONTANT_FACTURABLE");
tableElementFacturable.fireModification(model.getRowValuesAt(i));
}
} else if (a.getPercent() != null) {
for (int i = 0; i < model.getRowCount(); i++) {
model.putValue(a.getPercent(), i, "POURCENT_FACTURABLE");
model.putValue(null, i, "MONTANT_FACTURABLE");
tableElementFacturable.fireModification(model.getRowValuesAt(i));
}
} else {
// FIXME repartition du montant sur chaque ligne
BigDecimal totalHT = BigDecimal.ZERO;
for (int i = 0; i < model.getRowCount(); i++) {
SQLRowValues rowVals = model.getRowValuesAt(i);
int qte = rowVals.getInt("QTE");
BigDecimal qteU = rowVals.getBigDecimal("QTE_UNITAIRE");
BigDecimal pU = rowVals.getBigDecimal("PV_HT");
 
BigDecimal totalLine = pU.multiply(qteU, MathContext.DECIMAL128).multiply(new BigDecimal(qte), MathContext.DECIMAL128).setScale(2, RoundingMode.HALF_UP);
 
BigDecimal lremise = rowVals.getBigDecimal("POURCENT_REMISE");
 
if (lremise.compareTo(BigDecimal.ZERO) > 0 && lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
totalLine = totalLine.multiply(BigDecimal.valueOf(100).subtract(lremise), MathContext.DECIMAL128).movePointLeft(2);
}
 
totalHT = totalHT.add(totalLine);
}
 
for (int i = 0; i < model.getRowCount(); i++) {
model.putValue(null, i, "POURCENT_FACTURABLE");
SQLRowValues rowVals = model.getRowValuesAt(i);
int qte = rowVals.getInt("QTE");
BigDecimal qteU = rowVals.getBigDecimal("QTE_UNITAIRE");
BigDecimal pU = rowVals.getBigDecimal("PV_HT");
 
BigDecimal totalLine = pU.multiply(qteU, MathContext.DECIMAL128).multiply(new BigDecimal(qte), MathContext.DECIMAL128).setScale(2, RoundingMode.HALF_UP);
 
BigDecimal lremise = rowVals.getBigDecimal("POURCENT_REMISE");
 
if (lremise.compareTo(BigDecimal.ZERO) > 0 && lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
totalLine = totalLine.multiply(BigDecimal.valueOf(100).subtract(lremise), MathContext.DECIMAL128).movePointLeft(2);
}
 
BigDecimal percent = totalLine.divide(totalHT, MathContext.DECIMAL128);
 
model.putValue(a.getMontant().multiply(percent, MathContext.DECIMAL128).setScale(6, RoundingMode.HALF_UP), i, "MONTANT_FACTURABLE");
tableElementFacturable.fireModification(model.getRowValuesAt(i));
}
}
model.fireTableDataChanged();
}
});
}
};
model.submit(r);
 
}
 
private static Map<String, Boolean> visibilityMap = new HashMap<String, Boolean>();
 
public static Map<String, Boolean> getVisibilityMap() {
291,14 → 369,72
this.tableElementTVA.setPreferredSize(20);
list.add(this.tableElementTVA);
// Poids piece
SQLTableElement tableElementPoids = new SQLTableElement(e.getTable().getField("POIDS"), Float.class);
SQLTableElement tableElementPoids = new SQLTableElement(e.getTable().getField("POIDS"), Float.class) {
protected Object getDefaultNullValue() {
return 0F;
}
 
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
tableElementPoids.setPreferredSize(20);
list.add(tableElementPoids);
 
// Poids total
this.tableElementPoidsTotal = new SQLTableElement(e.getTable().getField("T_POIDS"), Float.class);
this.tableElementPoidsTotal = new SQLTableElement(e.getTable().getField("T_POIDS"), Float.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
};
this.tableElementPoidsTotal.setEditable(false);
list.add(this.tableElementPoidsTotal);
 
// Packaging
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
 
SQLTableElement poidsColis = new SQLTableElement(e.getTable().getField("POIDS_COLIS_NET"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
list.add(poidsColis);
 
SQLTableElement nbColis = new SQLTableElement(e.getTable().getField("NB_COLIS"), Integer.class);
list.add(nbColis);
 
final SQLTableElement totalPoidsColis = new SQLTableElement(e.getTable().getField("T_POIDS_COLIS_NET"), BigDecimal.class) {
@Override
public TableCellRenderer getTableCellRenderer() {
return new QteUnitRowValuesRenderer();
}
 
};
list.add(totalPoidsColis);
 
poidsColis.addModificationListener(totalPoidsColis);
nbColis.addModificationListener(totalPoidsColis);
totalPoidsColis.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(final SQLRowValues row) {
final Object o2 = row.getObject("POIDS_COLIS_NET");
final Object o3 = row.getObject("NB_COLIS");
if (o2 != null && o3 != null) {
BigDecimal poids = (BigDecimal) o2;
int nb = (Integer) o3;
return poids.multiply(new BigDecimal(nb), MathContext.DECIMAL128).setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
} else {
return row.getObject("T_POIDS_COLIS_NET");
}
}
});
 
}
 
// Service
if (DefaultNXProps.getInstance().getBooleanValue(ARTICLE_SERVICE, false)) {
this.service = new SQLTableElement(e.getTable().getField("SERVICE"), Boolean.class);
308,11 → 444,41
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"));
list.add(tableElementAcompte);
tableElementAcompte.addModificationListener(this.totalHT);
if (e.getTable().getFieldsName().contains("MONTANT_FACTURABLE")) {
// SQLTableElement tableElementAcompte = new
// SQLTableElement(e.getTable().getField("POURCENT_ACOMPTE"));
// list.add(tableElementAcompte);
 
this.tableElementFacturable = new SQLTableElement(e.getTable().getField("POURCENT_FACTURABLE"), Acompte.class, new AcompteCellEditor("POURCENT_FACTURABLE", "MONTANT_FACTURABLE")) {
@Override
public void setValueFrom(SQLRowValues row, Object value) {
 
if (value != null) {
Acompte a = (Acompte) value;
row.put("MONTANT_FACTURABLE", a.getMontant());
row.put("POURCENT_FACTURABLE", a.getPercent());
} else {
row.put("MONTANT_FACTURABLE", null);
row.put("POURCENT_FACTURABLE", BigDecimal.ONE.movePointRight(2));
}
fireModification(row);
}
};
tableElementFacturable.setRenderer(new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
SQLRowValues rowVals = ((RowValuesTable) table).getRowValuesTableModel().getRowValuesAt(row);
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
BigDecimal percent = rowVals.getBigDecimal("POURCENT_FACTURABLE");
BigDecimal amount = rowVals.getBigDecimal("MONTANT_FACTURABLE");
Acompte a = new Acompte(percent, amount);
label.setText(a.toString());
return label;
}
});
tableElementFacturable.addModificationListener(this.totalHT);
list.add(tableElementFacturable);
}
 
final SQLField field2 = e.getTable().getField("POURCENT_REMISE");
SQLTableElement tableElementRemise = new SQLTableElement(field2);
354,12 → 520,11
 
BigDecimal ha = (BigDecimal) row.getObject("T_PA_HT");
 
final Object o = row.getObject("POURCENT_ACOMPTE");
BigDecimal lA = (o == null) ? BigDecimal.valueOf(100) : ((BigDecimal) o);
if (lA.compareTo(BigDecimal.ZERO) >= 0 && lA.compareTo(BigDecimal.valueOf(100)) < 0) {
ha = ha.multiply(lA, MathContext.DECIMAL128).movePointLeft(2);
vt = vt.multiply(lA, MathContext.DECIMAL128).movePointLeft(2);
}
final BigDecimal acomptePercent = row.getBigDecimal("POURCENT_FACTURABLE");
final BigDecimal acompteMontant = row.getBigDecimal("MONTANT_FACTURABLE");
Acompte acompte = new Acompte(acomptePercent, acompteMontant);
ha = acompte.getResultFrom(ha);
vt = acompte.getResultFrom(vt);
 
return vt.subtract(ha).setScale(marge.getDecimalDigits(), RoundingMode.HALF_UP);
}
384,13 → 549,11
 
BigDecimal ha = row.getObject("PREBILAN") == null ? BigDecimal.ZERO : (BigDecimal) row.getObject("PREBILAN");
 
final Object o = row.getObject("POURCENT_ACOMPTE");
BigDecimal lA = (o == null) ? BigDecimal.valueOf(100) : ((BigDecimal) o);
if (lA.compareTo(BigDecimal.ZERO) >= 0 && lA.compareTo(BigDecimal.valueOf(100)) <= 100) {
ha = ha.multiply(lA, MathContext.DECIMAL128).movePointLeft(2);
vt = vt.multiply(lA, MathContext.DECIMAL128).movePointLeft(2);
}
 
final BigDecimal acomptePercent = row.getBigDecimal("POURCENT_FACTURABLE");
final BigDecimal acompteMontant = row.getBigDecimal("MONTANT_FACTURABLE");
Acompte acompte = new Acompte(acomptePercent, acompteMontant);
ha = acompte.getResultFrom(ha);
vt = acompte.getResultFrom(vt);
return vt.subtract(ha).setScale(marge.getDecimalDigits(), RoundingMode.HALF_UP);
}
 
410,7 → 573,9
this.tableElementTotalTTC.setEditable(false);
list.add(this.tableElementTotalTTC);
 
this.model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"));
SQLRowValues defautRow = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
defautRow.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
this.model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, defautRow);
 
this.table = new RowValuesTable(this.model, getConfigurationFile());
ToolTipManager.sharedInstance().unregisterComponent(this.table);
559,16 → 724,16
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
BigDecimal f = (BigDecimal) row.getObject("PV_HT");
BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), MathContext.DECIMAL128), MathContext.DECIMAL128);
if (row.getTable().getFieldsName().contains("POURCENT_ACOMPTE")) {
final Object o = row.getObject("POURCENT_ACOMPTE");
BigDecimal lA = (o == null) ? BigDecimal.ZERO : ((BigDecimal) o);
if (lA.compareTo(BigDecimal.ZERO) >= 0 && lA.compareTo(BigDecimal.valueOf(100)) <= 0) {
r = r.multiply(lA, MathContext.DECIMAL128).movePointLeft(2);
}
}
if (lremise.compareTo(BigDecimal.ZERO) > 0 && lremise.compareTo(BigDecimal.valueOf(100)) < 100) {
r = r.multiply(BigDecimal.valueOf(100).subtract(lremise), MathContext.DECIMAL128).movePointLeft(2);
}
if (row.getTable().getFieldsName().contains("POURCENT_FACTURABLE")) {
final BigDecimal acomptePercent = row.getBigDecimal("POURCENT_FACTURABLE");
final BigDecimal acompteMontant = row.getBigDecimal("MONTANT_FACTURABLE");
Acompte acompte = new Acompte(acomptePercent, acompteMontant);
r = acompte.getResultFrom(r);
}
 
return r.setScale(totalHT.getDecimalDigits(), BigDecimal.ROUND_HALF_UP);
}
});
586,7 → 751,9
if (DefaultNXProps.getInstance().getBooleanValue(ARTICLE_SHOW_DEVISE, false)) {
this.qte.addModificationListener(tableElementTotalDevise);
qteU.addModificationListener(tableElementTotalDevise);
if (eltUnitDevise != null) {
eltUnitDevise.addModificationListener(tableElementTotalDevise);
}
tableElementRemise.addModificationListener(this.tableElementTotalDevise);
tableElementTotalDevise.setModifier(new CellDynamicModifier() {
@Override
619,16 → 786,10
Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
 
if (resultTaux == null) {
System.err.println("Taxe par défaut non valide");
Thread.dumpStack();
Integer i = TaxeCache.getCache().getFirstTaxe();
if (i == null) {
ExceptionHandler.handle("Aucune taxe définie!");
} else {
row.put("ID_TAXE", i);
resultTaux = TaxeCache.getCache().getTauxFromId(i.intValue());
SQLRow rowTax = TaxeCache.getCache().getFirstTaxe();
row.put("ID_TAXE", rowTax.getID());
resultTaux = rowTax.getFloat("TAUX");
}
}
 
float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
editorPVHT.setTaxe(taux);
657,6 → 818,9
this.tableElementPoidsTotal.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(SQLRowValues row) {
Number f = (Number) row.getObject("POIDS");
if (f == null) {
f = 0;
}
int qte = Integer.parseInt(row.getObject("QTE").toString());
BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
// FIXME convertir en float autrement pour éviter une valeur non valeur transposable
678,15 → 842,13
 
});
if (DefaultNXProps.getInstance().getBooleanValue(ARTICLE_SHOW_DEVISE, false)) {
if (eltUnitDevise != null) {
eltUnitDevise.addModificationListener(tableElement_PrixMetrique1_VenteHT);
}
tableElement_PrixMetrique1_VenteHT.setModifier(new CellDynamicModifier() {
public Object computeValueFrom(SQLRowValues row) {
if (!row.getForeign("ID_DEVISE").isUndefined()) {
 
// return Long.valueOf(((Number)
// row.getObject("PRIX_METRIQUE_VT_1")).longValue());
BigDecimal t = (BigDecimal) row.getForeign("ID_DEVISE").getObject("TAUX");
 
BigDecimal bigDecimal = (BigDecimal) row.getObject("PV_U_DEVISE");
return (t.equals(BigDecimal.ZERO) ? row.getObject("PRIX_METRIQUE_VT_1") : bigDecimal.multiply(t));
}
736,6 → 898,11
 
setColumnVisible(this.model.getColumnForField("T_PA_HT"), true);
 
// Packaging
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
setColumnVisible(this.model.getColumnForField("T_POIDS_COLIS_NET"), false);
}
 
// Mode Gestion article avancé
final boolean modeAvance = DefaultNXProps.getInstance().getBooleanValue("ArticleModeVenteAvance", false);
setColumnVisible(this.model.getColumnForField("VALEUR_METRIQUE_1"), modeAvance);
761,7 → 928,7
 
// Voir le style
setColumnVisible(this.model.getColumnForField("ID_STYLE"), DefaultNXProps.getInstance().getBooleanValue("ArticleShowStyle", true));
setColumnVisible(this.model.getColumnForField("POURCENT_ACOMPTE"), false);
setColumnVisible(this.model.getColumnForField("POURCENT_FACTURABLE"), false);
 
 
for (String string : visibilityMap.keySet()) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseNumericHTConvertorCellEditor.java
13,7 → 13,9
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.erp.config.Log;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.utils.StringUtils;
 
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
45,15 → 47,20
 
public void actionPerformed(ActionEvent e) {
 
String s = textField.getText().trim();
String s = StringUtils.removeNonDecimalChars(textField.getText());
if (s.length() > 0) {
try {
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());
} catch (Exception ex) {
Log.get().info("Cannot substract tax from " + s + " for tax " + taxe);
ex.printStackTrace();
}
}
}
});
menuDroit.pack();
menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/NumericFormat.java
New file
0,0 → 1,25
/*
* 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 java.text.DecimalFormat;
 
public class NumericFormat {
 
public static DecimalFormat getQtyDecimalFormat(){
return new DecimalFormat("##,##0.######");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseTableCellRenderer.java
43,10 → 43,15
if (table.getColumnClass(column) != BigDecimal.class) {
throw new IllegalStateException("Value is not a BigDecimal :" + table.getColumnClass(column));
}
if (value != null) {
if (((BigDecimal) value).compareTo(oneCents) < 0)
this.setText(decimalFormat2.format(value));
else
this.setText(decimalFormat.format(value));
} else {
this.setText("");
}
 
return this;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCalculatorParameters.java
99,6 → 99,7
final SQLRowValues rowValsF = new SQLRowValues(familleArticleTable);
rowValsF.put("NOM", null);
rowValsF.put("ID", null);
rowValsF.put("ID_FAMILLE_ARTICLE_PERE", null);
rowValsF.put("ID_COMPTE_PCE", rowValsC2);
 
final SQLRowValues rowVals = new SQLRowValues(articleTable);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AcompteRowItemView.java
New file
0,0 → 1,60
/*
* 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 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;
 
import java.math.BigDecimal;
 
public class AcompteRowItemView extends VWRowItemView<Acompte> {
 
public AcompteRowItemView(ValueWrapper<Acompte> 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())) {
BigDecimal montant = r.getBigDecimal(getFields().get(0).getName());
BigDecimal percent = r.getBigDecimal(getFields().get(1).getName());
 
Acompte a = new Acompte(percent, montant);
this.getWrapper().setValue(a);
}
}
 
public void update(SQLRowValues vals) {
vals.put(getFields().get(0).getName(), this.isEmpty() ? SQLRowValues.SQL_DEFAULT : this.getWrapper().getValue().getMontant());
vals.put(getFields().get(1).getName(), this.isEmpty() ? SQLRowValues.SQL_DEFAULT : this.getWrapper().getValue().getPercent());
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/PreviewFrame.java
18,6 → 18,7
import java.io.File;
 
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
 
import org.jopendocument.model.OpenDocument;
import org.jopendocument.panel.ODSViewerPanel;
25,11 → 26,9
 
public class PreviewFrame extends JFrame {
 
private PreviewFrame(File file) {
super();
final OpenDocument doc = new OpenDocument(file);
private PreviewFrame(OpenDocument doc, String title) {
super(title);
this.setContentPane(new ODSViewerPanel(doc, new DefaultXMLDocumentPrinter()));
this.setTitle(file.getName());
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
this.setMaximizedBounds(ge.getMaximumWindowBounds());
Dimension maxD = ge.getMaximumWindowBounds().getSize();
48,8 → 47,19
this.setLocationRelativeTo(null);
}
 
public static void show(File f) {
new PreviewFrame(f).setVisible(true);
public static void show(File file) {
final OpenDocument doc = new OpenDocument(file);
final String title = file.getName();
if (SwingUtilities.isEventDispatchThread()) {
new PreviewFrame(doc, title).setVisible(true);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new PreviewFrame(doc, title).setVisible(true);
}
});
}
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCalculator.java
37,7 → 37,7
private static String FIELD_POIDS = "T_POIDS";
private final String fieldHT, fieldHA, fieldDevise;
 
private SQLRowAccessor rowDefaultCptProduit, rowDefaultCptService, rowDefaultCptTVA;
private SQLRowAccessor rowDefaultCptProduit, rowDefaultCptService, rowDefaultCptTVACollecte, rowDefaultCptTVADeductible, rowDefaultCptAchat;
private static final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
 
48,6 → 48,7
private BigDecimal totalService, totalServiceSel;
private BigDecimal totalTTC, totalTTCSel;
private long remiseHT, remiseRestante;
private final boolean achat;
 
// Total des HT par comptes
private Map<SQLRowAccessor, BigDecimal> mapHt = new HashMap<SQLRowAccessor, BigDecimal>();
61,9 → 62,13
private Boolean bServiceActive;
private BigDecimal totalHTAvantRemise;
 
// TODO Gestion des achats
public TotalCalculator(String fieldHA, String fieldHT, String fieldDeviseTotal) {
this(fieldHA, fieldHT, fieldDeviseTotal, false, null);
}
 
public TotalCalculator(String fieldHA, String fieldHT, String fieldDeviseTotal, boolean achat, SQLRowAccessor defaultCompte) {
 
this.achat = achat;
initValues();
 
this.fieldDevise = fieldDeviseTotal;
89,17 → 94,39
}
}
 
this.rowDefaultCptTVA = rowPrefsCompte.getForeign("ID_COMPTE_PCE_TVA_VENTE");
if (this.rowDefaultCptTVA == null || this.rowDefaultCptTVA.isUndefined()) {
this.rowDefaultCptTVACollecte = rowPrefsCompte.getForeign("ID_COMPTE_PCE_TVA_VENTE");
if (this.rowDefaultCptTVACollecte == null || this.rowDefaultCptTVACollecte.isUndefined()) {
try {
this.rowDefaultCptTVA = ComptePCESQLElement.getRowComptePceDefault("TVACollectee");
this.rowDefaultCptTVACollecte = ComptePCESQLElement.getRowComptePceDefault("TVACollectee");
} catch (Exception e) {
e.printStackTrace();
}
}
 
this.rowDefaultCptTVADeductible = rowPrefsCompte.getForeign("ID_COMPTE_PCE_TVA_ACHAT");
if (this.rowDefaultCptTVADeductible == null || this.rowDefaultCptTVADeductible.isUndefined()) {
try {
this.rowDefaultCptTVADeductible = ComptePCESQLElement.getRowComptePceDefault("TVADeductible");
} catch (Exception e) {
e.printStackTrace();
}
}
 
if (defaultCompte == null || defaultCompte.isUndefined()) {
this.rowDefaultCptAchat = rowPrefsCompte.getForeign("ID_COMPTE_PCE_ACHAT");
if (this.rowDefaultCptAchat == null || this.rowDefaultCptAchat.isUndefined()) {
try {
this.rowDefaultCptAchat = ComptePCESQLElement.getRowComptePceDefault("Achats");
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
this.rowDefaultCptAchat = defaultCompte;
}
 
}
 
/**
* Définition d'une remise HT à appliquer
*
177,8 → 204,13
rowValsC1.put("NUMERO", null);
rowValsC1.put("ID", null);
 
SQLRowValues rowValsC2 = new SQLRowValues(compteTable);
rowValsC2.put("NUMERO", null);
rowValsC2.put("ID", null);
 
rowVals.put(tvaTable.getKey().getName(), null);
rowVals.put("ID_COMPTE_PCE", rowValsC1);
rowVals.put("ID_COMPTE_PCE_DED", rowValsC2);
 
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
List<SQLRowValues> rowValsList = fetch.fetch();
203,10 → 235,18
}
 
if (tva != null && !tva.isUndefined()) {
SQLRowAccessor rowCptTva = tva.getForeign("ID_COMPTE_PCE");
SQLRowAccessor rowCptTva;
if (this.achat) {
rowCptTva = tva.getForeign("ID_COMPTE_PCE_DED");
if (rowCptTva == null || rowCptTva.isUndefined()) {
rowCptTva = this.rowDefaultCptTVA;
rowCptTva = this.rowDefaultCptTVADeductible;
}
} else {
rowCptTva = tva.getForeign("ID_COMPTE_PCE");
if (rowCptTva == null || rowCptTva.isUndefined()) {
rowCptTva = this.rowDefaultCptTVACollecte;
}
}
if (mapHtTVA.get(rowCptTva) == null) {
mapHtTVA.put(rowCptTva, totalTVA);
} else {
288,9 → 328,10
}
}
 
SQLRowAccessor cpt = this.rowDefaultCptProduit;
SQLRowAccessor cpt = (achat ? this.rowDefaultCptAchat : this.rowDefaultCptProduit);
if (article != null && !article.isUndefined()) {
SQLRowAccessor compteArticle = article.getForeign("ID_COMPTE_PCE");
String suffix = (this.achat ? "_ACHAT" : "");
SQLRowAccessor compteArticle = article.getForeign("ID_COMPTE_PCE" + suffix);
if (compteArticle != null && !compteArticle.isUndefined()) {
cpt = compteArticle;
} else {
299,7 → 340,7
while (familleArticle != null && !familleArticle.isUndefined() && !unique.contains(familleArticle)) {
 
unique.add(familleArticle);
SQLRowAccessor compteFamilleArticle = familleArticle.getForeign("ID_COMPTE_PCE");
SQLRowAccessor compteFamilleArticle = familleArticle.getForeign("ID_COMPTE_PCE" + suffix);
if (compteFamilleArticle != null && !compteFamilleArticle.isUndefined()) {
cpt = compteFamilleArticle;
break;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractAchatArticleItemTable.java
25,6 → 25,7
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
217,8 → 218,11
this.tableElementTotalTTC.setRenderer(new DeviseTableCellRenderer());
list.add(this.tableElementTotalTTC);
 
this.model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, null);
SQLRowValues defautRow = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
defautRow.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
 
this.model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, defautRow);
 
this.table = new RowValuesTable(this.model, getConfigurationFile());
ToolTipManager.sharedInstance().unregisterComponent(this.table);
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/MontantPanel.java
186,7 → 186,7
}
 
private void setHT(boolean b) {
 
System.err.println("MontantPanel.setHT()" + b);
if (b) {
this.textHT.setEditable(true);
this.textHT.setEnabled(true);
213,8 → 213,8
int idTaxe = this.comboTaxe.getSelectedId();
System.out.println("ID_TAXE = " + idTaxe);
if (idTaxe > 1) {
SQLRow ligneTaxe = SQLBackgroundTableCache.getInstance().getCacheForTable(((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("TAXE")).getRowFromId(
idTaxe);
SQLRow ligneTaxe = SQLBackgroundTableCache.getInstance().getCacheForTable(((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("TAXE"))
.getRowFromId(idTaxe);
taux = (ligneTaxe.getFloat("TAUX")) / 100.0F;
 
// calcul des montants HT ou TTC
222,9 → 222,13
 
if (this.textHT.getText().trim().length() > 0) {
pHT = new PrixHT(0);
try {
if (!this.textHT.getText().trim().equals("-")) {
pHT = new PrixHT(GestionDevise.parseLongCurrency(this.textHT.getText()));
}
} catch (Exception e) {
// text is not corret, default to 0
}
// affichage
String tva = GestionDevise.currencyToString(pHT.calculLongTVA(taux));
 
234,18 → 238,21
} else {
ttc = GestionDevise.currencyToString(pHT.calculLongTTC(taux));
}
updateText(tva, ttc, pHT.toString(), false);
updateText(tva, ttc, pHT.toString(), true);
} else
updateText("", "", "", false);
updateText("", "", "", true);
} else {
 
if (this.textTTC.getText().trim().length() > 0) {
 
pTTC = new PrixTTC(0);
try {
if (!this.textTTC.getText().trim().equals("-")) {
pTTC = new PrixTTC(GestionDevise.parseLongCurrency(this.textTTC.getText()));
}
 
} catch (Exception e) {
// text is not corret, default to 0
}
String tva;
// affichage
if (this.ue) {
260,15 → 267,15
} else {
ht = GestionDevise.currencyToString(pTTC.calculLongHT(taux));
}
updateText(tva, pTTC.toString(), ht, true);
updateText(tva, pTTC.toString(), ht, false);
} else
updateText("", "", "", true);
updateText("", "", "", false);
}
}
}
}
 
private void updateText(final String prixTVA, final String prixTTC, final String prixHT, final boolean HT) {
private void updateText(final String prixTVA, final String prixTTC, final String prixHT, final boolean isHT) {
SwingUtilities.invokeLater(new Runnable() {
 
public void run() {
275,13 → 282,14
MontantPanel.this.textHT.getDocument().removeDocumentListener(MontantPanel.this.listenerTextHT);
MontantPanel.this.textTTC.getDocument().removeDocumentListener(MontantPanel.this.listenerTextTTC);
 
if (HT) {
// Update text with formated values
if (!isHT) {
MontantPanel.this.textHT.setText(prixHT);
} else {
MontantPanel.this.textTTC.setText(prixTTC);
}
MontantPanel.this.textTaxe.setText(prixTVA);
 
setHT(isHT);
MontantPanel.this.textHT.getDocument().addDocumentListener(MontantPanel.this.listenerTextHT);
MontantPanel.this.textTTC.getDocument().addDocumentListener(MontantPanel.this.listenerTextTTC);
}
292,24 → 300,18
this.enabled = b;
this.checkHT.setEnabled(b);
this.checkTTC.setEnabled(b);
this.textHT.setEnabled(b);
this.textTTC.setEnabled(b);
this.textTaxe.setEnabled(b);
this.comboTaxe.setEnabled(b);
this.setHT(checkHT.isSelected());
}
 
public DeviseField getMontantTTC() {
 
return this.textTTC;
}
 
public DeviseField getMontantHT() {
 
return this.textHT;
}
 
public DeviseField getMontantTVA() {
 
return this.textTaxe;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalPanel.java
193,7 → 193,7
c.gridx = 1;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(getLabelBoldFor(textTotalHT.getField()), c);
this.add(getLabelBoldFor(textTotalHT.getField(), "Total HT"), c);
 
c.gridx++;
c.weightx = 1;
214,7 → 214,7
c.gridx = 1;
c.gridy++;
c.weightx = 0;
this.add(getLabelFor(textTotalTVA.getField()), c);
this.add(getLabelFor(textTotalTVA.getField(), "Total TVA"), c);
c.gridx++;
c.weightx = 1;
this.add(this.textTotalTVASel, c);
232,7 → 232,7
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(getLabelFor(textTotalDevise.getField()), c);
this.add(getLabelFor(textTotalDevise.getField(), "Total Devise"), c);
c.gridx++;
c.weightx = 1;
this.add(this.textTotalDeviseSel, c);
243,7 → 243,7
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(getLabelFor(textTotalTTC.getField()), c);
this.add(getLabelFor(textTotalTTC.getField(), "Total TTC"), c);
c.gridx++;
c.weightx = 1;
this.add(this.textTotalTTCSel, c);
304,7 → 304,7
c.gridy++;
c.gridx = 4;
c.weightx = 0;
this.add(getLabelBoldFor(textTotalHT.getField()), c);
this.add(getLabelBoldFor(textTotalHT.getField(), "Total HT"), c);
 
c.gridx++;
c.weightx = 1;
324,7 → 324,7
c.gridx = 4;
c.gridy++;
c.weightx = 0;
this.add(getLabelBoldFor(textTotalTVA.getField()), c);
this.add(getLabelBoldFor(textTotalTVA.getField(), "Total TVA"), c);
c.gridx++;
c.weightx = 1;
this.add(textTotalTVA, c);
344,7 → 344,7
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(getLabelBoldFor(textTotalDevise.getField()), c);
this.add(getLabelBoldFor(textTotalDevise.getField(), "Total Devise"), c);
c.gridx++;
c.weightx = 1;
textTotalDevise.setFont(textTotalHT.getFont());
356,7 → 356,7
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(getLabelBoldFor(textTotalTTC.getField()), c);
this.add(getLabelBoldFor(textTotalTTC.getField(), "Total TTC"), c);
c.gridx++;
c.weightx = 1;
textTotalTTC.setFont(textTotalHT.getFont());
371,6 → 371,12
});
}
 
private boolean achat = false;
 
public void setAchat(boolean b) {
this.achat = b;
}
 
private void reconfigure(JTextField field) {
field.setEditable(false);
field.setHorizontalAlignment(JTextField.RIGHT);
492,7 → 498,7
SQLTableElement tableElementTotalHT = articleTable.getPrixTotalHTElement();
String fieldHT = (tableElementTotalHT == null ? null : tableElementTotalHT.getField().getName());
 
final TotalCalculator calc = new TotalCalculator(fieldHA, fieldHT, fieldDevise);
final TotalCalculator calc = new TotalCalculator(fieldHA, fieldHT, fieldDevise, achat, null);
calc.setSelectedRows(selectedRows);
 
// Calcul avant remise
628,12 → 634,22
worker.execute();
}
 
private static final JLabel getLabelFor(SQLField field) {
public long getTotalHT() {
return GestionDevise.parseLongCurrency(this.textTotalHT.getText());
}
 
private static final JLabel getLabelFor(SQLField field, String defaultLabel) {
if (field == null) {
return new JLabel(defaultLabel);
}
return new JLabel(Configuration.getInstance().getTranslator().getLabelFor(field));
 
}
 
private static final JLabel getLabelBoldFor(SQLField field) {
private static final JLabel getLabelBoldFor(SQLField field, String defaultLabel) {
if (field == null) {
return new JLabelBold(defaultLabel);
}
return new JLabelBold(Configuration.getInstance().getTranslator().getLabelFor(field));
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/StatusPanel.java
13,6 → 13,7
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.sql.users.User;
import org.openconcerto.sql.users.UserManager;
 
import java.awt.GridLayout;
28,7 → 29,7
this.setOpaque(false);
this.setLayout(new GridLayout(1, 1));
this.add(this.l);
this.l.setText("Vous êtes connecté en tant que : " + UserManager.getInstance().getCurrentUser().getFullName());
this.fireStatusChanged();
}
 
public void setText(String text) {
44,6 → 45,12
}
 
public void fireStatusChanged() {
this.l.setText("Vous êtes connecté en tant que : " + UserManager.getInstance().getCurrentUser().getFullName());
final String txt;
final User user = UserManager.getUser();
if (user == null)
txt = "Pas d'utilisateurs";
else
txt = "Vous êtes connecté en tant que : " + user.getFullName();
this.l.setText(txt);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListFilterDatePanel.java
60,10 → 60,10
 
private EventListenerList listeners = new EventListenerList();
 
private final ActionListener listener = new ActionListener() {
private final PropertyChangeListener listener = new PropertyChangeListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
public void propertyChange(PropertyChangeEvent evt) {
combo.setSelectedItem(CUSTOM_COMBO_ITEM);
fireDateChanged();
}
245,8 → 245,8
this.add(this.dateDu, c);
this.add(new JLabel("Au"), c);
this.add(this.dateAu, c);
this.dateAu.addActionListener(this.listener);
this.dateDu.addActionListener(this.listener);
this.dateAu.addValueListener(this.listener);
this.dateDu.addValueListener(this.listener);
 
IListFilterDateStateManager stateManager = new IListFilterDateStateManager(this, getConfigFile(mapList), true);
stateManager.loadState();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseNumericCellEditor.java
14,6 → 14,7
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.utils.StringUtils;
 
import java.awt.Color;
import java.awt.Component;
108,6 → 109,7
try {
getCellEditorValue();
} catch (Exception e) {
e.printStackTrace();
this.textField.setBorder(new LineBorder(Color.RED));
return false;
}
126,8 → 128,9
}
 
public Object getCellEditorValue() {
if (this.textField.getText().trim().length() > 0) {
return new BigDecimal(this.textField.getText());
final String text = StringUtils.removeNonDecimalChars(this.textField.getText());
if (text.length() > 0) {
return new BigDecimal(text);
} else {
return BigDecimal.ZERO;
}
134,7 → 137,7
}
 
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
this.textField.setText((value == null ? "0" : ((BigDecimal) value).toString()));
this.textField.setText((value == null ? "0" : this.decimalFormat.format((BigDecimal) value)));
this.textField.selectAll();
this.textField.grabFocus();
return this.textField;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/JNiceButton.java
26,6 → 26,7
setBorderPainted(false);
setFocusPainted(false);
setOpaque(false);
setBorder(null);
setPreferredSize(new Dimension(20, 20));
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/component/TransfertGroupSQLComponent.java
New file
0,0 → 1,195
/*
* 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.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.GroupSQLComponent;
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.EditPanel.EditMode;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.group.Group;
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 TransfertGroupSQLComponent extends GroupSQLComponent {
protected SQLRowAccessor selectedRow;
private List<SQLRowValues> sourceRows;
 
public TransfertGroupSQLComponent(SQLElement element, Group group) {
super(element, group);
}
 
/**
* Chargement d'élément à partir d'une autre table ex : les éléments d'un BL dans une facture
*
* @param table ItemTable du component de destination (ex : tableFacture)
* @param elt element source (ex : BL)
* @param id id de la row source
* @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);
}
 
public void loadItem(AbstractArticleItemTable table, SQLElement elt, int id, SQLElement itemsElt, boolean clear) {
List<SQLRow> myListItem = elt.getTable().getRow(id).getReferentRows(itemsElt.getTable());
 
if (myListItem.size() != 0) {
SQLInjector injector = SQLInjector.getInjector(itemsElt.getTable(), table.getSQLElement().getTable());
if (clear) {
table.getModel().clearRows();
}
for (SQLRow rowElt : myListItem) {
 
SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(rowElt);
if (createRowValuesFrom.getTable().getFieldsName().contains("POURCENT_ACOMPTE")) {
if (createRowValuesFrom.getObject("POURCENT_ACOMPTE") == null) {
createRowValuesFrom.put("POURCENT_ACOMPTE", new BigDecimal(100.0));
}
}
table.getModel().addRow(createRowValuesFrom);
int rowIndex = table.getModel().getRowCount() - 1;
table.getModel().fireTableModelModified(rowIndex);
}
} else {
if (clear) {
table.getModel().clearRows();
table.getModel().addNewRowAt(0);
}
}
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, String groupID) {
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(destTableName);
final EditFrame editFrame = new EditFrame(elt.createComponent(groupID), EditMode.CREATION);
editFrame.setIconImage(new ImageIcon(Gestion.class.getResource("frameicon.png")).getImage());
final SQLComponent sqlComponent = editFrame.getSQLComponent();
if (sqlComponent instanceof TransfertGroupSQLComponent) {
final TransfertGroupSQLComponent comp = (TransfertGroupSQLComponent) 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
17,6 → 17,7
import org.openconcerto.map.ui.ITextComboVilleViewer;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.component.ITextArea;
23,7 → 24,10
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.Arrays;
import java.util.LinkedHashSet;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
62,8 → 66,9
this.add(textRue, c);
 
// Ville
final JLabel labelVille = new JLabel(getLabelFor("VILLE"), SwingConstants.RIGHT);
final ITextComboVilleViewer textVille = new ITextComboVilleViewer();
final VilleRowItemView villeRIV = new VilleRowItemView(new ITextComboVilleViewer());
villeRIV.init("VILLE", new LinkedHashSet<SQLField>(Arrays.asList(getField("CODE_POSTAL"), getField("VILLE"))));
final JLabel labelVille = new JLabel(getLabelFor(villeRIV.getSQLName()), SwingConstants.RIGHT);
c.gridy++;
c.gridx = 0;
c.weightx = 0;
74,8 → 79,8
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
DefaultGridBagConstraints.lockMinimumSize(textVille);
this.add(textVille, c);
DefaultGridBagConstraints.lockMinimumSize((JComponent) villeRIV.getComp());
this.add(villeRIV.getComp(), c);
 
// Cedex
final JLabel labelCedex = new JLabel(getLabelFor("CEDEX"), SwingConstants.RIGHT);
104,7 → 109,7
this.add(pays, c);
 
this.addSQLObject(textRue, "RUE");
this.addView(new VilleRowItemView(textVille), "CODE_POSTAL,VILLE", REQ);
this.addInitedView(villeRIV, REQ);
this.addView(cedex, "CEDEX");
this.addView(destinataire, "DEST");
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/component/SocieteCommonSQLElement.java
14,7 → 14,6
package org.openconcerto.erp.core.common.component;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.panel.ChargementCreationSocietePanel;
import org.openconcerto.sql.Configuration;
22,13 → 21,18
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.DBSystemRoot;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.graph.TablesMap;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FormLayouter;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.utils.CollectionMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
35,6 → 39,7
import java.awt.Insets;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
 
50,10 → 55,36
*/
public class SocieteCommonSQLElement extends ConfSQLElement {
 
private static final String TABLE_NAME = "SOCIETE_COMMON";
 
static public final DBRoot getRoot(final SQLRow company) {
try {
return getRoot(company, false);
} catch (SQLException e) {
// shouldn't happen since we don't allow refresh
throw new IllegalStateException(e);
}
}
 
static public final DBRoot getRoot(final SQLRow company, final boolean allowRefresh) throws SQLException {
final String rootName = company.getString("DATABASE_NAME");
final DBSystemRoot sysRoot = company.getTable().getDBSystemRoot();
if (allowRefresh && !sysRoot.contains(rootName)) {
sysRoot.addRootToMap(rootName);
sysRoot.refresh(TablesMap.createFromTables(rootName, Collections.singleton(TABLE_NAME)), true);
}
return sysRoot.getRoot(rootName);
}
 
public SocieteCommonSQLElement() {
super("SOCIETE_COMMON", "une société", "sociétés");
super(TABLE_NAME, "une société", "sociétés");
}
 
@Override
public CollectionMap<String, String> getShowAs() {
return CollectionMap.singleton(null, getListFields());
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
352,6 → 383,11
c.fill = GridBagConstraints.NONE;
this.add(panelPlan, c);
 
c.gridy++;
final JPanel additionalPanel = new JPanel();
this.add(additionalPanel, c);
this.setAdditionalFieldsPanel(new FormLayouter(additionalPanel, 2, 1));
 
this.addRequiredSQLObject(this.textNom, "NOM");
// this.addSQLObject(this.textAdresse, "ADRESSE");
this.addRequiredSQLObject(this.textNumAPE, "NUM_APE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/history/ui/ListeHistoriquePanel.java
25,6 → 25,7
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
55,6 → 56,7
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Vector;
 
61,6 → 63,7
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
126,7 → 129,18
 
Where w = null;
final SQLTable table = liste.getElement().getTable();
for (String key : ListeHistoriquePanel.this.whereList.keySet()) {
Where wTmp = ListeHistoriquePanel.this.whereList.get(key);
 
if (liste.getListe().getRequest().getAllFields().containsAll(wTmp.getFields())) {
if (w == null) {
w = wTmp;
} else {
w = w.and(wTmp);
}
}
}
 
if (id > 1) {
if (ListeHistoriquePanel.this.listFieldMap != null && ListeHistoriquePanel.this.listFieldMap.get(table) != null) {
SQLField field = ListeHistoriquePanel.this.listFieldMap.get(table);
237,7 → 251,7
protected void handleAction(JButton source, ActionEvent evt) {
 
if (elt.getTable().contains("ID_MOUVEMENT")) {
SQLRow row = getListe().getSelectedRow();
SQLRow row = getListe().fetchSelectedRow();
if (source == this.buttonModifier) {
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
} else {
354,11 → 368,10
}
});
 
this.jListePanel.addListSelectionListener(this.listListener);
this.addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
 
jListePanel.addListSelectionListener(listListener);
}
 
@Override
371,6 → 384,7
jListePanel.removeListSelectionListener(listListener);
}
});
 
}
 
public void selectIDinJList(int id) {
389,7 → 403,6
rend = new DeviseNiceTableCellRenderer();
}
for (int j = 0; j < table.getColumnCount(); j++) {
 
if (rend instanceof EtatDevisRenderer) {
table.getColumnModel().getColumn(j).setCellRenderer(rend);
} else {
440,7 → 453,6
if (liste != null) {
int size = liste.getRowCount();
listeIds = new ArrayList<Integer>(size);
 
for (int i = 0; i < size; i++) {
listeIds.add(liste.idFromIndex(i));
}
507,7 → 519,8
 
public IListPanel getIListePanelFromTableName(String tableName) {
IListPanel liste = null;
for (int i = 0; i < this.vectListePanel.size(); i++) {
final int size = this.vectListePanel.size();
for (int i = 0; i < size; i++) {
IListPanel listeTmp = this.vectListePanel.get(i);
// FIXME Null pointer Exception when client deleted
if (listeTmp != null) {
532,10 → 545,11
* @return -1 si la table n'est pas dans le vecteur
*/
private int getIndexFromTableName(String tableName) {
 
for (int i = 0; i < this.vectListePanel.size(); i++) {
IListPanel listeTmp = this.vectListePanel.get(i);
if (listeTmp.getListe().getModel().getTable().getName().equalsIgnoreCase(tableName)) {
final int size = this.vectListePanel.size();
for (int i = 0; i < size; i++) {
final IListPanel listeTmp = this.vectListePanel.get(i);
final String name = listeTmp.getListe().getModel().getTable().getName();
if (name.equalsIgnoreCase(tableName)) {
return i;
}
}
547,7 → 561,6
}
 
public void fireListesChanged() {
System.err.println("ListeHistoriquePanel.fireListesChanged()");
final int size = this.vectListePanel.size();
for (int i = 0; i < size; i++) {
final IListPanel listeTmp = this.vectListePanel.get(i);
558,27 → 571,4
 
}
 
// TODO Gestion de weakListener pour eviter de devoir supprimer les listeners pour le garbage
 
// public void addWeakListenerTable(TableModelListener listener, String tableName) {
// addListenerTable(new WeakListener(listener), tableName);
// }
//
// private final class WeakListener extends WeakReference<TableModelListener> implements
// TableModelListener {
// private WeakListener(TableModelListener referent) {
// super(referent);
// }
//
// @Override
// public void tableChanged(TableModelEvent e) {
//
// final TableModelListener l = this.get();
// if (l != null)
// l.tableChanged(e);
// // else
// //
// // this.rmListener_(this);
// }
// }
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/MouvementStockSQLElement.java
89,7 → 89,6
@Override
protected void archive(SQLRow row, boolean cutLinks) throws SQLException {
super.archive(row, cutLinks);
updateStock(Arrays.asList(row.getID()), true);
}
 
@Override
165,8 → 164,7
rowArticleAssocie = rowElt.getTable().getTable("ARTICLE").getRow(idArticle);
}
 
// FIXME Voir avec Guillaume Article déjà créé sans gestion de stock??
// if (rowArticleAssocie.getBoolean("GESTION_STOCK")) {
if (rowArticleAssocie.getBoolean("GESTION_STOCK")) {
 
// on crée un mouvement de stock pour chacun des articles
SQLElement eltMvtStock = Configuration.getInstance().getDirectory().getElement("MOUVEMENT_STOCK");
189,9 → 187,9
SQLRow row = rowVals.insert();
l.add(row.getID());
 
// }
}
}
}
final CollectionMap<SQLRow, List<SQLRowValues>> map = updateStock(l, false);
if (map.keySet().size() > 0 && !rowOrigin.getTable().getName().equalsIgnoreCase("TICKET_CAISSE")) {
if (!rowOrigin.getTable().contains("ID_TARIF")) {
282,20 → 280,23
String stockMin = props.getStringProperty("ArticleStockMin");
Boolean bStockMin = !stockMin.equalsIgnoreCase("false");
boolean gestionStockMin = (bStockMin == null || bStockMin.booleanValue());
if (!archive && rowArticle.getTable().getFieldsName().contains("QTE_MIN") && gestionStockMin && qteNvlle < rowArticle.getInt("QTE_MIN")) {
if (!archive && rowArticle.getTable().getFieldsName().contains("QTE_MIN") && gestionStockMin && rowArticle.getObject("QTE_MIN") != null && qteNvlle < rowArticle.getInt("QTE_MIN")) {
// final float qteShow = qteNvlle;
SQLInjector inj = SQLInjector.getInjector(rowArticle.getTable(), tableCmdElt);
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(rowArticle));
rowValsElt.put("ID_STYLE", 2);
final SQLRow unite = rowArticle.getForeign("ID_UNITE_VENTE");
final float qteElt = rowArticle.getInt("QTE_MIN") - qteNvlle;
if (unite.isUndefined() || unite.getBoolean("A_LA_PIECE")) {
rowValsElt.put("QTE", Math.round(rowArticle.getInt("QTE_MIN") - qteNvlle));
rowValsElt.put("QTE", Math.round(qteElt));
rowValsElt.put("QTE_UNITAIRE", BigDecimal.ONE);
} else {
rowValsElt.put("QTE_UNITAIRE", new BigDecimal(rowArticle.getInt("QTE_MIN") - qteNvlle));
rowValsElt.put("QTE", 1);
rowValsElt.put("QTE_UNITAIRE", new BigDecimal(qteElt));
}
rowValsElt.put("ID_TAXE", rowValsElt.getObject("ID_TAXE"));
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
rowValsElt.put("T_PA_HT", rowValsElt.getLong("PA_HT") * rowValsElt.getInt("QTE"));
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * qteElt);
rowValsElt.put("T_PA_HT", rowValsElt.getLong("PA_HT") * qteElt);
rowValsElt.put("T_PA_TTC", rowValsElt.getLong("T_PA_HT") * (rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0));
 
map.put(rowArticle.getForeignRow("ID_FOURNISSEUR"), rowValsElt);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/supplier/ui/ListeDesEcheancesFournPanel.java
13,13 → 13,18
package org.openconcerto.erp.core.supplychain.supplier.ui;
 
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.finance.payment.element.ReglerMontantSQLComponent;
import org.openconcerto.erp.core.supplychain.order.ui.ListPanelEcheancesFourn;
import org.openconcerto.erp.rights.ComptaUserRight;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
26,14 → 31,15
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.TableModelEvent;
42,7 → 48,6
public class ListeDesEcheancesFournPanel extends JPanel implements TableModelListener {
 
private ListPanelEcheancesFourn panelEcheances;
private EditFrame edit = null;
private JButton regler;
private SQLElement eltRegler = Configuration.getInstance().getDirectory().getElement("REGLER_MONTANT");
 
55,15 → 60,53
// PANEL AVEC LA LISTE DES ECHEANCES
c.weightx = 1;
c.weighty = 1;
c.gridwidth = 2;
c.gridwidth = 3;
c.fill = GridBagConstraints.BOTH;
this.add(this.panelEcheances, c);
 
// Bouton Encaisser
final IListe liste = this.panelEcheances.getListe();
IListFilterDatePanel datePanel = new IListFilterDatePanel(liste, liste.getRequest().getPrimaryTable().getField("DATE"), IListFilterDatePanel.getDefaultMap());
 
c.weighty = 0;
c.gridy++;
c.weightx = 1;
this.add(datePanel, c);
 
IListTotalPanel totalPanel = new IListTotalPanel(liste, Arrays.asList(this.panelEcheances.getElement().getTable().getField("MONTANT")));
 
c.weighty = 0;
c.gridy++;
c.anchor = GridBagConstraints.EAST;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
this.add(totalPanel, c);
 
c.anchor = GridBagConstraints.WEST;
c.gridx = 0;
c.gridy++;
c.gridwidth = 1;
 
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
c.weightx = 0;
final JCheckBox checkRegCompta = new JCheckBox("Voir les régularisations de comptabilité");
if (UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.MENU)) {
this.add(checkRegCompta, c);
}
 
checkRegCompta.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
panelEcheances.setShowRegCompta(checkRegCompta.isSelected());
 
}
});
 
// Bouton Encaisser
c.anchor = GridBagConstraints.EAST;
 
c.gridx++;
c.gridwidth = 1;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
74,19 → 117,58
this.regler.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent e) {
List<Integer> selectedIds = ListeDesEcheancesFournPanel.this.panelEcheances.getListe().getSelection().getSelectedIDs();
List<SQLRow> selectedRows = new ArrayList<SQLRow>(selectedIds.size());
int idCpt = -1;
int idFournisseur = -1;
boolean showMessage = false;
 
if (ListeDesEcheancesFournPanel.this.edit == null) {
String numeroFact = "";
for (Integer integer : selectedIds) {
final SQLRow row = ListeDesEcheancesFournPanel.this.panelEcheances.getListe().getSource().getPrimaryTable().getRow(integer);
selectedRows.add(row);
 
ListeDesEcheancesFournPanel.this.edit = new EditFrame(eltRegler);
String nom = row.getForeignRow("ID_MOUVEMENT").getForeignRow("ID_PIECE").getString("NOM");
numeroFact += " " + nom;
 
SQLRow rowFournisseur = row.getForeignRow("ID_FOURNISSEUR");
int idTmp = rowFournisseur.getInt("ID_COMPTE_PCE");
int idCliTmp = rowFournisseur.getID();
if (idCpt > -1 && idCpt != idTmp) {
JOptionPane.showMessageDialog(null, "Impossible d'effectuer un encaissement sur plusieurs factures ayant des fournisseurs avec des comptes différents.");
return;
} else {
idCpt = idTmp;
}
 
SQLRowValues rowVals = new SQLRowValues(eltRegler.getTable());
if (idFournisseur > -1 && idFournisseur != idCliTmp) {
showMessage = true;
} else {
idFournisseur = idCliTmp;
}
}
if (showMessage) {
int answer = JOptionPane.showConfirmDialog(null, "Attention vous avez sélectionné des factures ayant des fournisseurs différents. Voulez vous continuer?");
if (answer != JOptionPane.YES_OPTION) {
return;
}
 
rowVals.put("ID_ECHEANCE_FOURNISSEUR", ListeDesEcheancesFournPanel.this.panelEcheances.getListe().getSelectedId());
}
SQLElement encaisseElt = Configuration.getInstance().getDirectory().getElement("REGLER_MONTANT");
EditFrame edit = new EditFrame(encaisseElt);
 
ListeDesEcheancesFournPanel.this.edit.getSQLComponent().select(rowVals);
ListeDesEcheancesFournPanel.this.edit.pack();
ListeDesEcheancesFournPanel.this.edit.setVisible(true);
SQLRowValues rowVals = new SQLRowValues(encaisseElt.getTable());
 
rowVals.put("ID_FOURNISSEUR", idFournisseur);
rowVals.put("NOM", numeroFact);
 
final ReglerMontantSQLComponent sqlComponent = (ReglerMontantSQLComponent) edit.getSQLComponent();
 
sqlComponent.resetValue();
sqlComponent.select(rowVals);
sqlComponent.loadEcheancesFromRows(selectedRows);
edit.pack();
edit.setVisible(true);
}
});
 
107,65 → 189,8
});
 
this.panelEcheances.getListe().addListener(this);
// Gestion de la souris
this.panelEcheances.getJTable().addMouseListener(new MouseAdapter() {
 
public void mousePressed(MouseEvent mE) {
 
// Mise à jour de l'echeance sur la frame de reglement
// si cette derniere est cree
if (mE.getButton() == MouseEvent.BUTTON1) {
 
if (ListeDesEcheancesFournPanel.this.edit != null) {
SQLRowValues rowVals = new SQLRowValues(eltRegler.getTable());
 
int id = ListeDesEcheancesFournPanel.this.panelEcheances.getListe().getSelectedId();
 
rowVals.put("ID_ECHEANCE_FOURNISSEUR", id);
 
ListeDesEcheancesFournPanel.this.edit.getSQLComponent().select(rowVals);
ListeDesEcheancesFournPanel.this.edit.pack();
}
}
 
// Gestion du clic droit
if (mE.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
 
menuDroit.add(new AbstractAction("Voir la source") {
 
public void actionPerformed(ActionEvent e) {
SQLRow row = ListeDesEcheancesFournPanel.this.panelEcheances.getListe().getSelectedRow();
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
}
});
 
/*
* menuDroit.add(new AbstractAction("Encaisser") {
*
* public void actionPerformed(ActionEvent e) { if (edit == null) {
* ReglerMontantSQLElement encaisseElt = new ReglerMontantSQLElement(); edit =
* new EditFrame(encaisseElt); }
*
* SQLRowValues rowVals = new SQLRowValues(new
* ReglerMontantSQLElement().getTable());
*
* int id =
* ListeDesEcheancesFournPanel.this.panelEcheances.getListe().getSelectedId();
*
* rowVals.put("ID_ECHEANCE_FOURNISSEUR", id);
*
* edit.getSQLComponent().select(rowVals); edit.pack(); edit.setVisible(true); }
* });
*/
 
menuDroit.show(mE.getComponent(), mE.getX(), mE.getY());
}
}
});
 
}
 
public ListPanelEcheancesFourn getListPanelEcheanceFourn() {
return this.panelEcheances;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/supplier/component/FournisseurSQLComponent.java
51,6 → 51,7
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
public class FournisseurSQLComponent extends BaseSQLComponent {
 
70,16 → 71,14
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Code
JLabel labelCode = new JLabel("Code");
JLabel labelCode = new JLabel("Code", SwingConstants.RIGHT);
JTextField textCode = new JTextField();
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.weighty = 0;
c.gridwidth = 1;
this.add(labelCode, c);
c.gridx++;
c.gridwidth = 1;
c.weightx = 0.5;
this.add(textCode, c);
 
87,7 → 86,7
c.gridx = 0;
c.weightx = 0;
// Raison sociale
JLabel labelRS = new JLabel("Forme juridique");
JLabel labelRS = new JLabel("Forme juridique", SwingConstants.RIGHT);
SQLTextCombo textType = new SQLTextCombo();
JTextField textNom = new JTextField();
 
97,15 → 96,15
this.add(textType, c);
 
// Tel
JLabel labelTel = new JLabel(getLabelFor("TEL"));
JTextField textTel = new JTextField();
JLabel labelTel = new JLabel(getLabelFor("TEL"), SwingConstants.RIGHT);
JTextField textTel = new JTextField(15);
c.gridx++;
c.weightx = 0;
c.weighty = 0;
c.gridwidth = 1;
 
this.add(labelTel, c);
c.gridx++;
c.gridwidth = 1;
 
c.weightx = 0.5;
this.add(textTel, c);
 
117,9 → 116,9
if (getTable().contains("NOM_SOCIETE")) {
fieldNom = "NOM_SOCIETE";
}
this.add(new JLabel(getLabelFor(fieldNom)), c);
this.add(new JLabel(getLabelFor(fieldNom), SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = 1;
 
c.weightx = 0.5;
this.add(textNom, c);
this.addRequiredSQLObject(textNom, fieldNom);
127,9 → 126,9
// Fax
c.gridx++;
c.weightx = 0;
this.add(new JLabel(getLabelFor("FAX")), c);
this.add(new JLabel(getLabelFor("FAX"), SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
 
c.weightx = 0.5;
JTextField textFax = new JTextField();
this.add(textFax, c);
138,9 → 137,10
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(new JLabel(getLabelFor("MAIL")), c);
c.gridwidth = 1;
this.add(new JLabel(getLabelFor("MAIL"), SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = 1;
 
c.weightx = 0.5;
JTextField textMail = new JTextField();
this.add(textMail, c);
149,9 → 149,9
// Tel P
c.gridx++;
c.weightx = 0;
this.add(new JLabel(getLabelFor("TEL_P")), c);
 
this.add(new JLabel(getLabelFor("TEL_P"), SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 0.5;
JTextField textTelP = new JTextField();
this.add(textTelP, c);
160,9 → 160,8
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(new JLabel(getLabelFor("ID_LANGUE")), c);
this.add(new JLabel(getLabelFor("ID_LANGUE"), SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = 1;
c.weightx = 0.5;
ElementComboBox langue = new ElementComboBox(true, 35);
this.add(langue, c);
171,17 → 170,14
// Resp
c.gridx++;
c.weightx = 0;
this.add(new JLabel(getLabelFor("RESPONSABLE")), c);
this.add(new JLabel(getLabelFor("RESPONSABLE"), SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 0.5;
JTextField textResp = new JTextField();
this.add(textResp, c);
this.addView(textResp, "RESPONSABLE");
 
c.gridx = 0;
c.gridx = 1;
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
JCheckBox boxUE = new JCheckBox(getLabelFor("UE"));
this.add(boxUE, c);
 
268,7 → 264,6
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weighty = 0.8;
this.add(this.table, c);
 
// Mode de régelement
280,6 → 275,7
 
c.gridy++;
c.gridx = 0;
c.fill = GridBagConstraints.NONE;
this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
this.add(eltModeRegl, c);
290,45 → 286,27
c.gridy++;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = GridBagConstraints.REMAINDER;
TitledSeparator sepCompte = new TitledSeparator("Compte associé");
this.add(sepCompte, c);
TitledSeparator sepCompteCharge = new TitledSeparator("Comptes associés");
this.add(sepCompteCharge, c);
 
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c2 = new DefaultGridBagConstraints();
 
panel.add(new JLabel(getLabelFor("ID_COMPTE_PCE")), c2);
final JPanel panel = new JPanel(new GridBagLayout());
final GridBagConstraints c2 = new DefaultGridBagConstraints();
panel.add(new JLabel("Compte fournisseur associé", SwingConstants.RIGHT), c2);
ISQLCompteSelector compteSel = new ISQLCompteSelector(true);
c2.gridx++;
c2.weightx = 1;
panel.add(compteSel, c2);
c2.gridx = 0;
c2.gridy++;
c2.weightx = 0;
panel.add(new JLabel(getLabelFor("ID_COMPTE_PCE_CHARGE"), SwingConstants.RIGHT), c2);
ISQLCompteSelector compteSelCharge = new ISQLCompteSelector(true);
c2.gridx++;
c2.weightx = 1;
panel.add(compteSelCharge, c2);
 
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
c.gridx = 0;
c.weightx = 1;
c.weighty = 1;
c.anchor = GridBagConstraints.NORTHWEST;
this.add(panel, c);
 
// Compte charge par défaut
 
c.gridx = 0;
c.gridy++;
c.weightx = 1;
c.weighty = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
TitledSeparator sepCompteCharge = new TitledSeparator("Compte de charge par défaut");
this.add(sepCompteCharge, c);
 
JPanel panel2 = new JPanel(new GridBagLayout());
GridBagConstraints c3 = new DefaultGridBagConstraints();
 
panel2.add(new JLabel(getLabelFor("ID_COMPTE_PCE_CHARGE")), c3);
ISQLCompteSelector compteSelCharge = new ISQLCompteSelector(true);
c3.gridx++;
c3.weightx = 1;
panel2.add(compteSelCharge, c3);
addView(compteSelCharge, "ID_COMPTE_PCE_CHARGE");
 
c.gridwidth = GridBagConstraints.REMAINDER;
335,15 → 313,13
c.gridy++;
c.gridx = 0;
c.weightx = 1;
c.weighty = 1;
c.anchor = GridBagConstraints.NORTHWEST;
this.add(panel2, c);
this.add(panel, c);
 
// INfos
c.gridx = 0;
c.gridy++;
c.gridheight = 1;
c.weighty = 0;
c.weightx = 1;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/supplier/element/EcheanceFournisseurSQLElement.java
15,18 → 15,35
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.rights.ComptaUserRight;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
 
public class EcheanceFournisseurSQLElement extends ComptaSQLConfElement {
33,8 → 50,103
 
public EcheanceFournisseurSQLElement() {
super("ECHEANCE_FOURNISSEUR", "une échéance fournisseur", "échéances fournisseurs");
 
PredicateRowAction actionShowSource = new PredicateRowAction(new AbstractAction("Voir la source") {
 
public void actionPerformed(ActionEvent e) {
SQLRow row = IListe.get(e).fetchSelectedRow();
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
}
}, false);
actionShowSource.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
getRowActions().add(actionShowSource);
if (UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.MENU)) {
 
RowAction actionCancel = new RowAction(new AbstractAction("Annuler la régularisation en comptabilité") {
 
public void actionPerformed(ActionEvent e) {
 
int answer = JOptionPane.showConfirmDialog(null, "Etes vous sûr de vouloir annuler la régularisation ?");
if (answer == JOptionPane.YES_OPTION) {
SQLRow row = IListe.get(e).getSelectedRow().asRow();
SQLRowValues rowVals = row.createEmptyUpdateRow();
rowVals.put("REG_COMPTA", Boolean.FALSE);
try {
rowVals.commit();
} catch (SQLException e1) {
ExceptionHandler.handle("Une erreur est survenue lors de l'annulation de la régularisation.", e1);
}
}
}
}, false) {
@Override
public boolean enabledFor(List<SQLRowAccessor> selection) {
if (selection != null && selection.size() == 1) {
SQLRowAccessor row = selection.get(0);
return row.getBoolean("REG_COMPTA");
} else {
return true;
}
}
};
getRowActions().add(actionCancel);
 
RowAction actionRegul = new RowAction(new AbstractAction("Régularisation en comptabilité") {
 
public void actionPerformed(ActionEvent e) {
 
SQLRow row = IListe.get(e).fetchSelectedRow();
String price = GestionDevise.currencyToString(row.getLong("MONTANT"));
SQLRow rowFournisseur = row.getForeignRow("ID_FOURNISSEUR");
 
String nomFour = rowFournisseur.getString("NOM");
String piece = "";
SQLRow rowMvt = row.getForeignRow("ID_MOUVEMENT");
if (rowMvt != null) {
SQLRow rowPiece = rowMvt.getForeignRow("ID_PIECE");
piece = rowPiece.getString("NOM");
}
int answer = JOptionPane.showConfirmDialog(null, "Etes vous sûr de vouloir régulariser l'échéance de " + nomFour + " d'un montant de " + price
+ "€ avec une saisie au kilometre?\nNom de la piéce : " + piece + ".");
if (answer == JOptionPane.YES_OPTION) {
 
SQLRowValues rowVals = row.createEmptyUpdateRow();
rowVals.put("REG_COMPTA", Boolean.TRUE);
try {
rowVals.commit();
} catch (SQLException e1) {
ExceptionHandler.handle("Une erreur est survenue lors de la régularisation.", e1);
}
}
}
}, false) {
@Override
public boolean enabledFor(List<SQLRowAccessor> selection) {
if (selection != null && selection.size() == 1) {
SQLRowAccessor row = selection.get(0);
return !row.getBoolean("REG_COMPTA");
} else {
return true;
}
}
};
getRowActions().add(actionRegul);
 
}
}
 
@Override
public synchronized ListSQLRequest createListRequest() {
return new ListSQLRequest(this.getTable(), this.getListFields()) {
@Override
protected void customizeToFetch(SQLRowValues graphToFetch) {
super.customizeToFetch(graphToFetch);
graphToFetch.put("REG_COMPTA", null);
graphToFetch.put("REGLE", null);
}
};
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/credit/component/AvoirFournisseurSQLComponent.java
20,6 → 20,7
import org.openconcerto.erp.core.common.ui.MontantPanel;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.supplychain.credit.element.AvoirFournisseurSQLElement;
import org.openconcerto.erp.generationEcritures.GenerationMvtAvoirFournisseur;
import org.openconcerto.erp.model.ISQLCompteSelector;
45,7 → 46,6
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.util.Date;
 
import javax.swing.JCheckBox;
110,7 → 110,7
}
}
vals.put("ID_COMPTE_PCE", idCompteAchat);
vals.put("ID_TAXE", 2);
vals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(AvoirFournisseurSQLElement.class, new Date()));
return vals;
}
191,10 → 191,13
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
this.add(new JLabel("Montant", SwingConstants.RIGHT), c);
c.weighty = 0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
 
c.gridx++;
this.montantPanel = new MontantPanel();
this.add(this.montantPanel, c);
 
225,7 → 228,7
 
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridx = 0;
c.gridx = 1;
c.gridy++;
c.weighty = 0;
this.add(this.boxImmo, c);
259,8 → 262,9
c.gridheight = 1;
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(new JLabel(getLabelFor("INFOS")), c);
this.add(new TitledSeparator(getLabelFor("INFOS")), c);
 
c.gridy++;
c.fill = GridBagConstraints.BOTH;
296,7 → 300,7
this.selectFournisseur.addValueListener(this.listenerModeReglDefaut);
// this.boxAdeduire.addActionListener(this);
 
this.montantPanel.setChoixTaxe(2);
this.montantPanel.setChoixTaxe(TaxeCache.getCache().getFirstTaxe().getID());
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/FactureFournisseurElementSQLElement.java
New file
0,0 → 1,80
/*
* 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.supplychain.order.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.sqlobject.ElementComboBox;
 
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JTextField;
 
public class FactureFournisseurElementSQLElement extends ComptaSQLConfElement {
 
public FactureFournisseurElementSQLElement() {
super("FACTURE_FOURNISSEUR_ELEMENT", "un element de facture", "éléments de facture");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_STYLE");
l.add("CODE");
l.add("NOM");
l.add("PA_HT");
l.add("PV_HT");
l.add("ID_TAXE");
l.add("POIDS");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("CODE");
l.add("NOM");
l.add("PA_HT");
l.add("PV_HT");
return l;
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new UISQLComponent(this) {
public void addViews() {
this.addRequiredSQLObject(new JTextField(), "NOM", "left");
this.addRequiredSQLObject(new JTextField(), "CODE", "right");
 
this.addSQLObject(new ElementComboBox(), "ID_STYLE", "left");
 
this.addRequiredSQLObject(new DeviseField(), "PA_HT", "left");
this.addSQLObject(new DeviseField(), "PV_HT", "right");
 
this.addSQLObject(new JTextField(), "POIDS", "left");
this.addSQLObject(new ElementComboBox(), "ID_TAXE", "right");
}
};
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + "invoice.purchase.item";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/FactureFournisseurSQLElement.java
New file
0,0 → 1,79
/*
* 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.supplychain.order.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.supplychain.order.component.FactureFournisseurSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
 
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
public class FactureFournisseurSQLElement extends ComptaSQLConfElement {
 
public FactureFournisseurSQLElement() {
super("FACTURE_FOURNISSEUR", "une facture fournisseur", "factures fournisseur");
 
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NUMERO");
l.add("NOM");
l.add("DATE");
l.add("ID_FOURNISSEUR");
l.add("T_HT");
l.add("T_TTC");
l.add("INFOS");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NUMERO");
l.add("NOM");
l.add("DATE");
return l;
}
 
@Override
protected Set<String> getChildren() {
Set<String> set = new HashSet<String>();
set.add("FACTURE_FOURNISSEUR_ELEMENT");
return set;
}
 
protected List<String> getPrivateFields() {
final List<String> l = new ArrayList<String>();
l.addAll(super.getPrivateFields());
l.add("ID_MODE_REGLEMENT");
return l;
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new FactureFournisseurSQLComponent();
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".invoice.purchase";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/SaisieAchatSQLElement.java
21,11 → 21,18
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.RowAction;
 
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
 
33,6 → 40,7
 
public SaisieAchatSQLElement() {
super("SAISIE_ACHAT", "une saisie d'achat", "saisies d'achats");
this.getRowActions().add(getCloneAction());
}
 
protected List<String> getListFields() {
89,4 → 97,26
editAvoirFrame.setVisible(true);
 
}
 
public RowAction getCloneAction() {
return new RowAction(new AbstractAction("Dupliquer") {
 
public void actionPerformed(ActionEvent e) {
SQLRow selectedRow = IListe.get(e).fetchSelectedRow();
EditFrame editFrame = new EditFrame(SaisieAchatSQLElement.this, EditPanel.CREATION);
 
final SQLRowValues copy = SaisieAchatSQLElement.this.createCopy(selectedRow.getID());
copy.put("ID_MOUVEMENT", null);
copy.put("DATE", null);
editFrame.getSQLComponent().select(copy);
 
editFrame.setVisible(true);
}
}, true, "purchase.clone") {
public boolean enabledFor(java.util.List<org.openconcerto.sql.model.SQLRowAccessor> selection) {
return (selection != null && selection.size() == 1);
};
};
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/TransferSupplierOrderSQLElement.java
28,7 → 28,7
@Override
protected void ffInited() {
setAction("ID_COMMANDE", ReferenceAction.CASCADE);
setAction("ID_BON_DE_RECEPTION", ReferenceAction.CASCADE);
setAction("ID_BON_RECEPTION", ReferenceAction.CASCADE);
setAction("ID_SAISIE_ACHAT", ReferenceAction.CASCADE);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/action/ListeDesFacturesFournisseurAction.java
New file
0,0 → 1,67
/*
* 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.supplychain.order.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.finance.accounting.ui.ListeGestCommEltPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeDesFacturesFournisseurAction extends CreateFrameAbstractAction {
 
public ListeDesFacturesFournisseurAction() {
super();
this.putValue(Action.NAME, "Liste des factures fournisseurs");
}
 
public JFrame createFrame() {
SQLElement element = Configuration.getInstance().getDirectory().getElement("FACTURE_FOURNISSEUR");
ListeGestCommEltPanel panel = new ListeGestCommEltPanel(element);
panel.setAddVisible(true);
IListFrame frame = new IListFrame(panel);
IListTotalPanel total = new IListTotalPanel(frame.getPanel().getListe(), Arrays.asList(element.getTable().getField("T_HT"), element.getTable().getField("T_TTC")));
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridy = 3;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
frame.getPanel().add(total, c);
 
// Date panel
Map<IListe, SQLField> map = new HashMap<IListe, SQLField>();
map.put(frame.getPanel().getListe(), element.getTable().getField("DATE"));
 
IListFilterDatePanel datePanel = new IListFilterDatePanel(map, IListFilterDatePanel.getDefaultMap());
c.gridy = 4;
c.anchor = GridBagConstraints.CENTER;
c.weighty = 0;
datePanel.setFilterOnDefault();
frame.getPanel().add(datePanel, c);
return frame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/action/NouvelleFactureFournisseurAction.java
New file
0,0 → 1,34
/*
* 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.supplychain.order.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class NouvelleFactureFournisseurAction extends CreateFrameAbstractAction {
 
public NouvelleFactureFournisseurAction() {
super();
this.putValue(Action.NAME, "Facture fournisseur");
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("FACTURE_FOURNISSEUR"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/ui/ListPanelEcheancesFourn.java
20,6 → 20,7
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
34,6 → 35,7
public class ListPanelEcheancesFourn extends ListeAddPanel {
 
private EditFrame editFrame;
private boolean showRegCompta = false;
 
public ListPanelEcheancesFourn() {
this(Configuration.getInstance().getDirectory().getElement("ECHEANCE_FOURNISSEUR"));
46,6 → 48,11
setListe();
}
 
public void setShowRegCompta(boolean b) {
this.showRegCompta = b;
setListe();
}
 
public JTable getJTable() {
 
return this.getListe().getJTable();
72,7 → 79,11
}
 
private void setListe() {
Where wNotRegle = new Where(getListe().getSource().getPrimaryTable().getField("REGLE"), "=", Boolean.FALSE);
final SQLTable primaryTable = getListe().getSource().getPrimaryTable();
Where wNotRegle = new Where(primaryTable.getField("REGLE"), "=", Boolean.FALSE);
if (!showRegCompta) {
wNotRegle = wNotRegle.and(new Where(primaryTable.getField("REG_COMPTA"), "=", Boolean.FALSE));
}
this.getListe().getRequest().setWhere(wNotRegle);
 
this.getListe().setSQLEditable(false);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/ui/FactureFournisseurItemTable.java
New file
0,0 → 1,32
/*
* 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.supplychain.order.ui;
 
import org.openconcerto.erp.core.common.ui.AbstractAchatArticleItemTable;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
 
public class FactureFournisseurItemTable extends AbstractAchatArticleItemTable {
 
@Override
protected String getConfigurationFileName() {
return "Table_Facture_Fournisseur.xml";
 
}
 
@Override
public SQLElement getSQLElement() {
return Configuration.getInstance().getDirectory().getElement("FACTURE_FOURNISSEUR_ELEMENT");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/FactureFournisseurSQLComponent.java
New file
0,0 → 1,524
/*
* 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.supplychain.order.component;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.supplychain.order.element.CommandeSQLElement;
import org.openconcerto.erp.core.supplychain.order.ui.FactureFournisseurItemTable;
import org.openconcerto.erp.generationEcritures.GenerationMvtFactureFournisseur;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.DefaultElementSQLObject;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.ui.AutoHideListener;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FormLayouter;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.preferences.DefaultProps;
 
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
 
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
 
public class FactureFournisseurSQLComponent extends TransfertBaseSQLComponent {
 
private FactureFournisseurItemTable table = new FactureFournisseurItemTable();
private final JCheckBox checkImpression = new JCheckBox("Imprimer");
private final JCheckBox checkVisu = new JCheckBox("Visualiser");
private final ITextArea infos = new ITextArea(3, 3);
private ElementComboBox fourn = new ElementComboBox();
private ElementComboBox comptePCE = new ElementComboBox();
private DefaultElementSQLObject compAdr;
final JPanel panelAdrSpec = new JPanel(new GridBagLayout());
 
public FactureFournisseurSQLComponent() {
super(Configuration.getInstance().getDirectory().getElement("FACTURE_FOURNISSEUR"));
}
 
public ElementComboBox getBoxFournisseur() {
return this.fourn;
}
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Numero du commande
c.gridx = 0;
c.weightx = 0;
this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
 
JTextField numero = new JTextField(25);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
DefaultGridBagConstraints.lockMinimumSize(numero);
this.add(numero, c);
 
// Date
JLabel labelDate = new JLabel(getLabelFor("DATE"));
labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 2;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(labelDate, c);
 
JDate dateCommande = new JDate();
c.gridx++;
c.fill = GridBagConstraints.NONE;
this.add(dateCommande, c);
 
// Fournisseur
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel(getLabelFor("ID_FOURNISSEUR"), SwingConstants.RIGHT), c);
 
c.gridx = GridBagConstraints.RELATIVE;
c.gridwidth = 1;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
this.add(this.fourn, c);
addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
 
// Champ Module
c.gridx = 0;
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
this.add(addP, c);
 
c.gridy++;
c.gridwidth = 1;
 
final ElementComboBox boxDevise = new ElementComboBox();
if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) {
// Devise
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);
 
c.gridx = GridBagConstraints.RELATIVE;
c.gridwidth = 1;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
this.add(boxDevise, c);
this.addView(boxDevise, "ID_DEVISE");
}
 
// Compte pce
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel(getLabelFor("ID_COMPTE_PCE"), SwingConstants.RIGHT), c);
 
c.gridx = GridBagConstraints.RELATIVE;
c.gridwidth = 1;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
this.add(this.comptePCE, c);
this.addView(this.comptePCE, "ID_COMPTE_PCE");
 
// Reference
c.gridx = 0;
c.gridy++;
c.gridwidth = 1;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.EAST;
this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);
 
final JTextField textNom = new JTextField();
c.gridx++;
c.weightx = 1;
this.add(textNom, c);
 
String field;
field = "ID_COMMERCIAL";
// Commercial
c.weightx = 0;
c.gridx++;
this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c);
 
ElementComboBox commSel = new ElementComboBox(false, 25);
c.gridx = GridBagConstraints.RELATIVE;
c.gridwidth = 1;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
this.add(commSel, c);
addRequiredSQLObject(commSel, field);
 
// Table d'élément
c.fill = GridBagConstraints.BOTH;
c.gridy++;
c.gridx = 0;
c.weightx = 0;
c.weighty = 1;
c.gridwidth = 4;
this.add(this.table, c);
if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) {
 
boxDevise.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
table.setDevise(boxDevise.getSelectedRow());
 
}
});
}
 
this.fourn.addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
table.setFournisseur(fourn.getSelectedRow());
if (!isFilling()) {
SQLRow row = fourn.getSelectedRow();
if (row != null && !row.isUndefined() && !row.isForeignEmpty("ID_COMPTE_PCE_CHARGE")) {
comptePCE.setValue(row.getForeign("ID_COMPTE_PCE_CHARGE"));
}
}
}
});
// Bottom
c.gridy++;
c.weighty = 0;
this.add(getBottomPanel(), c);
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
 
JPanel panelOO = new JPanel(new FlowLayout(FlowLayout.RIGHT));
panelOO.add(this.checkImpression, c);
panelOO.add(this.checkVisu, c);
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(panelOO, c);
 
addSQLObject(textNom, "NOM");
addRequiredSQLObject(dateCommande, "DATE");
addRequiredSQLObject(numero, "NUMERO");
addSQLObject(this.infos, "INFOS");
 
DefaultGridBagConstraints.lockMinimumSize(this.fourn);
DefaultGridBagConstraints.lockMinimumSize(commSel);
}
 
private JPanel getBottomPanel() {
final JPanel panel = new JPanel(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Colonne 1 : Infos
c.gridx = 0;
c.weightx = 1;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.HORIZONTAL;
 
panel.add(new TitledSeparator(getLabelFor("INFOS")), c);
 
c.gridy++;
c.weighty = 0;
c.weightx = 1;
c.fill = GridBagConstraints.BOTH;
final JScrollPane scrollPane = new JScrollPane(this.infos);
scrollPane.setBorder(null);
panel.add(scrollPane, c);
 
this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
 
c.gridx++;
c.fill = GridBagConstraints.NONE;
c.weighty = 1;
eltModeRegl.setOpaque(false);
panel.add(eltModeRegl, c);
 
// Colonne 2 : Poids & autres
DefaultProps props = DefaultNXProps.getInstance();
Boolean b = props.getBooleanValue("ArticleShowPoids");
final JTextField textPoidsTotal = new JTextField(8);
JTextField poids = new JTextField();
if (b) {
final JPanel panelPoids = new JPanel();
 
panelPoids.add(new JLabel(getLabelFor("T_POIDS")), c);
 
textPoidsTotal.setEnabled(false);
textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
textPoidsTotal.setDisabledTextColor(Color.BLACK);
 
panelPoids.add(textPoidsTotal, c);
 
c.gridx++;
c.gridy = 0;
c.weightx = 0;
c.weighty = 0;
c.gridwidth = 1;
c.gridheight = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTHEAST;
panel.add(panelPoids, c);
DefaultGridBagConstraints.lockMinimumSize(panelPoids);
addSQLObject(textPoidsTotal, "T_POIDS");
} else {
addSQLObject(poids, "T_POIDS");
}
 
DeviseField textPortHT = new DeviseField();
ElementComboBox comboTaxePort = new ElementComboBox();
 
if (getTable().contains("PORT_HT")) {
addRequiredSQLObject(textPortHT, "PORT_HT");
final JPanel panelPoids = new JPanel(new GridBagLayout());
GridBagConstraints cPort = new DefaultGridBagConstraints();
cPort.gridx = 0;
cPort.weightx = 0;
panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort);
textPortHT.setHorizontalAlignment(JTextField.RIGHT);
cPort.gridx++;
cPort.weightx = 1;
panelPoids.add(textPortHT, cPort);
 
cPort.gridy++;
cPort.gridx = 0;
cPort.weightx = 0;
addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT");
panelPoids.add(new JLabel(getLabelFor("ID_TAXE_PORT")), cPort);
cPort.gridx++;
cPort.weightx = 0;
panelPoids.add(comboTaxePort, cPort);
 
c.gridx++;
c.gridy = 0;
c.weightx = 0;
c.weighty = 0;
c.gridwidth = 1;
c.gridheight = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTHEAST;
panel.add(panelPoids, c);
DefaultGridBagConstraints.lockMinimumSize(panelPoids);
}
// Total
 
DeviseField textRemiseHT = new DeviseField();
DeviseField fieldHT = new DeviseField();
DeviseField fieldTVA = new DeviseField();
DeviseField fieldTTC = new DeviseField();
DeviseField fieldDevise = new DeviseField();
DeviseField fieldService = new DeviseField();
fieldHT.setOpaque(false);
fieldTVA.setOpaque(false);
fieldTTC.setOpaque(false);
fieldService.setOpaque(false);
addRequiredSQLObject(fieldDevise, "T_DEVISE");
addRequiredSQLObject(fieldHT, "T_HT");
addRequiredSQLObject(fieldTVA, "T_TVA");
 
addRequiredSQLObject(fieldTTC, "T_TTC");
addRequiredSQLObject(fieldService, "T_SERVICE");
final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null,
(getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null));
 
c.gridx++;
c.gridy--;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = 2;
c.anchor = GridBagConstraints.NORTHEAST;
c.fill = GridBagConstraints.BOTH;
c.weighty = 0;
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
 
panel.add(totalTTC, c);
 
c.gridy += 3;
c.gridheight = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
panel.add(getModuleTotalPanel(), c);
 
table.getModel().addTableModelListener(new TableModelListener() {
 
public void tableChanged(TableModelEvent e) {
textPoidsTotal.setText(String.valueOf(table.getPoidsTotal()));
}
});
 
textPortHT.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
totalTTC.updateTotal();
}
 
public void removeUpdate(DocumentEvent e) {
totalTTC.updateTotal();
}
 
public void insertUpdate(DocumentEvent e) {
totalTTC.updateTotal();
}
});
 
comboTaxePort.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
// TODO Raccord de méthode auto-généré
totalTTC.updateTotal();
}
});
 
textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
totalTTC.updateTotal();
}
 
public void removeUpdate(DocumentEvent e) {
totalTTC.updateTotal();
}
 
public void insertUpdate(DocumentEvent e) {
totalTTC.updateTotal();
}
});
return panel;
}
 
protected JPanel getModuleTotalPanel() {
 
return AutoHideListener.listen(new JPanel());
}
 
public int insert(SQLRow order) {
 
int idFacture = getSelectedID();
idFacture = super.insert(order);
this.table.updateField("ID_FACTURE_FOURNISSEUR", idFacture);
 
// Création des articles
this.table.createArticle(idFacture, this.getElement());
 
new GenerationMvtFactureFournisseur(idFacture);
 
return idFacture;
}
 
@Override
public void update() {
 
super.update();
SQLRow row = getTable().getRow(getSelectedID());
this.table.updateField("ID_FACTURE_FOURNISSEUR", row.getID());
this.table.createArticle(getSelectedID(), this.getElement());
 
int idMvt = (row.getObject("ID_MOUVEMENT") == null ? 1 : row.getInt("ID_MOUVEMENT"));
System.err.println("__________***************** UPDATE" + idMvt);
 
// on supprime tout ce qui est lié à la facture
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE");
eltEcr.archiveMouvementProfondeur(idMvt, false);
if (idMvt > 1) {
new GenerationMvtFactureFournisseur(row.getID(), idMvt);
} else {
new GenerationMvtFactureFournisseur(row.getID());
}
}
 
public void setDefaults() {
this.resetValue();
this.table.getModel().clearRows();
}
 
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("T_POIDS", 0.0F);
// User
// SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
int idUser = UserManager.getInstance().getCurrentUser().getId();
 
// sel.addSelect(eltComm.getTable().getKey());
// sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser));
// List<SQLRow> rowsComm = (List<SQLRow>)
// Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new
// SQLRowListRSH(eltComm.getTable()));
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
 
if (rowsComm != null) {
rowVals.put("ID_COMMERCIAL", rowsComm.getID());
}
rowVals.put("T_HT", Long.valueOf(0));
rowVals.put("T_SERVICE", Long.valueOf(0));
rowVals.put("T_DEVISE", Long.valueOf(0));
rowVals.put("T_TVA", Long.valueOf(0));
rowVals.put("T_TTC", Long.valueOf(0));
// rowVals.put("NUMERO",
// NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class));
 
if (getTable().contains("ID_TAXE_PORT")) {
rowVals.put("ID_TAXE_PORT", TaxeCache.getCache().getFirstTaxe().getID());
}
 
return rowVals;
}
 
@Override
public RowValuesTable getRowValuesTable() {
return this.table.getRowValuesTable();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/SaisieAchatSQLComponent.java
18,6 → 18,7
import org.openconcerto.erp.core.common.ui.MontantPanel;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieAchat;
import org.openconcerto.erp.model.ISQLCompteSelector;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
48,8 → 49,9
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
 
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
73,14 → 75,12
final ISQLCompteSelector compteSel = new ISQLCompteSelector();
 
private JCheckBox checkImmo;
// private JRadioButton radioButtonNumeroFacture;
// private JRadioButton radioButtonNumeroCmd;
private ButtonGroup grp1;
 
private MontantPanel montant;
private ElementComboBox nomFournisseur;
private ElementComboBox comboAvoir;
protected ElementSQLObject eltModeRegl;
private int idFournSelect = 1;
 
private PropertyChangeListener listenerModeReglDefaut = new PropertyChangeListener() {
 
public void propertyChange(PropertyChangeEvent evt) {
87,8 → 87,6
 
SQLRow rowFourn = SaisieAchatSQLComponent.this.nomFournisseur.getRequest().getPrimaryTable().getRow(nomFournisseur.getWantedID());
 
// System.err.println("Select Fournisseur " + idSeleted);
 
if (!isFilling() && rowFourn != null && !rowFourn.isUndefined()) {
SaisieAchatSQLComponent.this.montant.setUE(rowFourn.getBoolean("UE"));
 
96,8 → 94,7
if (rowCharge != null && !rowCharge.isUndefined()) {
compteSel.setValue(rowCharge);
}
// if (getSelectedID() <= 1 || SaisieAchatSQLComponent.this.idFournSelect !=
// idSeleted) {
 
int idModeRegl = rowFourn.getInt("ID_MODE_REGLEMENT");
if (idModeRegl > 1 && SaisieAchatSQLComponent.this.eltModeRegl != null && getMode() == Mode.INSERTION) {
SQLElement sqlEltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
109,7 → 106,7
}
// }
}
// / SaisieAchatSQLComponent.this.idFournSelect = (idSeleted == null) ? 1 : idSeleted;
 
}
 
};
128,8 → 125,6
 
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = 1;
TitledSeparator sep = new TitledSeparator("Renseignements");
this.add(sep, c);
 
c.gridy++;
c.gridwidth = 1;
187,21 → 182,10
this.add(compteSel, c);
 
c.gridwidth = 1;
 
// Ligne 4 : Numero facture fournisseur
// this.radioButtonNumeroFacture = new JRadioButton(getLabelFor("NUMERO_FACTURE"));
// this.radioButtonNumeroFacture.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// SaisieAchatSQLComponent.this.textNumeroFacture.setEnabled(true);
// SaisieAchatSQLComponent.this.textNumeroCmd.setEnabled(false);
// }
// });
 
c.weightx = 0;
c.gridx = 0;
c.gridy++;
c.gridwidth = 1;
// this.add(this.radioButtonNumeroFacture, c);
this.add(new JLabel(getLabelFor("NUMERO_FACTURE"), SwingConstants.RIGHT), c);
 
this.textNumeroFacture = new JTextField(16);
218,26 → 202,16
this.add(new JLabel("Date"), c);
c.gridx++;
c.weightx = 1;
JDate dateSaisie = new JDate(true);
JDate dateSaisie = new JDate();
c.fill = GridBagConstraints.NONE;
 
this.add(dateSaisie, c);
 
// Ligne 5 : numéro commande fournisseur
// this.radioButtonNumeroCmd = new JRadioButton(getLabelFor("NUMERO_COMMANDE"));
// this.radioButtonNumeroCmd.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// // numeroCmd.setValue(textNumeroCmd.getText());
// // numeroFact.setValue("");
// SaisieAchatSQLComponent.this.textNumeroFacture.setEnabled(false);
// SaisieAchatSQLComponent.this.textNumeroCmd.setEnabled(true);
// }
// });
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
// this.add(this.radioButtonNumeroCmd, c);
 
this.add(new JLabel(getLabelFor("NUMERO_COMMANDE"), SwingConstants.RIGHT), c);
 
this.textNumeroCmd = new JTextField(16);
254,33 → 228,16
this.add(this.checkImmo, c);
c.anchor = GridBagConstraints.WEST;
 
// textNumeroCmd
// this.grp1 = new ButtonGroup();
// this.grp1.add(this.radioButtonNumeroCmd);
// this.grp1.add(this.radioButtonNumeroFacture);
//
// this.radioButtonNumeroFacture.setSelected(true);
// this.textNumeroFacture.setEnabled(true);
// this.textNumeroCmd.setEnabled(false);
 
// MONTANT
 
c.gridx = 0;
c.gridy++;
c.insets = new Insets(10, 2, 1, 2);
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.BOTH;
sep = new TitledSeparator("Montant en euros");
this.add(sep, c);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
c.weightx = 0;
this.add(new JLabel("Montant", SwingConstants.RIGHT), c);
 
c.insets = new Insets(2, 2, 1, 2);
c.gridwidth = 4;
 
// Montant
 
c.gridx = 0;
c.gridy++;
c.gridwidth = 4;
c.gridx = 1;
c.gridwidth = 3;
c.weightx = 1;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.NONE;
290,7 → 247,7
// Avoir
JPanel panelAvoir = new JPanel();
this.comboAvoir = new ElementComboBox(true);
panelAvoir.add(new JLabel(getLabelFor("ID_AVOIR_FOURNISSEUR")));
 
this.comboAvoir.setAddIconVisible(false);
panelAvoir.add(this.comboAvoir);
 
297,11 → 254,14
panelAvoir.add(new JLabel("Montant réglé"));
panelAvoir.add(this.fieldMontantRegle);
this.fieldMontantRegle.setEditable(false);
 
c.gridx = 0;
c.gridy++;
c.gridwidth = 1;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel(getLabelFor("ID_AVOIR_FOURNISSEUR"), SwingConstants.RIGHT), c);
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
this.add(panelAvoir, c);
 
315,7 → 275,7
c.gridy++;
c.insets = new Insets(10, 2, 1, 2);
c.fill = GridBagConstraints.HORIZONTAL;
sep = new TitledSeparator("Mode de règlement");
TitledSeparator sep = new TitledSeparator("Mode de règlement");
 
this.add(sep, c);
 
369,7 → 329,7
this.addSQLObject(this.comboAvoir, "ID_AVOIR_FOURNISSEUR");
this.addSQLObject(this.checkImmo, "IMMO");
 
this.montant.setChoixTaxe(2);
this.montant.setChoixTaxe(TaxeCache.getCache().getFirstTaxe().getID());
 
this.nomFournisseur.addModelListener("wantedID", this.listenerModeReglDefaut);
 
466,6 → 426,17
return id;
}
 
@Override
public Set<String> getPartialResetNames() {
Set<String> s = new HashSet<String>();
s.addAll(super.getPartialResetNames());
s.add("INFOS");
s.add("NUMERO_FACTURE");
s.add("NUMERO_COMMANDE");
s.add("MONTANT_HT");
return s;
}
 
public void select(SQLRowAccessor r) {
 
// FIXME probleme selection du mode de reglement par defaut -> l'id est celui du défaut dans
475,7 → 446,6
 
if (r != null) {
System.err.println(r);
// System.err.println("Select Mode regl " + r.getInt("ID_MODE_REGLEMENT"));
this.montant.calculMontant();
Object idF = r.getObject("ID_FOURNISSEUR");
System.err.println("Founisseur " + idF);
484,16 → 454,12
 
if (idSeleted > 1) {
SQLElement fournisseur = Configuration.getInstance().getDirectory().getElement("FOURNISSEUR");
 
SQLRow rowFourn = fournisseur.getTable().getRow(idSeleted);
 
this.idFournSelect = rowFourn.getID();
this.montant.setUE(rowFourn.getBoolean("UE"));
}
}
System.out.println("select id Saisie Achat " + r.getID());
}
 
}
 
final SQLTable tablePrefCompte = getTable().getTable("PREFS_COMPTE");
532,7 → 498,8
}
}
vals.put("ID_COMPTE_PCE", idCompteAchat);
vals.put("ID_TAXE", 2);
vals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
 
return vals;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/CommandeSQLComponent.java
759,7 → 759,7
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class));
 
if (getTable().contains("ID_TAXE_PORT")) {
rowVals.put("ID_TAXE_PORT", TaxeCache.getCache().getIdFromTaux(19.6F));
rowVals.put("ID_TAXE_PORT", TaxeCache.getCache().getFirstTaxe().getID());
}
 
return rowVals;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ClientNormalSQLComponent.java
16,36 → 16,9
*/
package org.openconcerto.erp.core.customerrelationship.customer.element;
 
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
72,17 → 45,45
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FormLayouter;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.component.ITextArea;
 
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
public class ClientNormalSQLComponent extends BaseSQLComponent {
 
int idDefaultCompteClient = 1;
JCheckBox checkAdrLivraison, checkAdrFacturation;
 
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
private ElementComboBox boxPays = null;
final ElementComboBox boxTarif = new ElementComboBox();
 
683,7 → 684,7
String compte = "411" + initialClient;
 
SQLTable table = Configuration.getInstance().getDirectory().getElement("COMPTE_PCE").getTable();
SQLSelect selCompte = new SQLSelect(this.getTable().getBase());
SQLSelect selCompte = new SQLSelect();
selCompte.addSelectFunctionStar("COUNT");
selCompte.setArchivedPolicy(SQLSelect.BOTH);
selCompte.setWhere(new Where(table.getField("NUMERO"), "LIKE", compte + "%"));
708,7 → 709,22
@Override
public int insert(SQLRow order) {
 
// incrémentation du numéro auto
if (NumerotationAutoSQLElement.getNextNumero(ClientNormalSQLElement.class, new Date()).equalsIgnoreCase(this.textCode.getText().trim())) {
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
int val = this.tableNum.getRow(2).getInt("CLIENT_START");
val++;
rowVals.put("CLIENT_START", new Integer(val));
 
try {
rowVals.update(2);
} catch (SQLException e) {
e.printStackTrace();
}
}
 
int id = super.insert(order);
 
this.table.updateField("ID_CLIENT", id);
this.adresseTable.updateField("ID_CLIENT", id);
if (this.boxGestionAutoCompte.isSelected()) {
723,6 → 739,7
SQLRow r;
 
vals.put("MARCHE_PUBLIC", Boolean.TRUE);
vals.put("CODE", NumerotationAutoSQLElement.getNextNumero(ClientNormalSQLElement.class, new Date()));
 
// Mode de règlement par defaut
try {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ClientNormalSQLElement.java
48,7 → 48,7
 
@Override
public void actionPerformed(ActionEvent e) {
final SQLRowAccessor row = IListe.get(e).getSelectedRow();
final SQLRowAccessor row = IListe.get(e).fetchSelectedRow();
final LabelCreator c = new LabelCreator(720);
c.setLeftMargin(10);
c.setTopMargin(10);
116,6 → 116,7
l.add("RESPONSABLE");
l.add("ID_ADRESSE");
l.add("TEL");
l.add("TEL_P");
l.add("FAX");
l.add("MAIL");
l.add("NUMERO_TVA");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ContactSQLElement.java
13,6 → 13,8
package org.openconcerto.erp.core.customerrelationship.customer.element;
 
import org.openconcerto.erp.config.Gestion;
 
public class ContactSQLElement extends ContactSQLElementBase {
 
static public class ContactFournisseurSQLElement extends ContactSQLElement {
33,6 → 35,6
 
protected ContactSQLElement(String tableName) {
super(tableName);
// TODO call this.setL18nPackageName()
this.setL18nLocation(Gestion.class);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033A.java
115,18 → 115,20
// S014=201...205+208+237+232
long v014 = this.sommeCompte.sommeCompteFils("109", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("201", this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("203", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("232", this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("205", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("208", this.dateDebut, this.dateFin)
+ this.sommeCompte.sommeCompteFils("237", this.dateDebut, this.dateFin);
+ this.sommeCompte.sommeCompteFils("205", this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompte(2088, 2089, true, this.dateDebut, this.dateFin)
+ this.sommeCompte.soldeCompte(2080, 2086, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("237", this.dateDebut, this.dateFin);
this.m.put("ACTIF1.1", GestionDevise.currencyToString(v014, false));
 
// 016 -SommeSolde( 280, 280* ) - SommeSolde(2905) - SommeSolde (2908)
// RacineDap = "2800, 2801, 2803, 2805, 2808, 2908, 2905"
// S016=-2801-2803-2805-2905-2808-2908-2932
// remove 26/11/13 present en case "012" - this.sommeCompte.sommeCompteFils("2807",
// this.dateDebut, this.dateFin)
long v016 = -this.sommeCompte.sommeCompteFils("2801", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("2803", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("2805", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("2807", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("2808", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("2905", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("2906", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("2907", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("2908", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("2932", this.dateDebut, this.dateFin);
- this.sommeCompte.sommeCompteFils("2805", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("2808", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("2905", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("2906", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("2907", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("2908", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("2932", this.dateDebut, this.dateFin);
 
this.m.put("ACTIF2.1", GestionDevise.currencyToString(v016, false));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ImpressionJournalPayeAction.java
29,6 → 29,9
 
@Override
public JFrame createFrame() {
return new PanelFrame(new ImpressionJournalPayePanel(), "Impression du journal de paye");
final PanelFrame panelFrame = new PanelFrame(new ImpressionJournalPayePanel(), "Impression du journal de paye");
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ListeDesEcrituresAction.java
52,6 → 52,7
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
 
73,27 → 74,27
src = element.getTableSource(true);
src.getReq().setWhere(new Where(element.getTable().getField("COMPTE_NUMERO"), "LIKE", "411%"));
} else {
src = element.getTableSource();
src = element.getTableSource(true);
}
 
final IListFrame frame = new IListFrame(new ListeAddPanel(element, new IListe(src)) {
 
// @Override
// protected GridBagConstraints createConstraints() {
// final GridBagConstraints res = super.createConstraints();
// res.gridwidth = GridBagConstraints.REMAINDER;
// res.gridy = 1;
// return res;
// }
@Override
protected GridBagConstraints createConstraints() {
final GridBagConstraints res = super.createConstraints();
res.gridwidth = GridBagConstraints.REMAINDER;
res.gridy = 1;
return res;
}
 
@Override
protected void handleAction(JButton source, ActionEvent evt) {
if (source == this.buttonEffacer && getListe().getSelectedRow() != null) {
if (source == this.buttonEffacer && getListe().fetchSelectedRow() != null) {
// Si on supprime une ecriture on doit supprimer toutes les ecritures du
// mouvement associé
System.err.println("Archivage des écritures");
// archiveMouvement(row.getInt("ID_MOUVEMENT"));
JFrame frame = new PanelFrame(new SuppressionEcrituresPanel(getListe().getSelectedRow().getInt("ID_MOUVEMENT")), "Suppression d'ecritures");
JFrame frame = new PanelFrame(new SuppressionEcrituresPanel(getListe().fetchSelectedRow().getInt("ID_MOUVEMENT")), "Suppression d'ecritures");
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
120,15 → 121,15
c.weightx = 1;
frame.getPanel().add(comp, c);
 
// List<SQLField> l = new ArrayList<SQLField>();
// l.add(element.getTable().getField("DEBIT"));
// l.add(element.getTable().getField("CREDIT"));
//
// IListTotalPanel comp2 = new IListTotalPanel(frame.getPanel().getListe(), l);
// c.gridx++;
// c.weightx = 0;
// frame.getPanel().add(comp2, c);
List<SQLField> l = new ArrayList<SQLField>();
l.add(element.getTable().getField("DEBIT"));
l.add(element.getTable().getField("CREDIT"));
 
IListTotalPanel comp2 = new IListTotalPanel(frame.getPanel().getListe(), l);
c.gridx++;
c.weightx = 0;
frame.getPanel().add(comp2, c);
 
// Renderer
JTable table = frame.getPanel().getListe().getJTable();
 
142,15 → 143,23
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
 
menuDroit.add(new AbstractAction("Contrepassation") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.contrePassationPiece(frame.getPanel().getListe().getSelectedId());
}
});
 
menuDroit.add(new AbstractAction("Dupliquer") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.dupliquer(frame.getPanel().getListe().fetchSelectedRow());
}
});
 
menuDroit.add(new AbstractAction("Voir la source") {
public void actionPerformed(ActionEvent event) {
 
SQLRow row = frame.getPanel().getListe().getSelectedRow();
SQLRow row = frame.getPanel().getListe().fetchSelectedRow();
 
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
}
202,6 → 211,7
 
System.err.println(sel.asString());
 
@SuppressWarnings("unchecked")
List<SQLRow> rows = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel, tableMvt));
 
for (SQLRow sqlRow : rows) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/BalanceAgeeAction.java
28,6 → 28,9
}
 
public JFrame createFrame() {
return new PanelFrame(new BalanceAgeePanel(), "Balance agée client");
final PanelFrame panelFrame = new PanelFrame(new BalanceAgeePanel(), "Balance âgée client");
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauClotureAction.java
29,6 → 29,9
 
@Override
public JFrame createFrame() {
return new PanelFrame(new CloturePanel(), "Assistant Clôture");
final PanelFrame panelFrame = new PanelFrame(new CloturePanel(), "Assistant Clôture");
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauClotureManuelleAction.java
29,6 → 29,9
 
@Override
public JFrame createFrame() {
return new PanelFrame(new ClotureManuellePanel(), "Clôture manuelle");
final PanelFrame panelFrame = new PanelFrame(new ClotureManuellePanel(), "Clôture manuelle");
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouvelleValidationAction.java
13,6 → 13,8
package org.openconcerto.erp.core.finance.accounting.action;
 
import java.awt.Dimension;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.finance.accounting.ui.ValidationEcriturePanel;
30,6 → 32,7
@Override
public JFrame createFrame() {
final PanelFrame panelFrame = new PanelFrame(new ValidationEcriturePanel(), "Validation des écritures");
panelFrame.setPreferredSize(new Dimension(panelFrame.getPreferredSize().width + 50, panelFrame.getPreferredSize().height));
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ExportRelationExpertAction.java
15,12 → 15,11
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.panel.compta.ExportRelationExpertPanel;
import org.openconcerto.erp.panel.compta.ExportPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
 
public class ExportRelationExpertAction extends CreateFrameAbstractAction {
public ExportRelationExpertAction() {
super();
27,9 → 26,8
this.putValue(Action.NAME, "Export relation expert");
}
 
@Override
public JFrame createFrame() {
 
return new PanelFrame(new ExportRelationExpertPanel(), "Export relation expert");
 
return new PanelFrame(new ExportPanel(), "Export des écritures");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ImpressionLivrePayeAction.java
29,6 → 29,9
 
@Override
public JFrame createFrame() {
return new PanelFrame(new ImpressionLivrePayePanel(), "Impression du livre de paye");
final PanelFrame panelFrame = new PanelFrame(new ImpressionLivrePayePanel(), "Impression du livre de paye");
panelFrame.pack();
panelFrame.setResizable(false);
return panelFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/NouveauJournalAction.java
29,6 → 29,9
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("JOURNAL"));
final EditFrame editFrame = new EditFrame(Configuration.getInstance().getDirectory().getElement("JOURNAL"));
editFrame.pack();
editFrame.setResizable(false);
return editFrame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/EtatChargePanel.java
13,6 → 13,7
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.MoisSQLElement;
import org.openconcerto.erp.core.finance.accounting.model.EtatChargeModel;
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseCotisationSQLElement;
69,9 → 70,8
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Periode
SQLElement eltMois = new MoisSQLElement();
final SQLElement eltMois = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(MoisSQLElement.class);
this.selMoisDu = new ElementComboBox(false, 15);
 
this.selMoisDu.init(eltMois);
this.selMoisDu.setButtonsVisible(false);
this.selMoisAu = new ElementComboBox(false, 15);
79,14 → 79,13
this.selMoisAu.init(eltMois);
this.selMoisAu.setButtonsVisible(false);
 
JLabel labelAnnee = new JLabel("Année");
JLabel labelAnnee = new JLabel("pour l'année");
this.textAnnee = new JTextField(5);
 
JLabel labelMoisDu = new JLabel("De");
JLabel labelMoisDu = new JLabel("Période de");
JLabel labelMoisAu = new JLabel("à");
{
JPanel pDate = new JPanel();
pDate.setBorder(BorderFactory.createTitledBorder("Période"));
pDate.setOpaque(false);
pDate.add(labelMoisDu);
pDate.add(this.selMoisDu);
111,6 → 110,8
this.textAnnee.setText(s);
 
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(pDate, c);
}
235,7 → 236,7
panel.add(scrollPane, c);
 
// cotisation salariale
c.fill = GridBagConstraints.HORIZONTAL;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTHWEST;
c.weightx = 1;
c.weighty = 0;
243,7 → 244,7
final JPanel panelTotal = new JPanel();
panelTotal.setOpaque(false);
 
final JLabel labelCotSal = new JLabel("Cotisations Sal.");
final JLabel labelCotSal = new JLabel("Cotisations salariales");
panelTotal.add(labelCotSal);
final JTextField textCotS = new JTextField(10);
panelTotal.add(textCotS);
251,7 → 252,7
textCotS.setEnabled(false);
 
// cotisation patronale
final JLabel labelCotPat = new JLabel("Cotisations Pat");
final JLabel labelCotPat = new JLabel("Cotisations patronales");
panelTotal.add(labelCotPat);
final JTextField textCotP = new JTextField(10);
panelTotal.add(textCotP);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieKmItemTable.java
21,6 → 21,7
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
51,6 → 52,7
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
89,7 → 91,7
this.credit = new SQLTableElement(tableElement.getField("CREDIT"), Long.class, this.deviseCellEditor);
list.add(this.credit);
 
final RowValuesTableModel model = new RowValuesTableModel(elt, list, tableElement.getField("NUMERO"), true, defaultRowVals) {
final RowValuesTableModel model = new RowValuesTableModel(elt, list, tableElement.getField("NUMERO"), false, defaultRowVals) {
@Override
public void setValueAt(final Object aValue, final int rowIndex, final int columnIndex) {
super.setValueAt(aValue, rowIndex, columnIndex);
172,7 → 174,7
* @param contrePasser contrePasser l'ecriture
*/
private void loadEcriture(final SQLRow ecrRow, final boolean contrePasser) {
 
assert SwingUtilities.isEventDispatchThread();
final SQLRow compteRow = ecrRow.getForeignRow("ID_COMPTE_PCE");
final Map<String, Object> m = new HashMap<String, Object>();
 
201,7 → 203,7
* @param contrePasser contrePasser le mouvement
*/
public void loadMouvement(final int idMvt, final boolean contrePasser) {
 
assert SwingUtilities.isEventDispatchThread();
// FIXME load analytique
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLTable ecrTable = base.getTable("ECRITURE");
232,6 → 234,10
this.table.insertFrom(field, id);
}
 
public void insertFrom(final SQLRowAccessor row) {
this.table.insertFrom(row);
}
 
public RowValuesTableModel getModel() {
return this.table.getRowValuesTableModel();
}
260,6 → 266,7
}
 
public void editCellAt(final int row, final int column) {
assert SwingUtilities.isEventDispatchThread();
this.table.setColumnSelectionInterval(column, column);
this.table.setRowSelectionInterval(row, row);
this.table.editCellAt(row, column);
266,6 → 273,7
}
 
private long getContrepartie() {
assert SwingUtilities.isEventDispatchThread();
long totalCred = 0;
long totalDeb = 0;
final RowValuesTableModel model = this.table.getRowValuesTableModel();
287,6 → 295,7
}
 
private long getSoldeRow(final int index) {
assert SwingUtilities.isEventDispatchThread();
if (index >= 0 && index < this.table.getRowCount()) {
final SQLRowValues rowVals = this.table.getRowValuesTableModel().getRowValuesAt(index);
return rowVals.getLong("DEBIT") - rowVals.getLong("CREDIT");
296,6 → 305,7
}
 
public void fillEmptyEntryLabel(String previousText, String text) {
assert SwingUtilities.isEventDispatchThread();
if (text == null)
return;
RowValuesTableModel model = table.getRowValuesTableModel();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CloturePanel.java
28,6 → 28,7
import org.openconcerto.sql.model.SQLSystem;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.ExceptionHandler;
73,17 → 74,13
private JButton annul = new JButton("Annuler");
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private JLabel opEnCours = new JLabel("Etat: en attente de validation");
JCheckBox boxValid = new JCheckBox("Je confirme avoir effectué toutes les opérations nécessaires.");
private JCheckBox boxValid = new JCheckBox("Je confirme avoir effectué toutes les opérations nécessaires.");
 
private JProgressBar bar = new JProgressBar(0, 4);
 
public CloturePanel() {
 
super();
this.setLayout(new GridBagLayout());
 
final GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(10, 2, 1, 2);
final GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
c.gridx = 0;
114,7 → 111,7
Calendar dFin = this.rowExercice.getDate("DATE_FIN");
JLabel labelAncienExercice = new JLabel("Clôture de l'exercice du " + dateFormat.format(dDebut.getTime()) + " au " + dateFormat.format(dFin.getTime()));
this.add(labelAncienExercice, c);
 
c.insets = new Insets(10, 2, 1, 2);
this.add(rappel, c);
this.add(label, c);
this.add(label2, c);
169,12 → 166,7
 
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
c.gridx = GridBagConstraints.RELATIVE;
// c.gridy = GridBagConstraints.SOUTH;
this.add(this.valider, c);
this.add(this.annul, c);
c.gridx = 0;
 
this.add(buttonBar, c);
 
final PropertyChangeListener listener = new PropertyChangeListener() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ListeEcritureParClassePanel.java
156,7 → 156,7
menuDroit.add(new AbstractAction("Voir la source") {
public void actionPerformed(ActionEvent e) {
 
SQLRow row = panel.getListe().getSelectedRow();
SQLRow row = panel.getListe().fetchSelectedRow();
 
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ValidationEcriturePanel.java
23,8 → 23,10
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
 
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
36,6 → 38,7
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
 
public class ValidationEcriturePanel extends JPanel {
42,7 → 45,7
 
private final JDate dateValid;
private final JLabel labelNbValid;
private final JButton buttonValid;
private JButton buttonValid;
private final JCheckBox checkCloture = new JCheckBox("Clôturer cette période");;
private final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
 
49,11 → 52,13
public ValidationEcriturePanel() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.gridx = GridBagConstraints.RELATIVE;
c.gridx = 0;
// date limite
JLabel labelDate = new JLabel("Validation jusqu'au ");
JLabel labelDate = new JLabel("Validation jusqu'au", SwingConstants.RIGHT);
this.add(labelDate, c);
 
c.gridx++;
c.weightx = 1;
this.dateValid = new JDate();
this.add(this.dateValid, c);
this.dateValid.addValueListener(new PropertyChangeListener() {
61,26 → 66,35
dateChanged();
}
});
 
//
c.gridy++;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 0;
c.gridwidth = 2;
this.labelNbValid = new JLabel();
this.labelNbValid.setText("Sélectionnez une date.");
this.add(this.labelNbValid, c);
 
// Cloture
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridx = 0;
c.gridy++;
this.add(this.checkCloture, c);
 
c.gridy++;
c.gridwidth = 1;
c.gridx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.SOUTHEAST;
this.add(createActions(), c);
 
}
 
private JPanel createActions() {
final JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 0));
this.buttonValid = new JButton("Valider");
this.add(this.buttonValid, c);
p.add(this.buttonValid);
final JButton buttonClose = new JButton("Annuler");
p.add(buttonClose);
 
// Listeners
this.buttonValid.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
validActionned();
87,19 → 101,17
}
});
 
c.gridx++;
JButton buttonClose = new JButton("Annuler");
this.add(buttonClose, c);
 
buttonClose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame f = (JFrame) SwingUtilities.getRoot(ValidationEcriturePanel.this);
f.dispose();
final Window window = (Window) SwingUtilities.getRoot(ValidationEcriturePanel.this);
window.dispose();
}
});
return p;
}
 
// TODO from UCDetector: Change visibility of Method "ValidationEcriturePanel.dateChanged()" to private
// TODO from UCDetector: Change visibility of Method "ValidationEcriturePanel.dateChanged()" to
// private
protected final void dateChanged() { // NO_UCD
if (this.dateValid.getDate() != null) {
nbValidationEcriture(this.dateValid.getDate());
132,4 → 144,5
this.labelNbValid.setText("Aucune écritures à valider.");
}
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ListPanelEcritures.java
79,10 → 79,10
*/
protected void handleAction(JButton source, ActionEvent e) {
if (source == this.buttonModifier) {
final SQLRow ecritureRow = new EcritureSQLElement().getTable().getRow(this.getListe().getSelectedId());
final SQLRow ecritureRow = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("ECRITURE").getRow(this.getListe().getSelectedId());
MouvementSQLElement.showSource(ecritureRow.getInt("ID_MOUVEMENT"));
} else if (source == this.buttonEffacer) {
SQLRow row = this.getListe().getSelectedRow();
SQLRow row = this.getListe().fetchSelectedRow();
 
PanelFrame frame = new PanelFrame(new SuppressionEcrituresPanel(row.getInt("ID_MOUVEMENT")), "Suppression");
frame.pack();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ComptaPrefTreeNode.java
26,6 → 26,7
import org.openconcerto.erp.preferences.GenerationDocumentGestCommPreferencePanel;
import org.openconcerto.erp.preferences.GenerationDocumentPayePreferencePanel;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
import org.openconcerto.erp.preferences.GestionPieceCommercialePanel;
import org.openconcerto.erp.preferences.ImpressionGestCommPreferencePanel;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.erp.preferences.NumerotationPreferencePanel;
91,9 → 92,11
 
nsGlobale.add(new PrefTreeNode(PayeGlobalPreferencePanel.class, "Paye", new String[] { "paye", "csg" }));
 
// Gestion des articles
// Gestion commerciale
final PrefTreeNode nGestionArticle = new PrefTreeNode(GestionArticlePreferencePanel.class, "Gestion des articles", new String[] { "articles", "gestion", "longueur", "largeur", "poids" });
final PrefTreeNode nGestionPiece = new PrefTreeNode(GestionPieceCommercialePanel.class, "Gestion des pièces commerciales", new String[] { "mouvements", "pieces", "facture" });
nsPoste.add(nGestionArticle);
nsPoste.add(nGestionPiece);
 
// Mode de règlement par défaut
final PrefTreeNode nModeRegl = new PrefTreeNode(ModeReglementDefautPrefPanel.class, "Mode de règlement par défaut", new String[] { "mode", "règlement", "défaut" });
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ClotureMensuellePayePanel.java
71,9 → 71,8
JLabel labelMois = new JLabel("Cloture du mois de ");
this.add(labelMois, c);
 
MoisSQLElement moisElt = new MoisSQLElement();
final ElementComboBox selMois = new ElementComboBox(true, 25);
selMois.init(moisElt);
selMois.init(((ComptaPropsConfiguration) Configuration.getInstance()).getDirectory().getElement(MoisSQLElement.class));
selMois.setButtonsVisible(false);
c.gridx++;
this.add(selMois, c);
118,13 → 117,10
buttonClot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
// if (selMois.getSelectedId() <= 1 || textAnnee.getText().trim().length() == 0)
// {
// return;
// }
 
// Valider les fiches non validés des salariés actifs
if (boxValid.isSelected()) {
SQLSelect selFiche = new SQLSelect(ClotureMensuellePayePanel.this.base);
SQLSelect selFiche = new SQLSelect();
SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE");
SQLTable tableSalarie = ClotureMensuellePayePanel.this.base.getTable("SALARIE");
SQLTable tableInfosSal = ClotureMensuellePayePanel.this.base.getTable("INFOS_SALARIE_PAYE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/BalanceAgeePanel.java
19,6 → 19,7
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
36,7 → 37,7
public BalanceAgeePanel() {
super(new GridBagLayout());
 
JLabel label = new JLabel("Créer la balance agée client pour la période du ");
JLabel label = new JLabel("Balance âgée client pour la période du ");
 
SQLRow rowExercice = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete().getForeignRow("ID_EXERCICE_COMMON");
Calendar dDebut = rowExercice.getDate("DATE_DEB");
75,8 → 76,8
try {
l.createDocument();
l.openDocument(false);
} catch (Exception e1) {
e1.printStackTrace();
} catch (Exception originalExn) {
ExceptionHandler.handle("Impossible de créer la balance âgée", originalExn);
}
}
});
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ImpressionPayePanel.java
13,7 → 13,9
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.MoisSQLElement;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
52,14 → 54,14
final GridBagConstraints c = new DefaultGridBagConstraints();
Calendar cal = Calendar.getInstance();
// Période
final MoisSQLElement moisElt = new MoisSQLElement();
this.selMoisDeb = new ElementComboBox(true, 25);
final SQLElement moisElt = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(MoisSQLElement.class);
this.selMoisDeb = new ElementComboBox(true, 12);
this.selMoisDeb.init(moisElt);
this.selMoisDeb.setButtonsVisible(false);
 
this.selMoisDeb.setAddIconVisible(false);
 
this.selMoisEnd = new ElementComboBox(true, 25);
this.selMoisEnd = new ElementComboBox(true, 12);
this.selMoisEnd.init(moisElt);
this.selMoisEnd.setButtonsVisible(false);
 
82,7 → 84,7
this.textAnnee = new JTextField(5);
c.gridx++;
c.weightx = 0;
this.add(new JLabel("Année"), c);
this.add(new JLabel("de l'année"), c);
c.gridx++;
c.weightx = 1;
this.textAnnee.setText(this.format.format(cal.getTime()));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/LettragePanel.java
425,7 → 425,7
this.ecriturePanel.getListe().addRowAction(new AbstractAction("Voir la source") {
public void actionPerformed(ActionEvent e) {
 
SQLRow rowEcr = LettragePanel.this.ecriturePanel.getListe().getSelectedRow();
SQLRow rowEcr = LettragePanel.this.ecriturePanel.getListe().fetchSelectedRow();
MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT"));
}
}, "financing.accouning.entries.source.show");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/GestionPlanComptableEFrame.java
21,7 → 21,9
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.SQLTableEvent;
import org.openconcerto.sql.model.SQLTableListener;
import org.openconcerto.sql.model.SQLTableModifiedListener;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ExceptionHandler;
41,9 → 43,9
 
public class GestionPlanComptableEFrame extends JFrame {
 
private JButton boutonAjout = new JButton("Ajout");
private JButton boutonAjout = new JButton("Créer un nouveau compte");
private JButton boutonSuppr = new JButton("Supprimer");
private JButton boutonAjoutPCG = new JButton("Ajout depuis le PCG");
private JButton boutonAjoutPCG = new JButton("Ajouter un compte depuis le PCG");
private EditFrame edit = null;
private AjouterComptePCGtoPCEFrame ajoutCptFrame = null;
 
72,7 → 74,7
 
container.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.fill = GridBagConstraints.NONE;
container.add(this.boutonAjout, c);
 
this.boutonAjout.addActionListener(new ActionListener() {
95,7 → 97,7
});
 
c.gridx++;
container.add(this.boutonAjoutPCG);
container.add(this.boutonAjoutPCG, c);
this.boutonAjoutPCG.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent e) {
116,25 → 118,13
 
container.add(this.panelPCE, c);
 
this.compteTable.addTableListener(new SQLTableListener() {
this.compteTable.addTableModifiedListener(new SQLTableModifiedListener() {
 
public void rowModified(SQLTable table, int id) {
 
SQLRow row = table.getRow(id);
GestionPlanComptableEFrame.this.panelPCE.fireModificationCompte(new Compte(id, row.getString("NUMERO"), row.getString("NOM")));
@Override
public void tableModified(SQLTableEvent evt) {
final SQLRow row = evt.getRow();
GestionPlanComptableEFrame.this.panelPCE.fireModificationCompte(new Compte(evt.getId(), row.getString("NUMERO"), row.getString("NOM")));
}
 
public void rowAdded(SQLTable table, int id) {
 
SQLRow row = table.getRow(id);
GestionPlanComptableEFrame.this.panelPCE.fireModificationCompte(new Compte(id, row.getString("NUMERO"), row.getString("NOM")));
}
 
public void rowDeleted(SQLTable table, int id) {
 
SQLRow row = table.getRow(id);
GestionPlanComptableEFrame.this.panelPCE.fireModificationCompte(new Compte(id, row.getString("NUMERO"), row.getString("NOM")));
}
});
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ListeGestCommEltPanel.java
17,13 → 17,16
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.event.ActionEvent;
import java.util.Collection;
 
import javax.swing.JButton;
 
44,8 → 47,55
super(elem, l);
this.setAddVisible(showAdd);
this.setOpaque(false);
if (elem.getTable().getName().equals("SAISIE_VENTE_FACTURE")) {
this.btnMngr.setAdditional(this.buttonEffacer, new ITransformer<JButton, String>() {
 
@Override
public String transformChecked(JButton input) {
 
SQLRowAccessor row = getListe().fetchSelectedRow();
 
if (row.getBoolean("PARTIAL") && !isLastPartialInvoice(row)) {
return "Vous ne pouvez pas supprimer cette facture intermédiaire.\n Des factures antérieures ont été établies !";
}
return null;
}
});
this.btnMngr.setAdditional(this.buttonModifier, new ITransformer<JButton, String>() {
 
@Override
public String transformChecked(JButton input) {
 
SQLRowAccessor row = getListe().fetchSelectedRow();
 
if (row.getBoolean("PARTIAL") || row.getBoolean("SOLDE")) {
return "Vous ne pouvez pas modifier une facture intermédiaire.";
}
return null;
}
});
}
}
 
public boolean isLastPartialInvoice(SQLRowAccessor sqlRowAccessor) {
Collection<? extends SQLRowAccessor> rows = sqlRowAccessor.getReferentRows(sqlRowAccessor.getTable().getTable("TR_COMMANDE_CLIENT"));
for (SQLRowAccessor sqlRowAccessor2 : rows) {
SQLRowAccessor rowCmd = sqlRowAccessor2.getForeign("ID_COMMANDE_CLIENT");
if (rowCmd != null && !rowCmd.isUndefined()) {
Collection<? extends SQLRowAccessor> rowSFacts = rowCmd.getReferentRows(sqlRowAccessor.getTable().getTable("TR_COMMANDE_CLIENT"));
for (SQLRowAccessor sqlRowAccessor3 : rowSFacts) {
if (!sqlRowAccessor3.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) {
SQLRowAccessor rowFact = sqlRowAccessor3.getForeign("ID_SAISIE_VENTE_FACTURE");
if (rowFact.getDate("DATE").after(sqlRowAccessor.getDate("DATE"))) {
return false;
}
}
}
}
}
return true;
}
 
public ListeGestCommEltPanel(SQLElement elem, IListe l, String variant) {
// TODO verifier que l'element contient la clef etrangere ID_MOUVEMENT
super(elem, l, variant);
74,11 → 124,11
SQLRow row = this.getElement().getTable().getRow(this.getListe().getSelectedId());
 
if (row != null && row.getID() > 1) {
final int idMvt = row.getInt("ID_MOUVEMENT");
final SQLRowAccessor mvt = row.getForeign("ID_MOUVEMENT");
if (source == this.buttonEffacer) {
 
if (idMvt > 1) {
PanelFrame frame = new PanelFrame(new SuppressionEcrituresPanel(idMvt), "Suppression");
if (mvt != null && !mvt.isUndefined()) {
PanelFrame frame = new PanelFrame(new SuppressionEcrituresPanel(mvt.getID()), "Suppression");
frame.pack();
frame.setLocationRelativeTo(null);
frame.setResizable(false);
89,7 → 139,7
} else {
if (source == this.buttonModifier) {
 
if (MouvementSQLElement.isEditable(idMvt)) {
if (mvt == null || mvt.isUndefined() | MouvementSQLElement.isEditable(mvt.getID())) {
if (this.editModifyFrame == null) {
this.editModifyFrame = new EditFrame(this.element, EditPanel.MODIFICATION);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ClotureManuellePanel.java
19,6 → 19,7
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
 
59,8 → 60,8
super();
this.setLayout(new GridBagLayout());
 
final GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(10, 2, 1, 2);
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
c.gridx = 0;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ImpressionJournalPayePanel.java
14,9 → 14,9
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.generationDoc.gestcomm.JournalPaieXmlSheet;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.event.ActionEvent;
import java.util.concurrent.ExecutionException;
 
public class ImpressionJournalPayePanel extends ImpressionPayePanel {
 
29,12 → 29,8
try {
bSheet.createDocument();
bSheet.showPrintAndExport(true, false, false);
} catch (InterruptedException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
} catch (ExecutionException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
} catch (Exception originalExn) {
ExceptionHandler.handle("Erreur lors de l'impression du journal de paye", originalExn);
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/PointageModel.java
85,10 → 85,11
 
if (row != null) {
 
if (row.getString("POINTEE").trim().length() == 0) {
// if (row.getString("POINTEE").trim().length() == 0) {
this.debitSelection += ((Long) row.getObject("DEBIT")).longValue();
this.creditSelection += ((Long) row.getObject("CREDIT")).longValue();
} /*
// }
/*
* else {
*
* this.debitSelection -= row.getFloat("DEBIT"); this.creditSelection -=
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/AssociationAnalytiqueModel.java
116,14 → 116,8
for (int j = 0; j < this.axes.size(); j++) {
 
// on recupere les repartitions pour chaque axe
// RepartitionAnalytiqueSQLElement repElt = new RepartitionAnalytiqueSQLElement();
SQLTable repTable = base.getTable("REPARTITION_ANALYTIQUE");
 
// RepartitionAnalytiqueElementSQLElement repElemElt = new
// RepartitionAnalytiqueElementSQLElement();
SQLTable repElemTable = base.getTable("REPARTITION_ANALYTIQUE_ELEMENT");
 
// PosteAnalytiqueSQLElement posteElt = new PosteAnalytiqueSQLElement();
SQLTable posteTable = base.getTable("POSTE_ANALYTIQUE");
 
SQLSelect selRep = new SQLSelect(base);
334,8 → 328,6
 
}
 
// Vector reps = (Vector) repartitionsAxe.get(columnIndex - 2);
// System.out.println("Value --> " + ((Repartition)aValue).getId());
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/SaisieKmSQLElement.java
226,7 → 226,7
this.textNom = new JTextField();
this.labelTotalCredit = new JLabel("0.00", SwingConstants.RIGHT);
this.labelTotalDebit = new JLabel("0.00", SwingConstants.RIGHT);
this.date = new JDate(true);
this.date = new JDate();
 
this.comboJrnl = new ElementComboBox(false, 20);
 
420,14 → 420,12
}
 
public void select(SQLRowAccessor r) {
 
if (r == null) {
this.dTemp = this.date.getDate();
}
 
super.select(r);
if (r != null) {
this.tableKm.insertFrom("ID_SAISIE_KM", r.getID());
this.tableKm.insertFrom(r);
}
}
 
442,13 → 440,12
 
@Override
protected SQLRowValues createDefaults() {
 
assert SwingUtilities.isEventDispatchThread();
SQLRowValues rowVals = new SQLRowValues(this.getTable());
 
if (this.dTemp == null) {
this.dTemp = new Date();
if (this.dTemp != null) {
rowVals.put("DATE", this.dTemp);
}
rowVals.put("DATE", this.dTemp);
this.tableKm.getModel().clearRows();
this.tableKm.revalidate();
this.tableKm.repaint();
537,10 → 534,12
 
@Override
public synchronized ValidState getValidState() {
assert SwingUtilities.isEventDispatchThread();
return super.getValidState().and(this.validState);
}
 
private void updateValidState() {
assert SwingUtilities.isEventDispatchThread();
ValidState state = ValidState.create(!this.labelMotifWarning.isVisible(), this.labelMotifWarning.getText());
if (!this.isCompteExist && !this.checkCreateCompte.isSelected())
state = state.and(ValidState.createCached(false, "Certains comptes n'existent pas"));
550,6 → 549,7
}
 
private void setValidState(final ValidState state) {
assert SwingUtilities.isEventDispatchThread();
if (!state.equals(this.validState)) {
this.validState = state;
fireValidChange();
557,6 → 557,7
}
 
private void setTotals(final long totalCred, final long totalDeb) {
assert SwingUtilities.isEventDispatchThread();
this.totalCred = totalCred;
this.totalDeb = totalDeb;
this.labelTotalCredit.setText(GestionDevise.currencyToString(this.totalCred));
577,6 → 578,7
}
 
private void tableChanged(TableModelEvent e) {
assert SwingUtilities.isEventDispatchThread();
long totalCred = 0;
long totalDeb = 0;
long totalCredWithNoValid = 0;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/JournalSQLElement.java
23,7 → 23,10
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
30,6 → 33,7
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
62,17 → 66,29
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
public void addViews() {
 
this.add(new JLabel(getLabelFor("CODE")));
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
this.add(new JLabel(getLabelFor("CODE"), SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
final JTextField code = new JTextField(6);
this.add(code);
this.add(code, c);
 
this.add(new JLabel(getLabelFor("NOM")));
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0;
this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
final JTextField nom = new JTextField(25);
this.add(nom);
 
this.add(nom, c);
c.gridy++;
c.anchor = GridBagConstraints.NORTHWEST;
c.weighty = 1;
final JCheckBox checkBox = new JCheckBox(getLabelFor("TYPE_BANQUE"));
this.add(checkBox);
this.add(checkBox, c);
 
this.addView(nom, "NOM", REQ);
this.addView(code, "CODE", REQ);
91,10 → 107,11
public static int getIdJournal(final String nom) {
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLTable journalTable = base.getTable("JOURNAL");
final SQLSelect selJrnl = new SQLSelect(base);
final SQLSelect selJrnl = new SQLSelect();
selJrnl.addSelect(journalTable.getField("ID"));
selJrnl.setWhere(new Where(journalTable.getField("NOM"), "=", nom.trim()));
 
@SuppressWarnings("unchecked")
final List<Object[]> myListJrnl = (List<Object[]>) base.getDataSource().execute(selJrnl.asString(), new ArrayListHandler());
 
if (myListJrnl.size() != 0) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/MouvementSQLElement.java
18,6 → 18,7
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.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLSelect;
142,24 → 143,27
 
if (id != 1) {
final EditFrame f;
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLTable tableMvt = base.getTable("MOUVEMENT");
final ComptaPropsConfiguration comptaPropsConfiguration = (ComptaPropsConfiguration) Configuration.getInstance();
final SQLTable tableMvt = comptaPropsConfiguration.getRootSociete().getTable("MOUVEMENT");
final String stringTableSource = tableMvt.getRow(id).getString("SOURCE").trim();
final int mode = MouvementSQLElement.isEditable(id) ? MouvementSQLElement.MODIFICATION : MouvementSQLElement.READONLY;
 
if (stringTableSource.length() != 0 && tableMvt.getRow(id).getInt("IDSOURCE") != 1) {
final SQLElement elementSource = comptaPropsConfiguration.getDirectory().getElement(stringTableSource);
if (mode == MouvementSQLElement.MODIFICATION) {
f = new EditFrame(Configuration.getInstance().getDirectory().getElement(stringTableSource), EditPanel.MODIFICATION);
 
f = new EditFrame(elementSource, EditPanel.MODIFICATION);
f.getPanel().disableDelete();
} else {
f = new EditFrame(Configuration.getInstance().getDirectory().getElement(stringTableSource), EditPanel.READONLY);
f = new EditFrame(elementSource, EditPanel.READONLY);
}
f.selectionId(tableMvt.getRow(id).getInt("IDSOURCE"));
} else {
final SQLElement elementSource = comptaPropsConfiguration.getDirectory().getElement(SaisieKmSQLElement.class);
if (mode == MouvementSQLElement.MODIFICATION) {
f = new EditFrame(new SaisieKmSQLElement(), EditPanel.MODIFICATION);
f = new EditFrame(elementSource, EditPanel.MODIFICATION);
} else {
f = new EditFrame(new SaisieKmSQLElement(), EditPanel.READONLY);
f = new EditFrame(elementSource, EditPanel.READONLY);
}
// FIXME se passer de requete dans Swing...
try {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/AssociationCompteAnalytiqueSQLElement.java
23,7 → 23,9
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.SQLTableEvent;
import org.openconcerto.sql.model.SQLTableListener;
import org.openconcerto.sql.model.SQLTableModifiedListener;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
84,166 → 86,67
final List<ClasseCompte> classeComptes = new ArrayList<ClasseCompte>();
tabbedClasse = new JTabbedPane();
 
SQLTable classeCompteTable = getTable().getBase().getTable("CLASSE_COMPTE");
SQLBase base = classeCompteTable.getBase();
SQLSelect selClasse = new SQLSelect(base);
 
final SQLTable classeCompteTable = getTable().getBase().getTable("CLASSE_COMPTE");
final SQLSelect selClasse = new SQLSelect();
selClasse.addSelect(classeCompteTable.getField("ID"));
selClasse.addSelect(classeCompteTable.getField("NOM"));
selClasse.addSelect(classeCompteTable.getField("TYPE_NUMERO_COMPTE"));
 
selClasse.addRawOrder("TYPE_NUMERO_COMPTE");
 
String reqClasse = selClasse.asString();
Object obClasse = getTable().getBase().getDataSource().execute(reqClasse, new ArrayListHandler());
 
List myListClasse = (List) obClasse;
 
for (int k = 0; k < myListClasse.size(); k++) {
Object[] objTmp = (Object[]) myListClasse.get(k);
List<Object[]> myListClasse = (List<Object[]>) obClasse;
for (Object[] objTmp : myListClasse) {
ClasseCompte ccTmp = new ClasseCompte(Integer.parseInt(objTmp[0].toString()), objTmp[1].toString(), objTmp[2].toString());
classeComptes.add(ccTmp);
 
tabbedClasse.add(ccTmp.getNom(), new JScrollPane(creerJTable(ccTmp)));
}
 
this.add(tabbedClasse, c);
// FIXME: la fete du copier coller!
AxeAnalytiqueSQLElement axeElt = new AxeAnalytiqueSQLElement();
axeElt.getTable().addTableListener(new SQLTableListener() {
 
public void rowModified(SQLTable table, int id) {
final SQLTableModifiedListener tListener = new SQLTableModifiedListener() {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
@Override
public void tableModified(SQLTableEvent evt) {
final int tabCount = tabbedClasse.getTabCount();
for (int i = 0; i < tabCount; i++) {
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
 
public void rowAdded(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
};
 
public void rowDeleted(SQLTable table, int id) {
final SQLTable tAxeAnalytique = getElement().getDirectory().getElement(AxeAnalytiqueSQLElement.class).getTable();
tAxeAnalytique.addTableModifiedListener(tListener);
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
final SQLTable tRepartitionAnalytique = getElement().getDirectory().getElement(RepartitionAnalytiqueSQLElement.class).getTable();
tRepartitionAnalytique.addTableModifiedListener(tListener);
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
});
final SQLTable tRepartitionAnalytiqueElement = getElement().getDirectory().getElement(RepartitionAnalytiqueElementSQLElement.class).getTable();
tRepartitionAnalytiqueElement.addTableModifiedListener(tListener);
 
RepartitionAnalytiqueSQLElement repElt = new RepartitionAnalytiqueSQLElement();
repElt.getTable().addTableListener(new SQLTableListener() {
final SQLTable tComptePCE = getElement().getDirectory().getElement(ComptePCESQLElement.class).getTable();
tComptePCE.addTableModifiedListener(tListener);
 
public void rowModified(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
 
public void rowAdded(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
 
public void rowDeleted(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
});
 
RepartitionAnalytiqueElementSQLElement repElemElt = new RepartitionAnalytiqueElementSQLElement();
repElemElt.getTable().addTableListener(new SQLTableListener() {
 
public void rowModified(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
 
public void rowAdded(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
 
public void rowDeleted(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
});
 
ComptePCESQLElement compteElt = (ComptePCESQLElement) Configuration.getInstance().getDirectory().getElement("COMPTE_PCE");
compteElt.getTable().addTableListener(new SQLTableListener() {
 
public void rowModified(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
 
public void rowAdded(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
 
public void rowDeleted(SQLTable table, int id) {
 
for (int i = 0; i < tabbedClasse.getTabCount(); i++) {
 
tabbedClasse.setComponentAt(i, new JScrollPane(creerJTable(classeComptes.get(i))));
}
}
});
}
};
 
}
 
public JTable creerJTable(ClasseCompte ccTmp) {
 
AssociationAnalytiqueModel model = new AssociationAnalytiqueModel(ccTmp);
 
JTable table = new JTable(model);
 
Vector vect = model.getRepartitionsAxe();
 
final AssociationAnalytiqueModel model = new AssociationAnalytiqueModel(ccTmp);
final JTable table = new JTable(model);
final Vector vect = model.getRepartitionsAxe();
table.getColumnModel().getColumn(0).setCellRenderer(new PlanComptableCellRenderer(0));
table.getColumnModel().getColumn(1).setCellRenderer(new PlanComptableCellRenderer(0));
 
for (int i = 0; i < vect.size(); i++) {
 
Vector rep = (Vector) vect.get(i);
final Vector rep = (Vector) vect.get(i);
JComboBox combo = new JComboBox();
for (int j = 0; j < rep.size(); j++) {
combo.addItem(rep.get(j));
}
 
table.getColumnModel().getColumn(i + 2).setCellEditor(new DefaultCellEditor(combo));
table.getColumnModel().getColumn(i + 2).setCellRenderer(new PlanComptableCellRenderer(0));
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java
50,6 → 50,7
import java.awt.event.KeyEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
 
272,12 → 273,6
this.journal.setEnabled(false);
}
 
/*
* System.out.println("Impossible de modifier une ecriture validée");
* SaisieKmSQLElement elt = new SaisieKmSQLElement(); EditFrame edit = new
* EditFrame(elt); edit.selectionId(row.getInt("ID_MOUVEMENT"), 0); edit.pack();
* edit.setVisible(true);
*/
}
 
public void update() {
323,7 → 318,7
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
 
SQLSelect selectFils = new SQLSelect(base);
SQLSelect selectFils = new SQLSelect();
selectFils.addSelect(tableMvt.getField("ID"));
selectFils.setWhere(tableMvt.getField("ID_MOUVEMENT_PERE"), "=", idMvtPere);
 
593,4 → 588,38
protected String createCode() {
return createCodeFromPackage() + ".entry.item";
}
 
public static void dupliquer(SQLRow selectedRow) {
 
final SQLRow foreignMvt = selectedRow.getForeign("ID_MOUVEMENT");
if (foreignMvt.getString("SOURCE").equalsIgnoreCase("SAISIE_KM")) {
final SQLElement elementSaisieKm = Configuration.getInstance().getDirectory().getElement("SAISIE_KM");
final SQLElement elementSaisieKmItem = Configuration.getInstance().getDirectory().getElement("SAISIE_KM_ELEMENT");
final EditFrame frameCloneSaisieKm = new EditFrame(elementSaisieKm);
int idSource = foreignMvt.getInt("IDSOURCE");
SQLRow rowKm = elementSaisieKm.getTable().getRow(idSource);
final SQLRowValues rowVals = elementSaisieKm.createCopy(idSource);
rowVals.put("ID_MOUVEMENT", null);
Collection<SQLRow> items = rowKm.getReferentRows(elementSaisieKm.getTable().getTable("SAISIE_KM_ELEMENT"));
for (SQLRow sqlRow : items) {
SQLRowValues sqlRowValues = elementSaisieKmItem.createCopy(sqlRow.getID());
sqlRowValues.put("ID_ECRITURE", null);
sqlRowValues.put("ID_SAISIE_KM", rowVals);
System.err.println("ADD ELEMENT KM :: " + sqlRowValues.getID());
}
 
SwingUtilities.invokeLater(new Runnable() {
public void run() {
frameCloneSaisieKm.getSQLComponent().select(rowVals);
}
});
frameCloneSaisieKm.setVisible(true);
} else {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "La duplication n'est possible que sur les saisies au kilomètre");
}
});
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/ui/TvaPreferencePanel.java
13,6 → 13,7
package org.openconcerto.erp.core.finance.tax.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.finance.tax.element.TaxeSQLElement;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.ui.DefaultGridBagConstraints;
31,7 → 32,7
cPanel.weightx = 1;
cPanel.weighty = 1;
 
final ListeAddPanel listeTaxe = new ListeAddPanel(new TaxeSQLElement());
final ListeAddPanel listeTaxe = new ListeAddPanel(ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(TaxeSQLElement.class));
listeTaxe.setAdjustVisible(false);
listeTaxe.setCloneVisible(false);
listeTaxe.setReloadVisible(false);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/model/TaxeCache.java
16,50 → 16,49
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.ExceptionHandler;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
public final class TaxeCache {
 
static private final SQLSelect getSel() {
// FIXME récupérer les comptes de TVA pour eviter les fetchs
final DBRoot root = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete();
final SQLTable table = root.getTable("TAXE");
final SQLSelect sel = new SQLSelect(table.getBase());
final SQLSelect sel = new SQLSelect();
sel.addSelect(table.getField("ID_TAXE"));
sel.addSelect(table.getField("TAUX"));
sel.addSelect(table.getField("DEFAULT"));
return sel;
}
 
private transient final Map<Integer, Float> mapTaux = new HashMap<Integer, Float>();
private transient final Map<SQLRowAccessor, Float> mapRowTaux = new LinkedHashMap<SQLRowAccessor, Float>();
private static TaxeCache instance;
private transient Integer firstIdTaxe = null;
private transient SQLRow firstIdTaxe = null;
 
private TaxeCache() {
final SQLSelect sel = getSel();
final String req = sel.asString();
sel.getSelectFields().get(0).getDBSystemRoot().getDataSource().execute(req, new ResultSetHandler() {
 
public Object handle(final ResultSet resultSet) throws SQLException {
while (resultSet.next()) {
final int idTaxe = resultSet.getInt(1);
final Float resultTaux = Float.valueOf(resultSet.getFloat(2));
TaxeCache.this.mapTaux.put(Integer.valueOf(idTaxe), resultTaux);
final List<SQLRow> l = SQLRowListRSH.execute(sel);
for (SQLRow sqlRow : l) {
this.mapRowTaux.put(sqlRow, sqlRow.getFloat("TAUX"));
this.mapTaux.put(sqlRow.getID(), sqlRow.getFloat("TAUX"));
if (sqlRow.getBoolean("DEFAULT")) {
this.firstIdTaxe = sqlRow;
}
return null;
}
});
 
}
 
synchronized public static TaxeCache getCache() {
73,19 → 72,21
return this.mapTaux.get(Integer.valueOf(idTaux));
}
 
public Integer getFirstTaxe() {
public SQLRow getFirstTaxe() {
if (this.firstIdTaxe == null) {
final SQLBase table = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLSelect sel = getSel();
final String req = sel.asString();
final List<Object[]> list = (List<Object[]>) table.getDataSource().execute(req, new ArrayListHandler());
if (list != null && !list.isEmpty()) {
final Object[] tmp = list.get(0);
this.firstIdTaxe = Integer.parseInt(tmp[0].toString());
sel.setWhere(new Where(sel.getTable("TAXE").getField("DEFAULT"), "=", Boolean.TRUE));
final List<SQLRow> rows = SQLRowListRSH.execute(sel);
if (rows != null && !rows.isEmpty()) {
 
this.firstIdTaxe = rows.get(0);
} else {
ExceptionHandler.handle("Aucune TVA par défaut définie!", new IllegalArgumentException("Aucune TVA par défaut définie!"));
return mapRowTaux.keySet().iterator().next().asRow();
}
 
}
return this.firstIdTaxe;
 
}
 
public Integer getIdFromTaux(Float tax) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/element/TaxeSQLElement.java
14,28 → 14,85
package org.openconcerto.erp.core.finance.tax.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.model.ISQLCompteSelector;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ProductInfo;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
public class TaxeSQLElement extends ComptaSQLConfElement {
 
public TaxeSQLElement() {
super("TAXE", "une taxe", "taxes");
 
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Définir par défaut") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
final SQLRowAccessor row = IListe.get(e).getSelectedRow();
final SQLDataSource ds = row.getTable().getDBSystemRoot().getDataSource();
 
try {
SQLUtils.executeAtomic(ds, new SQLUtils.SQLFactory<Object>() {
@Override
public Object create() throws SQLException {
// Transaction
UpdateBuilder upRemoveDefault = new UpdateBuilder(row.getTable());
upRemoveDefault.set("DEFAULT", "FALSE");
 
ds.execute(upRemoveDefault.asString());
 
UpdateBuilder upSetDefault = new UpdateBuilder(row.getTable());
upSetDefault.set("DEFAULT", "TRUE");
upSetDefault.setWhere(new Where(row.getTable().getKey(), "=", row.getID()));
 
ds.execute(upSetDefault.asString());
 
JOptionPane.showMessageDialog(null, "Rédémarrez " + ProductInfo.getInstance().getName() + " pour valider le changement de TVA par défaut.");
 
return null;
}
});
} catch (Exception ex) {
throw new IllegalStateException("Erreur lors d'affectation de la nouvelle TVA par défaut", ex);
}
 
}
}, true);
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
 
this.getRowActions().add(action);
 
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
l.add("TAUX");
l.add("DEFAULT");
return l;
}
 
53,48 → 110,63
 
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
JLabel labelNom = new JLabel(getLabelFor("NOM"));
JLabel labelNom = new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT);
 
this.add(labelNom, c);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
JTextField fieldNom = new JTextField(40);
DefaultGridBagConstraints.lockMinimumSize(fieldNom);
this.add(fieldNom, c);
c.gridx++;
c.gridx = 0;
c.gridy++;
c.weightx = 0;
JLabel labelTaux = new JLabel(getLabelFor("TAUX"));
c.fill = GridBagConstraints.HORIZONTAL;
JLabel labelTaux = new JLabel(getLabelFor("TAUX"), SwingConstants.RIGHT);
this.add(labelTaux, c);
c.gridx++;
c.fill = GridBagConstraints.NONE;
JTextField fieldTaux = new JTextField(6);
DefaultGridBagConstraints.lockMinimumSize(fieldTaux);
this.add(fieldTaux, c);
 
// JLabel labelCompteCol = new JLabel(getLabelFor("ID_COMPTE_PCE_COLLECTE"));
// c.gridx = 0;
// c.gridy++;
// this.add(labelCompteCol, c);
// c.gridx++;
// c.weightx = 1;
// c.gridwidth = GridBagConstraints.REMAINDER;
// ISQLCompteSelector compteCol = new ISQLCompteSelector();
// this.add(compteCol, c);
//
// JLabel labelCompteDed = new JLabel(getLabelFor("ID_COMPTE_PCE_DED"));
// c.gridx = 0;
// c.gridy++;
// c.weightx = 0;
// c.gridwidth = 1;
// this.add(labelCompteDed, c);
// c.gridx++;
// c.weightx = 1;
// c.gridwidth = GridBagConstraints.REMAINDER;
// ISQLCompteSelector compteDed = new ISQLCompteSelector();
// this.add(compteDed, c);
//
// this.addSQLObject(compteCol, "ID_COMPTE_PCE_COLLECTE");
// this.addSQLObject(compteDed, "ID_COMPTE_PCE_DED");
JLabel labelCompteCol = new JLabel(getLabelFor("ID_COMPTE_PCE_COLLECTE"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy++;
this.add(labelCompteCol, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteCol = new ISQLCompteSelector();
this.add(compteCol, c);
 
 
 
JLabel labelCompteDed = new JLabel(getLabelFor("ID_COMPTE_PCE_DED"), SwingConstants.RIGHT);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(labelCompteDed, c);
c.gridx++;
c.weightx = 1;
 
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteDed = new ISQLCompteSelector();
this.add(compteDed, c);
 
// Spacer
c.gridy++;
c.weighty = 1;
c.anchor = GridBagConstraints.NORTHWEST;
this.add(new JPanel(), c);
 
this.addSQLObject(compteCol, "ID_COMPTE_PCE_COLLECTE");
this.addSQLObject(compteDed, "ID_COMPTE_PCE_DED");
 
this.addRequiredSQLObject(fieldNom, "NOM");
this.addRequiredSQLObject(fieldTaux, "TAUX");
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/ModeDeReglementSQLComponent.java
13,8 → 13,8
package org.openconcerto.erp.core.finance.payment.component;
 
import static org.openconcerto.utils.CollectionUtils.createSet;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Log;
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
import org.openconcerto.erp.model.BanqueModifiedListener;
import org.openconcerto.sql.Configuration;
22,7 → 22,6
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ComboSQLRequest;
33,6 → 32,7
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.component.ITextCombo;
import org.openconcerto.utils.CollectionUtils;
 
import java.awt.Dimension;
import java.awt.GridBagConstraints;
43,6 → 43,7
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
 
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
54,98 → 55,86
 
public class ModeDeReglementSQLComponent extends BaseSQLComponent {
 
private ElementComboBox boxBanque = new ElementComboBox(true, 20);
private JPanel panelBanque = new JPanel(new GridBagLayout());
private JPanel panelEcheance = new JPanel(new GridBagLayout());
static private enum Mode {
ECHEANCE, CHEQUE, VIREMENT
}
 
static public final int MONTH_END = 31;
static public final int AT_INVOICE_DATE = 0;
 
private final ElementComboBox boxBanque = new ElementComboBox(true, 20);
private final JPanel panelBanque = new JPanel(new GridBagLayout());
private final JPanel panelEcheance = new JPanel(new GridBagLayout());
private final EventListenerList banqueModifiedListenerList = new EventListenerList();
private final SQLRequestComboBox comboTypeReglement = new SQLRequestComboBox();
private ITextCombo comboA;
private ITextCombo comboLe = new SQLTextCombo();
private SQLSearchableTextCombo comboBanque = new SQLSearchableTextCombo();
private JRadioButton buttonFinMois = new JRadioButton("fin de mois");
private JRadioButton buttonDateFacture = new JRadioButton("date de facturation");
private JRadioButton buttonLe = new JRadioButton("le");
private JCheckBox checkboxComptant = new JCheckBox("Comptant");
private JDate dateDepot = new JDate(false);
private JDate dateVirt = new JDate(false);
private JDate dateCheque = new JDate(false);
private JTextField numeroChq = new JTextField();
private JTextField nom = new JTextField(30);
private static final int MODE_VIRT = 3;
private static final int MODE_CHEQUE = 2;
private static final int MODE_ECHEANCE = 1;
private final ITextCombo comboLe = new SQLTextCombo();
private final SQLSearchableTextCombo comboBanque = new SQLSearchableTextCombo();
private final JRadioButton buttonFinMois = new JRadioButton("fin de mois");
private final JRadioButton buttonDateFacture = new JRadioButton("date de facturation");
private final JRadioButton buttonLe = new JRadioButton("le");
private final JCheckBox checkboxComptant = new JCheckBox("Comptant");
private final JDate dateDepot = new JDate(false);
private final JDate dateVirt = new JDate(false);
private final JDate dateCheque = new JDate(false);
private final JTextField numeroChq = new JTextField();
private final JTextField nom = new JTextField(30);
private JPanel panelActive = null;
private Map<Integer, JPanel> m = new HashMap<Integer, JPanel>();
private final Map<Mode, JPanel> m = new HashMap<Mode, JPanel>();
 
private int rowIdMode;
 
private void setComponentModeEnabled(SQLRow rowTypeRegl) {
private void setComponentModeEnabled(final SQLRow rowTypeRegl) {
 
if (rowTypeRegl != null && rowIdMode != rowTypeRegl.getID()) {
rowIdMode = rowTypeRegl.getID();
System.err.println("ModeDeReglementNGSQLComponent.setComponentModeEnabled() " + rowIdMode);
if (rowTypeRegl != null && this.rowIdMode != rowTypeRegl.getID()) {
this.rowIdMode = rowTypeRegl.getID();
System.err.println("ModeDeReglementNGSQLComponent.setComponentModeEnabled() " + this.rowIdMode);
} else {
 
return;
}
 
ButtonGroup group = new ButtonGroup();
final ButtonGroup group = new ButtonGroup();
group.add(this.buttonFinMois);
group.add(this.buttonDateFacture);
group.add(this.buttonLe);
 
final Boolean boolean1 = rowTypeRegl.getBoolean("ECHEANCE");
final Boolean forceLater = rowTypeRegl.getBoolean("ECHEANCE");
final Boolean forceNow = rowTypeRegl.getBoolean("COMPTANT");
if (forceLater && forceNow)
Log.get().warning("Force opposite for " + rowTypeRegl);
 
final Boolean boolean2 = rowTypeRegl.getBoolean("COMPTANT");
this.allowEditable(this.getView(this.checkboxComptant), !forceLater && !forceNow);
 
this.checkboxComptant.setEnabled(!(boolean1 || boolean2));
 
if (boolean1) {
if (forceLater) {
this.checkboxComptant.setSelected(false);
}
if (boolean2) {
if (forceNow) {
this.checkboxComptant.setSelected(true);
}
 
setEcheanceEnabled(!this.checkboxComptant.isSelected());
 
// Si cheque et comptant
boolean chequeComptant = (rowTypeRegl.getID() == TypeReglementSQLElement.CHEQUE && this.checkboxComptant.isSelected());
// if (isTCP) {
int mode = MODE_ECHEANCE;
if (chequeComptant) {
mode = MODE_CHEQUE;
} else {
boolean virtComptant = (rowTypeRegl.getID() == TypeReglementSQLElement.TRAITE && this.checkboxComptant.isSelected());
if (virtComptant) {
mode = MODE_VIRT;
updatePanel();
}
}
 
replacePanel(mode);
 
}
 
public ModeDeReglementSQLComponent(SQLElement elt) {
public ModeDeReglementSQLComponent(final SQLElement elt) {
super(elt);
}
 
// private
private JPanel infosCheque = new JPanel(new GridBagLayout());
private JPanel infosVirt = new JPanel(new GridBagLayout());
final ItemListener listenerComptant = new ItemListener() {
private final JPanel infosCheque = new JPanel(new GridBagLayout());
private final JPanel infosVirt = new JPanel(new GridBagLayout());
 
@Override
public void itemStateChanged(ItemEvent e) {
// System.err.println("Comptant");
setEcheanceEnabled(!ModeDeReglementSQLComponent.this.checkboxComptant.isSelected());
protected Set<String> createRequiredNames() {
return CollectionUtils.createSet("ID_TYPE_REGLEMENT");
}
};
 
@Override
public void addViews() {
 
this.setLayout(new GridBagLayout());
 
GridBagConstraints c = new DefaultGridBagConstraints();
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
183,18 → 172,23
createPanelEcheance();
this.add(this.panelEcheance, c);
 
this.addView(this.comboTypeReglement, "ID_TYPE_REGLEMENT");
this.addView(this.checkboxComptant, "COMPTANT");
 
// cheque
this.addSQLObject(this.comboBanque, "ETS");
this.addSQLObject(this.numeroChq, "NUMERO");
this.addSQLObject(this.dateCheque, "DATE");
this.addSQLObject(this.numeroChq, "NUMERO");
this.addSQLObject(this.dateDepot, "DATE_DEPOT");
 
// virement
this.addSQLObject(this.nom, "NOM");
this.addSQLObject(this.dateVirt, "DATE_VIREMENT");
 
this.addRequiredSQLObject(this.comboA, "AJOURS");
this.addSQLObject(this.buttonDateFacture, "DATE_FACTURE");
this.addSQLObject(this.buttonFinMois, "FIN_MOIS");
this.addRequiredSQLObject(this.comboLe, "LENJOUR");
this.addSQLObject(this.buttonFinMois, "FIN_MOIS");
this.addSQLObject(this.buttonDateFacture, "DATE_FACTURE");
this.addSQLObject(this.dateDepot, "DATE_DEPOT");
this.addSQLObject(this.dateVirt, "DATE_VIREMENT");
this.addSQLObject(this.checkboxComptant, "COMPTANT");
this.addRequiredSQLObject(this.comboTypeReglement, "ID_TYPE_REGLEMENT");
 
// Listeners
 
201,12 → 195,12
this.comboTypeReglement.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
Integer id = ModeDeReglementSQLComponent.this.comboTypeReglement.getValue();
public void propertyChange(final PropertyChangeEvent evt) {
final Integer id = ModeDeReglementSQLComponent.this.comboTypeReglement.getValue();
// System.err.println("value changed to " + id);
if (id != null && id > 1) {
 
SQLRow ligneTypeReg = SQLBackgroundTableCache.getInstance().getCacheForTable(getTable().getBase().getTable("TYPE_REGLEMENT")).getRowFromId(id);
final SQLRow ligneTypeReg = SQLBackgroundTableCache.getInstance().getCacheForTable(getTable().getBase().getTable("TYPE_REGLEMENT")).getRowFromId(id);
 
setComponentModeEnabled(ligneTypeReg);
 
216,36 → 210,56
}
});
 
this.buttonLe.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
allowEditable(getView(ModeDeReglementSQLComponent.this.comboLe), e.getStateChange() == ItemEvent.SELECTED && !ModeDeReglementSQLComponent.this.checkboxComptant.isSelected());
}
});
// initial value
this.allowEditable(this.getView(this.comboLe), false);
 
this.buttonFinMois.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
public void itemStateChanged(final ItemEvent e) {
// System.err.println("Fin de mois");
if (ModeDeReglementSQLComponent.this.buttonFinMois.isSelected()) {
ModeDeReglementSQLComponent.this.comboLe.setValue("31");
if (e.getStateChange() == ItemEvent.SELECTED) {
ModeDeReglementSQLComponent.this.comboLe.setValue(String.valueOf(MONTH_END));
}
boolean activeComboLe = !ModeDeReglementSQLComponent.this.buttonFinMois.isSelected() && !ModeDeReglementSQLComponent.this.checkboxComptant.isSelected();
ModeDeReglementSQLComponent.this.comboLe.setEnabled(activeComboLe);
}
});
 
this.buttonDateFacture.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
public void itemStateChanged(final ItemEvent e) {
// System.err.println("Date de facturation");
if (ModeDeReglementSQLComponent.this.buttonDateFacture.isSelected()) {
ModeDeReglementSQLComponent.this.comboLe.setValue("0");
if (e.getStateChange() == ItemEvent.SELECTED) {
ModeDeReglementSQLComponent.this.comboLe.setValue(String.valueOf(AT_INVOICE_DATE));
}
boolean activeComboLe = !ModeDeReglementSQLComponent.this.buttonDateFacture.isSelected() && !ModeDeReglementSQLComponent.this.checkboxComptant.isSelected();
ModeDeReglementSQLComponent.this.comboLe.setEnabled(activeComboLe);
}
});
 
this.checkboxComptant.addItemListener(listenerComptant);
this.getView(this.comboLe).addValueListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
final Number newVal = (Number) evt.getNewValue();
if (newVal != null && newVal.intValue() != AT_INVOICE_DATE && newVal.intValue() != MONTH_END) {
ModeDeReglementSQLComponent.this.buttonLe.setSelected(true);
}
}
});
 
this.checkboxComptant.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
setEcheanceEnabled(e.getStateChange() == ItemEvent.DESELECTED);
}
});
}
 
private void createPanelEcheance() {
 
GridBagConstraints c = new DefaultGridBagConstraints();
final GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.NONE;
this.panelEcheance.setOpaque(false);
this.panelEcheance.add(new JLabel("A"), c);
280,15 → 294,15
this.comboLe.setMaximumSize(new Dimension(60, this.comboLe.getMinimumSize().height));
this.panelEcheance.add(this.comboLe, c);
this.panelActive = this.panelEcheance;
this.m.put(MODE_ECHEANCE, this.panelEcheance);
this.m.put(Mode.ECHEANCE, this.panelEcheance);
 
DefaultGridBagConstraints.lockMinimumSize(panelEcheance);
DefaultGridBagConstraints.lockMinimumSize(this.panelEcheance);
 
}
 
public void createPanelChequeComptant() {
// this.infosCheque.setBorder(BorderFactory.createTitledBorder("Informations Chèque"));
GridBagConstraints cCheque = new DefaultGridBagConstraints();
final GridBagConstraints cCheque = new DefaultGridBagConstraints();
this.infosCheque.add(new JLabel("Banque"), cCheque);
cCheque.gridx++;
 
305,7 → 319,7
 
this.infosCheque.add(this.dateCheque, cCheque);
 
JLabel labelDepot = new JLabel("A déposer après le");
final JLabel labelDepot = new JLabel("A déposer après le");
cCheque.gridx++;
DefaultGridBagConstraints.lockMinimumSize(this.infosCheque);
this.infosCheque.add(labelDepot, cCheque);
312,14 → 326,14
 
cCheque.gridx++;
this.infosCheque.add(this.dateDepot, cCheque);
this.m.put(MODE_CHEQUE, this.infosCheque);
this.m.put(Mode.CHEQUE, this.infosCheque);
this.infosCheque.setVisible(false);
DefaultGridBagConstraints.lockMinimumSize(infosCheque);
DefaultGridBagConstraints.lockMinimumSize(this.infosCheque);
}
 
public void createPanelVirementComptant() {
// this.infosVirt.setBorder(BorderFactory.createTitledBorder("Informations Virement"));
GridBagConstraints cCheque = new DefaultGridBagConstraints();
final GridBagConstraints cCheque = new DefaultGridBagConstraints();
cCheque.weightx = 1;
this.infosVirt.add(new JLabel("Libellé"), cCheque);
cCheque.gridx++;
333,120 → 347,76
cCheque.gridx++;
 
this.infosVirt.add(this.dateVirt, cCheque);
this.m.put(MODE_VIRT, this.infosVirt);
this.m.put(Mode.VIREMENT, this.infosVirt);
this.infosVirt.setVisible(false);
DefaultGridBagConstraints.lockMinimumSize(infosVirt);
DefaultGridBagConstraints.lockMinimumSize(this.infosVirt);
}
 
private void replacePanel(int mode) {
JPanel panel = this.m.get(mode);
private void updatePanel() {
final Integer typeReglt = this.comboTypeReglement.getValue();
if (typeReglt == null)
return;
final boolean comptant = this.checkboxComptant.isSelected();
 
final Mode mode;
if (comptant && typeReglt == TypeReglementSQLElement.CHEQUE) {
mode = Mode.CHEQUE;
} else if (comptant && typeReglt == TypeReglementSQLElement.TRAITE) {
mode = Mode.VIREMENT;
} else {
mode = Mode.ECHEANCE;
}
replacePanel(mode);
}
 
private void replacePanel(final Mode mode) {
final JPanel panel = this.m.get(mode);
if (panel != this.panelActive) {
// System.err.println("replace panel " + mode);
this.panelActive.setVisible(false);
clearFields();
panel.setVisible(true);
this.panelActive = panel;
}
 
}
 
private void clearFields() {
System.err.println("ModeDeReglementNGSQLComponent.clearFields()");
this.dateCheque.setValue(null);
this.dateDepot.setValue(null);
this.dateVirt.setValue(null);
this.nom.setText("");
this.numeroChq.setText("");
this.comboBanque.setValue("");
}
 
private void fireBanqueIdChange(int id) {
BanqueModifiedListener[] l = this.banqueModifiedListenerList.getListeners(BanqueModifiedListener.class);
for (BanqueModifiedListener banqueModifiedListener : l) {
private void fireBanqueIdChange(final int id) {
final BanqueModifiedListener[] l = this.banqueModifiedListenerList.getListeners(BanqueModifiedListener.class);
for (final BanqueModifiedListener banqueModifiedListener : l) {
banqueModifiedListener.idChange(id);
}
}
 
@Override
public void select(SQLRowAccessor r) {
if (r != null) {
final SQLRowValues rVals = r.asRowValues();
final SQLRowValues vals = new SQLRowValues(r.getTable());
 
this.checkboxComptant.removeItemListener(this.listenerComptant);
 
vals.load(rVals, createSet("ID_TYPE_REGLEMENT", "COMPTANT"));
// // vals a besoin de l'ID sinon incohérence entre ID_AFFAIRE et ID (eg for
// reloadTable())
// // ne pas supprimer l'ID de rVals pour qu'on puisse UPDATE
vals.setID(rVals.getID());
super.select(vals);
 
ModeDeReglementSQLComponent.this.comboTypeReglement.setValue(vals.getInt("ID_TYPE_REGLEMENT"));
ModeDeReglementSQLComponent.this.checkboxComptant.setSelected(vals.getBoolean("COMPTANT"));
setComponentModeEnabled(SQLBackgroundTableCache.getInstance().getCacheForTable(r.getTable().getTable("TYPE_REGLEMENT")).getRowFromId(vals.getInt("ID_TYPE_REGLEMENT")));
 
setEcheanceEnabled(!vals.getBoolean("COMPTANT"), vals.getInt("ID_TYPE_REGLEMENT"));
super.select(rVals);
if (rVals.getObject("LENJOUR") != null && rVals.getInt("LENJOUR") != 0 && rVals.getInt("LENJOUR") != 31) {
this.buttonLe.setSelected(true);
}
this.checkboxComptant.addItemListener(this.listenerComptant);
} else {
super.select(r);
}
}
 
private void setEcheanceEnabled(boolean b) {
setEcheanceEnabled(b, this.comboTypeReglement.getValue());
}
 
// Active/Desactive le panel pour specifie la date d'echeance
private void setEcheanceEnabled(boolean b, Integer typeReglt) {
private void setEcheanceEnabled(final boolean b) {
// System.err.println("set echeance to " + b);
this.comboA.setEnabled(b);
this.comboLe.setEnabled(b);
this.buttonFinMois.setEnabled(b);
this.buttonDateFacture.setEnabled(b);
this.allowEditable(this.getView(this.comboA), b);
this.allowEditable(this.getView(this.comboLe), b && this.buttonLe.isSelected());
this.allowEditable(this.getView(this.buttonFinMois), b);
this.allowEditable(this.getView(this.buttonDateFacture), b);
this.buttonLe.setEnabled(b);
if (!b) {
this.buttonLe.setSelected(true);
this.comboA.setValue("0");
this.comboLe.setValue("0");
this.buttonDateFacture.setSelected(true);
} else {
// TODO factor with createDefaults()
this.comboA.setValue("30");
this.buttonDateFacture.setSelected(true);
this.buttonFinMois.setSelected(true);
}
 
if (typeReglt != null) {
 
boolean chequeComptant = (typeReglt == TypeReglementSQLElement.CHEQUE && (!b));
int mode = MODE_ECHEANCE;
if (chequeComptant) {
mode = MODE_CHEQUE;
} else {
boolean virtComptant = (typeReglt == TypeReglementSQLElement.TRAITE && (!b));
if (virtComptant) {
mode = MODE_VIRT;
updatePanel();
}
}
replacePanel(mode);
 
}
 
this.panelActive.revalidate();
this.panelActive.repaint();
}
 
// ATTN sometimes overwritten by ModeReglementDefautPrefPanel.getDefaultRow(true);
@Override
protected SQLRowValues createDefaults() {
final SQLRowValues vals = new SQLRowValues(getTable());
vals.put("COMPTANT", Boolean.FALSE);
vals.put("AJOURS", 30);
vals.put("LENJOUR", 31);
this.buttonLe.setSelected(true);
vals.put("FIN_MOIS", Boolean.TRUE);
return vals;
}
 
public void setWhereBanque(Where w) {
public void setWhereBanque(final Where w) {
if (this.boxBanque != null && this.boxBanque.isShowing()) {
final ComboSQLRequest request = this.boxBanque.getRequest();
if (request != null) {
456,7 → 426,7
}
}
 
public void setSelectedIdBanque(int id) {
public void setSelectedIdBanque(final int id) {
this.boxBanque.setValue(id);
}
 
464,7 → 434,7
return this.boxBanque.getSelectedId();
}
 
public void addBanqueModifiedListener(BanqueModifiedListener e) {
public void addBanqueModifiedListener(final BanqueModifiedListener e) {
this.banqueModifiedListenerList.add(BanqueModifiedListener.class, e);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ChequeAEncaisserSQLElement.java
14,12 → 14,18
package org.openconcerto.erp.core.finance.payment.element;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeSheet;
import org.openconcerto.erp.generationEcritures.GenerationMvtReglementChequeClient;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.ShowAs;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
 
26,12 → 32,13
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.SwingConstants;
 
public class ChequeAEncaisserSQLElement extends ComptaSQLConfElement {
public class ChequeAEncaisserSQLElement extends ChequeSQLElement {
 
public ChequeAEncaisserSQLElement() {
super("CHEQUE_A_ENCAISSER", "un chéque client", "chéques clients");
53,6 → 60,60
return l;
}
 
@Override
public String getDoneFieldName() {
return "ENCAISSE";
}
 
@Override
public String getDateFieldName() {
return "DATE_DEPOT";
}
 
@Override
public String getMinDateFieldName() {
return "DATE_MIN_DEPOT";
}
 
@Override
public void print(final List<Integer> listeCheque, final boolean preview, final Date d) {
ReleveChequeSheet sheet = new ReleveChequeSheet(listeCheque, d, preview);
sheet.createDocumentAsynchronous();
sheet.showPrintAndExportAsynchronous(true, false, true);
}
 
@Override
public void handle(SQLRowAccessor rowCheque, Date d, String label) throws Exception {
GenerationMvtReglementChequeClient gen = new GenerationMvtReglementChequeClient(rowCheque.getForeignID("ID_MOUVEMENT"), rowCheque.getLong("MONTANT"), d, rowCheque.getID(), label);
gen.genere();
}
 
@Override
public SQLTableModelSourceOnline createDepositTableSource() {
final List<String> l = new ArrayList<String>();
l.add("ETS");
l.add("NUMERO");
l.add("DATE");
l.add("ID_MOUVEMENT");
l.add("DATE_VENTE");
l.add(getMinDateFieldName());
l.add("ID_CLIENT");
l.add("MONTANT");
 
final ShowAs showAs = new ShowAs(getTable().getDBRoot());
 
final SQLTable mvtT = getTable().getForeignTable("ID_MOUVEMENT");
showAs.show(mvtT, "ID_PIECE");
showAs.show(mvtT.getForeignTable("ID_PIECE"), "NOM");
 
final SQLTable clientERP = getTable().getForeignTable("ID_CLIENT");
{
showAs.show(clientERP, "NOM");
}
 
return this.createDepositTableSource(l, showAs, new Where(getTable().getField("REG_COMPTA"), "=", Boolean.FALSE));
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE_VENTE");
</
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ChequeAvoirClientSQLElement.java
13,11 → 13,17
package org.openconcerto.erp.core.finance.payment.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.generationEcritures.GenerationMvtReglementAvoirChequeClient;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.ShowAs;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
 
24,12 → 30,13
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import javax.swing.JLabel;