OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 141 → Rev 142

/trunk/OpenConcerto/.classpath
38,5 → 38,7
<classpathentry kind="lib" path="lib/json-smart-1.3.1.jar"/>
<classpathentry kind="lib" path="lib/icu4j-56_1-module_format+calendar.jar"/>
<classpathentry kind="lib" path="lib/icu4j-56-data-western_europe.jar"/>
<classpathentry kind="lib" path="lib/DS_Desktop_Notify.jar"/>
<classpathentry kind="lib" path="lib/mime_util.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/OpenConcerto/lib/jOpenDocument-1.4rc2.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/mime_util.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/mime_util.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/json-smart-2.2.1.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/json-smart-2.2.1.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/jOpenCalendar.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/mysql-connector-java-5.1.40-bin.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/mysql-connector-java-5.1.40-bin.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/accessors-smart-1.1.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/accessors-smart-1.1.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/icudata_56.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/icudata_56.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/lib/DS_Desktop_Notify.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/lib/DS_Desktop_Notify.jar
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/product.properties
1,2 → 1,5
NAME=OpenConcerto
VERSION=1.4.2
VERSION=1.5
ORGANIZATION_NAME=OpenConcerto
ORGANIZATION_ID=org.openconcerto
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationListeColumnXML.java
200,17 → 200,17
// int nbPage = 1;
// int currentLineTmp = Integer.valueOf(tableau.getAttributeValue("firstLine"));
// int currentLine = Integer.valueOf(tableau.getAttributeValue("firstLine"));
int endPageLine = Integer.valueOf(tableau.getAttributeValue("endPageLine"));
// int endPageLine = Integer.valueOf(tableau.getAttributeValue("endPageLine"));
int endLine = Integer.valueOf(tableau.getAttributeValue("endLine"));
 
List listElts = tableau.getChildren("element");
 
Object o = null;
String columnSousTotal = tableau.getAttributeValue("groupSousTotalColumn");
// String columnSousTotal = tableau.getAttributeValue("groupSousTotalColumn");
//
// Map<String, Double> mapSousTotal = new HashMap<String, Double>();
// Map<String, Double> mapTotal = new HashMap<String, Double>();
 
Map<String, Double> mapSousTotal = new HashMap<String, Double>();
Map<String, Double> mapTotal = new HashMap<String, Double>();
 
// on remplit chaque colonnes à partir des rows recuperées
sheet.setColumnCount(liste.size() + 5);
Integer firstCol = Integer.valueOf(tableau.getAttributeValue("firstLine"));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/RestantAReglerProvider.java
16,14 → 16,34
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.erp.generationDoc.provider.TotalAcompteProvider.TypeTotalAcompteProvider;
import org.openconcerto.erp.generationDoc.provider.TotalCommandeClientProvider.TypeTotalCommandeClientProvider;
 
import java.math.BigDecimal;
 
public class RestantAReglerProvider implements SpreadSheetCellValueProvider {
 
TotalAcompteProvider acompteProv = new TotalAcompteProvider();
TotalCommandeClientProvider cmdProvider = new TotalCommandeClientProvider();
final TotalAcompteProvider acompteProv;
final TotalCommandeClientProvider cmdProvider;
 
private enum TypeRestantAReglerProvider {
HT, TTC;
};
 
private final TypeRestantAReglerProvider type;
 
public RestantAReglerProvider(TypeRestantAReglerProvider t) {
this.type = t;
if (this.type == TypeRestantAReglerProvider.HT) {
acompteProv = new TotalAcompteProvider(TypeTotalAcompteProvider.HT);
cmdProvider = new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.HT);
} else {
acompteProv = new TotalAcompteProvider(TypeTotalAcompteProvider.TTC);
cmdProvider = new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TTC);
}
 
}
 
public Object getValue(SpreadSheetCellValueContext context) {
Object acompte = acompteProv.getValue(context);
Object cmd = cmdProvider.getValue(context);
35,7 → 55,8
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.due", new RestantAReglerProvider());
SpreadSheetCellValueProviderManager.put("sales.account.due", new RestantAReglerProvider(TypeRestantAReglerProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.account.due.ttc", new RestantAReglerProvider(TypeRestantAReglerProvider.TTC));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/TotalCommandeClientProvider.java
23,6 → 23,16
 
public class TotalCommandeClientProvider implements SpreadSheetCellValueProvider {
 
public enum TypeTotalCommandeClientProvider {
HT, TTC;
};
 
private final TypeTotalCommandeClientProvider type;
 
public TotalCommandeClientProvider(TypeTotalCommandeClientProvider t) {
this.type = t;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
Collection<? extends SQLRowAccessor> rows = row.getReferentRows(row.getTable().getTable("TR_COMMANDE_CLIENT"));
30,7 → 40,7
for (SQLRowAccessor sqlRowAccessor : rows) {
if (!sqlRowAccessor.isForeignEmpty("ID_COMMANDE_CLIENT")) {
SQLRowAccessor rowCmd = sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT");
total += rowCmd.getLong("T_HT");
total += (this.type == TypeTotalCommandeClientProvider.HT ? rowCmd.getLong("T_HT") : rowCmd.getLong("T_TTC"));
}
}
return new BigDecimal(total).movePointLeft(2);
37,7 → 47,8
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.command.total", new TotalCommandeClientProvider());
SpreadSheetCellValueProviderManager.put("sales.account.command.total", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.account.command.total.ttc", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TTC));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/RemiseTotalProvider.java
17,7 → 17,6
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.DecimalUtils;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
25,6 → 24,16
 
public class RemiseTotalProvider extends UserInitialsValueProvider {
 
private enum TypeRemiseTotalProvider {
TTC, HT
};
 
private final TypeRemiseTotalProvider type;
 
public RemiseTotalProvider(TypeRemiseTotalProvider t) {
this.type = t;
}
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
34,25 → 43,38
BigDecimal total = BigDecimal.ZERO;
for (SQLRowAccessor sqlRowAccessor : cols) {
 
final BigDecimal montant = sqlRowAccessor.getBigDecimal("MONTANT_REMISE");
BigDecimal remise = (BigDecimal) sqlRowAccessor.getObject("POURCENT_REMISE");
if (!sqlRowAccessor.getTable().contains("NIVEAU") || sqlRowAccessor.getInt("NIVEAU") == 1) {
 
if (montant != null) {
total = total.add(montant.setScale(2, RoundingMode.HALF_UP));
} else if (remise != null && remise.signum() != 0) {
final BigDecimal subtract = BigDecimal.ONE.subtract(remise.movePointLeft(2));
if (subtract.signum() == 0) {
total = total.add(sqlRowAccessor.getBigDecimal("PV_HT").multiply(sqlRowAccessor.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowAccessor.getInt("QTE")))));
} else {
total = total.add((sqlRowAccessor.getBigDecimal("T_PV_HT").divide(subtract, DecimalUtils.HIGH_PRECISION)).subtract(sqlRowAccessor.getBigDecimal("T_PV_HT")).setScale(2,
RoundingMode.HALF_UP));
BigDecimal lineDiscount = BigDecimal.ZERO;
lineDiscount = sqlRowAccessor.getBigDecimal("PV_HT").multiply(sqlRowAccessor.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowAccessor.getInt("QTE"))));
 
if (this.type == TypeRemiseTotalProvider.TTC) {
if (sqlRowAccessor.getForeign("ID_TAXE") != null && !sqlRowAccessor.isForeignEmpty("ID_TAXE")) {
BigDecimal vat = new BigDecimal(sqlRowAccessor.getForeign("ID_TAXE").getFloat("TAUX")).movePointLeft(2).add(BigDecimal.ONE);
lineDiscount = lineDiscount.multiply(vat).setScale(2, RoundingMode.HALF_UP);
}
}
 
total = total.add(lineDiscount);
 
}
return total;
}
 
String prefix = "MONTANT_";
if (row.getTable().contains("T_HT")) {
prefix = "T_";
}
 
if (this.type == TypeRemiseTotalProvider.TTC) {
total = new BigDecimal(row.getLong(prefix + "TTC")).movePointLeft(2).subtract(total);
} else {
total = new BigDecimal(row.getLong(prefix + "HT")).movePointLeft(2).subtract(total);
}
return total.abs();
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.discount.total", new RemiseTotalProvider());
SpreadSheetCellValueProviderManager.put("sales.discount.total", new RemiseTotalProvider(TypeRemiseTotalProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.discount.total.ttc", new RemiseTotalProvider(TypeRemiseTotalProvider.TTC));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/TotalAcompteProvider.java
26,6 → 26,16
 
public class TotalAcompteProvider implements SpreadSheetCellValueProvider {
 
public enum TypeTotalAcompteProvider {
HT, TTC;
};
 
private final TypeTotalAcompteProvider type;
 
public TotalAcompteProvider(TypeTotalAcompteProvider t) {
this.type = t;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
Calendar c = row.getDate("DATE");
42,7 → 52,8
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.total", new TotalAcompteProvider());
SpreadSheetCellValueProviderManager.put("sales.account.total", new TotalAcompteProvider(TypeTotalAcompteProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.account.total.ttc", new TotalAcompteProvider(TypeTotalAcompteProvider.TTC));
}
 
public long getPreviousAcompte(SQLRowAccessor sqlRowAccessor, Set<SQLRowAccessor> alreadyAdded, Calendar c) {
56,7 → 67,7
 
if (rowFact != null && !rowFact.isUndefined() && !alreadyAdded.contains(rowFact) && rowFact.getDate("DATE").before(c)) {
alreadyAdded.add(rowFact);
l += rowFact.getLong("T_HT");
l += this.type == TypeTotalAcompteProvider.HT ? rowFact.getLong("T_HT") : rowFact.getLong("T_TTC");
}
}
return l;
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/SaledTotalNotDiscountedProvider.java
41,7 → 41,7
}
}
if (table.contains("PORT_HT")) {
total.add(new BigDecimal(row.getLong("PORT_HT")).movePointLeft(2));
total = total.add(new BigDecimal(row.getLong("PORT_HT")).movePointLeft(2));
}
return total;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/RecapFactureProvider.java
19,7 → 19,6
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.utils.GestionDevise;
 
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
27,6 → 26,16
 
public class RecapFactureProvider implements SpreadSheetCellValueProvider {
 
private enum TypeRecapFactureProvider {
HT, TTC;
};
 
private final TypeRecapFactureProvider type;
 
public RecapFactureProvider(TypeRecapFactureProvider t) {
this.type = t;
}
 
public Object getValue(SpreadSheetCellValueContext context) {
SQLRowAccessor row = context.getRow();
Calendar c = row.getDate("DATE");
46,7 → 55,8
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("sales.account.history", new RecapFactureProvider());
SpreadSheetCellValueProviderManager.put("sales.account.history", new RecapFactureProvider(TypeRecapFactureProvider.HT));
SpreadSheetCellValueProviderManager.put("sales.account.history.ttc", new RecapFactureProvider(TypeRecapFactureProvider.TTC));
}
 
public String getPreviousAcompte(SQLRowAccessor sqlRowAccessor, Set<SQLRowAccessor> alreadyAdded, Calendar c) {
60,7 → 70,8
 
if (rowFact != null && !rowFact.isUndefined() && !alreadyAdded.contains(rowFact) && rowFact.getDate("DATE").before(c)) {
alreadyAdded.add(rowFact);
result.append(rowFact.getString("NUMERO") + " (" + GestionDevise.currencyToString(rowFact.getLong("T_HT")) + "€), ");
final String fieldTotal = this.type == TypeRecapFactureProvider.HT ? "T_HT" : "T_TTC";
result.append(rowFact.getString("NUMERO") + " (" + GestionDevise.currencyToString(rowFact.getLong(fieldTotal)) + "€), ");
}
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/AdresseFullClientValueProvider.java
34,46 → 34,59
if (this.withName) {
result = context.getRow().getForeign("ID_CLIENT").getString("NOM") + "\n";
}
if (r.getString("LIBELLE").trim().length() > 0) {
result = r.getString("LIBELLE") + "\n";
result = getFormattedAddress(r, result);
 
return result;
}
if (r.getString("DEST").trim().length() > 0) {
result = r.getString("DEST") + "\n";
 
public static String getFormattedAddress(final SQLRowAccessor rAddress, String prefix) {
String result = prefix;
if (getStringTrimmed(rAddress, "LIBELLE").length() > 0) {
result = getStringTrimmed(rAddress, "LIBELLE") + "\n";
}
if (r.getString("RUE").trim().length() > 0) {
result += r.getString("RUE") + "\n";
if (getStringTrimmed(rAddress, "DEST").length() > 0) {
result = getStringTrimmed(rAddress, "DEST") + "\n";
}
result += "\n" + r.getString("CODE_POSTAL");
if (getStringTrimmed(rAddress, "RUE").length() > 0) {
result += getStringTrimmed(rAddress, "RUE") + "\n";
}
result += "\n" + getStringTrimmed(rAddress, "CODE_POSTAL");
result += " ";
if (r.getTable().contains("DISTRICT")) {
result += r.getString("DISTRICT") + " ";
if (rAddress.getTable().contains("DISTRICT")) {
result += getStringTrimmed(rAddress, "DISTRICT") + " ";
}
result += r.getString("VILLE");
if (r.getBoolean("HAS_CEDEX")) {
result += getStringTrimmed(rAddress, "VILLE");
if (rAddress.getBoolean("HAS_CEDEX")) {
result += " Cedex";
String cedex = r.getString("CEDEX");
if (cedex != null && cedex.trim().length() > 0) {
String cedex = getStringTrimmed(rAddress, "CEDEX");
if (cedex.length() > 0) {
result += " " + cedex;
}
}
if (r.getTable().contains("PROVINCE")) {
if (rAddress.getTable().contains("PROVINCE")) {
result += "\n";
if (r.getString("PROVINCE").trim().length() > 0) {
result += r.getString("PROVINCE") + " ";
if (getStringTrimmed(rAddress, "PROVINCE").length() > 0) {
result += getStringTrimmed(rAddress, ("PROVINCE")) + " ";
}
 
if (r.getTable().contains("DEPARTEMENT")) {
result += r.getString("DEPARTEMENT");
if (rAddress.getTable().contains("DEPARTEMENT")) {
result += getStringTrimmed(rAddress, "DEPARTEMENT");
}
}
 
if (r.getString("PAYS").trim().length() > 0) {
result += "\n" + r.getString("PAYS");
if (getStringTrimmed(rAddress, "PAYS").length() > 0) {
result += "\n" + getStringTrimmed(rAddress, "PAYS");
}
 
return result;
}
 
public static String getStringTrimmed(SQLRowAccessor r, String field) {
String result = r.getString(field);
if (result == null)
return "";
return result.trim();
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("address.customer.full", new AdresseFullClientValueProvider(ADRESSE_PRINCIPALE, false));
SpreadSheetCellValueProviderManager.put("address.customer.invoice.full", new AdresseFullClientValueProvider(ADRESSE_FACTURATION, false));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/PaiementRemainedProvider.java
19,6 → 19,7
import org.openconcerto.sql.model.SQLRowAccessor;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collection;
 
public class PaiementRemainedProvider implements SpreadSheetCellValueProvider {
54,6 → 55,12
totalEch += row.getLong("MONTANT");
}
}
if (r.getTable().contains("ACOMPTE_COMMANDE") && r.getBigDecimal("ACOMPTE_COMMANDE") != null) {
long totalAcompte = r.getBigDecimal("ACOMPTE_COMMANDE").movePointRight(2).setScale(0, RoundingMode.HALF_UP).longValue();
if (totalEch > totalAcompte) {
totalEch -= totalAcompte;
}
}
 
long total = totalEch;
if (t == Type.DONE) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/DateProvider.java
New file
0,0 → 1,50
/*
* 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.SpreadSheetCellValueProviderManager;
 
import java.util.Date;
 
public class DateProvider extends UserInitialsValueProvider {
 
private enum TypeDateProvider {
TODAY, CREATION, MODIFICATION
};
 
private final TypeDateProvider type;
 
public DateProvider(TypeDateProvider t) {
this.type = t;
}
 
@Override
public Object getValue(SpreadSheetCellValueContext context) {
 
if (this.type == TypeDateProvider.CREATION) {
return context.getRow().getCreationDate().getTime();
} else if (this.type == TypeDateProvider.MODIFICATION) {
return context.getRow().getModificationDate().getTime();
} else {
return new Date();
}
}
 
public static void register() {
SpreadSheetCellValueProviderManager.put("date.today", new DateProvider(TypeDateProvider.TODAY));
SpreadSheetCellValueProviderManager.put("date.creation", new DateProvider(TypeDateProvider.CREATION));
SpreadSheetCellValueProviderManager.put("date.modification", new DateProvider(TypeDateProvider.MODIFICATION));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLCache.java
210,7 → 210,7
final SQLTable tableArtElt = root.getTable("ARTICLE_ELEMENT");
SQLRowValues rowVals = new SQLRowValues(tableArtElt);
rowVals.putNulls("QTE", "QTE_UNITAIRE", "ID_UNITE_VENTE", "ID_ARTICLE_PARENT");
rowVals.putRowValues("ID_ARTICLE").putNulls("CODE", "NOM");
rowVals.putRowValues("ID_ARTICLE").setAllToNull();
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
fetch.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/EtatVentesXmlSheet.java
13,6 → 13,8
package org.openconcerto.erp.generationDoc.gestcomm;
 
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.sql.Configuration;
20,6 → 22,8
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.AliasedField;
import org.openconcerto.sql.model.AliasedTable;
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;
32,8 → 36,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 org.apache.commons.dbutils.handlers.ArrayListHandler;
 
152,6 → 158,8
selQte.addSelect(tableFactureElement.getField("T_PA_HT"), "SUM");
selQte.addSelect(tableFactureElement.getField("T_PV_HT"), "SUM");
selQte.addSelect(tableFactureElement.getField("T_PV_TTC"), "SUM");
selQte.addSelect(tableFactureElement.getField("ID_TAXE"));
selQte.addSelect(tableFactureElement.getField("ID_ARTICLE"));
selQte.addJoin("LEFT", tableFactureElement.getField("ID_SAISIE_VENTE_FACTURE")).setWhere(w);
selQte.addJoin("LEFT", tableFactureElement.getField("ID_TICKET_CAISSE"), "ticket").setWhere(w2);
if (this.du != null && this.au != null) {
159,6 → 167,8
}
selQte.addGroupBy(tableFactureElement.getField("NOM"));
selQte.addGroupBy(tableFactureElement.getField("CODE"));
selQte.addGroupBy(tableFactureElement.getField("ID_TAXE"));
selQte.addGroupBy(tableFactureElement.getField("ID_ARTICLE"));
 
List<Object[]> listeQte = (List<Object[]>) Configuration.getInstance().getBase().getDataSource().execute(selQte.asString(), new ArrayListHandler());
 
171,7 → 181,10
Number ha = (Number) sqlRow[3];
Number ht = (Number) sqlRow[4];
Number ttc = (Number) sqlRow[5];
ArticleVendu a = new ArticleVendu(code, nom, qteVendu.intValue(), (BigDecimal) ht, (BigDecimal) ha, (BigDecimal) ttc);
Number tvaID = (Number) sqlRow[6];
Number articleID = (Number) sqlRow[7];
ArticleVendu a = new ArticleVendu(code, nom, qteVendu.intValue(), (BigDecimal) ht, (BigDecimal) ha, (BigDecimal) ttc, tvaID.intValue(),
tableFactureElement.getForeignTable("ID_ARTICLE").getRow(articleID.intValue()));
map.put(code + "##" + nom, a);
}
 
199,6 → 212,8
mValues.put("QTE", a.qte);
mValues.put("T_PA", a.ha);
mValues.put("T_PV_HT", a.ht);
mValues.put("TVA_TAUX", a.tva);
mValues.put("NUMERO_COMPTE", a.numeroCompte);
mValues.put("T_PV_TTC", a.ttc);
mValues.put("NB_CHEQUE", obj[2]);
mValues.put("NB_CB", obj[3]);
372,12 → 387,36
 
}
 
public static SQLRow rowDefaultCptService, rowDefaultCptProduit;
static {
final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
rowDefaultCptService = rowPrefsCompte.getForeign("ID_COMPTE_PCE_VENTE_SERVICE");
if (rowDefaultCptService == null || rowDefaultCptService.isUndefined()) {
try {
rowDefaultCptService = ComptePCESQLElement.getRowComptePceDefault("VentesServices");
} catch (Exception e) {
e.printStackTrace();
}
}
 
rowDefaultCptProduit = rowPrefsCompte.getForeign("ID_COMPTE_PCE_VENTE_PRODUIT");
if (rowDefaultCptProduit == null || rowDefaultCptProduit.isUndefined()) {
try {
rowDefaultCptProduit = ComptePCESQLElement.getRowComptePceDefault("VentesProduits");
} catch (Exception e) {
e.printStackTrace();
}
}
}
 
class ArticleVendu {
public String code, nom;
public int qte;
public BigDecimal ht, ha, ttc;
public int qte, tvaID;
public BigDecimal ht, ha, ttc, tva;
public String numeroCompte;
 
public ArticleVendu(String code, String nom, int qte, BigDecimal ht, BigDecimal ha, BigDecimal ttc) {
public ArticleVendu(String code, String nom, int qte, BigDecimal ht, BigDecimal ha, BigDecimal ttc, int tvaID, SQLRow rowArticle) {
this.code = code;
this.nom = nom;
this.qte = qte;
384,6 → 423,51
this.ht = ht;
this.ha = ha;
this.ttc = ttc;
this.tvaID = tvaID;
this.tva = new BigDecimal(TaxeCache.getCache().getTauxFromId(tvaID));
 
SQLRowAccessor rowTVA = TaxeCache.getCache().getRowFromId(tvaID);
boolean service = rowArticle.getBoolean("SERVICE");
SQLRowAccessor rowCpt;
// Total Service
if (service) {
rowCpt = rowDefaultCptService;
if (rowTVA != null && !rowTVA.isForeignEmpty("ID_COMPTE_PCE_VENTE_SERVICE")) {
rowCpt = rowTVA.getForeign("ID_COMPTE_PCE_VENTE_SERVICE");
}
} else {
rowCpt = rowDefaultCptProduit;
// Compte defini par défaut dans la TVA
if (rowTVA != null && !rowTVA.isForeignEmpty("ID_COMPTE_PCE_VENTE")) {
rowCpt = rowTVA.getForeign("ID_COMPTE_PCE_VENTE");
}
 
}
 
if (rowArticle != null && !rowArticle.isUndefined()) {
SQLRowAccessor compteArticle = rowArticle.getForeign("ID_COMPTE_PCE");
if (compteArticle != null && !compteArticle.isUndefined()) {
rowCpt = compteArticle;
} else {
SQLRowAccessor familleArticle = rowArticle.getForeign("ID_FAMILLE_ARTICLE");
Set<SQLRowAccessor> unique = new HashSet<SQLRowAccessor>();
while (familleArticle != null && !familleArticle.isUndefined() && !unique.contains(familleArticle)) {
 
unique.add(familleArticle);
SQLRowAccessor compteFamilleArticle = familleArticle.getForeign("ID_COMPTE_PCE");
if (compteFamilleArticle != null && !compteFamilleArticle.isUndefined()) {
rowCpt = compteFamilleArticle;
break;
}
 
familleArticle = familleArticle.getForeign("ID_FAMILLE_ARTICLE_PERE");
}
}
}
if (rowCpt != null) {
 
this.numeroCompte = rowCpt.getString("NUMERO");
}
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/FicheRelanceSheet.java
28,7 → 28,7
 
public class FicheRelanceSheet extends AbstractListeSheetXml {
 
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
public static final String TEMPLATE_ID = "FicheRelance";
public static final String TEMPLATE_PROPERTY_NAME = DEFAULT_PROPERTY_NAME;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/ReleveChequeSheet.java
32,7 → 32,7
public class ReleveChequeSheet extends AbstractListeSheetXml {
 
private List<Map<String, Object>> listValues;
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
private Date date;
private long total = 0;
private long nb = 0;
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/ReportingEcoContributionSheetXML.java
New file
0,0 → 1,185
/*
* 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.
*/
/*
* Créé le 19 nov. 2012
*/
package org.openconcerto.erp.generationDoc.gestcomm;
 
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
import org.openconcerto.sql.Configuration;
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.utils.cc.ITransformer;
 
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class ReportingEcoContributionSheetXML extends AbstractListeSheetXml {
 
public static final String TEMPLATE_ID = "ReportingEcoContribution";
public static final String TEMPLATE_PROPERTY_NAME = DEFAULT_PROPERTY_NAME;
 
private Date dateD, dateF;
 
public ReportingEcoContributionSheetXML(Date debut, Date fin) {
super();
 
this.dateD = debut;
this.dateF = fin;
 
}
 
@Override
public String getStoragePathP() {
return "Autres";
}
 
@Override
public String getDefaultTemplateId() {
return TEMPLATE_ID;
};
 
@Override
public String getName() {
return "ReportingBA";
}
 
@Override
protected void createListeValues() {
 
this.mapAllSheetValues = new HashMap<Integer, Map<String, Object>>();
this.listAllSheetValues = new HashMap<Integer, List<Map<String, Object>>>();
this.styleAllSheetValues = new HashMap<Integer, Map<Integer, String>>();
 
fillSynthese();
 
}
 
private static SQLTable tableVF = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE").getTable();
 
class EcoContribRecap {
private final String code, nom;
private BigDecimal totalEco, qte;
 
public EcoContribRecap(String code, String nom) {
this.code = code;
this.nom = nom;
this.qte = BigDecimal.ZERO;
this.totalEco = BigDecimal.ZERO;
}
 
public void cumul(BigDecimal qte, BigDecimal total) {
this.qte = qte.add(this.qte);
this.totalEco = total.add(this.totalEco);
}
 
public String getCode() {
return code;
}
 
public String getNom() {
return nom;
}
 
public BigDecimal getQte() {
return qte;
}
 
public BigDecimal getTotalEco() {
return totalEco;
}
}
 
private void fillSynthese() {
final SQLTable tableVF = Configuration.getInstance().getRoot().findTable("SAISIE_VENTE_FACTURE");
final SQLTable tableVFElt = Configuration.getInstance().getRoot().findTable("SAISIE_VENTE_FACTURE_ELEMENT");
 
SQLRowValues rowvalsVF = new SQLRowValues(tableVF);
rowvalsVF.put("NUMERO", null);
rowvalsVF.put("DATE", null);
 
SQLRowValues rowvalsVFElt = new SQLRowValues(tableVFElt);
rowvalsVFElt.put("ID_SAISIE_VENTE_FACTURE", rowvalsVF);
rowvalsVFElt.put("T_ECO_CONTRIBUTION", null);
rowvalsVFElt.put("QTE", null);
rowvalsVFElt.put("QTE_UNITAIRE", null);
rowvalsVFElt.putRowValues("ID_ECO_CONTRIBUTION").putNulls("CODE", "NOM");
 
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowvalsVFElt);
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
Where w = new Where(input.getAlias(tableVF).getField("DATE"), dateD, dateF);
w = w.and(new Where(tableVFElt.getField("T_ECO_CONTRIBUTION"), ">", BigDecimal.ZERO));
input.setWhere(w);
return input;
}
});
 
Map<Integer, EcoContribRecap> recap = new HashMap<Integer, ReportingEcoContributionSheetXML.EcoContribRecap>();
List<SQLRowValues> results = fetcher.fetch();
for (SQLRowValues sqlRowValues : results) {
EcoContribRecap r;
if (recap.containsKey(sqlRowValues.getForeignID("ID_ECO_CONTRIBUTION"))) {
r = recap.get(sqlRowValues.getForeignID("ID_ECO_CONTRIBUTION"));
} else {
SQLRowAccessor rEco = sqlRowValues.getForeign("ID_ECO_CONTRIBUTION");
r = new EcoContribRecap(rEco.getString("CODE"), rEco.getString("NOM"));
recap.put(sqlRowValues.getForeignID("ID_ECO_CONTRIBUTION"), r);
}
r.cumul(sqlRowValues.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(sqlRowValues.getInt("QTE"))), sqlRowValues.getBigDecimal("T_ECO_CONTRIBUTION"));
}
 
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
this.listAllSheetValues.put(0, values);
Map<Integer, String> style = new HashMap<Integer, String>();
this.styleAllSheetValues.put(0, style);
 
BigDecimal total = BigDecimal.ZERO;
BigDecimal qteTotal = BigDecimal.ZERO;
 
for (EcoContribRecap item : recap.values()) {
Map<String, Object> vals = new HashMap<String, Object>();
 
vals.put("CODE", item.getCode());
vals.put("NOM", item.getNom());
vals.put("QTE", item.getQte());
vals.put("TOTAL_ECO", item.getTotalEco());
style.put(values.size(), "Normal");
total = total.add(item.getTotalEco());
qteTotal = qteTotal.add(item.getQte());
values.add(vals);
}
 
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Map<String, Object> vals = new HashMap<String, Object>();
vals.put("DATE_DEB", this.dateD);
vals.put("DATE_FIN", this.dateF);
vals.put("PERIODE", "Période du " + format.format(this.dateD) + " au " + format.format(this.dateF));
vals.put("TOTAL", total);
vals.put("TOTAL_QTE", qteTotal);
this.mapAllSheetValues.put(0, vals);
// style.put(values.size(), "Titre 1");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/JournalPaieXmlSheet.java
37,7 → 37,7
*/
public class JournalPaieXmlSheet extends AbstractListeSheetXml {
 
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yy");
private final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yy");
 
public static final String TEMPLATE_ID = "JournalPaie";
 
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/ODTPrinterNX.java
54,7 → 54,7
(float) (paper.getImageableWidth() / POINTS_PER_INCH), (float) (paper.getImageableHeight() / POINTS_PER_INCH), Size2DSyntax.INCH);
attributes.add(printableArea);
 
final PageFormat format = job.getPageFormat(null);
final PageFormat format = printJob.getPageFormat(null);
format.setPaper(paper);
printJob.setPrintable(this, format);
printJob.print(attributes);
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLField.java
238,6 → 238,7
String prefix = this.elt.getAttributeValue("prefix");
String suffix = this.elt.getAttributeValue("suffix");
String display = this.elt.getAttributeValue("display");
// FIXME attribut cellSize à mettre sur l'element
String cellSize = this.elt.getAttributeValue("cellSize");
if (prefix != null || suffix != null) {
 
346,8 → 347,19
}
} else if (typeComp.equalsIgnoreCase("cumulPaye")) {
double val = ((Number) result).doubleValue();
double valC = ((Number) this.row.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
double valC;
if (this.row.getTable().getFieldsName().contains("ID_CUMULS_PAYE")) {
valC = ((Number) this.row.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
} else {
SQLRowAccessor refRow = this.row.getReferentRows(this.row.getTable().getTable("FICHE_PAYE")).iterator().next();
valC = ((Number) refRow.getForeign("ID_CUMULS_PAYE").getObject(field + "_C")).doubleValue();
}
return new Double(val + valC);
} else if (typeComp.equalsIgnoreCase("cumulConges")) {
double val = ((Number) result).doubleValue();
SQLRowAccessor refRow = this.row.getReferentRows(this.row.getTable().getTable("FICHE_PAYE")).iterator().next();
double valC = ((Number) refRow.getObject("CONGES_ACQUIS")).doubleValue();
return new Double(val + valC);
} else if (typeComp.equalsIgnoreCase("globalAcompte")) {
Long prix = (Long) result;
int pourcent = this.row.getInt("POURCENT_ACOMPTE");
645,25 → 657,15
Nombre n1 = new Nombre(entier.intValue(), langue);
Nombre n2 = new Nombre(decimal.intValue(), langue);
 
// result.append(n1.getText() + " euros");
// 2.51 -> deux euros et cinquante et un centimes
result.append(n1.getText() + " " + deviseName.get0().trim());
 
if (decimal.intValue() > 0)
 
{
// result.append(" et " + n2.getText() + " cents");
result.append(" " + n1.getLocal().getSeparateurLabel() + " " + n2.getText() + deviseName.get1());
if (decimal.intValue() > 0) {
result.append(" " + n1.getSeparateurLabel() + " " + n2.getText() + deviseName.get1());
}
if (result != null && result.length() > 0)
 
{
if (result != null && result.length() > 0) {
return result.toString().replaceFirst(String.valueOf(result.charAt(0)), String.valueOf(result.charAt(0)).toUpperCase());
} else
 
{
return result.toString();
}
 
return "";
}
 
private static BigDecimal calcul(Object o1, Object o2, String op) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationXML.java
16,6 → 16,10
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Log;
import org.openconcerto.erp.core.common.element.StyleSQLElement;
import org.openconcerto.erp.core.common.ui.TotalCalculator;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.openoffice.ODPackage;
import org.openconcerto.openoffice.spreadsheet.MutableCell;
import org.openconcerto.openoffice.spreadsheet.Sheet;
25,10 → 29,11
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;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.StreamUtils;
import org.openconcerto.utils.Tuple2;
 
import java.awt.Point;
import java.io.File;
37,6 → 42,7
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
122,7 → 128,6
}
}
 
Date d = new Date();
SAXBuilder builder = new SAXBuilder();
try {
 
236,7 → 241,7
Map<String, Map<Integer, String>> mapStyle = searchStyle(sheet, lastColumn, endPageLine);
 
if (tableau.getAttributeValue("table").equalsIgnoreCase("TVA")) {
fillTaxe(tableau, sheet, mapStyle, false);
fillTaxeDocumentMap(tableau, sheet, mapStyle, false);
return;
}
int nbPage = fillTable(tableau, row, sheet, mapStyle, true, rowLanguage);
364,6 → 369,128
 
}
 
private void fillTaxe(Element tableau, List<? extends SQLRowAccessor> rows) {
// getValuesFromElement(boolean achat, String fieldTotalHT, SQLRow row, SQLTable foreign,
// BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon,
// SQLRow defaultCompte) {
SQLTable tableElt = Configuration.getInstance().getRoot().findTable(tableau.getAttributeValue("table"));
if (tableElt.contains("ID_TAXE") && tableElt.contains("T_PA_HT")) {
boolean achat = tableElt.contains("T_PA_TTC");
TotalCalculator calc = new TotalCalculator("T_PA_HT", achat ? "T_PA_HT" : "T_PV_HT", null, achat, null);
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
Boolean bServiceActive = Boolean.valueOf(val);
 
calc.setServiceActive(bServiceActive != null && bServiceActive);
if (row.getTable().contains("ID_COMPTE_PCE_SERVICE") && !row.isForeignEmpty("ID_COMPTE_PCE_SERVICE")) {
SQLRowAccessor serviceCompte = row.getForeign("ID_COMPTE_PCE_SERVICE");
if (!serviceCompte.isUndefined()) {
calc.setRowDefaultCptService(serviceCompte);
}
}
if (row.getTable().contains("ID_COMPTE_PCE_VENTE") && !row.isForeignEmpty("ID_COMPTE_PCE_VENTE")) {
SQLRowAccessor produitCompte = row.getForeign("ID_COMPTE_PCE_VENTE");
if (!produitCompte.isUndefined()) {
calc.setRowDefaultCptProduit(produitCompte);
}
}
long remise = 0;
BigDecimal totalAvtRemise = BigDecimal.ZERO;
SQLTable tableEchantillon = null;
if (row.getTable().getName().equalsIgnoreCase("SAISIE_VENTE_FACTURE") && row.getTable().getDBRoot().contains("ECHANTILLON_ELEMENT")) {
tableEchantillon = row.getTable().getTable("ECHANTILLON_ELEMENT");
}
if (row.getTable().contains("REMISE_HT")) {
remise = row.getLong("REMISE_HT");
if (remise != 0) {
for (SQLRowAccessor sqlRow : rows) {
calc.addLine(sqlRow, sqlRow.getForeign("ID_ARTICLE"), 1, false);
}
 
if (tableEchantillon != null) {
List<SQLRow> rowsEch = row.getReferentRows(tableEchantillon);
for (SQLRow sqlRow : rowsEch) {
calc.addEchantillon((BigDecimal) sqlRow.getObject("T_PV_HT"), sqlRow.getForeign("ID_TAXE"));
}
}
calc.checkResult();
totalAvtRemise = calc.getTotalHT();
}
}
 
calc.initValues();
long valRemiseHTReel = remise;
if (row.getFields().contains("POURCENT_FACTURABLE") && row.getFields().contains("MONTANT_FACTURABLE")) {
BigDecimal montantFact = row.getBigDecimal("MONTANT_FACTURABLE");
BigDecimal percentFact = row.getBigDecimal("POURCENT_FACTURABLE");
 
if (montantFact != null && montantFact.signum() > 0) {
valRemiseHTReel = 0;
} else if (percentFact != null && percentFact.signum() > 0) {
valRemiseHTReel = percentFact.movePointLeft(2).multiply(new BigDecimal(remise)).setScale(0, RoundingMode.HALF_UP).longValue();
}
 
}
calc.setRemise(valRemiseHTReel, totalAvtRemise);
 
for (int i = 0; i < rows.size(); i++) {
SQLRowAccessor sqlRow = rows.get(i);
calc.addLine(sqlRow, sqlRow.getForeign("ID_ARTICLE"), i, i == rows.size() - 1);
}
 
if (tableEchantillon != null) {
List<SQLRow> rowsEch = row.getReferentRows(tableEchantillon);
for (SQLRow sqlRow : rowsEch) {
calc.addEchantillon((BigDecimal) sqlRow.getObject("T_PV_HT"), sqlRow.getForeign("ID_TAXE"));
}
}
SQLRowAccessor rowTVAPort = null;
if (row.getTable().contains("ID_TAXE_PORT")) {
rowTVAPort = row.getForeign("ID_TAXE_PORT");
}
if (rowTVAPort != null && !rowTVAPort.isUndefined()) {
SQLRowValues rowValsPort = new SQLRowValues(tableElt);
rowValsPort.put("T_PV_HT", BigDecimal.valueOf(row.getLong("PORT_HT")).movePointLeft(2));
rowValsPort.put("QTE", 1);
rowValsPort.put("ID_TAXE", rowTVAPort.getIDNumber());
 
final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
SQLRow rowDefaultCptPort;
if (rowTVAPort.getFloat("TAUX") > 0) {
rowDefaultCptPort = rowPrefsCompte.getForeign("ID_COMPTE_PCE_PORT_SOUMIS");
if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
try {
rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortVenteSoumisTVA");
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
rowDefaultCptPort = rowPrefsCompte.getForeign("ID_COMPTE_PCE_PORT_NON_SOUMIS");
if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
try {
rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortVenteNonSoumisTVA");
} catch (Exception e) {
e.printStackTrace();
}
}
}
rowValsPort.putRowValues("ID_ARTICLE").put("ID_COMPTE_PCE", rowDefaultCptPort.getID());
 
calc.addLine(rowValsPort, rowValsPort.getForeign("ID_ARTICLE"), 1, false);
}
calc.checkResult();
Map<SQLRowAccessor, Tuple2<BigDecimal, BigDecimal>> taxeCalc = calc.getMapHtTVARowTaux();
for (SQLRowAccessor sqlRow : taxeCalc.keySet()) {
Tuple2<BigDecimal, BigDecimal> v = taxeCalc.get(sqlRow);
Map<String, Object> m = new HashMap<String, Object>();
m.put("MONTANT_HT", v.get0());
m.put("MONTANT_TVA", v.get1());
taxe.put(sqlRow, m);
}
}
}
 
private int fillTable(Element tableau, SQLRow row, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test, SQLRow rowLanguage) {
 
if (tableau == null) {
388,52 → 515,11
}
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);
}
}
}
}
 
fillTaxe(tableau, rowsEltCache.get(ref));
// on remplit chaque ligne à partir des rows recuperées
int numeroRef = 0;
for (SQLRowAccessor rowElt : rowsEltCache.get(ref)) {
 
if (!cache && rowElt.getTable().getFieldRaw("ID_TAXE") != null) {
if (!rowElt.getTable().contains("NIVEAU") || rowElt.getInt("NIVEAU") == 1) {
SQLRowAccessor rowTaxe = getForeignRow(rowElt, rowElt.getTable().getField("ID_TAXE"));
BigDecimal ht = BigDecimal.ZERO;
if (rowElt.getTable().getFieldRaw("T_PV_HT") != null) {
ht = (BigDecimal) rowElt.getObject("T_PV_HT");
}
 
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);
}
}
}
 
final boolean included = isIncluded(tableElement.getFilterId(), tableElement.getForeignTableWhere(), tableElement.getFilterId(), tableElement.getFieldWhere(), rowElt);
String styleName = null;
if (tableElement.getSQLElement().getTable().contains("ID_STYLE")) {
615,7 → 701,7
return nbCellule;
}
 
private void fillTaxe(Element tableau, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test) {
private void fillTaxeDocumentMap(Element tableau, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test) {
 
int line = Integer.valueOf(tableau.getAttributeValue("firstLine"));
List<Element> listElts = tableau.getChildren("element");
638,9 → 724,12
} else if (name.equalsIgnoreCase("MONTANT_TVA")) {
// value = Math.round(((Long) m.get("MONTANT_HT") * rowTaxe.getFloat("TAUX")
// / 100.0));
value = ((BigDecimal) m.get("MONTANT_HT")).multiply(new BigDecimal(rowTaxe.getFloat("TAUX")), DecimalUtils.HIGH_PRECISION).movePointLeft(2);
value = ((BigDecimal) m.get("MONTANT_TVA"));
// value = ((BigDecimal) m.get("MONTANT_HT")).multiply(new
// BigDecimal(rowTaxe.getFloat("TAUX")),
// DecimalUtils.HIGH_PRECISION).movePointLeft(2);
} else if (name.equalsIgnoreCase("NOM")) {
value = rowTaxe.getString("NOM");
value = TaxeCache.getCache().getRowFromId(rowTaxe.getID()).getString("NOM");
// TODO prefix et suffix
String prefix = e.getAttributeValue("prefix");
if (prefix != null) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtFactureFournisseur.java
95,7 → 95,8
}
}
 
TotalCalculator calc = getValuesFromElement(true, "T_PA_HT", saisieRow, saisieRow.getTable().getTable("FACTURE_FOURNISSEUR_ELEMENT"), BigDecimal.ZERO, null, null, rowCompteAchat);
TotalCalculator calc = getValuesFromElement(rowFournisseur.getBoolean("UE"), 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();
120,18 → 121,40
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");
// 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();
// }
}
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVAIntra));
this.mEcritures.put("DEBIT", new Long(0));
this.mEcritures.put("CREDIT", new Long(longValue));
}
Map<SQLRowAccessor, BigDecimal> tvaMapIntra = calc.getMapHtTVAIntra();
for (SQLRowAccessor rowAc : tvaMapIntra.keySet()) {
long longValue = tvaMapIntra.get(rowAc).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
if (longValue != 0) {
this.mEcritures.put("ID_COMPTE_PCE", rowAc.getID());
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", 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");
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtReglementChequeClient.java
68,6 → 68,7
 
// compte Clients
int idCompteClient = -1;
if (chequeRow.getBoolean("SANS_VALEUR_ENCAISSEMENT")) {
if (clientRow != null) {
idCompteClient = clientRow.getInt("ID_COMPTE_PCE");
}
77,6 → 78,12
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
}
}
} else {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("ValeurEncaissement");
}
}
 
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteClient));
this.mEcritures.put("DEBIT", new Long(0));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieAchat.java
20,6 → 20,7
import org.openconcerto.erp.model.PrixHT;
import org.openconcerto.erp.model.PrixTTC;
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;
37,16 → 38,12
private static final SQLTable tableFournisseur = base.getTable("FOURNISSEUR");
private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
 
public GenerationMvtSaisieAchat(SQLRow row, int idMvt) {
public GenerationMvtSaisieAchat(SQLRow row) {
setRowAnalytiqueSource(row);
this.saisieRow = row;
this.idMvt = idMvt;
this.idMvt = row.getInt("ID_MOUVEMENT");
}
 
public GenerationMvtSaisieAchat(SQLRow row) {
this(row, 1);
}
 
public void genereMouvement() throws Exception {
SQLRow rowFournisseur = tableFournisseur.getRow(this.saisieRow.getInt("ID_FOURNISSEUR"));
 
105,11 → 102,16
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVAImmo");
}
} else {
SQLRowAccessor rowCptTva = this.saisieRow.getForeign("ID_TAXE").getForeign(rowFournisseur.getBoolean("UE") ? "ID_COMPTE_PCE_DED_INTRA" : "ID_COMPTE_PCE_DED");
if (rowCptTva == null || rowCptTva.isUndefined()) {
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_ACHAT");
if (idCompteTVA <= 1) {
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVADeductible");
}
} else {
idCompteTVA = rowCptTva.getID();
}
}
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVA));
this.mEcritures.put("DEBIT", new Long(prixTVA.getLongValue()));
this.mEcritures.put("CREDIT", new Long(0));
116,10 → 118,17
ajoutEcriture();
 
if (rowFournisseur.getBoolean("UE")) {
int idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
SQLRowAccessor rowCptTva = this.saisieRow.getForeign("ID_TAXE").getForeign("ID_COMPTE_PCE_COLLECTE_INTRA");
int idCompteTVAIntra;
if (rowCptTva == null || rowCptTva.isUndefined()) {
idCompteTVAIntra = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_INTRA");
 
if (idCompteTVAIntra <= 1) {
idCompteTVAIntra = ComptePCESQLElement.getIdComptePceDefault("TVAIntraComm");
}
} else {
idCompteTVAIntra = rowCptTva.getID();
}
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVAIntra));
this.mEcritures.put("DEBIT", new Long(0));
this.mEcritures.put("CREDIT", new Long(prixTVA.getLongValue()));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationEcritures.java
33,6 → 33,7
import org.openconcerto.utils.ExceptionHandler;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
365,13 → 366,14
}
 
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);
return getValuesFromElement(false, false, "T_PV_HT", row, foreign, portHT, rowTVAPort, tableEchantillon, null);
}
 
protected TotalCalculator getValuesFromElement(boolean achat, String fieldTotalHT, SQLRow row, SQLTable foreign, BigDecimal portHT, SQLRow rowTVAPort, SQLTable tableEchantillon,
protected TotalCalculator getValuesFromElement(boolean intra, 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);
calc.setIntraComm(intra);
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
Boolean bServiceActive = Boolean.valueOf(val);
 
410,8 → 412,20
}
 
calc.initValues();
calc.setRemise(remise, totalAvtRemise);
long valRemiseHTReel = remise;
if (row.getFields().contains("POURCENT_FACTURABLE") && row.getFields().contains("MONTANT_FACTURABLE")) {
BigDecimal montantFact = row.getBigDecimal("MONTANT_FACTURABLE");
BigDecimal percentFact = row.getBigDecimal("POURCENT_FACTURABLE");
 
if (montantFact != null && montantFact.signum() > 0) {
valRemiseHTReel = 0;
} else if (percentFact != null && percentFact.signum() > 0) {
valRemiseHTReel = percentFact.movePointLeft(2).multiply(new BigDecimal(remise)).setScale(0, RoundingMode.HALF_UP).longValue();
}
 
}
calc.setRemise(valRemiseHTReel, totalAvtRemise);
 
List<SQLRow> rows = row.getReferentRows(foreign);
for (int i = 0; i < rows.size(); i++) {
SQLRow sqlRow = rows.get(i);
452,8 → 466,9
}
}
}
rowValsPort.putRowValues("ID_ARTICLE").put("ID_COMPTE_PCE", rowDefaultCptPort.getID());
 
final SQLRowValues rowValsArt = rowValsPort.putRowValues("ID_ARTICLE");
rowValsArt.put("ID_COMPTE_PCE", rowDefaultCptPort.getID());
rowValsArt.put("ID_TAXE_COMPLEMENTAIRE", null);
calc.addLine(rowValsPort, rowValsPort.getForeign("ID_ARTICLE"), 1, false);
}
calc.checkResult();
547,8 → 562,12
* @throws Exception
*/
protected void fillCompteBanqueFromRow(SQLRow sqlRow, String defaultProps, boolean achat) throws Exception {
 
int idPce = base.getTable("TYPE_REGLEMENT").getRow(2).getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
int idPce = -1;
if (sqlRow.getTable().contains("ID_TYPE_REGLEMENT")) {
idPce = sqlRow.getForeign("ID_TYPE_REGLEMENT").getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
} else {
idPce = base.getTable("TYPE_REGLEMENT").getRow(2).getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
}
if (idPce <= 1) {
idPce = ComptePCESQLElement.getIdComptePceDefault(defaultProps);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtAvoirClient.java
100,11 → 100,27
 
TotalCalculator calc;
if (rowClient.getTable().contains("ID_COMPTE_PCE_PRODUIT") && !rowClient.isForeignEmpty("ID_COMPTE_PCE_PRODUIT")) {
calc = getValuesFromElement(false, "T_PV_HT", avoirRow, avoirRow.getTable().getTable("AVOIR_CLIENT_ELEMENT"), portHT, null, null, rowClient.getForeign("ID_COMPTE_PCE_PRODUIT"));
calc = getValuesFromElement(false, false, "T_PV_HT", avoirRow, avoirRow.getTable().getTable("AVOIR_CLIENT_ELEMENT"), portHT, null, null, rowClient.getForeign("ID_COMPTE_PCE_PRODUIT"));
} else {
calc = getValuesFromElement(avoirRow, avoirRow.getTable().getTable("AVOIR_CLIENT_ELEMENT"), portHT, null, null);
}
 
Map<SQLRowAccessor, BigDecimal> compl = calc.getMapHtTaxeCompl();
for (SQLRowAccessor rowCompl : compl.keySet()) {
if (compl.get(rowCompl) != null) {
long taxeC = compl.get(rowCompl).multiply(rowCompl.getBigDecimal("POURCENT").movePointLeft(2)).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
this.mEcritures.put("ID_COMPTE_PCE", rowCompl.getForeignID("ID_COMPTE_PCE"));
this.mEcritures.put("CREDIT", Long.valueOf(0));
this.mEcritures.put("DEBIT", Long.valueOf(taxeC));
ajoutEcriture();
 
this.mEcritures.put("ID_COMPTE_PCE", rowCompl.getForeignID("ID_COMPTE_PCE_PRODUITS"));
this.mEcritures.put("CREDIT", Long.valueOf(taxeC));
this.mEcritures.put("DEBIT", Long.valueOf(0));
ajoutEcriture();
}
}
 
for (SQLRowAccessor row : calc.getMapHt().keySet()) {
long b = calc.getMapHt().get(row).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
if (b != 0) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementVenteNG.java
56,7 → 56,12
}
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse) throws Exception {
this(label, rowClient, ttc, d, modeReglement, source, mvtSource, createEncaisse, false);
}
 
public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse, boolean avance)
throws Exception {
 
SQLRow typeRegRow = modeReglement.getForeignRow("ID_TYPE_REGLEMENT");
setRowAnalytiqueSource(source);
// iniatilisation des valeurs de la map
138,9 → 143,9
 
Calendar c = modeReglement.getDate("DATE_DEPOT");
if (c != null) {
paiementCheque(c.getTime(), source, ttc, rowClient.getID(), modeReglement, mvtSource.getTable().getRow(idMvt));
paiementCheque(c.getTime(), source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance);
} else {
paiementCheque(this.date, source, ttc, rowClient.getID(), modeReglement, mvtSource.getTable().getRow(idMvt));
paiementCheque(this.date, source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance);
}
 
} else {
160,9 → 165,16
this.mEcritures.put("ID_JOURNAL", JournalSQLElement.CAISSES);
}
 
int idCompteClient = rowClient.getInt("ID_COMPTE_PCE");
if (avance) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("AvanceClients");
}
} else {
 
// compte Clients
 
int idCompteClient = rowClient.getInt("ID_COMPTE_PCE");
if (idCompteClient <= 1) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
if (idCompteClient <= 1) {
169,10 → 181,11
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
}
}
 
}
this.mEcritures.put("ID_COMPTE_PCE", idCompteClient);
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", Long.valueOf(ttc.getLongValue()));
 
this.ecrClient = ajoutEcriture();
 
// compte de reglement, caisse, cheque, ...
300,10 → 313,10
}
}
 
private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, int idClient, SQLRow modeRegl, SQLRow mvtSource) throws SQLException {
private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, SQLRow rowClient, SQLRow modeRegl, SQLRow mvtSource, boolean avance) throws Exception {
 
SQLRowValues valCheque = new SQLRowValues(base.getTable("CHEQUE_A_ENCAISSER"));
valCheque.put("ID_CLIENT", idClient);
valCheque.put("ID_CLIENT", rowClient.getID());
 
final String foreignBanqueFieldName = "ID_" + BanqueSQLElement.TABLENAME;
if (valCheque.getTable().contains(foreignBanqueFieldName))
326,5 → 339,40
rowVals.update(this.idMvt);
}
 
int idCompteClient = rowClient.getInt("ID_COMPTE_PCE");
if (avance) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("AvanceClients");
}
} else {
 
// compte Clients
 
if (idCompteClient <= 1) {
idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
if (idCompteClient <= 1) {
idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
}
}
}
this.mEcritures.put("ID_JOURNAL", JournalSQLElement.BANQUES);
this.mEcritures.put("ID_COMPTE_PCE", idCompteClient);
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", Long.valueOf(ttc.getLongValue()));
 
this.ecrClient = ajoutEcriture();
 
// compte de reglement, caisse, cheque, ...
int idCompteRegl = rowPrefsCompte.getInt("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT");
if (idCompteRegl <= 1) {
idCompteRegl = ComptePCESQLElement.getIdComptePceDefault("ValeurEncaissement");
}
this.mEcritures.put("ID_COMPTE_PCE", Integer.valueOf(idCompteRegl));
this.mEcritures.put("DEBIT", Long.valueOf(ttc.getLongValue()));
this.mEcritures.put("CREDIT", Long.valueOf(0));
 
ajoutEcriture();
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieVenteFacture.java
133,12 → 133,26
BigDecimal portHT = BigDecimal.valueOf(saisieRow.getLong("PORT_HT")).movePointLeft(2);
TotalCalculator calc;
if (clientRow.getTable().contains("ID_COMPTE_PCE_PRODUIT") && !clientRow.isForeignEmpty("ID_COMPTE_PCE_PRODUIT")) {
calc = getValuesFromElement(false, "T_PV_HT", saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), tableEchantillon,
calc = getValuesFromElement(false, false, "T_PV_HT", saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), tableEchantillon,
clientRow.getForeign("ID_COMPTE_PCE_PRODUIT"));
} else {
calc = getValuesFromElement(saisieRow, saisieVFTable.getTable("SAISIE_VENTE_FACTURE_ELEMENT"), portHT, saisieRow.getForeign("ID_TAXE_PORT"), tableEchantillon);
}
Map<SQLRowAccessor, BigDecimal> compl = calc.getMapHtTaxeCompl();
for (SQLRowAccessor rowCompl : compl.keySet()) {
if (compl.get(rowCompl) != null) {
long taxeC = compl.get(rowCompl).multiply(rowCompl.getBigDecimal("POURCENT").movePointLeft(2)).setScale(2, RoundingMode.HALF_UP).movePointRight(2).longValue();
this.mEcritures.put("ID_COMPTE_PCE", rowCompl.getForeignID("ID_COMPTE_PCE"));
this.mEcritures.put("DEBIT", Long.valueOf(0));
this.mEcritures.put("CREDIT", Long.valueOf(taxeC));
ajoutEcriture();
 
this.mEcritures.put("ID_COMPTE_PCE", rowCompl.getForeignID("ID_COMPTE_PCE_PRODUITS"));
this.mEcritures.put("DEBIT", Long.valueOf(taxeC));
this.mEcritures.put("CREDIT", Long.valueOf(0));
ajoutEcriture();
}
}
// On génére les ecritures si la facture n'est pas un acompte
long ttcLongValue = calc.getTotalTTC().movePointRight(2).longValue();
if (acompte == null || !acompte) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtSaisieVenteComptoir.java
18,6 → 18,7
import org.openconcerto.erp.model.PrixHT;
import org.openconcerto.erp.model.PrixTTC;
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;
116,10 → 117,18
// compte TVA
long tva = prixTTC.calculLongTVA(taxeRow.getFloat("TAUX") / 100.0);
if (tva > 0) {
int idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_VENTE");
int idCompteTVA;
 
SQLRowAccessor rowCptTva = saisieRow.getForeign("ID_TAXE").getForeign("ID_COMPTE_PCE_COLLECTE");
if (rowCptTva == null || rowCptTva.isUndefined()) {
idCompteTVA = rowPrefsCompte.getInt("ID_COMPTE_PCE_TVA_VENTE");
if (idCompteTVA <= 1) {
idCompteTVA = ComptePCESQLElement.getIdComptePceDefault("TVACollectee");
}
} else {
idCompteTVA = rowCptTva.getID();
}
 
this.mEcritures.put("ID_COMPTE_PCE", new Integer(idCompteTVA));
this.mEcritures.put("DEBIT", new Long(0));
this.mEcritures.put("CREDIT", new Long(tva));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CompteClientTransactionSQLELement.java
New file
0,0 → 1,48
/*
* 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.customerrelationship.customer.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
 
import java.util.ArrayList;
import java.util.List;
 
public class CompteClientTransactionSQLELement extends ComptaSQLConfElement {
 
public CompteClientTransactionSQLELement() {
super("COMPTE_CLIENT_TRANSACTION");
}
 
@Override
protected List<String> getListFields() {
final List<String> fields = new ArrayList<String>();
fields.add("ID_CLIENT");
fields.add("DATE");
fields.add("MONTANT");
fields.add("ID_MODE_REGLEMENT");
return fields;
}
 
@Override
protected SQLComponent createComponent() {
return new GroupSQLComponent(this, new CompteClientTransactionGroup());
}
 
@Override
protected String createCode() {
return super.createCodeFromPackage() + ".account.transaction";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLElement.java
13,9 → 13,12
package org.openconcerto.erp.core.customerrelationship.customer.element;
 
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
 
import java.util.List;
 
26,6 → 29,11
final CustomerGroup group = new CustomerGroup();
GlobalMapper.getInstance().map(CustomerGroup.ID, group);
setDefaultGroup(group);
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
 
}
 
@Override
38,6 → 46,11
@Override
protected List<String> getListFields() {
final List<String> fields = super.getListFields();
if (getTable().contains("GROUPE")) {
fields.add("GROUPE");
}
fields.add("SOLDE_COMPTE");
fields.add("REMIND_DATE");
fields.add("OBSOLETE");
return fields;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLComponent.java
16,7 → 16,6
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
28,7 → 27,6
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenu;
45,6 → 43,7
import org.openconcerto.ui.component.ComboLockedMode;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.component.InteractionMode;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Component;
import java.awt.Dimension;
53,7 → 52,6
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
 
62,9 → 60,11
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.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
75,7 → 75,16
private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT").getTable();
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
private final JUniqueTextField code = new JUniqueTextField(20);
private final JUniqueTextField code = new JUniqueTextField(20) {
@Override
public String getAutoRefreshNumber() {
if (getMode() == Mode.INSERTION) {
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass());
} else {
return null;
}
}
};
 
private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
private JCheckBox checkAdrLivraison, checkAdrFacturation;
243,10 → 252,40
 
@Override
public int insert(SQLRow order) {
int id = super.insert(order);
int id;
 
int attempt = 0;
// on verifie qu'un client du meme numero n'a pas été inséré entre temps
if (!this.code.checkValidation(false)) {
while (attempt < JUniqueTextField.RETRY_COUNT) {
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass());
this.code.setText(num);
attempt++;
if (this.code.checkValidation(false)) {
System.err.println("ATEMPT " + attempt + " SUCCESS WITH NUMERO " + num);
break;
}
try {
Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
final String num = this.code.getText();
if (attempt == JUniqueTextField.RETRY_COUNT) {
id = getSelectedID();
ExceptionHandler.handle("Impossible d'ajouter, numéro de client existant.");
final Object root = SwingUtilities.getRoot(this);
if (root instanceof EditFrame) {
final EditFrame frame = (EditFrame) root;
frame.getPanel().setAlwaysVisible(true);
}
} else {
id = super.insert(order);
this.table.updateField("ID_CLIENT", id);
this.adresseTable.updateField("ID_CLIENT", id);
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.code.getText().trim())) {
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.code.getText().trim())) {
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
final SQLRow rowNumAuto = this.tableNum.getRow(2);
if (rowNumAuto.getObject("CLIENT_START") != null) {
261,7 → 300,14
}
}
}
 
if (attempt > 0) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
}
});
}
}
return id;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CompteClientTransactionGroup.java
New file
0,0 → 1,29
/*
* 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.customerrelationship.customer.element;
 
import org.openconcerto.ui.group.Group;
 
public class CompteClientTransactionGroup extends Group {
public final static String ID = "customerrelationship.customer.account.default";
 
public CompteClientTransactionGroup() {
super(ID);
this.addItem("ID_CLIENT");
this.addItem("DATE");
this.addItem("MONTANT");
this.addItem("ID_REGLEMENT");
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerGroup.java
82,6 → 82,7
 
this.add(gState);
final Group gInfo = new Group("customerrelationship.customer.info", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gInfo.addItem("REMIND_DATE");
gInfo.addItem("INFOS", new LayoutHints(true, true, true, true, true, true, true, true));
gInfo.addItem("COMMENTAIRES", new LayoutHints(true, true, true, true, true, true, true, true));
gInfo.addItem("OBSOLETE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ContactSQLElementBase.java
47,6 → 47,9
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
if (getTable().contains("ID_TITRE_PERSONNEL")) {
l.add("ID_TITRE_PERSONNEL");
}
l.add("NOM");
l.add("PRENOM");
l.add("FONCTION");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ClientNormalSQLElement.java
16,6 → 16,7
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.customerrelationship.customer.report.FicheClientXmlSheet;
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.ql.LabelCreator;
import org.openconcerto.ql.QLPrinter;
23,6 → 24,7
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
49,25 → 51,8
@Override
public void actionPerformed(ActionEvent e) {
final SQLRowAccessor row = IListe.get(e).fetchSelectedRow();
final LabelCreator c = new LabelCreator(720);
c.setLeftMargin(10);
c.setTopMargin(10);
c.setDefaultFont(new Font("Verdana", Font.PLAIN, 50));
c.addLineBold(row.getString("NOM"));
final SQLRowAccessor foreignRow = row.getForeign("ID_ADRESSE");
final String string = foreignRow.getString("RUE");
String[] s = string.split("\n");
for (String string2 : s) {
c.addLineNormal(string2);
printLabel(row, property);
}
c.addLineNormal(foreignRow.getString("CODE_POSTAL") + " " + foreignRow.getString("VILLE"));
final QLPrinter prt = new QLPrinter(property);
try {
prt.print(c.getImage());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}, false, "customerrelationship.customer.label.print");
actionPrintLabel.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionPrintLabel);
98,6 → 83,33
getRowActions().add(action);
}
 
public void printLabel(SQLRowAccessor row, String qlPrinterProperty) {
final LabelCreator c = new LabelCreator(720);
c.setLeftMargin(10);
c.setTopMargin(10);
c.setDefaultFont(new Font("Verdana", Font.PLAIN, 50));
c.addLineBold(row.getString("NOM"));
final SQLRowAccessor foreignRow = row.asRow().getForeign("ID_ADRESSE");
final String string = foreignRow.getString("RUE");
String[] s = string.split("\n");
for (String string2 : s) {
c.addLineNormal(string2);
}
c.addLineNormal(foreignRow.getString("CODE_POSTAL") + " " + foreignRow.getString("VILLE"));
 
final String pays = foreignRow.getString("PAYS");
if (pays != null && pays.trim().length() > 0 && !pays.equalsIgnoreCase(ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeignRow("ID_ADRESSE_COMMON").getString("PAYS"))) {
c.addLineNormal(pays);
}
 
final QLPrinter prt = new QLPrinter(qlPrinterProperty);
try {
prt.print(c.getImage());
} catch (Exception ex) {
ex.printStackTrace();
}
}
 
protected void sendMail(List<SQLRowValues> l) {
 
String mail = "";
155,6 → 167,10
} else {
l.add("CODE");
}
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
if (prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_PCE, false)) {
l.add("ID_COMPTE_PCE");
}
return l;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map3310.java
39,7 → 39,7
public class Map3310 extends Thread {
 
private Map<String, Object> m;
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private JProgressBar bar;
private Date dateDebut, dateFin;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033A.java
37,11 → 37,17
public class Map2033A extends Thread {
 
private Map<String, Object> m;
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private JProgressBar bar;
private Date dateDebut, dateFin;
SommeCompte sommeCompte;
 
// Debugger un bilan non réparti
// Faire le bilan mois par mois pour retrouver à partir de quel date le bilan est déséquilibré,
// puis comparer les balances J J-1 pour trouver les différences ( ou le grand livre)
// --> Utiliser Check Bilan ACtion pour retrouver les mouvements qui ne sont pas bien réparti
// entre actif et passif
 
// TODO if value = 0.0 ne pas mettre -0.0
 
public void run() {
114,7 → 120,7
// Racine = "109, 201, 203, 205, 208, 237"
// S014=201...205+208+237+232
// Fix Abaque 208 - 2087
long v014 = this.sommeCompte.sommeCompteFils("109", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("201", this.dateDebut, this.dateFin)
long v014 = this.sommeCompte.soldeCompteDebiteur(109, 109, true, 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.soldeCompte(208, 208, true, this.dateDebut, this.dateFin)
- this.sommeCompte.soldeCompte(2087, 2087, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("237", this.dateDebut, this.dateFin);
501,8 → 507,9
// 120 -SommeSolde( 100, 103* )-SommeSolde( 108, 109* )
// Racine = "101, 104, 108"
// S120=-10...101-108-104
long v120 = -this.sommeCompte.sommeCompteFils("101", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("108", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("104", this.dateDebut, this.dateFin);
long v120 = -this.sommeCompte.sommeCompteFils("101", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("103", this.dateDebut, this.dateFin)
- this.sommeCompte.sommeCompteFils("108", this.dateDebut, this.dateFin) - this.sommeCompte.sommeCompteFils("104", this.dateDebut, this.dateFin)
+ this.sommeCompte.soldeCompteCrediteur(109, 109, true, this.dateDebut, this.dateFin);
this.m.put("PASSIF3.15", GestionDevise.currencyToString(v120, false));
 
// 121
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033B.java
34,7 → 34,7
 
public class Map2033B extends Thread {
private Map<String, String> m;
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private JProgressBar bar;
private Date dateDeb, dateFin;
SommeCompte sommeCompte;
431,6 → 431,7
******************************************************************************************/
// 312
// 374 SommeSoldeDebit( 4457, 4457* )
// TODO répartir les comptes crediteurs
long v374 = this.sommeCompte.soldeCompteDebiteur(4457, 4457, true, this.dateDeb, this.dateFin);
this.m.put("T1.41", GestionDevise.currencyToString(v374, false));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033E.java
28,7 → 28,7
// TODO finir de remplir la Map
public class Map2033E {
private Map m;
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy");
private final DateFormat format = new SimpleDateFormat("ddMMyyyy");
SommeCompte sommeCompte;
 
public Map2033E() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/VentilationAnalytiqueSheetXML.java
50,8 → 50,8
private final static SQLTable tableMvt = base.getTable("MOUVEMENT");
private final static SQLTable tableCompte = base.getTable("COMPTE_PCE");
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final static DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
 
private Date dateDu, dateAu;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/RepartitionAnalytiqueSheetXML.java
41,8 → 41,8
protected final static SQLTable tablePoste = base.getTable("POSTE_ANALYTIQUE");
private final static SQLTable tableEcriture = base.getTable("ECRITURE");
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final static DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
 
private Date dateDu, dateAu;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/BalanceSheet.java
40,8 → 40,8
private final static SQLTable tableEcriture = base.getTable("ECRITURE");
private final static SQLTable tableCompte = base.getTable("COMPTE_PCE");
private boolean centralClient, centralFourn, centralFournImmo;
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final static DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
public static String TEMPLATE_ID = "Balance";
public static String TEMPLATE_PROPERTY_NAME = "LocationBalance";
private Date dateAu, dateDu;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/PdfGenerator.java
51,7 → 51,7
 
public static void main(String[] args) {
new PdfGenerator_2033B().generateFrom(null);
HashMap h = new HashMap();
// HashMap h = new HashMap();
// h.put("NOM","Front Software");
// new PdfGenerator_2033A().generateFrom(h);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/JournauxAnalytiqueSheetXML.java
47,8 → 47,8
public final static int MODELETTREE = 2;
public final static int MODENONLETTREE = 3;
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final static DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
protected Date dateDu, dateAu;
private SQLRow rowPoste;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/BalanceAgeeListeSheetXML.java
94,10 → 94,11
sel.addSelect(ecr.getTable().getField("LETTRAGE"));
Where w = new Where(ecr.getTable().getField("LETTRAGE"), "IS NOT", (Object) null);
w = w.and(new Where(ecr.getTable().getField("LETTRAGE"), "!=", ""));
if (this.fin == null) {
this.fin = new Date();
}
 
if (fin != null) {
w = w.and(new Where(ecr.getTable().getField("DATE"), "<=", fin));
}
sel.setWhere(w);
 
final List<String> lettrageList = (List<String>) Configuration.getInstance().getBase().getDataSource().executeCol(sel.asString());
110,9 → 111,9
if (deb != null) {
w2 = w2.and(new Where(ecr.getTable().getField("DATE"), ">=", deb));
}
if (fin != null) {
 
w2 = w2.and(new Where(ecr.getTable().getField("DATE"), "<=", fin));
}
 
sel2.addGroupBy(ecr.getTable().getField("LETTRAGE"));
sel2.setHaving(Where.createRaw("SUM(\"DEBIT\") != SUM(\"CREDIT\")", Arrays.asList(ecr.getTable().getField("DEBIT"), ecr.getTable().getField("CREDIT"))));
sel2.setWhere(w2);
135,9 → 136,8
if (deb != null) {
w = w.and(new Where(tableEcriture.getField("DATE"), ">=", deb));
}
if (fin != null) {
w = w.and(new Where(tableEcriture.getField("DATE"), "<=", fin));
}
 
// w = w.and(new Where(cpt.getTable().getField("NOM"), "LIKE", "%RIBEIRO%"));
// w = w.and(new Where(ecr.getTable().getField("ID_COMPTE_PCE"), "=",
// cpt.getTable().getKey()));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ListeDesEcrituresAction.java
18,6 → 18,7
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.accounting.ui.AssociationAnalytiquePanel;
27,6 → 28,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.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
53,7 → 55,6
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
 
144,7 → 145,12
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
 
menuDroit.add(new AbstractAction("Consultation du compte") {
public void actionPerformed(ActionEvent event) {
SQLRowAccessor row = frame.getPanel().getListe().getSelectedRow();
((EcritureSQLElement) element).consultationCompte(ComptePCESQLElement.getRow(row.getString("COMPTE_NUMERO"), row.getString("COMPTE_NOM")));
}
});
menuDroit.add(new AbstractAction("Contrepassation") {
public void actionPerformed(ActionEvent event) {
EcritureSQLElement.contrePassationPiece(frame.getPanel().getListe().getSelectedId());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ListeDesComptesAction.java
21,11 → 21,10
import javax.swing.Action;
import javax.swing.JFrame;
 
 
public class ListeDesComptesAction extends CreateFrameAbstractAction {
public ListeDesComptesAction() {
super();
this.putValue(Action.NAME, "Liste des comptes");
this.putValue(Action.NAME, "Liste des comptes du plan comptable");
}
 
public JFrame createFrame() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/EcritureGrandLivreRenderer.java
31,7 → 31,7
public class EcritureGrandLivreRenderer extends DefaultTableCellRenderer {
 
private TableSorter model;
private static final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRENCH);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRENCH);
private final static Color couleurEcritureValide = new Color(253, 243, 204);
private final static Color couleurEcritureToDay = new Color(225, 254, 207);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieKmItemTable.java
93,12 → 93,6
final SQLTableElement tableElementNomEcriture = new SQLTableElement(tableElement.getField("NOM_ECRITURE"));
list.add(tableElementNomEcriture);
 
if (!DefaultNXProps.getInstance().getBooleanValue("HideAnalytique")) {
final AnalytiqueItemTable analytiqueAssocTable = new AnalytiqueItemTable(true);
SQLTableElement eltPourcentAnalytique = new SQLTableElement(tableElement.getField("ANALYTIQUE"), String.class, new MultiLineTableCellEditor(
(RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable));
list.add(eltPourcentAnalytique);
}
//
 
this.debit = new SQLTableElement(tableElement.getField("DEBIT"), Long.class, this.deviseCellEditor);
105,6 → 99,12
list.add(this.debit);
this.credit = new SQLTableElement(tableElement.getField("CREDIT"), Long.class, this.deviseCellEditor);
list.add(this.credit);
if (!DefaultNXProps.getInstance().getBooleanValue("HideAnalytique")) {
final AnalytiqueItemTable analytiqueAssocTable = new AnalytiqueItemTable(true);
SQLTableElement eltPourcentAnalytique = new SQLTableElement(tableElement.getField("ANALYTIQUE"), String.class,
new MultiLineTableCellEditor((RowValuesMultiLineEditTable) analytiqueAssocTable.getTable(), analytiqueAssocTable));
list.add(eltPourcentAnalytique);
}
 
final RowValuesTableModel model = new RowValuesTableModel(elt, list, tableElement.getField("NUMERO"), false, defaultRowVals) {
@Override
131,8 → 131,9
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
 
// Autocompletion
final AutoCompletionManager m = new AutoCompletionManager(this.tableElementNumeroCompte, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField(
"COMPTE_PCE.NUMERO"), this.table, this.table.getRowValuesTableModel(), ITextWithCompletion.MODE_STARTWITH, true, false, new ValidStateChecker() {
final AutoCompletionManager m = new AutoCompletionManager(this.tableElementNumeroCompte,
((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("COMPTE_PCE.NUMERO"), this.table, this.table.getRowValuesTableModel(),
ITextWithCompletion.MODE_STARTWITH, true, false, new ValidStateChecker() {
 
ComptePCESQLElement elt = Configuration.getInstance().getDirectory().getElement(ComptePCESQLElement.class);
 
146,6 → 147,8
});
m.fill("NOM", "NOM");
m.setFillWithField("NUMERO");
final Where w = new Where(elt.getTable().getTable("COMPTE_PCE").getField("OBSOLETE"), "=", Boolean.FALSE);
m.setWhere(w);
 
// FIXME erreur fill numero
final AutoCompletionManager m2 = new AutoCompletionManager(tableElementNomCompte, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("COMPTE_PCE.NOM"),
152,6 → 155,7
this.table, this.table.getRowValuesTableModel(), ITextWithCompletion.MODE_CONTAINS, true);
m2.fill("NUMERO", "NUMERO");
m2.setFillWithField("NOM");
m2.setWhere(w);
 
TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ClotureManuellePanel.java
53,7 → 53,7
private final SQLRow rowExercice = this.exercice.getRow(this.rowSociete.getInt("ID_EXERCICE_COMMON"));
private JButton valider = new JButton("Valider");
private JButton annul = new JButton("Annuler");
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
 
public ClotureManuellePanel() {
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ClotureMensuellePayePanel.java
131,6 → 131,7
selFiche.andWhere(new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText())));
selFiche.andWhere(new Where(tableSalarie.getField("ID"), "=", tableFiche.getField("ID_SALARIE")));
selFiche.andWhere(new Where(tableInfosSal.getField("ID"), "=", tableSalarie.getField("ID_INFOS_SALARIE_PAYE")));
selFiche.andWhere(new Where(tableSalarie.getField("ID_FICHE_PAYE"), "!=", tableFiche.getKey()));
 
// FIXME ne pas valider les fiches d'un employé renvoyé
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ComptaPrefTreeNode.java
20,6 → 20,7
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleManager;
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
import org.openconcerto.erp.preferences.AttachmentPreferencePanel;
import org.openconcerto.erp.preferences.GenerationDeclarationDocPreferencePanel;
import org.openconcerto.erp.preferences.GenerationDocGlobalPreferencePanel;
import org.openconcerto.erp.preferences.GenerationDocumentComptaPreferencePanel;
142,8 → 143,10
final PrefTreeNode nDestGestComm = new PrefTreeNode(GenerationDocumentGestCommPreferencePanel.class, "Gestion commerciale", new String[] { "destination" });
final PrefTreeNode nDestPaye = new PrefTreeNode(GenerationDocumentPayePreferencePanel.class, "Paye", new String[] { "destination" });
final PrefTreeNode nDestEtat = new PrefTreeNode(GenerationDeclarationDocPreferencePanel.class, "Déclaration", new String[] { "Déclaration", "destination" });
final PrefTreeNode nGED = new PrefTreeNode(AttachmentPreferencePanel.class, "GED", new String[] { "GED", "EDM" });
 
nDest.add(nDestCompta);
nDest.add(nGED);
nDest.add(nDestGestComm);
nDest.add(nDestPaye);
nDest.add(nDestEtat);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteGestCommPreferencePanel.java
40,8 → 40,8
 
public class CompteGestCommPreferencePanel extends DefaultPreferencePanel {
 
private ISQLCompteSelector selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteClient, selCompteVenteProduits, selCompteVenteService, selCompteTVACol, selCompteTVADed,
selCompteTVAImmo, selCompteAchatIntra, selCompteFactor, selComptePortSoumis, selComptePortNonSoumis;
private ISQLCompteSelector selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteValeurEncaissement, selCompteAvanceClient, selCompteClient, selCompteVenteProduits,
selCompteVenteService, selCompteTVACol, selCompteTVADed, selCompteTVAImmo, selCompteAchatIntra, selCompteFactor, selComptePortSoumis, selComptePortNonSoumis;
private ElementComboBox selJrnlFactor;
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
145,6 → 145,28
this.selCompteClient.init();
this.add(this.selCompteClient, c);
 
// Avance Compte client
c.gridy++;
c.weightx = 0;
this.add(new JLabel("Compte Avance Client"), c);
c.weightx = 1;
c.gridx++;
 
this.selCompteAvanceClient = new ISQLCompteSelector();
this.selCompteAvanceClient.init();
this.add(this.selCompteAvanceClient, c);
 
// Valeur à l'encaissement
c.gridy++;
c.weightx = 0;
this.add(new JLabel("Compte dépôt chèque"), c);
c.weightx = 1;
c.gridx++;
 
this.selCompteValeurEncaissement = new ISQLCompteSelector();
this.selCompteValeurEncaissement.init();
this.add(this.selCompteValeurEncaissement, c);
 
// Compte vente produits
c.gridy++;
c.weightx = 0;
298,6 → 320,8
this.rowPrefCompteVals.put("ID_JOURNAL_FACTOR", (selectedId > 1) ? selectedId : 1);
this.rowPrefCompteVals.put("ID_COMPTE_PCE_FOURNISSEUR", this.selCompteFourn.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_CLIENT", this.selCompteClient.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_AVANCE_CLIENT", this.selCompteAvanceClient.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", this.selCompteValeurEncaissement.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_ACHAT", this.selCompteTVADed.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_VENTE", this.selCompteTVACol.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_INTRA", this.selCompteTVAIntraComm.getValue());
358,6 → 382,14
value = ComptePCESQLElement.getId(compte);
this.selCompteClient.setValue(value);
 
// AvanceClient
compte = ComptePCESQLElement.getComptePceDefault("AvanceClients");
value = ComptePCESQLElement.getId(compte);
this.selCompteAvanceClient.setValue(value);
 
compte = ComptePCESQLElement.getComptePceDefault("ValeurEncaissement");
value = ComptePCESQLElement.getId(compte);
this.selCompteValeurEncaissement.setValue(value);
// Port
compte = ComptePCESQLElement.getComptePceDefault("PortVenteSoumisTVA");
value = ComptePCESQLElement.getId(compte);
416,6 → 448,8
 
setComboValues(selCompteFourn, "ID_COMPTE_PCE_FOURNISSEUR", "Fournisseurs");
setComboValues(selCompteClient, "ID_COMPTE_PCE_CLIENT", "Clients");
setComboValues(selCompteAvanceClient, "ID_COMPTE_PCE_AVANCE_CLIENT", "AvanceClients");
setComboValues(selCompteValeurEncaissement, "ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", "ValeurEncaissement");
setComboValues(selComptePortSoumis, "ID_COMPTE_PCE_PORT_SOUMIS", "PortVenteSoumisTVA");
setComboValues(selComptePortNonSoumis, "ID_COMPTE_PCE_PORT_NON_SOUMIS", "PortVenteNonSoumisTVA");
setComboValues(selCompteTVACol, "ID_COMPTE_PCE_TVA_VENTE", "TVACollectee");
/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.sql.utils.SQLUtils;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
72,7 → 73,7
private final Map<Object, Long> mRAN = new HashMap<Object, Long>();
private JButton valider = new JButton("Valider");
private JButton annul = new JButton("Annuler");
private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
private JLabel opEnCours = new JLabel("Etat: en attente de validation");
private JCheckBox boxValid = new JCheckBox("Je confirme avoir effectué toutes les opérations nécessaires.");
 
182,16 → 183,31
this.valider.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
 
valider.setEnabled(false);
dateFerm.setEnabled(false);
dateOuv.setEnabled(false);
 
new Thread(new Runnable() {
public void run() {
try {
clotureExercice();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// show OK works fine
Component comp = SwingUtilities.getRoot(CloturePanel.this);
JOptionPane.showMessageDialog(CloturePanel.this, "Exercice clôturé", "Fin de la clôture", JOptionPane.INFORMATION_MESSAGE);
if (comp != null) {
((JFrame) comp).dispose();
}
}
});
} catch (Exception ex) {
ExceptionHandler.handle("Erreur lors de la clôture", ex);
}
}
}).start();
 
}
});
 
this.valider.setEnabled(isDateValid());
222,15 → 238,19
 
private void clotureExercice() throws SQLException {
 
SQLRow rowPrefCompte = this.tablePrefCompte.getRow(2);
int id_Compte_Bilan_Ouverture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_O");
if (id_Compte_Bilan_Ouverture <= 1) {
final SQLRow rowPrefCompte = this.tablePrefCompte.getRow(2);
final int id_Compte_Bilan_Ouverture;
if (rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_O") <= 1) {
id_Compte_Bilan_Ouverture = ComptePCESQLElement.getId("890");
} else {
id_Compte_Bilan_Ouverture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_O");
}
 
int id_Compte_Bilan_Cloture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F");
if (id_Compte_Bilan_Cloture <= 1) {
final int id_Compte_Bilan_Cloture;
if (rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F") <= 1) {
id_Compte_Bilan_Cloture = ComptePCESQLElement.getId("891");
} else {
id_Compte_Bilan_Cloture = rowPrefCompte.getInt("ID_COMPTE_PCE_BILAN_F");
}
 
/*******************************************************************************************
237,10 → 257,19
* Validation des écritures
******************************************************************************************/
EcritureSQLElement.validationEcrituresBefore((Date) this.rowExercice.getObject("DATE_FIN"), true);
 
SQLUtils.executeAtomic(this.tablePrefCompte.getDBSystemRoot().getDataSource(), new SQLUtils.SQLFactory<Object>() {
@Override
public Object create() throws SQLException {
 
/*******************************************************************************************
* Solde des comptes de gestion 6* et 7* (génération du résultat)
******************************************************************************************/
this.opEnCours.setText("En cours: solde des comptes 6 et 7");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.opEnCours.setText("En cours: solde des comptes 6 et 7");
}
});
long time = new Date().getTime();
System.err.println("Start :: " + time);
soldeCompte(false);
248,8 → 277,12
/*******************************************************************************************
* Solde des autres comptes (comptes de bilan)
******************************************************************************************/
this.opEnCours.setText("En cours: solde des comptes autres que 6 et 7");
this.bar.setValue(1);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.opEnCours.setText("En cours: solde des comptes autres que 6 et 7");
CloturePanel.this.bar.setValue(1);
}
});
soldeCompte(true);
 
long time2 = new Date().getTime();
259,12 → 292,16
/*******************************************************************************************
* Reouverture des comptes de bilan
******************************************************************************************/
this.opEnCours.setText("En cours: report des à nouveaux");
this.bar.setValue(2);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.opEnCours.setText("En cours: report des à nouveaux");
CloturePanel.this.bar.setValue(2);
}
});
// transfert du compte bilan fermeture vers le compte bilan ouverture
SQLTable ecritureTable = this.base.getTable("ECRITURE");
SQLTable compteTable = this.base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(this.base);
SQLTable ecritureTable = CloturePanel.this.base.getTable("ECRITURE");
SQLTable compteTable = CloturePanel.this.base.getTable("COMPTE_PCE");
SQLSelect sel = new SQLSelect(CloturePanel.this.base);
 
sel.addSelect(compteTable.getKey());
sel.addSelect(compteTable.getField("NUMERO"));
279,13 → 316,13
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\", \"COMPTE_PCE\".\"NUMERO\", \"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
System.out.println(req);
 
Object ob = this.base.getDataSource().execute(req, new ArrayListHandler());
Object ob = CloturePanel.this.base.getDataSource().execute(req, new ArrayListHandler());
 
List myList = (List) ob;
 
if (myList.size() != 0) {
GenerationMvtVirement gen = new GenerationMvtVirement(1, id_Compte_Bilan_Cloture, 0, 0, "Fermeture du compte ", this.rowExercice.getDate("DATE_FIN").getTime(), JournalSQLElement.OD,
"Fermeture des comptes");
GenerationMvtVirement gen = new GenerationMvtVirement(1, id_Compte_Bilan_Cloture, 0, 0, "Fermeture du compte ", CloturePanel.this.rowExercice.getDate("DATE_FIN").getTime(),
JournalSQLElement.OD, "Fermeture des comptes");
for (int i = 0; i < myList.size(); i++) {
 
Object[] objTmp = (Object[]) myList.get(i);
296,12 → 333,12
 
if (solde != 0) {
if (solde > 0) {
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, 0, Math.abs(solde), "Fermeture du compte " + cptTmp.getNumero(), this.rowExercice.getDate("DATE_FIN").getTime(),
JournalSQLElement.OD, false);
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, 0, Math.abs(solde), "Fermeture du compte " + cptTmp.getNumero(),
CloturePanel.this.rowExercice.getDate("DATE_FIN").getTime(), JournalSQLElement.OD, false);
 
} else {
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, Math.abs(solde), 0, "Fermeture du compte " + cptTmp.getNumero(), this.rowExercice.getDate("DATE_FIN").getTime(),
JournalSQLElement.OD, false);
gen.setValues(cptTmp.getId(), id_Compte_Bilan_Cloture, Math.abs(solde), 0, "Fermeture du compte " + cptTmp.getNumero(),
CloturePanel.this.rowExercice.getDate("DATE_FIN").getTime(), JournalSQLElement.OD, false);
}
gen.genereMouvement();
}
310,24 → 347,29
/*******************************************************************************************
* Validation des écritures de clotures
******************************************************************************************/
this.opEnCours.setText("En cours: validation des écritures de l'exercice");
this.bar.setValue(3);
EcritureSQLElement.validationEcrituresBefore((Date) this.rowExercice.getObject("DATE_FIN"), true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.opEnCours.setText("En cours: validation des écritures de l'exercice");
CloturePanel.this.bar.setValue(3);
}
});
EcritureSQLElement.validationEcrituresBefore((Date) CloturePanel.this.rowExercice.getObject("DATE_FIN"), true);
 
// A nouveaux
Object[] compteAnouveau = this.mRAN.keySet().toArray();
GenerationMvtVirement genAnouveaux = new GenerationMvtVirement(id_Compte_Bilan_Ouverture, 1, 0, 0, "A nouveaux", this.dateOuv.getValue(), JournalSQLElement.OD, "A nouveaux");
for (int i = 0; i < this.mRAN.keySet().size(); i++) {
Object[] compteAnouveau = CloturePanel.this.mRAN.keySet().toArray();
GenerationMvtVirement genAnouveaux = new GenerationMvtVirement(id_Compte_Bilan_Ouverture, 1, 0, 0, "A nouveaux", CloturePanel.this.dateOuv.getValue(), JournalSQLElement.OD,
"A nouveaux");
for (int i = 0; i < CloturePanel.this.mRAN.keySet().size(); i++) {
 
long solde = this.mRAN.get(compteAnouveau[i]).longValue();
long solde = CloturePanel.this.mRAN.get(compteAnouveau[i]).longValue();
 
// if (solde != 0) {
if (solde > 0) {
genAnouveaux.setValues(id_Compte_Bilan_Ouverture, Integer.parseInt(compteAnouveau[i].toString()), 0, Math.abs(solde), "A nouveaux", this.dateOuv.getValue(), JournalSQLElement.OD,
false);
genAnouveaux.setValues(id_Compte_Bilan_Ouverture, Integer.parseInt(compteAnouveau[i].toString()), 0, Math.abs(solde), "A nouveaux", CloturePanel.this.dateOuv.getValue(),
JournalSQLElement.OD, false);
} else {
genAnouveaux.setValues(id_Compte_Bilan_Ouverture, Integer.parseInt(compteAnouveau[i].toString()), Math.abs(solde), 0, "A nouveaux", this.dateOuv.getValue(), JournalSQLElement.OD,
false);
genAnouveaux.setValues(id_Compte_Bilan_Ouverture, Integer.parseInt(compteAnouveau[i].toString()), Math.abs(solde), 0, "A nouveaux", CloturePanel.this.dateOuv.getValue(),
JournalSQLElement.OD, false);
}
genAnouveaux.genereMouvement();
// }
334,35 → 376,33
}
 
// Fixé la nouvel date de l'exercice
SQLRowValues valsExercice = new SQLRowValues(this.exercice);
SQLRowValues valsExercice = new SQLRowValues(CloturePanel.this.exercice);
valsExercice.put("CLOTURE", Boolean.TRUE);
try {
valsExercice.update(this.rowExercice.getID());
} catch (SQLException e) {
valsExercice.update(CloturePanel.this.rowExercice.getID());
 
e.printStackTrace();
}
 
// Creation d'un nouvel exercice
valsExercice.put("CLOTURE", Boolean.FALSE);
valsExercice.put("DATE_DEB", new java.sql.Date(this.dateOuv.getValue().getTime()));
valsExercice.put("DATE_FIN", new java.sql.Date(this.dateFerm.getValue().getTime()));
valsExercice.put("ID_SOCIETE_COMMON", this.rowSociete.getID());
try {
valsExercice.put("DATE_DEB", new java.sql.Date(CloturePanel.this.dateOuv.getValue().getTime()));
valsExercice.put("DATE_FIN", new java.sql.Date(CloturePanel.this.dateFerm.getValue().getTime()));
valsExercice.put("ID_SOCIETE_COMMON", CloturePanel.this.rowSociete.getID());
SQLRow rowNewEx = valsExercice.insert();
 
// mise a jour de l'exercice de la societe
SQLRowValues rowValsSociete = new SQLRowValues(this.societe);
SQLRowValues rowValsSociete = new SQLRowValues(CloturePanel.this.societe);
rowValsSociete.put("ID_EXERCICE_COMMON", rowNewEx.getID());
rowValsSociete.update(this.rowSociete.getID());
rowValsSociete.update(CloturePanel.this.rowSociete.getID());
// Recharge les informations de la societe pour pointer sur le nouvel exercice
ComptaPropsConfiguration.getInstanceCompta().getRowSociete().fetchValues();
} catch (SQLException e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CloturePanel.this.bar.setValue(4);
CloturePanel.this.opEnCours.setText("Etat: clôture terminée");
}
});
 
e.printStackTrace();
return null;
}
this.bar.setValue(4);
this.opEnCours.setText("Etat: clôture terminée");
});
}
 
private void soldeCompte(boolean compteBilan) throws SQLException {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ListeGestCommEltPanel.java
15,6 → 15,8
 
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent;
import org.openconcerto.erp.core.sales.account.VenteFactureSoldeSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
32,7 → 34,7
 
public class ListeGestCommEltPanel extends ListeAddPanel {
 
private EditFrame editModifyFrame, editReadOnlyFrame;
private EditFrame editReadOnlyFrame;
 
private ListeGestCommEltPanel(SQLElement elem, boolean showAdd, Where w, String variant) {
// TODO verifier que l'element contient la clef etrangere ID_MOUVEMENT
61,21 → 63,21
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.";
// 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;
// }
// });
}
return null;
}
});
}
}
 
public boolean isLastPartialInvoice(SQLRowAccessor sqlRowAccessor) {
Collection<? extends SQLRowAccessor> rows = sqlRowAccessor.getReferentRows(sqlRowAccessor.getTable().getTable("TR_COMMANDE_CLIENT"));
139,12 → 141,17
} else {
if (source == this.buttonModifier) {
 
if (mvt == null || mvt.isUndefined() | MouvementSQLElement.isEditable(mvt.getID())) {
if (this.editModifyFrame == null) {
this.editModifyFrame = new EditFrame(this.element, EditPanel.MODIFICATION);
if (mvt == null || mvt.isUndefined() || MouvementSQLElement.isEditable(mvt.getID())) {
EditFrame editModifyFrame;
if (this.element.getTable().getName().equals("SAISIE_VENTE_FACTURE") && row.getBoolean("PARTIAL")) {
editModifyFrame = new EditFrame(this.element.createComponent(VenteFactureSituationSQLComponent.ID), EditPanel.MODIFICATION);
} else if (this.element.getTable().getName().equals("SAISIE_VENTE_FACTURE") && row.getBoolean("SOLDE")) {
editModifyFrame = new EditFrame(this.element.createComponent(VenteFactureSoldeSQLComponent.ID), EditPanel.MODIFICATION);
} else {
editModifyFrame = new EditFrame(this.element, EditPanel.MODIFICATION);
}
this.editModifyFrame.selectionId(this.getListe().getSelectedId());
this.editModifyFrame.setVisible(true);
editModifyFrame.selectionId(this.getListe().getSelectedId());
editModifyFrame.setVisible(true);
} else {
if (this.editReadOnlyFrame == null) {
this.editReadOnlyFrame = new EditFrame(this.element, EditPanel.READONLY);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/PlanComptableEPanel.java
14,7 → 14,7
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.accounting.model.PlanComptableEModel;
import org.openconcerto.erp.element.objet.ClasseCompte;
import org.openconcerto.erp.element.objet.Compte;
22,8 → 22,6
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBase;
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;
import org.openconcerto.ui.DefaultGridBagConstraints;
255,75 → 253,9
 
public void actionPerformed(ActionEvent e) {
int row = table.rowAtPoint(mE.getPoint());
 
// ConsultationCompteFrame f = new ConsultationCompteFrame(table.getValueAt(row,
// 0).toString());
final ConsultationCompteFrame f = new ConsultationCompteFrame(new ListeDesEcrituresPanel(), "Consultation compte n°" + table.getValueAt(row, 0).toString() + " "
+ table.getValueAt(row, 1).toString());
 
f.getPanel().getListe().getJTable().addMouseListener(new MouseAdapter() {
 
public void mousePressed(final MouseEvent mE) {
 
if (mE.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
 
menuDroit.add(new AbstractAction("Voir les ecritures du journal") {
 
public void actionPerformed(ActionEvent e) {
int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
// int id = f.getPanel().getListe().getSelectedId();
 
SQLTable ecrTable = base.getTable("ECRITURE");
 
System.err.println("Ecritures ID ::: " + id);
SQLRow rowEcr = ecrTable.getRow(id);
 
System.err.println("Ecritures ID ::: " + id + " --> ID_JOURNAL = " + rowEcr.getInt("ID_JOURNAL"));
 
ConsultationCompteFrame f2 = new ConsultationCompteFrame(new ListeDesEcrituresPanel(), "Consultation du journal "
+ base.getTable("JOURNAL").getRow(rowEcr.getInt("ID_JOURNAL")).getString("NOM"));
 
Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", rowEcr.getInt("ID_JOURNAL"));
 
f2.getPanel().getListe().getRequest().setWhere(w);
f2.getPanel().getListe().setSQLEditable(false);
f2.pack();
f2.setVisible(true);
}
});
 
menuDroit.add(new AbstractAction("Voir la source") {
 
public void actionPerformed(ActionEvent e) {
 
// int id = f.getPanel().getListe().getSelectedId();
int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
System.err.println("ID COMPTE SELECTED " + id);
SQLRow rowEcr = base.getTable("ECRITURE").getRow(id);
 
System.out.println("MOUVEMENT VALIDE ------------->>>>>>>>>>>>>> " + MouvementSQLElement.isEditable(rowEcr.getInt("ID_MOUVEMENT")));
 
MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT"));
 
System.out.println("Mouvement Numero : " + rowEcr.getInt("ID_MOUVEMENT"));
}
});
 
menuDroit.show(mE.getComponent(), mE.getX(), mE.getY());
}
}
});
 
SQLTable ecrTable = base.getTable("ECRITURE");
SQLRow rowCompte = base.getTable("COMPTE_PCE").getRow(((PlanComptableEModel) (table.getModel())).getId(row));
 
Where w = new Where(ecrTable.getField("ID_COMPTE_PCE"), "=", rowCompte.getID());
f.getPanel().getListe().getRequest().setWhere(w);
 
f.getPanel().getListe().setSQLEditable(false);
f.pack();
f.setVisible(true);
((EcritureSQLElement) ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement("ECRITURE")).consultationCompte(rowCompte);
}
});
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/PlanComptableGModel.java
92,6 → 92,9
if (w2 != null) {
w1 = w1.and(w2);
}
if (compteTable.getName().equals("COMPTE_PCE")) {
w1 = w1.and(new Where(compteTable.getField("OBSOLETE"), "=", Boolean.FALSE));
}
selCompte.setWhere(w1);
 
selCompte.addRawOrder("\"" + table + "\".\"NUMERO\"");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/Currency.java
17,13 → 17,24
import java.util.Map;
 
public class Currency {
 
private String code;
 
public Currency(String code) {
this.code = code;
}
 
public String getCode() {
return code;
}
 
public static String[] ISO_CODES = { "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTN",
"BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL",
"GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR",
"KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN",
"NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP",
"SLL", "SOS", "SPL", "SRD", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TVD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", "VND", "VUV",
"WST", "XAF", "XCD", "XDR", "XOF", "XPF", "YER", "ZAR", "ZMW", "ZWD" };
"BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP",
"GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW",
"KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO",
"NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SPL", "SRD",
"STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TVD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XCD", "XDR", "XOF",
"XPF", "YER", "ZAR", "ZMW", "ZWD" };
 
private static final Map<String, String> mapSymbol;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/CurrencyConverter.java
48,7 → 48,7
}
 
public CurrencyConverter() {
this(ComptaPropsConfiguration.getInstanceCompta().getRootSociete(), ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeign("ID_DEVISE").getString("CODE"), "EUR");
this(ComptaPropsConfiguration.getInstanceCompta().getRootSociete(), ComptaPropsConfiguration.getInstanceCompta().getCurrency().getCode(), "EUR");
}
 
public String getCompanyCurrencyCode() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/AssociationAnalytiqueSQLElement.java
14,15 → 14,13
package org.openconcerto.erp.core.finance.accounting.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.map.model.Ville;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.utils.CollectionUtils;
 
import java.math.BigDecimal;
76,8 → 74,8
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
SQLTableModelSourceOnline table = super.createTableSource();
protected synchronized void _initTableSource(final SQLTableModelSource table) {
super._initTableSource(table);
BaseSQLTableModelColumn debit = new BaseSQLTableModelColumn("Débit", BigDecimal.class) {
 
@Override
121,7 → 119,5
};
 
table.getColumns().add(credit);
 
return table;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/ComptePCESQLElement.java
24,13 → 24,18
import org.openconcerto.sql.model.SQLBackgroundTableCacheItem;
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;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
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.ui.component.ITextArea;
import org.openconcerto.utils.ExceptionHandler;
39,11 → 44,13
 
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 java.util.regex.Pattern;
 
import javax.swing.AbstractAction;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
55,13 → 62,33
 
public ComptePCESQLElement() {
super("COMPTE_PCE", "un compte", "comptes");
 
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Consulter le compte") {
 
public void actionPerformed(ActionEvent e) {
final SQLRowAccessor row = IListe.get(e).getSelectedRow();
((EcritureSQLElement) getDirectory().getElement("ECRITURE")).consultationCompte(row);
// ConsultationCompteFrame f = new ConsultationCompteFrame(table.getValueAt(row,
// 0).toString());
 
}
}, true);
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(action);
}
 
@Override
protected void _initComboRequest(ComboSQLRequest req) {
super._initComboRequest(req);
req.setWhere(new Where(getTable().getField("OBSOLETE"), "=", Boolean.FALSE));
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(3);
list.add("NUMERO");
list.add("NOM");
list.add("INFOS");
list.add("OBSOLETE");
return list;
}
 
141,6 → 168,12
JCheckBox checkRacine = new JCheckBox("Racine");
this.add(checkRacine, c);
 
c.gridy++;
c.gridx++;
c.weightx = 0;
JCheckBox checkObs = new JCheckBox("Obsolète");
this.add(checkObs, c);
 
// Infos
JLabel labelInfos = new JLabel(getLabelFor("INFOS"));
c.gridy++;
161,6 → 194,7
this.addRequiredSQLObject(textNom, "NOM");
this.addSQLObject(textInfos, "INFOS");
this.addSQLObject(checkRacine, "RACINE");
this.addSQLObject(checkObs, "OBSOLETE");
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java
17,8 → 17,11
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.finance.accounting.ui.ConsultationCompteFrame;
import org.openconcerto.erp.core.finance.accounting.ui.LettrageRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.ListEcritureRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.ListeDesEcrituresPanel;
import org.openconcerto.erp.core.finance.accounting.ui.PointageRenderer;
import org.openconcerto.erp.core.finance.accounting.ui.SuppressionEcrituresPanel;
import org.openconcerto.sql.Configuration;
43,7 → 46,10
import org.openconcerto.sql.utils.SQLUtils.SQLFactory;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
50,11 → 56,17
import org.openconcerto.ui.component.InteractionMode;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.convertor.ValueConvertor;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
62,9 → 74,11
import java.util.List;
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
 
74,6 → 88,9
 
public EcritureSQLElement() {
super("ECRITURE", "une écriture", "écritures");
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction("ID_MOUVEMENT").getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
}
 
@Override
87,8 → 104,6
 
public List<String> getListFields() {
final List<String> l = new ArrayList<String>();
 
l.add("ID");
l.add("VALIDE");
l.add("ID_MOUVEMENT");
if (getTable().contains("NOM_PIECE")) {
125,9 → 140,100
req.addToGraphToFetch("VALIDE");
}
 
public void consultationCompte(SQLRowAccessor rowCpt) {
final ConsultationCompteFrame f = new ConsultationCompteFrame(new ListeDesEcrituresPanel(), "Consultation compte n°" + rowCpt.getString("NUMERO") + " " + rowCpt.getString("NOM"));
 
f.getPanel().getListe().getJTable().addMouseListener(new MouseAdapter() {
 
public void mousePressed(final MouseEvent mE) {
 
if (mE.getButton() == MouseEvent.BUTTON3) {
JPopupMenu menuDroit = new JPopupMenu();
 
menuDroit.add(new AbstractAction("Voir les ecritures du journal") {
 
public void actionPerformed(ActionEvent e) {
int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
// int id = f.getPanel().getListe().getSelectedId();
 
SQLTable ecrTable = getTable().getTable("ECRITURE");
 
System.err.println("Ecritures ID ::: " + id);
SQLRow rowEcr = ecrTable.getRow(id);
 
System.err.println("Ecritures ID ::: " + id + " --> ID_JOURNAL = " + rowEcr.getInt("ID_JOURNAL"));
 
ConsultationCompteFrame f2 = new ConsultationCompteFrame(new ListeDesEcrituresPanel(),
"Consultation du journal " + getTable().getTable("JOURNAL").getRow(rowEcr.getInt("ID_JOURNAL")).getString("NOM"));
 
Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", rowEcr.getInt("ID_JOURNAL"));
 
f2.getPanel().getListe().getRequest().setWhere(w);
f2.getPanel().getListe().setSQLEditable(false);
f2.pack();
f2.setVisible(true);
}
});
 
menuDroit.add(new AbstractAction("Voir la source") {
 
public void actionPerformed(ActionEvent e) {
 
// int id = f.getPanel().getListe().getSelectedId();
int id = f.getPanel().getListe().idFromIndex(f.getPanel().getListe().getJTable().rowAtPoint(mE.getPoint()));
System.err.println("ID COMPTE SELECTED " + id);
SQLRow rowEcr = getTable().getTable("ECRITURE").getRow(id);
 
System.out.println("MOUVEMENT VALIDE ------------->>>>>>>>>>>>>> " + MouvementSQLElement.isEditable(rowEcr.getInt("ID_MOUVEMENT")));
 
MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT"));
 
System.out.println("Mouvement Numero : " + rowEcr.getInt("ID_MOUVEMENT"));
}
});
 
menuDroit.show(mE.getComponent(), mE.getX(), mE.getY());
}
}
});
 
SQLTable ecrTable = getTable().getTable("ECRITURE");
 
Where w = new Where(ecrTable.getField("ID_COMPTE_PCE"), "=", rowCpt.getID());
f.getPanel().getListe().getRequest().setWhere(w);
 
f.getPanel().getListe().setSQLEditable(false);
f.pack();
f.setVisible(true);
}
 
@Override
protected void _initTableSource(SQLTableModelSourceOnline res) {
protected void _initTableSource(SQLTableModelSource res) {
super._initTableSource(res);
BaseSQLTableModelColumn analytique = new BaseSQLTableModelColumn("Poste analytique", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> assocs = r.getReferentRows(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
StringBuffer res = new StringBuffer();
 
for (SQLRowAccessor sqlRowAccessor : assocs) {
res.append(sqlRowAccessor.getForeign("ID_POSTE_ANALYTIQUE").getString("NOM"));
res.append(", ");
}
 
return res.toString();
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
p = p.add(p.getLast().getForeignTable("ID_POSTE_ANALYTIQUE"));
return CollectionUtils.createSet(new FieldPath(p, "NOM"));
}
};
res.getColumns().add(analytique);
for (SQLTableModelColumn col : res.getColumns()) {
col.setRenderer(ListEcritureRenderer.UTILS.getRenderer(col.getRenderer()));
}
142,13 → 248,35
listEcriture.add("DATE");
listEcriture.add("DEBIT");
listEcriture.add("CREDIT");
final SQLTableModelSourceOnline res = this.initTableSource(new SQLTableModelSourceOnline(this.createListRequest(listEcriture)));
for (SQLTableModelColumn column : res.getColumns()) {
column.setRenderer(PointageRenderer.UTILS.getRenderer(column.getRenderer()));
final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
for (SQLTableModelColumn col : res.getColumns()) {
if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
col.setConverter(new ValueConvertor<Number, BigDecimal>() {
@Override
public BigDecimal convert(Number o) {
if (o == null) {
return BigDecimal.ZERO;
}
return res;
return new BigDecimal(o.longValue()).movePointLeft(2);
}
 
@Override
public Number unconvert(BigDecimal o) {
 
if (o == null) {
return 0;
}
return o.movePointRight(2);
}
}, BigDecimal.class);
col.setRenderer(CURRENCY_RENDERER);
}
 
col.setRenderer(PointageRenderer.UTILS.getRenderer(col.getRenderer()));
}
return this.initTableSource(res, true);
}
 
public final SQLTableModelSourceOnline createLettrageTableSource() {
final List<String> listEcriture = new ArrayList<String>();
listEcriture.add("LETTRAGE");
162,44 → 290,33
listEcriture.add("DATE");
listEcriture.add("DEBIT");
listEcriture.add("CREDIT");
final SQLTableModelSourceOnline res = this.initTableSource(new SQLTableModelSourceOnline(this.createListRequest(listEcriture)));
for (SQLTableModelColumn column : res.getColumns()) {
column.setRenderer(LettrageRenderer.UTILS.getRenderer(column.getRenderer()));
final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
for (SQLTableModelColumn col : res.getColumns()) {
if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
col.setConverter(new ValueConvertor<Number, BigDecimal>() {
@Override
public BigDecimal convert(Number o) {
if (o == null) {
return BigDecimal.ZERO;
}
return res;
return new BigDecimal(o.longValue()).movePointLeft(2);
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
SQLTableModelSourceOnline source = super.createTableSource();
public Number unconvert(BigDecimal o) {
 
BaseSQLTableModelColumn analytique = new BaseSQLTableModelColumn("Poste analytique", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> assocs = r.getReferentRows(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
StringBuffer res = new StringBuffer();
 
for (SQLRowAccessor sqlRowAccessor : assocs) {
res.append(sqlRowAccessor.getForeign("ID_POSTE_ANALYTIQUE").getString("NOM"));
res.append(", ");
if (o == null) {
return 0;
}
 
return res.toString();
return o.movePointRight(2);
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
p = p.add(p.getLast().getForeignTable("ID_POSTE_ANALYTIQUE"));
return CollectionUtils.createSet(new FieldPath(p, "NOM"));
}, BigDecimal.class);
col.setRenderer(CURRENCY_RENDERER);
}
};
source.getColumns().add(analytique);
 
return source;
col.setRenderer(LettrageRenderer.UTILS.getRenderer(col.getRenderer()));
}
return this.initTableSource(res, true);
}
 
/*
* (non-Javadoc)
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/action/ReportingEcoContributionPanel.java
New file
0,0 → 1,106
/*
* 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.
*/
/*
* Créé le 23 avr. 2012
*/
package org.openconcerto.erp.core.finance.tax.action;
 
import org.openconcerto.erp.generationDoc.gestcomm.ReportingEcoContributionSheetXML;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Calendar;
import java.util.concurrent.ExecutionException;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
public class ReportingEcoContributionPanel extends JPanel {
 
public ReportingEcoContributionPanel() {
super(new GridBagLayout());
 
JLabel labelCom = new JLabel("Période du ");
 
GridBagConstraints c = new DefaultGridBagConstraints();
this.add(labelCom, c);
c.gridx++;
final JDate dateDeb = new JDate();
this.add(dateDeb, c);
c.gridx++;
JLabel labelYear = new JLabel("au");
final JDate dateFin = new JDate();
 
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.DAY_OF_MONTH, 1);
dateDeb.setValue(cal.getTime());
 
this.add(labelYear, c);
c.gridx++;
this.add(dateFin, c);
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DAY_OF_MONTH, 31);
dateFin.setValue(cal.getTime());
 
final JButton buttonValid = new JButton(new AbstractAction("Valider") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
new Thread() {
public void run() {
ReportingEcoContributionSheetXML sheet = new ReportingEcoContributionSheetXML(dateDeb.getValue(), dateFin.getValue());
try {
sheet.createDocument();
} catch (InterruptedException exn) {
exn.printStackTrace();
} catch (ExecutionException exn) {
exn.printStackTrace();
}
sheet.showPrintAndExport(true, false, false);
 
};
}.start();
 
}
 
});
c.gridx++;
// buttonValid.setEnabled(false);
this.add(buttonValid, c);
dateDeb.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null);
}
});
dateFin.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null);
}
});
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/model/TaxeCache.java
73,6 → 73,17
return this.mapTaux.get(Integer.valueOf(idTaux));
}
 
public SQLRowAccessor getRowFromId(final int idTaux) {
Set<SQLRowAccessor> s = mapRowTaux.keySet();
for (SQLRowAccessor r : s) {
if (r.getID() == idTaux) {
return r;
}
}
return null;
 
}
 
public SQLRow getFirstTaxe() {
if (this.firstIdTaxe == null) {
final SQLSelect sel = getSel();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/element/TaxeSQLElement.java
142,8 → 142,6
ISQLCompteSelector compteCol = new ISQLCompteSelector();
this.add(compteCol, c);
 
 
 
JLabel labelCompteDed = new JLabel(getLabelFor("ID_COMPTE_PCE_DED"), SwingConstants.RIGHT);
c.gridx = 0;
c.gridy++;
158,7 → 156,6
ISQLCompteSelector compteDed = new ISQLCompteSelector();
this.add(compteDed, c);
 
JLabel labelCompteVente = new JLabel(getLabelFor("ID_COMPTE_PCE_VENTE"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
185,6 → 182,31
ISQLCompteSelector compteVenteS = new ISQLCompteSelector();
this.add(compteVenteS, c);
JLabel labelCompteColIntra = new JLabel(getLabelFor("ID_COMPTE_PCE_COLLECTE_INTRA"), SwingConstants.RIGHT);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy++;
this.add(labelCompteColIntra, c);
c.gridx++;
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteColIntra = new ISQLCompteSelector();
this.add(compteColIntra, c);
 
JLabel labelCompteDedIntra = new JLabel(getLabelFor("ID_COMPTE_PCE_DED_INTRA"), SwingConstants.RIGHT);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(labelCompteDedIntra, c);
c.gridx++;
c.weightx = 1;
 
c.gridwidth = GridBagConstraints.REMAINDER;
ISQLCompteSelector compteDedIntra = new ISQLCompteSelector();
this.add(compteDedIntra, c);
 
// Spacer
c.gridy++;
c.weighty = 1;
195,8 → 217,9
this.addSQLObject(compteDed, "ID_COMPTE_PCE_DED");
this.addSQLObject(compteVente, "ID_COMPTE_PCE_VENTE");
this.addSQLObject(compteVenteS, "ID_COMPTE_PCE_VENTE_SERVICE");
this.addSQLObject(compteColIntra, "ID_COMPTE_PCE_COLLECTE_INTRA");
this.addSQLObject(compteDedIntra, "ID_COMPTE_PCE_DED_INTRA");
 
 
this.addRequiredSQLObject(fieldNom, "NOM");
this.addRequiredSQLObject(fieldTaux, "TAUX");
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/element/TaxeComplementaireSQLElement.java
New file
0,0 → 1,126
/*
* 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.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.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
public class TaxeComplementaireSQLElement extends ComptaSQLConfElement {
 
public TaxeComplementaireSQLElement() {
super("TAXE_COMPLEMENTAIRE", "une taxe complémentaire", "taxes complémentaires");
 
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
l.add("POURCENT");
l.add("ID_COMPTE_PCE");
l.add("ID_COMPTE_PCE_PRODUITS");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
@Override
protected void addViews() {
 
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
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 = 0;
c.gridy++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
JLabel labelTaux = new JLabel(getLabelFor("POURCENT"), 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"), 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 compte = new ISQLCompteSelector();
this.add(compte, c);
 
JLabel labelCompteDed = new JLabel(getLabelFor("ID_COMPTE_PCE_PRODUITS"), 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 compteProduits = new ISQLCompteSelector();
this.add(compteProduits, c);
 
// Spacer
c.gridy++;
c.weighty = 1;
c.anchor = GridBagConstraints.NORTHWEST;
this.add(new JPanel(), c);
 
this.addRequiredSQLObject(compte, "ID_COMPTE_PCE");
this.addRequiredSQLObject(compteProduits, "ID_COMPTE_PCE_PRODUITS");
this.addRequiredSQLObject(fieldNom, "NOM");
this.addRequiredSQLObject(fieldTaux, "POURCENT");
}
};
}
 
@Override
protected String createCode() {
return "finance.tax.complement";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/action/ListeDesReferencesAction.java
91,7 → 91,7
}
};
 
final IListe list = new IListe(elementArticle.initTableSource(new SQLTableModelSourceOnline(req)));
final IListe list = new IListe(elementArticle.createTableSourceOnline(req));
 
IListFrame frame = new IListFrame(new ListeAddPanel(elementArticle, list) {
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/ui/GestionChequesRenderer.java
24,7 → 24,7
public class GestionChequesRenderer extends DefaultTableCellRenderer {
 
private final static Color couleurChequeValide = new Color(255, 128, 64);
private static final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
 
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/EncaisserMontantSQLElement.java
31,7 → 31,7
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.utils.CollectionUtils;
 
import java.sql.SQLException;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/TypeReglementSQLElement.java
34,7 → 34,9
public static final int CB = 3;
public static final int ESPECE = 4;
public static final int TRAITE = 5;
public static final int INDEFINI = 7;
public static final int INDEFINI = 6;
public static final int VIREMENT = 7;
public static final int CESU = 8;
 
public TypeReglementSQLElement() {
super("TYPE_REGLEMENT", "Type de règlement", "Type de règlement");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ChequeSQLElement.java
15,9 → 15,7
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.finance.payment.ui.GestionChequesRenderer;
import org.openconcerto.sql.FieldExpander;
import org.openconcerto.sql.ShowAs;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
31,21 → 29,9
}
 
protected final SQLTableModelSourceOnline createDepositTableSource(final List<String> fields, final ShowAs showAs, final Where w) {
final ListSQLRequest req = new ListSQLRequest(getTable(), fields) {
@Override
protected void customizeToFetch(SQLRowValues graphToFetch) {
super.customizeToFetch(graphToFetch);
graphToFetch.putNulls(getDoneFieldName());
}
 
@Override
protected FieldExpander getShowAs() {
return showAs;
}
};
req.setWhere(new Where(this.getTable().getField(this.getDoneFieldName()), "=", Boolean.FALSE).and(w));
 
final SQLTableModelSourceOnline res = new SQLTableModelSourceOnline(req);
final ListSQLRequest req = this.createListRequest(fields, new Where(this.getTable().getField(this.getDoneFieldName()), "=", Boolean.FALSE).and(w), showAs);
req.addToGraphToFetch(getDoneFieldName());
final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(req);
res.init();
res.getColumn(getTable().getField(getMinDateFieldName())).setRenderer(new GestionChequesRenderer());
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/ListeDesInfosSalariePayeAction.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.humanresources.payroll.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeDesInfosSalariePayeAction extends CreateFrameAbstractAction {
 
public ListeDesInfosSalariePayeAction() {
super();
this.putValue(Action.NAME, "Historique des Informations de contrat");
}
 
public JFrame createFrame() {
return new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("INFOS_SALARIE_PAYE")));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/ListeFichePayeAddPanel.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.humanresources.payroll.action;
 
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.view.list.IListe;
 
public class ListeFichePayeAddPanel extends ListeViewPanel {
{
this.buttonModifier.setText("Voir");
}
 
public ListeFichePayeAddPanel(SQLElement component) {
super(component);
}
 
public ListeFichePayeAddPanel(SQLElement component, IListe list) {
super(component, list);
this.buttonEffacer.setVisible(true);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/action/ListeDesFichesDePayeAction.java
16,7 → 16,6
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheet;
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
import org.openconcerto.erp.core.humanresources.payroll.ui.PanelCumulsPaye;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
36,7 → 35,6
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
 
import javax.swing.AbstractAction;
import javax.swing.Action;
60,7 → 58,7
final SQLTableModelSourceOnline src = elt.getTableSource(true);
// On affcihe seulement les fiches de payes validées
src.getReq().setWhere(new Where(elt.getTable().getField("VALIDE"), "=", Boolean.TRUE));
final ListeAddPanel liste = new ListFichePayeAddPanel(elt, new IListe(src));
final ListeAddPanel liste = new ListeFichePayeAddPanel(elt, new IListe(src));
 
final IListFrame frame = new IListFrame(liste);
 
113,29 → 111,4
return frame;
}
 
class ListFichePayeAddPanel extends ListeAddPanel {
{
this.buttonModifier.setText("Voir");
}
 
public ListFichePayeAddPanel(SQLElement component) {
super(component);
}
 
public ListFichePayeAddPanel(SQLElement component, IListe list) {
super(component, list);
}
 
protected void handleAction(JButton source, ActionEvent evt) {
if (source == this.buttonModifier) {
if (ListeDesFichesDePayeAction.this.editFrame == null) {
ListeDesFichesDePayeAction.this.editFrame = new EditFrame(this.element, EditPanel.READONLY);
}
ListeDesFichesDePayeAction.this.editFrame.selectionId(this.getListe().getSelectedId());
ListeDesFichesDePayeAction.this.editFrame.setVisible(true);
} else {
super.handleAction(source, evt);
}
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/CaisseCotisationRenseignementTable.java
New file
0,0 → 1,95
/*
* 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.humanresources.payroll.ui;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.RowValuesTablePanel;
import org.openconcerto.sql.view.list.RowValuesTableRenderer;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.List;
import java.util.Vector;
 
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
 
public class CaisseCotisationRenseignementTable extends RowValuesTablePanel {
 
public CaisseCotisationRenseignementTable() {
 
init();
uiInit();
 
}
 
/**
*
*/
protected void init() {
 
final SQLElement e = getSQLElement();
 
final List<SQLTableElement> tableElements = new Vector<SQLTableElement>();
 
tableElements.add(new SQLTableElement(e.getTable().getField("IDENTIFIANT")));
tableElements.add(new SQLTableElement(e.getTable().getField("IBAN")));
tableElements.add(new SQLTableElement(e.getTable().getField("BIC")));
tableElements.add(new SQLTableElement(e.getTable().getField("ENTITE_AFFECTATION")));
// tableElements.add(new
// SQLTableElement(e.getTable().getField("ORGANISME_COMPLEMENTAIRE")));
tableElements.add(new SQLTableElement(e.getTable().getField("CODE_DELEGATAIRE")));
tableElements.add(new SQLTableElement(e.getTable().getField("ID_CAISSE_MODE_PAIEMENT")));
tableElements.add(new SQLTableElement(e.getTable().getField("PAIEMENT_TRIMESTRIEL")));
tableElements.add(new SQLTableElement(e.getTable().getField("ID_SOCIETE_COMMON")));
 
this.defaultRowVals = new SQLRowValues(getSQLElement().getTable());
this.model = new RowValuesTableModel(e, tableElements, e.getTable().getField("ID_SOCIETE_COMMON"), false, this.defaultRowVals);
 
this.table = new RowValuesTable(this.model, null);
}
 
public SQLElement getSQLElement() {
return Configuration.getInstance().getDirectory().getElement("CAISSE_COTISATION_RENSEIGNEMENT");
}
 
protected void uiInit() {
// Ui init
setLayout(new GridBagLayout());
this.setOpaque(false);
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.weightx = 1;
 
RowValuesTableControlPanel control = new RowValuesTableControlPanel(this.table);
control.setOpaque(false);
this.add(control, c);
 
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
final JScrollPane comp = new JScrollPane(this.table);
comp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
this.add(comp, c);
this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/ContratPrevSalarieTable.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.humanresources.payroll.ui;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.RowValuesTablePanel;
import org.openconcerto.sql.view.list.RowValuesTableRenderer;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.List;
import java.util.Vector;
 
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
 
public class ContratPrevSalarieTable extends RowValuesTablePanel {
 
public ContratPrevSalarieTable() {
 
init();
uiInit();
 
}
 
/**
*
*/
protected void init() {
 
final SQLElement e = getSQLElement();
 
final List<SQLTableElement> tableElements = new Vector<SQLTableElement>();
tableElements.add(new SQLTableElement(e.getTable().getField("ID_INFOS_SALARIE_PAYE")));
tableElements.add(new SQLTableElement(e.getTable().getField("CODE_OPTION")));
tableElements.add(new SQLTableElement(e.getTable().getField("CODE_POPULATION")));
tableElements.add(new SQLTableElement(e.getTable().getField("NB_ENFANT_CHARGE")));
tableElements.add(new SQLTableElement(e.getTable().getField("NB_ADULTE_AYANT_DROIT")));
tableElements.add(new SQLTableElement(e.getTable().getField("NB_AYANT_DROIT")));
tableElements.add(new SQLTableElement(e.getTable().getField("NB_AYANT_DROIT_AUTRE")));
tableElements.add(new SQLTableElement(e.getTable().getField("NB_ENFANT_AYANT_DROIT")));
 
this.defaultRowVals = new SQLRowValues(getSQLElement().getTable());
this.model = new RowValuesTableModel(e, tableElements, e.getTable().getField("ID_INFOS_SALARIE_PAYE"), false, this.defaultRowVals);
 
this.table = new RowValuesTable(this.model, null);
}
 
public SQLElement getSQLElement() {
return Configuration.getInstance().getDirectory().getElement("CONTRAT_PREVOYANCE_CONTRAT_SALARIE");
}
 
protected void uiInit() {
// Ui init
setLayout(new GridBagLayout());
this.setOpaque(false);
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.weightx = 1;
 
RowValuesTableControlPanel control = new RowValuesTableControlPanel(this.table);
control.setOpaque(false);
this.add(control, c);
 
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
final JScrollPane comp = new JScrollPane(this.table);
comp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
this.add(comp, c);
this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/AyantDroitTable.java
New file
0,0 → 1,86
/*
* 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.humanresources.payroll.ui;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.RowValuesTablePanel;
import org.openconcerto.sql.view.list.RowValuesTableRenderer;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.List;
import java.util.Vector;
 
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
 
public class AyantDroitTable extends RowValuesTablePanel {
 
public AyantDroitTable() {
 
init();
uiInit();
 
}
 
/**
*
*/
protected void init() {
 
final SQLElement e = getSQLElement();
 
final List<SQLTableElement> tableElements = new Vector<SQLTableElement>();
 
tableElements.add(new SQLTableElement(e.getTable().getField("ID_CONTRAT_PREVOYANCE")));
 
this.defaultRowVals = new SQLRowValues(getSQLElement().getTable());
this.model = new RowValuesTableModel(e, tableElements, e.getTable().getField("ID_CONTRAT_PREVOYANCE"), false, this.defaultRowVals);
 
this.table = new RowValuesTable(this.model, null);
}
 
public SQLElement getSQLElement() {
return Configuration.getInstance().getDirectory().getElement("CONTRAT_PREVOYANCE_AYANT_DROIT");
}
 
protected void uiInit() {
// Ui init
setLayout(new GridBagLayout());
this.setOpaque(false);
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.weightx = 1;
 
RowValuesTableControlPanel control = new RowValuesTableControlPanel(this.table);
control.setOpaque(false);
this.add(control, c);
 
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
final JScrollPane comp = new JScrollPane(this.table);
comp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
this.add(comp, c);
this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/ContratPenibiliteTable.java
New file
0,0 → 1,86
/*
* 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.humanresources.payroll.ui;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.RowValuesTablePanel;
import org.openconcerto.sql.view.list.RowValuesTableRenderer;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.List;
import java.util.Vector;
 
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
 
public class ContratPenibiliteTable extends RowValuesTablePanel {
 
public ContratPenibiliteTable() {
 
init();
uiInit();
 
}
 
/**
*
*/
protected void init() {
 
final SQLElement e = getSQLElement();
 
final List<SQLTableElement> tableElements = new Vector<SQLTableElement>();
 
tableElements.add(new SQLTableElement(e.getTable().getField("ID_CODE_PENIBILITE")));
 
this.defaultRowVals = new SQLRowValues(getSQLElement().getTable());
this.model = new RowValuesTableModel(e, tableElements, e.getTable().getField("ID_CODE_PENIBILITE"), false, this.defaultRowVals);
 
this.table = new RowValuesTable(this.model, null);
}
 
public SQLElement getSQLElement() {
return Configuration.getInstance().getDirectory().getElement("CODE_PENIBILITE_CONTRAT_SALARIE");
}
 
protected void uiInit() {
// Ui init
setLayout(new GridBagLayout());
this.setOpaque(false);
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.weightx = 1;
 
RowValuesTableControlPanel control = new RowValuesTableControlPanel(this.table);
control.setOpaque(false);
this.add(control, c);
 
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
final JScrollPane comp = new JScrollPane(this.table);
comp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
this.add(comp, c);
this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/HistoriqueFichePayePanel.java
15,7 → 15,7
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheet;
import org.openconcerto.erp.core.humanresources.payroll.action.ListeFichePayeAddPanel;
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.Configuration;
27,7 → 27,6
import org.openconcerto.sql.users.rights.JListSQLTablePanel;
import org.openconcerto.sql.view.IListPanel;
import org.openconcerto.sql.view.IListener;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
41,9 → 40,6
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
108,7 → 104,7
// IListe
final SQLTableModelSourceOnline src = eltFiche.getTableSource(true);
src.getReq().setWhere(Where.FALSE);
this.listePanel = new ListeAddPanel(eltFiche, new IListe(src));
this.listePanel = new ListeFichePayeAddPanel(eltFiche, new IListe(src));
this.listePanel.setAddVisible(false);
 
this.listePanel.getListe().setSQLEditable(false);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/ContratPrevRubriqueTable.java
New file
0,0 → 1,90
/*
* 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.humanresources.payroll.ui;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.RowValuesTablePanel;
import org.openconcerto.sql.view.list.RowValuesTableRenderer;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.List;
import java.util.Vector;
 
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
 
public class ContratPrevRubriqueTable extends RowValuesTablePanel {
 
public final boolean net;
 
public ContratPrevRubriqueTable(final boolean net) {
 
this.net = net;
init();
uiInit();
 
}
 
/**
*
*/
protected void init() {
 
final SQLElement e = getSQLElement();
 
final List<SQLTableElement> tableElements = new Vector<SQLTableElement>();
 
String fieldName = net ? "ID_RUBRIQUE_NET" : "ID_RUBRIQUE_COTISATION";
tableElements.add(new SQLTableElement(e.getTable().getField(fieldName)));
 
this.defaultRowVals = new SQLRowValues(getSQLElement().getTable());
this.model = new RowValuesTableModel(e, tableElements, e.getTable().getField(fieldName), false, this.defaultRowVals);
 
this.table = new RowValuesTable(this.model, null);
}
 
public SQLElement getSQLElement() {
return Configuration.getInstance().getDirectory().getElement(net ? "CONTRAT_PREVOYANCE_RUBRIQUE_NET" : "CONTRAT_PREVOYANCE_RUBRIQUE");
}
 
protected void uiInit() {
// Ui init
setLayout(new GridBagLayout());
this.setOpaque(false);
final GridBagConstraints c = new DefaultGridBagConstraints();
 
c.weightx = 1;
 
RowValuesTableControlPanel control = new RowValuesTableControlPanel(this.table);
control.setOpaque(false);
this.add(control, c);
 
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
final JScrollPane comp = new JScrollPane(this.table);
comp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
this.add(comp, c);
this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeCotisationIndividuelleSQLElement.java
New file
0,0 → 1,33
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.utils.ListMap;
 
public class CodeCotisationIndividuelleSQLElement extends AbstractCodeSQLElement {
 
public CodeCotisationIndividuelleSQLElement() {
super("CODE_COTISATION_INDIVIDUELLE", "un code de cotisation individuelle", "codes de cotisation individuelle");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cotisation.individuelle.code";
}
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "CODE");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratPrevoyanceSQLElement.java
New file
0,0 → 1,263
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.humanresources.payroll.ui.ContratPrevRubriqueTable;
import org.openconcerto.erp.core.humanresources.payroll.ui.ContratPrevSalarieTable;
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.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
public class ContratPrevoyanceSQLElement extends ComptaSQLConfElement {
 
public ContratPrevoyanceSQLElement() {
super("CONTRAT_PREVOYANCE", "un contrat de prévoyance, mutuelle, formation", "contrats de prévoyance, mutuelle, formation");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
// l.add("CODE_UNIQUE");
l.add("NOM");
l.add("REFERENCE");
l.add("CODE_ORGANISME");
l.add("CODE_DELEGATAIRE");
l.add("COTISATION_ETABLISSEMENT");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
l.add("REFERENCE");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "NOM");
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
ContratPrevSalarieTable tableSalarie = new ContratPrevSalarieTable();
 
ContratPrevRubriqueTable tableRub = new ContratPrevRubriqueTable(false);
ContratPrevRubriqueTable tableRubNet = new ContratPrevRubriqueTable(true);
 
public void addViews() {
 
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
/***********************************************************************************
* Renseignements
**********************************************************************************/
JPanel panelInfos = new JPanel();
panelInfos.setBorder(BorderFactory.createTitledBorder("Renseignements (S21.G00.15)"));
panelInfos.setLayout(new GridBagLayout());
 
// // Code
// JLabel labelCode = new JLabel(getLabelFor("CODE_UNIQUE"));
// JTextField textCode = new JTextField();
// panelInfos.add(labelCode, c);
// c.gridx++;
// c.weightx = 1;
// panelInfos.add(textCode, c);
// this.addSQLObject(textCode, "CODE_UNIQUE");
// c.weightx = 0;
 
// Nom
JLabel labelNom = new JLabel(getLabelFor("NOM"));
JTextField textNom = new JTextField();
// c.gridx++;
c.weightx = 0;
panelInfos.add(labelNom, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textNom, c);
c.weightx = 0;
// Ref
JLabel labelRef = new JLabel(getLabelFor("REFERENCE"));
JTextField textRef = new JTextField();
c.gridx++;
panelInfos.add(labelRef, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textRef, c);
 
c.weightx = 0;
 
// Nom
JLabel labelCO = new JLabel(getLabelFor("CODE_ORGANISME"));
JTextField textCO = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelCO, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textCO, c);
c.weightx = 0;
 
// Ref
JLabel labelCD = new JLabel(getLabelFor("CODE_DELEGATAIRE"));
JTextField textCD = new JTextField();
c.gridx++;
panelInfos.add(labelCD, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textCD, c);
 
// Formation
JCheckBox checkFO = new JCheckBox(getLabelFor("COTISATION_ETABLISSEMENT"));
c.gridy++;
c.gridx = 0;
c.weightx = 0;
c.gridwidth = 2;
panelInfos.add(checkFO, c);
 
// Deb
JLabel labelDateDeb = new JLabel(getLabelFor("DATE_DEBUT"));
JDate dateDeb = new JDate();
c.gridx = 0;
c.gridy++;
c.weightx = 0;
panelInfos.add(labelDateDeb, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(dateDeb, c);
this.addSQLObject(dateDeb, "DATE_DEBUT");
c.weightx = 0;
// Fin
JLabel labelDateFin = new JLabel(getLabelFor("DATE_FIN"));
JDate dateFin = new JDate();
c.gridx++;
panelInfos.add(labelDateFin, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(dateFin, c);
this.addSQLObject(dateFin, "DATE_FIN");
 
c.weightx = 0;
 
TitledSeparator sepRenseignement = new TitledSeparator("Renseignement par contrat salarié (S21.G00.70)");
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
c.gridx = 0;
panelInfos.add(sepRenseignement, c);
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weighty = 0.5;
 
panelInfos.add(tableSalarie, c);
 
TitledSeparator sepRub = new TitledSeparator("Rubriques de cotisation rattachées");
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
c.gridx = 0;
panelInfos.add(sepRub, c);
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weighty = 0.5;
panelInfos.add(tableRub, c);
 
TitledSeparator sepRubN = new TitledSeparator("Rubriques de net rattachées");
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
c.gridx = 0;
panelInfos.add(sepRubN, c);
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weighty = 0.5;
panelInfos.add(tableRubNet, c);
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
this.add(panelInfos, c);
 
this.addSQLObject(textNom, "NOM");
 
this.addSQLObject(textCD, "CODE_DELEGATAIRE");
this.addSQLObject(textCO, "CODE_ORGANISME");
this.addSQLObject(textRef, "REFERENCE");
this.addSQLObject(checkFO, "COTISATION_ETABLISSEMENT");
}
 
@Override
public int insert(SQLRow order) {
 
int id = super.insert(order);
 
tableRub.updateField("ID_CONTRAT_PREVOYANCE", id);
tableRubNet.updateField("ID_CONTRAT_PREVOYANCE", id);
tableSalarie.updateField("ID_CONTRAT_PREVOYANCE", id);
return id;
}
 
@Override
public void update() {
 
int id = getSelectedID();
super.update();
tableRub.updateField("ID_CONTRAT_PREVOYANCE", id);
tableRubNet.updateField("ID_CONTRAT_PREVOYANCE", id);
tableSalarie.updateField("ID_CONTRAT_PREVOYANCE", id);
 
}
 
@Override
public void select(SQLRowAccessor r) {
 
super.select(r);
if (r != null) {
tableRub.insertFrom("ID_CONTRAT_PREVOYANCE", r.getID());
tableRubNet.insertFrom("ID_CONTRAT_PREVOYANCE", r.getID());
tableSalarie.insertFrom("ID_CONTRAT_PREVOYANCE", r.getID());
}
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CaisseCotisationRenseignentSQLElement.java
New file
0,0 → 1,88
/*
* 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.humanresources.payroll.element;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
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.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.utils.ListMap;
 
public class CaisseCotisationRenseignentSQLElement extends ConfSQLElement {
 
public CaisseCotisationRenseignentSQLElement() {
super("CAISSE_COTISATION_RENSEIGNEMENT", "une caisse renseignement", "caisses renseignements");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("IDENTIFIANT");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("IDENTIFIANT");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "IDENTIFIANT");
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
 
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Nom
JLabel labelNom = new JLabel(getLabelFor("NOM"));
JTextField textNom = new JTextField();
this.add(labelNom, c);
c.gridx++;
c.weightx = 1;
this.add(textNom, c);
c.weightx = 0;
 
this.addSQLObject(textNom, "NOM");
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AyantDroitSQLElement.java
New file
0,0 → 1,267
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.humanresources.payroll.ui.AyantDroitTable;
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.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
public class AyantDroitSQLElement extends ComptaSQLConfElement {
 
public AyantDroitSQLElement() {
super("AYANT_DROIT", "un ayant droit", "ayants droit");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_SALARIE");
l.add("NOM");
l.add("PRENOMS");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
l.add("PRENOMS");
return l;
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".ayantdroit";
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "NOM");
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
AyantDroitTable table = new AyantDroitTable();
 
public void addViews() {
 
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
/***********************************************************************************
* Renseignements
**********************************************************************************/
JPanel panelInfos = new JPanel();
panelInfos.setBorder(BorderFactory.createTitledBorder("Renseignements (S21.G00.73)"));
panelInfos.setLayout(new GridBagLayout());
 
// Code
JLabel labelSal = new JLabel(getLabelFor("ID_SALARIE"));
SQLRequestComboBox boxSal = new SQLRequestComboBox();
panelInfos.add(labelSal, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(boxSal, c);
this.addRequiredSQLObject(boxSal, "ID_SALARIE");
c.weightx = 0;
 
// Nom
JLabel labelNom = new JLabel(getLabelFor("NOM"));
JTextField textNom = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelNom, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textNom, c);
this.addRequiredSQLObject(textNom, "NOM");
c.weightx = 0;
// Ref
JLabel labelPrenoms = new JLabel(getLabelFor("PRENOMS"));
JTextField textPrenoms = new JTextField();
c.gridx++;
panelInfos.add(labelPrenoms, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textPrenoms, c);
this.addRequiredSQLObject(textPrenoms, "PRENOMS");
 
c.weightx = 0;
 
// Nom
JLabel labelCO = new JLabel(getLabelFor("CODE_OPTION"));
JTextField textCO = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelCO, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textCO, c);
this.addSQLObject(textCO, "CODE_OPTION");
 
c.weightx = 0;
 
// Ref
JLabel labelADT = new JLabel(getLabelFor("ID_AYANT_DROIT_TYPE"));
SQLRequestComboBox boxType = new SQLRequestComboBox();
c.gridx++;
panelInfos.add(labelADT, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(boxType, c);
this.addRequiredSQLObject(boxType, "ID_AYANT_DROIT_TYPE");
 
// Nom
JLabel labelD = new JLabel(getLabelFor("DATE_DEBUT_RATTACHEMENT"));
JDate d = new JDate();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelD, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(d, c);
this.addRequiredSQLObject(d, "DATE_DEBUT_RATTACHEMENT");
 
c.weightx = 0;
 
// Ref
JLabel labelDN = new JLabel(getLabelFor("DATE_NAISSANCE"));
JDate dn = new JDate();
c.gridx++;
panelInfos.add(labelDN, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(dn, c);
this.addRequiredSQLObject(dn, "DATE_NAISSANCE");
 
// Nom
JLabel labelNIR = new JLabel(getLabelFor("NIR"));
JTextField nir = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelNIR, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(nir, c);
this.addSQLObject(nir, "NIR");
 
c.weightx = 0;
 
// // Ref
// JLabel labelNIRO = new JLabel(getLabelFor("NIR_OUVRANT_DROIT"));
// JTextField niro = new JTextField();
// c.gridx++;
// panelInfos.add(labelNIRO, c);
// c.gridx++;
// c.weightx = 1;
// panelInfos.add(niro, c);
// this.addRequiredSQLObject(niro, "NIR_OUVRANT_DROIT");
 
// Nom
JLabel labelCodeAffil = new JLabel(getLabelFor("CODE_ORGANISME_AFFILIATION"));
JTextField codeAffil = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelCodeAffil, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(codeAffil, c);
this.addSQLObject(codeAffil, "CODE_ORGANISME_AFFILIATION");
 
c.weightx = 0;
 
// Ref
JLabel labelDATEFIN = new JLabel(getLabelFor("DATE_FIN_RATTACHEMENT"));
JDate dFin = new JDate();
c.gridx++;
panelInfos.add(labelDATEFIN, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(dFin, c);
this.addRequiredSQLObject(dFin, "DATE_FIN_RATTACHEMENT");
 
c.weightx = 0;
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weighty = 1;
panelInfos.add(table, c);
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
this.add(panelInfos, c);
 
 
}
 
@Override
public int insert(SQLRow order) {
 
int id = super.insert(order);
 
table.updateField("ID_AYANT_DROIT", id);
return id;
}
 
@Override
public void update() {
 
int id = getSelectedID();
super.update();
table.updateField("ID_AYANT_DROIT", id);
}
 
@Override
public void select(SQLRowAccessor r) {
 
super.select(r);
if (r != null) {
table.insertFrom("ID_AYANT_DROIT", r.getID());
}
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueCotisationSQLElement.java
68,6 → 68,8
l.add("BRUT");
l.add("ID_CODE_CAISSE_TYPE_RUBRIQUE");
l.add("ID_CODE_BASE_ASSUJETTIE");
l.add("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE");
l.add("ID_CODE_COTISATION_INDIVIDUELLE");
l.add("PART_CSG");
l.add("PART_CSG_SANS_ABATTEMENT");
l.add("IMPOSABLE");
235,7 → 237,7
JCheckBox checkImpo = new JCheckBox(getLabelFor("IMPOSABLE"));
panelProp.add(checkImpo, cPanel);
 
JLabel labelSelTypePersonnel = new JLabel("Code Type Personnel");
JLabel labelSelTypePersonnel = new JLabel("Code Type Personnel URSSAF (S21.G00.23)");
cPanel.gridy++;
cPanel.gridx = 1;
cPanel.weightx = 0;
247,7 → 249,7
panelProp.add(comboSelTypePersonnel, cPanel);
this.addView(comboSelTypePersonnel, "ID_CODE_CAISSE_TYPE_RUBRIQUE");
 
JLabel labelSelTypeBase = new JLabel("Code Base assujettie");
JLabel labelSelTypeBase = new JLabel("Code Base assujettie (S21.G00.78)");
cPanel.gridy++;
cPanel.gridx = 1;
cPanel.weightx = 0;
259,6 → 261,44
panelProp.add(comboSelTypeBase, cPanel);
this.addView(comboSelTypeBase, "ID_CODE_BASE_ASSUJETTIE");
 
JLabel labelSelTypeComposant = new JLabel("Type Composant base assujettie (S21.G00.79)");
cPanel.gridy++;
cPanel.gridx = 1;
cPanel.weightx = 0;
panelProp.add(labelSelTypeComposant, cPanel);
 
ElementComboBox comboSelTypeComposant = new ElementComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelTypeComposant, cPanel);
this.addView(comboSelTypeComposant, "ID_TYPE_COMPOSANT_BASE_ASSUJETTIE");
 
JLabel labelSelCodeInd = new JLabel("Code cotisation individuelle (S21.G00.81)");
cPanel.gridy++;
cPanel.gridx = 1;
cPanel.weightx = 0;
panelProp.add(labelSelCodeInd, cPanel);
 
ElementComboBox comboSelCodeInd = new ElementComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelCodeInd, cPanel);
this.addView(comboSelCodeInd, "ID_CODE_COTISATION_INDIVIDUELLE");
JLabel labelSelCodeEta = new JLabel("Code cotisation établissement (S21.G00.82.002)");
cPanel.gridy++;
cPanel.gridx = 1;
cPanel.weightx = 0;
panelProp.add(labelSelCodeEta, cPanel);
 
ElementComboBox comboSelCodeEta = new ElementComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelCodeEta, cPanel);
this.addView(comboSelCodeEta, "ID_CODE_COTISATION_ETABLISSEMENT");
 
// Patronale imposable
cPanel.gridy++;
c.gridx--;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/FichePayeSQLElement.java
54,7 → 54,9
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.element.SQLElementLinksSetup;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.element.SQLElementLink.LinkType;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
101,6 → 103,14
return true;
}
 
@Override
protected void setupLinks(SQLElementLinksSetup links) {
super.setupLinks(links);
if (getTable().contains("ID_INFOS_SALARIE_PAYE")) {
links.get("ID_INFOS_SALARIE_PAYE").setType(LinkType.ASSOCIATION);
}
}
 
/*
* (non-Javadoc)
*
665,6 → 675,9
float cotSal = rowCumuls.getFloat("COT_SAL_C") - row.getFloat("COT_SAL");
float cotPat = rowCumuls.getFloat("COT_PAT_C") - row.getFloat("COT_PAT");
float netImp = rowCumuls.getFloat("NET_IMP_C") - row.getFloat("NET_IMP");
// TODO stocker les heures travaillées du mois pour faire déduction
// float heure = rowCumuls.getFloat("HEURE_TRAV_C") -
// row.getFloat("HEURE_TRAV");
float netAPayer = rowCumuls.getFloat("NET_A_PAYER_C") - row.getFloat("NET_A_PAYER") - row.getFloat("ACOMPTE");
 
SQLRowValues rowValsCumul = rowCumuls.createEmptyUpdateRow();
674,6 → 687,7
rowValsCumul.put("NET_IMP_C", new Float(netImp));
rowValsCumul.put("NET_A_PAYER_C", new Float(netAPayer));
rowValsCumul.put("CSG_C", new Float(cgs));
// rowValsCumul.put("HEURE_TRAV_C", new Float(heure));
 
try {
rowValsCumul.update();
825,12 → 839,12
float cotSal = rowCumuls.getFloat("COT_SAL_C") + rowFiche.getFloat("COT_SAL");
float cotPat = rowCumuls.getFloat("COT_PAT_C") + rowFiche.getFloat("COT_PAT");
float netImp = rowCumuls.getFloat("NET_IMP_C") + rowFiche.getFloat("NET_IMP");
float hTrav = rowCumuls.getFloat("HEURE_TRAV") + rowVarSal.getFloat("HEURE_TRAV");
float hTrav = rowCumuls.getFloat("HEURE_TRAV_C") + rowVarSal.getFloat("HEURE_TRAV");
float netAPayer = rowCumuls.getFloat("NET_A_PAYER_C") + rowFiche.getFloat("NET_A_PAYER") + rowFiche.getFloat("ACOMPTE");
 
SQLRowValues rowValsCumul = new SQLRowValues(tableCumuls);
rowValsCumul.put("SAL_BRUT_C", new Float(salBrut));
rowValsCumul.put("HEURE_TRAV", new Float(hTrav));
rowValsCumul.put("HEURE_TRAV_C", new Float(hTrav));
rowValsCumul.put("COT_SAL_C", new Float(cotSal));
rowValsCumul.put("COT_PAT_C", new Float(cotPat));
rowValsCumul.put("NET_IMP_C", new Float(netImp));
904,8 → 918,12
// Remise à 0 des variables sal
final SQLRowValues rowVals = new SQLRowValues(tableVariableSal);
for (final SQLField field : tableVariableSal.getContentFields()) {
if (field.getType().getJavaType() == Integer.class) {
rowVals.put(field.getName(), 0);
} else {
rowVals.put(field.getName(), Float.valueOf(0));
}
}
rowVals.put("HEURE_TRAV", rowSalInfosPaye.getObject("DUREE_MOIS"));
 
if (tableVariableSal.contains("NB_JOUR_MOIS")) {
973,6 → 991,8
final SQLRow rContrat = rInfosSalPaye.getForeignRow("ID_CONTRAT_SALARIE");
rowValsFiche.put("NATURE_EMPLOI", rContrat.getString("NATURE"));
rowValsFiche.put("ID_IDCC", rInfosSalPaye.getInt("ID_IDCC"));
rowValsFiche.put("ID_INFOS_SALARIE_PAYE", rInfosSalPaye.getID());
 
rowValsFiche.update(id);
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CaisseModePaiementSQLElement.java
New file
0,0 → 1,26
/*
* 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.humanresources.payroll.element;
 
public class CaisseModePaiementSQLElement extends AbstractCodeSQLElement {
 
public CaisseModePaiementSQLElement() {
super("CAISSE_MODE_PAIEMENT", "un mode de paiement", "modes de paiement");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".mode.paiement";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueNetSQLElement.java
13,6 → 13,7
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import org.openconcerto.erp.config.DsnBrutCode;
import org.openconcerto.erp.core.common.ui.SQLJavaEditor;
import org.openconcerto.erp.core.humanresources.payroll.component.FormuleTreeNode;
import org.openconcerto.erp.core.humanresources.payroll.component.RubriqueSQLComponent;
21,8 → 22,11
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
326,6 → 330,104
panelProp.add(textCpt, cPanel);
addView(textCpt, "NUMERO_COMPTE_PCE_CHARGES");
 
TitledSeparator sepRenseignement = new TitledSeparator("Prime, gratification et indemnité (S21.G00.52)");
cPanel.gridwidth = GridBagConstraints.REMAINDER;
cPanel.gridy++;
cPanel.gridx = 1;
panelProp.add(sepRenseignement, cPanel);
 
// Type
JLabel labelSelCodeRubrique = new JLabel("Code DSN (S21.G00.52.001)");
labelSelCodeRubrique.setHorizontalAlignment(SwingConstants.RIGHT);
cPanel.gridy++;
cPanel.gridwidth = 1;
cPanel.gridx = 1;
cPanel.gridheight = 1;
cPanel.gridwidth = 1;
cPanel.weightx = 0;
cPanel.anchor = GridBagConstraints.WEST;
panelProp.add(labelSelCodeRubrique, cPanel);
 
ElementComboBox comboSelCodeRubrique = new ElementComboBox(false);
final SQLElement foreignElement = getElement().getForeignElement("ID_CODE_TYPE_RUBRIQUE_BRUT");
ComboSQLRequest req = foreignElement.getComboRequest(true);
Where where = new Where(foreignElement.getTable().getField("TYPE"), "=", DsnBrutCode.DsnTypeCodeBrut.PRIME.getName());
where = where.or(new Where(foreignElement.getTable().getField("TYPE"), "=", DsnBrutCode.DsnTypeCodeBrut.AUTRE.getName()));
req.setWhere(where);
comboSelCodeRubrique.init(foreignElement, req);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelCodeRubrique, cPanel);
this.addView(comboSelCodeRubrique, "ID_CODE_TYPE_RUBRIQUE_BRUT");
 
TitledSeparator sepRenseignementPrev = new TitledSeparator("Renseignement contrat prévoyance, mutuelle");
cPanel.gridwidth = GridBagConstraints.REMAINDER;
cPanel.gridy++;
cPanel.gridx = 1;
panelProp.add(sepRenseignementPrev, cPanel);
 
JLabel labelSelCaisse = new JLabel("Caisse de cotisation");
cPanel.gridy++;
cPanel.gridwidth = 1;
cPanel.gridx = 1;
cPanel.weightx = 0;
panelProp.add(labelSelCaisse, cPanel);
 
ElementComboBox comboSelTypeCaisse = new ElementComboBox(true);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelTypeCaisse, cPanel);
this.addView(comboSelTypeCaisse, "ID_CAISSE_COTISATION");
 
JLabel labelSelTypeBase = new JLabel("Code Base assujettie (S21.G00.78)");
cPanel.gridy++;
cPanel.gridx = 1;
cPanel.weightx = 0;
panelProp.add(labelSelTypeBase, cPanel);
 
ElementComboBox comboSelTypeBase = new ElementComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelTypeBase, cPanel);
this.addView(comboSelTypeBase, "ID_CODE_BASE_ASSUJETTIE");
 
JLabel labelSelTypeComposant = new JLabel("Type Composant base assujettie (S21.G00.79)");
cPanel.gridy++;
cPanel.gridx = 1;
cPanel.weightx = 0;
panelProp.add(labelSelTypeComposant, cPanel);
 
ElementComboBox comboSelTypeComposant = new ElementComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelTypeComposant, cPanel);
this.addView(comboSelTypeComposant, "ID_TYPE_COMPOSANT_BASE_ASSUJETTIE");
 
JLabel labelSelCodeInd = new JLabel("Code cotisation individuelle (S21.G00.81)");
cPanel.gridy++;
cPanel.gridx = 1;
cPanel.weightx = 0;
panelProp.add(labelSelCodeInd, cPanel);
 
ElementComboBox comboSelCodeInd = new ElementComboBox(false);
cPanel.gridx++;
cPanel.weightx = 1;
panelProp.add(comboSelCodeInd, cPanel);
this.addView(comboSelCodeInd, "ID_CODE_COTISATION_INDIVIDUELLE");
 
// JLabel labelSelCodeEta = new JLabel("Code cotisation établissement
// (S21.G00.82.002)");
// cPanel.gridy++;
// cPanel.gridx = 1;
// cPanel.weightx = 0;
// panelProp.add(labelSelCodeEta, cPanel);
//
// ElementComboBox comboSelCodeEta = new ElementComboBox(false);
// cPanel.gridx++;
// cPanel.weightx = 1;
// panelProp.add(comboSelCodeEta, cPanel);
// this.addView(comboSelCodeEta, "ID_CODE_COTISATION_ETABLISSEMENT");
 
// Tabbed Pane
JTabbedPane tab = new JTabbedPane();
tab.add("Calcul", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, paneTree, panelCalcul));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AyantDroitContratPrevSQLElement.java
New file
0,0 → 1,262
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.humanresources.payroll.ui.AyantDroitTable;
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.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
public class AyantDroitContratPrevSQLElement extends ComptaSQLConfElement {
 
public AyantDroitContratPrevSQLElement() {
super("CONTRAT_PREVOYANCE_AYANT_DROIT", "un ayant droit", "ayants droit");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_CONTRAT_PREVOYANCE");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_CONTRAT_PREVOYANCE");
return l;
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".contrat.ayantdroit";
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "ID_CONTRAT_PREVOYANCE");
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
AyantDroitTable table = new AyantDroitTable();
 
public void addViews() {
 
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
/***********************************************************************************
* Renseignements
**********************************************************************************/
JPanel panelInfos = new JPanel();
panelInfos.setBorder(BorderFactory.createTitledBorder("Renseignements"));
panelInfos.setLayout(new GridBagLayout());
 
// Code
JLabel labelSal = new JLabel(getLabelFor("ID_SALARIE"));
SQLRequestComboBox boxSal = new SQLRequestComboBox();
panelInfos.add(labelSal, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(boxSal, c);
this.addRequiredSQLObject(boxSal, "ID_SALARIE");
c.weightx = 0;
 
// Nom
JLabel labelNom = new JLabel(getLabelFor("NOM"));
JTextField textNom = new JTextField();
// c.gridx++;
c.weightx = 0;
panelInfos.add(labelNom, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textNom, c);
c.weightx = 0;
// Ref
JLabel labelPrenoms = new JLabel(getLabelFor("PRENOMS"));
JTextField textPrenoms = new JTextField();
c.gridx++;
panelInfos.add(labelPrenoms, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textPrenoms, c);
this.addSQLObject(textPrenoms, "PRENOMS");
 
c.weightx = 0;
 
// Nom
JLabel labelCO = new JLabel(getLabelFor("CODE_OPTION"));
JTextField textCO = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelCO, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(textCO, c);
this.addSQLObject(textCO, "CODE_OPTION");
 
c.weightx = 0;
 
// Ref
JLabel labelADT = new JLabel(getLabelFor("ID_AYANT_DROIT_TYPE"));
SQLRequestComboBox boxType = new SQLRequestComboBox();
c.gridx++;
panelInfos.add(labelADT, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(boxType, c);
this.addRequiredSQLObject(boxType, "ID_AYANT_DROIT_TYPE");
 
// Nom
JLabel labelD = new JLabel(getLabelFor("DATE_DEBUT"));
JDate d = new JDate();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelD, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(d, c);
this.addRequiredSQLObject(d, "DATE_DEBUT");
 
c.weightx = 0;
 
// Ref
JLabel labelDN = new JLabel(getLabelFor("DATE_NAISSANCE"));
JDate dn = new JDate();
c.gridx++;
panelInfos.add(labelDN, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(dn, c);
this.addRequiredSQLObject(dn, "DATE_NAISSANCE");
 
// Nom
JLabel labelNIR = new JLabel(getLabelFor("NIR"));
JTextField nir = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelNIR, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(nir, c);
this.addSQLObject(nir, "NIR");
 
c.weightx = 0;
 
// Ref
JLabel labelNIRO = new JLabel(getLabelFor("NIR_OUVRANT_DROIT"));
JTextField niro = new JTextField();
c.gridx++;
panelInfos.add(labelNIRO, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(niro, c);
this.addRequiredSQLObject(niro, "NIR_OUVRANT_DROIT");
 
// Nom
JLabel labelCodeAffil = new JLabel(getLabelFor("CODE_ORGANISME_AFFILIATION"));
JTextField codeAffil = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelInfos.add(labelCodeAffil, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(codeAffil, c);
this.addSQLObject(codeAffil, "CODE_ORGANISME_AFFILIATION");
 
c.weightx = 0;
 
// Ref
JLabel labelDATEFIN = new JLabel(getLabelFor("DATE_FIN"));
JDate dFin = new JDate();
c.gridx++;
panelInfos.add(labelDATEFIN, c);
c.gridx++;
c.weightx = 1;
panelInfos.add(dFin, c);
this.addRequiredSQLObject(dFin, "DATE_FIN");
 
c.weightx = 0;
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weighty = 1;
panelInfos.add(table, c);
 
c.gridx = 0;
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
this.add(panelInfos, c);
 
this.addSQLObject(textNom, "NOM");
 
}
 
@Override
public int insert(SQLRow order) {
 
int id = super.insert(order);
 
table.updateField("ID_AYANT_DROIT", id);
return id;
}
 
@Override
public void update() {
 
int id = getSelectedID();
super.update();
table.updateField("ID_AYANT_DROIT", id);
}
 
@Override
public void select(SQLRowAccessor r) {
 
super.select(r);
if (r != null) {
table.insertFrom("ID_AYANT_DROIT", r.getID());
}
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratSalarieSQLElement.java
24,7 → 24,9
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.JLabel;
import javax.swing.JTextField;
42,9 → 44,17
return l;
}
 
@Override
public Set<String> getInsertOnlyFields() {
Set<String> s = new HashSet<String>();
s.add("DATE_MODIFICATION");
return s;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NATURE");
l.add("NUMERO");
l.add("DATE_DEBUT");
return l;
}
 
64,8 → 74,22
public void addViews() {
 
this.setLayout(new GridBagLayout());
 
GridBagConstraints c = new DefaultGridBagConstraints();
 
// Numero
JLabel labelNumero = new JLabel(getLabelFor("NUMERO"));
labelNumero.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textNumero = new JTextField();
 
this.add(labelNumero, c);
c.gridx++;
c.weightx = 1;
this.add(textNumero, c);
this.addRequiredSQLObject(textNumero, "NUMERO");
 
c.gridy++;
c.gridx = 0;
// Nature
JLabel labelNature = new JLabel(getLabelFor("NATURE"));
labelNature.setHorizontalAlignment(SwingConstants.RIGHT);
296,6 → 320,49
// this.add(textCodeRegimeRetraite, c);
// addRequiredSQLObject(textCodeRegimeRetraite, "CODE_REGIME_RETRAITE_DSN");
 
JLabel labelDateModif = new JLabel(getLabelFor("DATE_MODIFICATION"));
labelDateModif.setHorizontalAlignment(SwingConstants.RIGHT);
JDate textDateModif = new JDate();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(textDateModif, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textDateModif, c);
addSQLObject(textDateModif, "DATE_MODIFICATION");
 
// JLabel labelCM = new JLabel(getLabelFor("ID_INFOS_SALARIE_PAYE_MODIFIE"));
// labelCM.setHorizontalAlignment(SwingConstants.RIGHT);
// ElementComboBox selCM = new ElementComboBox();
// final SQLElement elementInfosPaye =
// getDirectory().getElement("INFOS_SALARIE_PAYE");
// selCM.init(elementInfosPaye, elementInfosPaye.createComboRequest());
// selCM.setInfoIconVisible(false);
// c.gridy++;
// c.gridx = 0;
// c.weightx = 0;
// this.add(labelCM, c);
// c.gridx++;
// c.weighty = 1;
// c.weightx = 1;
// this.add(selCM, c);
// this.addSQLObject(selCM, "ID_INFOS_SALARIE_PAYE_MODIFIE");
 
JLabel labelDateDebut = new JLabel(getLabelFor("DATE_DEBUT"));
labelDateDebut.setHorizontalAlignment(SwingConstants.RIGHT);
JDate textDateDebut = new JDate();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelDateDebut, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textDateDebut, c);
addSQLObject(textDateDebut, "DATE_DEBUT", REQ);
 
JLabel labelDateFin = new JLabel(getLabelFor("DATE_PREV_FIN"));
labelDateFin.setHorizontalAlignment(SwingConstants.RIGHT);
JDate textDateFin = new JDate();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/SalarieSQLElement.java
18,6 → 18,7
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
25,7 → 26,14
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanelListener;
import org.openconcerto.sql.view.EditPanel.EditMode;
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.ui.FrameUtil;
import org.openconcerto.ui.warning.JLabelWarning;
import org.openconcerto.utils.checks.ValidState;
import org.openconcerto.utils.text.SimpleDocumentListener;
32,13 → 40,16
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
49,8 → 60,56
 
public SalarieSQLElement() {
super("SALARIE", "un salarié", "salariés");
 
PredicateRowAction actionNewContrat = new PredicateRowAction(new AbstractAction("Créer un nouveau contrat") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
final SQLRowAccessor rowSelected = IListe.get(e).getSelectedRow();
 
JOptionPane.showMessageDialog(null,
"Attention la création d'un nouveau contrat n'est pas réversible.\nCréer tous les bulletins de salaire de l'ancien contrat avant la création du nouveau.");
final SQLElement infosPayeElement = getDirectory().getElement("INFOS_SALARIE_PAYE");
EditFrame f = new EditFrame(infosPayeElement, EditMode.CREATION);
final SQLRow rowInfosAncien = rowSelected.asRow().getForeign("ID_INFOS_SALARIE_PAYE");
 
SQLRowValues cloneInfos = infosPayeElement.createCopy(rowInfosAncien.getID());
((SQLRowValues) cloneInfos.getForeign("ID_CONTRAT_SALARIE")).put("DATE_DEBUT", null);
f.getSQLComponent().select(cloneInfos);
 
f.addEditPanelListener(new EditPanelListener() {
 
@Override
public void modified() {
}
 
@Override
public void inserted(int id) {
try {
rowInfosAncien.createEmptyUpdateRow().put("ID_SALARIE", rowSelected.getID()).commit();
rowSelected.createEmptyUpdateRow().put("ID_INFOS_SALARIE_PAYE", id).commit();
} catch (SQLException e) {
e.printStackTrace();
}
}
 
@Override
public void deleted() {
}
 
@Override
public void cancelled() {
}
});
FrameUtil.show(f);
}
}, true);
actionNewContrat.setPredicate(IListeEvent.getSingleSelectionPredicate());
this.getRowActions().add(actionNewContrat);
 
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("CODE");
287,6 → 346,11
SQLTable tableInfosPaye = getTable().getBase().getTable("INFOS_SALARIE_PAYE");
SQLRow row = getTable().getRow(id);
SQLRow rowInfosPaye = tableInfosPaye.getRow(row.getInt("ID_INFOS_SALARIE_PAYE"));
try {
rowInfosPaye.createEmptyUpdateRow().put("ID_SALARIE", id).commit();
} catch (SQLException e1) {
e1.printStackTrace();
}
 
SQLRowValues rowVals = new SQLRowValues(tableFichePaye);
rowVals.put("ID_SALARIE", id);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/AyantDroitTypeSQLElement.java
New file
0,0 → 1,26
/*
* 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.humanresources.payroll.element;
 
public class AyantDroitTypeSQLElement extends AbstractCodeSQLElement {
 
public AyantDroitTypeSQLElement() {
super("AYANT_DROIT_TYPE", "un type d'ayant droit", "types d'ayant droit");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".type.ayantdroit";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeCotisationEtablissementSQLElement.java
New file
0,0 → 1,33
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.utils.ListMap;
 
public class CodeCotisationEtablissementSQLElement extends AbstractCodeSQLElement {
 
public CodeCotisationEtablissementSQLElement() {
super("CODE_COTISATION_ETABLISSEMENT", "un code de cotisation établissement", "codes de cotisation établissement");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cotisation.etablissement.code";
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "CODE");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CumulsPayeSQLElement.java
116,7 → 116,7
// net imposable
cPanel.gridx = 0;
cPanel.gridy++;
JLabel labelH = new JLabel(getLabelFor("HEURE_TRAV"));
JLabel labelH = new JLabel(getLabelFor("HEURE_TRAV_C"));
this.add(labelH, cPanel);
JTextField textH = new JTextField(10);
cPanel.gridx++;
127,7 → 127,7
this.addSQLObject(textCotSal, "COT_SAL_C");
this.addSQLObject(textNetAPayer, "NET_A_PAYER_C");
this.addSQLObject(textNetImp, "NET_IMP_C");
this.addSQLObject(textH, "HEURE_TRAV");
this.addSQLObject(textH, "HEURE_TRAV_C");
this.addSQLObject(textSalBrut, "SAL_BRUT_C");
}
};
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratPrevoyanceRubriqueNetSQLElement.java
New file
0,0 → 1,76
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
public class ContratPrevoyanceRubriqueNetSQLElement extends ComptaSQLConfElement {
 
public ContratPrevoyanceRubriqueNetSQLElement() {
super("CONTRAT_PREVOYANCE_RUBRIQUE_NET", "un rattachement rubrique net-contrat prévoyance", "rattachements rubrique net-contrat prévoyance");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_RUBRIQUE_NET");
l.add("ID_CONTRAT_PREVOYANCE");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_RUBRIQUE_NET");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "ID_RUBRIQUE_NET");
}
 
@Override
protected String getParentFFName() {
return "ID_CONTRAT_PREVOYANCE";
}
 
@Override
protected String createCode() {
return "humanresources.payroll.prevoyance.rubriquenet";
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
 
this.setLayout(new GridBagLayout());
 
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratPrevoyanceSalarieSQLElement.java
New file
0,0 → 1,86
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElementLinksSetup;
import org.openconcerto.sql.element.SQLElementLink.LinkType;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
public class ContratPrevoyanceSalarieSQLElement extends ComptaSQLConfElement {
 
public ContratPrevoyanceSalarieSQLElement() {
super("CONTRAT_PREVOYANCE_CONTRAT_SALARIE", "un rattachement salarié-contrat prévoyance", "rattachements salarié-contrat prévoyance");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_INFOS_SALARIE_PAYE");
l.add("ID_CONTRAT_PREVOYANCE");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_INFOS_SALARIE_PAYE");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "ID_INFOS_SALARIE_PAYE");
}
 
@Override
protected void setupLinks(SQLElementLinksSetup links) {
super.setupLinks(links);
if (getTable().contains("ID_INFOS_SALARIE_PAYE")) {
links.get("ID_INFOS_SALARIE_PAYE").setType(LinkType.ASSOCIATION);
}
}
 
@Override
protected String getParentFFName() {
return "ID_CONTRAT_PREVOYANCE";
}
 
@Override
protected String createCode() {
return "humanresources.payroll.prevoyance.employee";
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
 
this.setLayout(new GridBagLayout());
 
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodePenibiliteContratSQLElement.java
New file
0,0 → 1,76
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
public class CodePenibiliteContratSQLElement extends ComptaSQLConfElement {
 
public CodePenibiliteContratSQLElement() {
super("CODE_PENIBILITE_CONTRAT_SALARIE", "un rattachement code pénibilité contrat salarié", "rattachements code pénibilité contrat salarié");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_CODE_PENIBILITE");
l.add("ID_INFOS_SALARIE_PAYE");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_INFOS_SALARIE_PAYE");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "ID_INFOS_SALARIE_PAYE");
}
 
@Override
protected String getParentFFName() {
return "ID_INFOS_SALARIE_PAYE";
}
 
@Override
protected String createCode() {
return "humanresources.payroll.penibilite.contrat";
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
 
this.setLayout(new GridBagLayout());
 
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueBrutSQLElement.java
328,7 → 328,7
panelProp.add(checkCP, cPanel);
 
// Type
JLabel labelSelCodeRubrique = new JLabel("Code DSN");
JLabel labelSelCodeRubrique = new JLabel("Code DSN (S21.G00.51.011)");
labelSelCodeRubrique.setHorizontalAlignment(SwingConstants.RIGHT);
cPanel.gridy++;
cPanel.gridx = 1;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/TypeComposantBaseAssujettieSQLElement.java
New file
0,0 → 1,33
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.utils.ListMap;
 
public class TypeComposantBaseAssujettieSQLElement extends AbstractCodeSQLElement {
 
public TypeComposantBaseAssujettieSQLElement() {
super("TYPE_COMPOSANT_BASE_ASSUJETTIE", "un type de composant de base assujettie", "types de composant de base assujettie");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".composant.base.type";
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "CODE");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CaisseCotisationSQLElement.java
13,16 → 13,7
package org.openconcerto.erp.core.humanresources.payroll.element;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
import org.openconcerto.erp.core.humanresources.payroll.ui.CaisseCotisationRenseignementTable;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
29,6 → 20,7
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
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;
36,6 → 28,17
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
public class CaisseCotisationSQLElement extends ConfSQLElement {
 
public CaisseCotisationSQLElement() {
86,6 → 89,7
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
CaisseCotisationRenseignementTable table;
 
public void addViews() {
 
108,6 → 112,26
panelInfos.add(textNom, c);
c.weightx = 0;
 
// Nom
JCheckBox boxOrgProt = new JCheckBox(getLabelFor("ORG_PROTECTION_SOCIALE"));
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
c.gridy++;
c.gridx = 0;
panelInfos.add(boxOrgProt, c);
this.addSQLObject(boxOrgProt, "ORG_PROTECTION_SOCIALE");
c.gridwidth = 1;
 
// Nom
JCheckBox boxUrssaf = new JCheckBox(getLabelFor("URSSAF"));
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
c.gridy++;
c.gridx = 0;
panelInfos.add(boxUrssaf, c);
this.addSQLObject(boxUrssaf, "URSSAF");
c.gridwidth = 1;
 
// Adresse
TitledSeparator sep = new TitledSeparator("Adresse");
c.gridwidth = GridBagConstraints.REMAINDER;
164,12 → 188,18
c.gridx++;
c.weightx = 1;
panelInfos.add(textMail, c);
 
this.addSQLObject(textMail, "MAIL");
c.weightx = 0;
 
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
this.add(panelInfos, c);
c.weightx = 0;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
 
/***********************************************************************************
215,7 → 245,11
c.gridx = 0;
c.gridy = 1;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
this.add(panelCompta, c);
c.weightx = 0;
c.weighty = 0;
 
this.addSQLObject(textNom, "NOM");
this.addSQLObject(textTel, "TEL");
224,7 → 258,43
// this.addSQLObject(selCompteCharge, "ID_COMPTE_PCE_CHARGE");
// selCompteTiers.init();
// selCompteCharge.init();
TitledSeparator sepRenseignement = new TitledSeparator("Renseignement Organisme de protection social (S21.G00.20)");
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
c.gridx = 0;
c.weightx = 1;
this.add(sepRenseignement, c);
this.table = new CaisseCotisationRenseignementTable();
this.table.setEnabled(true);
c.gridy++;
c.weighty = 1;
this.add(this.table, c);
 
}
 
@Override
public void select(SQLRowAccessor r) {
super.select(r);
if (r != null) {
this.table.getModel().insertFrom(r);
} else {
this.table.getModel().clearRows();
}
}
 
@Override
public void update() {
 
super.update();
this.table.getModel().updateField("ID_CAISSE_COTISATION", getSelectedID());
}
 
@Override
public int insert(SQLRow order) {
final int insertID = super.insert(order);
this.table.getModel().updateField("ID_CAISSE_COTISATION", insertID);
return insertID;
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/TypePreavisSQLElement.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.humanresources.payroll.element;
 
public class TypePreavisSQLElement extends AbstractCodeCommonSQLElement {
public TypePreavisSQLElement() {
super("TYPE_PREAVIS", "un type de préavis", "types de préavis");
}
 
@Override
protected String createCode() {
return "humanresources.type.preavis.code";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodePenibiliteSQLElement.java
New file
0,0 → 1,33
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.utils.ListMap;
 
public class CodePenibiliteSQLElement extends AbstractCodeSQLElement {
 
public CodePenibiliteSQLElement() {
super("CODE_PENIBILITE", "un code de pénibilité", "codes de pénibilité");
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".cotisation.penibilite.code";
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "CODE");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratPrevoyanceRubriqueSQLElement.java
New file
0,0 → 1,76
/*
* 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.humanresources.payroll.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
public class ContratPrevoyanceRubriqueSQLElement extends ComptaSQLConfElement {
 
public ContratPrevoyanceRubriqueSQLElement() {
super("CONTRAT_PREVOYANCE_RUBRIQUE", "un rattachement rubrique-contrat prévoyance", "rattachements rubrique-contrat prévoyance");
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_RUBRIQUE_COTISATION");
l.add("ID_CONTRAT_PREVOYANCE");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_RUBRIQUE_COTISATION");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "ID_RUBRIQUE_COTISATION");
}
 
@Override
protected String getParentFFName() {
return "ID_CONTRAT_PREVOYANCE";
}
 
@Override
protected String createCode() {
return "humanresources.payroll.prevoyance.rubrique";
}
 
/*
* (non-Javadoc)
*
* @see org.openconcerto.devis.SQLElement#getComponent()
*/
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
 
this.setLayout(new GridBagLayout());
 
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/CodeTypeRubriqueBrutSQLElement.java
13,11 → 13,88
package org.openconcerto.erp.core.humanresources.payroll.element;
 
public class CodeTypeRubriqueBrutSQLElement extends AbstractCodeCommonSQLElement {
import org.openconcerto.erp.config.DsnBrutCode;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.component.ComboLockedMode;
import org.openconcerto.ui.component.ITextCombo;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class CodeTypeRubriqueBrutSQLElement extends ConfSQLElement {
 
public CodeTypeRubriqueBrutSQLElement() {
super("CODE_TYPE_RUBRIQUE_BRUT", "un code rubrique de brut", "codes rubrique de brut");
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(3);
list.add("CODE");
list.add("TYPE");
list.add("NOM");
return list;
}
 
protected List<String> getComboFields() {
final List<String> list = new ArrayList<String>(3);
list.add("CODE");
list.add("TYPE");
list.add("NOM");
return list;
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Code
final JLabel labelCode = new JLabel("Code");
this.add(labelCode, c);
c.gridx++;
c.weightx = 1;
final JTextField textCode = new JTextField();
this.add(textCode, c);
 
// Nom
c.gridx++;
c.weightx = 0;
final JLabel labelNom = new JLabel("Libellé");
this.add(labelNom, c);
c.gridx++;
c.weightx = 1;
final JTextField textNom = new JTextField();
this.add(textNom, c);
 
// Type
ITextCombo comboType = new ITextCombo(ComboLockedMode.LOCKED);
comboType.initCache(Arrays.asList(DsnBrutCode.DsnTypeCodeBrut.PRIME.getName(), DsnBrutCode.DsnTypeCodeBrut.AUTRE.getName(), DsnBrutCode.DsnTypeCodeBrut.REMUNERATION.getName()));
c.gridx++;
c.weightx = 0;
final JLabel labelType = new JLabel("Type");
this.add(labelType, c);
c.gridx++;
c.weightx = 1;
this.add(comboType, c);
 
this.addRequiredSQLObject(comboType, "TYPE");
this.addRequiredSQLObject(textNom, "NOM");
this.addRequiredSQLObject(textCode, "CODE");
}
};
}
 
@Override
protected String createCode() {
return "humanresources.rubriquebrut.code";
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/InfosSalariePayeSQLElement.java
15,6 → 15,7
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.humanresources.payroll.ui.ContratPenibiliteTable;
import org.openconcerto.erp.model.PrixHT;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
21,6 → 22,7
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
53,12 → 55,14
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_IDCC");
l.add("ID_SALARIE");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_IDCC");
l.add("ID_SALARIE");
l.add("ID_CONTRAT_SALARIE");
return l;
}
 
103,6 → 107,24
}
};
 
ContratPenibiliteTable tablePeni = new ContratPenibiliteTable();
 
@Override
public int insert(SQLRow order) {
// TODO Auto-generated method stub
int id = super.insert(order);
tablePeni.updateField("ID_INFOS_SALARIE_PAYE", id);
return id;
}
 
@Override
public void update() {
// TODO Auto-generated method stub
int id = getSelectedID();
super.update();
tablePeni.updateField("ID_INFOS_SALARIE_PAYE", id);
}
 
public void addViews() {
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
176,7 → 198,7
 
c.gridx = 2;
c.gridy = 1;
c.gridheight = 3;
c.gridheight = 4;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
this.add(panelContrat, c);
232,6 → 254,22
this.add(panelEntreeSortie, c);
c.gridwidth = 1;
 
JPanel panelPeni = new JPanel();
panelPeni.setOpaque(false);
panelPeni.setBorder(BorderFactory.createTitledBorder("Pénibilité (S21.G00.34)"));
panelPeni.setLayout(new GridBagLayout());
GridBagConstraints cPeni = new DefaultGridBagConstraints();
cPeni.weightx = 1;
cPeni.weighty = 1;
cPeni.fill = GridBagConstraints.BOTH;
 
panelPeni.add(tablePeni, cPeni);
c.gridy++;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
this.add(panelPeni, c);
c.fill = GridBagConstraints.HORIZONTAL;
 
/***********************************************************************************
* Valeurs de bases
**********************************************************************************/
404,7 → 442,7
panelBase.add(sectionAT, c);
addView(sectionAT, "CODE_SECTION_AT");
 
c.gridy = 4;
c.gridy = 5;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weighty = 1;
462,6 → 500,10
 
super.select(r);
 
if (r != null) {
tablePeni.insertFrom("ID_INFOS_SALARIE_PAYE", r.getID());
}
 
this.dureeMois.getDocument().addDocumentListener(this.listenerMois);
this.dureeHebdo.getDocument().addDocumentListener(this.listenerHebdo);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/FichePayeSheetXML.java
18,6 → 18,8
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRow;
 
import java.util.Calendar;
 
public class FichePayeSheetXML extends AbstractSheetXMLWithDate {
 
public static final String TEMPLATE_ID = "FichePaye";
39,8 → 41,12
public String getName() {
SQLRow rowSal = row.getForeign("ID_SALARIE");
SQLRow rowMois = row.getForeign("ID_MOIS");
return ("FichePaye_" + rowSal.getString("CODE") + "_" + rowMois.getString("NOM") + "_" + row.getString("ANNEE"));
 
Calendar du = row.getDate("DU");
String suffix = "";
if (du != null && du.get(Calendar.DAY_OF_MONTH) != 1) {
suffix = "_" + du.get(Calendar.DAY_OF_MONTH);
}
return ("FichePaye_" + rowSal.getString("CODE") + suffix + "_" + rowMois.getString("NOM") + "_" + row.getString("ANNEE"));
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/LivrePayeSheet.java
43,7 → 43,7
private final static SQLTable tableRubNet = Configuration.getInstance().getBase().getTable("RUBRIQUE_NET");
private final static SQLTable tableRubBrut = Configuration.getInstance().getBase().getTable("RUBRIQUE_BRUT");
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private int moisDu, moisAu;
private String annee;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/EtatChargesPayeSheet.java
41,7 → 41,7
private final static SQLTable tableCaisse = Configuration.getInstance().getBase().getTable("CAISSE_COTISATION");
private final static SQLTable tableRubCot = Configuration.getInstance().getBase().getTable("RUBRIQUE_COTISATION");
 
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
private int moisDu, moisAu;
private String annee;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/FichePayeSheet.java
59,7 → 59,6
private final static SQLTable tableCumulsPaye = base.getTable("CUMULS_PAYE");
private final static SQLTable tableVarPeriode = base.getTable("VARIABLE_SALARIE");
private final static SQLTable tableConventionC = base.getTable("IDCC");
private final static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
 
private Map styleMapRow;
 
200,6 → 199,8
 
protected void createMap() {
 
final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
 
this.styleMapRow = new HashMap();
this.mapReplace = new HashMap();
 
426,7 → 427,6
cotPatCumul = cotPatCumul.add(rowCumulsPaye.getBigDecimal("COT_PAT_C"));
netImpCumul = netImpCumul.add(rowCumulsPaye.getBigDecimal("NET_IMP_C"));
 
this.mCell.put("D62", salBrutCumul);
this.mCell.put("E62", cotSalCumul);
this.mCell.put("F62", cotPatCumul);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/report/N4DS.java
14,6 → 14,8
package org.openconcerto.erp.core.humanresources.employe.report;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
41,7 → 43,7
 
public class N4DS {
 
private static DateFormat format = new SimpleDateFormat("ddMMyyyy");
private DateFormat format = new SimpleDateFormat("ddMMyyyy");
private ComptaPropsConfiguration conf = ((ComptaPropsConfiguration) Configuration.getInstance());
private double masseSalarialeBrute;
private static final byte[] retour = "'\n".getBytes();
65,8 → 67,12
 
public File createDocument() {
this.masseSalarialeBrute = 0;
File f = new File("N4DS_" + format.format(new Date()) + ".txt");
File dir = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(FichePayeSheetXML.TEMPLATE_ID);
dir.mkdirs();
File f = new File(dir, "N4DS_" + format.format(new Date()) + ".txt");
 
// File f = new File("N4DS_" + format.format(new Date()) + ".txt");
 
try {
 
this.stream = new PrintStream(f, "ISO-8859-1");
83,6 → 89,16
SQLSelect sel = new SQLSelect();
sel.addSelect(eltSalarie.getTable().getKey());
 
final SQLElement infosElt = eltSalarie.getForeignElement("ID_INFOS_SALARIE_PAYE");
// Date d1 = new Date(116, 0, 1);
Date d2 = new Date(116, 11, 31);
 
Where w = new Where(infosElt.getTable().getKey(), "=", eltSalarie.getTable().getField("ID_INFOS_SALARIE_PAYE"));
w = w.and(new Where(infosElt.getTable().getField("DATE_ARRIVE"), "<=", d2));
w = w.and(new Where(infosElt.getTable().getField("DATE_SORTIE"), "=", (Date) null).or(new Where(infosElt.getTable().getField("DATE_SORTIE"), "<=", d2)));
 
sel.setWhere(w);
 
@SuppressWarnings("unchecked")
List<SQLRow> l = (List<SQLRow>) this.conf.getBase().getDataSource().execute(sel.asString(), new SQLRowListRSH(eltSalarie.getTable()));
 
134,12 → 150,12
complement = complement.substring(0, complement.length() - 1);
}
 
write("S80.G01.00.003.001", complement);
write("S80.G01.00.003.001", normalizeString2(complement));
}
}
 
// Voie
write("S80.G01.00.003.006", voie);
write("S80.G01.00.003.006", normalizeString2(voie));
 
// TODO Code INSEE, facultatif
// stream.write("S80.G01.00.003.007",voie);
226,9 → 242,11
SQLElement eltInfos = this.conf.getDirectory().getElement("INFOS_SALARIE_PAYE");
SQLSelect sel = new SQLSelect();
sel.addSelect(eltSalarie.getTable().getKey());
Date d2 = new Date(112, 11, 31);
// Date d1 = new Date(116, 0, 1);
Date d2 = new Date(116, 11, 31);
Where w = new Where(eltSalarie.getTable().getField("ID_INFOS_SALARIE_PAYE"), "=", eltInfos.getTable().getKey());
w = w.and(new Where(eltInfos.getTable().getField("DATE_SORTIE"), "=", (Date) null).or(new Where(eltInfos.getTable().getField("DATE_SORTIE"), ">", d2)));
w = w.and(new Where(eltInfos.getTable().getField("DATE_SORTIE"), "=", (Date) null).or(new Where(eltInfos.getTable().getField("DATE_SORTIE"), "<=", d2)));
w = w.and(new Where(eltInfos.getTable().getField("DATE_ARRIVE"), "=", (Date) null).or(new Where(eltInfos.getTable().getField("DATE_ARRIVE"), "<=", d2)));
 
sel.setWhere(w);
System.err.println(sel.asString());
241,6 → 259,10
s = s.toUpperCase();
String temp = Normalizer.normalize(s, Form.NFC);
temp = temp.replaceAll("-", " ");
temp = temp.replaceAll("é", "e");
temp = temp.replaceAll("è", "e");
temp = temp.replaceAll("ê", "e");
temp = temp.replaceAll(",", "");
return temp.replaceAll("[^\\p{ASCII}]", "");
}
 
254,13 → 276,13
write("S20.G01.00.001", siren);
 
// Raison sociale
write("S20.G01.00.002", rowSociete.getString("NOM"));
write("S20.G01.00.002", normalizeString2(rowSociete.getString("NOM")));
 
// FIXME Debut periode
write("S20.G01.00.003.001", "01012015");
write("S20.G01.00.003.001", "01012016");
 
// FIXME Fin periode
write("S20.G01.00.003.002", "31122015");
write("S20.G01.00.003.002", "31122016");
 
// Code nature
write("S20.G01.00.004.001", "01");
299,12 → 321,12
complement = complement.substring(0, complement.length() - 1);
}
 
write("S20.G01.00.009.001", complement);
write("S20.G01.00.009.001", normalizeString2(complement));
}
}
 
// Voie
write("S20.G01.00.009.006", voie);
write("S20.G01.00.009.006", normalizeString2(voie));
 
// Code postal
write("S20.G01.00.009.010", rowAdr.getString("CODE_POSTAL"));
339,7 → 361,7
write("S10.G01.00.001.002", nic);
 
// Raison sociale
write("S10.G01.00.002", rowSociete.getString("NOM"));
write("S10.G01.00.002", normalizeString2(rowSociete.getString("NOM")));
 
SQLRow rowAdr = rowSociete.getForeignRow("ID_ADRESSE_COMMON");
String voie = rowAdr.getString("RUE");
357,12 → 379,12
complement = complement.substring(0, complement.length() - 1);
}
 
write("S10.G01.00.003.001", complement);
write("S10.G01.00.003.001", normalizeString2(complement));
}
}
 
// Voie
write("S10.G01.00.003.006", voie);
write("S10.G01.00.003.006", normalizeString2(voie));
 
// TODO Code INSEE, facultatif
// stream.write("S10.G01.00.003.007",voie);
400,7 → 422,7
write("S10.G01.00.010", "02");
 
// Norme utilisée
write("S10.G01.00.011", "V01X10");
write("S10.G01.00.011", "V01X11");
 
// Code table char
write("S10.G01.00.012", "01");
437,8 → 459,13
write("S10.G01.01.005", rowContact.getString("EMAIL"));
 
// Tel
write("S10.G01.01.006", rowContact.getString("TEL_DIRECT"));
String string = rowContact.getString("TEL_DIRECT");
if (string.trim().length() == 0) {
string = rowContact.getString("TEL_STANDARD");
}
 
write("S10.G01.01.006", string);
 
// Fax
write("S10.G01.01.007", rowContact.getString("FAX"));
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/report/N4DSSalarie.java
39,12 → 39,12
 
public class N4DSSalarie {
 
private static DateFormat format = new SimpleDateFormat("ddMMyyyy");
private DateFormat format = new SimpleDateFormat("ddMMyyyy");
private ComptaPropsConfiguration conf = ((ComptaPropsConfiguration) Configuration.getInstance());
private N4DS n4ds;
 
Date d = new Date(114, 0, 1);
Date d2 = new Date(114, 11, 31);
Date d = new Date(116, 0, 1);
Date d2 = new Date(116, 11, 31);
 
DecimalFormat decimalFormat = new DecimalFormat("0.00");
 
82,7 → 82,7
n4ds.write("S45.G01.00.001.001", dateFormat.format(dateArrivee.getTime()));
 
// Code situation familiale
n4ds.write("S45.G01.00.002", siutationFam.getString("CODE"));
n4ds.write("S45.G01.00.002", "0" + (siutationFam.getID() - 1));
 
// Nombre d'enfant à charge
n4ds.write("S45.G01.00.006", rowEtatCivil.getString("NB_ENFANTS"));
181,6 → 181,7
 
private void writeS48(SQLRow rowSalarie) throws IOException {
// Assurance chômage
 
n4ds.write("S48.G10.00.015", "01");
n4ds.write("S48.G10.00.016", "90");
n4ds.write("S48.G10.00.017", "01");
199,11 → 200,15
n4ds.write("S65.G40.05.010", "05");
 
// FIXME durée annuelle = 1200heures
n4ds.write("S65.G40.10.023.001", "01");
n4ds.write("S65.G40.10.023.002", "98");
n4ds.write("S65.G40.10.023.003", "98");
n4ds.write("S65.G40.10.023.004", "03");
n4ds.write("S65.G40.10.023.005", "98");
// n4ds.write("S65.G40.10.023.001", "01");
// n4ds.write("S65.G40.10.023.002", "98");
// n4ds.write("S65.G40.10.023.003", "98");
// if (rowSalarie.getString("PRENOM").equalsIgnoreCase("Vincent")) {
// n4ds.write("S65.G40.10.023.004", "12");
// } else {
// n4ds.write("S65.G40.10.023.004", "03");
// }
// n4ds.write("S65.G40.10.023.005", "98");
 
}
 
252,7 → 257,7
SQLRow rowContrat = rowInfos.getForeignRow("ID_CONTRAT_SALARIE");
 
// Nature de l'emploi
n4ds.write("S40.G10.00.010", rowContrat.getString("NATURE"));
n4ds.write("S40.G10.00.010", normalizeString2(rowContrat.getString("NATURE")));
 
// Catégorie socio
SQLRow rowCodeEmploi = rowContrat.getForeignRow("ID_CODE_EMPLOI");
283,7 → 288,13
 
// Convention collective IDCC
SQLRow rowIDCC = rowInfos.getForeignRow("ID_IDCC");
n4ds.write("S40.G10.05.016", rowIDCC.getString("CODE"));
String idcc = rowIDCC.getString("CODE").trim();
if (idcc.length() <= 3) {
for (int c = 0; c < 4 - idcc.length(); c++) {
idcc = "0" + idcc;
}
}
n4ds.write("S40.G10.05.016", idcc);
// FIXME Classement conventionnel
n4ds.write("S40.G10.05.017", "sans classement conventionnel");
 
306,7 → 317,7
 
/**
* Emploi supérieur antérieur de l'agent sous statut personnel de droit public. S40.G10.15
* */
*/
// TODO secteur public
 
/**
336,6 → 347,7
 
// FIXME Temps de travail
double tempsTravail = 1820.00;
 
n4ds.write("S40.G15.00.003", decimalFormat.format(tempsTravail));
n4ds.write("S40.G15.00.022.001", decimalFormat.format(tempsTravail));
n4ds.write("S40.G15.00.022.002", decimalFormat.format(tempsTravail));
386,23 → 398,27
n4ds.write("S40.G30.04.002", decimalFormat.format(getCSG(rowSalarie)));
 
// final double baseBrute = getBaseBrute(rowSalarie);
final double smicMensuel = 9.53;
final double smicMensuel = 9.61;
if ((baseBrute) < (2.5 * smicMensuel * 12 * 151.6667)) {
 
n4ds.write("S40.G30.40.001", String.valueOf("17344.60"));
n4ds.write("S40.G30.40.001", String.valueOf("17490.00"));
n4ds.write("S40.G30.40.002", decimalFormat.format(baseBrute));
}
 
if ((baseBrute / 12.0 / 151.6667) < (1.6 * smicMensuel)) {
double COEFF_FILLON = (0.281 / 0.6) * ((1.6 * smicMensuel * 12 * 151.6667 / (rowSalarie.getForeign("ID_INFOS_SALARIE_PAYE").getFloat("SALAIRE_MOIS") * 12.0)) - 1.0);
double COEFF_FILLON = (0.2795 / 0.6) * ((1.6 * 17490.0 / (rowSalarie.getForeign("ID_INFOS_SALARIE_PAYE").getFloat("SALAIRE_MOIS") * 12.0)) - 1.0);
n4ds.write("S40.G30.40.003", decimalFormat.format(baseBrute * COEFF_FILLON));
} else {
n4ds.write("S40.G30.40.003", String.valueOf("0.00"));
}
 
n4ds.write("S40.G30.40.004", String.valueOf("0.00"));
if ((baseBrute) < (2.5 * smicMensuel * 12 * 151.6667)) {
n4ds.write("S40.G30.40.005", String.valueOf("17344.60"));
// n4ds.write("S40.G30.40.004", String.valueOf("0.00"));
if ((baseBrute) < (2.5 * 17490.0)) {
n4ds.write("S40.G30.40.005", String.valueOf("17490.00"));
n4ds.write("S40.G30.40.006", decimalFormat.format(baseBrute));
} else {
n4ds.write("S40.G30.40.005", String.valueOf("0.00"));
n4ds.write("S40.G30.40.006", String.valueOf("0.00"));
}
 
// FIXME base brute fiscale
543,11 → 559,11
n4ds.write("S30.G01.00.001", nir);
 
// Nom
n4ds.write("S30.G01.00.002", rowSalarie.getString("NOM"));
n4ds.write("S30.G01.00.002", normalizeString2(rowSalarie.getString("NOM")));
 
// Prenoms
// FIXME: regarder pour les prénoms pas seulement le 1er
n4ds.write("S30.G01.00.003", rowSalarie.getString("PRENOM"));
n4ds.write("S30.G01.00.003", normalizeString2(rowSalarie.getString("PRENOM")));
 
// Code civilite
final SQLRow rowTitre = rowSalarie.getForeignRow("ID_TITRE_PERSONNEL");
577,12 → 593,12
complement = complement.substring(0, complement.length() - 1);
}
 
n4ds.write("S30.G01.00.008.001", complement);
n4ds.write("S30.G01.00.008.001", normalizeString2(complement));
}
}
 
// Numéro, extension, nature et libellé de la voie
n4ds.write("S30.G01.00.008.006", voie);
n4ds.write("S30.G01.00.008.006", normalizeString2(voie));
 
// Code postal
n4ds.write("S30.G01.00.008.010", rowAdr.getString("CODE_POSTAL"));
621,6 → 637,10
s = s.toUpperCase();
String temp = Normalizer.normalize(s, Form.NFC);
temp = temp.replaceAll("-", " ");
temp = temp.replaceAll("é", "e");
temp = temp.replaceAll("è", "e");
temp = temp.replaceAll("ê", "e");
temp = temp.replaceAll(",", "");
return temp.replaceAll("[^\\p{ASCII}]", "");
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/action/ListeDesAyantsDroitsAction.java
New file
0,0 → 1,36
/*
* 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.humanresources.employe.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeDesAyantsDroitsAction extends CreateFrameAbstractAction {
 
public ListeDesAyantsDroitsAction() {
super();
this.putValue(Action.NAME, "Liste des ayants droit");
}
 
public JFrame createFrame() {
ListeAddPanel listeSal = new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("AYANT_DROIT"));
listeSal.getListe().setSQLEditable(false);
return new IListFrame(listeSal);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/action/ListeDesContratsPrevoyanceAction.java
New file
0,0 → 1,36
/*
* 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.humanresources.employe.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeDesContratsPrevoyanceAction extends CreateFrameAbstractAction {
 
public ListeDesContratsPrevoyanceAction() {
super();
this.putValue(Action.NAME, "Liste des contrats prévoyance, mutuelles, formations, ...");
}
 
public JFrame createFrame() {
ListeAddPanel listeSal = new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("CONTRAT_PREVOYANCE"));
listeSal.getListe().setSQLEditable(false);
return new IListFrame(listeSal);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/action/ListeDesCaissesCotisationsAction.java
New file
0,0 → 1,36
/*
* 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.humanresources.employe.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeDesCaissesCotisationsAction extends CreateFrameAbstractAction {
 
public ListeDesCaissesCotisationsAction() {
super();
this.putValue(Action.NAME, "Liste des caisses de cotisations");
}
 
public JFrame createFrame() {
ListeAddPanel listeSal = new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("CAISSE_COTISATION"));
listeSal.getListe().setSQLEditable(false);
return new IListFrame(listeSal);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/png-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/png-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/doc-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/doc-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/ods-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/ods-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/FilePanel.java
New file
0,0 → 1,279
/*
* 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.edm;
 
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.JImage;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
 
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
 
public class FilePanel extends JPanel {
JImage image = null;
 
public static final int WIDTH = 128;
public static final int HEIGHT = 80;
JLabel label;
 
public FilePanel(final SQLRowValues rowAttachment, final AttachmentPanel panelSource) {
final String name = rowAttachment.getString("NAME");
this.setOpaque(true);
this.setLayout(new BorderLayout());
try {
String type = rowAttachment.getString("MIMETYPE");
if (type == null || type.trim().isEmpty() || type.equals("application/octet-stream")) {
image = new JImage(this.getClass().getResource("data-icon.png"));
} else if (type.equals("application/msword")) {
image = new JImage(this.getClass().getResource("doc-icon.png"));
} else if (type.equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) {
image = new JImage(this.getClass().getResource("docx-icon.png"));
} else if (type.equals("application/vnd.oasis.opendocument.text")) {
image = new JImage(this.getClass().getResource("odt-icon.png"));
} else if (type.equals("application/pdf")) {
image = new JImage(this.getClass().getResource("pdf-icon.png"));
} else if (type.equals("image/jpeg")) {
image = new JImage(this.getClass().getResource("jpg-icon.png"));
} else if (type.equals("image/png")) {
image = new JImage(this.getClass().getResource("png-icon.png"));
} else if (type.equals("application/vnd.oasis.opendocument.spreadsheet")) {
image = new JImage(this.getClass().getResource("ods-icon.png"));
} else if (type.equals("application/msexcel") || type.equals("application/vnd.ms-excel") || type.equals("application/xls")) {
image = new JImage(this.getClass().getResource("xls-icon.png"));
} else if (type.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
image = new JImage(this.getClass().getResource("xlsx-icon.png"));
} else {
image = new JImage(this.getClass().getResource("data-icon.png"));
}
image.setOpaque(true);
 
image.setCenterImage(true);
this.add(image, BorderLayout.CENTER);
} catch (Exception e) {
e.printStackTrace();
}
setBackground(Color.WHITE);
label = new JLabel(name, SwingConstants.CENTER);
label.setOpaque(false);
this.add(label, BorderLayout.SOUTH);
 
this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
this.setMinimumSize(new Dimension(WIDTH, HEIGHT));
this.addMouseListener(new MouseAdapter() {
 
@Override
public void mouseExited(MouseEvent e) {
setBackground(Color.WHITE);
}
 
@Override
public void mouseEntered(MouseEvent e) {
setBackground(new Color(230, 240, 255));
}
 
});
final JPopupMenu menu = new JPopupMenu();
final JMenuItem menuItemDelete = new JMenuItem("Supprimer");
menuItemDelete.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
 
int value = JOptionPane.showConfirmDialog(FilePanel.this, "Voulez-vous vraiment supprimer ce fichier ?\n" + rowAttachment.getString("NAME") + "\nFichier orignal : "
+ rowAttachment.getString("FILENAME") + "\nType : " + rowAttachment.getString("MIMETYPE"), "Supprimer le ficher", JOptionPane.YES_NO_OPTION);
 
if (value == JOptionPane.YES_OPTION) {
AttachmentUtils utils = new AttachmentUtils();
try {
utils.deleteFile(rowAttachment);
panelSource.initUI();
} catch (Exception e1) {
ExceptionHandler.handle("Erreur lors de la suppression du fichier!", e1);
}
}
 
}
});
menu.add(menuItemDelete);
final JMenuItem menuItemRename = new JMenuItem("Renommer");
menuItemRename.addActionListener(new ActionListener() {
 
final JTextField text = new JTextField(name);
 
private void stopNameEditing() {
FilePanel.this.invalidate();
FilePanel.this.remove(text);
FilePanel.this.add(label, BorderLayout.SOUTH);
FilePanel.this.validate();
FilePanel.this.repaint();
}
 
public void validText(final SQLRowValues rowAttachment, final String name, final JTextField text) {
try {
String newName = text.getText();
if (newName.trim().isEmpty()) {
newName = name;
}
rowAttachment.put("NAME", newName).commit();
label.setText(newName);
} catch (SQLException e1) {
ExceptionHandler.handle("Erreur lors du renommage du fichier!", e1);
}
}
 
@Override
public void actionPerformed(ActionEvent e) {
final String name = rowAttachment.getString("NAME");
 
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
validText(rowAttachment, name, text);
stopNameEditing();
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
stopNameEditing();
}
}
 
});
text.addFocusListener(new FocusListener() {
 
@Override
public void focusLost(FocusEvent e) {
validText(rowAttachment, name, text);
stopNameEditing();
}
 
@Override
public void focusGained(FocusEvent e) {
}
 
});
text.addMouseListener(new MouseAdapter() {
 
@Override
public void mouseExited(MouseEvent e) {
validText(rowAttachment, name, text);
stopNameEditing();
}
 
});
 
FilePanel.this.invalidate();
FilePanel.this.remove(label);
FilePanel.this.add(text, BorderLayout.SOUTH);
FilePanel.this.validate();
FilePanel.this.repaint();
 
text.grabFocus();
text.setSelectionStart(0);
text.setSelectionEnd(name.length());
}
 
});
menu.add(menuItemRename);
menu.addSeparator();
JMenuItem menuItemProperties = new JMenuItem("Propriétés");
menuItemProperties.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
JFrame f = new JFrame();
f.setTitle("Propriétés de " + rowAttachment.getString("NAME"));
JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
// Name
c.weightx = 0;
p.add(new JLabel("Nom : ", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel(rowAttachment.getString("NAME")), c);
c.gridy++;
// Type
c.gridx = 0;
c.weightx = 0;
p.add(new JLabel("Type : ", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel(rowAttachment.getString("MIMETYPE")), c);
c.gridy++;
// FileName
c.gridx = 0;
c.weightx = 0;
p.add(new JLabel("Fichier original : ", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel(rowAttachment.getString("FILENAME")), c);
c.gridy++;
// Size
c.gridx = 0;
c.weightx = 0;
p.add(new JLabel("Taille : ", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 1;
p.add(new JLabel(rowAttachment.getInt("FILESIZE") + " octets"), c);
 
// Spacer
c.gridx = 1;
c.gridy++;
c.weightx = 1;
JPanel spacer = new JPanel();
spacer.setPreferredSize(new Dimension(300, 1));
p.add(spacer, c);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 
f.setContentPane(p);
f.pack();
f.setResizable(false);
f.setLocationRelativeTo(FilePanel.this);
f.setVisible(true);
 
}
});
menu.add(menuItemProperties);
setComponentPopupMenu(menu);
}
 
@Override
public void setBackground(Color bg) {
super.setBackground(bg);
if (image != null) {
image.setBackground(bg);
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/odt-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/odt-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/xls-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/xls-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentSQLElement.java
New file
0,0 → 1,83
/*
* 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.edm;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
public class AttachmentSQLElement extends ComptaSQLConfElement {
 
public final static String DIRECTORY_PREFS = "EDMdirectory";
 
public AttachmentSQLElement() {
super("ATTACHMENT", "un attachement", "attachements");
 
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("SOURCE_TABLE");
l.add("SOURCE_ID");
l.add("NAME");
l.add("MIMETYPE");
l.add("FILENAME");
l.add("STORAGE_PATH");
l.add("THUMBNAIL");
l.add("THUMBNAIL_WIDTH");
l.add("THUMBNAIL_HEIGHT");
l.add("TAG");
return l;
}
 
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NAME");
return l;
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
public void addViews() {
this.setLayout(new GridBagLayout());
 
final GridBagConstraints c = new DefaultGridBagConstraints();
c.anchor = GridBagConstraints.NORTHEAST;
c.gridwidth = 1;
 
// // Numero
// JLabel labelNumero = new JLabel("Numéro ");
// this.add(labelNumero, c);
//
// JTextField textNumero = new JTextField();
// c.gridx++;
// c.weightx = 1;
// this.add(textNumero, c);
 
// this.addRequiredSQLObject(textNumero, "NUMERO");
}
};
}
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".attachment";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/data-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/data-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/pdf-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/pdf-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentAction.java
New file
0,0 → 1,50
/*
* 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.edm;
 
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.FrameUtil;
 
import java.awt.event.ActionEvent;
 
import javax.swing.AbstractAction;
 
public class AttachmentAction extends PredicateRowAction {
 
public AttachmentAction(final String foreignField) {
super(new AbstractAction("Fichiers liés") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRowAccessor row = IListe.get(e).getSelectedRow();
if (foreignField != null) {
row = row.getForeign(foreignField);
}
AttachmentPanel panel = new AttachmentPanel(row);
// TODO mettre le nom du sqlelement et la ref??? ex : du devis DEV20170101-003
PanelFrame frame = new PanelFrame(panel, "Liste des fichiers liés");
FrameUtil.show(frame);
}
}, true);
 
}
 
public AttachmentAction() {
this(null);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/docx-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/docx-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/xlsx-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/xlsx-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentPanel.java
New file
0,0 → 1,244
/*
* 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.edm;
 
import org.openconcerto.erp.core.common.ui.ScrollablePanel;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.SwingThreadUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
 
public class AttachmentPanel extends JPanel {
 
private final SQLRowAccessor rowSource;
private List<ListDataListener> listeners = new ArrayList<ListDataListener>();
 
public AttachmentPanel(SQLRowAccessor rowSource) {
super();
this.rowSource = rowSource;
this.setLayout(new GridBagLayout());
initUI();
setFocusable(true);
}
 
public void addListener(ListDataListener l) {
this.listeners.add(l);
}
 
public void removeListener(ListDataListener l) {
this.listeners.remove(l);
}
 
public void fireDataChanged() {
for (ListDataListener listDataListener : listeners) {
listDataListener.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, 0));
}
}
 
public void initUI() {
this.invalidate();
this.removeAll();
GridBagConstraints c = new DefaultGridBagConstraints();
 
// Recupération de la liste des fichiers
 
// TODO requete dans un SwingWorker
final SQLTable tableAttachment = rowSource.getTable().getTable("ATTACHMENT");
SQLRowValues rowVals = new SQLRowValues(tableAttachment);
rowVals.putNulls(tableAttachment.getFieldsName());
 
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
Where where = new Where(tableAttachment.getField("SOURCE_TABLE"), "=", this.rowSource.getTable().getName());
where = where.and(new Where(tableAttachment.getField("SOURCE_ID"), "=", this.rowSource.getID()));
// TODO en premier les dossier, puis trier par nom
List<SQLRowValues> attachments = fetcher.fetch(where);
 
// AJout d'un fichier
final JButton addButton = new JButton("Ajouter un fichier");
this.add(addButton, c);
 
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
final JProgressBar progressBar = new JProgressBar(0, 100);
progressBar.setValue(100);
progressBar.setStringPainted(true);
progressBar.setVisible(false);
this.add(progressBar, c);
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy++;
 
addButton.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
 
final FileDialog fd = new FileDialog(frame, "Ajouter un fichier", FileDialog.LOAD);
fd.setVisible(true);
final String fileName = fd.getFile();
if (fileName != null) {
File inFile = new File(fd.getDirectory(), fileName);
AttachmentUtils utils = new AttachmentUtils();
utils.uploadFile(inFile, rowSource);
initUI();
}
}
});
 
ScrollablePanel files = new ScrollablePanel() {
@Override
public Dimension getPreferredSize() {
int w = getSize().width;
int nbPerRow = (w - 5) / (FilePanel.WIDTH + 5);
if (nbPerRow < 1) {
nbPerRow = 1;
}
int nbRow = 1 + (getComponentCount() / nbPerRow);
if (nbRow < 1) {
nbRow = 1;
}
return new Dimension(w, 5 + nbRow * (FilePanel.HEIGHT + 5));
}
 
};
files.setOpaque(true);
files.setBackground(Color.WHITE);
files.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT);
files.setScrollableHeight(ScrollablePanel.ScrollableSizeHint.NONE);
files.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
// Liste des fichiers
for (final SQLRowValues sqlRowValues : attachments) {
 
final FilePanel filePanel = new FilePanel(sqlRowValues, this);
filePanel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) {
Thread t = new Thread() {
@Override
public void run() {
AttachmentUtils utils = new AttachmentUtils();
File f = utils.getFile(sqlRowValues);
if (f == null) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Impossible de récupérer le fichier.", "Erreur", JOptionPane.ERROR_MESSAGE);
}
});
System.err.println("Impossible de récupérer le fichier.");
} else {
try {
FileUtils.openFile(f);
} catch (IOException e1) {
ExceptionHandler.handle("Erreur lors de l'ouverture du fichier.", e1);
}
}
}
};
t.start();
}
}
});
files.add(filePanel);
 
}
c.gridwidth = 2;
c.gridx = 0;
c.gridy++;
c.weightx = 1;
c.weighty = 1;
JScrollPane scroll = new JScrollPane(files);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setMinimumSize(new Dimension((int) (400 * 1.618), 400));
scroll.setPreferredSize(new Dimension((int) (400 * 1.618), 400));
scroll.setBackground(Color.WHITE);
scroll.getViewport().setBackground(Color.WHITE);
this.add(scroll, c);
 
this.validate();
this.repaint();
 
DropTarget dt = new DropTarget() {
@Override
public synchronized void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Transferable t = dtde.getTransferable();
try {
 
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
@SuppressWarnings("unchecked")
List<File> fileList = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
// TODO faire en arriere plan, mettre une jauge à droite du bouton ajouter
// et mettre un bouton d'annulation
AttachmentUtils utils = new AttachmentUtils();
boolean cancelledByUser = false;
for (File f : fileList) {
if (cancelledByUser) {
break;
}
utils.uploadFile(f, rowSource);
}
initUI();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
files.setDropTarget(dt);
scroll.getViewport().setDropTarget(dt);
fireDataChanged();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/AttachmentUtils.java
New file
0,0 → 1,264
/*
* 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.edm;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
import org.openconcerto.erp.storage.StorageEngine;
import org.openconcerto.erp.storage.StorageEngines;
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 org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.sync.SyncClient;
 
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
 
import javax.swing.JOptionPane;
 
import eu.medsea.mimeutil.MimeType;
import eu.medsea.mimeutil.MimeUtil;
 
public class AttachmentUtils {
 
public void uploadFile(File inFile, SQLRowAccessor rowSource) {
try {
 
// Création de la row attachment
SQLRowValues rowValsAttachment = new SQLRowValues(rowSource.getTable().getTable("ATTACHMENT"));
rowValsAttachment.put("SOURCE_TABLE", rowSource.getTable().getName());
rowValsAttachment.put("SOURCE_ID", rowSource.getID());
 
SQLRow rowAttachment = rowValsAttachment.insert();
int id = rowAttachment.getID();
 
String subDir = "EDM" + File.separator + String.valueOf((id / 1000) * 1000);
String fileNameID = String.valueOf(id);
String ext = "";
 
int i = inFile.getName().lastIndexOf('.');
if (i > 0) {
ext = inFile.getName().substring(i + 1);
}
 
final String fileWithIDNAme = fileNameID + "." + ext;
 
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta();
boolean isOnCloud = config.isOnCloud();
 
if (isOnCloud) {
 
String remotePath = subDir;
remotePath = remotePath.replace('\\', '/');
List<StorageEngine> engines = StorageEngines.getInstance().getActiveEngines();
for (StorageEngine storageEngine : engines) {
if (storageEngine.isConfigured() && storageEngine.allowAutoStorage()) {
final String path = remotePath;
try {
storageEngine.connect();
final BufferedInputStream inStream = new BufferedInputStream(new FileInputStream(inFile));
storageEngine.store(inStream, path, fileWithIDNAme, true);
inStream.close();
storageEngine.disconnect();
} catch (IOException e) {
ExceptionHandler.handle("Impossible de sauvegarder le fichier " + inFile.getAbsolutePath() + " vers " + path + "(" + storageEngine + ")", e);
}
// if (storageEngine instanceof CloudStorageEngine) {
// try {
// storageEngine.connect();
// final BufferedInputStream inStream = new BufferedInputStream(new
// FileInputStream(generatedFile));
// storageEngine.store(inStream, path, generatedFile.getName(), true);
// inStream.close();
// storageEngine.disconnect();
// } catch (IOException e) {
// ExceptionHandler.handle("Impossible de sauvegarder le fichier généré " +
// generatedFile.getAbsolutePath() + " vers " + path + "(" + storageEngine +
// ")", e);
// }
// }
}
}
} else {
// Upload File
 
// Get file out
File dirRoot = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(AttachmentSQLElement.DIRECTORY_PREFS);
File storagePathFile = new File(dirRoot, subDir);
storagePathFile.mkdirs();
// TODO CHECK IF FILE EXISTS
FileUtils.copyFile(inFile, new File(storagePathFile, fileWithIDNAme));
 
}
 
// Update rowAttachment
rowValsAttachment = rowAttachment.createEmptyUpdateRow();
 
// Default is without extension
String fileName = inFile.getName();
String name = fileName;
int index = name.lastIndexOf('.');
if (index > 0) {
name = name.substring(0, index);
}
rowValsAttachment.put("NAME", name);
rowValsAttachment.put("SOURCE_TABLE", rowSource.getTable().getName());
rowValsAttachment.put("SOURCE_ID", rowSource.getID());
Collection<MimeType> mimeTypes = MimeUtil.getMimeTypes(inFile);
if (mimeTypes != null && !mimeTypes.isEmpty()) {
final MimeType mimeType = (MimeType) mimeTypes.toArray()[0];
rowValsAttachment.put("MIMETYPE", mimeType.getMediaType() + "/" + mimeType.getSubType());
} else {
rowValsAttachment.put("MIMETYPE", "application/octet-stream");
}
rowValsAttachment.put("FILENAME", fileName);
rowValsAttachment.put("FILESIZE", inFile.length());
rowValsAttachment.put("STORAGE_PATH", subDir);
rowValsAttachment.put("STORAGE_FILENAME", fileWithIDNAme);
// TODO THUMBNAIL
// rowVals.put("THUMBNAIL", );
// rowVals.put("THUMBNAIL_WIDTH", );
// rowVals.put("THUMBNAIL_HEIGHT", );
 
// needed for update count
 
rowValsAttachment.commit();
 
updateAttachmentsCountFromAttachment(rowValsAttachment);
} catch (IOException e1) {
e1.printStackTrace();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
 
public File getFile(SQLRowAccessor rowAttachment) {
 
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta();
boolean isOnCloud = config.isOnCloud();
 
String subDir = rowAttachment.getString("STORAGE_PATH");
String fileName = rowAttachment.getString("STORAGE_FILENAME");
 
String remotePath = config.getSocieteID() + File.separator + subDir;
 
File fTemp;
try {
fTemp = File.createTempFile("edm_", "oc");
} catch (IOException e) {
ExceptionHandler.handle("Impossible de créer le fichier temporaire de réception", e);
return null;
}
File f = new File(fTemp.getParent(), fTemp.getName() + "-dir");
f.mkdirs();
fTemp.delete();
 
if (isOnCloud) {
remotePath = remotePath.replace('\\', '/');
final SyncClient client = new SyncClient("https://" + config.getStorageServer());
 
client.setVerifyHost(false);
 
try {
client.retrieveFile(f, remotePath, fileName, config.getToken());
} catch (Exception e) {
ExceptionHandler.handle("Impossible de récupérer le fichier depuis le cloud", e);
return null;
}
 
} else {
 
// Get file out
File dirRoot = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(AttachmentSQLElement.DIRECTORY_PREFS);
File storagePathFile = new File(dirRoot, subDir);
File fileIn = new File(storagePathFile, fileName);
if (fileIn.exists()) {
final File outFile = new File(f, fileName);
try {
FileUtils.copyFile(fileIn, outFile);
} catch (IOException e) {
ExceptionHandler.handle("Impossible de copier le fichier vers le fichier temporaire de réception", e);
return null;
}
} else {
JOptionPane.showMessageDialog(null, "Le fichier n'existe pas sur le serveur!", "Erreur fichier", JOptionPane.ERROR_MESSAGE);
}
}
final File outFile = new File(f, fileName);
outFile.setReadOnly();
return outFile;
 
}
 
public void deleteFile(SQLRowAccessor rowAttachment) throws SQLException, IllegalStateException {
 
final ComptaPropsConfiguration config = ComptaPropsConfiguration.getInstanceCompta();
boolean isOnCloud = config.isOnCloud();
 
// Delete File
String subDir = rowAttachment.getString("STORAGE_PATH");
String fileName = rowAttachment.getString("STORAGE_FILENAME");
 
String remotePath = config.getSocieteID() + File.separator + subDir;
if (isOnCloud) {
remotePath = remotePath.replace('\\', '/');
// final SyncClient client = new SyncClient("https://" + config.getStorageServer());
//
// client.setVerifyHost(false);
 
// TODO DELETE FILE ON CLOUD OR RENAME?
// client.retrieveFile(f, remotePath, fileName, config.getToken());
} else {
 
File dirRoot = DocumentLocalStorageManager.getInstance().getDocumentOutputDirectory(AttachmentSQLElement.DIRECTORY_PREFS);
File storagePathFile = new File(dirRoot, subDir);
File f = new File(storagePathFile, fileName);
if (f.exists()) {
if (!f.delete()) {
throw new IllegalStateException("Une erreur est survenue lors de la suppression du fichier");
}
}
}
 
// Delete Row
config.getDirectory().getElement(rowAttachment.getTable()).archive(rowAttachment.getID());
updateAttachmentsCountFromAttachment(rowAttachment);
}
 
public void updateAttachmentsCountFromAttachment(SQLRowAccessor rowAttachment) {
SQLTable table = rowAttachment.getTable().getTable(rowAttachment.getString("SOURCE_TABLE"));
SQLRow source = table.getRow(rowAttachment.getInt("SOURCE_ID"));
updateAttachmentsCountFromSource(source);
}
 
public void updateAttachmentsCountFromSource(SQLRow rowSource) {
SQLTable tableSource = rowSource.getTable();
SQLTable tableAtt = rowSource.getTable().getTable("ATTACHMENT");
 
String req = "UPDATE " + tableSource.getSQLName().quote() + " SET " + tableSource.getField("ATTACHMENTS").getQuotedName() + "=(SELECT COUNT(*) FROM " + tableAtt.getSQLName().quote();
req += " WHERE " + tableAtt.getArchiveField().getQuotedName() + "=0 AND " + tableAtt.getField("SOURCE_TABLE").getQuotedName() + "='" + tableSource.getName() + "'";
req += " AND " + tableAtt.getField("SOURCE_ID").getQuotedName() + "=" + rowSource.getID() + ") WHERE " + tableSource.getKey().getQuotedName() + "=" + rowSource.getID();
 
tableSource.getDBSystemRoot().getDataSource().execute(req);
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/jpg-icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/edm/jpg-icon.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/FamilleEcoContributionSQLElement.java
New file
0,0 → 1,76
/*
* 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.element;
 
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class FamilleEcoContributionSQLElement extends ConfSQLElement {
 
public FamilleEcoContributionSQLElement() {
super("FAMILLE_ECO_CONTRIBUTION");
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(2);
list.add("NOM");
return list;
}
 
protected List<String> getComboFields() {
final List<String> list = new ArrayList<String>(2);
list.add("NOM");
return list;
}
 
@Override
public ListMap<String, String> getShowAs() {
ListMap<String, String> map = new ListMap<String, String>();
map.add(null, "NOM");
return map;
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Nom
c.gridx++;
c.weightx = 0;
final JLabel labelNom = new JLabel(getLabelFor("NOM"));
this.add(labelNom, c);
c.gridx++;
c.weightx = 1;
final JTextField textNom = new JTextField();
this.add(textNom, c);
 
this.addRequiredSQLObject(textNom, "NOM");
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReferenceArticleSQLElement.java
16,6 → 16,7
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.sales.product.action.InventairePanel;
import org.openconcerto.erp.core.sales.product.component.ReferenceArticleSQLComponent;
36,7 → 37,6
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
44,9 → 44,8
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ListMap;
55,7 → 54,6
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
111,11 → 109,15
}, true, false);
clone.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(clone);
 
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
}
 
@Override
protected SQLTableModelSourceOnline createTableSource() {
SQLTableModelSourceOnline source = super.createTableSource();
protected synchronized void _initTableSource(final SQLTableModelSource source) {
super._initTableSource(source);
source.init();
final SQLTableModelColumn pvHA1Col = source.getColumn(getTable().getField("PRIX_METRIQUE_HA_1"));
if (pvHA1Col != null) {
164,7 → 166,6
}
});
}
return source;
}
 
protected List<String> getListFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/EcoContributionSQLElement.java
New file
0,0 → 1,115
/*
* 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.element;
 
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ConfSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class EcoContributionSQLElement extends ConfSQLElement {
 
public EcoContributionSQLElement() {
super("ECO_CONTRIBUTION");
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(2);
list.add("ID_FAMILLE_ECO_CONTRIBUTION");
list.add("CODE");
list.add("NOM");
list.add("TAUX");
return list;
}
 
protected List<String> getComboFields() {
final List<String> list = new ArrayList<String>(2);
list.add("CODE");
list.add("NOM");
list.add("TAUX");
return list;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, "CODE", "NOM");
 
}
 
public SQLComponent createComponent() {
return new BaseSQLComponent(this) {
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Code
final JLabel labelCode = new JLabel(getLabelFor("CODE"));
c.weightx = 0;
this.add(labelCode, c);
c.gridx++;
c.weightx = 1;
final JTextField textCode = new JTextField();
this.add(textCode, c);
 
// Nom
c.gridx++;
c.weightx = 0;
final JLabel labelNom = new JLabel(getLabelFor("NOM"));
this.add(labelNom, c);
c.gridx++;
c.weightx = 1;
final JTextField textNom = new JTextField();
this.add(textNom, c);
 
// Famille
c.gridy++;
c.gridx = 0;
c.weightx = 0;
final JLabel labelFamille = new JLabel(getLabelFor("ID_FAMILLE_ECO_CONTRIBUTION"));
this.add(labelFamille, c);
c.gridx++;
c.weightx = 1;
ElementComboBox combo = new ElementComboBox();
this.add(combo, c);
 
// Taux
c.gridx++;
c.weightx = 0;
final JLabel labelTaux = new JLabel(getLabelFor("TAUX"));
this.add(labelTaux, c);
c.gridx++;
c.weightx = 1;
final JTextField textTaux = new JTextField();
this.add(textTaux, c);
 
this.addRequiredSQLObject(textTaux, "TAUX");
this.addSQLObject(combo, "ID_FAMILLE_ECO_CONTRIBUTION");
this.addRequiredSQLObject(textNom, "NOM");
this.addRequiredSQLObject(textCode, "CODE");
}
};
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReliquatSQLElement.java
13,16 → 13,6
package org.openconcerto.erp.core.sales.product.element;
 
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 org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.sales.invoice.ui.FactureAffacturerTable;
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent;
37,6 → 27,16
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
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;
 
public class ReliquatSQLElement extends ComptaSQLConfElement {
 
private final String tableBonName;
73,7 → 73,7
for (SQLRowValues rowVals : rows) {
try {
SQLRowValues upRowVals = rowVals.createEmptyUpdateRow();
upRowVals.put("ID_BON_RECEPTION", id);
upRowVals.put("ID_" + tableBonName, id);
upRowVals.update();
} catch (SQLException exn) {
exn.printStackTrace();
91,8 → 91,13
}
});
 
BonReceptionSQLComponent comp = (BonReceptionSQLComponent) frame.getSQLComponent();
comp.loadFromReliquat(rows);
SQLComponent comp = (SQLComponent) frame.getSQLComponent();
if (comp instanceof BonReceptionSQLComponent) {
((BonReceptionSQLComponent) comp).loadFromReliquat(rows);
} else {
// ((BonDeLivraisonSQLComponent) comp).loadFromReliquat(rows);
 
}
frame.setVisible(true);
 
}
107,7 → 112,6
 
@Override
protected String getParentFFName() {
 
return "ID_" + this.tableBonName;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/ListeDesArticlesAction.java
81,8 → 81,7
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(this.sqlTableArticle);
final FamilleArticlePanel panelFam = new FamilleArticlePanel(elt.getForeignElement("ID_FAMILLE_ARTICLE"));
 
final SQLTableModelSourceOnline createTableSource = elt.initTableSource(elt.getTableSource(true));
createTableSource.init();
final SQLTableModelSourceOnline createTableSource = elt.createTableSource();
 
SQLTableModelColumn colStock;
if (elt.getTable().getDBRoot().contains("ARTICLE_PRIX_REVIENT")) {
139,7 → 138,7
c.gridx++;
panel.add(buttonSuppr, c);
 
final JFrame frame = new PanelFrame(panel, "Suppression d'ecritures");
final JFrame frame = new PanelFrame(panel, "Suppression d'article");
buttonObs.addActionListener(new ActionListener() {
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/ListeEcoContributionAction.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.sales.product.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
 
import javax.swing.Action;
import javax.swing.JFrame;
 
public class ListeEcoContributionAction extends CreateFrameAbstractAction {
 
public ListeEcoContributionAction() {
super();
this.putValue(Action.NAME, "Barème éco-contribution");
}
 
public JFrame createFrame() {
return new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("ECO_CONTRIBUTION")));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/QtyToDeliverRowValuesRenderer.java
New file
0,0 → 1,73
/*
* 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.erp.core.common.ui.DeviseNiceTableCellRenderer;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.table.AlternateTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
 
import java.awt.Color;
import java.awt.Component;
 
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
 
public class QtyToDeliverRowValuesRenderer extends DeviseNiceTableCellRenderer {
 
// Red
public static final Color red = new Color(255, 31, 52);
public static final Color redLightGrey = new Color(240, 65, 85);
 
// Orange
public final static Color orange = new Color(243, 125, 75);
public final static Color orangeGrey = new Color(222, 107, 47);
 
// Blue
public final static Color light = new Color(232, 238, 250);
public final static Color lightGrey = new Color(211, 220, 222);
 
// Black
public final static Color lightBlack = new Color(192, 192, 192);
public final static Color lightBlackGrey = new Color(155, 155, 155);
 
public QtyToDeliverRowValuesRenderer() {
AlternateTableCellRenderer.setBGColorMap(this, CollectionUtils.createMap(lightBlack, lightBlackGrey, red, redLightGrey, orange, orangeGrey));
}
 
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
 
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
 
if (table instanceof RowValuesTable) {
 
((JLabel) comp).setHorizontalAlignment(SwingConstants.RIGHT);
RowValuesTableModel model = ((RowValuesTable) table).getRowValuesTableModel();
SQLRowValues rowVals = model.getRowValuesAt(row);
 
Number qte = (Number) rowVals.getObject("QTE");
Number qteL = (Number) rowVals.getObject("QTE_LIVREE");
if (qte != null && qteL != null) {
if (qte.intValue() <= 0) {
comp.setBackground(red);
}
}
}
return comp;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/DeliveredQtyRowValuesRenderer.java
New file
0,0 → 1,77
/*
* 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.erp.core.common.ui.DeviseNiceTableCellRenderer;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.table.AlternateTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
 
import java.awt.Color;
import java.awt.Component;
 
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
 
public class DeliveredQtyRowValuesRenderer extends DeviseNiceTableCellRenderer {
 
// Red
public static final Color red = new Color(255, 31, 52);
public static final Color redLightGrey = new Color(240, 65, 85);
 
// Orange
public final static Color orange = new Color(243, 125, 75);
public final static Color orangeGrey = new Color(222, 107, 47);
 
// Blue
public final static Color light = new Color(232, 238, 250);
public final static Color lightGrey = new Color(211, 220, 222);
 
// Black
public final static Color lightBlack = new Color(192, 192, 192);
public final static Color lightBlackGrey = new Color(155, 155, 155);
 
public DeliveredQtyRowValuesRenderer() {
AlternateTableCellRenderer.setBGColorMap(this, CollectionUtils.createMap(lightBlack, lightBlackGrey, red, redLightGrey, orange, orangeGrey));
}
 
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
 
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
 
if (table instanceof RowValuesTable) {
 
((JLabel) comp).setHorizontalAlignment(SwingConstants.RIGHT);
RowValuesTableModel model = ((RowValuesTable) table).getRowValuesTableModel();
SQLRowValues rowVals = model.getRowValuesAt(row);
 
Number qte = (Number) rowVals.getObject("QTE");
Number qteL = (Number) rowVals.getObject("QTE_LIVREE");
if (qte != null && qteL != null) {
if (qte.intValue() < qteL.intValue()) {
comp.setBackground(red);
} else if (qteL.intValue() <= 0) {
comp.setBackground(lightBlack);
} else if (qteL.intValue() != qte.intValue()) {
comp.setBackground(orange);
}
}
}
return comp;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/ProductItemListTable.java
59,7 → 59,7
 
final List<SQLTableElement> list = new Vector<SQLTableElement>();
 
SQLTableElement product = new SQLTableElement(productItemTable.getField("ID_ARTICLE"));
final SQLTableElement product = new SQLTableElement(productItemTable.getField("ID_ARTICLE"));
list.add(product);
// Quantité
final SQLTableElement q = new SQLTableElement(productItemTable.getField("QTE"), Integer.class);
75,6 → 75,8
 
@Override
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
if (source.equals(product)) {
 
final Object object = row.getObject("ID_ARTICLE");
if (object == null) {
return null;
81,7 → 83,10
}
SQLRowAccessor r = row.getForeign("ID_ARTICLE");
return r.getForeignIDNumber("ID_UNITE_VENTE");
} else {
return row.getObject("ID_UNITE_VENTE");
}
}
 
});
product.addModificationListener(unit);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/ProductQtyPriceListTable.java
121,7 → 121,8
 
// Prix de vente HT de la métrique 1
final SQLField field = e.getTable().getField("PRIX_METRIQUE_VT_1");
final DeviseNumericHTConvertorCellEditor editorPVHT = new DeviseNumericHTConvertorCellEditor(field);
// final DeviseNumericHTConvertorCellEditor editorPVHT = new
// DeviseNumericHTConvertorCellEditor(field);
this.tableElementVenteHT = new SQLTableElement(field, BigDecimal.class);
list.add(tableElementVenteHT);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/model/ProductHelper.java
137,16 → 137,21
public Map<Long, BigDecimal> getUnitCost(Map<Long, Integer> productQties, TypePrice type) {
final Map<Long, BigDecimal> result = new HashMap<Long, BigDecimal>();
 
String fieldPrice = (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR ? "PRIX_ACHAT_DEVISE_F" : "PRIX");
String fieldDate = (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR ? "DATE_PRIX" : "DATE");
String fieldPrice = (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR || type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP ? "PRIX_ACHAT_DEVISE_F" : "PRIX");
String fieldDate = (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR || type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP ? "DATE_PRIX" : "DATE");
 
// get all costs
final SQLTable costTable = root.getTable(type.name());
final SQLTable costTable = root.getTable(type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP ? "ARTICLE_TARIF_FOURNISSEUR" : type.name());
final SQLSelect sel = new SQLSelect();
sel.addSelect(costTable.getKey());
sel.addSelect(costTable.getField("ID_ARTICLE"));
sel.addSelect(costTable.getField("QTE"));
sel.addSelect(costTable.getField(fieldPrice));
if (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP) {
for (SupplierPriceField f : SupplierPriceField.values()) {
sel.addSelect(costTable.getField(f.name()));
}
}
sel.addSelect(costTable.getField(fieldDate));
sel.setWhere(new Where(costTable.getField("ID_ARTICLE"), true, productQties.keySet()));
sel.addFieldOrder(costTable.getField("QTE"));
158,6 → 163,9
System.out.println(sqlRow.getID() + ":" + sqlRow.getAllValues());
}
final int size = l.size();
if (size == 0 && type == TypePrice.ARTICLE_PRIX_REVIENT) {
return getUnitCost(productQties, TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP);
} else {
for (Long id : productQties.keySet()) {
BigDecimal cost = BigDecimal.ZERO;
final int qty = productQties.get(id);
167,11 → 175,19
// stop when the max qty is found
if (row.getLong("QTE") > qty) {
if (cost == null) {
if (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP) {
cost = getEnumPrice(row, SupplierPriceField.COEF_TRANSPORT_SIEGE);
} else {
cost = row.getBigDecimal(fieldPrice);
}
}
break;
}
if (type == TypePrice.ARTICLE_TARIF_FOURNISSEUR_DDP) {
cost = getEnumPrice(row, SupplierPriceField.COEF_TRANSPORT_SIEGE);
} else {
cost = row.getBigDecimal(fieldPrice);
}
 
}
}
183,6 → 199,7
}
return result;
}
}
 
/**
*
210,8 → 227,12
final Map<Integer, BigDecimal> qtyParent = new HashMap<Integer, BigDecimal>();
for (ProductComponent p : items) {
parentsArticleIDs.add(p.getProduct().getID());
qtyParent.put(p.getProduct().getID(), p.getQty());
BigDecimal qty = BigDecimal.ZERO;
if (qtyParent.get(p.getProduct().getID()) != null) {
qty = qtyParent.get(p.getProduct().getID());
}
qtyParent.put(p.getProduct().getID(), qty.add(p.getQty()));
}
 
// get all childs
final SQLTable costTable = root.getTable("ARTICLE_ELEMENT");
240,8 → 261,9
if (childs.size() > 0) {
 
for (SQLRowValues childRowValues : childs) {
final SQLRowAccessor foreignArticleParent = childRowValues.getForeign("ID_ARTICLE_PARENT");
 
final SQLRowAccessor foreignArticleParent = childRowValues.getForeign("ID_ARTICLE_PARENT");
if (!childRowValues.isForeignEmpty("ID_ARTICLE") && childRowValues.getForeign("ID_ARTICLE") != null) {
ProductComponent childComponent = ProductComponent.createFrom(childRowValues);
// Test pour éviter les boucles dans les boms
if (!ancestors.contains(childComponent.getProduct().getID())) {
260,6 → 282,7
}
}
}
}
 
// Recherche si un kit est présent parmis les articles
final List<ProductComponent> bomFromChilds = getChildWithQtyFrom(new ArrayList(result), ancestors);
334,7 → 357,7
}
 
public enum TypePrice {
ARTICLE_PRIX_REVIENT, ARTICLE_PRIX_MIN_VENTE, ARTICLE_PRIX_PUBLIC, ARTICLE_TARIF_FOURNISSEUR
ARTICLE_PRIX_REVIENT, ARTICLE_PRIX_MIN_VENTE, ARTICLE_PRIX_PUBLIC, ARTICLE_TARIF_FOURNISSEUR, ARTICLE_TARIF_FOURNISSEUR_DDP
};
 
public BigDecimal getBomPriceForQuantity(int qty, Collection<? extends SQLRowAccessor> rowValuesProductItems, TypePrice type) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/component/ReferenceArticleSQLComponent.java
42,6 → 42,7
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FormLayouter;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.DecimalUtils;
399,7 → 400,32
panel.setOpaque(false);
GridBagConstraints c = new DefaultGridBagConstraints();
 
c.weightx = 0;
JLabel labelEco = new JLabel(getLabelFor("ID_ECO_CONTRIBUTION"));
c.fill = GridBagConstraints.BOTH;
panel.add(labelEco, c);
c.weightx = 1;
c.gridx++;
ElementComboBox box = new ElementComboBox();
panel.add(box, c);
 
c.weightx = 0;
c.gridy++;
c.gridx = 0;
JLabel labelTaxeCompl = new JLabel(getLabelFor("ID_TAXE_COMPLEMENTAIRE"));
c.fill = GridBagConstraints.BOTH;
panel.add(labelTaxeCompl, c);
c.weightx = 1;
c.gridx++;
ElementComboBox boxTaxeCompl = new ElementComboBox();
panel.add(boxTaxeCompl, c);
 
c.gridy++;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
TitledSeparator sep = new TitledSeparator(getLabelFor("INFOS"));
panel.add(sep, c);
c.gridy++;
c.weighty = 1;
ITextArea infos = new ITextArea();
c.fill = GridBagConstraints.BOTH;
406,7 → 432,8
panel.add(infos, c);
 
this.addSQLObject(infos, "INFOS");
 
this.addSQLObject(box, "ID_ECO_CONTRIBUTION");
this.addSQLObject(boxTaxeCompl, "ID_TAXE_COMPLEMENTAIRE");
return panel;
}
 
537,7 → 564,7
panel.setOpaque(false);
GridBagConstraints c = new DefaultGridBagConstraints();
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
boolean gestionStockMin = prefs.getBoolean("ArticleStockMin", true);
boolean gestionStockMin = prefs.getBoolean(GestionArticleGlobalPreferencePanel.WARNING_STOCK_MIN, true);
c.gridx = 0;
c.gridy++;
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/toolbar_menu.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/toolbar_list.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/calculator_selected.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/toolbar.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/cheque.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/cb.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/especes.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/calculator.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/toolbar_retour.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/POSDisplay.java
New file
0,0 → 1,22
/*
* 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.ui;
 
import java.io.IOException;
 
public abstract class POSDisplay {
 
public abstract void setMessage(String line1, String line2) throws Exception, IOException;
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/POSGlassPane.java
New file
0,0 → 1,183
/*
* 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.ui;
 
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
 
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
 
public class POSGlassPane extends JPanel implements MouseListener, MouseMotionListener, FocusListener {
 
JMenuBar menuBar;
 
// Container contentPane;
 
boolean inDrag = false;
 
// trigger for redispatching (allows external control)
boolean needToRedispatch = false;
 
POSGlassPane(JPanel p, int x, int y) {
this.setLayout(null);
p.setSize(p.getPreferredSize());
p.setLocation(x, y);
this.add(p);
addMouseListener(this);
addMouseMotionListener(this);
addFocusListener(this);
}
 
public void setVisible(boolean v) {
// Make sure we grab the focus so that key events don't go astray.
if (v)
requestFocus();
super.setVisible(v);
}
 
// Once we have focus, keep it if we're visible
public void focusLost(FocusEvent fe) {
if (isVisible())
requestFocus();
}
 
public void focusGained(FocusEvent fe) {
}
 
// We only need to redispatch if we're not visible, but having full control
// over this might prove handy.
public void setNeedToRedispatch(boolean need) {
needToRedispatch = need;
}
 
/*
* (Based on code from the Java Tutorial) We must forward at least the mouse drags that started
* with mouse presses over the check box. Otherwise, when the user presses the check box then
* drags off, the check box isn't disarmed -- it keeps its dark gray background or whatever its
* L&F uses to indicate that the button is currently being pressed.
*/
public void mouseDragged(MouseEvent e) {
if (needToRedispatch)
redispatchMouseEvent(e);
}
 
public void mouseMoved(MouseEvent e) {
if (needToRedispatch)
redispatchMouseEvent(e);
}
 
public void mouseClicked(MouseEvent e) {
if (needToRedispatch)
redispatchMouseEvent(e);
}
 
public void mouseEntered(MouseEvent e) {
if (needToRedispatch)
redispatchMouseEvent(e);
}
 
public void mouseExited(MouseEvent e) {
if (needToRedispatch)
redispatchMouseEvent(e);
}
 
public void mousePressed(MouseEvent e) {
if (needToRedispatch)
redispatchMouseEvent(e);
}
 
public void mouseReleased(MouseEvent e) {
if (needToRedispatch) {
redispatchMouseEvent(e);
inDrag = false;
}
}
 
private void redispatchMouseEvent(MouseEvent e) {
boolean inButton = false;
boolean inMenuBar = false;
Point glassPanePoint = e.getPoint();
Component component = null;
Container container = null;
Point containerPoint = SwingUtilities.convertPoint(this, glassPanePoint, null);
int eventID = e.getID();
 
if (containerPoint.y < 0) {
inMenuBar = true;
container = menuBar;
containerPoint = SwingUtilities.convertPoint(this, glassPanePoint, menuBar);
testForDrag(eventID);
}
 
// XXX: If the event is from a component in a popped-up menu,
// XXX: then the container should probably be the menu's
// XXX: JPopupMenu, and containerPoint should be adjusted
// XXX: accordingly.
component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);
 
if (component == null) {
return;
} else {
inButton = true;
testForDrag(eventID);
}
 
if (inMenuBar || inButton || inDrag) {
Point componentPoint = SwingUtilities.convertPoint(this, glassPanePoint, component);
component.dispatchEvent(new MouseEvent(component, eventID, e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger()));
}
}
 
private void testForDrag(int eventID) {
if (eventID == MouseEvent.MOUSE_PRESSED) {
inDrag = true;
}
}
 
@Override
protected void paintComponent(Graphics g) {
// enables anti-aliasing
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 
// gets the current clipping area
Rectangle clip = g.getClipBounds();
 
// sets a 65% translucent composite
AlphaComposite alpha = AlphaComposite.SrcOver.derive(0.65f);
Composite composite = g2.getComposite();
g2.setComposite(alpha);
 
// fills the background
g2.setColor(Color.BLACK);
g2.fillRect(clip.x, clip.y, clip.width, clip.height);
 
g2.setComposite(composite);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseControler.java
19,11 → 19,13
import org.openconcerto.erp.core.sales.pos.io.ESCSerialDisplay;
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.Client;
import org.openconcerto.erp.core.sales.pos.model.Paiement;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.utils.Pair;
 
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar;
38,6 → 40,7
private Article articleSelected;
private Paiement paiementSelected;
private Ticket t;
private Client client = Client.NONE;
private List<CaisseListener> listeners = new ArrayList<CaisseListener>();
 
private final BarcodeReader r;
45,7 → 48,7
private Paiement p2 = new Paiement(Paiement.CB);
private Paiement p3 = new Paiement(Paiement.CHEQUE);
private final CaisseFrame caisseFrame;
private final ESCSerialDisplay lcd;
private final POSDisplay lcd;
 
public CaisseControler(CaisseFrame caisseFrame) {
this.caisseFrame = caisseFrame;
58,7 → 61,11
this.r = new BarcodeReader(POSConfiguration.getInstance().getScanDelay());
this.r.start();
this.r.addBarcodeListener(this);
lcd = new ESCSerialDisplay(POSConfiguration.getInstance().getLCDSerialPort());
if (POSConfiguration.getInstance().getLCDType().equals("serial")) {
lcd = new ESCSerialDisplay(POSConfiguration.getInstance().getLCDPort());
} else {
lcd = new PrinterPOSDisplay(POSConfiguration.getInstance().getLCDPort());
}
this.setLCDDefaultDisplay(0);
}
 
96,6 → 103,24
this.listeners.add(l);
}
 
// Customer
public void setClient(Client client) {
if (client == null) {
throw new IllegalArgumentException("Customer cannot be null");
}
this.client = client;
this.t.setClient(client);
fire();
}
 
public boolean isClientDefined() {
return this.client != Client.NONE;
}
 
public Client getClient() {
return client;
}
 
// Articles
void addArticle(Article a) {
this.t.addArticle(a);
136,6 → 161,12
}
 
public void setPaiementValue(Paiement p, int v) {
if (p.getType() == Paiement.SOLDE) {
int soldeInCents = getClient().getSolde().movePointRight(2).intValue();
if (v > soldeInCents) {
v = soldeInCents;
}
}
p.setMontantInCents(v);
fire();
this.setLCD("Paiement " + p.getTypeAsString().replace('è', 'e').replace('é', 'e'), TicketCellRenderer.centsToString(p.getMontantInCents()), 0);
173,6 → 204,7
 
@Override
public void barcodeRead(String code) {
System.err.println("CaisseControler.barcodeRead() " + code);
if (code.equalsIgnoreCase("especes")) {
autoFillPaiement(this.p1);
 
216,8 → 248,14
}
 
void autoFillPaiement(Paiement p) {
int montant = p.getMontantInCents();
p.setMontantInCents(getTotal() - getPaidTotal() + montant);
int nouveauMontant = getTotal() - getPaidTotal() + p.getMontantInCents();
if (p.getType() == Paiement.SOLDE) {
int soldeInCents = getClient().getSolde().movePointRight(2).intValue();
if (nouveauMontant > soldeInCents) {
nouveauMontant = soldeInCents;
}
}
p.setMontantInCents(nouveauMontant);
setPaiementSelected(p);
this.setLCD("Paiement " + p.getTypeAsString(), TicketCellRenderer.centsToString(p.getMontantInCents()), 0);
this.setLCDDefaultDisplay(3);
274,7 → 312,7
this.t.addPaiement(this.p3);
this.setPaiementSelected(null);
this.setArticleSelected(null);
 
client = Client.NONE;
}
}
}
306,7 → 344,7
}
 
public void switchListMode() {
caisseFrame.t.switchListMode();
caisseFrame.mainPanel.switchListMode();
 
}
 
373,4 → 411,34
}
 
}
 
public void setArticleHT(Article article, BigDecimal ht) {
Article existingArticle = null;
final List<Pair<Article, Integer>> articles = t.getArticles();
for (Pair<Article, Integer> pair : articles) {
final Article a = pair.getFirst();
if (a.getId() == article.getId()) {
if (article.getPriceWithoutTax().doubleValue() == a.getPriceWithoutTax().doubleValue()) {
existingArticle = a;
break;
}
}
}
if (existingArticle != null) {
existingArticle.updatePriceWithoutTax(ht);
fire();
}
}
 
public void openPriceEditor(Article article) {
caisseFrame.showPriceEditor(article, this);
}
 
public void enableBarcodeReader() {
this.r.setEnabled(true);
}
 
public void disableBarcodeReader() {
this.r.setEnabled(false);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/POSLabel.java
New file
0,0 → 1,26
/*
* 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.ui;
 
import java.awt.Font;
 
import javax.swing.JLabel;
 
public class POSLabel extends JLabel {
public POSLabel(String text) {
super(text);
final Font f = getFont().deriveFont(20f);
this.setFont(f);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/SoldePaiementPanel.java
New file
0,0 → 1,244
/*
* 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.ui;
 
import org.openconcerto.erp.core.sales.pos.model.Paiement;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.ParseException;
import java.util.Locale;
 
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.text.NumberFormatter;
 
public class SoldePaiementPanel extends JPanel {
 
private JFormattedTextField textField;
private JRadioButton bCB;
private JRadioButton bCheque;
private JRadioButton bEspece;
 
public SoldePaiementPanel() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
 
// Label
c.insets = new Insets(14, 5, 5, 5);
this.add(new POSLabel("Montant"), c);
 
// Textfield
final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("##0.00", new DecimalFormatSymbols(Locale.ENGLISH)));
formatter.setAllowsInvalid(false);
textField = new JFormattedTextField(formatter);
textField.setHorizontalAlignment(JTextField.RIGHT);
textField.setFont(textField.getFont().deriveFont(20f));
textField.setMargin(new Insets(5, 5, 5, 5));
textField.setPreferredSize(new Dimension(100, textField.getPreferredSize().height));
c.gridx++;
c.insets = new Insets(14, 5, 5, 0);
this.add(textField, c);
// Reset
c.gridx++;
c.insets = new Insets(14, 0, 5, 5);
final JButton b = new JButton("C");
b.setBackground(CaissePanel.LIGHT_BLUE);
b.setForeground(Color.WHITE);
b.setFont(b.getFont().deriveFont(18f));
b.setFocusPainted(false);
b.setPreferredSize(new Dimension(64, 40));
b.setFocusable(false);
b.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
textField.setValue(null);
 
}
});
this.add(b, c);
 
c.gridx++;
//
c.gridwidth = 3;
c.gridx = 1;
c.gridy++;
c.weighty = 1;
bCB = createRadioButton("CB");
bCB.setFocusable(false);
bCB.setSelected(true);
this.add(bCB, c);
c.gridy++;
bCheque = createRadioButton("Chèque");
bCheque.setFocusable(false);
this.add(bCheque, c);
c.gridy++;
bEspece = createRadioButton("Espèce");
bEspece.setFocusable(false);
this.add(bEspece, c);
ButtonGroup g = new ButtonGroup();
g.add(bCB);
g.add(bCheque);
g.add(bEspece);
// Calculator
c.gridx = 4;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 4;
c.insets = new Insets(0, 0, 0, 0);
this.add(createCalculatorPanel(), c);
this.setBackground(Color.WHITE);
}
 
private JRadioButton createRadioButton(String string) {
JRadioButton b = new JRadioButton(string);
b.setFont(b.getFont().deriveFont(20f));
b.setOpaque(false);
b.setFocusable(false);
return b;
}
 
JPanel createCalculatorPanel() {
JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
JButton b7 = createButton("7");
p.add(b7, c);
c.gridx++;
JButton b8 = createButton("8");
p.add(b8, c);
c.gridx++;
JButton b9 = createButton("9");
p.add(b9, c);
//
c.gridx = 0;
c.gridy++;
JButton b4 = createButton("4");
p.add(b4, c);
c.gridx++;
JButton b5 = createButton("5");
p.add(b5, c);
c.gridx++;
JButton b6 = createButton("6");
p.add(b6, c);
 
//
c.gridx = 0;
c.gridy++;
JButton b1 = createButton("1");
p.add(b1, c);
c.gridx++;
JButton b2 = createButton("2");
p.add(b2, c);
c.gridx++;
JButton b3 = createButton("3");
p.add(b3, c);
//
c.gridx = 0;
c.gridy++;
JButton b0 = createButton("0");
c.gridwidth = 2;
p.add(b0, c);
c.gridx += 2;
c.gridwidth = 1;
JButton bPoint = createButton(".");
 
p.add(bPoint, c);
p.setBackground(CaissePanel.LIGHT_BLUE);
p.setFocusable(false);
return p;
}
 
private JButton createButton(final String string) {
final JButton b = new JButton(string);
b.setBackground(CaissePanel.DARK_BLUE);
b.setForeground(Color.WHITE);
b.setFont(b.getFont().deriveFont(20f));
b.setBorderPainted(false);
// b.setContentAreaFilled(false);
b.setFocusPainted(false);
b.setPreferredSize(new Dimension(64, 64));
b.setFocusable(false);
b.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final char c = string.charAt(0);
textField.grabFocus();
textField.dispatchEvent(new KeyEvent(textField, KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, c));
 
}
});
return b;
}
 
public BigDecimal getAmount() {
try {
this.textField.commitEdit();
BigDecimal m = new BigDecimal(((Number) this.textField.getValue()).doubleValue());
return m;
} catch (ParseException e) {
e.printStackTrace();
return null;
}
 
}
 
public int getPaymentType() {
if (bCB.isSelected()) {
return Paiement.CB;
}
if (bCheque.isSelected()) {
return Paiement.CHEQUE;
}
if (bEspece.isSelected()) {
return Paiement.ESPECES;
}
throw new IllegalStateException("Unable to compute payment type");
}
 
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
final JFrame jFrame = new JFrame();
jFrame.setUndecorated(true);
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setContentPane(new SoldePaiementPanel());
jFrame.pack();
 
jFrame.setVisible(true);
}
});
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/POSRadioButton.java
New file
0,0 → 1,37
/*
* 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.ui;
 
import java.awt.Font;
 
import javax.swing.Icon;
import javax.swing.JRadioButton;
 
public class POSRadioButton extends JRadioButton {
public POSRadioButton(String text, Icon icon, boolean selected) {
super(text, icon, selected);
customize();
}
 
public POSRadioButton(String text) {
super(text);
customize();
}
 
public void customize() {
final Font f = getFont().deriveFont(20f);
this.setFont(f);
this.setOpaque(false);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseMenuPanel.java
13,36 → 13,25
package org.openconcerto.erp.core.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.geom.Rectangle2D;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Set;
 
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
public class CaisseMenuPanel extends JPanel implements ListSelectionListener {
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.JImage;
 
private JList l;
public class CaisseMenuPanel extends JPanel {
 
private CaisseFrame frame;
private Image bg;
 
CaisseMenuPanel(CaisseFrame caisseFrame) {
this.frame = caisseFrame;
49,66 → 38,61
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.NONE;
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.weightx = 1;
c.weighty = 1;
c.weightx = 0;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
final Font font = new Font("Arial", Font.PLAIN, 46);
l = new JList(new String[] { "Retour", "", "Liste des tickets", "Clôturer", "", "Fermer le logiciel", "" });
l.setCellRenderer(new ListCellRenderer() {
c.insets = new Insets(20, 20, 30, 20);
final JImage image = new JImage(ComptaBasePropsConfiguration.class.getResource("logo.png"));
this.add(image, c);
c.gridx++;
 
final POSButton bTickets = new POSButton("Liste des tickets");
this.add(bTickets, c);
c.gridy++;
final POSButton bCloture = new POSButton("Clôturer");
this.add(bCloture, c);
c.gridy++;
c.insets = new Insets(20, 20, 20, 20);
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
final POSButton bQuit = new POSButton("Quitter");
bQuit.setBackground(Color.decode("#AD1457"));
this.add(bQuit, c);
// Listeners
bTickets.addActionListener(new ActionListener() {
 
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel l = new JLabel(value.toString()) {
@Override
public void paint(Graphics g) {
 
super.paint(g);
 
g.setColor(Color.LIGHT_GRAY);
g.drawLine(0, 0, this.getWidth(), 0);
public void actionPerformed(ActionEvent e) {
try {
frame.showTickets(null);
} catch (Exception ex) {
ExceptionHandler.handle("Erreur", ex);
}
};
l.setFont(font);
return l;
}
 
});
l.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
l.getSelectionModel().addListSelectionListener(this);
bCloture.addActionListener(new ActionListener() {
 
l.setFixedCellHeight(80);
this.add(l, c);
bg = new ImageIcon(TicketPanel.class.getResource("toolbar.png")).getImage();
setFont(new Font("Arial", Font.BOLD, 24));
}
 
@Override
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting()) {
return;
}
public void actionPerformed(ActionEvent e) {
try {
final int selectedIndex = l.getSelectedIndex();
switch (selectedIndex) {
case 0:
// Retour
frame.showCaisse();
break;
case 2:
// Liste des tickets
frame.showTickets(null);
break;
case 3:
// Clôture
 
frame.getControler().setLCD("Cloture", "En cours...", 0);
POSConfiguration.getInstance().commitAll(POSConfiguration.getInstance().allTickets());
frame.getControler().setLCD("Cloture", "Terminee", 0);
break;
case 5:
} catch (Exception ex) {
ExceptionHandler.handle("Erreur", ex);
}
}
});
bQuit.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
try {
// Fermeture
frame.getControler().setLCD(" CAISSE FERMEE ", "", 0);
frame.dispose();
123,30 → 107,12
System.err.println(thread.getName() + " " + thread.getId() + " not daemon");
}
}
break;
default:
break;
}
} catch (Exception ex) {
ExceptionHandler.handle("Erreur", ex);
}
}
});
 
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
final int w = this.getWidth();
int imWidth = bg.getWidth(null);
for (int x = 0; x <= w; x += imWidth) {
g.drawImage(bg, x, 0, null);
}
 
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(new Color(250, 250, 250));
String str = "Menu Principal";
 
Rectangle2D r = g.getFontMetrics().getStringBounds(str, g);
int x = (int) (this.getWidth() - r.getWidth()) / 2;
g.drawString(str, x, 30);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ListeDesClientsPanel.java
New file
0,0 → 1,145
/*
* 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.ui;
 
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.RoundingMode;
import java.util.Vector;
 
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.erp.core.sales.pos.model.Client;
import org.openconcerto.ui.DefaultListModel;
import org.openconcerto.ui.touch.ScrollableList;
 
public class ListeDesClientsPanel extends JPanel {
 
private ScrollableList clientList;
private DefaultListModel ticketLlistModel;
 
ListeDesClientsPanel(final CaisseFrame caisseFrame) {
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.CENTER;
c.weightx = 1;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
 
final StatusBar p = new StatusBar();
p.setTitle("Liste des clients");
p.setLayout(new FlowLayout(FlowLayout.RIGHT));
final POSButton bBack = new POSButton("Fermer");
p.add(bBack);
this.add(p, c);
 
// Liste des clients
c.gridy++;
c.gridwidth = 1;
c.weighty = 1;
c.gridheight = 2;
 
ticketLlistModel = new DefaultListModel();
ticketLlistModel.addAll(new Vector<Client>(POSConfiguration.getInstance().allClients()));
final Font f = new Font("Arial", Font.PLAIN, 24);
clientList = new ScrollableList(ticketLlistModel) {
@Override
public void paintCell(Graphics g, Object object, int index, boolean isSelected, int posY) {
g.setFont(f);
 
if (isSelected) {
g.setColor(new Color(232, 242, 254));
} else {
g.setColor(Color.WHITE);
}
g.fillRect(0, posY, getWidth(), getCellHeight());
 
//
g.setColor(Color.GRAY);
g.drawLine(0, posY + this.getCellHeight() - 1, this.getWidth(), posY + this.getCellHeight() - 1);
 
if (isSelected) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Client client = (Client) object;
String label = client.getFullName();
final int soldeInCents = client.getSolde().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
String euro = TicketCellRenderer.centsToString(soldeInCents) + "€";
 
int wEuro = (int) g.getFontMetrics().getStringBounds(euro, g).getWidth();
g.drawString(label, 10, posY + 24);
g.drawString(euro, getWidth() - 5 - wEuro, posY + 24);
 
final String addr = client.getAddr();
if (addr != null) {
g.drawString(addr, 10, posY + 48);
}
}
};
this.add(clientList, c);
 
// Detail
c.fill = GridBagConstraints.BOTH;
c.gridx++;
c.gridheight = 1;
c.weighty = 1;
c.insets = new Insets(10, 10, 10, 10);
 
final DetailClientPanel detailClientPanel = new DetailClientPanel(caisseFrame);
this.add(detailClientPanel, c);
 
clientList.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
Client selectedValue = (Client) clientList.getSelectedValue();
detailClientPanel.setSelectedClient(selectedValue);
}
});
 
bBack.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.showCaisse();
 
}
});
 
}
 
public void setSelectedClient(Object selectedValue) {
clientList.setSelectedValue(selectedValue, true);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TransparentPanel.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.pos.ui;
 
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Robot;
import java.awt.image.BufferedImage;
 
import javax.swing.JPanel;
 
public class TransparentPanel extends JPanel {
private BufferedImage screenShot;
 
public TransparentPanel(Frame frame) {
try {
final Robot robot = new Robot();
screenShot = robot.createScreenCapture(frame.getBounds());
final Graphics2D graphics = screenShot.createGraphics();
// sets a 65% translucent composite
final AlphaComposite alpha = AlphaComposite.SrcOver.derive(0.65f);
graphics.setComposite(alpha);
// fills the background
graphics.setColor(Color.BLACK);
graphics.fillRect(0, 0, screenShot.getWidth(), screenShot.getHeight());
graphics.dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
 
@Override
protected void paintComponent(Graphics g) {
if (screenShot != null) {
g.drawImage(screenShot, 0, 0, null);
}
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PaiementPanel.java
13,7 → 13,6
package org.openconcerto.erp.core.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.io.ConcertProtocol;
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.Paiement;
 
22,24 → 21,25
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Rectangle2D;
import java.util.List;
 
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
 
public class PaiementPanel extends JPanel implements CaisseListener, MouseListener, BarcodeListener {
private static final int OFFSETY = 50;
private static final int LINE_HEIGHT = 64;
private Image bg, bg2, bgCB, bgCHEQUE, bgESPECES;
private static final int PAYMENT_POS_Y = 50;
private static final int PAYMENT_LINE_HEIGHT = 60;
 
private CaisseControler controller;
private String calculatorValue = "";
 
int calcHeight = 5 * 68;
int calcWidth = 4 * 69;
int BUTTON_SIZE = 64;
/**
* Mode '+' ajout d'une quantité '*' multiplication '-' soustraction ' ' remplacement
*/
51,11 → 51,7
this.controller.addCaisseListener(this);
this.controller.addBarcodeListener(this);
this.setOpaque(false);
bg = new ImageIcon(TicketPanel.class.getResource("calculator.png")).getImage();
bg2 = new ImageIcon(TicketPanel.class.getResource("calculator_selected.png")).getImage();
bgCB = new ImageIcon(TicketPanel.class.getResource("cb.png")).getImage();
bgCHEQUE = new ImageIcon(TicketPanel.class.getResource("cheque.png")).getImage();
bgESPECES = new ImageIcon(TicketPanel.class.getResource("especes.png")).getImage();
 
this.addMouseListener(this);
 
this.setLayout(null);
70,51 → 66,85
 
@Override
public void paint(Graphics g) {
g.setColor(Color.BLACK);
Graphics2D g2 = (Graphics2D) g;
g.setColor(new Color(250, 250, 250));
g.fillRect(0, 0, this.getWidth(), this.getHeight());
int y = this.getHeight() - this.bg.getHeight(null);
if (controller.getArticleSelected() != null || controller.getPaiementSelected() != null) {
g.drawImage(bg2, 0, y, null);
} else {
g.drawImage(bg, 0, y, null);
}
 
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.drawLine(0, 0, 0, this.getHeight());
y = OFFSETY;
int y = PAYMENT_POS_Y;
for (Paiement p : controller.getPaiements()) {
if (p.getType() == Paiement.CB) {
g.drawImage(bgCB, 0, y, null);
drawMontant(g, p, 242, y);
drawMontant(g, "CB", p, 242 - 15, y, true);
} else if (p.getType() == Paiement.CHEQUE) {
g.drawImage(bgCHEQUE, 0, y, null);
drawMontant(g, p, 242, y);
drawMontant(g, "Chèque", p, 242 - 15, y, true);
} else if (p.getType() == Paiement.ESPECES) {
g.drawImage(bgESPECES, 0, y, null);
drawMontant(g, p, 300, y);
drawMontant(g, "Espèces", p, 300 - 45, y, false);
} else if (p.getType() == Paiement.SOLDE) {
drawMontant(g, "Solde", p, 300 - 45, y, false);
}
y += LINE_HEIGHT;
y += PAYMENT_LINE_HEIGHT;
}
 
drawKey(g2, "0", 0, 0, 2, 1, CaissePanel.DARK_BLUE);
drawKey(g2, ".", 2, 0, 1, 1, CaissePanel.DARK_BLUE);
 
drawKey(g2, "1", 0, 1, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "2", 1, 1, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "3", 2, 1, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "=", 3, 1, 1, 2, CaissePanel.DARK_BLUE);
 
drawKey(g2, "4", 0, 2, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "5", 1, 2, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "6", 2, 2, 1, 1, CaissePanel.DARK_BLUE);
 
drawKey(g2, "7", 0, 3, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "8", 1, 3, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "9", 2, 3, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "+", 3, 3, 1, 2, CaissePanel.DARK_BLUE);
 
drawKey(g2, "C", 0, 4, 2, 1, CaissePanel.LIGHT_BLUE);
drawKey(g2, "x", 2, 4, 1, 1, CaissePanel.DARK_BLUE);
drawKey(g2, "-", 3, 4, 1, 1, CaissePanel.DARK_BLUE);
 
drawCalculator(g);
if (Boolean.getBoolean("sales.pos.debug")) {
drawGrid(g);
}
super.paint(g);
}
 
private void drawGrid(Graphics g) {
g.setColor(Color.RED);
for (int x = 0; x < 320; x += 80) {
for (int y = 28; y < 900; y += 72) {
g.drawLine(x, y, x + 2, y + 2);
private void drawKey(Graphics2D g2, String string, int col, int row, int w, int h, Color color) {
// background
g2.setColor(color);
g2.fillRect(3 + col * 69, this.getHeight() - (68 * (row + 1)) + 2, 69 * w - 5, 68 * h - 4);
// label
g2.setColor(Color.WHITE);
g2.setFont(g2.getFont().deriveFont(32f));
final int width2 = (int) g2.getFontMetrics().getStringBounds(string, g2).getWidth();
int x = -width2 / 2 + (69) / 2 + col * 69;
int y = this.getHeight() - (row * 68 + 20);
 
g2.drawString(string, x, y);
}
 
public int getLCDY() {
return this.getHeight() - this.calcHeight - 66;
}
 
public int getLCDHeight() {
return 64;
}
 
private void drawCalculator(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
int y = this.getHeight() - this.bg.getHeight(null);
 
// LCD
if (controller.getArticleSelected() != null || controller.getPaiementSelected() != null) {
g.setColor(new Color(232, 242, 254));
} else {
g.setColor(new Color(240, 240, 240));
}
g.fillRect(3, getLCDY(), this.getWidth() - 5, getLCDHeight());
//
int y = this.getHeight() - this.calcHeight - 10;
g.setFont(new Font("Arial", Font.PLAIN, 32));
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
final Article article = controller.getArticleSelected();
123,7 → 153,7
String string = calculatorValue;
g.setFont(g.getFont().deriveFont(52f));
Rectangle2D r1 = g.getFontMetrics().getStringBounds(string, g2);
g.drawString(string, (int) (260 - r1.getWidth()), 500 + y);
g.drawString(string, (int) (260 - r1.getWidth()), y);
g.setFont(g.getFont().deriveFont(14f));
g.drawString("Quantité", 10, 460 + y);
 
133,7 → 163,7
String string = calculatorValue;
g.setFont(g.getFont().deriveFont(52f));
Rectangle2D r1 = g.getFontMetrics().getStringBounds(string, g2);
g.drawString(string, (int) (300 - r1.getWidth()), 500 + y);
g.drawString(string, (int) (260 - r1.getWidth()), y);
g.setFont(g.getFont().deriveFont(14f));
String str = "Paiement ";
if (paiement.getType() == Paiement.CB) {
142,17 → 172,19
str += " en espèces";
} else if (paiement.getType() == Paiement.CHEQUE) {
str += " par chèque";
} else if (paiement.getType() == Paiement.SOLDE) {
str += " depuis solde";
}
g.drawString(str, 10, 460 + y);
g.drawString(str, 10, y - 40);
}
}
g.setFont(g.getFont().deriveFont(14f));
g.drawString("" + mode, 10, 480 + y);
g.drawString("" + mode, 10, y - 20);
}
 
private char getToucheFrom(int x, int y) {
int yy = (this.getHeight() - y) / 72;
int xx = x / 80;
int yy = (this.getHeight() - y) / 68;
int xx = x / 69;
switch (yy) {
case 0:
if (xx == 0) {
219,13 → 251,36
return '?';
}
 
private void drawMontant(Graphics g, Paiement p, int x, int y) {
private void drawMontant(Graphics g, String label, Paiement p, int x, int y, boolean showAdd) {
y = y + 36;
Graphics2D g2 = (Graphics2D) g;
g.setColor(Color.GRAY);
 
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int cents = p.getMontantInCents() % 100;
int euros = p.getMontantInCents() / 100;
// Background
g.setColor(new Color(240, 240, 240));
g.fillRect(3, y - 36, this.getWidth() - 5, 44);
 
g.setColor(CaissePanel.DARK_BLUE);
 
g.fillRect(3, y - 36, 95, 44);
 
if (showAdd) {
g.setColor(CaissePanel.DARK_BLUE);
g.fillRect(this.getWidth() - 46, y - 36, 44, 44);
}
// Label
g.setFont(g.getFont().deriveFont(20f));
g.setFont(g.getFont().deriveFont(Font.BOLD));
 
g.setColor(Color.WHITE);
g.drawString(label, 10, y - 8);
if (showAdd) {
g.drawString("+", this.getWidth() - 32, y - 8);
}
// Cents
g.setColor(Color.GRAY);
String sCents = String.valueOf(cents);
if (sCents.length() < 2) {
sCents = "0" + sCents;
233,10 → 288,10
g.setFont(getFont().deriveFont(18f));
Rectangle2D r1 = g.getFontMetrics().getStringBounds(sCents, g2);
g.drawString(sCents, (int) (x - r1.getWidth()), y);
//
// Euros
g.setFont(g.getFont().deriveFont(36f));
g.setFont(g.getFont().deriveFont(Font.BOLD));
g.setColor(Color.WHITE);
g.setColor(Color.BLACK);
String sEuros = String.valueOf(euros) + ".";
Rectangle2D r2 = g.getFontMetrics().getStringBounds(sEuros, g2);
g.drawString(sEuros, (int) (x - r1.getWidth() - r2.getWidth()), y);
244,13 → 299,11
 
@Override
public Dimension getPreferredSize() {
 
return new Dimension(320, 900);
return new Dimension(calcWidth, 768);
}
 
public Dimension getMinimumSize() {
 
return new Dimension(320, 900);
return new Dimension(calcWidth, 768);
}
 
@Override
260,7 → 313,33
} else if (controller.getPaiementSelected() != null) {
initCaissePaiement();
}
// Add / Remove solde if needed
boolean soldeIsShown = false;
for (Paiement p : controller.getPaiements()) {
if (p.getType() == Paiement.SOLDE) {
soldeIsShown = true;
break;
}
}
 
if (controller.isClientDefined()) {
if (!soldeIsShown && controller.getClient().getSolde().signum() == 1) {
// add
controller.addPaiement(new Paiement(Paiement.SOLDE));
}
} else {
if (soldeIsShown) {
// remove
final List<Paiement> paiements = controller.getPaiements();
for (int i = 0; i < paiements.size(); i++) {
final Paiement p = paiements.get(i);
if (p.getType() == Paiement.SOLDE) {
controller.getPaiements().remove(i);
break;
}
}
}
}
repaint();
 
}
279,24 → 358,26
 
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
 
// Nothing to do here
}
 
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
 
// Nothing to do here
}
 
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
 
// Nothing to do here
}
 
@Override
public void mousePressed(MouseEvent e) {
if (e.getY() > getLCDY() && e.getY() < (getLCDY() + getLCDHeight())) {
lcdPressed();
return;
}
 
char c = getToucheFrom(e.getX(), e.getY());
if (c != '?') {
handleCharacter(c);
303,7 → 384,7
} else {
Paiement p = getPaiementFrom(e.getY());
if (p != null) {
if (e.getX() > 320 - 64 && p.getType() != Paiement.ESPECES && controller.canAddPaiement(p.getType())) {
if (e.getX() > this.getWidth() - 68 && p.getType() != Paiement.ESPECES && controller.canAddPaiement(p.getType())) {
p = new Paiement(p.getType());
controller.addPaiement(p);
}
324,6 → 405,16
}
}
 
public void lcdPressed() {
System.err.println("PaiementPanel.lcdPressed()");
final Article articleSelected = controller.getArticleSelected();
if (articleSelected != null) {
controller.openPriceEditor(articleSelected);
}
repaint();
 
}
 
private void handleCharacter(char c) {
System.out.println("Handle: " + c);
if (c == '?')
376,9 → 467,7
mode = ' ';
controller.clearPaiement(paiement);
} else if (c == '.' && (calculatorValue.indexOf('.') < 0)) {
 
calculatorValue += ".";
 
} else if (c == '=' || c == '\n') {
if (!init) {
int v = getCentsFrom(this.calculatorValue);
401,12 → 490,13
}
if (calculatorValue.length() < 9) {
int i = calculatorValue.indexOf('.');
if (i < 0 || (i >= 0 && calculatorValue.length() - i < 3))
if (i < 0 || (calculatorValue.length() - i < 3)) {
calculatorValue += c;
}
}
}
}
}
repaint();
}
 
434,17 → 524,16
 
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
 
// Nothing to do here
}
 
@Override
public void barcodeRead(String code) {
 
// Nothing to do here
}
 
private Paiement getPaiementFrom(int y) {
int index = (y - OFFSETY) / LINE_HEIGHT;
int index = (y - PAYMENT_POS_Y) / PAYMENT_LINE_HEIGHT;
if (index < controller.getPaiements().size() && index >= 0) {
return controller.getPaiements().get(index);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseFrame.java
14,16 → 14,22
package org.openconcerto.erp.core.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.Client;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.RemoteShell;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.utils.ClassPathLoader;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
30,21 → 36,21
 
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
 
public class CaisseFrame extends JFrame {
CaissePanel t;
final CaissePanel mainPanel;
 
CaisseFrame() {
t = new CaissePanel(this);
 
setContentPane(t);
this.mainPanel = new CaissePanel(this);
setContentPane(mainPanel);
setFocusable(true);
}
 
public static void main(String[] args) {
System.setProperty(SQLRowAccessor.ACCESS_DB_IF_NEEDED_PROP, "true");
try {
System.out.println("Lancement du module de caisse");
ToolTipManager.sharedInstance().setInitialDelay(0);
79,7 → 85,7
public void run() {
 
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
123,35 → 129,96
public void showMenu() {
System.out.println("CaisseFrame.showMenu()");
this.invalidate();
this.setContentPane(new CaisseMenuPanel(this));
final CaisseMenuPanel panel = new CaisseMenuPanel(this);
 
final POSGlassPane glassPane2 = new POSGlassPane(panel, (getWidth() - panel.getPreferredSize().width) / 2, 100) {
@Override
public void mousePressed(MouseEvent e) {
Point containerPoint = SwingUtilities.convertPoint(this, e.getPoint(), panel);
if (containerPoint.x < 0 || containerPoint.x > panel.getWidth() || containerPoint.y < 0 || containerPoint.y > panel.getHeight()) {
setGlassPane(new JPanel());
getGlassPane().setVisible(false);
}
super.mousePressed(e);
}
 
};
this.setGlassPane(glassPane2);
this.getGlassPane().setVisible(true);
this.validate();
this.repaint();
t.getControler().setLCD("OpenConcerto", "Menu", 0);
this.getControler().setLCD("OpenConcerto", "Menu", 0);
 
}
 
public void showCaisse() {
System.out.println("CaisseFrame.showCaisse()");
public void showPriceEditor(Article article, CaisseControler caisseControler) {
getControler().disableBarcodeReader();
System.out.println("CaisseFrame.showPriceEditor()");
this.invalidate();
this.setContentPane(this.t);
final PriceEditorPanel panel = new PriceEditorPanel(this, article);
 
final POSGlassPane glassPane2 = new POSGlassPane(panel, (getWidth() - panel.getPreferredSize().width) / 2, 100) {
@Override
public void mousePressed(MouseEvent e) {
Point containerPoint = SwingUtilities.convertPoint(this, e.getPoint(), panel);
if (containerPoint.x < 0 || containerPoint.x > panel.getWidth() || containerPoint.y < 0 || containerPoint.y > panel.getHeight()) {
setGlassPane(new JPanel());
getGlassPane().setVisible(false);
getControler().enableBarcodeReader();
 
}
super.mousePressed(e);
}
 
};
this.setGlassPane(glassPane2);
this.getGlassPane().setVisible(true);
this.validate();
this.repaint();
t.getControler().setLCD("OpenConcerto", "Caisse", 0);
t.getControler().setLCDDefaultDisplay(5);
 
}
 
public void showCaisse() {
getControler().enableBarcodeReader();
setGlassPane(new JPanel());
getGlassPane().setVisible(false);
 
System.out.println("CaisseFrame.showCaisse()");
this.setContentPane(this.mainPanel);
this.getControler().setLCD("OpenConcerto", "Caisse", 0);
this.getControler().setLCDDefaultDisplay(5);
}
 
public void showTickets(Ticket t) {
System.out.println("CaisseFrame.showMenu()");
this.invalidate();
ListeDesTicketsPanel panel = new ListeDesTicketsPanel(this);
final ListeDesTicketsPanel panel = new ListeDesTicketsPanel(this);
panel.setSelectedTicket(t);
this.setContentPane(panel);
this.validate();
this.repaint();
 
}
 
public CaisseControler getControler() {
return t.getControler();
return this.mainPanel.getControler();
}
 
public void showClients() {
System.out.println("CaisseFrame.showClients()");
final ListeDesClientsPanel panel = new ListeDesClientsPanel(this);
this.setContentPane(panel);
}
 
public void setClient(Client client) {
System.err.println("CaisseFrame.setClient() " + client.getFullName());
this.getControler().setClient(client);
 
}
 
@Override
public void setContentPane(Container contentPane) {
this.invalidate();
setGlassPane(new JPanel());
getGlassPane().setVisible(false);
super.setContentPane(contentPane);
this.validate();
this.repaint();
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ArticleSelector.java
18,6 → 18,7
import org.openconcerto.ui.touch.ScrollableList;
 
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
24,6 → 25,8
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
49,9 → 52,13
c.gridy = 0;
c.weightx = 1;
c.fill = GridBagConstraints.BOTH;
comp = new StatusBar("toolbar.png", "toolbar_list.png");
comp.setPrevious(true);
comp = new StatusBar();
comp.setLayout(new FlowLayout(FlowLayout.LEFT));
comp.setTitle("Articles");
final POSButton bSwitch = new POSButton("-");
bSwitch.setForeground(Color.WHITE);
bSwitch.setBackground(CaissePanel.DARK_BLUE);
comp.add(bSwitch);
this.add(comp, c);
 
c.weighty = 1;
114,10 → 121,13
}
}
});
comp.addMouseListener(new MouseAdapter() {
 
bSwitch.addActionListener(new ActionListener() {
 
@Override
public void mousePressed(MouseEvent e) {
public void actionPerformed(ActionEvent e) {
controller.switchListMode();
 
}
});
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaissePanel.java
20,6 → 20,8
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.ExceptionHandler;
 
import java.awt.Color;
28,11 → 30,13
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Rectangle2D;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
41,6 → 45,10
import javax.swing.JPanel;
 
public class CaissePanel extends JPanel implements CaisseListener {
 
public static final Color LIGHT_BLUE = new Color(83, 129, 172);
public static final Color DARK_BLUE = new Color(0, 98, 159);
 
private CaisseControler controler;
 
private StatusBar st;
62,38 → 70,8
this.controler = new CaisseControler(caisseFrame);
 
c.fill = GridBagConstraints.HORIZONTAL;
this.st = new StatusBar("toolbar.png", "toolbar_menu.png");
this.st.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.getX() < 110) {
// Valider
CaissePanel.this.controler.setLCD("Impression de", "votre ticket...", 0);
try {
CaissePanel.this.controler.printTicket();
} catch (UnsatisfiedLinkError ex) {
JOptionPane.showMessageDialog(CaissePanel.this, "Erreur de configuration de la liaison à l'imprimante");
} catch (Throwable ex) {
JOptionPane.showMessageDialog(CaissePanel.this, "Erreur d'impression du ticket");
}
try {
CaissePanel.this.controler.saveAndClearTicket();
} catch (Throwable ex) {
ExceptionHandler.handle("Erreur de sauvegardes des informations du ticket", ex);
}
CaissePanel.this.controler.setLCDDefaultDisplay(2);
} else if (e.getX() > 165 && e.getX() < 275) {
// Menu
try {
caisseFrame.showMenu();
} catch (Throwable ex) {
ExceptionHandler.handle("Erreur d'affichage du menu", ex);
}
}
this.st = createStatusBar(caisseFrame);
 
}
});
this.st.setPrevious(true);
this.add(this.st, c);
 
TicketPanel t = new TicketPanel(this.controler);
124,6 → 102,84
this.controler.addCaisseListener(this);
}
 
private StatusBar createStatusBar(final CaisseFrame caisseFrame) {
final StatusBar s = new StatusBar();
s.setLayout(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(0, 10, 0, 10);
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
c.weightx = 0;
final POSButton bValidate = new POSButton("Valider");
bValidate.setForeground(Color.WHITE);
bValidate.setBackground(DARK_BLUE);
s.add(bValidate, c);
c.weightx = 1;
c.gridx++;
final POSButton bClients = new POSButton("Clients");
bClients.setForeground(Color.WHITE);
bClients.setBackground(DARK_BLUE);
s.add(bClients, c);
c.gridx++;
final POSButton bMenu = new POSButton("Menu");
bMenu.setForeground(Color.WHITE);
bMenu.setBackground(DARK_BLUE);
s.add(bMenu, c);
bValidate.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
// Valider
CaissePanel.this.controler.setLCD("Impression de", "votre ticket...", 0);
try {
CaissePanel.this.controler.printTicket();
} catch (UnsatisfiedLinkError ex) {
JOptionPane.showMessageDialog(CaissePanel.this, "Erreur de configuration de la liaison à l'imprimante");
} catch (Throwable ex) {
JOptionPane.showMessageDialog(CaissePanel.this, "Erreur d'impression du ticket");
}
try {
CaissePanel.this.controler.saveAndClearTicket();
} catch (Throwable ex) {
ExceptionHandler.handle("Erreur de sauvegardes des informations du ticket", ex);
}
CaissePanel.this.controler.setLCDDefaultDisplay(2);
 
}
});
bClients.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
// Clients
try {
caisseFrame.showClients();
} catch (Throwable ex) {
ExceptionHandler.handle("Erreur d'affichage du menu", ex);
}
 
}
});
 
bMenu.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
// Menu
try {
caisseFrame.showMenu();
} catch (Throwable ex) {
ExceptionHandler.handle("Erreur d'affichage du menu", ex);
}
 
}
});
 
return s;
}
 
@SuppressWarnings("unchecked")
private void loadArticles() {
 
153,8 → 209,10
}
 
final SQLSelect selArticle = new SQLSelect();
selArticle.addSelectStar(eltArticle.getTable());
List<SQLRow> l2 = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(selArticle.asString(), SQLRowListRSH.createFromSelect(selArticle, eltArticle.getTable()));
final SQLTable tableArticle = eltArticle.getTable();
selArticle.addSelectStar(tableArticle);
selArticle.setWhere(new Where(tableArticle.getField("OBSOLETE"), "=", Boolean.FALSE));
List<SQLRow> l2 = (List<SQLRow>) Configuration.getInstance().getBase().getDataSource().execute(selArticle.asString(), SQLRowListRSH.createFromSelect(selArticle, tableArticle));
 
final Categorie cUnclassified = new Categorie("Non classés", true);
for (SQLRow row : l2) {
189,6 → 247,17
Graphics2D g2 = (Graphics2D) g;
g.setFont(new Font("Arial", Font.PLAIN, 32));
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 
if (this.controler.isClientDefined()) {
g.setColor(CaissePanel.DARK_BLUE);
g.setFont(new Font("Arial", Font.PLAIN, 28));
g.drawString(this.controler.getClient().getFullName(), 20, 75);
g.setColor(Color.GRAY);
g.setFont(g.getFont().deriveFont(18f));
g.drawString("Solde : " + new DecimalFormat("#0.00").format(this.controler.getClient().getSolde()), 20, 120);
 
}
 
// Prix
int x = 300;
int y = 110;
195,7 → 264,13
String euros;
String cents;
Rectangle2D r;
g.setColor(Color.BLACK);
if (this.controler.isClientDefined()) {
g.setFont(g.getFont().deriveFont(46f));
y += 10;
} else {
g.setFont(g.getFont().deriveFont(66f));
}
final int total = this.controler.getTotal();
euros = CaisseControler.getEuros(total) + ".";
cents = CaisseControler.getCents(total);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ArticleSearchPanel.java
18,6 → 18,7
import org.openconcerto.ui.touch.ScrollableList;
 
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
25,14 → 26,16
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
 
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
55,11 → 58,12
final FilteredListModel model = new FilteredListModel();
final Font f1 = new Font("Arial", Font.PLAIN, 24);
final Font f2 = new Font("Arial", Font.PLAIN, 16);
setBackground(CaissePanel.LIGHT_BLUE);
list = new ScrollableList(model) {
@Override
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.GRAY);
g.setColor(CaissePanel.LIGHT_BLUE);
g.drawLine(0, 0, 0, this.getHeight());
}
 
80,14 → 84,21
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
StatusBar bar = new StatusBar("toolbar.png", "toolbar_list.png");
bar.addMouseListener(new MouseAdapter() {
final StatusBar bar = new StatusBar();
final POSButton bSwitch = new POSButton("-");
bSwitch.setForeground(Color.WHITE);
bSwitch.setBackground(CaissePanel.DARK_BLUE);
bar.setLayout(new FlowLayout(FlowLayout.LEFT));
bar.add(bSwitch);
bSwitch.addActionListener(new ActionListener() {
 
@Override
public void mousePressed(MouseEvent e) {
public void actionPerformed(ActionEvent e) {
controler.switchListMode();
 
}
});
bar.setPrevious(true);
 
bar.setTitle("Articles");
c.fill = GridBagConstraints.BOTH;
c.gridwidth = 2;
111,6 → 122,7
c.weightx = 0;
this.add(label, c);
final JTextField textField = new JTextField();
textField.setBorder(BorderFactory.createLineBorder(CaissePanel.DARK_BLUE, 1));
textField.setFont(f1);
c.weightx = 1;
c.gridx++;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PriceEditorPanel.java
New file
0,0 → 1,247
/*
* 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.ui;
 
import org.openconcerto.erp.core.common.ui.NumericTextField;
import org.openconcerto.erp.core.sales.pos.model.Article;
 
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
 
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
public class PriceEditorPanel extends JPanel {
CaisseFrame frame;
private POSLabel labelPrice;
private Article article;
final POSRadioButton rHT, rTTC, rDiscountPercent, rDiscount;
private NumericTextField htTextField;
private NumericTextField ttcTextField;
private NumericTextField discountPercentTextField;
private NumericTextField discountTextField;
 
public PriceEditorPanel(final CaisseFrame caisseFrame, final Article article) {
this.article = article;
this.frame = caisseFrame;
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.EAST;
c.weightx = 0;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.insets = new Insets(20, 20, 30, 20);
// Line 1
c.gridwidth = 2;
POSLabel title = new POSLabel("Modification du prix de vente");
this.add(title, c);
// Line 2
c.gridy++;
c.gridwidth = 1;
rHT = new POSRadioButton("prix HT");
rHT.setSelected(true);
c.weightx = 0;
this.add(rHT, c);
htTextField = new NumericTextField();
htTextField.setValue(article.getPriceWithoutTax());
htTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(htTextField, c);
// Line 3
c.gridy++;
rTTC = new POSRadioButton("prix TTC");
htTextField.setValue(article.getPriceWithTax());
c.gridx = 0;
c.weightx = 0;
this.add(rTTC, c);
ttcTextField = new NumericTextField();
ttcTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(ttcTextField, c);
// Line 4
c.gridy++;
rDiscountPercent = new POSRadioButton("remise en %");
c.gridx = 0;
c.weightx = 0;
this.add(rDiscountPercent, c);
discountPercentTextField = new NumericTextField();
discountPercentTextField.setValue(BigDecimal.ZERO);
discountPercentTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(discountPercentTextField, c);
// Line 5
rDiscount = new POSRadioButton("remise HT");
c.gridx = 0;
c.weightx = 0;
c.gridy++;
this.add(rDiscount, c);
discountTextField = new NumericTextField();
discountTextField.setValue(BigDecimal.ZERO);
discountTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(discountTextField, c);
 
final ButtonGroup group = new ButtonGroup();
group.add(rHT);
group.add(rTTC);
group.add(rDiscountPercent);
group.add(rDiscount);
//
//
c.gridy++;
c.gridx = 0;
c.gridwidth = 2;
final POSLabel labelPriceOld = new POSLabel("Ancien Prix : ");
final BigDecimal ttc = Article.computePriceWithTax(this.article.getPriceWithoutTax(), this.article.getIdTaxe());
ttcTextField.setValue(ttc);
labelPriceOld.setText("Ancien Prix : " + TicketCellRenderer.toString(this.article.getPriceWithoutTax()) + " HT, " + TicketCellRenderer.toString(ttc));
this.add(labelPriceOld, c);
 
c.gridy++;
c.gridx = 0;
labelPrice = new POSLabel("Nouveau Prix : ");
this.add(labelPrice, c);
 
c.gridy++;
c.gridx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.SOUTHEAST;
 
final JPanel buttons = new JPanel();
buttons.setOpaque(false);
POSButton bApply = new POSButton("Appliquer");
buttons.add(bApply, c);
POSButton bCancel = new POSButton("Annuler");
buttons.add(bCancel, c);
bApply.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.getControler().setArticleHT(article, getHTFromUI());
caisseFrame.showCaisse();
}
});
bCancel.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.showCaisse();
}
});
 
this.add(buttons, c);
updatePrice(article.getPriceWithoutTax());
updateTextFields();
//
final ActionListener listenerRadio = new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
updatePrice(getHTFromUI());
 
updateTextFields();
 
}
};
this.rDiscount.addActionListener(listenerRadio);
this.rDiscountPercent.addActionListener(listenerRadio);
this.rHT.addActionListener(listenerRadio);
this.rTTC.addActionListener(listenerRadio);
 
final DocumentListener docListener = new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
 
}
 
@Override
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
 
}
 
@Override
public void changedUpdate(DocumentEvent e) {
updatePrice(getHTFromUI());
}
};
this.ttcTextField.getDocument().addDocumentListener(docListener);
this.htTextField.getDocument().addDocumentListener(docListener);
this.discountPercentTextField.getDocument().addDocumentListener(docListener);
this.discountTextField.getDocument().addDocumentListener(docListener);
}
 
protected BigDecimal getHTFromUI() {
BigDecimal r = null;
try {
if (this.rHT.isSelected()) {
r = this.htTextField.getValue();
} else if (this.rTTC.isSelected()) {
r = Article.computePriceWithoutTax(this.ttcTextField.getValue(), this.article.getIdTaxe());
} else if (this.rDiscountPercent.isSelected()) {
r = this.article.getPriceWithoutTax().subtract(this.article.getPriceWithoutTax().multiply(this.discountPercentTextField.getValue().divide(new BigDecimal(100))));
} else if (this.rDiscount.isSelected()) {
r = this.article.getPriceWithoutTax().subtract(this.discountTextField.getValue());
}
} catch (Exception e) {
e.printStackTrace();
}
if (r == null) {
// fallback if something wrong
r = this.article.getPriceWithoutTax();
}
return r;
}
 
void updatePrice(BigDecimal ht) {
BigDecimal ttc = Article.computePriceWithTax(ht, this.article.getIdTaxe());
labelPrice.setText("Nouveau Prix : " + TicketCellRenderer.toString(ht) + " HT, " + TicketCellRenderer.toString(ttc));
}
 
public void updateTextFields() {
this.invalidate();
htTextField.setVisible(false);
ttcTextField.setVisible(false);
discountPercentTextField.setVisible(false);
discountTextField.setVisible(false);
if (rHT.isSelected()) {
htTextField.setVisible(true);
} else if (rTTC.isSelected()) {
ttcTextField.setVisible(true);
} else if (rDiscountPercent.isSelected()) {
discountPercentTextField.setVisible(true);
} else if (rDiscount.isSelected()) {
discountTextField.setVisible(true);
}
this.validate();
repaint();
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PrinterPOSDisplay.java
New file
0,0 → 1,70
/*
* 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.ui;
 
import java.io.IOException;
 
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
import javax.print.attribute.AttributeSet;
import javax.print.attribute.HashPrintServiceAttributeSet;
import javax.print.attribute.standard.PrinterName;
 
public class PrinterPOSDisplay extends POSDisplay {
 
private String printerName;
 
public PrinterPOSDisplay(String lcdPort) {
this.printerName = lcdPort;
}
 
@Override
public void setMessage(String line1, String line2) throws Exception, IOException {
if (line1 == null) {
line1 = "";
}
if (line2 == null) {
line2 = "";
}
// clear
sendBytes(new byte[] { 12 });
// send the two lines
sendBytes((line1 + "\r\n" + line2 + "\r\n").getBytes());
}
 
private synchronized void sendBytes(byte[] b) throws PrintException {
if (this.printerName == null || this.printerName.isEmpty()) {
return;
}
final AttributeSet attrSet = new HashPrintServiceAttributeSet(new PrinterName(this.printerName, null));
final PrintService[] lookupPrintServices = PrintServiceLookup.lookupPrintServices(null, attrSet);
if (lookupPrintServices.length <= 0) {
throw new PrintException("Printer " + this.printerName + " not found");
}
final DocPrintJob job = lookupPrintServices[0].createPrintJob();
final DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
final Doc doc = new SimpleDoc(b, flavor, null);
job.print(doc, null);
}
 
public static void main(String[] args) throws IOException, Exception {
PrinterPOSDisplay p = new PrinterPOSDisplay("EPSON DM-D Display");
p.setMessage("OpenConcerto", "Caisse ouverte");
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/POSButton.java
New file
0,0 → 1,33
/*
* 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.ui;
 
import java.awt.Color;
import java.awt.Font;
 
import javax.swing.JButton;
 
public class POSButton extends JButton {
public POSButton(String label) {
super(label);
final Font f = getFont().deriveFont(20f);
this.setForeground(Color.WHITE);
this.setBackground(CaissePanel.DARK_BLUE);
this.setFont(f);
this.setFocusPainted(false);
this.setBorderPainted(false);
this.setContentAreaFilled(false);
this.setOpaque(true);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CategorieSelector.java
26,11 → 26,8
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
 
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
156,11 → 153,9
CategorieSelector.this.list.clearSelection();
if (newCategory == null) {
CategorieSelector.this.comp.setTitle("Catégories");
CategorieSelector.this.comp.setPrevious(false);
CategorieSelector.this.previous = null;
} else {
CategorieSelector.this.comp.setTitle(newCategory.getName());
CategorieSelector.this.comp.setPrevious(true);
CategorieSelector.this.previous = newCategory.getParent();
}
articleModel.setCategorie(newCategory);
180,7 → 175,6
this.previous = this.model.getRoot();
this.model.setRoot(c);
this.comp.setTitle(c.getName());
this.comp.setPrevious(true);
this.list.clearSelection();
}
this.articleModel.setCategorie(c);
198,7 → 192,6
this.model.setRoot(c.getParent());
this.comp.setTitle(c.getParent().getName());
}
this.comp.setPrevious(true);
this.list.setSelectedValue(c, true);
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/search.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/StatusBar.java
18,37 → 18,18
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
 
import javax.swing.ImageIcon;
import javax.swing.JPanel;
 
public class StatusBar extends JPanel {
private Image bg;
private Image bg_retour;
 
private String title = "";
 
private boolean previous;
private int offsetX = 110;
 
StatusBar() {
this("toolbar.png", "toolbar_retour.png");
}
 
StatusBar(String fileBg, String fileFg) {
bg = new ImageIcon(TicketPanel.class.getResource(fileBg)).getImage();
bg_retour = new ImageIcon(TicketPanel.class.getResource(fileFg)).getImage();
public StatusBar() {
setFont(new Font("Arial", Font.BOLD, 24));
}
 
public void setPrevious(boolean b) {
if (b != previous) {
this.previous = b;
repaint();
}
}
 
public void setTitle(String t) {
if (this.title == null || !this.title.equals(t)) {
this.title = t;
56,24 → 37,14
}
}
 
void setTitleLocation(int x) {
offsetX = x;
}
 
@Override
protected void paintComponent(Graphics g) {
final int w = this.getWidth();
int imWidth = bg.getWidth(null);
for (int x = imWidth - 1; x <= w; x += imWidth) {
g.drawImage(bg, x, 0, null);
}
if (previous)
g.drawImage(bg_retour, 0, 0, null);
else
g.drawImage(bg, 0, 0, null);
g.setColor(CaissePanel.LIGHT_BLUE);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int w = (int) g.getFontMetrics().getStringBounds(title, g).getWidth();
g.setColor(new Color(250, 250, 250));
g.drawString(title, offsetX, 30);
g.drawString(title, (this.getWidth() - w) / 2, 30);
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TicketCellRenderer.java
26,6 → 26,7
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.math.BigDecimal;
import java.math.RoundingMode;
 
import javax.swing.JLabel;
38,6 → 39,7
 
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
@SuppressWarnings("unchecked")
Pair<Article, Integer> item = (Pair<Article, Integer>) value;
JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
57,7 → 59,8
c.gridx++;
c.weightx = 0;
 
final JLabel l3 = new JLabel(centsToString(article.getPriceWithTax().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()), SwingConstants.RIGHT);
final BigDecimal priceWithTax = article.getPriceWithTax();
final JLabel l3 = new JLabel(toString(priceWithTax), SwingConstants.RIGHT);
p.add(l3, c);
 
//
116,8 → 119,10
if (c < 10) {
sc = "0" + sc;
}
 
return cents / 100 + "." + sc;
}
 
public static String toString(final BigDecimal p) {
return centsToString(p.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue());
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ConfigCaissePanel.java
39,6 → 39,8
import java.util.List;
import java.util.Vector;
 
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
55,6 → 57,7
 
public class ConfigCaissePanel extends JPanel {
 
private final POSConfiguration configuration = POSConfiguration.getInstance();
private int userId;
private int societeId;
private int caisseId;
70,7 → 73,8
private final TicketPrinterConfigPanel ticketPanel1;
private final TicketPrinterConfigPanel ticketPanel2;
// LCD
private JTextField textLCDSerialPort;
private JComboBox comboLCDType;
private JTextField textLCDPort;
private JTextField textLCDLine1;
private JTextField textLCDLine2;
 
89,8 → 93,8
c.gridwidth = 3;
c.weightx = 1;
JTextField textConfigurationFile = new JTextField("");
if (POSConfiguration.getConfigFile() != null) {
textConfigurationFile.setText(POSConfiguration.getConfigFile().getAbsolutePath());
if (this.configuration.getConfigFile() != null) {
textConfigurationFile.setText(this.configuration.getConfigFile().getAbsolutePath());
}
textConfigurationFile.setEditable(false);
this.add(textConfigurationFile, c);
252,13 → 256,25
c.gridwidth = 1;
c.anchor = GridBagConstraints.EAST;
c.fill = GridBagConstraints.NONE;
p.add(new JLabel("Port série", SwingConstants.RIGHT), c);
p.add(new JLabel("Type", SwingConstants.RIGHT), c);
c.gridx++;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
comboLCDType = new JComboBox(new String[] { "Port série", "Emulation imprimante" });
 
p.add(comboLCDType, c);
c.gridy++;
c.gridx = 0;
c.anchor = GridBagConstraints.EAST;
final JLabel labelType = new JLabel("Port", SwingConstants.RIGHT);
p.add(labelType, c);
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
 
this.textLCDSerialPort = new JTextField(20);
p.add(this.textLCDSerialPort, c);
this.textLCDPort = new JTextField(20);
p.add(this.textLCDPort, c);
c.weightx = 0;
c.gridx++;
final JButton selectPortButton = new JButton("Sélectionner");
269,22 → 285,33
List<String> choices = new ArrayList<String>();
final String title;
final String message;
 
if (comboLCDType.getSelectedIndex() == 1) {
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
for (PrintService printer : printServices) {
choices.add(printer.getName());
}
title = "Afficheur LCD";
message = "Choisissez l'imprimante correspondante à l'afficheur LCD";
} else if (comboLCDType.getSelectedIndex() == 0) {
choices.addAll(ESCSerialPrinter.getSerialPortNames());
title = "Port série";
message = "Choisissez le port série lié à l'afficheur";
message = "Choisissez le port série lié à l'afficheur LCD";
} else {
return;
}
if (choices.isEmpty()) {
return;
}
String s = (String) JOptionPane.showInputDialog(p, message, title, JOptionPane.PLAIN_MESSAGE, null, choices.toArray(), choices.get(0));
 
// If a string was returned
if ((s != null) && (s.length() > 0)) {
textLCDSerialPort.setText(s);
textLCDPort.setText(s);
}
 
}
});
p.add(selectPortButton, c);
//
 
c.gridx = 0;
c.gridy++;
429,11 → 456,18
 
public void loadConfiguration() {
 
final POSConfiguration configuration = POSConfiguration.getInstance();
final POSConfiguration configuration = this.configuration;
// Terminal CB
this.textTerminalCB.setText(configuration.getCreditCardPort());
// Afficheur LCD
this.textLCDSerialPort.setText(configuration.getLCDSerialPort());
final String lcdType = configuration.getLCDType();
if (lcdType.equals("serial")) {
this.comboLCDType.setSelectedIndex(0);
} else {
this.comboLCDType.setSelectedIndex(1);
}
 
this.textLCDPort.setText(configuration.getLCDPort());
this.textLCDLine1.setText(configuration.getLCDLine1());
this.textLCDLine2.setText(configuration.getLCDLine2());
 
562,7 → 596,7
}
 
public void saveConfiguration() {
POSConfiguration configuration = POSConfiguration.getInstance();
final POSConfiguration configuration = this.configuration;
this.ticketPanel1.commitValues();
this.ticketPanel2.commitValues();
configuration.setUserID(this.userId);
573,7 → 607,13
// Terminal CB
configuration.setCreditCardPort(this.textTerminalCB.getText());
// LCD
configuration.setLCDSerialPort(this.textLCDSerialPort.getText());
final int selectedIndex = this.comboLCDType.getSelectedIndex();
if (selectedIndex == 0) {
configuration.setLCDType("serial");
} else {
configuration.setLCDType("printer");
}
configuration.setLCDPort(this.textLCDPort.getText());
configuration.setLCDLine1(this.textLCDLine1.getText());
configuration.setLCDLine2(this.textLCDLine2.getText());
// Save
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/DetailClientPanel.java
New file
0,0 → 1,245
/*
* 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.ui;
 
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.erp.core.sales.pos.TicketPrinterConfiguration;
import org.openconcerto.erp.core.sales.pos.io.TicketPrinter;
import org.openconcerto.erp.core.sales.pos.model.Client;
import org.openconcerto.erp.core.sales.pos.model.Transaction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.DefaultListModel;
import org.openconcerto.ui.touch.ScrollableList;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
import com.ibm.icu.text.DateFormat;
 
public class DetailClientPanel extends JPanel {
private CaisseFrame caisseFrame;
 
DetailClientPanel(CaisseFrame f) {
this.caisseFrame = f;
this.setOpaque(false);
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
final JPanel filler = new JPanel();
filler.setOpaque(false);
this.add(filler, c);
}
 
public void setSelectedClient(final Client client) {
 
this.removeAll();
this.invalidate();
final Font f = new Font("Arial", Font.PLAIN, 24);
GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 0;
final JLabel label = new JLabel(client.getFullName());
label.setFont(f);
this.add(label, c);
c.gridy++;
final JLabel labelTransaction = new JLabel("Transactions");
labelTransaction.setFont(f);
this.add(labelTransaction, c);
c.gridy++;
//
c.weighty = 1;
this.add(createTransactionList(client), c);
//
 
c.fill = GridBagConstraints.NONE;
c.weighty = 0;
c.gridy++;
final JButton bCredit = new POSButton("Créditer le compte");
this.add(bCredit, c);
 
//
c.gridy++;
c.anchor = GridBagConstraints.EAST;
c.insets = new Insets(20, 20, 5, 2);
final JButton bSelect = new POSButton("Sélectionner ce client");
this.add(bSelect, c);
 
this.validate();
this.repaint();
 
// Listeners
bCredit.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
TransparentPanel tP = new TransparentPanel(caisseFrame);
//
JPanel p = new JPanel();
p.setBackground(Color.WHITE);
p.setLayout(new GridBagLayout());
GridBagConstraints constraints = new DefaultGridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
constraints.insets = new Insets(20, 20, 20, 20);
constraints.gridwidth = 2;
constraints.weightx = 1;
POSLabel label = new POSLabel(client.getFullName());
p.add(label, constraints);
constraints.gridy++;
 
final SoldePaiementPanel soldePanel = new SoldePaiementPanel();
p.add(soldePanel, constraints);
constraints.gridwidth = 1;
constraints.gridy++;
constraints.gridx = 0;
constraints.fill = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.EAST;
POSButton bC = new POSButton("Créditer");
p.add(bC, constraints);
bC.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
try {
final BigDecimal amount = soldePanel.getAmount();
final int paymentType = soldePanel.getPaymentType();
client.credit(amount, paymentType);
final BigDecimal nouveauSolde = client.getSolde();
final Thread t = new Thread(new Runnable() {
 
@Override
public void run() {
final TicketPrinterConfiguration conf1 = POSConfiguration.getInstance().getTicketPrinterConfiguration1();
if (conf1.isValid()) {
final TicketPrinter prt = conf1.createTicketPrinter();
final int ticketWidth = conf1.getTicketWidth();
client.printCredit(prt, ticketWidth, amount, paymentType, nouveauSolde);
}
 
}
});
t.setDaemon(true);
t.start();
caisseFrame.showClients();
} catch (Exception e1) {
ExceptionHandler.handle("Erreur lors du crédit", e1);
}
 
}
});
constraints.gridx++;
constraints.weightx = 0;
POSButton bClose = new POSButton("Fermer");
p.add(bClose, constraints);
bClose.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.showClients();
}
});
//
tP.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = 1;
c.gridheight = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
tP.add(p, c);
caisseFrame.invalidate();
caisseFrame.setContentPane(tP);
caisseFrame.validate();
caisseFrame.repaint();
 
}
});
bSelect.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.setClient(client);
caisseFrame.showCaisse();
}
});