OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 174 → Rev 173

/trunk/OpenConcerto/.classpath
16,6 → 16,7
<classpathentry exported="true" kind="lib" path="lib/ognl-2.6.5.jar"/>
<classpathentry exported="true" kind="lib" path="lib/resolver.jar"/>
<classpathentry exported="true" kind="lib" path="lib/RXTXcomm.jar"/>
<classpathentry exported="true" kind="lib" path="lib/poi-3.8-beta3-20110606.jar"/>
<classpathentry kind="lib" path="lib/jcip-annotations.jar"/>
<classpathentry kind="lib" path="lib/fb-annotations-2.0.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-dbcp-1.4.jar"/>
43,6 → 44,5
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.40-bin.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/postgresql-42.2.2.jre7.jar"/>
<classpathentry kind="lib" path="lib/poi-3.17.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/jOpenCalendar.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/OpenConcerto/src/org/jopendocument/link/OOConnexion.java
84,14 → 84,8
perms.add(new RuntimePermission("modifyThread"));
// needed by PrinterJob.getPrinterJob()
perms.add(new RuntimePermission("queuePrintJob"));
 
// ProcessBuilder.start() calls SecurityManager.checkExec() which requires
// absolute path (or execute on "<<ALL FILES>>")
 
// needed by OOConnexion.init() to find the port
perms.add(new FilePermission("/usr/bin/lsof", "execute"));
// macOS path
perms.add(new FilePermission("/usr/sbin/lsof", "execute"));
perms.add(new FilePermission("/bin/ps", "execute"));
perms.add(new FilePermission("C:/Windows/System32/tasklist.exe", "execute"));
perms.add(new RuntimePermission("getenv.*"));
/trunk/OpenConcerto/src/org/jopendocument/link/OOInstallation.java
102,14 → 102,10
rootPaths.addAll(Arrays.asList(loRootPaths));
rootPaths.addAll(Arrays.asList(ooRootPaths));
}
 
for (final String p : rootPaths) {
// On force à chercher dans le registre 64 bits sinon il va chercher dans le registre 32
// bits si os 64b et VM 32b
if (DesktopEnvironment.test("reg", "query", p, "/reg:64"))
if (DesktopEnvironment.test("reg", "query", p))
return p;
}
 
return null;
}
 
127,8 → 123,7
// all string values for the passed registry path
private static Map<String, String> getStringValues(final String path, final String option) throws IOException {
final Map<String, String> values = new HashMap<String, String>();
// On force /reg:64 (utile si on utilise une VM 32 avec un systeme 64 bits)
final String out = DesktopEnvironment.cmdSubstitution(Runtime.getRuntime().exec(new String[] { "reg", "query", path, option, "/reg:64" }));
final String out = DesktopEnvironment.cmdSubstitution(Runtime.getRuntime().exec(new String[] { "reg", "query", path, option }));
final Matcher matcher = stringValuePattern.matcher(out);
while (matcher.find()) {
values.put(matcher.group(1), matcher.group(2));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/QteTotalDocProvider.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/provider/ArticleCodeFournisseurProvider.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/AbstractJOOReportsSheet.java
27,7 → 27,6
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
 
import java.awt.print.PrinterJob;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileNotFoundException;
246,13 → 245,9
return;
}
final Component doc = ooConnexion.loadDocument(fileOutOO, true);
if (this.printer != null && this.printer.trim().length() > 0) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("Name", this.printer);
map.put("Name", printer);
doc.printDocument(map);
} else {
doc.printDocument(PrinterJob.getPrinterJob());
}
doc.close();
} catch (LinkageError e) {
JOptionPane.showMessageDialog(new JFrame(), "Merci d'installer OpenOffice ou LibreOffice");
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/SheetXml.java
179,7 → 179,6
 
try {
if (!useODSViewer) {
if (exportToPDF || printDocument) {
final Component doc = ComptaPropsConfiguration.getOOConnexion().loadDocument(generatedFile, !showDocument);
 
if (printDocument) {
194,9 → 193,6
doc.close();
}
} else {
openDocument(false);
}
} else {
final OpenDocument doc = new OpenDocument(generatedFile);
 
if (showDocument) {
547,13 → 543,9
}
 
public void showPreviewDocument() throws Exception {
showPreviewDocument(null, null);
}
 
public void showPreviewDocument(String actionName, Runnable r) throws Exception {
File f = null;
f = getOrCreateDocumentFile();
PreviewFrame.show(f, actionName, r);
PreviewFrame.show(f);
}
 
public void printDocument() {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/gestcomm/EtatVentesXmlSheet.java
24,8 → 24,6
import org.openconcerto.sql.model.AliasedTable;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLSelectJoin;
import org.openconcerto.sql.model.SQLTable;
64,13 → 62,11
 
private Timestamp du, au;
public boolean ticketCaisse = false;
public boolean facture = false;
 
public EtatVentesXmlSheet(Date du, Date au, boolean ticketCaisse, boolean facture) {
public EtatVentesXmlSheet(Date du, Date au, boolean ticketCaisse) {
super();
this.printer = PrinterNXProps.getInstance().getStringProperty("BonPrinter");
this.ticketCaisse = ticketCaisse;
this.facture = facture;
if (du != null) {
final Calendar c1 = Calendar.getInstance();
c1.setTime(du);
132,11 → 128,7
styleAllSheetValues.put(0, style);
}
 
final ArrayList<Map<String, Object>> listValuesStock = new ArrayList<>();
final Map<Integer, String> styleStock = new HashMap<>();
 
// Ventes
final SQLTable foreignTableArticle = tableFactureElement.getForeignTable("ID_ARTICLE");
{
 
final AliasedTable tableModeReglement1 = new AliasedTable(tableModeReglement, MODE1);
143,17 → 135,6
final AliasedTable tableModeReglement2 = new AliasedTable(tableModeReglement, MODE2);
final AliasedTable tableTicket = new AliasedTable(eltTicketCaisse.getTable(), "ticket");
 
// Stock
SQLRowValues rowValsArtStock = new SQLRowValues(foreignTableArticle);
rowValsArtStock.putNulls("ID", "CODE", "NOM");
rowValsArtStock.putRowValues("ID_STOCK").putNulls("QTE_REEL", "QTE_TH", "QTE_MIN", "QTE_RECEPT_ATTENTE", "QTE_LIV_ATTENTE");
SQLRowValuesListFetcher fetcherStock = SQLRowValuesListFetcher.create(rowValsArtStock);
List<SQLRowValues> resultStock = fetcherStock.fetch();
Map<Integer, SQLRowValues> mapStock = new HashMap<>();
for (SQLRowValues sqlRowValues : resultStock) {
mapStock.put(sqlRowValues.getID(), sqlRowValues);
}
 
// Requete Pour obtenir les quantités pour chaque type de réglement
SQLSelect sel = new SQLSelect();
 
212,16 → 193,12
selQte.addSelect(tableFactureElement.getField("T_PV_TTC"), "SUM");
selQte.addSelect(tableFactureElement.getField("ID_TAXE"));
selQte.addSelect(tableFactureElement.getField("ID_ARTICLE"));
if (this.ticketCaisse) {
selQte.addJoin("LEFT", tableFactureElement.getField("ID_SAISIE_VENTE_FACTURE")).setWhere(Where.FALSE);
selQte.addJoin("LEFT", tableFactureElement.getField("ID_TICKET_CAISSE"), "ticket").setWhere(w2);
} else if (this.facture) {
if (!this.ticketCaisse) {
selQte.addJoin("LEFT", tableFactureElement.getField("ID_SAISIE_VENTE_FACTURE")).setWhere(w);
selQte.addJoin("LEFT", tableFactureElement.getField("ID_TICKET_CAISSE"), "ticket").setWhere(Where.FALSE);
} else {
selQte.addJoin("LEFT", tableFactureElement.getField("ID_SAISIE_VENTE_FACTURE")).setWhere(w);
selQte.addJoin("LEFT", tableFactureElement.getField("ID_SAISIE_VENTE_FACTURE")).setWhere(Where.FALSE);
}
selQte.addJoin("LEFT", tableFactureElement.getField("ID_TICKET_CAISSE"), "ticket").setWhere(w2);
}
SQLSelectJoin joinArt2 = selQte.addJoin("LEFT", tableFactureElement.getField("ID_ARTICLE"));
SQLSelectJoin joinFamArt2 = selQte.addJoin("LEFT", joinArt2.getJoinedTable().getField("ID_FAMILLE_ARTICLE"));
selQte.addSelect(joinFamArt2.getJoinedTable().getField("NOM"));
257,8 → 234,8
mapTVAVT.put(tvaID.intValue(), Tuple2.create(t.get0().add((BigDecimal) ht), t.get1().add(ttc)));
}
Number articleID = (Number) sqlRow[7];
ArticleVendu a = new ArticleVendu(code, nom, qteVendu.intValue(), (BigDecimal) ht, (BigDecimal) ha, ttc, tvaID.intValue(), foreignTableArticle.getRow(articleID.intValue()));
 
ArticleVendu a = new ArticleVendu(code, nom, qteVendu.intValue(), (BigDecimal) ht, (BigDecimal) ha, ttc, tvaID.intValue(),
tableFactureElement.getForeignTable("ID_ARTICLE").getRow(articleID.intValue()));
map.put(articleID + "##" + code + "##" + nom + "##" + tvaID, a);
 
}
279,8 → 256,6
mValues.put("NOM", famille);
style.put(listValues.size(), "Titre 1");
listValues.add(mValues);
styleStock.put(listValuesStock.size(), "Titre 1");
listValuesStock.add(mValues);
} else if (valueFam != null && !valueFam.toString().equalsIgnoreCase(famille)) {
famille = valueFam.toString();
Map<String, Object> mValues = new HashMap<String, Object>();
287,8 → 262,6
mValues.put("NOM", famille);
style.put(listValues.size(), "Titre 1");
listValues.add(mValues);
styleStock.put(listValuesStock.size(), "Titre 1");
listValuesStock.add(mValues);
}
 
Map<String, Object> mValues = new HashMap<String, Object>();
318,26 → 291,7
totalTPVTTC = totalTPVTTC.add(a.ttc);
style.put(listValues.size(), "Normal");
listValues.add(mValues);
 
Map<String, Object> mValuesStock = new HashMap<String, Object>();
mValuesStock.put("CODE", code);
mValuesStock.put("NOM", nom);
mValuesStock.put("QTE", a.qte);
if (mapStock.containsKey(articleID)) {
SQLRowValues rowValsArt = mapStock.get(articleID);
if (rowValsArt.getObject("ID_STOCK") != null && !rowValsArt.isForeignEmpty("ID_STOCK")) {
SQLRowAccessor rowValsStock = rowValsArt.getForeign("ID_STOCK");
mValuesStock.put("QTE_TH", rowValsStock.getObject("QTE_TH"));
mValuesStock.put("QTE_REEL", rowValsStock.getObject("QTE_REEL"));
mValuesStock.put("QTE_MIN", rowValsStock.getObject("QTE_MIN"));
mValuesStock.put("QTE_RECEPT_ATTENTE", rowValsStock.getObject("QTE_RECEPT_ATTENTE"));
mValuesStock.put("QTE_LIV_ATTENTE", rowValsStock.getObject("QTE_LIV_ATTENTE"));
}
styleStock.put(listValuesStock.size(), "Normal");
listValuesStock.add(mValuesStock);
}
 
}
// System.out.println("EtatVentesXmlSheet.createListeValues():" + listValues);
}
}
486,7 → 440,7
}
Number articleID = (Number) sqlRow[7];
ArticleVendu a = new ArticleVendu(code, nom, -qteVendu.intValue(), ((BigDecimal) ht).negate(), ((BigDecimal) ha).negate(), ttc.negate(), tvaID.intValue(),
foreignTableArticle.getRow(articleID.intValue()));
tableFactureElement.getForeignTable("ID_ARTICLE").getRow(articleID.intValue()));
map.put(articleID + "##" + code + "##" + nom + "##" + tvaID, a);
 
}
759,10 → 713,6
this.listAllSheetValues.put(3, listValuesTVA);
valuesTVA.put("DATE", periode);
this.mapAllSheetValues.put(3, valuesTVA);
 
this.listAllSheetValues.put(4, listValuesStock);
this.styleAllSheetValues.put(4, styleStock);
this.mapAllSheetValues.put(4, values);
}
 
public static SQLRow rowDefaultCptService, rowDefaultCptProduit;
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOXMLField.java
266,9 → 266,6
result += stringValue;
}
if (suffix != null) {
if (suffix.contains("#n")) {
suffix = suffix.replaceAll("#n", "\n");
}
result += suffix;
}
if (cellSize != null && cellSize.trim().length() != 0) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationDoc/OOgenerationXML.java
195,7 → 195,6
}
} catch (Exception e) {
ExceptionHandler.handle("Impossible de remplir le document " + templateId + " " + ((rowLanguage == null) ? "" : rowLanguage.getString("CHEMIN")), e);
e.printStackTrace();
return null;
}
 
445,12 → 444,6
}
calc.setRemise(valRemiseHTReel, totalAvtRemise);
 
// Fix TVA si nécessaire pour facture fournisseur
if (row.getTable().contains("TVA_ADJUSTMENT")) {
BigDecimal tvaFix = row.getBigDecimal("TVA_ADJUSTMENT");
calc.addTVAAdjust(tvaFix);
}
 
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);
497,20 → 490,6
 
calc.addLine(rowValsPort, rowValsPort.getForeign("ID_ARTICLE"), 1, false);
}
if (row.getTable().contains("FRAIS_DOCUMENT_HT") && row.getTable().contains("ID_TAXE_FRAIS_DOCUMENT")) {
BigDecimal fraisDoc = BigDecimal.valueOf(row.getLong("FRAIS_DOCUMENT_HT")).movePointLeft(2);
SQLRowAccessor tvafraisDoc = row.getForeign("ID_TAXE_FRAIS_DOCUMENT");
if (tvafraisDoc != null && fraisDoc.signum() != 0 && !tvafraisDoc.isUndefined()) {
SQLRowValues rowValsfraisDoc = new SQLRowValues(tableElt);
rowValsfraisDoc.put("T_PV_HT", fraisDoc);
rowValsfraisDoc.put("QTE", 1);
rowValsfraisDoc.put("ID_TAXE", tvafraisDoc.getIDNumber());
rowValsfraisDoc.put("SERVICE", Boolean.TRUE);
rowValsfraisDoc.put("ID_FAMILLE_ARTICLE", null);
calc.addLine(rowValsfraisDoc, null, 1, false);
}
}
 
calc.checkResult();
Map<SQLRowAccessor, Tuple2<BigDecimal, BigDecimal>> taxeCalc = calc.getMapHtTVARowTaux();
for (SQLRowAccessor sqlRow : taxeCalc.keySet()) {
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Piece.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Compte.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Exercice.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/AssociationAnalytique.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Journal.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/MouvementPostInsertionAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Mouvement.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/Ecriture.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtFactureFournisseur.java
166,10 → 166,6
}
}
this.putValue("ID_COMPTE_PCE", new Integer(idCompteFourn));
if (rowFournisseur.getTable().getTable("ECRITURE").contains("CODE_CLIENT")) {
this.putValue("CODE_CLIENT", rowFournisseur.getString("CODE"));
}
 
this.putValue("DEBIT", new Long(0));
if (rowFournisseur.getBoolean("UE")) {
this.putValue("CREDIT", new Long(htLongValue));
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationMvtDepotChequeClient.java
93,7 → 93,7
 
List<Integer> pieceIDs = new ArrayList<Integer>();
SQLRowValues rowValsDepotElt = new SQLRowValues(depot.getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
rowValsDepotElt.putNulls("MONTANT", "TIERS", "PIECE");
rowValsDepotElt.putNulls("MONTANT", "TIERS");
rowValsDepotElt.putRowValues("ID_CLIENT").putNulls("NOM", "ID_COMPTE_PCE");
final SQLRowValues rowValuesChq = rowValsDepotElt.putRowValues("ID_CHEQUE_A_ENCAISSER");
rowValuesChq.putNulls("SANS_VALEUR_ENCAISSEMENT").putRowValues("ID_MOUVEMENT").putNulls("ID_PIECE");
102,7 → 102,7
for (SQLRowValues sqlRowAccessor : cheques) {
final SQLRowAccessor clientRow = sqlRowAccessor.getForeign("ID_CLIENT");
// this.nom = this.nom + " " + StringUtils.limitLength(clientRow.getString("NOM"), 20);
this.putValue("NOM", this.nom + " " + sqlRowAccessor.getString("PIECE") + " " + StringUtils.limitLength(clientRow.getString("NOM"), 20));
this.putValue("NOM", this.nom + " " + StringUtils.limitLength(clientRow.getString("NOM"), 20));
SQLRowAccessor chequeRow = sqlRowAccessor.getForeign("ID_CHEQUE_A_ENCAISSER");
pieceIDs.add(chequeRow.getForeign("ID_MOUVEMENT").getForeignID("ID_PIECE"));
// compte Clients
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationEcritures.java
396,10 → 396,6
if (tiers.getObject("ID_CATEGORIE_COMPTABLE") != null && !tiers.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
rowCatCompta = tiers.getForeign("ID_CATEGORIE_COMPTABLE");
}
 
if (row.getTable().contains("ID_CATEGORIE_COMPTABLE") && row.getObject("ID_CATEGORIE_COMPTABLE") != null && !row.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
rowCatCompta = row.getForeign("ID_CATEGORIE_COMPTABLE");
}
TotalCalculator calc = new TotalCalculator("T_PA_HT", fieldTotalHT, null, achat, defaultCompte, rowCatCompta);
calc.setIntraComm(intra);
 
440,7 → 436,6
calc.addEchantillon((BigDecimal) sqlRow.getObject("T_PV_HT"), sqlRow.getForeign("ID_TAXE"));
}
}
 
calc.checkResult();
totalAvtRemise = calc.getTotalHT();
}
519,12 → 514,6
calc.addLine(rowValsFraisDoc, null, 1, false);
}
 
// Fix TVA si nécessaire pour facture fournisseur
if (row.getTable().contains("TVA_ADJUSTMENT")) {
BigDecimal tvaFix = row.getBigDecimal("TVA_ADJUSTMENT");
calc.addTVAAdjust(tvaFix);
}
 
calc.checkResult();
return calc;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/generationEcritures/GenerationReglementVenteNG.java
392,12 → 392,7
}
}
 
int idJournal = JournalSQLElement.BANQUES;
if (rowPrefsCompte.getObject("ID_JOURNAL_VALEUR_ENCAISSEMENT") != null && !rowPrefsCompte.isForeignEmpty("ID_JOURNAL_VALEUR_ENCAISSEMENT")) {
idJournal = rowPrefsCompte.getForeignID("ID_JOURNAL_VALEUR_ENCAISSEMENT");
}
this.putValue("ID_JOURNAL", idJournal);
this.putValue("ID_JOURNAL", JournalSQLElement.BANQUES);
this.putValue("ID_COMPTE_PCE", idCompteClient);
this.putValue("DEBIT", Long.valueOf(0));
this.putValue("CREDIT", Long.valueOf(ttc.getLongValue()));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractArticleItemTable.java
74,7 → 74,7
protected SQLRowAccessor rowCatComptable;
private RowValuesTableModel model;
protected SQLRowValues defaultRowVals;
protected List<JButton> buttons = null;
private List<JButton> buttons = null;
protected RowValuesTableControlPanel control = null;
private SQLRowAccessor tarif = null;
 
344,16 → 344,6
}
}
 
private SQLRowAccessor rowClient = null;
 
public SQLRowAccessor getRowClient() {
return rowClient;
}
 
public void setClient(SQLRowAccessor rowClient, boolean ask) {
this.rowClient = rowClient;
}
 
protected void calculTarifNomenclature() {
 
if (this.model.getRowCount() == 0) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractVenteArticleItemTable.java
26,7 → 26,6
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
import org.openconcerto.erp.core.sales.product.ui.QteMultipleRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
import org.openconcerto.erp.importer.ArrayTableModel;
import org.openconcerto.erp.importer.DataImporter;
import org.openconcerto.erp.preferences.DefaultNXProps;
49,8 → 48,6
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
import org.openconcerto.sql.users.rights.UserRights;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.AutoCompletionManager;
import org.openconcerto.sql.view.list.CellDynamicModifier;
import org.openconcerto.sql.view.list.RowValuesTable;
73,7 → 70,6
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.awt.event.KeyEvent;
96,8 → 92,6
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
293,10 → 287,6
 
list.add(new SQLTableElement(e.getTable().getField("ID_STYLE")));
 
if (e.getTable().contains("ID_COMPTE_PCE")) {
list.add(new SQLTableElement(e.getTable().getField("ID_COMPTE_PCE")));
}
 
final SQLTableElement tableFamille = new SQLTableElement(e.getTable().getField("ID_FAMILLE_ARTICLE"));
list.add(tableFamille);
 
653,9 → 643,7
return isCellNiveauEditable(vals, rowIndex, columnIndex);
}
};
CurrencyWithSymbolRenderer totalRenderer = new CurrencyWithSymbolRenderer();
totalRenderer.setHideZeroValue(true);
this.totalHT.setRenderer(totalRenderer);
this.totalHT.setRenderer(new CurrencyWithSymbolRenderer());
this.totalHT.setEditable(false);
if (e.getTable().getFieldsName().contains("MONTANT_FACTURABLE")) {
// SQLTableElement tableElementAcompte = new
739,7 → 727,7
 
// Total HT
this.totalHA = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
this.totalHA.setRenderer(totalRenderer);
this.totalHA.setRenderer(new CurrencyWithSymbolRenderer());
this.totalHA.setEditable(false);
list.add(this.totalHA);
 
752,10 → 740,8
}
};
Path p = new Path(getSQLElement().getTable()).addForeignField("ID_DEVISE");
CurrencyWithSymbolRenderer currencyRenderer = new CurrencyWithSymbolRenderer(new FieldPath(p, "CODE"));
currencyRenderer.setHideZeroValue(true);
this.tableElementTotalDevise.setRenderer(currencyRenderer);
list.add(this.tableElementTotalDevise);
this.tableElementTotalDevise.setRenderer(new CurrencyWithSymbolRenderer(new FieldPath(p, "CODE")));
list.add(tableElementTotalDevise);
}
 
// Marge HT
772,7 → 758,7
}
 
};
marge.setRenderer(totalRenderer);
marge.setRenderer(new CurrencyWithSymbolRenderer());
marge.setEditable(false);
list.add(marge);
this.totalHT.addModificationListener(marge);
848,7 → 834,7
return isCellNiveauEditable(vals, rowIndex, columnIndex);
}
};
this.tableElementTotalTTC.setRenderer(totalRenderer);
this.tableElementTotalTTC.setRenderer(new CurrencyWithSymbolRenderer());
this.tableElementTotalTTC.setEditable(false);
list.add(this.tableElementTotalTTC);
 
877,44 → 863,6
ToolTipManager.sharedInstance().unregisterComponent(this.table);
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
 
this.table.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
displayPopupMenu(e);
}
}
 
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
displayPopupMenu(e);
}
}
 
private void displayPopupMenu(MouseEvent e) {
JPopupMenu menu = new JPopupMenu();
 
TaxeCache cache = TaxeCache.getCache();
Set<SQLRowAccessor> taxes = cache.getAllTaxe();
JMenu subMenuTVA = new JMenu("Appliquer une TVA spécifique sur toutes les lignes");
menu.add(subMenuTVA);
for (SQLRowAccessor taxe : taxes) {
 
subMenuTVA.add(new JMenuItem(new AbstractAction(taxe.getFloat("TAUX") + "%") {
 
@Override
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < AbstractVenteArticleItemTable.this.table.getRowCount(); i++) {
AbstractVenteArticleItemTable.this.table.getRowValuesTableModel().putValue(taxe.getID(), i, "ID_TAXE");
}
}
}));
}
menu.show(e.getComponent(), e.getX(), e.getY());
}
});
 
if (filterFamilleArticle) {
((SQLTextComboTableCellEditor) tableElementArticle.getTableCellEditor(this.table)).setDynamicWhere(e.getTable().getTable("ARTICLE").getField("ID_FAMILLE_ARTICLE"));
}
965,13 → 913,11
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
return super.getValueFrom(row, field, rowDest);
} else {
return res;
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
return res;
}
 
};
m.fill("NOM", "NOM");
1063,13 → 1009,11
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
return super.getValueFrom(row, field, rowDest);
} else {
return res;
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
return res;
}
 
};
m2.fill("CODE", "CODE");
1086,13 → 1030,11
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
return super.getValueFrom(row, field, rowDest);
} else {
return res;
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
return res;
}
 
};
m3.fill("CODE", "CODE");
1585,72 → 1527,8
// On réécrit la configuration au cas ou les preferences aurait changé (ajout ou suppression
// du mode de vente specifique)
this.table.writeState();
 
if (this.table.getRowValuesTableModel().getColumnForField("ID_DEPOT_STOCK") >= 0 && this.table.getRowValuesTableModel().getColumnForField("ID_ARTICLE") >= 0) {
if (this.buttons == null) {
this.buttons = new ArrayList<>();
}
 
JButton buttonStock = new JButton("Consulter le stock");
buttonStock.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
SQLRowValues rowValsSel = table.getSelectedRowValues();
if (rowValsSel != null) {
SQLRowAccessor foreignArt = rowValsSel.getForeign("ID_ARTICLE");
if (foreignArt != null && !foreignArt.isUndefined()) {
SQLRowAccessor rowValsStock = StockSQLElement.getStock(rowValsSel);
if (rowValsStock != null && !rowValsStock.isUndefined()) {
EditFrame frame = new EditFrame(table.getRowValuesTableModel().getSQLElement().getDirectory().getElement("STOCK"), EditMode.READONLY);
frame.selectionId(rowValsStock.getID());
frame.setVisible(true);
}
}
}
 
}
});
 
this.buttons.add(buttonStock);
 
}
 
}
 
Collection<? extends SQLRowAccessor> cacheRemise = null;
 
protected BigDecimal getTarifRemiseClient(SQLRowAccessor article, BigDecimal pv) {
if (cacheRemise != null) {
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
for (SQLRowAccessor sqlRowAccessor : cacheRemise) {
if (!sqlRowAccessor.isForeignEmpty("ID_ARTICLE") && sqlRowAccessor.getForeignID("ID_ARTICLE") == article.getID()) {
BigDecimal remise = sqlRowAccessor.getBigDecimal("POURCENT_REMISE");
if (remise != null) {
return pv.multiply(BigDecimal.ONE.subtract(remise.movePointLeft(2)), DecimalUtils.HIGH_PRECISION).setScale(pv.scale(), RoundingMode.HALF_UP);
}
}
}
}
}
return pv;
}
 
protected Acompte getRemiseClient(SQLRowAccessor article) {
Acompte remise = new Acompte(BigDecimal.ZERO, BigDecimal.ZERO);
if (this.cacheRemise != null) {
if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
for (SQLRowAccessor sqlRowAccessor : this.cacheRemise) {
if (!sqlRowAccessor.isForeignEmpty("ID_ARTICLE") && sqlRowAccessor.getForeignID("ID_ARTICLE") == article.getID()) {
BigDecimal r = sqlRowAccessor.getBigDecimal("POURCENT_REMISE");
if (remise != null) {
remise = new Acompte(r, null);
}
}
}
}
}
return remise;
}
 
@Override
protected void refreshDeviseAmount() {
int count = getRowValuesTable().getRowCount();
1793,40 → 1671,6
}
 
@Override
public void setClient(SQLRowAccessor rowClient, boolean ask) {
if (rowClient == null || getRowClient() == null || rowClient.getID() != getRowClient().getID()) {
super.setClient(rowClient, ask);
if (getRowClient() != null && !getRowClient().isUndefined()) {
this.cacheRemise = getRowClient().getReferentRows(getSQLElement().getTable().getTable("TARIF_ARTICLE_CLIENT"));
if (ask && getRowValuesTable().getRowCount() > 0
&& JOptionPane.showConfirmDialog(null, "Appliquer les remises associées au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) {
int nbRows = this.table.getRowCount();
for (int i = 0; i < nbRows; i++) {
SQLRowValues rowVals = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(i);
 
if (!rowVals.isForeignEmpty("ID_ARTICLE")) {
SQLRowAccessor rowValsArt = rowVals.getForeign("ID_ARTICLE");
final Object taxeValue = tarifCompletion(rowValsArt, "ID_TAXE", rowVals);
if (taxeValue != null) {
getRowValuesTable().getRowValuesTableModel().putValue(taxeValue, i, "ID_TAXE");
}
 
final Object deviseValue = tarifCompletion(rowValsArt, "ID_DEVISE", rowVals);
if (deviseValue != null) {
getRowValuesTable().getRowValuesTableModel().putValue(deviseValue, i, "ID_DEVISE");
}
getRowValuesTable().getRowValuesTableModel().putValue(tarifCompletion(rowValsArt, "PV_U_DEVISE", rowVals), i, "PV_U_DEVISE");
getRowValuesTable().getRowValuesTableModel().putValue(tarifCompletion(rowValsArt, "PRIX_METRIQUE_VT_1", rowVals), i, "PRIX_METRIQUE_VT_1");
}
}
}
} else {
this.cacheRemise = null;
}
}
}
 
@Override
public void setTarif(SQLRowAccessor rowValuesTarif, boolean ask) {
if (rowValuesTarif == null || getTarif() == null || rowValuesTarif.getID() != getTarif().getID()) {
super.setTarif(rowValuesTarif, ask);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/NumericTextField.java
53,7 → 53,7
this(15);
}
 
public NumericTextField(int columns) {
private NumericTextField(int columns) {
super(columns);
 
this.supp = new PropertyChangeSupport(this);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/DeviseTableCellRenderer.java
28,7 → 28,6
private final DecimalFormat decimalFormat;
private final DecimalFormat decimalFormat2;
private BigDecimal oneCents = new BigDecimal(0.01f);
private boolean hideZeroValue = false;
 
public DeviseTableCellRenderer() {
this(new DecimalFormat("##,##0.00#"), new DecimalFormat("##,##0.00#######"));
43,10 → 42,6
decimalFormat2.setDecimalFormatSymbols(symbol);
}
 
public void setHideZeroValue(boolean hideZeroValue) {
this.hideZeroValue = hideZeroValue;
}
 
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
TableCellRendererUtils.setColors(this, table, isSelected);
54,17 → 49,11
if (table.getColumnClass(column) != BigDecimal.class) {
throw new IllegalStateException("Value is not a BigDecimal :" + table.getColumnClass(column));
}
 
if (value != null) {
BigDecimal amount = (BigDecimal) value;
if (this.hideZeroValue && amount.signum() == 0) {
this.setText("");
} else {
if (amount.compareTo(oneCents) < 0)
if (((BigDecimal) value).compareTo(oneCents) < 0)
this.setText(decimalFormat2.format(value));
else
this.setText(decimalFormat.format(value));
}
} else {
this.setText("");
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/PreviewFrame.java
21,8 → 21,6
 
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.Paper;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
37,8 → 35,6
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.MediaPrintableArea;
import javax.print.attribute.standard.MediaSizeName;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
52,31 → 48,16
 
private PreviewFrame(OpenDocument doc, String title) {
super(title);
final ODSViewerPanel viewerPanel = new ODSViewerPanel(doc, createDocumentPrinter());
this.setContentPane(viewerPanel);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setContentPane(new ODSViewerPanel(doc, createDocumentPrinter()));
init();
}
 
public PreviewFrame(String title, String url, String odspXml) {
final ODSViewerPanel contentPane = new ODSViewerPanel(url, odspXml, createDocumentPrinter(), true);
 
this.setContentPane(contentPane);
this.setContentPane(new ODSViewerPanel(url, odspXml, createDocumentPrinter(), true));
this.setTitle(title);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
init();
}
 
public void addTool(String n, Runnable r) {
JButton b = new JButton(n);
((ODSViewerPanel) this.getContentPane()).addTool(b);
b.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
r.run();
}
});
}
 
public DefaultXMLDocumentPrinter createDocumentPrinter() {
return new DefaultXMLDocumentPrinter() {
public void print(List<OpenDocument> documents) {
95,6 → 76,7
final MediaPrintableArea printableArea = new MediaPrintableArea((float) (paper.getImageableX() / POINTS_PER_INCH), (float) (paper.getImageableY() / POINTS_PER_INCH),
(float) (paper.getImageableWidth() / POINTS_PER_INCH), (float) (paper.getImageableHeight() / POINTS_PER_INCH), Size2DSyntax.INCH);
attributes.add(printableArea);
attributes.add(new Copies(2));
// Print dialog
boolean okToPrint = printJob.printDialog(attributes);
final Attribute attribute = attributes.get(Copies.class);
131,13 → 113,12
 
}
 
@Override
public void pack() {
private void init() {
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
this.setMaximizedBounds(ge.getMaximumWindowBounds());
final Dimension maxD = ge.getMaximumWindowBounds().getSize();
this.setMaximumSize(maxD);
super.pack();
this.pack();
Dimension d = this.getSize();
if (d.width > maxD.width) {
d.setSize(maxD.width, d.height);
145,34 → 126,23
if (d.height > maxD.height) {
d.setSize(d.width, maxD.height);
}
this.setSize(d);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 
this.setLocationRelativeTo(null);
}
 
public static void show(File file) {
show(file, null, null);
}
 
public static void show(File file, String actionName, Runnable r) {
final OpenDocument doc = new OpenDocument(file);
final String title = file.getName();
if (SwingUtilities.isEventDispatchThread()) {
PreviewFrame previewFrame = new PreviewFrame(doc, title);
if (r != null) {
previewFrame.addTool(actionName, r);
}
previewFrame.pack();
previewFrame.setVisible(true);
new PreviewFrame(doc, title).setVisible(true);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
PreviewFrame previewFrame = new PreviewFrame(doc, title);
if (r != null) {
previewFrame.addTool(actionName, r);
new PreviewFrame(doc, title).setVisible(true);
}
previewFrame.pack();
previewFrame.setVisible(true);
}
});
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalCalculator.java
21,6 → 21,8
import org.openconcerto.sql.model.SQLBackgroundTableCacheItem;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.utils.DecimalUtils;
31,6 → 33,7
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
176,7 → 179,7
}
 
public void retoreRowDefaultCptProduit() {
this.rowDefaultCptProduit = this.rowDefaultCptProduitStandard;
this.rowDefaultCptProduit = rowDefaultCptProduitStandard;
}
 
/**
191,55 → 194,6
this.totalHTAvantRemise = totalHTAvantRemise;
}
 
public void addTVAAdjust(BigDecimal tvaFix) {
 
final SQLBackgroundTableCacheItem cacheForTableCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(this.compteTable);
 
SQLRowAccessor tva = TaxeCache.getCache().getFirstTaxe();
 
SQLRowAccessor rowCptTva;
if (this.intraComm) {
 
// Intra comm TTC=HT et solde de TVA
rowCptTva = cacheForTableCompte.getRowFromId(tva.getForeignID("ID_COMPTE_PCE_DED_INTRA"));
if (rowCptTva == null || rowCptTva.isUndefined()) {
rowCptTva = this.rowDefaultCptTVADeductible;
}
 
SQLRowAccessor rowCptTvaIntra = cacheForTableCompte.getRowFromId(tva.getForeignID("ID_COMPTE_PCE_COLLECTE_INTRA"));
if (rowCptTvaIntra == null || rowCptTvaIntra.isUndefined()) {
rowCptTvaIntra = this.rowDefaultCptTVADeductible;
}
 
if (this.mapHtTVAIntra.get(rowCptTvaIntra) == null) {
this.mapHtTVAIntra.put(rowCptTvaIntra, tvaFix);
} else {
BigDecimal l = this.mapHtTVAIntra.get(rowCptTvaIntra);
this.mapHtTVAIntra.put(rowCptTvaIntra, l.add(tvaFix));
}
 
} else if (this.achat) {
rowCptTva = cacheForTableCompte.getRowFromId(tva.getForeignID("ID_COMPTE_PCE_DED"));
if (rowCptTva == null || rowCptTva.isUndefined()) {
rowCptTva = this.rowDefaultCptTVADeductible;
}
} else {
rowCptTva = cacheForTableCompte.getRowFromId(tva.getForeignID("ID_COMPTE_PCE_COLLECTE"));
if (rowCptTva == null || rowCptTva.isUndefined()) {
rowCptTva = this.rowDefaultCptTVACollecte;
}
}
if (this.mapHtTVA.get(rowCptTva) == null) {
this.mapHtTVA.put(rowCptTva, tvaFix);
} else {
BigDecimal l = this.mapHtTVA.get(rowCptTva);
this.mapHtTVA.put(rowCptTva, l.add(tvaFix));
}
 
this.totalTTC = this.totalTTC.add(tvaFix);
 
}
 
/**
* Gestion de la vente de service
*
310,48 → 264,44
*/
private void fetchTVA() {
mapTVA = new HashMap<Integer, SQLRowAccessor>();
Set<SQLRowAccessor> taxes = TaxeCache.getCache().getAllTaxe();
for (SQLRowAccessor sqlRowAccessor : taxes) {
mapTVA.put(sqlRowAccessor.getID(), sqlRowAccessor);
SQLRowValues rowVals = new SQLRowValues(tvaTable);
SQLRowValues rowValsC1 = new SQLRowValues(compteTable);
rowValsC1.put("NUMERO", null);
rowValsC1.put("ID", null);
 
SQLRowValues rowValsC2 = new SQLRowValues(compteTable);
rowValsC2.put("NUMERO", null);
rowValsC2.put("ID", null);
 
SQLRowValues rowValsC3 = new SQLRowValues(compteTable);
rowValsC3.put("NUMERO", null);
rowValsC3.put("ID", null);
SQLRowValues rowValsC4 = new SQLRowValues(compteTable);
rowValsC4.put("NUMERO", null);
rowValsC4.put("ID", null);
 
rowVals.put(tvaTable.getKey().getName(), null);
rowVals.put("ID_COMPTE_PCE_COLLECTE", rowValsC1);
rowVals.put("ID_COMPTE_PCE_DED", rowValsC2);
rowVals.put("ID_COMPTE_PCE_VENTE", rowValsC3);
rowVals.put("ID_COMPTE_PCE_VENTE_SERVICE", rowValsC4);
 
if (tvaTable.contains("ID_COMPTE_PCE_COLLECTE_INTRA")) {
SQLRowValues rowValsC1Intra = new SQLRowValues(compteTable);
rowValsC1Intra.put("NUMERO", null);
rowValsC1Intra.put("ID", null);
rowVals.put("ID_COMPTE_PCE_COLLECTE_INTRA", rowValsC1Intra);
SQLRowValues rowValsC2Intra = new SQLRowValues(compteTable);
rowValsC2Intra.put("NUMERO", null);
rowValsC2Intra.put("ID", null);
rowVals.put("ID_COMPTE_PCE_DED_INTRA", rowValsC2Intra);
}
// SQLRowValues rowVals = new SQLRowValues(this.tvaTable);
// SQLRowValues rowValsC1 = new SQLRowValues(this.compteTable);
// rowValsC1.put("NUMERO", null);
// rowValsC1.put("ID", null);
//
// SQLRowValues rowValsC2 = new SQLRowValues(this.compteTable);
// rowValsC2.put("NUMERO", null);
// rowValsC2.put("ID", null);
//
// SQLRowValues rowValsC3 = new SQLRowValues(this.compteTable);
// rowValsC3.put("NUMERO", null);
// rowValsC3.put("ID", null);
// SQLRowValues rowValsC4 = new SQLRowValues(this.compteTable);
// rowValsC4.put("NUMERO", null);
// rowValsC4.put("ID", null);
//
// rowVals.put(this.tvaTable.getKey().getName(), null);
// rowVals.put("ID_COMPTE_PCE_COLLECTE", rowValsC1);
// rowVals.put("ID_COMPTE_PCE_DED", rowValsC2);
// rowVals.put("ID_COMPTE_PCE_VENTE", rowValsC3);
// rowVals.put("ID_COMPTE_PCE_VENTE_SERVICE", rowValsC4);
//
// if (this.tvaTable.contains("ID_COMPTE_PCE_COLLECTE_INTRA")) {
// SQLRowValues rowValsC1Intra = new SQLRowValues(this.compteTable);
// rowValsC1Intra.put("NUMERO", null);
// rowValsC1Intra.put("ID", null);
// rowVals.put("ID_COMPTE_PCE_COLLECTE_INTRA", rowValsC1Intra);
// SQLRowValues rowValsC2Intra = new SQLRowValues(this.compteTable);
// rowValsC2Intra.put("NUMERO", null);
// rowValsC2Intra.put("ID", null);
// rowVals.put("ID_COMPTE_PCE_DED_INTRA", rowValsC2Intra);
// }
// SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
// List<SQLRowValues> rowValsList = fetch.fetch();
//
// for (SQLRowValues sqlRowValues : rowValsList) {
// mapTVA.put(sqlRowValues.getID(), sqlRowValues);
// }
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
List<SQLRowValues> rowValsList = fetch.fetch();
 
for (SQLRowValues sqlRowValues : rowValsList) {
mapTVA.put(sqlRowValues.getID(), sqlRowValues);
}
lastTVAfetchedTime = System.currentTimeMillis();
}
 
385,11 → 335,11
rowCptTvaIntra = this.rowDefaultCptTVADeductible;
}
 
if (this.mapHtTVAIntra.get(rowCptTvaIntra) == null) {
this.mapHtTVAIntra.put(rowCptTvaIntra, totalTVA);
if (mapHtTVAIntra.get(rowCptTvaIntra) == null) {
mapHtTVAIntra.put(rowCptTvaIntra, totalTVA);
} else {
BigDecimal l = this.mapHtTVAIntra.get(rowCptTvaIntra);
this.mapHtTVAIntra.put(rowCptTvaIntra, l.add(totalTVA));
BigDecimal l = mapHtTVAIntra.get(rowCptTvaIntra);
mapHtTVAIntra.put(rowCptTvaIntra, l.add(totalTVA));
}
 
ttc = ht;
404,35 → 354,35
rowCptTva = this.rowDefaultCptTVACollecte;
}
}
if (this.mapHtTVA.get(rowCptTva) == null) {
this.mapHtTVA.put(rowCptTva, totalTVA);
if (mapHtTVA.get(rowCptTva) == null) {
mapHtTVA.put(rowCptTva, totalTVA);
} else {
BigDecimal l = this.mapHtTVA.get(rowCptTva);
this.mapHtTVA.put(rowCptTva, l.add(totalTVA));
BigDecimal l = mapHtTVA.get(rowCptTva);
mapHtTVA.put(rowCptTva, l.add(totalTVA));
}
if (ht.signum() != 0) {
if (this.mapHtTVARowTaux.get(tva) == null) {
this.mapHtTVARowTaux.put(tva, Tuple2.create(ht, totalTVA));
if (mapHtTVARowTaux.get(tva) == null) {
mapHtTVARowTaux.put(tva, Tuple2.create(ht, totalTVA));
} else {
Tuple2<BigDecimal, BigDecimal> l = this.mapHtTVARowTaux.get(tva);
this.mapHtTVARowTaux.put(tva, Tuple2.create(ht.add(l.get0()), l.get1().add(totalTVA)));
Tuple2<BigDecimal, BigDecimal> l = mapHtTVARowTaux.get(tva);
mapHtTVARowTaux.put(tva, Tuple2.create(ht.add(l.get0()), l.get1().add(totalTVA)));
}
}
if (selection) {
if (this.mapHtTVASel.get(rowCptTva) == null) {
this.mapHtTVASel.put(rowCptTva, totalTVA);
if (mapHtTVASel.get(rowCptTva) == null) {
mapHtTVASel.put(rowCptTva, totalTVA);
} else {
BigDecimal l = this.mapHtTVASel.get(rowCptTva);
this.mapHtTVASel.put(rowCptTva, l.add(totalTVA));
BigDecimal l = mapHtTVASel.get(rowCptTva);
mapHtTVASel.put(rowCptTva, l.add(totalTVA));
}
}
}
 
if (this.mapHt.get(cptArticle) == null) {
this.mapHt.put(cptArticle, ht);
if (mapHt.get(cptArticle) == null) {
mapHt.put(cptArticle, ht);
} else {
BigDecimal l = this.mapHt.get(cptArticle);
this.mapHt.put(cptArticle, l.add(ht));
BigDecimal l = mapHt.get(cptArticle);
mapHt.put(cptArticle, l.add(ht));
}
 
this.totalTTC = this.totalTTC.add(ttc);
439,11 → 389,11
this.totalHTSansFActurable = this.totalHTSansFActurable.add(htSansFacturable);
if (selection) {
 
if (this.mapHtSel.get(cptArticle) == null) {
this.mapHtSel.put(cptArticle, ht);
if (mapHtSel.get(cptArticle) == null) {
mapHtSel.put(cptArticle, ht);
} else {
BigDecimal l = this.mapHtSel.get(cptArticle);
this.mapHtSel.put(cptArticle, l.add(ht));
BigDecimal l = mapHtSel.get(cptArticle);
mapHtSel.put(cptArticle, l.add(ht));
}
this.totalTTCSel = this.totalTTCSel.add(ttc);
}
469,11 → 419,11
}
 
// Total HT de la ligne
BigDecimal totalLineHT = rowAccessorLine.getObject(this.fieldHT) == null ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject(this.fieldHT);
BigDecimal totalLineHT = rowAccessorLine.getObject(fieldHT) == null ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject(fieldHT);
BigDecimal totalLineEco = rowAccessorLine.getObject("T_ECO_CONTRIBUTION") == null ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject("T_ECO_CONTRIBUTION");
 
BigDecimal totalLineHTSansFacturable = totalLineHT;
if (!this.achat) {
if (!achat) {
totalLineHTSansFacturable = rowAccessorLine.getObject("PV_HT") == null ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject("PV_HT");
BigDecimal qteUV = rowAccessorLine.getObject("QTE_UNITAIRE") == null ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject("QTE_UNITAIRE");
int qte = rowAccessorLine.getInt("QTE");
481,11 → 431,11
}
// Prix Unitaire de la ligne
// TODO voir pour passer le prix total et non le prix unitaire
BigDecimal totalHALigne = rowAccessorLine.getObject(this.fieldHA) == null ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject(this.fieldHA);
BigDecimal totalHALigne = rowAccessorLine.getObject(fieldHA) == null ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject(fieldHA);
 
Boolean service = rowAccessorLine.getBoolean(FIELD_SERVICE);
 
BigDecimal totalLineDevise = (this.fieldDevise == null || rowAccessorLine.getObject(this.fieldDevise) == null) ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject(this.fieldDevise);
BigDecimal totalLineDevise = (fieldDevise == null || rowAccessorLine.getObject(fieldDevise) == null) ? BigDecimal.ZERO : (BigDecimal) rowAccessorLine.getObject(fieldDevise);
 
Number nPoids = (Number) rowAccessorLine.getObject(FIELD_POIDS);
 
522,13 → 472,13
}
SQLRowAccessor tva = mapTVA.get(idTVA);
 
SQLRowAccessor cpt = (this.achat ? this.rowDefaultCptAchat : this.rowDefaultCptProduit);
SQLRowAccessor cpt = (achat ? this.rowDefaultCptAchat : this.rowDefaultCptProduit);
final SQLBackgroundTableCacheItem cacheForTableCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(cpt.getTable());
 
if (!this.achat) {
if (!achat) {
// Total Service
if (this.bServiceActive != null && this.bServiceActive && service != null && service.booleanValue()) {
this.totalService = this.totalService.add(totalLineHT);
if (bServiceActive != null && bServiceActive && service != null && service.booleanValue()) {
totalService = totalService.add(totalLineHT);
cpt = this.rowDefaultCptService;
if (tva != null && !tva.isForeignEmpty("ID_COMPTE_PCE_VENTE_SERVICE")) {
cpt = cacheForTableCompte.getRowFromId(tva.getForeignID("ID_COMPTE_PCE_VENTE_SERVICE"));
541,23 → 491,15
 
}
}
 
// Compte PCE défini directement sur la ligne
boolean compteSpec = false;
if (rowAccessorLine.getTable().contains("ID_COMPTE_PCE") && rowAccessorLine.getObject("ID_COMPTE_PCE") != null && !rowAccessorLine.isForeignEmpty("ID_COMPTE_PCE")) {
compteSpec = true;
cpt = cacheForTableCompte.getRowFromId(rowAccessorLine.getForeignID("ID_COMPTE_PCE"));
}
if (article != null && !article.isUndefined()) {
if (!compteSpec) {
SQLRowAccessor cptCatComptable = null;
// TODO Optimiser les requetes
if (this.rowCatComptable != null && !this.rowCatComptable.isUndefined()) {
if (rowCatComptable != null && !rowCatComptable.isUndefined()) {
String suffix = (this.achat ? "_ACHAT" : "_VENTE");
Collection<? extends SQLRowAccessor> rows = article.getReferentRows(this.compteTable.getTable("ARTICLE_CATEGORIE_COMPTABLE"));
Collection<? extends SQLRowAccessor> rows = article.getReferentRows(compteTable.getTable("ARTICLE_CATEGORIE_COMPTABLE"));
for (SQLRowAccessor sqlRowAccessor : rows) {
if (sqlRowAccessor.getForeignID("ID_CATEGORIE_COMPTABLE") == this.rowCatComptable.getID()) {
cptCatComptable = cacheForTableCompte.getRowFromId(this.rowCatComptable.getForeignID("ID_COMPTE_PCE" + suffix));
cptCatComptable = cacheForTableCompte.getRowFromId(rowCatComptable.getForeignID("ID_COMPTE_PCE" + suffix));
}
}
}
586,8 → 528,7
} else {
cpt = cptCatComptable;
}
}
if (!this.achat) {
if (!achat) {
SQLRowAccessor taxeCompl = (article.getFields().contains("ID_TAXE_COMPLEMENTAIRE") && article.getObject("ID_TAXE_COMPLEMENTAIRE") != null
&& !article.isForeignEmpty("ID_TAXE_COMPLEMENTAIRE") ? article.getForeign("ID_TAXE_COMPLEMENTAIRE") : null);
if (taxeCompl != null && !taxeCompl.isUndefined()) {
607,11 → 548,11
}
}
 
if (!compteSpec) {
if (achat) {
// Total Service
if (this.bServiceActive != null && this.bServiceActive) {
if (bServiceActive != null && bServiceActive) {
if (service != null && service.booleanValue()) {
this.totalService = this.totalService.add(totalLineHT);
totalService = totalService.add(totalLineHT);
cpt = this.rowDefaultCptService;
}
}
622,31 → 563,31
 
// Total Devise
if (totalLineDevise != null) {
this.totalDevise = this.totalDevise.add(totalLineDevise);
totalDevise = totalDevise.add(totalLineDevise);
}
 
// Total Poids
 
this.totalPoids += nPoids == null ? 0 : nPoids.doubleValue();
totalPoids += nPoids == null ? 0 : nPoids.doubleValue();
 
// Eco-contribution
this.totalEco = this.totalEco.add(totalLineEco);
 
// Calcul total sélectionné
boolean selection = containsInt(this.selectedRows, lineNumber);
boolean selection = containsInt(selectedRows, lineNumber);
if (selection) {
 
this.totalHASel = this.totalHASel.add(totalHALigne);
totalHASel = totalHASel.add(totalHALigne);
 
if (this.bServiceActive != null && this.bServiceActive) {
if (bServiceActive != null && bServiceActive) {
if (service != null && service.booleanValue()) {
this.totalServiceSel = this.totalServiceSel.add(totalLineHT);
totalServiceSel = totalServiceSel.add(totalLineHT);
}
}
this.totalEcoSel = this.totalEcoSel.add(totalLineEco);
 
if (totalLineDevise != null) {
this.totalDeviseSel = this.totalDeviseSel.add(totalLineDevise);
totalDeviseSel = totalDeviseSel.add(totalLineDevise);
}
}
 
661,7 → 602,7
BigDecimal tva = getTotalTVA();
BigDecimal totalTTC2 = getTotalTTC();
BigDecimal reste = totalTTC2.subtract(ht.add(tva));
if (!this.intraComm && reste.compareTo(BigDecimal.ZERO) != 0) {
if (!intraComm && reste.compareTo(BigDecimal.ZERO) != 0) {
System.err.print("Ecarts: " + reste + "(HT:" + ht);
System.err.print(" TVA:" + tva);
System.err.println(" TTC:" + totalTTC2);
683,35 → 624,35
}
 
public BigDecimal getTotalDevise() {
return this.totalDevise;
return totalDevise;
}
 
public BigDecimal getTotalDeviseSel() {
return this.totalDeviseSel;
return totalDeviseSel;
}
 
public BigDecimal getTotalHA() {
return this.totalHA;
return totalHA;
}
 
public BigDecimal getTotalHASel() {
return this.totalHASel;
return totalHASel;
}
 
public double getTotalPoids() {
return this.totalPoids;
return totalPoids;
}
 
public BigDecimal getTotalService() {
return this.totalService;
return totalService;
}
 
public BigDecimal getTotalServiceSel() {
return this.totalServiceSel;
return totalServiceSel;
}
 
public Map<SQLRowAccessor, Map<SQLRowAccessor, BigDecimal>> getMapHtTaxeCompl() {
return this.mapHtTaxeCompl;
return mapHtTaxeCompl;
}
 
public BigDecimal getTotalHT() {
740,7 → 681,7
}
 
public BigDecimal getTotalHTSansFActurable() {
return this.totalHTSansFActurable;
return totalHTSansFActurable;
}
 
public BigDecimal getTotalTTC() {
770,18 → 711,18
}
 
public Map<SQLRowAccessor, BigDecimal> getMapHt() {
return this.mapHt;
return mapHt;
}
 
public Map<SQLRowAccessor, Tuple2<BigDecimal, BigDecimal>> getMapHtTVARowTaux() {
return this.mapHtTVARowTaux;
return mapHtTVARowTaux;
}
 
public Map<SQLRowAccessor, BigDecimal> getMapHtTVA() {
return this.mapHtTVA;
return mapHtTVA;
}
 
public Map<SQLRowAccessor, BigDecimal> getMapHtTVAIntra() {
return this.mapHtTVAIntra;
return mapHtTVAIntra;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/AbstractAchatArticleItemTable.java
21,7 → 21,6
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
import org.openconcerto.erp.core.sales.product.ui.DeliveredQtyRowValuesRenderer;
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
50,7 → 49,6
import org.openconcerto.utils.Tuple3;
import org.openconcerto.utils.i18n.TranslationManager;
 
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
71,7 → 69,6
 
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
79,7 → 76,6
import javax.swing.ToolTipManager;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
 
public abstract class AbstractAchatArticleItemTable extends AbstractArticleItemTable {
138,10 → 134,6
list.add(dmdElt);
}
 
if (e.getTable().contains("ID_AFFAIRE")) {
list.add(new SQLTableElement(e.getTable().getField("ID_AFFAIRE")));
}
 
SQLTableElement tableElementCodeFournisseur = null;
 
if (e.getTable().contains("ID_CODE_FOURNISSEUR") && supplierCode) {
149,10 → 141,6
list.add(tableElementCodeFournisseur);
}
 
if (e.getTable().contains("ID_COMPTE_PCE")) {
list.add(new SQLTableElement(e.getTable().getField("ID_COMPTE_PCE")));
}
 
SQLTableElement tableElementArticle = new SQLTableElement(e.getTable().getField("ID_ARTICLE"), true, true, true) {
@Override
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
226,6 → 214,12
};
list.add(tableElementNom);
 
SQLTableElement tableCmdElt = null;
if (e.getTable().contains("ID_COMMANDE_ELEMENT")) {
tableCmdElt = new SQLTableElement(e.getTable().getField("ID_COMMANDE_ELEMENT"));
list.add(tableCmdElt);
}
 
if (e.getTable().getFieldsName().contains("DESCRIPTIF")) {
final SQLTableElement tableElementDesc = new SQLTableElement(e.getTable().getField("DESCRIPTIF"));
list.add(tableElementDesc);
299,36 → 293,6
SQLTableElement uniteVente = new SQLTableElement(e.getTable().getField("ID_UNITE_VENTE"));
list.add(uniteVente);
 
SQLTableElement tableCmdElt = null;
if (e.getTable().contains("ID_COMMANDE_ELEMENT")) {
tableCmdElt = new SQLTableElement(e.getTable().getField("ID_COMMANDE_ELEMENT"));
tableCmdElt.setRenderer(new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
SQLRowValues rowVals = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(row);
 
JLabel tableCellRendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
tableCellRendererComponent.setText("");
if (rowVals.getObject("ID_COMMANDE_ELEMENT") != null && !rowVals.isForeignEmpty("ID_COMMANDE_ELEMENT")) {
SQLRowAccessor rowCmdItem = rowVals.getForeign("ID_COMMANDE_ELEMENT");
int qte = rowCmdItem.getInt("QTE");
BigDecimal qteU = rowCmdItem.getBigDecimal("QTE_UNITAIRE");
BigDecimal qteR = rowCmdItem.getBigDecimal("QTE_RECUE");
qteU = qteU.multiply(new BigDecimal(qte));
if (qteR != null) {
tableCellRendererComponent.setText(qteU.subtract(qteR).setScale(2, RoundingMode.HALF_UP).toString());
} else {
tableCellRendererComponent.setText(qteU.setScale(2, RoundingMode.HALF_UP).toString());
}
}
 
return tableCellRendererComponent;
}
});
tableCmdElt.setEditable(false);
list.add(tableCmdElt);
}
 
if (e.getTable().getFieldsName().contains("QTE_ORIGINE")) {
final SQLTableElement tableQteO = new SQLTableElement(e.getTable().getField("QTE_ORIGINE"));
tableQteO.setEditable(false);
341,9 → 305,6
return Integer.valueOf(0);
}
};
if (e.getTable().getFieldsName().contains("QTE_ORIGINE")) {
qteElement.setRenderer(new DeliveredQtyRowValuesRenderer(false));
}
list.add(qteElement);
// TVA
this.tableElementTVA = new SQLTableElement(e.getTable().getField("ID_TAXE"));
367,9 → 328,7
if (showDevise) {
// Prix d'achat HT devise
this.tableElementTotalDevise = new SQLTableElement(e.getTable().getField("PA_DEVISE_T"), BigDecimal.class);
CurrencyWithSymbolRenderer deviseTotalRenderer = new CurrencyWithSymbolRenderer(new FieldPath(p, "CODE"));
deviseTotalRenderer.setHideZeroValue(true);
this.tableElementTotalDevise.setRenderer(deviseTotalRenderer);
this.tableElementTotalDevise.setRenderer(new CurrencyWithSymbolRenderer(new FieldPath(p, "CODE")));
list.add(tableElementTotalDevise);
}
 
386,9 → 345,7
 
// Total HT
this.totalHT = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
DeviseTableCellRenderer totalRenderer = new DeviseTableCellRenderer();
totalRenderer.setHideZeroValue(true);
this.totalHT.setRenderer(totalRenderer);
this.totalHT.setRenderer(new DeviseTableCellRenderer());
this.totalHT.setEditable(false);
if (e.getTable().contains("POURCENT_REMISE") && tableElementRemise != null) {
tableElementRemise.addModificationListener(this.totalHT);
397,7 → 354,7
this.totalHA = this.totalHT;
// Total TTC
this.tableElementTotalTTC = new SQLTableElement(e.getTable().getField("T_PA_TTC"), BigDecimal.class);
this.tableElementTotalTTC.setRenderer(totalRenderer);
this.tableElementTotalTTC.setRenderer(new DeviseTableCellRenderer());
list.add(this.tableElementTotalTTC);
 
this.defaultRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
963,7 → 920,7
public Object tarifCompletion(SQLRow row, String field) {
final SQLTable tTarifFournisseur = this.getSQLElement().getTable().getDBRoot().getTable("ARTICLE_TARIF_FOURNISSEUR");
 
if (row != null && !row.isUndefined() && (field.equalsIgnoreCase("PRIX_METRIQUE_HA_1") || field.equalsIgnoreCase("PA_HT")) && tTarifFournisseur != null) {
if (row != null && !row.isUndefined() && field.equalsIgnoreCase("PRIX_METRIQUE_HA_1") && tTarifFournisseur != null) {
List<String> incoTerms;
 
if (this.incoterm != null && this.incoterm.equalsIgnoreCase("CPT")) {
987,7 → 944,7
if (rowsT.size() > 0) {
BigDecimal min = BigDecimal.ZERO;
 
BigDecimal defaultPrice = sqlRow.getForeign("ID_ARTICLE").getBigDecimal("PRIX_METRIQUE_HA_1");
BigDecimal defaultPrice = BigDecimal.ZERO;
Calendar c = null;
for (SQLRow sqlRowT : rowsT) {
if (this.rowFournisseur != null && this.rowFournisseur.getID() == sqlRowT.getForeignID("ID_FOURNISSEUR")) {
1034,9 → 991,7
}
return price;
} else if (!rows.isEmpty()) {
 
BigDecimal min = row.getBigDecimal("PRIX_METRIQUE_HA_1");
 
BigDecimal min = BigDecimal.ZERO;
Calendar c = null;
for (SQLRow sqlRow : rows) {
if (this.rowFournisseur != null && this.rowFournisseur.getID() == sqlRow.getForeignID("ID_FOURNISSEUR")) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/TotalPanel.java
65,7 → 65,6
private DeviseField textTotalTTC, textTotalTTCSel;
private DeviseField textPortHT;
private DeviseField textRemiseHT, textTotalEco, textTotalEcoSel;
private JTextField textTVAFix;
private JTextField textPoids;
private DeviseField textTotalDevise, textTotalDeviseSel;
private DeviseField textService, textServiceSel;
115,7 → 114,6
this.textRemiseHT = textRemiseHT;
this.textService = textService;
this.textFraisDoc = new DeviseField();
this.textTVAFix = new DeviseField();
this.textFraisDocSel = new DeviseField();
this.textTotalHTSel = new DeviseField(true);
this.textServiceSel = new DeviseField();
149,7 → 147,6
reconfigure(this.marge);
reconfigure(this.textTotalHTSel);
reconfigure(this.textFraisDoc);
reconfigure(this.textTVAFix);
reconfigure(this.textFraisDocSel);
reconfigure(this.textTotalEcoSel);
reconfigure(this.textTotalTVASel);
442,10 → 439,6
this.selFraisDocTVA = boxTVA;
}
 
public void setTextFixTVA(JTextField textTVAFix) {
this.textTVAFix = textTVAFix;
}
 
public void setIntraComm(boolean intraComm) {
this.intraComm = intraComm;
updateTotal();
520,7 → 513,7
public void updateTotal() {
 
final long valRemiseHT;
final BigDecimal valPortHT, fraisDoc, tvaFix;
final BigDecimal valPortHT, fraisDoc;
 
clearTextField();
// Clone rows to be thread safe
626,18 → 619,6
rowValsFraisDoc = null;
}
 
// Fix TVA si écart avec facture fournisseur
if (textTVAFix.getText().trim().length() > 0) {
if (!textTVAFix.getText().trim().equals("-")) {
long p = GestionDevise.parseLongCurrency(textTVAFix.getText().trim());
tvaFix = new BigDecimal(p).movePointLeft(2);
} else {
tvaFix = BigDecimal.ZERO;
}
} else {
tvaFix = BigDecimal.ZERO;
}
 
final Boolean isServiceActive = bServiceActive;
if (worker != null) {
worker.cancel(true);
725,8 → 706,6
calc.addLine(rowValsFraisDoc, null, 0, false);
}
 
calc.addTVAAdjust(tvaFix);
 
// Verification du resultat ht +tva = ttc
calc.checkResult();
if (Thread.currentThread().isInterrupted()) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IListFilterDatePanel.java
57,7 → 57,6
private Map<String, Tuple2<Date, Date>> map;
private static LinkedHashMap<String, Tuple2<Date, Date>> mapDefault;
public static boolean LOAD_STATE = true;
private static Tuple2<Date, Date> exerciceTuple;
 
private JComboBox combo;
 
81,34 → 80,21
}
}
 
private static void initDefaultMap() {
mapDefault = new LinkedHashMap<String, Tuple2<Date, Date>>();
 
// Exercice courant
SQLRow rowEx = ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeignRow("ID_EXERCICE_COMMON");
Calendar c1 = rowEx.getDate("DATE_DEB");
clearTimeSchedule(c1);
Calendar c2 = rowEx.getDate("DATE_FIN");
setEndTimeSchedule(c2);
exerciceTuple = Tuple2.create(c1.getTime(), c2.getTime());
}
 
public static Map<String, Tuple2<Date, Date>> getDefaultMap() {
if (mapDefault == null) {
initDefaultMap();
}
Map<String, Tuple2<Date, Date>> m = new LinkedHashMap<String, Tuple2<Date, Date>>();
m.putAll(getDefaultDateFilter());
m.putAll(mapDefault);
return m;
}
 
public static Map<String, Tuple2<Date, Date>> getDefaultDateFilter() {
Map<String, Tuple2<Date, Date>> mapDefaultDate = new LinkedHashMap<>();
private static void initDefaultMap() {
mapDefault = new LinkedHashMap<String, Tuple2<Date, Date>>();
 
// ALL
Date emptyDate = null;
mapDefaultDate.put(TM.tr("dateFilter.none"), Tuple2.create(emptyDate, emptyDate));
mapDefault.put(TM.tr("dateFilter.none"), Tuple2.create(emptyDate, emptyDate));
 
Calendar c = Calendar.getInstance();
// Année courante
120,7 → 106,7
c.set(Calendar.DATE, 31);
c.set(Calendar.MONTH, 11);
Date d2 = c.getTime();
mapDefaultDate.put(TM.tr("dateFilter.currentYear"), Tuple2.create(d1, d2));
mapDefault.put(TM.tr("dateFilter.currentYear"), Tuple2.create(d1, d2));
 
// Année précedente
clearTimeSchedule(c);
133,7 → 119,7
c.set(Calendar.DATE, 31);
c.set(Calendar.MONTH, 11);
Date d4 = c.getTime();
mapDefaultDate.put(TM.tr("dateFilter.previousYear"), Tuple2.create(d3, d4));
mapDefault.put(TM.tr("dateFilter.previousYear"), Tuple2.create(d3, d4));
 
// Mois courant
c = Calendar.getInstance();
143,7 → 129,7
c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE));
setEndTimeSchedule(c);
Date d6 = c.getTime();
mapDefaultDate.put(TM.tr("dateFilter.currentMonth"), Tuple2.create(d5, d6));
mapDefault.put(TM.tr("dateFilter.currentMonth"), Tuple2.create(d5, d6));
 
// Mois précédent
c = Calendar.getInstance();
154,7 → 140,7
c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE));
setEndTimeSchedule(c);
Date d8 = c.getTime();
mapDefaultDate.put(TM.tr("dateFilter.previousMonth"), Tuple2.create(d7, d8));
mapDefault.put(TM.tr("dateFilter.previousMonth"), Tuple2.create(d7, d8));
 
// semaine courante
c = Calendar.getInstance();
164,7 → 150,7
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
setEndTimeSchedule(c);
Date d10 = c.getTime();
mapDefaultDate.put(TM.tr("dateFilter.currentWeek"), Tuple2.create(d9, d10));
mapDefault.put(TM.tr("dateFilter.currentWeek"), Tuple2.create(d9, d10));
 
// semaine précédente
c = Calendar.getInstance();
175,23 → 161,24
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
setEndTimeSchedule(c);
Date d12 = c.getTime();
mapDefaultDate.put(TM.tr("dateFilter.previousWeek"), Tuple2.create(d11, d12));
mapDefault.put(TM.tr("dateFilter.previousWeek"), Tuple2.create(d11, d12));
 
// Exercice courant
SQLRow rowEx = ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeignRow("ID_EXERCICE_COMMON");
Calendar c1 = rowEx.getDate("DATE_DEB");
clearTimeSchedule(c1);
Calendar c2 = rowEx.getDate("DATE_FIN");
setEndTimeSchedule(c2);
 
final Tuple2<Date, Date> exerciceTuple = Tuple2.create(c1.getTime(), c2.getTime());
if (findItem(exerciceTuple, mapDefault).equals(CUSTOM_COMBO_ITEM)) {
mapDefaultDate.put(TM.tr("dateFilter.currentFiscalYear"), exerciceTuple);
mapDefault.put(TM.tr("dateFilter.currentFiscalYear"), exerciceTuple);
}
 
// Custom
mapDefaultDate.put(CUSTOM_COMBO_ITEM, null);
 
return mapDefaultDate;
 
mapDefault.put(CUSTOM_COMBO_ITEM, null);
}
 
private static void addCustomToMap(Map<String, Tuple2<Date, Date>> map) {
 
}
 
public static void addDefaultValue(String label, Tuple2<Date, Date> period) {
if (mapDefault == null)
initDefaultMap();
349,7 → 336,6
final SQLField filterField = this.mapList.get(list);
 
list.getRequest().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
Where w = new Where(input.getAlias(filterField), "<=", c.getTime());
359,10 → 345,8
}
 
} else {
 
final Calendar c = Calendar.getInstance();
c.setTime(this.dateAu.getValue());
 
setEndTimeSchedule(c);
 
final Calendar c2 = Calendar.getInstance();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/ui/IColorChooser.java
New file
0,0 → 1,85
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.common.ui;
 
import org.openconcerto.ui.valuewrapper.ValueWrapper;
import org.openconcerto.utils.checks.ValidListener;
import org.openconcerto.utils.checks.ValidState;
 
import java.awt.Color;
import java.beans.PropertyChangeListener;
 
import javax.swing.JColorChooser;
import javax.swing.JComponent;
 
public class IColorChooser extends JColorChooser implements ValueWrapper<Integer> {
 
public IColorChooser() {
super();
}
 
@Override
public JComponent getComp() {
return this;
}
 
@Override
public ValidState getValidState() {
return ValidState.getTrueInstance();
}
 
@Override
public void setValue(Integer val) {
if (val == null) {
val = Color.white.getRGB();
}
setColor(val);
}
 
@Override
public Integer getValue() {
if (getColor() == null) {
return null;
} else {
return getColor().getRGB();
}
}
 
@Override
public void addValidListener(ValidListener l) {
// TODO Auto-generated method stub
 
}
 
@Override
public void removeValidListener(ValidListener l) {
// TODO Auto-generated method stub
 
}
 
@Override
public void resetValue() {
this.setColor(null);
}
 
@Override
public final void addValueListener(final PropertyChangeListener l) {
this.addPropertyChangeListener("value", l);
}
 
@Override
public void rmValueListener(final PropertyChangeListener l) {
this.removePropertyChangeListener("value", l);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/component/TransfertBaseSQLComponent.java
27,7 → 27,6
import org.openconcerto.sql.model.SQLRowValues.ForeignCopyMode;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
166,8 → 165,7
for (SQLRowValues sqlRowValues : sourceRows) {
ids.add(sqlRowValues.getIDNumber());
}
 
final SQLRowValues row = new SQLRowValues(sourceRows.get(0).getTable());
final SQLRowValues row = sourceRows.get(0).deepCopy();
// FIXME don't work in the general case
for (final SQLField rk : row.getTable().getDBSystemRoot().getGraph().getReferentKeys(row.getTable())) {
final Set<SQLRowValues> referentRows = row.getReferentRows(rk);
205,57 → 203,4
throw new IllegalArgumentException("Table " + destTableName + " SQLComponent is not a TransfertBaseSQLComponent");
}
}
 
public static boolean isAlreadyAllTransfert(final List<SQLRowValues> selectedRows, final SQLTable from, final SQLTable to, final String fieldTotalFrom, final String fieldTotalTo) {
final SQLTable tableTransfert = from.getTable("TR_" + from.getName());
SQLRowValues rowVals = new SQLRowValues(tableTransfert);
rowVals.put("ID_" + from.getName(), new SQLRowValues(from).put("NUMERO", null).put(fieldTotalFrom, null));
rowVals.putRowValues("ID_" + to.getName()).put("NUMERO", null).put(fieldTotalTo, null);
rowVals.put("ID", null);
 
final List<Number> lID = new ArrayList<>();
for (SQLRowValues sqlRowValues : selectedRows) {
lID.add(sqlRowValues.getID());
}
 
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
fetch.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
Where w = new Where(tableTransfert.getField("ID_" + from.getName()), lID);
w = w.and(new Where(tableTransfert.getField("ID_" + to.getName()), "IS NOT", (Object) null));
input.setWhere(w);
return input;
}
});
 
List<SQLRowValues> rows = fetch.fetch();
if (rows != null && rows.size() > 0) {
String numero = "";
 
long totalBR = 0;
long totalFact = 0;
Set<String> idsAdded = new HashSet<>();
for (SQLRowValues sqlRow : rows) {
final SQLRowAccessor foreignBR = sqlRow.getForeign("ID_" + from.getName());
final SQLRowAccessor foreignFact = sqlRow.getForeign("ID_" + to.getName());
numero += foreignBR.getString("NUMERO") + " ,";
String fromKey = from.getName() + "-" + foreignBR.getID();
if (!idsAdded.contains(fromKey)) {
totalBR += foreignBR.getLong(fieldTotalFrom);
idsAdded.add(fromKey);
}
String toKey = to.getName() + "-" + foreignFact.getID();
if (!idsAdded.contains(toKey)) {
totalFact += foreignFact.getLong(fieldTotalTo);
idsAdded.add(toKey);
}
}
 
numero = numero.substring(0, numero.length() - 2);
return totalBR <= totalFact;
}
return Boolean.FALSE;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/common/element/SocieteSQLConfElement.java
14,6 → 14,7
package org.openconcerto.erp.core.common.element;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
25,6 → 26,8
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.sql.ui.light.GroupToLightUIConvertor;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.SQLTableModelColumn;
import org.openconcerto.sql.view.list.SQLTableModelSource;
336,6 → 339,16
}
}
 
public GroupToLightUIConvertor getGroupToLightUIConvertor(final PropsConfiguration configuration, final EditMode editMode, final SQLRowValues sqlRow, final String sessionSecurityToken) {
final GroupToLightUIConvertor convertor = new GroupToLightUIConvertor(configuration);
if (editMode.equals(EditMode.CREATION)) {
convertor.putAllCustomEditorProvider(this.getCustomEditorProviderForCreation(configuration, sessionSecurityToken));
} else {
convertor.putAllCustomEditorProvider(this.getCustomEditorProviderForModification(configuration, sqlRow, sessionSecurityToken));
}
return convertor;
}
 
public List<SQLRowValues> getRowValues(final String fieldName, final long id) {
final SQLTableModelSourceOnline tableSource = this.getTableSource(true);
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/stat/action/ReportingCommercialAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/DepotStockSQLElement.java
14,27 → 14,16
package org.openconcerto.erp.core.supplychain.stock.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.IListFrame;
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.utils.ListMap;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JLabel;
import javax.swing.JTextField;
 
44,22 → 33,7
 
public DepotStockSQLElement() {
super("DEPOT_STOCK", "un dépôt", "dépôts");
 
PredicateRowAction actionStock = new PredicateRowAction(new AbstractAction("Voir le détails du stock") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRowAccessor selRow = IListe.get(e).getSelectedRow();
final SQLElement elementStock = getDirectory().getElement("STOCK");
IListFrame frame = new IListFrame(
new ListeViewPanel(elementStock, new IListe(elementStock.createTableSource(new Where(elementStock.getTable().getField("ID_DEPOT_STOCK"), "=", selRow.getID())))));
FrameUtil.showPacked(frame);
 
}
}, true);
actionStock.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionStock);
}
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/StockItemsUpdater.java
25,8 → 25,6
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.SQLTableEvent;
import org.openconcerto.sql.model.SQLTableEvent.Mode;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.utils.DecimalUtils;
156,13 → 154,12
for (String s : requests) {
handlers.add(null);
}
// FIXME FIRE TABLE CHANGED TO UPDATE ILISTE ??
try {
SQLUtils.executeAtomic(stockTable.getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
@Override
public Object handle(SQLDataSource ds) throws SQLException, IOException {
SQLUtils.executeMultiple(stockTable.getDBSystemRoot(), requests, handlers);
// FIXME FIRE ONLY CHANGED ROWS
stockTable.fire(new SQLTableEvent(stockTable, SQLRow.NONEXISTANT_ID, Mode.ROW_UPDATED));
return null;
}
});
267,6 → 264,35
SQLUtils.executeMultiple(table.getDBSystemRoot(), multipleRequests, handlers);
}
 
private void fillProductComponent(List<ProductComponent> productComponents, int qte, int index, int level) {
if (level > 0) {
for (int i = index; i < items.size(); i++) {
SQLRowAccessor r = items.get(i);
 
if (!r.getTable().contains("NIVEAU") || r.getInt("NIVEAU") >= level) {
// On ne calcul pas les stocks pour les éléments ayant des fils (le mouvement de
// stock
// des fils impactera les stocks automatiquement)
if (r.getTable().contains("NIVEAU")) {
if (i + 1 < items.size()) {
SQLRowAccessor rNext = items.get(i + 1);
if (rNext.getInt("NIVEAU") > r.getInt("NIVEAU")) {
fillProductComponent(productComponents, qte * r.getInt("QTE"), i + 1, rNext.getInt("NIVEAU"));
continue;
}
}
}
if ((!r.getTable().contains("NIVEAU") || r.getInt("NIVEAU") == level) && !r.isForeignEmpty("ID_ARTICLE") && r.getForeign("ID_ARTICLE") != null) {
productComponents.add(ProductComponent.createFrom(r, qte, r));
}
} else if (r.getInt("NIVEAU") < level) {
// BREAK si on sort de l'article composé
break;
}
}
}
}
 
/**
* Récupére les stocks associés aux articles non composés (inclus les fils des nomenclatures) et
* les met à jour
279,10 → 305,9
 
String mvtStockTableQuoted = rowSource.getTable().getTable("MOUVEMENT_STOCK").getSQLName().quote();
 
ProductHelper helper = new ProductHelper(rowSource.getTable().getDBRoot());
// Liste des éléments à mettre à jour
List<ProductComponent> productComponents = new ArrayList<ProductComponent>();
helper.fillProductComponent(this.items, productComponents, 1, 0, 1);
fillProductComponent(productComponents, 1, 0, 1);
// for (int i = 0; i < items.size(); i++) {
// SQLRowAccessor r = items.get(i);
//
302,6 → 327,7
// }
 
// Liste des articles non composés à mettre à jour (avec les fils des nomenclatures)
ProductHelper helper = new ProductHelper(rowSource.getTable().getDBRoot());
List<ProductComponent> boms = helper.getChildWithQtyFrom(productComponents);
 
for (ProductComponent productComp : boms) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/StockSQLElement.java
20,7 → 20,6
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
101,7 → 100,7
@Override
public ListMap<String, String> getShowAs() {
if (getTable().contains("ID_DEPOT_STOCK")) {
return ListMap.singleton(null, "QTE_TH", "QTE_REEL", "QTE_MIN", "QTE_LIV_ATTENTE", "QTE_RECEPT_ATTENTE", "ID_DEPOT_STOCK");
return ListMap.singleton(null, "QTE_TH", "QTE_REEL", "QTE_LIV_ATTENTE", "QTE_RECEPT_ATTENTE", "ID_DEPOT_STOCK");
} else {
return ListMap.singleton(null, "QTE_TH", "QTE_REEL", "QTE_LIV_ATTENTE", "QTE_RECEPT_ATTENTE");
}
135,15 → 134,8
if (rowValsSource.getForeign("ID_DEPOT_STOCK") != null && !rowValsSource.isForeignEmpty("ID_DEPOT_STOCK")) {
idDepot = rowValsSource.getForeignID("ID_DEPOT_STOCK");
} else {
SQLRowAccessor rowValsArt = rowValsSource.getForeign("ID_ARTICLE");
if (rowValsArt.getObject("ID_DEPOT_STOCK") == null) {
rowValsArt = rowValsArt.asRow();
((SQLRow) rowValsArt).fetchValues();
System.err.println("REFETCH ARTICLE");
Thread.dumpStack();
idDepot = rowValsSource.getForeign("ID_ARTICLE").getForeignID("ID_DEPOT_STOCK");
}
idDepot = rowValsArt.getForeignID("ID_DEPOT_STOCK");
}
SQLTable stockTable = rowValsSource.getTable().getTable("STOCK");
SQLRowValues putRowValuesStock = new SQLRowValues(stockTable);
putRowValuesStock.putNulls(stockTable.getTable().getFieldsName());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/MouvementStockSQLElement.java
16,12 → 16,10
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent;
import org.openconcerto.erp.core.supplychain.order.ui.CommandeItemTable;
import org.openconcerto.erp.core.supplychain.supplier.component.MouvementStockSQLComponent;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
52,7 → 50,6
import java.util.List;
import java.util.Map.Entry;
 
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
 
public class MouvementStockSQLElement extends ComptaSQLConfElement {
249,10 → 246,10
}
 
public static void createCommandeF(final ListMap<SQLRow, SQLRowValues> col, final SQLRow rowDevise) {
createCommandeF(col, rowDevise, "");
createCommandeF(col, rowDevise, "", true);
}
 
public static void createCommandeF(final ListMap<SQLRow, SQLRowValues> col, final SQLRow rowDevise, final String ref) {
public static void createCommandeF(final ListMap<SQLRow, SQLRowValues> col, final SQLRow rowDevise, final String ref, final boolean useCommandeEnCours) {
if (SwingUtilities.isEventDispatchThread()) {
throw new IllegalStateException("This method must be called outside of EDT");
}
259,7 → 256,6
if (col.size() > 0) {
 
final SQLElement commande = Configuration.getInstance().getDirectory().getElement("COMMANDE");
Boolean useCommandeEnCours = SQLPreferences.getMemCached(commande.getTable().getDBRoot()).getBoolean(GestionCommercialeGlobalPreferencePanel.COMMANDE_FOURNISSEUR_EN_COURS, false);
for (final Entry<SQLRow, List<SQLRowValues>> e : col.entrySet()) {
final SQLRow fournisseur = e.getKey();
// On regarde si il existe une commande en cours existante
328,23 → 324,9
}
}
if (rowValsMatch != null) {
 
int qte = rowValsMatch.getInt("QTE");
BigDecimal qteUV = rowValsMatch.getBigDecimal("QTE_UNITAIRE");
 
if (rowValsMatch.getObject("ID_UNITE_VENTE") != null && rowValsMatch.getForeignID("ID_UNITE_VENTE") != UniteVenteArticleSQLElement.A_LA_PIECE) {
qteUV = qteUV.multiply(new BigDecimal(qte));
int qteElt = rowValsElt.getInt("QTE");
BigDecimal qteUVElt = rowValsElt.getBigDecimal("QTE_UNITAIRE");
qteUV = qteUV.add(qteUVElt.multiply(new BigDecimal(qteElt)));
qte = 1;
final int qte = rowValsMatch.getInt("QTE");
model.putValue(qte + rowValsElt.getInt("QTE"), index, "QTE");
} else {
qte += rowValsElt.getInt("QTE");
}
 
model.putValue(qte, index, "QTE");
model.putValue(qteUV, index, "QTE_UNITAIRE");
} else {
model.addRow(rowValsElt);
if (rowValsElt.getObject("ID_ARTICLE") != null && !rowValsElt.isForeignEmpty("ID_ARTICLE")) {
Object o = itemTable.tarifCompletion(rowValsElt.getForeign("ID_ARTICLE").asRow(), "PRIX_METRIQUE_HA_1");
360,16 → 342,9
 
}
});
}
} else {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
JOptionPane.showMessageDialog(null, "Aucune commande à passer", "Commande fournisseur", JOptionPane.INFORMATION_MESSAGE);
}
 
});
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/EtatDemandeAchatItemSQLElement.java
17,9 → 17,9
package org.openconcerto.erp.core.supplychain.order.element;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.IColorChooser;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.ui.IColorChooser;
import org.openconcerto.utils.ListMap;
 
import java.util.ArrayList;
68,7 → 68,7
return new UISQLComponent(this) {
public void addViews() {
this.addRequiredSQLObject(new JTextField(), "NOM", "left");
this.addRequiredSQLObject(new IColorChooser("Couleur"), "COLOR", "right");
this.addRequiredSQLObject(new IColorChooser(), "COLOR", "right");
}
};
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/FactureFournisseurSQLElement.java
19,23 → 19,15
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.utils.ListMap;
 
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.AbstractAction;
 
public class FactureFournisseurSQLElement extends ComptaSQLConfElement {
 
public FactureFournisseurSQLElement() {
49,22 → 41,7
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
}
RowAction actionClone = new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
 
EditFrame editFrame = new EditFrame(FactureFournisseurSQLElement.this, EditPanel.CREATION);
 
((FactureFournisseurSQLComponent) editFrame.getSQLComponent()).loadFactureExistante(IListe.get(e).getSelectedId());
editFrame.setVisible(true);
}
}, true, "supplychain.invoice.clone") {
public boolean enabledFor(IListeEvent evt) {
List<? extends SQLRowAccessor> l = evt.getSelectedRows();
return (l != null && l.size() == 1);
}
};
getRowActions().add(actionClone);
}
 
@Override
public Set<String> getReadOnlyFields() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/DemandeAchatItemSQLElement.java
25,7 → 25,6
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
93,6 → 92,7
 
@Override
public void actionPerformed(ActionEvent e) {
List<SQLRowValues> rows = IListe.get(e).getSelectedRows();
StyleSQLElement styleElt = getDirectory().getElement(StyleSQLElement.class);
int idNormal = styleElt.getAllStyleByName().get("Normal");
 
99,10 → 99,9
SQLRowValues rowVals = new SQLRowValues(getTable().getTable("DEMANDE_PRIX"));
rowVals.put("DATE", new Date());
SQLInjector inj = SQLInjector.getInjector(getTable(), getTable().getTable("DEMANDE_PRIX_ELEMENT"));
 
final List<SQLRow> rows = SQLRowListRSH.fetch(IListe.get(e).getRequest().getPrimaryTable(), IListe.get(e).getSelection().getSelectedIDs());
 
for (SQLRow row : rows) {
for (SQLRowValues sqlRowValues : rows) {
SQLRow row = sqlRowValues.asRow();
row.fetchValues();
rowVals.put("ID_AFFAIRE", row.getForeignID("ID_AFFAIRE"));
SQLRowValues rowValsCmdElt = inj.createRowValuesFrom(row);
rowValsCmdElt.put("ID_STYLE", idNormal);
153,6 → 152,7
 
@Override
public void actionPerformed(ActionEvent e) {
List<SQLRowValues> rows = IListe.get(e).getSelectedRows();
StyleSQLElement styleElt = getDirectory().getElement(StyleSQLElement.class);
int idNormal = styleElt.getAllStyleByName().get("Normal");
 
159,8 → 159,9
SQLRowValues rowVals = new SQLRowValues(getTable().getTable("COMMANDE"));
rowVals.put("DATE", new Date());
SQLInjector inj = SQLInjector.getInjector(getTable(), getTable().getTable("COMMANDE_ELEMENT"));
final List<SQLRow> rows = SQLRowListRSH.fetch(IListe.get(e).getRequest().getPrimaryTable(), IListe.get(e).getSelection().getSelectedIDs());
for (SQLRow row : rows) {
for (SQLRowValues sqlRowValues : rows) {
SQLRow row = sqlRowValues.asRow();
row.fetchValues();
rowVals.put("ID_AFFAIRE", row.getForeignID("ID_AFFAIRE"));
SQLRowValues rowValsCmdElt = inj.createRowValuesFrom(row);
rowValsCmdElt.put("ID_STYLE", idNormal);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/CommandeSQLElement.java
21,7 → 21,6
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent;
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
34,7 → 33,6
import org.openconcerto.sql.model.SQLSelectJoin;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.sql.view.list.IListe;
52,8 → 50,6
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
71,57 → 67,11
transfertBR(selectedRows);
}
 
}, true, "supplychain.order.create.receipt");
}, false, "supplychain.order.create.receipt");
 
bonAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(bonAction);
 
PredicateRowAction actionsTRFA = new PredicateRowAction(new AbstractAction("Transfert vers facture fournisseur") {
public void actionPerformed(ActionEvent e) {
final List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
SwingWorker<Boolean, Object> worker = new SwingWorker<Boolean, Object>() {
@Override
protected Boolean doInBackground() throws Exception {
 
boolean b = TransfertBaseSQLComponent.isAlreadyAllTransfert(selectedRows, getTable(), getTable().getTable("FACTURE_FOURNISSEUR"), "T_HT", "T_HT");
 
if (b) {
String label = "Attention ";
if (selectedRows.size() > 1) {
label += " les " + getPluralName() + " ont déjà été transféré!";
} else {
label += getSingularName() + " a déjà été transféré!";
}
label += "\n Voulez vous continuer?";
 
int ans = JOptionPane.showConfirmDialog(null, label, "Transfert " + getSingularName(), JOptionPane.YES_NO_OPTION);
if (ans == JOptionPane.NO_OPTION) {
return Boolean.FALSE;
}
}
 
return Boolean.TRUE;
 
}
 
@Override
protected void done() {
try {
Boolean b = get();
if (b) {
TransfertBaseSQLComponent.openTransfertFrame(selectedRows, "FACTURE_FOURNISSEUR");
}
} catch (Exception e) {
ExceptionHandler.handle("Erreur lors du transfert des " + getPluralName() + "!", e);
}
}
};
worker.execute();
}
}, false);
actionsTRFA.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
getRowActions().add(actionsTRFA);
 
// Transfert vers facture
PredicateRowAction factureAction = new PredicateRowAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
157,13 → 107,9
l.add("NOM");
l.add("DATE");
l.add("ID_FOURNISSEUR");
l.add("ID_COMMERCIAL");
l.add("T_HT");
l.add("T_TTC");
Boolean useCommandeEnCours = SQLPreferences.getMemCached(getTable().getDBRoot()).getBoolean(GestionCommercialeGlobalPreferencePanel.COMMANDE_FOURNISSEUR_EN_COURS, false);
if (useCommandeEnCours) {
l.add("EN_COURS");
}
l.add("INFOS");
return l;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/action/ListeDesCommandesAction.java
14,11 → 14,9
package org.openconcerto.erp.core.supplychain.order.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
27,17 → 25,13
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.table.PercentTableCellRenderer;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
 
import java.awt.GridBagConstraints;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
 
import javax.swing.Action;
53,135 → 47,28
 
final SQLElement elementCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE");
final SQLTableModelSourceOnline tableSource = elementCmd.getTableSource(true);
BaseSQLTableModelColumn colAvancementR = new BaseSQLTableModelColumn("Avancement réception", BigDecimal.class) {
BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Avancement réception", BigDecimal.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
return getAvancementLFromBR(r);
return getAvancement(r);
}
 
@Override
public Set<FieldPath> getPaths() {
final Path p = new PathBuilder(elementCmd.getTable()).addTable("COMMANDE_ELEMENT").build();
return CollectionUtils.createSet(new FieldPath(p, "RECU_FORCED"), new FieldPath(p, "RECU"), new FieldPath(p, "QTE_RECUE"), new FieldPath(p, "PA_HT"), new FieldPath(p, "ID_ARTICLE"),
new FieldPath(p, "QTE"), new FieldPath(p, "QTE_UNITAIRE"));
final Path p = new PathBuilder(elementCmd.getTable()).addTable("TR_COMMANDE").addTable("BON_RECEPTION").build();
return CollectionUtils.createSet(new FieldPath(p, "TOTAL_HT"));
}
};
tableSource.getColumns().add(colAvancementR);
colAvancementR.setRenderer(new PercentTableCellRenderer());
 
BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
return getAvancementFact(r);
}
 
@Override
public Set<FieldPath> getPaths() {
final Path p = new PathBuilder(elementCmd.getTable()).addTable("TR_COMMANDE").addTable("SAISIE_ACHAT").build();
final Path p2 = new PathBuilder(elementCmd.getTable()).addTable("TR_COMMANDE").addTable("FACTURE_FOURNISSEUR").build();
 
final Path pBr = new PathBuilder(elementCmd.getTable()).addTable("TR_COMMANDE").addTable("BON_RECEPTION").build();
final Path trBr = pBr.add(elementCmd.getTable().getTable("TR_BON_RECEPTION"));
final Path pFact2 = trBr.addTable("FACTURE_FOURNISSEUR");
final Path pAchat2 = trBr.addTable("SAISIE_ACHAT");
return CollectionUtils.createSet(new FieldPath(p, "MONTANT_HT"), new FieldPath(p2, "T_HT"), new FieldPath(pAchat2, "MONTANT_HT"), new FieldPath(pFact2, "T_HT"));
}
};
tableSource.getColumns().add(colAvancement);
colAvancement.setRenderer(new PercentTableCellRenderer());
 
final ListeAddPanel panel = new ListeAddPanel(elementCmd, new IListe(tableSource));
// Date panel
Map<IListe, SQLField> map = new HashMap<IListe, SQLField>();
map.put(panel.getListe(), elementCmd.getTable().getField("DATE"));
final IListFrame frame = new IListFrame(new ListeAddPanel(elementCmd, new IListe(tableSource)));
 
IListFilterDatePanel datePanel = new IListFilterDatePanel(map, IListFilterDatePanel.getDefaultMap());
GridBagConstraints c = new DefaultGridBagConstraints();
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
c.gridy = 4;
c.anchor = GridBagConstraints.CENTER;
c.weighty = 0;
datePanel.setFilterOnDefault();
panel.add(datePanel, c);
final IListFrame frame = new IListFrame(panel);
 
return frame;
}
 
private BigDecimal getAvancementLFromBR(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("COMMANDE_ELEMENT"));
BigDecimal totalQte = BigDecimal.ZERO;
BigDecimal totalQteL = BigDecimal.ZERO;
for (SQLRowAccessor row : rows) {
BigDecimal qte = row.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(row.getInt("QTE")));
// On ne prend en compte que les articles ou les lignes différentes de 0
if (!row.isForeignEmpty("ID_ARTICLE") || row.getBigDecimal("PA_HT").signum() != 0) {
totalQte = totalQte.add(qte);
if (row.getBoolean("RECU_FORCED") || row.getBoolean("RECU")) {
totalQteL = totalQteL.add(qte);
} else if (row.getBigDecimal("QTE_RECUE") != null) {
final BigDecimal qteLivree = row.getBigDecimal("QTE_RECUE");
if (qteLivree != null) {
totalQteL = totalQteL.add(qteLivree);
}
}
}
}
if (totalQte.signum() != 0) {
return totalQteL.divide(totalQte, DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
} else {
return BigDecimal.ONE.movePointRight(2);
}
}
 
BigDecimal bigDecimal100 = new BigDecimal(100.0);
 
private BigDecimal getAvancementFact(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_COMMANDE"));
long totalFact = 0;
long total = r.getLong("T_HT");
for (SQLRowAccessor row : rows) {
if (!row.isForeignEmpty("ID_FACTURE_FOURNISSEUR")) {
SQLRowAccessor rowFact = row.getForeign("ID_FACTURE_FOURNISSEUR");
Long l = rowFact.getLong("T_HT");
totalFact += l;
}
if (!row.isForeignEmpty("ID_SAISIE_ACHAT")) {
SQLRowAccessor rowFact = row.getForeign("ID_SAISIE_ACHAT");
Long l = rowFact.getLong("MONTANT_HT");
totalFact += l;
}
 
if (!row.isForeignEmpty("ID_BON_RECEPTION")) {
Collection<? extends SQLRowAccessor> rowsBr = row.getForeign("ID_BON_RECEPTION").getReferentRows(r.getTable().getTable("TR_BON_RECEPTION"));
for (SQLRowAccessor rowTrBr : rowsBr) {
if (!rowTrBr.isForeignEmpty("ID_FACTURE_FOURNISSEUR")) {
SQLRowAccessor rowFact = rowTrBr.getForeign("ID_FACTURE_FOURNISSEUR");
Long l = rowFact.getLong("T_HT");
totalFact += l;
}
if (!rowTrBr.isForeignEmpty("ID_SAISIE_ACHAT")) {
SQLRowAccessor rowFact = rowTrBr.getForeign("ID_SAISIE_ACHAT");
Long l = rowFact.getLong("MONTANT_HT");
totalFact += l;
}
 
}
}
}
 
if (total > 0) {
return this.bigDecimal100.min(new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP));
} else {
return BigDecimal.ONE.movePointRight(2);
}
}
 
private BigDecimal getAvancement(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_COMMANDE"));
long totalFact = 0;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/FactureFournisseurSQLComponent.java
59,9 → 59,6
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
68,7 → 65,6
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TableModelEvent;
106,7 → 102,7
 
int idModeRegl = rowFourn.getInt("ID_MODE_REGLEMENT");
if (idModeRegl > 1 && FactureFournisseurSQLComponent.this.eltModeRegl != null && getMode() == Mode.INSERTION) {
SQLElement sqlEltModeRegl = getElement().getDirectory().getElement("MODE_REGLEMENT");
SQLElement sqlEltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
SQLRow rowModeRegl = sqlEltModeRegl.getTable().getRow(idModeRegl);
SQLRowValues rowVals = rowModeRegl.createUpdateRow();
rowVals.clearPrimaryKeys();
128,15 → 124,6
return this.fourn;
}
 
@Override
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<>(1);
if (getTable().contains("ID_TYPE_CMD")) {
s.add("ID_TYPE_CMD");
}
return s;
}
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
493,10 → 480,10
ElementComboBox comboTaxePort = new ElementComboBox();
DeviseField textRemiseHT = new DeviseField();
 
if (getTable().contains("PORT_HT")) {
addSQLObject(textPortHT, "PORT_HT");
final JPanel panelPoids = new JPanel(new GridBagLayout());
GridBagConstraints cPort = new DefaultGridBagConstraints();
if (getTable().contains("PORT_HT")) {
addSQLObject(textPortHT, "PORT_HT");
cPort.gridx = 0;
cPort.weightx = 0;
panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort);
575,49 → 562,6
final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null,
(getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null), null);
 
if (getTable().contains("TVA_ADJUSTMENT")) {
final JTextField textTvaAdujs = new JTextField(15);
 
JLabel labelTvaAdujst = new JLabel(getLabelFor("TVA_ADJUSTMENT"));
labelTvaAdujst.setHorizontalAlignment(SwingConstants.RIGHT);
 
cPort.gridx = 0;
cPort.gridy++;
panelPoids.add(labelTvaAdujst, cPort);
cPort.gridx++;
panelPoids.add(textTvaAdujs, cPort);
addView(textTvaAdujs, "TVA_ADJUSTMENT");
totalTTC.setTextFixTVA(textTvaAdujs);
textTvaAdujs.getDocument().addDocumentListener(new SimpleDocumentListener() {
@Override
public void update(final DocumentEvent e) {
final String text = textTvaAdujs.getText();
if (text != null && text.trim().length() > 0) {
if (!text.trim().equals("-")) {
BigDecimal tvaFix = new BigDecimal(text);
if (tvaFix.abs().compareTo(new BigDecimal(0.05)) > 0) {
final String limitedFix;
if (tvaFix.signum() > 0) {
limitedFix = tvaFix.min(new BigDecimal(0.05)).toString();
} else {
limitedFix = tvaFix.max(new BigDecimal(-0.05)).toString();
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
 
textTvaAdujs.setText(limitedFix);
}
});
}
}
}
totalTTC.updateTotal();
}
});
DefaultGridBagConstraints.lockMinimumSize(textTvaAdujs);
}
 
c.gridx++;
c.gridy--;
c.gridwidth = GridBagConstraints.REMAINDER;
914,48 → 858,4
 
}
 
public void loadFactureExistante(int idFacture) {
 
SQLElement fact = getElement();
SQLElement factElt = getElement().getDirectory().getElement("FACTURE_FOURNISSEUR_ELEMENT");
 
// On duplique la facture
if (idFacture > 1) {
SQLRow row = fact.getTable().getRow(idFacture);
SQLRowValues rowVals = new SQLRowValues(fact.getTable());
rowVals.put("ID_FOURNISSEUR", row.getInt("ID_FOURNISSEUR"));
// if (getTable().contains("ID_NUMEROTATION_AUTO")) {
// rowVals.put("NUMERO",
// NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new
// Date(), row.getForeign("ID_NUMEROTATION_AUTO")));
// } else {
// rowVals.put("NUMERO",
// NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new
// Date()));
// }
rowVals.put("NOM", row.getObject("NOM"));
this.select(rowVals);
}
 
// On duplique les elements de facture
List<SQLRow> myListItem = fact.getTable().getRow(idFacture).getReferentRows(factElt.getTable());
 
if (myListItem.size() != 0) {
this.table.getModel().clearRows();
 
for (SQLRow rowElt : myListItem) {
 
SQLRowValues rowVals = rowElt.createUpdateRow();
rowVals.clearPrimaryKeys();
this.table.getModel().addRow(rowVals);
int rowIndex = this.table.getModel().getRowCount() - 1;
this.table.getModel().fireTableModelModified(rowIndex);
}
} else {
this.table.getModel().clearRows();
}
this.table.getModel().fireTableDataChanged();
this.table.repaint();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/CommandeSQLComponent.java
31,7 → 31,6
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
import org.openconcerto.erp.panel.PanelOOSQLComponent;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.DefaultElementSQLObject;
48,11 → 47,9
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.AutoHideListener;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FormLayouter;
64,7 → 61,6
import org.openconcerto.ui.component.InteractionMode;
import org.openconcerto.ui.preferences.DefaultProps;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.checks.ValidState;
 
import java.awt.Color;
import java.awt.GridBagConstraints;
74,9 → 70,7
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.JCheckBox;
import javax.swing.JLabel;
115,17 → 109,6
return this.fourn;
}
 
@Override
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<>(4);
if (getTable().contains("ID_TYPE_CMD")) {
s.add("ID_TYPE_CMD");
s.add("DA1");
s.add("ID_POLE_PRODUIT");
}
return s;
}
 
public void addViews() {
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
201,9 → 184,7
} else {
table.setRowCatComptable(null);
}
if (getTable().contains("OFFRE_COM")) {
((SQLTextCombo) getView("OFFRE_COM").getComp()).setValue(rowF.getString("RESPONSABLE"));
}
 
} else {
table.setRowCatComptable(null);
}
210,9 → 191,7
}
});
 
Boolean useCommandeEnCours = SQLPreferences.getMemCached(getElement().getTable().getDBRoot()).getBoolean(GestionCommercialeGlobalPreferencePanel.COMMANDE_FOURNISSEUR_EN_COURS, false);
 
if (!getTable().getFieldsName().contains("LIVRER") && useCommandeEnCours) {
if (!getTable().getFieldsName().contains("LIVRER")) {
// Commande en cours
JCheckBox boxEnCours = new JCheckBox(getLabelFor("EN_COURS"));
c.gridx += 2;
1025,27 → 1004,6
stockUpdater.update();
}
 
@Override
public synchronized ValidState getValidState() {
if (getTable().contains("ID_TYPE_CMD") && getTable().contains("ID_AFFAIRE") && getTable().getTable("COMMANDE_ELEMENT").contains("ID_AFFAIRE")) {
SQLRequestComboBox boxAff = (SQLRequestComboBox) getView("ID_AFFAIRE").getComp();
final SQLRow selectedAff = boxAff.getSelectedRow();
if (selectedAff == null || selectedAff.isUndefined()) {
RowValuesTableModel tableRow = this.table.getRowValuesTable().getRowValuesTableModel();
 
for (int i = 0; i < tableRow.getRowCount(); i++) {
SQLRowValues rowVals = tableRow.getRowValuesAt(i);
if (rowVals.getInt("QTE") != 0 && (rowVals.getObject("ID_AFFAIRE") == null || rowVals.isForeignEmpty("ID_AFFAIRE"))) {
return ValidState.create(false, "Aucune affaire globale sélectionnée et une ligne avec une quantité > 0 n'est pas affectée à une affaire!");
}
}
} else {
ValidState.create(false, "Aucune affaire globale sélectionnée!");
}
}
return super.getValidState();
}
 
public void setDefaults() {
this.resetValue();
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/component/BonReceptionSQLComponent.java
60,14 → 60,11
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
94,15 → 91,6
}
 
@Override
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<>(1);
if (getTable().contains("ID_TYPE_CMD")) {
s.add("ID_TYPE_CMD");
}
return s;
}
 
@Override
protected SQLRowValues createDefaults() {
this.tableBonItem.getModel().clearRows();
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
640,8 → 628,6
}
}
int count = this.tableBonItem.getModel().getRowCount();
int receipt = 0;
 
for (int i = 0; i < count; i++) {
SQLRowValues r = this.tableBonItem.getModel().getRowValuesAt(i);
SQLRowValues rowTR = map.get(r.getForeignID("ID_ARTICLE"));
648,28 → 634,14
if (rowTR != null && !rowTR.isUndefined()) {
if (r.getInt("QTE") > 0) {
if (NumberUtils.areNumericallyEqual(r.getBigDecimal("QTE_UNITAIRE"), BigDecimal.ONE) || r.getInt("QTE") > 1) {
int value = r.getInt("QTE") - rowTR.getInt("QTE");
if ((value <= 0)) {
receipt++;
}
 
this.tableBonItem.getModel().putValue(Math.max(0, value), i, "QTE");
this.tableBonItem.getModel().putValue(r.getInt("QTE") - rowTR.getInt("QTE"), i, "QTE");
} else {
BigDecimal subtract = r.getBigDecimal("QTE_UNITAIRE").subtract(rowTR.getBigDecimal("QTE_UNITAIRE"));
if (subtract.signum() <= 0) {
receipt++;
this.tableBonItem.getModel().putValue(r.getBigDecimal("QTE_UNITAIRE").subtract(rowTR.getBigDecimal("QTE_UNITAIRE")), i, "QTE_UNITAIRE");
}
this.tableBonItem.getModel().putValue(subtract.max(BigDecimal.ZERO), i, "QTE_UNITAIRE");
}
} else {
receipt++;
}
}
}
if (receipt == count) {
JOptionPane.showMessageDialog(null, "Attention tous les articles ont déjà été réceptionné!");
}
}
 
@Override
public void update() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/element/BonReceptionSQLElement.java
27,7 → 27,6
import org.openconcerto.sql.model.AliasedTable;
import org.openconcerto.sql.model.SQLName;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
36,7 → 35,6
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.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
 
import java.awt.event.ActionEvent;
47,8 → 45,6
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
 
import org.apache.commons.dbutils.handlers.ArrayListHandler;
 
59,46 → 55,8
 
PredicateRowAction actionsTRFA = new PredicateRowAction(new AbstractAction("Transfert vers facture fournisseur") {
public void actionPerformed(ActionEvent e) {
final List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
SwingWorker<Boolean, Object> worker = new SwingWorker<Boolean, Object>() {
@Override
protected Boolean doInBackground() throws Exception {
 
boolean b = TransfertBaseSQLComponent.isAlreadyAllTransfert(selectedRows, getTable(), getTable().getTable("FACTURE_FOURNISSEUR"), "TOTAL_HT", "T_HT");
 
if (b) {
String label = "Attention ";
if (selectedRows.size() > 1) {
label += " les " + getPluralName() + " ont déjà été transféré!";
} else {
label += getSingularName() + " a déjà été transféré!";
TransfertBaseSQLComponent.openTransfertFrame(IListe.get(e).getSelectedRows(), "FACTURE_FOURNISSEUR");
}
label += "\n Voulez vous continuer?";
 
int ans = JOptionPane.showConfirmDialog(null, label, "Transfert " + getSingularName(), JOptionPane.YES_NO_OPTION);
if (ans == JOptionPane.NO_OPTION) {
return Boolean.FALSE;
}
}
 
return Boolean.TRUE;
 
}
 
@Override
protected void done() {
try {
Boolean b = get();
if (b) {
TransfertBaseSQLComponent.openTransfertFrame(selectedRows, "FACTURE_FOURNISSEUR");
}
} catch (Exception e) {
ExceptionHandler.handle("Erreur lors du transfert des " + getPluralName() + "!", e);
}
}
};
worker.execute();
}
}, true);
actionsTRFA.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
 
127,7 → 85,6
protected List<String> getListFields() {
final List<String> l = new ArrayList<>(5);
l.add("NUMERO");
l.add("NOM");
l.add("DATE");
l.add("ID_FOURNISSEUR");
l.add("TOTAL_HT");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/action/ListeDesBonsReceptionsAction.java
94,8 → 94,6
return frame;
}
 
private BigDecimal bigDecimal100 = new BigDecimal(100);
 
private BigDecimal getAvancement(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_BON_RECEPTION"));
long totalFact = 0;
108,7 → 106,7
}
}
if (total > 0) {
return this.bigDecimal100.min(new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP));
return new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
} else {
return BigDecimal.ONE.movePointRight(2);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ComptaContactSQLElement.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLComponent.java
17,7 → 17,6
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
76,7 → 75,6
private ContactItemTable table;
private ClientCodeArticleTable tableCustomProduct;
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) {
90,7 → 88,6
}
};
 
private CustomerProductQtyPriceListTable clienTarifTable = new CustomerProductQtyPriceListTable();
private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
private JCheckBox checkAdrLivraison, checkAdrFacturation;
 
170,8 → 167,6
return this.table;
} else if (id.equals("customerrelationship.customer.customproduct")) {
return this.tableCustomProduct;
} else if (id.equals("customerrelationship.customer.customtarif")) {
return this.clienTarifTable;
} else if (id.equals("customerrelationship.customer.addresses")) {
return createAdressesComponent();
} else if (id.equals("NOM")) {
248,7 → 243,6
super.update();
final int selectedID = getSelectedID();
this.table.updateField("ID_CLIENT", selectedID);
this.clienTarifTable.updateField("ID_CLIENT", selectedID);
this.tableCustomProduct.updateField("ID_CLIENT", selectedID);
this.adresseTable.updateField("ID_CLIENT", selectedID);
}
260,7 → 254,6
this.checkAdrFacturation.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_F") || r.isForeignEmpty("ID_ADRESSE_F"));
if (r != null) {
this.table.insertFrom("ID_CLIENT", r.asRowValues());
this.clienTarifTable.insertFrom("ID_CLIENT", r.asRowValues());
this.tableCustomProduct.insertFrom("ID_CLIENT", r.asRowValues());
this.adresseTable.insertFrom("ID_CLIENT", r.asRowValues());
}
301,7 → 294,6
id = super.insert(order);
this.table.updateField("ID_CLIENT", id);
this.tableCustomProduct.updateField("ID_CLIENT", id);
this.clienTarifTable.updateField("ID_CLIENT", id);
this.adresseTable.updateField("ID_CLIENT", id);
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.code.getText().trim())) {
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerGroup.java
94,9 → 94,6
final Group gCustomProduct = new Group("customerrelationship.customer.customproduct", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gCustomProduct.addItem("customerrelationship.customer.customproduct", new LayoutHints(true, true, true, true, true, true, true, true));
this.add(gCustomProduct);
final Group gCustomRemiseProduct = new Group("customerrelationship.customer.customtarif", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gCustomRemiseProduct.addItem("customerrelationship.customer.customtarif", new LayoutHints(true, true, true, true, true, true, true, true));
this.add(gCustomRemiseProduct);
 
this.add(gState);
final Group gInfo = new Group("customerrelationship.customer.info", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ClientNormalSQLElement.java
22,19 → 22,14
import org.openconcerto.ql.QLPrinter;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.EmailComposer;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.Font;
42,7 → 37,6
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
 
import javax.swing.AbstractAction;
 
186,28 → 180,6
return l;
}
 
@Override
protected void _initTableSource(SQLTableModelSource res) {
super._initTableSource(res);
 
res.getColumns().add(new BaseSQLTableModelColumn(getDirectory().getTranslator().getLabelFor(getTable().getField("CATEGORIES")), String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
return r.getString("CATEGORIES");
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
return CollectionUtils.createSet(new FieldPath(p, "CATEGORIES"));
 
}
});
 
}
 
/*
* (non-Javadoc)
*
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ContactSQLElement.java
New file
0,0 → 1,56
/*
* 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.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
 
import java.awt.event.ActionEvent;
 
import javax.swing.AbstractAction;
 
public class ContactSQLElement extends ContactSQLElementBase {
 
static public class ContactFournisseurSQLElement extends ContactSQLElement {
public ContactFournisseurSQLElement() {
super("CONTACT_FOURNISSEUR");
}
}
 
static public class ContactAdministratifSQLElement extends ContactSQLElement {
public ContactAdministratifSQLElement() {
super("CONTACT_ADMINISTRATIF");
}
}
 
public ContactSQLElement() {
this("CONTACT");
 
}
 
protected ContactSQLElement(String tableName) {
super(tableName);
PredicateRowAction action = new PredicateRowAction(new AbstractAction() {
 
@Override
public void actionPerformed(ActionEvent e) {
sendMail(IListe.get(e).getSelectedRows());
 
}
}, true, "customerrelationship.customer.email.send");
action.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
getRowActions().add(action);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/report/ReportingCommercialItem.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/report/ReportingCommercial.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/report/ReportingCommercialCreator.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/report/ReportingCommercialPanel.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/report/ReportingCommercialPDF.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/action/ListeDesContactsAction.java
15,7 → 15,7
 
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement;
 
public class ListeDesContactsAction extends CreateIListFrameAbstractAction<ContactSQLElement> {
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/action/ListeDesClientsAction.java
15,8 → 15,9
 
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.customerrelationship.customer.element.ClientNormalSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerSQLElement;
import org.openconcerto.erp.core.sales.invoice.ui.EcheanceRenderer;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.view.IListFrame;
25,12 → 26,10
 
import javax.swing.JTable;
 
public class ListeDesClientsAction extends CreateIListFrameAbstractAction<SQLElement> {
public class ListeDesClientsAction extends CreateIListFrameAbstractAction<ClientNormalSQLElement> {
 
public ListeDesClientsAction(final ComptaPropsConfiguration conf) {
// handle CustomerSQLElement/ClientSocieteSQLElement (or even a module replacing the
// default element)
super(conf, conf.getDirectory().getElement(conf.getRootSociete().getTable("CLIENT")));
super(conf, CustomerSQLElement.class);
}
 
@Override
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/ui/CategorieComptableChoiceUI.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/EmailTemplateSQLElement.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/EmailTemplateGroup.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/ValueListener.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/EmailTemplate.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/EmailTemplateSQLComponent.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/mail/action/ListeDesModelesEmailAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/AssociationAnalytiqueSQLElement.java
16,8 → 16,6
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.SQLElementLink.LinkType;
import org.openconcerto.sql.element.SQLElementLinksSetup;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.graph.Path;
46,14 → 44,6
this.setAction("ID_SAISIE_KM_ELEMENT", ReferenceAction.CASCADE);
}
 
@Override
protected void setupLinks(SQLElementLinksSetup links) {
super.setupLinks(links);
if (getTable().contains("ID_ECRITURE")) {
links.get("ID_ECRITURE").setType(LinkType.ASSOCIATION);
}
}
 
protected List<String> getListFields() {
final List<String> list = new ArrayList<String>(2);
list.add("ID_ECRITURE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java
65,6 → 65,8
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;
78,6 → 80,7
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
 
150,11 → 153,6
return "ID_MOUVEMENT";
}
 
@Override
public boolean isPrivate() {
return false;
}
 
// Impossible de modifier si validée
// FIXME impossible de saisir une écriture avant la date de debut d'exercice --> de saisir de
// document de gest comm
198,9 → 196,67
}
 
public void consultationCompte(SQLRowAccessor rowCpt) {
final ListeDesEcrituresPanel panel = new ListeDesEcrituresPanel();
final ConsultationCompteFrame f = new ConsultationCompteFrame(panel, 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().setModificationAllowed(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().setModificationAllowed(false);
f.pack();
f.setVisible(true);
640,9 → 696,7
 
// on archive le mouvement
if (dropMvt) {
 
SQLElement elt = getDirectory().getElement(tableMvt);
 
SQLElement elt = Configuration.getInstance().getDirectory().getElement(tableMvt);
try {
elt.archive(idMvt);
} catch (SQLException e) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033A.java
499,9 → 499,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("102", 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);
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
215,7 → 215,7
* VARIATION DE STOCK
******************************************************************************************/
// 240 SommeSolde( 6030, 6036* )
long v240 = this.sommeCompte.soldeCompte(6031, 6036, true, this.dateDeb, this.dateFin);
long v240 = this.sommeCompte.soldeCompte(6031, 6032, true, this.dateDeb, this.dateFin);
this.m.put("CHARGES3.11", GestionDevise.currencyToString(v240, false));
 
// 213
264,7 → 264,7
******************************************************************************************/
// 250 SommeSolde( 640, 644* )+SommeSolde( 648, 649* )
long v250 = this.sommeCompte.soldeCompte(644, 644, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(648, 649, true, this.dateDeb, this.dateFin)
+ this.sommeCompte.soldeCompte(641, 641, true, this.dateDeb, this.dateFin)+ this.sommeCompte.soldeCompte(642, 642, true, this.dateDeb, this.dateFin);
+ this.sommeCompte.soldeCompte(641, 641, true, this.dateDeb, this.dateFin);
this.m.put("CHARGES3.14", GestionDevise.currencyToString(v250, false));
 
// 220
352,7 → 352,7
* PRODUITS FINANCIERS
******************************************************************************************/
// 280 -SommeSolde( 760, 769* )-SommeSolde( 786, 786* )-SommeSolde( 796, 796* )
long v280 = -this.sommeCompte.soldeCompte(760, 768, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(786, 786, true, this.dateDeb, this.dateFin)
long v280 = -this.sommeCompte.soldeCompte(761, 768, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(786, 786, true, this.dateDeb, this.dateFin)
- this.sommeCompte.soldeCompte(796, 796, true, this.dateDeb, this.dateFin);
this.m.put("PCHARGES3.21", GestionDevise.currencyToString(v280, false));
 
369,7 → 369,7
* PRODUITS EXCEPTIONNELS
******************************************************************************************/
// 290 -SommeSolde( 77, 77* )-SommeSolde( 787, 789* )-SommeSolde( 797, 799* )
long v290 = -this.sommeCompte.soldeCompte(770, 772, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(775, 778, true, this.dateDeb, this.dateFin)
long v290 = -this.sommeCompte.soldeCompte(771, 772, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(775, 778, true, this.dateDeb, this.dateFin)
- this.sommeCompte.soldeCompte(787, 787, true, this.dateDeb, this.dateFin) - this.sommeCompte.soldeCompte(797, 797, true, this.dateDeb, this.dateFin);
this.m.put("PCHARGES3.22", GestionDevise.currencyToString(v290, false));
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/GrandLivreSheetXML.java
179,8 → 179,47
@Override
public SQLSelect transformChecked(SQLSelect sel) {
 
Where w = getWhere(lCompteSolde);
Where w = (new Where(tableEcriture.getField("DATE"), GrandLivreSheetXML.this.dateDu, GrandLivreSheetXML.this.dateAu));
 
if (GrandLivreSheetXML.this.compteDeb.equals(GrandLivreSheetXML.this.compteEnd)) {
w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), "=", GrandLivreSheetXML.this.compteDeb));
} else {
w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), (Object) GrandLivreSheetXML.this.compteDeb, (Object) GrandLivreSheetXML.this.compteEnd));
}
w = w.and(new Where(tableEcriture.getField("ID_JOURNAL"), "!=", idJrnlExclude));
w = w.and(new Where(tableEcriture.getField("ID_MOUVEMENT"), "=", tableMvt.getField("ID")));
 
if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODELETTREE) {
Object o = null;
w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "<>", o));
w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "!=", ""));
w = w.and(new Where(tableEcriture.getField("DATE_LETTRAGE"), "<=", GrandLivreSheetXML.this.dateAu));
} else if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODENONLETTREE_PERIODE) {
Object o = null;
Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
Where wSTTC = new Where(tableEcriture.getField("DATE_LETTRAGE"), "<>", o);
wSTTC = wSTTC.and(new Where(tableEcriture.getField("DATE_LETTRAGE"), ">", GrandLivreSheetXML.this.dateAu));
 
w2 = w2.or(wSTTC);
w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
} else if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODENONLETTREE_ALL) {
Object o = null;
Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
}
 
if (GrandLivreSheetXML.this.excludeCompteSolde) {
System.err.println("Exclude compte");
 
w = w.and(new Where(tableEcriture.getField("ID_COMPTE_PCE"), lCompteSolde).not());
}
w = w.and(new Where(tableEcriture.getField("NOM"), "NOT LIKE", "Fermeture du compte%"));
 
if (!UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
// TODO Show Restricted acces in UI
w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), "LIKE", "411%"));
}
 
sel.setWhere(w);
sel.addFieldOrder(tableEcriture.getField("COMPTE_NUMERO"));
sel.addFieldOrder(tableEcriture.getField("DATE"));
528,8 → 567,36
sel.addSelect(tableEcriture.getField("DEBIT"), "SUM");
sel.addSelect(tableEcriture.getField("CREDIT"), "SUM");
 
Where w = getWhere(null);
Where w;
if (this.compteDeb.equals(this.compteEnd)) {
w = new Where(tableCompte.getField("NUMERO"), "=", this.compteDeb);
} else {
w = new Where(tableCompte.getField("NUMERO"), (Object) this.compteDeb, (Object) this.compteEnd);
}
 
w = w.and(new Where(tableEcriture.getField("ID_COMPTE_PCE"), "=", tableCompte.getField("ID")));
 
if (this.cumul) {
w = w.and(new Where(tableEcriture.getField("DATE"), "<=", this.dateAu));
} else {
w = w.and(new Where(tableEcriture.getField("DATE"), this.dateDu, this.dateAu));
}
w = w.and(new Where(tableEcriture.getField("ID_JOURNAL"), "!=", idJrnlExclude));
if (this.lettrage == GrandLivreSheet.MODELETTREE) {
Object o = null;
w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "<>", o));
w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "!=", ""));
} else if (this.lettrage == GrandLivreSheet.MODENONLETTREE_ALL) {
Object o = null;
Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
 
} else if (this.lettrage == GrandLivreSheet.MODENONLETTREE_PERIODE) {
Object o = null;
Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
}
 
sel.setWhere(w);
 
String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\"";
556,52 → 623,6
return list;
}
 
private Where getWhere(final List<Integer> lCompteSolde) {
Where w = (new Where(tableEcriture.getField("DATE"), GrandLivreSheetXML.this.dateDu, GrandLivreSheetXML.this.dateAu));
 
if (GrandLivreSheetXML.this.compteDeb.equals(GrandLivreSheetXML.this.compteEnd)) {
w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), "=", GrandLivreSheetXML.this.compteDeb));
} else {
w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), (Object) GrandLivreSheetXML.this.compteDeb, (Object) GrandLivreSheetXML.this.compteEnd));
}
w = w.and(new Where(tableEcriture.getField("ID_JOURNAL"), "!=", idJrnlExclude));
w = w.and(new Where(tableEcriture.getField("ID_MOUVEMENT"), "=", tableMvt.getField("ID")));
 
if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODELETTREE) {
Object o = null;
w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "<>", o));
w = w.and(new Where(tableEcriture.getField("LETTRAGE"), "!=", ""));
w = w.and(new Where(tableEcriture.getField("DATE_LETTRAGE"), "<=", GrandLivreSheetXML.this.dateAu));
} else if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODENONLETTREE_PERIODE) {
Object o = null;
Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
Where wSTTC = new Where(tableEcriture.getField("DATE_LETTRAGE"), "<>", o);
wSTTC = wSTTC.and(new Where(tableEcriture.getField("DATE_LETTRAGE"), ">", GrandLivreSheetXML.this.dateAu));
 
w2 = w2.or(wSTTC);
w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
} else if (GrandLivreSheetXML.this.lettrage == GrandLivreSheet.MODENONLETTREE_ALL) {
Object o = null;
Where w2 = new Where(tableEcriture.getField("LETTRAGE"), "=", o);
w = w.and(w2.or(new Where(tableEcriture.getField("LETTRAGE"), "=", "")));
}
 
if (GrandLivreSheetXML.this.excludeCompteSolde) {
System.err.println("Exclude compte");
 
if (lCompteSolde != null) {
w = w.and(new Where(tableEcriture.getField("ID_COMPTE_PCE"), lCompteSolde).not());
}
}
w = w.and(new Where(tableEcriture.getField("NOM"), "NOT LIKE", "Fermeture du compte%"));
 
if (!UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
// TODO Show Restricted acces in UI
w = w.and(new Where(tableEcriture.getField("COMPTE_NUMERO"), "LIKE", "411%"));
}
return w;
}
 
/**
* @param d date limite des cumuls
* @return Map<Integer id compte, Long solde(debit-credit)>
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ComptaPrefTreeNode.java
31,6 → 31,7
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.erp.preferences.GestionPieceCommercialePanel;
import org.openconcerto.erp.preferences.ImpressionGestCommPreferencePanel;
import org.openconcerto.erp.preferences.MailRelancePreferencePanel;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.erp.preferences.NumerotationPreferencePanel;
import org.openconcerto.erp.preferences.PayPalPreferencePanel;
118,6 → 119,7
nsGlobale.add(new PrefTreeNode(GenerationDocGlobalPreferencePanel.class, "Génération des Documents", new String[] { "documents" }));
nsGlobale.add(new PrefTreeNode(GestionClientPreferencePanel.class, "Gestion des clients", new String[] { "client", "service" }));
nsGlobale.add(new PrefTreeNode(GestionCommercialeGlobalPreferencePanel.class, "Gestion des piéces commericales", new String[] { "transfert", "numéro" }));
nsGlobale.add(new PrefTreeNode(MailRelancePreferencePanel.class, "Email de relance", new String[] { "relance", "mail" }));
 
// PayPal
final PrefTreeNode nPayPall = new PrefTreeNode(PayPalPreferencePanel.class, "PayPal", new String[] { "paypal", "facture" });
160,6 → 162,7
final PrefTreeNode nMail = new PrefTreeNode(EmailNode.class, "EMail", new String[] { "email", "mail", "courriel" });
nsPoste.add(nMail);
 
 
// add preferences for modules
for (final AbstractModule module : moduleManager.getRunningModules().values()) {
for (final Entry<Boolean, List<ModulePreferencePanelDesc>> e : module.getPrefDescriptorsByLocation(moduleManager.getRoot()).entrySet()) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteGestCommPreferencePanel.java
15,7 → 15,6
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
import org.openconcerto.erp.model.ISQLCompteSelector;
import org.openconcerto.erp.preferences.DefaultNXProps;
46,7 → 45,7
 
private ISQLCompteSelector selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteValeurEncaissement, selCompteAvanceClient, selCompteClient, selCompteVenteProduits,
selCompteVenteService, selCompteTVACol, selCompteTVADed, selCompteTVAImmo, selCompteAchatIntra, selCompteFactor, selComptePortSoumis, selComptePortNonSoumis;
private ElementComboBox selJrnlFactor, selJrnlValEnc;
private ElementComboBox selJrnlFactor;
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
private SQLRowValues rowPrefCompteVals = new SQLRowValues(tablePrefCompte);
175,17 → 174,6
this.selCompteValeurEncaissement.init();
this.add(this.selCompteValeurEncaissement, c);
 
// Journal
c.gridy++;
c.weightx = 0;
c.gridx = 0;
this.add(new JLabel("Journal dépôt chèque"), c);
c.weightx = 1;
c.gridx++;
this.selJrnlValEnc = new ElementComboBox();
this.selJrnlValEnc.init(Configuration.getInstance().getDirectory().getElement("JOURNAL"));
this.add(this.selJrnlValEnc, c);
 
// Compte vente produits
c.gridy++;
c.weightx = 0;
337,10 → 325,6
this.rowPrefCompteVals.put("ID_COMPTE_PCE_FACTOR", this.selCompteFactor.getValue());
final int selectedId = this.selJrnlFactor.getSelectedId();
this.rowPrefCompteVals.put("ID_JOURNAL_FACTOR", (selectedId > 1) ? selectedId : 1);
 
final int selectedIdEnc = this.selJrnlValEnc.getSelectedId();
this.rowPrefCompteVals.put("ID_JOURNAL_VALEUR_ENCAISSEMENT", (selectedIdEnc > 1) ? selectedIdEnc : 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());
404,7 → 388,6
this.selCompteFactor.setValue(value);
 
this.selJrnlFactor.setValue(GenerationMvtSaisieVenteFacture.journal);
this.selJrnlValEnc.setValue(JournalSQLElement.BANQUES);
 
// Fournisseurs
compte = ComptePCESQLElement.getComptePceDefault("Fournisseurs");
472,22 → 455,14
setComboValues(selCompteVenteService, "ID_COMPTE_PCE_VENTE_SERVICE", "VentesServices");
setComboValues(selCompteFactor, "ID_COMPTE_PCE_FACTOR", "Factor");
 
{
// Journal Factor
int value = (this.rowPrefCompteVals.getObject("ID_JOURNAL_FACTOR") == null ? 1 : this.rowPrefCompteVals.getInt("ID_JOURNAL_FACTOR"));
if (value <= 1) {
 
value = GenerationMvtSaisieVenteFacture.journal;
}
this.selJrnlFactor.setValue(value);
}
{
// Journal Val enc
int value = (this.rowPrefCompteVals.getObject("ID_JOURNAL_VALEUR_ENCAISSEMENT") == null ? 1 : this.rowPrefCompteVals.getInt("ID_JOURNAL_VALEUR_ENCAISSEMENT"));
if (value <= 1) {
value = JournalSQLElement.BANQUES;
}
this.selJrnlValEnc.setValue(value);
}
 
setComboValues(selCompteFourn, "ID_COMPTE_PCE_FOURNISSEUR", "Fournisseurs");
setComboValues(selCompteClient, "ID_COMPTE_PCE_CLIENT", "Clients");
setComboValues(selCompteAvanceClient, "ID_COMPTE_PCE_AVANCE_CLIENT", "AvanceClients");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ListeDesEcrituresPanel.java
13,10 → 13,6
package org.openconcerto.erp.core.finance.accounting.ui;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.ITableModel;
import org.openconcerto.ui.DefaultGridBagConstraints;
26,7 → 22,6
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.Date;
 
import javax.swing.BorderFactory;
import javax.swing.JLabel;
59,18 → 54,9
c.fill = GridBagConstraints.BOTH;
this.add(this.panelEcritures, c);
 
SQLRow rowExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON").getRow(ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getInt("ID_EXERCICE_COMMON"));
 
final IListFilterDatePanel comp = new IListFilterDatePanel(this.panelEcritures.getListe(), this.panelEcritures.getListe().getSource().getElem().getTable().getField("DATE"),
IListFilterDatePanel.getDefaultMap());
comp.setDateDu((Date) rowExercice.getObject("DATE_DEB"));
c.weightx = 1;
c.gridy++;
this.add(comp, c);
 
/* Panel Legende */
c.gridwidth = 1;
c.gridy++;
c.gridy = GridBagConstraints.RELATIVE;
this.panelLegende = new JPanel();
this.panelLegende.setLayout(new GridBagLayout());
this.panelLegende.setBorder(BorderFactory.createTitledBorder("Légende"));
81,7 → 67,6
panelValide.add(new JLabel("Ecritures validées"));
panelValide.setBackground(Color.WHITE);
// panelValide.setBorder(BorderFactory.createLineBorder(Color.BLACK));
c.gridy++;
this.panelLegende.add(panelValide, c);
 
JPanel panelNonValide = new JPanel();
89,7 → 74,6
panelNonValide.add(new JLabel("Ecritures non validées"));
panelNonValide.setBackground(ListEcritureRenderer.getCouleurEcritureNonValide());
// panelNonValide.setBorder(BorderFactory.createLineBorder(Color.BLACK));
c.gridy++;
this.panelLegende.add(panelNonValide, c);
 
JPanel panelNonValideToDay = new JPanel();
97,10 → 81,9
panelNonValideToDay.add(new JLabel("Ecritures non validées du jour"));
panelNonValideToDay.setBackground(ListEcritureRenderer.getCouleurEcritureToDay());
// panelNonValideToDay.setBorder(BorderFactory.createLineBorder(Color.BLACK));
c.gridy++;
this.panelLegende.add(panelNonValideToDay, c);
 
c.gridy = 2;
c.gridy = 1;
c.weightx = 0;
c.weighty = 0;
c.insets = new Insets(2, 2, 1, 2);
108,7 → 91,7
 
/* Panel Total */
c.gridx = 0;
// c.gridy = 0;
c.gridy = 0;
this.panelTotal = new JPanel();
this.panelTotal.setLayout(new GridBagLayout());
this.panelTotal.setBorder(BorderFactory.createTitledBorder("Totaux"));
142,7 → 125,7
c.gridx++;
this.panelTotal.add(this.montantSolde, c);
 
c.gridy = 2;
c.gridy = 1;
c.gridx = 1;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/EcritureGrandLivreRenderer.java
40,16 → 40,23
}
 
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
 
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
 
TableCellRendererUtils.setBackgroundColor(this, table, isSelected);
 
if (!isSelected) {
 
Ecriture ecrTmp = ((ConsultCompteModel) this.model.getTableModel()).getEcritures().get(this.model.viewIndex(row));
 
if (!ecrTmp.getValide()) {
// this.setForeground(couleurEcritureValide);
Date dateEcr = ecrTmp.getDate();
Date dateToDay = new Date();
 
if ((dateEcr.getDate() == dateToDay.getDate()) && (dateEcr.getMonth() == dateToDay.getMonth()) && (dateEcr.getYear() == dateToDay.getYear())) {
// System.out.println("ToDay :: " + dateToDay + " Ecr ::: " + dateEcr);
 
this.setBackground(couleurEcritureToDay);
} else {
this.setBackground(couleurEcritureValide);
56,13 → 63,14
}
}
}
if (value != null) {
 
if (value instanceof Date) {
this.setText(dateFormat.format((Date) value));
} else if (value.getClass() == Long.class) {
}
if (value.getClass() == Long.class) {
this.setText(GestionDevise.currencyToString(((Long) value).longValue()));
}
}
 
return this;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieKmItemTable.java
20,7 → 20,6
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.TM;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLRow;
39,16 → 38,13
import org.openconcerto.sql.view.list.TextTableCellEditorWithCompletion;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JComponentUtils;
import org.openconcerto.utils.checks.ValidState;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
55,7 → 51,6
import java.util.Vector;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
148,7 → 143,7
@Override
public ValidState getValidState(Object o) {
if (o != null) {
return this.elt.getCompteNumeroValidState(o.toString());
return elt.getCompteNumeroValidState(o.toString());
}
return super.getValidState(o);
}
166,19 → 161,8
m2.setWhere(w);
 
TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
JButton buttonClone = new JButton(TM.tr("duplicateLine"));
buttonClone.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
cloneLine(table.getSelectedRow());
}
});
buttonClone.setEnabled(false);
c.gridx++;
JComponentUtils.setMinimumWidth(buttonClone, 95);
 
RowValuesTableControlPanel rowValuesTableControlPanel = new RowValuesTableControlPanel(this.table, Arrays.asList(buttonClone));
rowValuesTableControlPanel.setVisibleButtonClone(false);
this.add(rowValuesTableControlPanel, c);
this.add(new RowValuesTableControlPanel(this.table), c);
 
c.gridy++;
c.fill = GridBagConstraints.BOTH;
238,29 → 222,6
 
}
 
private void cloneLine(int row) {
if (row < 0) {
System.err.println("RowValuesTableControlPanel.cloneLine() wrong selected line, index = " + row);
Thread.dumpStack();
return;
}
SQLRowValues rowVals = this.table.getRowValuesTableModel().getRowValuesAt(row);
 
SQLRowValues rowValsBis = rowVals.deepCopy();
rowValsBis.clearPrimaryKeys();
rowValsBis.put(rowValsBis.getTable().getOrderField().getName(), null);
 
this.table.getRowValuesTableModel().getSQLElement().clearPrivateFields(rowValsBis);
rowValsBis.putEmptyLink("ID_ECRITURE");
for (String elt : this.table.getClearCloneTableElement()) {
if (rowValsBis.getTable().getFieldsName().contains(elt)) {
rowValsBis.putEmptyLink(elt);
}
}
 
this.table.getRowValuesTableModel().addRow(rowValsBis);
}
 
/**
* Remplit la RowValuesTable avec les ecritures du mouvement
*
373,11 → 334,11
assert SwingUtilities.isEventDispatchThread();
if (text == null)
return;
RowValuesTableModel model = this.table.getRowValuesTableModel();
RowValuesTableModel model = table.getRowValuesTableModel();
int size = model.getRowCount();
for (int i = 0; i < size; i++) {
SQLRowValues r = model.getRowValuesAt(i);
if (r.getString("NOM_ECRITURE") == null || r.getString("NOM_ECRITURE").trim().isEmpty() || r.getString("NOM_ECRITURE").equals(previousText)) {
if (r.getString("NOM_ECRITURE") == null || r.getString("NOM_ECRITURE").trim().isEmpty() || r.getString("NOM_ECRITURE").trim().equals(previousText)) {
r.put("NOM_ECRITURE", text);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieJournalItemTable.java
21,7 → 21,6
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieKm;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.TM;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
37,7 → 36,6
import org.openconcerto.sql.view.list.TextTableCellEditorWithCompletion;
import org.openconcerto.sql.view.list.ValidStateChecker;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JComponentUtils;
import org.openconcerto.ui.RangedIntegerTableCellEditor;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.GestionDevise;
47,7 → 45,6
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
57,7 → 54,6
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
66,7 → 62,6
 
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
300,21 → 295,10
 
TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
 
JButton buttonClone = new JButton(TM.tr("duplicateLine"));
buttonClone.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
cloneLine(table.getSelectedRow());
}
});
buttonClone.setEnabled(false);
c.gridx++;
JComponentUtils.setMinimumWidth(buttonClone, 95);
this.controlPanel = new RowValuesTableControlPanel(this.table);
controlPanel.setButtonAjouterEnabled(false);
this.add(controlPanel, c);
 
this.controlPanel = new RowValuesTableControlPanel(this.table, Arrays.asList(buttonClone));
this.controlPanel.setVisibleButtonClone(false);
this.controlPanel.setButtonAjouterEnabled(false);
this.add(this.controlPanel, c);
 
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
704,26 → 688,4
public void mouseExited(final MouseEvent e) {
}
 
private void cloneLine(int row) {
if (row < 0) {
System.err.println("RowValuesTableControlPanel.cloneLine() wrong selected line, index = " + row);
Thread.dumpStack();
return;
}
SQLRowValues rowVals = this.table.getRowValuesTableModel().getRowValuesAt(row);
 
SQLRowValues rowValsBis = rowVals.deepCopy();
rowValsBis.clearPrimaryKeys();
rowValsBis.put(rowValsBis.getTable().getOrderField().getName(), null);
 
this.table.getRowValuesTableModel().getSQLElement().clearPrivateFields(rowValsBis);
rowValsBis.putEmptyLink("ID_ECRITURE");
for (String elt : this.table.getClearCloneTableElement()) {
if (rowValsBis.getTable().getFieldsName().contains(elt)) {
rowValsBis.putEmptyLink(elt);
}
}
 
this.table.getRowValuesTableModel().addRow(rowValsBis);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteCloturePreferencePanel.java
133,7 → 133,7
this.rowPrefCompteVals.put("ID_COMPTE_PCE_BILAN_O", this.selCompteOuverture.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_BILAN_F", this.selCompteFermeture.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_RESULTAT", this.selCompteResultat.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_RESULTAT_PERTE", this.selCompteResultatPerte.getValue());
this.rowPrefCompteVals.put("ID_COMPTE_PCE_RESULTAT_PERTE", this.selCompteResultat.getValue());
this.rowPrefCompteVals.put("ID_JOURNAL_AN", this.selJournal.getValue());
this.rowPrefCompteVals.put("CREATE_NUL_SOLDE_ECR", this.boxCompteSolde.isSelected());
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/ConsultationCompteFrame.java
15,32 → 15,20
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.State;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.state.WindowStateManager;
 
import java.awt.DisplayMode;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
 
 
public class ConsultationCompteFrame extends JFrame {
// panel contenant la liste des ecritures
private final ListPanelEcritures panelEcritures;
49,13 → 37,12
 
private String titre;
 
private int indexID;
 
public ConsultationCompteFrame(ListeDesEcrituresPanel panel, SQLRowAccessor rowCpt) {
public ConsultationCompteFrame(ListeDesEcrituresPanel panel, String titre) {
super();
this.panel = panel;
this.panelEcritures = panel.getListPanelEcritures();
this.titre = "Consultation compte n°" + rowCpt.getString("NUMERO") + " " + rowCpt.getString("NOM");
this.titre = titre;
 
// rafraichir le titre à chaque changement de la liste
this.panelEcritures.getListe().addListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
76,74 → 63,8
}
});
}
 
SQLTable ecrTable = rowCpt.getTable().getTable("ECRITURE");
 
final int id = rowCpt.getID();
Where w = new Where(ecrTable.getField("ID_COMPTE_PCE"), "=", id);
getPanel().getListe().getRequest().setWhere(w);
 
final SQLTable cptTable = ecrTable.getForeignTable("ID_COMPTE_PCE");
List<SQLRow> rowsCpt = new ArrayList<SQLRow>(SQLBackgroundTableCache.getInstance().getCacheForTable(cptTable).getRows());
Collections.sort(rowsCpt, new Comparator<SQLRow>() {
@Override
public int compare(SQLRow o1, SQLRow o2) {
 
return o1.getString("NUMERO").compareTo(o2.getString("NUMERO"));
}
});
final List<Integer> idsCpt = new ArrayList<>();
for (SQLRow sqlRow : rowsCpt) {
idsCpt.add(sqlRow.getID());
}
this.indexID = idsCpt.indexOf(rowCpt.getID());
 
final PredicateRowAction prec = new PredicateRowAction(new AbstractAction("Précédent") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
if (indexID > 0) {
int newCptId = idsCpt.get(indexID - 1);
Where w = new Where(ecrTable.getField("ID_COMPTE_PCE"), "=", newCptId);
getPanel().getListe().getRequest().setWhere(w);
SQLRow rowCptNew = SQLBackgroundTableCache.getInstance().getCacheForTable(cptTable).getRowFromId(newCptId);
setTitle("Consultation compte n°" + rowCptNew.getString("NUMERO") + " " + rowCptNew.getString("NOM"));
indexID--;
}
 
}
}, true, false);
prec.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
panel.getListPanelEcritures().getListe().addIListeAction(prec);
 
final PredicateRowAction suivant = new PredicateRowAction(new AbstractAction("Suivant") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
if (indexID < idsCpt.size() - 1) {
int newCptId = idsCpt.get(indexID + 1);
Where w = new Where(ecrTable.getField("ID_COMPTE_PCE"), "=", newCptId);
getPanel().getListe().getRequest().setWhere(w);
SQLRow rowCptNew = SQLBackgroundTableCache.getInstance().getCacheForTable(cptTable).getRowFromId(newCptId);
setTitle("Consultation compte n°" + rowCptNew.getString("NUMERO") + " " + rowCptNew.getString("NOM"));
indexID++;
}
 
}
}, true, false);
suivant.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
panel.getListPanelEcritures().getListe().addIListeAction(suivant);
 
}
 
@Override
public void setTitle(String title) {
this.titre = title;
super.setTitle(title);
}
 
private String getPlural(String s, int nb) {
return nb + " " + s + (nb > 1 ? "s" : "");
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/component/EncaisserMontantSQLComponent.java
16,9 → 16,11
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.payment.element.EncaisserMontantSQLElement;
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
import org.openconcerto.erp.core.finance.payment.ui.EncaisseMontantTable;
import org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent;
import org.openconcerto.erp.generationEcritures.GenerationReglementVenteNG;
import org.openconcerto.erp.model.PrixTTC;
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
31,6 → 33,7
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
38,6 → 41,7
import org.openconcerto.ui.warning.JLabelWarning;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.StringUtils;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
import java.awt.GridBagConstraints;
51,6 → 55,7
 
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
178,6 → 183,7
 
this.addSQLObject(this.nom, "NOM");
 
 
this.addSQLObject(new ElementComboBox(), "ID_COMPTE_PCE_TIERS");
this.addSQLObject(new JTextField(), "TIERS");
DefaultGridBagConstraints.lockMinimumSize(this.montant);
299,17 → 305,64
public int insert(SQLRow order) {
 
int id = super.insert(order);
try {
this.table.updateField("ID_ENCAISSER_MONTANT", id);
 
System.out.println("Génération des ecritures du reglement");
SQLRow row = getTable().getRow(id);
String s = row.getString("NOM");
SQLRow rowModeRegl = row.getForeignRow("ID_MODE_REGLEMENT");
SQLRow rowTypeRegl = rowModeRegl.getForeignRow("ID_TYPE_REGLEMENT");
 
try {
((EncaisserMontantSQLElement) getElement()).regleFacture(row);
// Compte Client
SQLRow clientRow = row.getForeignRow("ID_CLIENT");
 
String label = "Règlement vente " + ((s == null) ? "" : s) + " (" + rowTypeRegl.getString("NOM") + ") " + StringUtils.limitLength(clientRow.getString("NOM"), 20);
long montant = row.getLong("MONTANT");
PrixTTC ttc = new PrixTTC(montant);
 
List<SQLRow> l = row.getReferentRows(Configuration.getInstance().getDirectory().getElement("ENCAISSER_MONTANT_ELEMENT").getTable());
if (l.isEmpty()) {
JOptionPane.showMessageDialog(null, "Un problème a été rencontré lors de l'encaissement! \n Les écritures comptables non pu être générer!");
System.err.println("Liste des échéances vides pour l'encaissement ID " + id);
Thread.dumpStack();
}
new GenerationReglementVenteNG(label, clientRow, ttc, row.getDate("DATE").getTime(), rowModeRegl, row, l.get(0).getForeignRow("ID_MOUVEMENT_ECHEANCE"), false, false,
row.getString("TIERS"), row.getForeign("ID_COMPTE_PCE_TIERS"));
 
// Mise a jour du montant de l'echeance
boolean supplement = false;
 
if (!row.getBoolean("ACOMPTE")) {
// On marque les echeances comme reglees
for (SQLRow sqlRow : l) {
 
final SQLRow rowEch = sqlRow.getForeignRow("ID_ECHEANCE_CLIENT");
SQLRowValues rowValsEch = rowEch.createEmptyUpdateRow();
if (sqlRow.getLong("MONTANT_REGLE") >= sqlRow.getLong("MONTANT_A_REGLER")) {
rowValsEch.put("REGLE", Boolean.TRUE);
if (sqlRow.getLong("MONTANT_REGLE") > sqlRow.getLong("MONTANT_A_REGLER")) {
supplement = true;
}
}
rowValsEch.put("MONTANT", Long.valueOf(rowEch.getLong("MONTANT") - sqlRow.getLong("MONTANT_REGLE")));
 
rowValsEch.update();
// this.comboEcheance.rowDeleted(tableEch, rowEch.getID());
// getTable().fireTableModified(rowEch.getID());
}
}
// si le montant réglé est supérieur, on crée une facture de complément
if (supplement) {
SQLElement elt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
EditFrame f = new EditFrame(elt, EditFrame.CREATION);
SaisieVenteFactureSQLComponent comp = (SaisieVenteFactureSQLComponent) f.getSQLComponent();
comp.setComplement(true);
f.setVisible(true);
}
} catch (Exception e) {
ExceptionHandler.handle("Erreur de génération des écritures", e);
ExceptionHandler.handle("Erreur lors de la génération des ecritures du reglement", e);
}
 
return id;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/ChequeAEncaisserSQLElement.java
100,13 → 100,9
l.add("DATE_VENTE");
l.add(getMinDateFieldName());
l.add("ID_CLIENT");
final ShowAs showAs = new ShowAs(getTable().getDBRoot());
if (getTable().contains("ID_BANQUE")) {
l.add("ID_BANQUE");
showAs.show(getTable().getForeignTable("ID_BANQUE"), "NOM");
}
l.add("MONTANT");
 
final ShowAs showAs = new ShowAs(getTable().getDBRoot());
 
final SQLTable mvtT = getTable().getForeignTable("ID_MOUVEMENT");
showAs.show(mvtT, "ID_PIECE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/element/EncaisserMontantSQLElement.java
17,13 → 17,9
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.payment.component.EncaisserMontantSQLComponent;
import org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent;
import org.openconcerto.erp.generationEcritures.GenerationReglementVenteNG;
import org.openconcerto.erp.model.PrixTTC;
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRow;
36,7 → 32,6
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
44,7 → 39,6
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.StringUtils;
 
import java.awt.event.ActionEvent;
import java.sql.SQLException;
57,8 → 51,6
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
 
public class EncaisserMontantSQLElement extends ComptaSQLConfElement {
 
172,77 → 164,7
super.archive(trees, cutLinks);
}
 
public void regleFacture(SQLRow row) throws Exception {
 
System.out.println("Génération des ecritures du reglement");
String s = row.getString("NOM");
SQLRow rowModeRegl = row.getForeignRow("ID_MODE_REGLEMENT");
SQLRow rowTypeRegl = rowModeRegl.getForeignRow("ID_TYPE_REGLEMENT");
 
// Compte Client
SQLRow clientRow = row.getForeignRow("ID_CLIENT");
 
String label = "Règlement vente " + ((s == null) ? "" : s) + " (" + rowTypeRegl.getString("NOM") + ") " + StringUtils.limitLength(clientRow.getString("NOM"), 20);
long montant = row.getLong("MONTANT");
PrixTTC ttc = new PrixTTC(montant);
 
List<SQLRow> l = row.getReferentRows(row.getTable().getTable("ENCAISSER_MONTANT_ELEMENT"));
if (l.isEmpty()) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
JOptionPane.showMessageDialog(null, "Un problème a été rencontré lors de l'encaissement! \n Les écritures comptables non pu être générer!");
}
});
System.err.println("Liste des échéances vides pour l'encaissement ID " + row.getID());
Thread.dumpStack();
return;
}
new GenerationReglementVenteNG(label, clientRow, ttc, row.getDate("DATE").getTime(), rowModeRegl, row, l.get(0).getForeignRow("ID_MOUVEMENT_ECHEANCE"), false, false, row.getString("TIERS"),
row.getForeign("ID_COMPTE_PCE_TIERS"));
 
// Mise a jour du montant de l'echeance
boolean supplement = false;
 
if (!row.getBoolean("ACOMPTE")) {
// On marque les echeances comme reglees
for (SQLRow sqlRow : l) {
 
final SQLRow rowEch = sqlRow.getForeignRow("ID_ECHEANCE_CLIENT");
SQLRowValues rowValsEch = rowEch.createEmptyUpdateRow();
if (sqlRow.getLong("MONTANT_REGLE") >= sqlRow.getLong("MONTANT_A_REGLER")) {
rowValsEch.put("REGLE", Boolean.TRUE);
if (sqlRow.getLong("MONTANT_REGLE") > sqlRow.getLong("MONTANT_A_REGLER")) {
supplement = true;
}
}
rowValsEch.put("MONTANT", Long.valueOf(rowEch.getLong("MONTANT") - sqlRow.getLong("MONTANT_REGLE")));
 
rowValsEch.update();
// this.comboEcheance.rowDeleted(tableEch, rowEch.getID());
// getTable().fireTableModified(rowEch.getID());
}
}
// si le montant réglé est supérieur, on crée une facture de complément
if (supplement) {
SQLElement elt = getDirectory().getElement("SAISIE_VENTE_FACTURE");
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
 
EditFrame f = new EditFrame(elt, EditFrame.CREATION);
SaisieVenteFactureSQLComponent comp = (SaisieVenteFactureSQLComponent) f.getSQLComponent();
comp.setComplement(true);
f.setVisible(true);
}
});
}
 
}
 
@Override
protected String createCodeSuffix() {
return ".category";
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/payment/ui/ListeDesChequesAEncaisserPanel.java
18,7 → 18,6
import org.openconcerto.erp.rights.ComptaTotalUserRight;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.users.rights.UserRightsManager;
54,10 → 53,10
 
@Override
protected JTextComponent createLabelText() {
if (this.fieldLabel == null) {
if (fieldLabel == null) {
this.fieldLabel = new JTextField();
}
return this.fieldLabel;
return fieldLabel;
}
 
@Override
67,16 → 66,18
@Override
public void actionPerformed(ActionEvent e) {
final String s = text.getText();
SQLRowValues rowValsDepot = new SQLRowValues(ListeDesChequesAEncaisserPanel.this.element.getTable().getTable("DEPOT_CHEQUE"));
SQLRowValues rowValsDepot = new SQLRowValues(element.getTable().getTable("DEPOT_CHEQUE"));
rowValsDepot.put("DATE", dateDepot.getValue());
rowValsDepot.put("NOM", ListeDesChequesAEncaisserPanel.this.fieldLabel.getText());
rowValsDepot.put("NOM", fieldLabel.getText());
final SQLRow selectedBanque = banqueSelect.getSelectedRow();
if (selectedBanque != null) {
rowValsDepot.put("ID_" + selectedBanque.getTable().getName(), selectedBanque.getID());
}
final List<SQLRow> chq = SQLRowListRSH.fetch(getListe().getRequest().getPrimaryTable(), getListe().getSelection().getSelectedIDs());
for (SQLRow rowChq : chq) {
SQLRowValues rowValsDepotElt = new SQLRowValues(ListeDesChequesAEncaisserPanel.this.element.getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
List<SQLRowValues> chq = getListe().getSelectedRows();
for (SQLRowValues sqlRowValues : chq) {
SQLRow rowChq = sqlRowValues.asRow();
rowChq.fetchValues();
SQLRowValues rowValsDepotElt = new SQLRowValues(element.getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
rowValsDepotElt.put("ID_DEPOT_CHEQUE", rowValsDepot);
if (rowChq.getObject("ID_CLIENT") != null && !rowChq.isForeignEmpty("ID_CLIENT")) {
rowValsDepotElt.put("ID_CLIENT", rowChq.getForeignID("ID_CLIENT"));
95,7 → 96,7
rowValsDepotElt.put("NUMERO", (rowChq.getObject("NUMERO") == null ? "" : rowChq.getObject("NUMERO")));
rowValsDepotElt.put("MONTANT", rowChq.getObject("MONTANT"));
}
EditFrame frame = new EditFrame(ListeDesChequesAEncaisserPanel.this.element.getDirectory().getElement("DEPOT_CHEQUE"), EditMode.CREATION);
EditFrame frame = new EditFrame(element.getDirectory().getElement("DEPOT_CHEQUE"), EditMode.CREATION);
frame.getSQLComponent().select(rowValsDepot);
frame.setVisible(true);
text.setText("");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/employe/element/EtatCivilSQLElement.java
293,7 → 293,7
c.gridwidth = 1;
c.weightx = 1;
JTextField fieldNTT = new JTextField();
panelSituation.add(fieldNTT, c);
panelSituation.add(fieldCNPS, c);
c.weightx = 0;
c.gridwidth = 1;
addView(fieldNTT, "NTT");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/SalarieSQLElement.java
15,7 → 15,6
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactItemTable;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ElementSQLObject;
26,17 → 25,15
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.UndefinedRowValuesCache;
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.EditPanelListener;
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.FormLayouter;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.warning.JLabelWarning;
import org.openconcerto.utils.checks.ValidState;
49,11 → 46,9
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
99,7 → 94,6
try {
rowInfosAncien.createEmptyUpdateRow().put("ID_SALARIE", rowSelected.getID()).commit();
rowSelected.createEmptyUpdateRow().put("ID_INFOS_SALARIE_PAYE", id).commit();
infosPayeElement.getTable().getRow(id).createEmptyUpdateRow().put("ID_SALARIE", rowSelected.getID()).commit();
} catch (SQLException e) {
e.printStackTrace();
}
147,7 → 141,7
return new BaseSQLComponent(this) {
private final JLabel warningCodeSalLabel = new JLabelWarning();
private final JTextField textCode = new JTextField();
ContactItemTable tableContact = new ContactItemTable(UndefinedRowValuesCache.getInstance().getDefaultRowValues(getTable().getTable("CONTACT_SALARIE")));
 
private JTabbedPane tabbedPane;
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
 
212,18 → 206,6
}
});
 
// User
final JLabel labelUser = new JLabel(getLabelFor("ID_USER_COMMON"));
final ElementComboBox comboUser = new ElementComboBox(false, 50);
c.gridx = 0;
c.gridy++;
this.add(labelUser, c);
c.gridx++;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
this.add(comboUser, c);
this.addView(comboUser, "ID_USER_COMMON");
 
/***********************************************************************************
* TABBED PANE
**********************************************************************************/
236,18 → 218,6
scrollEtatCivil.setBorder(null);
this.tabbedPane.add("Etat Civil", scrollEtatCivil);
 
// Contact
JPanel panelContact = new JPanel(new GridBagLayout());
DefaultGridBagConstraints cContact = new DefaultGridBagConstraints();
cContact.weighty = 1;
cContact.weightx = 1;
cContact.fill = GridBagConstraints.BOTH;
 
panelContact.add(tableContact, cContact);
JScrollPane scrollContact = new JScrollPane(panelContact);
scrollContact.setBorder(null);
this.tabbedPane.add("Contacts", scrollContact);
 
// Règlement de la paye
this.addView("ID_REGLEMENT_PAYE", REQ + ";" + DEC + ";" + SEP);
ElementSQLObject eltReglPaye = (ElementSQLObject) this.getView("ID_REGLEMENT_PAYE");
316,18 → 286,7
this.tabbedPane.add("Cumuls et variables de la période", new JScrollPane(panelAllCumul));
// this.tabbedPane.setEnabledAt(this.tabbedPane.getTabCount() - 1, false);
 
Map<String, JComponent> additionalFields = getElement().getAdditionalFields();
if (additionalFields != null && additionalFields.size() > 0) {
// Champ Module
c.gridx = 0;
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
this.tabbedPane.add("Compléments", new JScrollPane(addP));
}
 
c.gridy++;
c.gridx = 0;
c.weighty = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
376,19 → 335,15
* }
*/
checkCode();
if (r != null) {
this.tableContact.insertFrom("ID_SALARIE", r.asRowValues());
}
}
 
public void update() {
 
super.update();
 
SQLTable tableFichePaye = getTable().getBase().getTable("FICHE_PAYE");
SQLRowValues rowVals = new SQLRowValues(tableFichePaye);
rowVals.put("ID_SALARIE",
 
getSelectedID());
rowVals.put("ID_SALARIE", getSelectedID());
SQLRow row = getTable().getRow(getSelectedID());
try {
rowVals.update(row.getInt("ID_FICHE_PAYE"));
395,7 → 350,6
} catch (SQLException e) {
e.printStackTrace();
}
this.tableContact.updateField("ID_SALARIE", getSelectedID());
}
 
public int insert(SQLRow order) {
433,10 → 387,9
e.printStackTrace();
}
}
this.tableContact.updateField("ID_SALARIE", id);
 
return id;
}
 
};
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/InfosSalariePayeSQLElement.java
442,19 → 442,6
panelBase.add(sectionAT, c);
addView(sectionAT, "CODE_SECTION_AT");
 
if (getTable().contains("DUREE_FORFAIT")) {
JLabel labelForfait = new JLabel(getLabelFor("DUREE_FORFAIT"));
labelForfait.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField forfait = new JTextField();
c.gridx++;
c.weightx = 0;
panelBase.add(labelForfait, c);
c.gridx++;
c.weightx = 1;
panelBase.add(forfait, c);
addView(forfait, "DUREE_FORFAIT");
}
 
c.gridy = 5;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ReglementPayeSQLElement.java
97,7 → 97,7
JLabel labelNomBq = new JLabel(getLabelFor("NOM_BANQUE"));
labelNomBq.setHorizontalAlignment(SwingConstants.RIGHT);
SQLTextCombo textNomBq = new SQLTextCombo();
c.weightx = 0;
 
panelBanque.add(labelNomBq, c);
c.gridx++;
c.weightx = 1;
104,32 → 104,6
panelBanque.add(textNomBq, c);
c.weightx = 0;
 
// IBAN
JLabel labelIBAN = new JLabel(getLabelFor("IBAN"));
labelIBAN.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textIBAN = new JTextField();
 
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelBanque.add(labelIBAN, c);
c.gridx++;
c.weightx = 1;
panelBanque.add(textIBAN, c);
 
// BIC
JLabel labelBIC = new JLabel(getLabelFor("BIC"));
labelBIC.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textBIC = new JTextField();
 
c.gridy++;
c.gridx = 0;
c.weightx = 0;
panelBanque.add(labelBIC, c);
c.gridx++;
c.weightx = 1;
panelBanque.add(textBIC, c);
 
// RIB
JLabel labelRIB = new JLabel(getLabelFor("RIB"));
labelRIB.setHorizontalAlignment(SwingConstants.RIGHT);
179,13 → 153,11
c.gridy++;
panelReglement.add(radioLe, c);
c.gridx++;
c.weightx = 1;
panelReglement.add(textLe, c);
textLe.setText("31");
c.gridx++;
c.weightx = 0;
c.weightx = 1;
panelReglement.add(labelDu, c);
c.weightx = 1;
 
c.gridy++;
c.gridx = 0;
238,7 → 210,6
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 1;
c.weightx = 0;
panelCompta.add(labelCompteSal, c);
c.gridx++;
c.weightx = 1;
254,8 → 225,6
 
this.addSQLObject(textNomBq, "NOM_BANQUE");
this.addSQLObject(textRIB, "RIB");
this.addSQLObject(textIBAN, "IBAN");
this.addSQLObject(textBIC, "BIC");
this.addRequiredSQLObject(typeRegl, "ID_MODE_REGLEMENT_PAYE");
this.addRequiredSQLObject(textLe, "LE");
this.addRequiredSQLObject(compteSal, "ID_COMPTE_PCE");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/ContratSalarieSQLElement.java
113,20 → 113,6
c.weightx = 1;
this.add(selCodeCatSocio, c);
JLabel complPCSLabel = new JLabel(getLabelFor("COMPLEMENT_PCS"));
complPCSLabel.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField complPCS = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(complPCSLabel, c);
c.gridx++;
c.weightx = 1;
this.add(complPCS, c);
addView(complPCS,"COMPLEMENT_PCS");
 
// Contrat de travail
JLabel labelContratTravail = new JLabel(getLabelFor("ID_CODE_CONTRAT_TRAVAIL"));
labelContratTravail.setHorizontalAlignment(SwingConstants.RIGHT);
239,91 → 225,87
this.add(selFF, c);
this.addSQLObject(selFF, "ID_CONTRAT_MOTIF_RECOURS");
 
// Code Arrco, agirc retirés du contrat et ajoutés dans les caisses de cotisations
 
// Code UGRR
JLabel labelCodeUGRR = new JLabel(getLabelFor("CODE_IRC_UGRR"));
labelCodeUGRR.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textCodeUGRR = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelCodeUGRR, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textCodeUGRR, c);
addView(textCodeUGRR, "CODE_IRC_UGRR");
 
// JLabel labelCodeUGRR = new JLabel(getLabelFor("CODE_IRC_UGRR"));
// labelCodeUGRR.setHorizontalAlignment(SwingConstants.RIGHT);
// JTextField textCodeUGRR = new JTextField();
// c.gridy++;
// c.gridx = 0;
// c.weightx = 0;
// this.add(labelCodeUGRR, c);
// c.gridx++;
// c.weighty = 1;
// c.weightx = 1;
// this.add(textCodeUGRR, c);
// addView(textCodeUGRR, "CODE_IRC_UGRR");
//
// JLabel labelNumUGRR = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_UGRR"));
// labelNumUGRR.setHorizontalAlignment(SwingConstants.RIGHT);
// JTextField textNumUGRR = new JTextField();
// c.gridy++;
// c.gridx = 0;
// c.weightx = 0;
// this.add(labelNumUGRR, c);
// c.gridx++;
// c.weighty = 1;
// c.weightx = 1;
// this.add(textNumUGRR, c);
// addView(textNumUGRR, "NUMERO_RATTACHEMENT_UGRR");
//
// // Code UGRC
// JLabel labelCodeUGRC = new JLabel(getLabelFor("CODE_IRC_UGRC"));
// labelCodeUGRC.setHorizontalAlignment(SwingConstants.RIGHT);
// JTextField textCodeUGRC = new JTextField();
// c.gridy++;
// c.gridx = 0;
// c.weightx = 0;
// this.add(labelCodeUGRC, c);
// c.gridx++;
// c.weighty = 1;
// c.weightx = 1;
// this.add(textCodeUGRC, c);
// addView(textCodeUGRC, "CODE_IRC_UGRC");
//
// JLabel labelNumUGRC = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_UGRC"));
// labelNumUGRC.setHorizontalAlignment(SwingConstants.RIGHT);
// JTextField textNumUGRC = new JTextField();
// c.gridy++;
// c.gridx = 0;
// c.weightx = 0;
// this.add(labelNumUGRC, c);
// c.gridx++;
// c.weighty = 1;
// c.weightx = 1;
// this.add(textNumUGRC, c);
// addView(textNumUGRC, "NUMERO_RATTACHEMENT_UGRC");
//
// // Retraite
// JLabel labelCodeRetraite = new JLabel(getLabelFor("CODE_IRC_RETRAITE"));
// labelCodeRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
// JTextField textCodeRetraite = new JTextField();
// c.gridy++;
// c.gridx = 0;
// c.weightx = 0;
// this.add(labelCodeRetraite, c);
// c.gridx++;
// c.weighty = 1;
// c.weightx = 1;
// this.add(textCodeRetraite, c);
// addView(textCodeRetraite, "CODE_IRC_RETRAITE");
//
// JLabel labelNumRetraite = new
// JLabel(getLabelFor("NUMERO_RATTACHEMENT_RETRAITE"));
// labelNumRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
// JTextField textNumRetraite = new JTextField();
// c.gridy++;
// c.gridx = 0;
// c.weightx = 0;
// this.add(labelNumRetraite, c);
// c.gridx++;
// c.weighty = 1;
// c.weightx = 1;
// this.add(textNumRetraite, c);
// addView(textNumRetraite, "NUMERO_RATTACHEMENT_RETRAITE");
JLabel labelNumUGRR = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_UGRR"));
labelNumUGRR.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textNumUGRR = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelNumUGRR, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textNumUGRR, c);
addView(textNumUGRR, "NUMERO_RATTACHEMENT_UGRR");
 
// Code UGRC
JLabel labelCodeUGRC = new JLabel(getLabelFor("CODE_IRC_UGRC"));
labelCodeUGRC.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textCodeUGRC = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelCodeUGRC, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textCodeUGRC, c);
addView(textCodeUGRC, "CODE_IRC_UGRC");
 
JLabel labelNumUGRC = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_UGRC"));
labelNumUGRC.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textNumUGRC = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelNumUGRC, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textNumUGRC, c);
addView(textNumUGRC, "NUMERO_RATTACHEMENT_UGRC");
 
// Retraite
JLabel labelCodeRetraite = new JLabel(getLabelFor("CODE_IRC_RETRAITE"));
labelCodeRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textCodeRetraite = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelCodeRetraite, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textCodeRetraite, c);
addView(textCodeRetraite, "CODE_IRC_RETRAITE");
 
JLabel labelNumRetraite = new JLabel(getLabelFor("NUMERO_RATTACHEMENT_RETRAITE"));
labelNumRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
JTextField textNumRetraite = new JTextField();
c.gridy++;
c.gridx = 0;
c.weightx = 0;
this.add(labelNumRetraite, c);
c.gridx++;
c.weighty = 1;
c.weightx = 1;
this.add(textNumRetraite, c);
addView(textNumRetraite, "NUMERO_RATTACHEMENT_RETRAITE");
 
// JLabel labelCodeRegimeRetraite = new
// JLabel(getLabelFor("CODE_REGIME_RETRAITE_DSN"));
// labelCodeRegimeRetraite.setHorizontalAlignment(SwingConstants.RIGHT);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/report/FichePayeSheetXML.java
198,36 → 198,10
ligneSimplifiee.put("MONTANT_SAL_DED", montantSalBulletinSimpl.add(montantSalLigne));
ligneSimplifiee.put("MONTANT_PAT", montantPatBulletinSimpl.add(montantPatLigne));
}
 
BigDecimal tauxPatBulletinSimpl = BigDecimal.ZERO;
BigDecimal tauxSalBulletinSimpl = BigDecimal.ZERO;
if (ligneSimplifiee.getBigDecimal("TAUX_SAL") != null) {
tauxSalBulletinSimpl = ligneSimplifiee.getBigDecimal("TAUX_SAL");
}
if (ligneSimplifiee.getBigDecimal("TAUX_PAT") != null) {
tauxPatBulletinSimpl = ligneSimplifiee.getBigDecimal("TAUX_PAT");
}
 
BigDecimal tauxPatLigne = BigDecimal.ZERO;
BigDecimal tauxSalLigne = BigDecimal.ZERO;
if (sqlRowAccessor.getBigDecimal("TAUX_SAL") != null) {
tauxSalLigne = sqlRowAccessor.getBigDecimal("TAUX_SAL");
}
if (sqlRowAccessor.getBigDecimal("TAUX_PAT") != null) {
tauxPatLigne = sqlRowAccessor.getBigDecimal("TAUX_PAT");
}
 
if (tauxSalLigne.signum() > 0) {
ligneSimplifiee.put("TAUX_SAL", tauxSalBulletinSimpl.add(tauxSalLigne));
}
 
if (tauxPatLigne.signum() > 0) {
ligneSimplifiee.put("TAUX_PAT", tauxPatBulletinSimpl.add(tauxPatLigne));
}
}
}
}
 
private StyleSQLElement eltStyle = Configuration.getInstance().getDirectory().getElement(StyleSQLElement.class);
 
private Map<String, SQLRowValues> initCotisations(boolean cadre, List<SQLRowAccessor> resultCotis) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/EditionFichePayePanel.java
165,7 → 165,7
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null && dateDeb.getValue().compareTo(dateFin.getValue()) <= 0);
buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null && dateDeb.getValue().before(dateFin.getValue()));
model.setDateLimit(dateDeb.getValue());
}
};
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/ui/BonDeLivraisonItemTable.java
617,7 → 617,6
if (e.getTable().getFieldsName().contains("ID_ECO_CONTRIBUTION")) {
completionField.add("ID_ECO_CONTRIBUTION");
}
completionField.add("POURCENT_REMISE");
completionField.add("ID_UNITE_VENTE");
completionField.add("QTE_UNITAIRE");
completionField.add("PA_HT");
654,13 → 653,11
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
return super.getValueFrom(row, field, rowDest);
} else {
return res;
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
return res;
}
};
m.fill("NOM", "NOM");
m.fill("ID", "ID_ARTICLE");
746,13 → 743,11
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
return super.getValueFrom(row, field, rowDest);
} else {
return res;
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
return res;
}
};
m2.fill("CODE", "CODE");
m2.fill("ID", "ID_ARTICLE");
769,13 → 764,11
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
Object res = tarifCompletion(row, field, rowDest, true);
if (res == null) {
res = super.getValueFrom(row, field, rowDest);
return super.getValueFrom(row, field, rowDest);
} else {
return res;
}
if (field.equals("POURCENT_REMISE")) {
return getRemiseClient(row);
}
return res;
}
};
m3.fill("CODE", "CODE");
m3.fill("NOM", "NOM");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/component/BonDeLivraisonSQLComponent.java
22,7 → 22,6
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
41,7 → 40,6
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
52,8 → 50,6
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.list.RowValuesTable;
import org.openconcerto.sql.view.list.RowValuesTableModel;
109,7 → 105,6
private final JDate date = new JDate(true);
private final boolean displayDpt;
private final ElementComboBox comboDpt = new ElementComboBox();
private ElementComboBox comboCommercial;
 
public BonDeLivraisonSQLComponent() {
super(Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON"));
130,13 → 125,6
if (rowVals == null) {
rowVals = new SQLRowValues(getTable());
}
SQLElement eltComm = getElement().getForeignElement("ID_COMMERCIAL");
int idUser = UserManager.getInstance().getCurrentUser().getId();
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
 
if (rowsComm != null) {
rowVals.put("ID_COMMERCIAL", rowsComm.getID());
}
if (getTable().contains("CREATE_VIRTUAL_STOCK")) {
rowVals.put("CREATE_VIRTUAL_STOCK", Boolean.TRUE);
}
319,23 → 307,6
}
});
}
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
// cat spe
final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
catUI.addToUI(this, c);
catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
int wantedID = catUI.getCombo().getWantedID();
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
tableBonItem.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
} else {
tableBonItem.setRowCatComptable(null);
}
}
});
}
if (getTable().contains("SPEC_LIVRAISON")) {
// Date livraison
c.gridx++;
391,37 → 362,14
} else {
tableBonItem.setRowCatComptable(null);
}
if (!isFilling()) {
tableBonItem.setClient(rowClient, true);
}
 
} else {
comboContact.getRequest().setWhere(Where.FALSE);
tableBonItem.setRowCatComptable(null);
if (!isFilling()) {
tableBonItem.setClient(null, true);
}
// DevisSQLComponent.this.table.setTarif(null, false);
}
}
});
 
// Commercial
JLabel labelCommercial = new JLabel(getLabelFor("ID_COMMERCIAL"));
labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);
 
c.gridx++;
c.weightx = 0;
this.add(labelCommercial, c);
 
this.comboCommercial = new ElementComboBox(false, 25);
this.comboCommercial.setListIconVisible(false);
c.gridx++;
c.fill = GridBagConstraints.NONE;
c.weightx = 1;
this.add(this.comboCommercial, c);
addRequiredSQLObject(this.comboCommercial, "ID_COMMERCIAL");
 
}
 
final ElementComboBox boxTarif = new ElementComboBox();
497,23 → 445,7
tableBonItem.setTarif(selectedRow, !isFilling());
}
});
 
if (getTable().contains("SERVI_PAR")) {
// Commercial
JLabel labelServi = new JLabel("Servi par");
labelServi.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx++;
c.weightx = 0;
this.add(labelServi, c);
 
SQLTextCombo comboServiPar = new SQLTextCombo();
c.gridx++;
c.fill = GridBagConstraints.NONE;
c.weightx = 1;
this.add(comboServiPar, c);
addRequiredSQLObject(comboServiPar, "SERVI_PAR");
}
}
 
if (getTable().contains("A_ATTENTION")) {
// Date livraison
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/element/BonDeLivraisonItemSQLElement.java
37,7 → 37,6
 
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_BON_DE_LIVRAISON");
l.add("CODE");
l.add("NOM");
l.add("PA_HT");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/shipment/element/BonDeLivraisonSQLElement.java
77,10 → 77,6
final List<String> l = new ArrayList<>();
l.add("NUMERO");
l.add("DATE");
if(getTable().contains("ID_COMMERCIAL")) {
l.add("ID_COMMERCIAL");
}
l.add("ID_CLIENT");
DefaultProps props = DefaultNXProps.getInstance();
Boolean b = props.getBooleanValue("ArticleShowPoids");
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/credit/component/AvoirClientSQLComponent.java
27,7 → 27,6
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.payment.component.ModeDeReglementSQLComponent;
194,9 → 193,6
boxTarif.setValue(foreignRow.getID());
}
}
if (!isFilling()) {
AvoirClientSQLComponent.this.table.setClient(row, true);
}
 
} else {
table.setRowCatComptable(null);
427,25 → 423,7
}
});
}
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
// cat spe
final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
catUI.addToUI(this, c);
catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
int wantedID = catUI.getCombo().getWantedID();
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
table.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
} else {
table.setRowCatComptable(null);
}
}
});
 
}
 
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
 
// Contact
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/component/CommandeClientSQLComponent.java
23,7 → 23,6
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
import org.openconcerto.erp.core.sales.order.ui.CommandeClientItemTable;
256,16 → 255,8
// }
// table.setTarif(foreignRow, true);
}
if (!isFilling()) {
table.setClient(row, true);
}
 
} else {
if (!isFilling()) {
table.setClient(null, true);
}
}
}
 
}
});
402,24 → 393,6
});
}
 
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
// cat spe
final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
catUI.addToUI(this, c);
catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
int wantedID = catUI.getCombo().getWantedID();
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
table.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
} else {
table.setRowCatComptable(null);
}
}
});
}
 
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ORDER_PACKAGING_MANAGEMENT, true)) {
// Emballage
c.gridy++;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/CommandeClientElementSQLElement.java
16,11 → 16,11
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.UISQLComponent;
66,9 → 66,16
 
@Override
public void actionPerformed(ActionEvent e) {
final List<SQLRow> rows = SQLRowListRSH.fetch(IListe.get(e).getRequest().getPrimaryTable(), IListe.get(e).getSelection().getSelectedIDs());
((CommandeClientSQLElement) getForeignElement("ID_COMMANDE_CLIENT")).transfertEltToCommandeF(rows);
final List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
@Override
public void run() {
 
createCommandeF(selectedRows);
}
});
}
 
}, true);
rowAction.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
207,7 → 214,6
l.add("NOM");
l.add("ID_COMMANDE_CLIENT");
l.add("ID_ARTICLE");
l.add("ID_DEPOT_STOCK");
l.add("PA_HT");
l.add("PV_HT");
l.add("T_PA_HT");
228,11 → 234,6
*/
public void transfertCommande(List<SQLRowValues> commandeClientEltsRows) {
 
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
@Override
public void run() {
 
SQLTable tableCmdElt = getDirectory().getElement("COMMANDE_ELEMENT").getTable();
SQLElement eltArticle = getDirectory().getElement("ARTICLE");
 
239,26 → 240,10
final ListMap<SQLRow, SQLRowValues> map = new ListMap<SQLRow, SQLRowValues>();
List<String> fields2copy = Arrays.asList("CODE", "NOM", "VALEUR_METRIQUE_1", "VALEUR_METRIQUE_2", "VALEUR_METRIQUE_3");
 
Set<Integer> artAdded = new HashSet<Integer>();
// Set<Integer> art = new HashSet<Integer>();
for (SQLRowValues sqlRow : commandeClientEltsRows) {
boolean article = false;
if (sqlRow.getTable().getName().equalsIgnoreCase("ARTICLE")) {
article = true;
}
 
// renderer sur liste des ar
 
// if()
 
/// rowValsElt.put("QTE", sqlRow.getObject("QTE"));
SQLRowAccessor rowArticleFind;
SQLRowValues rowArticle;
int qte = 1;
BigDecimal qteUV = BigDecimal.ONE;
boolean gestionStock = true;
if (!article) {
// on récupére l'article qui lui correspond
rowArticle = new SQLRowValues(eltArticle.getTable());
SQLRowValues rowArticle = new SQLRowValues(eltArticle.getTable());
for (String field : fields2copy) {
// if (sqlRow.getTable().getFieldsName().contains(field.getName())) {
rowArticle.put(field, sqlRow.asRow().getObject(field));
266,43 → 251,54
}
 
int idArticle = ReferenceArticleSQLElement.getIdForCNM(rowArticle, true);
rowArticleFind = eltArticle.getTable().getRow(idArticle);
SQLRow rowArticleFind = eltArticle.getTable().getRow(idArticle);
if (rowArticleFind != null && !rowArticleFind.isUndefined()) {
SQLInjector inj = SQLInjector.getInjector(rowArticle.getTable(), tableCmdElt);
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(rowArticleFind));
rowValsElt.put("ID_STYLE", sqlRow.getObject("ID_STYLE"));
 
gestionStock = rowArticleFind.getBoolean("GESTION_STOCK");
if (!gestionStock) {
qte = sqlRow.getInt("QTE");
qteUV = sqlRow.getBigDecimal("QTE_UNITAIRE");
// if()
 
if (sqlRow.getObject("ID_UNITE_VENTE") != null && sqlRow.getForeignID("ID_UNITE_VENTE") != UniteVenteArticleSQLElement.A_LA_PIECE) {
qteUV = qteUV.multiply(new BigDecimal(qte));
qte = 1;
rowValsElt.put("QTE", sqlRow.getObject("QTE"));
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
rowValsElt.put("T_PA_TTC",
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)), DecimalUtils.HIGH_PRECISION));
// rowValsElt.put("ID_DEVISE",
// rowCmd.getForeignRow("ID_TARIF").getForeignID("ID_DEVISE"));
map.add(rowArticleFind.getForeignRow("ID_FOURNISSEUR"), rowValsElt);
}
} else {
if (rowArticle.getForeign("ID_STOCK") != null && !rowArticle.isForeignEmpty("ID_STOCK")) {
SQLRowAccessor rowStock = rowArticle.getForeign("ID_STOCK");
qte = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
 
}
// TODO
MouvementStockSQLElement.createCommandeF(map, null, "", false);
}
} else {
rowArticleFind = sqlRow;
rowArticle = sqlRow;
if (rowArticle.getForeign("ID_STOCK") != null && !rowArticle.isForeignEmpty("ID_STOCK")) {
SQLRowAccessor rowStock = rowArticle.getForeign("ID_STOCK");
qte = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
}
}
if (rowArticleFind != null && !rowArticleFind.isUndefined() && (!gestionStock || !artAdded.contains(rowArticleFind.getID()))) {
 
artAdded.add(rowArticleFind.getID());
public void createCommandeF(final List<? extends SQLRowAccessor> rowsItems) {
 
SQLInjector inj = SQLInjector.getInjector(rowArticle.getTable(), tableCmdElt);
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(rowArticleFind.asRow()));
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
rowValsElt.put("ID_STYLE", sqlRow.getObject("ID_STYLE"));
@Override
public void run() {
final ListMap<SQLRow, SQLRowValues> map = new ListMap<SQLRow, SQLRowValues>();
final Set<Integer> stockChecked = new HashSet<Integer>();
for (SQLRowAccessor rowItem : rowsItems) {
if (rowItem.getObject("ID_ARTICLE") != null && !rowItem.isForeignEmpty("ID_ARTICLE")) {
SQLRowAccessor rowArticleFind = rowItem.getForeign("ID_ARTICLE");
 
rowValsElt.put("QTE", qte);
rowValsElt.put("QTE_UNITAIRE", qteUV);
SQLRow row = rowArticleFind.asRow();
SQLRowAccessor rowStock = StockSQLElement.getStock(rowItem);
if (!stockChecked.contains(rowStock.getID())) {
stockChecked.add(rowStock.getID());
 
int value = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
 
if (value > 0) {
 
SQLInjector inj = SQLInjector.getInjector(row.getTable(), row.getTable().getTable("COMMANDE_ELEMENT"));
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(row));
 
rowValsElt.put("QTE", value);
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
rowValsElt.put("T_PA_TTC", ((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)),
309,13 → 305,15
DecimalUtils.HIGH_PRECISION));
// rowValsElt.put("ID_DEVISE",
// rowCmd.getForeignRow("ID_TARIF").getForeignID("ID_DEVISE"));
map.add(rowArticleFind.asRow().getForeignRow("ID_FOURNISSEUR"), rowValsElt);
map.add(rowArticleFind.getForeign("ID_FOURNISSEUR").asRow(), rowValsElt);
}
}
 
MouvementStockSQLElement.createCommandeF(map, null, "");
}
}
MouvementStockSQLElement.createCommandeF(map, null, "", false);
}
});
 
}
 
protected List<String> getComboFields() {
340,7 → 338,7
res.putCollection("ID_COMMANDE_CLIENT", "NUMERO", "DATE", "DATE_LIVRAISON_PREV", "ID_CLIENT");
 
if (getTable().contains("ID_ARTICLE")) {
res.putCollection("ID_ARTICLE", "GESTION_STOCK", "ID_FAMILLE_ARTICLE", "ID_FOURNISSEUR");
res.putCollection("ID_ARTICLE", "ID_FAMILLE_ARTICLE", "ID_FOURNISSEUR");
}
res.putCollection(null, "NOM");
return res;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/CommandeClientSQLElement.java
22,9 → 22,7
import org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent;
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient;
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
import org.openconcerto.erp.core.sales.product.model.ProductHelper;
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
import org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent;
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
38,6 → 36,7
import org.openconcerto.sql.element.TreesOfSQLRows;
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
580,68 → 579,43
public void transfertCommande(int commandeID, boolean useCommandeEnCours) {
 
SQLElement elt = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT");
SQLTable tableCmdElt = Configuration.getInstance().getDirectory().getElement("COMMANDE_ELEMENT").getTable();
SQLElement eltArticle = Configuration.getInstance().getDirectory().getElement("ARTICLE");
SQLRow rowCmd = getTable().getRow(commandeID);
List<SQLRow> rows = rowCmd.getReferentRows(elt.getTable());
transfertEltToCommandeF(rows);
}
 
public void transfertEltToCommandeF(List<? extends SQLRowAccessor> rowsItems) {
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
 
@Override
public void run() {
ProductHelper helper = new ProductHelper(getTable().getDBRoot());
List<ProductComponent> productComp = new ArrayList<>();
helper.fillProductComponent(rowsItems, productComp, 1, 0, 1);
 
List<ProductComponent> leafItems = helper.getChildWithQtyFrom(productComp);
 
final ListMap<SQLRow, SQLRowValues> map = new ListMap<SQLRow, SQLRowValues>();
final Set<Integer> stockChecked = new HashSet<Integer>();
for (ProductComponent comp : leafItems) {
SQLRowAccessor rowArticleFind = comp.getProduct();
 
SQLRow row = rowArticleFind.asRow();
SQLRowAccessor rowStock = comp.getStock();
int value = 0;
if (row.getBoolean("GESTION_STOCK") && !stockChecked.contains(rowStock.getID())) {
stockChecked.add(rowStock.getID());
 
value = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
} else if (!row.getBoolean("GESTION_STOCK")) {
value = comp.getQty().intValue();
for (SQLRow sqlRow : rows) {
// on récupére l'article qui lui correspond
SQLRowValues rowArticle = new SQLRowValues(eltArticle.getTable());
for (SQLField field : eltArticle.getTable().getFields()) {
if (sqlRow.getTable().getFieldsName().contains(field.getName())) {
rowArticle.put(field.getName(), sqlRow.getObject(field.getName()));
}
if (value > 0) {
 
SQLInjector inj = SQLInjector.getInjector(row.getTable(), row.getTable().getTable("COMMANDE_ELEMENT"));
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(row));
 
int qte = 1;
BigDecimal qteUV = BigDecimal.ONE;
 
if (row.getObject("ID_UNITE_VENTE") != null && row.getForeignID("ID_UNITE_VENTE") != UniteVenteArticleSQLElement.A_LA_PIECE) {
qteUV = comp.getQty();
} else {
qte = comp.getQty().setScale(0, RoundingMode.HALF_UP).intValue();
}
 
rowValsElt.put("QTE", qte);
rowValsElt.put("QTE_UNITAIRE", qteUV);
 
int idArticle = ReferenceArticleSQLElement.getIdForCNM(rowArticle, true);
SQLRow rowArticleFind = eltArticle.getTable().getRow(idArticle);
if (rowArticleFind != null && !rowArticleFind.isUndefined()) {
SQLInjector inj = SQLInjector.getInjector(rowArticle.getTable(), tableCmdElt);
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(rowArticleFind));
rowValsElt.put("ID_STYLE", sqlRow.getObject("ID_STYLE"));
rowValsElt.put("QTE", sqlRow.getObject("QTE"));
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
rowValsElt.put("T_PA_TTC", ((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)),
DecimalUtils.HIGH_PRECISION));
// rowValsElt.put("ID_DEVISE",
// rowCmd.getForeignRow("ID_TARIF").getForeignID("ID_DEVISE"));
map.add(rowArticleFind.getForeign("ID_FOURNISSEUR").asRow(), rowValsElt);
rowValsElt.put("T_PA_TTC",
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)), DecimalUtils.HIGH_PRECISION));
final SQLRow foreignRow = rowArticleFind.getForeignRow("ID_FOURNISSEUR");
if (foreignRow != null && !foreignRow.isUndefined()) {
rowValsElt.put("ID_DEVISE", foreignRow.getForeignID("ID_DEVISE"));
} else {
rowValsElt.put("ID_DEVISE", rowCmd.getForeignRow("ID_TARIF").getForeignID("ID_DEVISE"));
}
map.add(rowArticleFind.getForeignRow("ID_FOURNISSEUR"), rowValsElt);
}
 
}
MouvementStockSQLElement.createCommandeF(map, null, "");
MouvementStockSQLElement.createCommandeF(map, rowCmd.getForeignRow("ID_TARIF").getForeignRow("ID_DEVISE"), rowCmd.getString("NUMERO") + " - " + rowCmd.getString("NOM"), useCommandeEnCours);
}
});
}
 
/**
* Transfert en BL
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/action/ListeDesElementsACommanderClientAction.java
18,7 → 18,6
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
import org.openconcerto.erp.core.sales.order.element.CommandeClientElementSQLElement;
import org.openconcerto.erp.core.sales.product.ui.QteAcommanderRenderer;
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
import org.openconcerto.sql.element.SQLElement;
125,17 → 124,14
protected Object show_(SQLRowAccessor r) {
 
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
 
if (foreign != null && !foreign.isUndefined()) {
if (foreign.getBoolean("GESTION_STOCK")) {
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
if (foreign2 != null && !foreign2.isUndefined()) {
return foreign2.getFloat("QTE_REEL");
}
}
return 0F;
}
return null;
}
 
@Override
public Set<FieldPath> getPaths() {
154,16 → 150,13
 
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
if (foreign != null && !foreign.isUndefined()) {
if (foreign.getBoolean("GESTION_STOCK")) {
 
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
if (foreign2 != null && !foreign2.isUndefined()) {
return foreign2.getFloat("QTE_TH");
}
}
return 0F;
}
return null;
}
 
@Override
public Set<FieldPath> getPaths() {
182,16 → 175,13
 
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
if (foreign != null && !foreign.isUndefined()) {
if (foreign.getBoolean("GESTION_STOCK")) {
 
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
if (foreign2 != null && !foreign2.isUndefined()) {
return foreign2.getFloat("QTE_MIN");
}
}
return 0F;
}
return null;
}
 
@Override
public Set<FieldPath> getPaths() {
210,8 → 200,6
 
final SQLRowAccessor foreign = r.getForeign("ID_ARTICLE");
if (foreign != null && !foreign.isUndefined()) {
if (foreign.getBoolean("GESTION_STOCK")) {
 
SQLRowAccessor foreign2 = StockSQLElement.getStockFetched(r);
if (foreign2 != null && !foreign2.isUndefined()) {
float qteMin = foreign2.getFloat("QTE_MIN");
218,13 → 206,10
float manque = foreign2.getFloat("QTE_TH") - qteMin;
if (manque < 0) {
return -manque;
} else {
return 0f;
}
}
}
}
return r.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(r.getInt("QTE"))).floatValue();
return 0F;
 
}
 
237,7 → 222,7
}
};
tableSource.getColumns().add(colSug);
colSug.setRenderer(new QteAcommanderRenderer());
// colLiv2.setRenderer(new PercentTableCellRenderer());
 
return tableSource;
}
329,7 → 314,7
@Override
public void actionPerformed(ActionEvent e) {
List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
eltCmd.transfertCommande(selectedRows);
eltCmd.createCommandeF(selectedRows);
}
}, true);
predicateACtion.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/EcheanceClientSQLElement.java
18,11 → 18,7
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.customerrelationship.customer.element.RelanceSQLElement;
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplate;
import org.openconcerto.erp.core.customerrelationship.mail.ValueListener;
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
import org.openconcerto.erp.core.finance.payment.element.EncaisserMontantSQLElement;
import org.openconcerto.erp.core.sales.invoice.action.ImportReglementSage;
import org.openconcerto.erp.core.sales.invoice.report.MailRelanceCreator;
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
import org.openconcerto.erp.rights.ComptaUserRight;
30,25 → 26,18
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLDataSource;
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.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Link;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
60,15 → 49,11
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.EmailComposer;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.SwingThreadUtils;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.ListMap;
 
import java.awt.Component;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
77,7 → 62,6
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
87,6 → 71,7
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
 
public class EcheanceClientSQLElement extends ComptaSQLConfElement {
 
126,90 → 111,16
}
 
{
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Envoyer un mail de relance") {
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Envoyer un mail") {
 
@Override
public void actionPerformed(ActionEvent e) {
final IListe iListe = IListe.get(e);
if (iListe.getSelectedRows().isEmpty()) {
int result = JOptionPane.showConfirmDialog(iListe,
"Souhaitez vous envoyer un email de relance pour toutes les factures\ndont l'échéance est dépassée?\nLes relances ne seront pas envoyées si les factures ont déjà  une relance de moins d'un mois. ",
"Relance automatique", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.YES_OPTION) {
EmailTemplate.askTemplate(iListe, getTable().getDBRoot(), new ValueListener() {
public void actionPerformed(ActionEvent arg0) {
 
@Override
public void valueSelected(Object value) {
final Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
EmailTemplate template = (EmailTemplate) value;
final SQLTable table = getTable();
final SQLRowValues v = new SQLRowValues(table);
v.putNulls(table.getFieldsName());
Where w = new Where(table.getField("REGLE"), "=", false);
w = w.and(new Where(table.getField("REG_COMPTA"), "=", false));
final Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, -1);
w = w.and(new Where(table.getField("DATE_LAST_RELANCE"), ">", c.getTime()));
w = w.and(new Where(table.getField("DATE"), "<=", Calendar.getInstance().getTime()));
List<SQLRowValues> rowValues = SQLRowValuesListFetcher.create(v).fetch(w);
if (rowValues.isEmpty()) {
JOptionPane.showMessageDialog(iListe, "Aucune relance à  envoyer.");
} else {
for (SQLRowValues row : rowValues) {
sendMail(row.asRow(), template);
SQLRow row = IListe.get(arg0).fetchSelectedRow();
sendMail(row);
}
}
} catch (Exception e) {
ExceptionHandler.handle("erreur lors de l'envoi", e);
}
 
}
});
t.setDaemon(true);
t.setName("email relance");
t.start();
 
}
});
 
}
 
} else {
final SQLTable primaryTable = iListe.getRequest().getPrimaryTable();
final List<Integer> selectedIDs = iListe.getSelection().getSelectedIDs();
EmailTemplate.askTemplate(iListe, getTable().getDBRoot(), new ValueListener() {
 
@Override
public void valueSelected(Object value) {
final Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
EmailTemplate template = (EmailTemplate) value;
final List<SQLRow> rows = SQLRowListRSH.fetch(primaryTable, selectedIDs);
for (SQLRow row : rows) {
sendMail(row, template);
}
} catch (Exception e) {
ExceptionHandler.handle("erreur lors de l'envoi", e);
}
 
}
});
t.setDaemon(true);
t.setName("email relance selection");
t.start();
 
}
});
 
}
}
}, true);
action.setPredicate(IListeEvent.createTotalRowCountPredicate(0, Integer.MAX_VALUE));
}, false);
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(action);
}
 
232,7 → 143,6
}
}
}, false) {
 
@Override
public boolean enabledFor(List<SQLRowValues> selection) {
if (selection != null && selection.size() == 1) {
274,7 → 184,6
}
}
}, false) {
 
@Override
public boolean enabledFor(List<SQLRowValues> selection) {
if (selection != null && selection.size() == 1) {
284,63 → 193,24
return true;
}
}
 
};
getRowActions().add(actionRegul);
}
 
RowAction actionImport = new RowAction(new AbstractAction("Importer") {
 
public void actionPerformed(ActionEvent e) {
 
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
final FileDialog fd = new FileDialog(frame, "Import XML des réglements Sage", FileDialog.LOAD);
if (fd.getFile() != null) {
try {
SQLUtils.executeAtomic(getTable().getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
@Override
public Object handle(final SQLDataSource ds) throws SQLException, IOException {
 
ImportReglementSage sageImporter = new ImportReglementSage(getDirectory().getElement(EncaisserMontantSQLElement.class));
try {
sageImporter.importFromFile(new File(fd.getDirectory(), fd.getFile()));
} catch (Exception e) {
e.printStackTrace();
new SQLException(e);
}
return null;
}
 
});
JOptionPane.showMessageDialog(null, "Import des paiements terminés!");
} catch (IOException exn) {
ExceptionHandler.handle(frame, "Erreur lors de la lecture du fichier", exn);
} catch (SQLException exn) {
ExceptionHandler.handle(frame, "Erreur lors de l'insertion des paiements dans la base", exn);
}
 
}
fd.setVisible(true);
}
}, true) {
@Override
public boolean enabledFor(List<SQLRowValues> selection) {
return true;
}
};
getRowActions().add(actionImport);
private void sendMail(final SQLRow row) {
 
}
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
 
if (row != null) {
 
private void sendMail(final SQLRow row, EmailTemplate template) throws Exception {
 
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
 
int idMvtSource = MouvementSQLElement.getSourceId(row.getInt("ID_MOUVEMENT"));
SQLRow rowMvtSource = base.getTable("MOUVEMENT").getRow(idMvtSource);
 
if (!rowMvtSource.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
// this.relancer.setEnabled(false);
return;
}
int idFact = rowMvtSource.getInt("IDSOURCE");
372,12 → 242,16
}
final String adresseMail = mail;
 
MailRelanceCreator creator = new MailRelanceCreator(template, row);
final String references = creator.getObject();
final String text = creator.getValue();
MailRelanceCreator creator = new MailRelanceCreator();
final String references = creator.getObject(row);
final String text = creator.getValue(row);
 
final Thread t = new Thread() {
@Override
public void run() {
 
final File f;
 
try {
f = sheet.getOrCreatePDFDocumentFile(true);
 
EmailComposer.getInstance().compose(adresseMail, references, text, f.getAbsoluteFile());
392,7 → 266,7
rowValsR.put("MONTANT", row.getObject("MONTANT"));
rowValsR.put("INFOS", "Email");
rowValsR.put("ID_ECHEANCE_CLIENT", row.getID());
 
try {
rowValsR.insert();
 
SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
413,8 → 287,26
 
rowValsEch.update(row.getID());
 
} catch (SQLException e) {
 
e.printStackTrace();
}
} catch (IOException exn) {
exn.printStackTrace();
} catch (InterruptedException exn) {
exn.printStackTrace();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
 
}
};
 
t.start();
}
}
 
@Override
public ListMap<String, String> getShowAs() {
ListMap<String, String> map = new ListMap<String, String>();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/ReportingStockXmlSheet.java
13,6 → 13,7
package org.openconcerto.erp.core.sales.invoice.report;
 
import org.openconcerto.erp.core.sales.invoice.report.ReportingVenteXmlSheet.Line;
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.sql.Configuration;
36,6 → 37,8
import java.util.Map;
import java.util.TreeMap;
 
import javax.swing.JProgressBar;
 
public class ReportingStockXmlSheet extends AbstractListeSheetXml {
 
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
122,12 → 125,11
Float qte = vals.getForeign("ID_STOCK").getFloat("QTE_REEL");
BigDecimal ha = BigDecimal.ZERO;
if (qte > 0) {
final BigDecimal puHA = vals.getBigDecimal("PA_HT");
ha = puHA.multiply(new BigDecimal(qte));
ha = vals.getBigDecimal("PA_HT").multiply(new BigDecimal(qte));
 
int idFamille = vals.getForeignID("ID_FAMILLE_ARTICLE");
SQLRow rowF = mapF.get(idFamille);
Line lineArt = new Line(vals.getString("NOM"), vals.getString("CODE"), puHA, ha, qte);
Line lineArt = new Line(vals.getString("NOM"), vals.getString("CODE"), ha, qte);
 
// Init des lines familles
 
223,18 → 225,13
 
class Line {
final private String nomArt, codeArt;
private BigDecimal totalHA, puHA;
private BigDecimal totalHA;
private Float qte;
 
public Line(String nomArt, String codeArt, BigDecimal totalHA, Float qte) {
this(nomArt, codeArt, BigDecimal.ZERO, totalHA, qte);
}
 
public Line(String nomArt, String codeArt, BigDecimal puHA, BigDecimal totalHA, Float qte) {
this.nomArt = nomArt;
this.codeArt = codeArt;
this.totalHA = totalHA;
this.puHA = puHA;
this.qte = qte;
}
 
246,10 → 243,6
return codeArt;
}
 
public BigDecimal getPuHA() {
return puHA;
}
 
public String getNomArt() {
return nomArt;
}
270,7 → 263,6
m.put("CODE", getCodeArt());
m.put("NOM", getNomArt());
m.put("QTE", getQte());
m.put("PU_HA", getPuHA());
m.put("TOTAL_HA", getTotalHA());
return m;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/MailRelanceCreator.java
14,10 → 14,11
package org.openconcerto.erp.core.sales.invoice.report;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplate;
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
import org.openconcerto.erp.preferences.MailRelancePreferencePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.utils.GestionDevise;
 
29,18 → 30,10
 
public class MailRelanceCreator {
 
private final EmailTemplate template;
private final SQLRow rowEcheance;
private final Map<String, String> map;
SQLRow rowEcheance;
 
public MailRelanceCreator(EmailTemplate template, SQLRow row) {
if (template == null) {
template = new EmailTemplate("defautl", getDefaultObject(), getDefaultValue(), true, "dd/MM/yyyy");
}
this.template = template;
this.rowEcheance = row;
public MailRelanceCreator() {
 
this.map = getMapValues();
}
 
public String getDefaultObject() {
57,14 → 50,9
return value;
}
 
private Map<String, String> getMapValues() {
String datePattern = this.template.getDateFormat();
if (datePattern == null || datePattern.trim().isEmpty()) {
datePattern = "dd/MM/yyyy";
}
public Map<String, String> getMapValues(SQLRow rowEch, String datePattern) {
final Map<String, String> map = new HashMap<String, String>();
 
final Map<String, String> map = new HashMap<>();
 
final SQLRow rowSoc = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
final SQLRow rowSocAdresse = rowSoc.getForeignRow("ID_ADRESSE_COMMON");
SQLRow rowUser = rowSoc.getTable().getDBRoot().findTable("USER_COMMON").getRow(UserManager.getUser().getId());
96,7 → 84,7
map.put("SocieteVille", ville);
 
SQLRow rowClient;
final SQLRow clientRowNX = this.rowEcheance.getForeignRow("ID_CLIENT");
final SQLRow clientRowNX = rowEch.getForeignRow("ID_CLIENT");
rowClient = clientRowNX;
SQLRow rowAdresse = rowClient.getForeignRow("ID_ADRESSE");
if (!clientRowNX.isForeignEmpty("ID_ADRESSE_F")) {
130,13 → 118,13
DateFormat dateFormat = new SimpleDateFormat(datePattern);
map.put("RelanceDate", dateFormat.format(d));
 
SQLRow rowFacture = this.rowEcheance.getForeignRow("ID_SAISIE_VENTE_FACTURE");
SQLRow rowFacture = rowEch.getForeignRow("ID_SAISIE_VENTE_FACTURE");
 
 
// Infos facture
Long lTotal = (Long) rowFacture.getObject("T_TTC");
Long lRestant = (Long) this.rowEcheance.getObject("MONTANT");
Long lVerse = Long.valueOf(lTotal.longValue() - lRestant.longValue());
Long lRestant = (Long) rowEch.getObject("MONTANT");
Long lVerse = new Long(lTotal.longValue() - lRestant.longValue());
map.put("FactureNumero", rowFacture.getString("NUMERO"));
map.put("FactureReference", rowFacture.getString("NOM"));
map.put("FactureTotal", GestionDevise.currencyToString(lTotal.longValue(), true));
148,22 → 136,30
SQLRow modeRegRow = rowFacture.getForeignRow("ID_MODE_REGLEMENT");
Date dateEch = ModeDeReglementSQLElement.calculDate(modeRegRow.getInt("AJOURS"), modeRegRow.getInt("LENJOUR"), dFacture);
map.put("FactureDateEcheance", dateFormat.format(dateEch));
map.put("message", "");
 
return map;
}
 
public String getObject() {
return fill(this.template.getTitle());
public String getObject(SQLRow rowEch) {
SQLPreferences prefs = new SQLPreferences(rowEch.getTable().getDBRoot());
String object = prefs.get(MailRelancePreferencePanel.MAIL_RELANCE_OBJET, getDefaultObject());
String date = prefs.get(MailRelancePreferencePanel.MAIL_RELANCE_DATE_PATTERN, "dd/MM/yyyy");
return fill(rowEch, date, object);
}
 
public String getValue() {
return fill(this.template.getText());
public String getValue(SQLRow rowEch) {
SQLPreferences prefs = new SQLPreferences(rowEch.getTable().getDBRoot());
String value = prefs.get(MailRelancePreferencePanel.MAIL_RELANCE, getDefaultValue());
String date = prefs.get(MailRelancePreferencePanel.MAIL_RELANCE_DATE_PATTERN, "dd/MM/yyyy");
return fill(rowEch, date, value);
}
 
private String fill(String string) {
private String fill(SQLRow rowEch, String datePattern, String string) {
 
Map<String, String> map = getMapValues(rowEch, datePattern);
String result = string;
for (String key : this.map.keySet()) {
result = result.replace("{" + key + "}", this.map.get(key));
for (String key : map.keySet()) {
result = result.replace("{" + key + "}", map.get(key));
}
return result;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/ImportReglementSageAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/ImportReglementSage.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/GenListeVentePanel.java
31,8 → 31,6
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
 
import javax.swing.JButton;
111,40 → 109,16
sel.addSelectStar(tableFact);
sel.setDistinct(true);
sel.setWhere(new Where(tableFact.getField("DATE"), GenListeVentePanel.this.du.getDate(), GenListeVentePanel.this.au.getDate()));
List<SQLRow> l = new ArrayList((List<SQLRow>) dataSource.execute(sel.asString(), SQLRowListRSH.createFromSelect(sel, tableFact)));
Collections.sort(l, new Comparator<SQLRow>() {
@Override
public int compare(SQLRow o1, SQLRow o2) {
int dateComp = o1.getDate("DATE").compareTo(o2.getDate("DATE"));
if (dateComp == 0) {
return o1.getString("NUMERO").compareTo(o2.getString("NUMERO"));
} else {
return dateComp;
}
}
});
 
List<SQLRow> l = (List<SQLRow>) dataSource.execute(sel.asString(), SQLRowListRSH.createFromSelect(sel, tableFact));
SQLSelect sel2 = new SQLSelect(Configuration.getInstance().getBase());
sel2.addSelectStar(tableAvoir);
sel2.setWhere(new Where(tableAvoir.getField("DATE"), GenListeVentePanel.this.du.getDate(), GenListeVentePanel.this.au.getDate()));
sel2.setDistinct(true);
List<SQLRow> l2 = new ArrayList((List<SQLRow>) dataSource.execute(sel2.asString(), SQLRowListRSH.createFromSelect(sel2, tableAvoir)));
Collections.sort(l2, new Comparator<SQLRow>() {
@Override
public int compare(SQLRow o1, SQLRow o2) {
int dateComp = o1.getDate("DATE").compareTo(o2.getDate("DATE"));
if (dateComp == 0) {
return o1.getString("NUMERO").compareTo(o2.getString("NUMERO"));
} else {
return dateComp;
}
}
});
List<SQLRow> l2 = (List<SQLRow>) dataSource.execute(sel2.asString(), SQLRowListRSH.createFromSelect(sel2, tableAvoir));
 
List<SQLRow> lTotal = new ArrayList<SQLRow>();
lTotal.addAll(l);
lTotal.addAll(l2);
 
ListeVenteXmlSheet sheet = new ListeVenteXmlSheet(lTotal, GenListeVentePanel.this.du.getDate(), GenListeVentePanel.this.au.getDate(), GenListeVentePanel.this.bar);
 
sheet.createDocumentAsynchronous().get();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/EtatVentesPanel.java
18,7 → 18,6
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.NoneSelectedButtonGroup;
import org.openconcerto.utils.Tuple2;
 
import java.awt.FlowLayout;
44,8 → 43,7
private JDate du, au;
private JButton buttonGen = new JButton("Créer");
private JButton buttonClose = new JButton("Fermer");
private JCheckBox boxTicket = new JCheckBox("Uniquement les ventes en caisse");
private JCheckBox boxFacture = new JCheckBox("Uniquement les ventes sur facture");
JCheckBox boxTicket = new JCheckBox("Uniquement les ventes en caisse");
 
public EtatVentesPanel() {
super(new GridBagLayout());
122,18 → 120,7
 
c.gridy++;
c.gridx = 0;
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
 
this.add(boxFacture, c);
 
NoneSelectedButtonGroup grou = new NoneSelectedButtonGroup();
grou.add(boxFacture);
grou.add(boxTicket);
 
c.gridy++;
c.gridx = 0;
 
JPanel panelButton = new JPanel();
panelButton.add(this.buttonGen);
panelButton.add(this.buttonClose);
180,7 → 167,7
if (e.getSource() == this.buttonGen) {
final Date start = this.du.getDate();
final Date stop = this.au.getDate();
final EtatVentesXmlSheet sheet = new EtatVentesXmlSheet(start, stop, boxTicket.isSelected(), boxFacture.isSelected());
final EtatVentesXmlSheet sheet = new EtatVentesXmlSheet(start, stop, boxTicket.isSelected());
try {
// FIXME probleme de rendu avec le viewer
sheet.createDocumentAsynchronous().get();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/component/SaisieVenteFactureSQLComponent.java
24,7 → 24,6
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.payment.component.ModeDeReglementSQLComponent;
161,10 → 160,6
tableFacture.setRowCatComptable(null);
}
 
if (!isFilling()) {
tableFacture.setClient(rowCli, true);
}
 
if (getMode() == SQLComponent.Mode.INSERTION || !isFilling()) {
SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
int idModeRegl = rowCli.getInt("ID_MODE_REGLEMENT");
485,26 → 480,6
}
});
// }
 
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
// cat spe
final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
catUI.addToUI(this, c);
catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
int wantedID = catUI.getCombo().getWantedID();
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
tableFacture.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
} else {
tableFacture.setRowCatComptable(null);
}
}
});
}
 
// Contact
this.contact = new ElementComboBox() {
@Override
751,6 → 726,7
final DeviseField textFraisDocHT = new DeviseField();
final SQLRequestComboBox boxTaxeFraisDoc = new SQLRequestComboBox(false, 8);
 
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
final boolean showFrais = prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.FRAIS_DOCUMENT, false);
if (showFrais) {
 
1939,57 → 1915,4
this.tableFacture.setDateDevise(this.dateSaisie.getValue());
}
 
@Override
protected void initDone() {
 
super.initDone();
 
// FIXME listener pour le module project à déplacer dans le module quand l'interface passera
// en group
if (getTable().contains("ID_AFFAIRE")) {
final SQLRequestComboBox viewClient = (SQLRequestComboBox) getView("ID_CLIENT").getComp();
final SQLRequestComboBox viewAffaire = (SQLRequestComboBox) getView("ID_AFFAIRE").getComp();
final SQLRequestComboBox viewComm = (SQLRequestComboBox) getView("ID_COMMERCIAL").getComp();
final SQLRequestComboBox viewAgence;
if (getTable().contains("ID_POLE_PRODUIT")) {
viewAgence = (SQLRequestComboBox) getView("ID_POLE_PRODUIT").getComp();
} else {
viewAgence = null;
}
 
viewAffaire.addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!isFilling()) {
SQLRowAccessor selAffaire = viewAffaire.getSelectedRow();
if (selAffaire != null && !selAffaire.isUndefined()) {
viewClient.setValue(selAffaire.getForeignID("ID_CLIENT"));
if (selAffaire.getTable().contains("ID_COMMERCIAL")) {
viewComm.setValue(selAffaire.getForeignID("ID_COMMERCIAL"));
}
}
}
}
});
 
if (viewAgence != null) {
 
viewComm.addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!isFilling()) {
SQLRowAccessor selComm = viewComm.getSelectedRow();
if (selComm != null && !selComm.isUndefined() && selComm.getTable().contains("ID_POLE_PRODUIT")) {
viewAgence.setValue(selComm.getForeignID("ID_POLE_PRODUIT"));
}
}
}
});
}
}
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/component/DevisSQLComponent.java
27,7 → 27,6
import org.openconcerto.erp.core.common.ui.TotalPanel;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement;
import org.openconcerto.erp.core.sales.quote.report.DevisXmlSheet;
384,23 → 383,6
}
});
}
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
// cat spe
final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
catUI.addToUI(this, c);
catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
int wantedID = catUI.getCombo().getWantedID();
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
table.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
} else {
table.setRowCatComptable(null);
}
}
});
}
if (getTable().contains("ID_CONTACT")) {
// Contact Client
c.gridx = 0;
436,15 → 418,8
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
int idClient = rowClient.getID();
comboContact.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_CLIENT"), "=", idClient));
if (!isFilling()) {
table.setClient(rowClient, true);
}
 
} else {
comboContact.getRequest().setWhere(Where.FALSE);
if (!isFilling()) {
table.setClient(null, true);
}
DevisSQLComponent.this.table.setTarif(null, false);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/element/DevisSQLElement.java
48,7 → 48,6
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.ui.light.CustomRowEditor;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.EditFrame;
64,6 → 63,7
import org.openconcerto.ui.light.ActivationOnSelectionControler;
import org.openconcerto.ui.light.ColumnSpec;
import org.openconcerto.ui.light.ColumnsSpec;
import org.openconcerto.ui.light.CustomEditorProvider;
import org.openconcerto.ui.light.LightController;
import org.openconcerto.ui.light.LightUIButtonUnmanaged;
import org.openconcerto.ui.light.LightUIComboBox;
99,6 → 99,7
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.AbstractAction;
766,12 → 767,14
}
 
@Override
public List<CustomRowEditor> getCustomRowEditors(Configuration configuration, String sessionToken) {
List<CustomRowEditor> map = super.getCustomRowEditors(configuration, sessionToken);
map.add(new CustomRowEditor("sales.quote.items.list") {
protected Map<String, CustomEditorProvider> _getDefaultCustomEditorProvider(final Configuration configuration, final SQLRowAccessor sqlRow, final String sessionSecurityToken)
throws IllegalArgumentException {
final Map<String, CustomEditorProvider> map = super._getDefaultCustomEditorProvider(configuration, sqlRow, sessionSecurityToken);
map.put("sales.quote.items.list", new CustomEditorProvider() {
 
@Override
public LightUIElement createUIElement() {
public LightUIElement createUIElement(final String id) {
 
final ColumnSpec c1 = new ColumnSpec("sales.quote.item.style", StringWithId.class, "Style", new StringWithId(2, "Normal"), true, new LightUIComboBox("sales.quote.item.style"));
final ColumnSpec c2 = new ColumnSpec("sales.quote.item.code", String.class, "Code", "", true, new LightUITextField("sales.quote.item.code"));
final ColumnSpec c3 = new ColumnSpec("sales.quote.item.label", String.class, "Nom", "", true, new LightUITextField("sales.quote.item.name"));
861,11 → 864,65
final ColumnsSpec cSpec = new ColumnsSpec(lId, columnsSpec, possibleColumnIds, null);
cSpec.setAllowMove(true);
cSpec.setAllowResize(true);
final RowSelectionSpec selectionSpec = new RowSelectionSpec(getItemId());
final TableSpec tSpec = new TableSpec(getItemId(), selectionSpec, cSpec);
final RowSelectionSpec selectionSpec = new RowSelectionSpec(id);
final TableSpec tSpec = new TableSpec(id, selectionSpec, cSpec);
tSpec.setColumns(cSpec);
 
String id = getItemId();
if (sqlRow != null) {
// send: id,value
final SQLElement elem = configuration.getDirectory().getElement("DEVIS_ELEMENT");
final SQLTable table = elem.getTable();
final List<String> fieldsToFetch = new ArrayList<>();
for (ColumnSpec cs : columnsSpec) {
String colId = cs.getId();
SQLField f = configuration.getFieldMapper().getSQLFieldForItem(colId);
if (f != null) {
fieldsToFetch.add(f.getName());
} else {
throw new IllegalStateException("No field in " + table + " for column id " + colId);
}
}
 
final Where where = new Where(table.getField("ID_DEVIS"), "=", sqlRow.getID());
final ListSQLRequest req = elem.createListRequest(fieldsToFetch, where, configuration.getShowAs());
List<SQLRowValues> fetchedRows = req.getValues();
 
List<Row> rows = new ArrayList<>();
for (final SQLRowValues vals : fetchedRows) {
Row r = new Row(vals.getID(), columnsSpec.size());
List<Object> values = new ArrayList<>();
for (ColumnSpec cs : columnsSpec) {
String colId = cs.getId();
SQLField f = configuration.getFieldMapper().getSQLFieldForItem(colId);
if (f != null) {
Object object = vals.getObject(f.getName());
if (object instanceof SQLRowValues) {
SQLRowValues sqlRowValues = (SQLRowValues) object;
long rowId = sqlRowValues.getIDNumber().longValue();
List<SQLField> fieldsToExpand = configuration.getShowAs().getFieldExpand(sqlRowValues.getTable());
final StringBuilder b = new StringBuilder();
for (SQLField sqlField : fieldsToExpand) {
b.append(sqlRowValues.getObject(sqlField.getName()).toString());
b.append(' ');
}
object = new StringWithId(rowId, b.toString().trim());
}
values.add(object);
} else {
throw new IllegalStateException("No field in " + table + " for column id " + colId);
}
}
r.setValues(values);
rows.add(r);
}
 
TableContent tableContent = new TableContent();
tableContent.setRows(rows);
// tableContent.setSpec(new RowSpec());
tSpec.setContent(tableContent);
 
}
 
final LightUITable eList = new LightUITable(id);
eList.setTableSpec(tSpec);
 
917,74 → 974,8
panel.addChild(listLine);
 
return panel;
 
}
 
@Override
public void fillFrom(LightUIElement uiElement, SQLRowAccessor sqlRow) {
LightUIPanel p = (LightUIPanel) uiElement;
LightUITable ltable = p.getFirstChild(LightUITable.class);
TableSpec tSpec = ltable.getTableSpec();
ColumnsSpec columnsSpec = tSpec.getColumns();
// send: id,value
final SQLElement elem = configuration.getDirectory().getElement("DEVIS_ELEMENT");
final SQLTable table = elem.getTable();
final List<String> fieldsToFetch = new ArrayList<>();
for (ColumnSpec cs : columnsSpec.getColumns()) {
String colId = cs.getId();
SQLField f = configuration.getFieldMapper().getSQLFieldForItem(colId);
if (f != null) {
fieldsToFetch.add(f.getName());
} else {
throw new IllegalStateException("No field in " + table + " for column id " + colId);
}
}
 
final Where where = new Where(table.getField("ID_DEVIS"), "=", sqlRow.getID());
final ListSQLRequest req = elem.createListRequest(fieldsToFetch, where, configuration.getShowAs());
List<SQLRowValues> fetchedRows = req.getValues();
 
List<Row> rows = new ArrayList<>();
for (final SQLRowValues vals : fetchedRows) {
Row r = new Row(vals.getID(), columnsSpec.getColumns().size());
List<Object> values = new ArrayList<>();
for (ColumnSpec cs : columnsSpec.getColumns()) {
String colId = cs.getId();
SQLField f = configuration.getFieldMapper().getSQLFieldForItem(colId);
if (f != null) {
Object object = vals.getObject(f.getName());
if (object instanceof SQLRowValues) {
SQLRowValues sqlRowValues = (SQLRowValues) object;
long rowId = sqlRowValues.getIDNumber().longValue();
List<SQLField> fieldsToExpand = configuration.getShowAs().getFieldExpand(sqlRowValues.getTable());
final StringBuilder b = new StringBuilder();
for (SQLField sqlField : fieldsToExpand) {
b.append(sqlRowValues.getObject(sqlField.getName()).toString());
b.append(' ');
}
object = new StringWithId(rowId, b.toString().trim());
}
values.add(object);
} else {
throw new IllegalStateException("No field in " + table + " for column id " + colId);
}
}
r.setValues(values);
rows.add(r);
}
 
TableContent tableContent = new TableContent();
tableContent.setRows(rows);
tSpec.setContent(tableContent);
 
}
 
@Override
public void store(LightUIElement uiElement, SQLRowValues row) {
// TODO Auto-generated method stub
 
}
 
});
return map;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/CustomerProductQtyPriceSQLElement.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReferenceArticleSQLElement.java
14,7 → 14,6
package org.openconcerto.erp.core.sales.product.element;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.update.Updater_1_5;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
21,7 → 20,9
import org.openconcerto.erp.core.reports.history.ui.HistoriqueArticleFrame;
import org.openconcerto.erp.core.sales.product.action.InventairePanel;
import org.openconcerto.erp.core.sales.product.component.ReferenceArticleSQLComponent;
import org.openconcerto.erp.core.supplychain.stock.element.ComposedItemStockUpdater;
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
import org.openconcerto.erp.generationDoc.gestcomm.FicheArticleXmlSheet;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.erp.preferences.DefaultNXProps;
52,6 → 53,7
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
 
import java.awt.event.ActionEvent;
219,7 → 221,6
l.add("SKU");
 
// if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false)) {
l.add("GESTION_STOCK");
l.add("ID_STOCK");
// }
String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
526,9 → 527,58
 
public void initStock(int id) {
SQLRow row = getTable().getRow(id);
Updater_1_5.initStock(row);
SQLSelect sel = new SQLSelect();
sel.addSelectStar(getTable().getTable("DEPOT_STOCK"));
List<SQLRow> rowsDepot = SQLRowListRSH.execute(sel);
 
SQLSelect selStock = new SQLSelect();
selStock.addSelectStar(getTable().getTable("STOCK"));
selStock.setWhere(new Where(getTable().getTable("STOCK").getField("ID_ARTICLE"), "=", id));
List<SQLRow> rowsStock = SQLRowListRSH.execute(selStock);
Map<Integer, SQLRow> initedDepot = new HashMap<>();
for (SQLRow sqlRow : rowsStock) {
initedDepot.put(sqlRow.getForeignID("ID_DEPOT_STOCK"), sqlRow);
}
 
List<StockItem> stockItems = new ArrayList<StockItem>();
for (SQLRow sqlRow : rowsDepot) {
try {
if (!initedDepot.keySet().contains(sqlRow.getID())) {
SQLRowValues rowVals = new SQLRowValues(getTable().getTable("STOCK"));
rowVals.put("ID_ARTICLE", row.getID());
rowVals.put("ID_DEPOT_STOCK", sqlRow.getID());
 
SQLRow rowStock = rowVals.commit();
if ((row.getObject("ID_DEPOT_STOCK") == null || row.isForeignEmpty("ID_DEPOT_STOCK")) && sqlRow.getID() == DepotStockSQLElement.DEFAULT_ID) {
row.createEmptyUpdateRow().put("ID_STOCK", rowStock.getID()).put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID).commit();
} else if (sqlRow.getID() == row.getForeignID("ID_DEPOT_STOCK")) {
row.createEmptyUpdateRow().put("ID_STOCK", rowStock.getID()).commit();
}
stockItems.add(new StockItem(row, rowStock));
 
} else {
SQLRow rowExisting = initedDepot.get(sqlRow.getID());
if ((row.getObject("ID_DEPOT_STOCK") == null || row.isForeignEmpty("ID_DEPOT_STOCK")) && sqlRow.getID() == DepotStockSQLElement.DEFAULT_ID) {
row.createEmptyUpdateRow().put("ID_STOCK", rowExisting.getID()).put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID).commit();
} else if (sqlRow.getID() == row.getForeignID("ID_DEPOT_STOCK")) {
row.createEmptyUpdateRow().put("ID_STOCK", rowExisting.getID()).commit();
}
stockItems.add(new StockItem(row, rowExisting));
}
} catch (SQLException e) {
ExceptionHandler.handle("Erreur lors de l'initialisation du stock de l'article", e);
}
}
if (row.getReferentRows(getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT")).size() > 0) {
ComposedItemStockUpdater up = new ComposedItemStockUpdater(getTable().getDBRoot(), stockItems);
try {
up.updateNomenclature(stockItems);
} catch (SQLException e) {
ExceptionHandler.handle("Erreur lors de l'actualisation du stock!", e);
}
}
}
 
@Override
protected String createCode() {
return createCodeOfPackage() + ".ref";
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/TransfertStockAction.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/action/TransfertStockPanel.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/QteAcommanderRenderer.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/CustomerProductQtyPriceListTable.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/CurrencyWithSymbolRenderer.java
34,8 → 34,6
private final FieldPath fieldPath;
private final CurrencyConverter c;
 
private boolean hideZeroValue = false;
 
private String getSymbol(String currencyCode) {
// Because Java Currency return PLN as Symbol for Zl, we use our own talbe
return org.openconcerto.erp.core.finance.accounting.model.Currency.getSymbol(currencyCode);
48,10 → 46,6
this(null);
}
 
public void setHideZeroValue(boolean hideZeroValue) {
this.hideZeroValue = hideZeroValue;
}
 
/**
* Affiche une valeur monétaire en ajoutant le symbole de la devise du path
*
66,13 → 60,8
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
 
if (value != null) {
BigDecimal amount = (BigDecimal) value;
value = GestionDevise.currencyToString((BigDecimal) value);
 
if (this.hideZeroValue && amount.signum() == 0) {
value = "";
} else {
value = GestionDevise.currencyToString(amount);
 
if (fieldPath == null) {
value = value + " " + getSymbol(c.getCompanyCurrencyCode());
} else {
89,8 → 78,7
// reprend
// pas les valeurs de la SQLRow (ex : si on veut récupérer la devise du
// fournisseur
// sélectionné, getDistantRow ira chercher la valeur du fournisseur
// référencé en
// sélectionné, getDistantRow ira chercher la valeur du fournisseur référencé en
// BDD
// et non dans la SQLRow)
 
120,7 → 108,6
}
}
}
}
setHorizontalAlignment(SwingConstants.RIGHT);
 
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/ui/DeliveredQtyRowValuesRenderer.java
45,15 → 45,8
public final static Color lightBlack = new Color(192, 192, 192);
public final static Color lightBlackGrey = new Color(155, 155, 155);
 
private final boolean customer;
 
public DeliveredQtyRowValuesRenderer() {
this(true);
}
 
public DeliveredQtyRowValuesRenderer(boolean customer) {
AlternateTableCellRenderer.setBGColorMap(this, CollectionUtils.createMap(lightBlack, lightBlackGrey, red, redLightGrey, orange, orangeGrey));
this.customer = customer;
}
 
@Override
67,15 → 60,8
RowValuesTableModel model = ((RowValuesTable) table).getRowValuesTableModel();
SQLRowValues rowVals = model.getRowValuesAt(row);
 
Number qte;
Number qteL;
if (this.customer) {
qte = (Number) rowVals.getObject("QTE");
qteL = (Number) rowVals.getObject("QTE_LIVREE");
} else {
qte = (Number) rowVals.getObject("QTE_ORIGINE");
qteL = (Number) rowVals.getObject("QTE");
}
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);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/model/ProductHelper.java
74,44 → 74,6
return result;
}
 
/**
* Fill productComponents with items (SQLrowAccessor of TABLE_ELEMENT)
*
* @param items
* @param productComponents
* @param qte
* @param index
* @param level
*/
public void fillProductComponent(List<? extends SQLRowAccessor> itemsTableElement, List<ProductComponent> productComponents, int qte, int index, int level) {
if (level > 0) {
for (int i = index; i < itemsTableElement.size(); i++) {
SQLRowAccessor r = itemsTableElement.get(i);
 
if (!r.getTable().contains("NIVEAU") || r.getInt("NIVEAU") >= level) {
// On ne calcul pas les stocks pour les éléments ayant des fils (le mouvement de
// stock
// des fils impactera les stocks automatiquement)
if (r.getTable().contains("NIVEAU")) {
if (i + 1 < itemsTableElement.size()) {
SQLRowAccessor rNext = itemsTableElement.get(i + 1);
if (rNext.getInt("NIVEAU") > r.getInt("NIVEAU")) {
fillProductComponent(itemsTableElement, productComponents, qte * r.getInt("QTE"), i + 1, rNext.getInt("NIVEAU"));
continue;
}
}
}
if ((!r.getTable().contains("NIVEAU") || r.getInt("NIVEAU") == level) && r.getForeign("ID_ARTICLE") != null && !r.isForeignEmpty("ID_ARTICLE")) {
productComponents.add(ProductComponent.createFrom(r, qte, r));
}
} else if (r.getInt("NIVEAU") < level) {
// BREAK si on sort de l'article composé
break;
}
}
}
}
 
public BigDecimal getUnitCostForQuantity(SQLRowAccessor rArticle, int qty) {
 
Collection<? extends SQLRowAccessor> l = rArticle.getReferentRows(rArticle.getTable().getTable("ARTICLE_PRIX_REVIENT"));
284,7 → 246,7
 
SQLRowValues rowVals = new SQLRowValues(costTable);
 
final SQLRowValues artRowValues = rowVals.putRowValues("ID_ARTICLE").putNulls("ID", "GESTION_STOCK", "CODE", "NOM", "ID_DEPOT_STOCK", "ID_UNITE_VENTE", "ID_FOURNISSEUR");
final SQLRowValues artRowValues = rowVals.putRowValues("ID_ARTICLE").putNulls("ID", "GESTION_STOCK", "CODE", "NOM", "ID_DEPOT_STOCK", "ID_UNITE_VENTE");
SQLRowValues stockRowVals = new SQLRowValues(root.getTable("STOCK"));
stockRowVals.putNulls("QTE_TH", "QTE_RECEPT_ATTENTE", "QTE_REEL", "QTE_LIV_ATTENTE", "ID_DEPOT_STOCK");
stockRowVals.put("ID_ARTICLE", artRowValues);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/model/ProductComponent.java
15,8 → 15,6
 
import org.openconcerto.erp.core.sales.product.model.ProductHelper.SupplierPriceField;
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
169,39 → 167,10
 
private static SQLRowAccessor getStock(SQLRowAccessor rowValsProduct, SQLRowAccessor rowValsElt, SQLRowAccessor rowValsSource) {
SQLRowAccessor rowStock = null;
int idDepot = -1;
 
if (rowValsProduct.getTable().getDBRoot().contains("AFFAIRE")) {
SQLTable tableAff = rowValsProduct.getTable().getTable("AFFAIRE");
if (tableAff.contains("ID_DEPOT_STOCK")) {
final int idDepot;
if (rowValsSource.getFields().contains("ID_DEPOT_STOCK") && !rowValsSource.isForeignEmpty("ID_DEPOT_STOCK")) {
idDepot = rowValsSource.getForeignID("ID_DEPOT_STOCK");
} else if (rowValsSource.getFields().contains("ID_AFFAIRE") && !rowValsSource.isForeignEmpty("ID_AFFAIRE")) {
SQLRowAccessor rowAff = rowValsSource.getForeign("ID_AFFAIRE");
if (rowAff.getFields().contains("ID_DEPOT_STOCK") && !rowAff.isForeignEmpty("ID_DEPOT_STOCK")) {
idDepot = rowAff.getForeignID("ID_DEPOT_STOCK");
}
} else {
SQLField fieldParent = Configuration.getInstance().getDirectory().getElement(rowValsSource.getTable()).getParentForeignField();
if (fieldParent != null) {
SQLRowAccessor parent = rowValsSource.getForeign(fieldParent.getName());
 
if (parent.getFields().contains("ID_AFFAIRE") && !parent.isForeignEmpty("ID_AFFAIRE")) {
SQLRowAccessor rowAff = parent.getForeign("ID_AFFAIRE");
if (rowAff.getFields().contains("ID_DEPOT_STOCK") && !rowAff.isForeignEmpty("ID_DEPOT_STOCK")) {
idDepot = rowAff.getForeignID("ID_DEPOT_STOCK");
}
}
}
}
}
}
 
if (idDepot == -1) {
 
if (rowValsSource.getFields().contains("ID_DEPOT_STOCK") && !rowValsSource.isForeignEmpty("ID_DEPOT_STOCK")) {
idDepot = rowValsSource.getForeignID("ID_DEPOT_STOCK");
} else {
if (rowValsElt.getForeign("ID_DEPOT_STOCK") != null && !rowValsElt.isForeignEmpty("ID_DEPOT_STOCK")) {
idDepot = rowValsElt.getForeignID("ID_DEPOT_STOCK");
} else {
214,7 → 183,7
 
}
}
}
 
SQLTable stockTable = rowValsElt.getTable().getTable("STOCK");
SQLRowValues putRowValuesStock = new SQLRowValues(stockTable);
putRowValuesStock.putNulls(stockTable.getTable().getFieldsName());
246,37 → 215,4
}
return rowStock;
}
 
public static SQLRowAccessor findOrCreateStock(SQLRowAccessor article, SQLRowAccessor depot) {
 
SQLRowAccessor rowStock = null;
SQLTable stockTable = article.getTable().getTable("STOCK");
SQLRowValues putRowValuesStock = new SQLRowValues(stockTable);
putRowValuesStock.putNulls(stockTable.getTable().getFieldsName());
 
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(putRowValuesStock);
Where w = new Where(putRowValuesStock.getTable().getField("ID_DEPOT_STOCK"), "=", depot.getID());
Where w2 = new Where(putRowValuesStock.getTable().getField("ID_ARTICLE"), "=", article.getID());
Collection<SQLRowValues> rowValsResult = fetch.fetch(w.and(w2));
if (rowValsResult.size() == 0) {
SQLRowValues rowValsStock = new SQLRowValues(stockTable);
rowValsStock.put("ID_ARTICLE", article.getID());
rowValsStock.put("ID_DEPOT_STOCK", depot.getID());
rowValsStock.put("QTE_TH", 0F);
rowValsStock.put("QTE_REEL", 0F);
rowValsStock.put("QTE_RECEPT_ATTENTE", 0F);
rowValsStock.put("QTE_LIV_ATTENTE", 0F);
try {
rowStock = rowValsStock.insert();
} catch (SQLException e) {
ExceptionHandler.handle("Erreur lors la création du stock!", e);
}
} else if (rowValsResult.size() == 1) {
rowStock = rowValsResult.iterator().next();
} else if (rowValsResult.size() > 1) {
throw new IllegalStateException("2 lignes de stocks pour le même dépôt! Article " + article.getID() + " Depot " + depot.getID());
}
return rowStock;
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PostalCodeEditorPanel.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PaiementPanel.java
15,7 → 15,6
 
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.Paiement;
import org.openconcerto.erp.core.sales.pos.model.TicketItem;
 
import java.awt.Color;
import java.awt.Dimension;
27,7 → 26,6
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Rectangle2D;
import java.math.BigDecimal;
import java.util.List;
 
import javax.swing.JOptionPane;
68,16 → 66,14
 
@Override
public void paint(Graphics g) {
 
Graphics2D g2 = (Graphics2D) g;
g.setColor(new Color(250, 250, 250));
g.fillRect(0, 0, this.getWidth(), this.getHeight());
 
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.LIGHT_GRAY);
g.drawLine(0, 0, 0, this.getHeight());
int y = PAYMENT_POS_Y;
for (Paiement p : this.controller.getPaiements()) {
for (Paiement p : controller.getPaiements()) {
if (p.getType() == Paiement.CB) {
drawMontant(g, "CB", p, 242 - 15, y, true);
} else if (p.getType() == Paiement.CHEQUE) {
113,7 → 109,6
 
drawCalculator(g);
super.paint(g);
 
}
 
private void drawKey(Graphics2D g2, String string, int col, int row, int w, int h, Color color) {
142,7 → 137,7
Graphics2D g2 = (Graphics2D) g;
 
// LCD
if (this.controller.getArticleSelected() != null || this.controller.getPaiementSelected() != null) {
if (controller.getArticleSelected() != null || controller.getPaiementSelected() != null) {
g.setColor(new Color(232, 242, 254));
} else {
g.setColor(new Color(240, 240, 240));
152,10 → 147,10
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 = this.controller.getArticleSelected();
final Article article = controller.getArticleSelected();
g.setColor(Color.DARK_GRAY);
if (article != null) {
String string = this.calculatorValue;
String string = calculatorValue;
g.setFont(g.getFont().deriveFont(52f));
Rectangle2D r1 = g.getFontMetrics().getStringBounds(string, g2);
g.drawString(string, (int) (260 - r1.getWidth()), y);
163,9 → 158,9
g.drawString("Quantité", 10, 460 + y);
 
} else {
final Paiement paiement = this.controller.getPaiementSelected();
final Paiement paiement = controller.getPaiementSelected();
if (paiement != null) {
String string = this.calculatorValue;
String string = calculatorValue;
g.setFont(g.getFont().deriveFont(52f));
Rectangle2D r1 = g.getFontMetrics().getStringBounds(string, g2);
g.drawString(string, (int) (260 - r1.getWidth()), y);
184,7 → 179,7
}
}
g.setFont(g.getFont().deriveFont(14f));
g.drawString("" + this.mode, 10, y - 20);
g.drawString("" + mode, 10, y - 20);
}
 
private char getToucheFrom(int x, int y) {
304,23 → 299,23
 
@Override
public Dimension getPreferredSize() {
return new Dimension(this.calcWidth, 768);
return new Dimension(calcWidth, 768);
}
 
public Dimension getMinimumSize() {
return new Dimension(this.calcWidth, 768);
return new Dimension(calcWidth, 768);
}
 
@Override
public void caisseStateChanged() {
if (this.controller.getArticleSelected() != null) {
if (controller.getArticleSelected() != null) {
initCaisseArticle();
} else if (this.controller.getPaiementSelected() != null) {
} else if (controller.getPaiementSelected() != null) {
initCaissePaiement();
}
// Add / Remove solde if needed
boolean soldeIsShown = false;
for (Paiement p : this.controller.getPaiements()) {
for (Paiement p : controller.getPaiements()) {
if (p.getType() == Paiement.SOLDE) {
soldeIsShown = true;
break;
327,19 → 322,19
}
}
 
if (this.controller.isClientDefined()) {
if (!soldeIsShown && this.controller.getClient().getSolde().signum() == 1) {
if (controller.isClientDefined()) {
if (!soldeIsShown && controller.getClient().getSolde().signum() == 1) {
// add
this.controller.addPaiement(new Paiement(Paiement.SOLDE));
controller.addPaiement(new Paiement(Paiement.SOLDE));
}
} else {
if (soldeIsShown) {
// remove
final List<Paiement> paiements = this.controller.getPaiements();
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) {
this.controller.getPaiements().remove(i);
controller.getPaiements().remove(i);
break;
}
}
350,19 → 345,15
}
 
private void initCaisseArticle() {
if (this.controller.getTicketItemSelected() != null) {
this.calculatorValue = this.controller.getTicketItemSelected().getQty().toPlainString();
} else {
this.calculatorValue = "";
calculatorValue = String.valueOf(controller.getItemCount(controller.getArticleSelected()));
init = true;
mode = ' ';
}
this.init = true;
this.mode = ' ';
}
 
private void initCaissePaiement() {
this.calculatorValue = TicketCellRenderer.centsToString(this.controller.getPaiementSelected().getMontantInCents());
this.init = true;
this.mode = ' ';
calculatorValue = TicketCellRenderer.centsToString(controller.getPaiementSelected().getMontantInCents());
init = true;
mode = ' ';
}
 
@Override
393,32 → 384,32
} else {
Paiement p = getPaiementFrom(e.getY());
if (p != null) {
if (e.getX() > this.getWidth() - 68 && p.getType() != Paiement.ESPECES && this.controller.canAddPaiement(p.getType())) {
if (e.getX() > this.getWidth() - 68 && p.getType() != Paiement.ESPECES && controller.canAddPaiement(p.getType())) {
p = new Paiement(p.getType());
this.controller.addPaiement(p);
controller.addPaiement(p);
}
this.controller.autoFillPaiement(p);
controller.autoFillPaiement(p);
this.calculatorValue = TicketCellRenderer.centsToString(p.getMontantInCents());
if (p.getType() == Paiement.ESPECES) {
try {
this.controller.openDrawer();
controller.openDrawer();
} catch (Throwable ex) {
JOptionPane.showMessageDialog(PaiementPanel.this, "Ouverture du tiroir caisse impossible");
}
} else if (p.getType() == Paiement.CB) {
this.controller.sendCBRequest(p);
controller.sendCBRequest(p);
}
 
}
this.controller.setPaiementSelected(p);
controller.setPaiementSelected(p);
}
}
 
public void lcdPressed() {
System.err.println("PaiementPanel.lcdPressed()");
final TicketItem articleSelected = this.controller.getTicketItemSelected();
final Article articleSelected = controller.getArticleSelected();
if (articleSelected != null) {
this.controller.openPriceEditor(articleSelected);
controller.openPriceEditor(articleSelected);
}
repaint();
 
428,10 → 419,10
System.out.println("Handle: " + c);
if (c == '?')
return;
final TicketItem article = this.controller.getTicketItemSelected();
final Article article = controller.getArticleSelected();
 
if (c == '+' || c == '-' || c == '*') {
this.mode = c;
mode = c;
 
repaint();
return;
441,71 → 432,66
// Changement de quantité
if (c == 'c' || c == '/') {
System.out.println("Clear quantité");
this.mode = ' ';
this.controller.removeTicketItem(article);
mode = ' ';
controller.clearArticle(article);
} else if (c == '=' || c == '\n') {
if (!this.init) {
BigDecimal v = new BigDecimal(this.calculatorValue);
if (this.mode == ' ') {
article.setQty(v);
} else if (this.mode == '+') {
article.setQty(article.getQty().add(v));
} else if (this.mode == '-') {
article.setQty(article.getQty().subtract(v));
} else if (this.mode == '*') {
article.setQty(article.getQty().multiply(v));
if (!init) {
int v = Integer.parseInt(calculatorValue);
if (mode == ' ') {
controller.setArticleCount(article, v);
} else if (mode == '+') {
controller.setArticleCount(article, controller.getItemCount(article) + v);
} else if (mode == '-') {
controller.setArticleCount(article, controller.getItemCount(article) - v);
} else if (mode == '*') {
controller.setArticleCount(article, controller.getItemCount(article) * v);
}
// Reselect to fire a refresh
this.controller.setTicketItemSelected(article);
}
initCaisseArticle();
} else if (Character.isDigit(c)) {
if (this.init) {
this.calculatorValue = "";
this.init = false;
if (init) {
calculatorValue = "";
init = false;
}
if (this.calculatorValue.length() < 8) {
this.calculatorValue += c;
if (calculatorValue.length() < 8) {
calculatorValue += c;
}
}
if (article.getArticle().getSalesUnit() != null && c == '.' && (this.calculatorValue.indexOf('.') < 0)) {
this.calculatorValue += ".";
}
 
} else {
final Paiement paiement = this.controller.getPaiementSelected();
final Paiement paiement = controller.getPaiementSelected();
if (paiement != null) {
// Changement de paiement
if (c == 'c' || c == '/') {
System.out.println("Clear paiement");
this.mode = ' ';
this.controller.clearPaiement(paiement);
} else if (c == '.' && (this.calculatorValue.indexOf('.') < 0)) {
this.calculatorValue += ".";
mode = ' ';
controller.clearPaiement(paiement);
} else if (c == '.' && (calculatorValue.indexOf('.') < 0)) {
calculatorValue += ".";
} else if (c == '=' || c == '\n') {
if (!this.init) {
if (!init) {
int v = getCentsFrom(this.calculatorValue);
if (this.mode == ' ') {
this.controller.setPaiementValue(paiement, v);
} else if (this.mode == '+') {
this.controller.setPaiementValue(paiement, paiement.getMontantInCents() + v);
} else if (this.mode == '-') {
this.controller.setPaiementValue(paiement, paiement.getMontantInCents() - v);
} else if (this.mode == '*') {
this.controller.setPaiementValue(paiement, paiement.getMontantInCents() * v);
if (mode == ' ') {
controller.setPaiementValue(paiement, v);
} else if (mode == '+') {
controller.setPaiementValue(paiement, paiement.getMontantInCents() + v);
} else if (mode == '-') {
controller.setPaiementValue(paiement, paiement.getMontantInCents() - v);
} else if (mode == '*') {
controller.setPaiementValue(paiement, paiement.getMontantInCents() * v);
}
}
initCaissePaiement();
this.controller.setPaiementSelected(null);
controller.setPaiementSelected(null);
} else if (Character.isDigit(c)) {
if (this.init) {
this.calculatorValue = "";
this.init = false;
if (init) {
calculatorValue = "";
init = false;
}
if (this.calculatorValue.length() < 9) {
int i = this.calculatorValue.indexOf('.');
if (i < 0 || (this.calculatorValue.length() - i < 3)) {
this.calculatorValue += c;
if (calculatorValue.length() < 9) {
int i = calculatorValue.indexOf('.');
if (i < 0 || (calculatorValue.length() - i < 3)) {
calculatorValue += c;
}
}
}
548,8 → 534,8
 
private Paiement getPaiementFrom(int y) {
int index = (y - PAYMENT_POS_Y) / PAYMENT_LINE_HEIGHT;
if (index < this.controller.getPaiements().size() && index >= 0) {
return this.controller.getPaiements().get(index);
if (index < controller.getPaiements().size() && index >= 0) {
return controller.getPaiements().get(index);
}
return null;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseFrame.java
16,6 → 16,7
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
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.DBState;
import org.openconcerto.erp.core.sales.pos.model.ReceiptCode;
25,7 → 26,6
import org.openconcerto.erp.core.sales.pos.model.RegisterState;
import org.openconcerto.erp.core.sales.pos.model.RegisterState.Status;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.erp.core.sales.pos.model.TicketItem;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.RemoteShell;
225,6 → 225,11
public void run() {
 
try {
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
try {
CaisseFrame f = new CaisseFrame(posConf, conf, registerFiles, registerDB);
f.setUndecorated(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
243,9 → 248,9
}
System.out.println("Affichage de l'interface");
f.setVisible(true);
if (screenSize.getWidth() < 1024 || screenSize.getHeight() < 720) {
if (screenSize.getWidth() < 1280 || screenSize.getHeight() < 720) {
JOptionPane.showMessageDialog(f,
"La résolution de votre écran est trop faible.\nLa largeur doit être au minium de 1024 pixels.\nLa hauteur doit être au minium de 720 pixels.");
"La résolution de votre écran est trop faible.\nLa largeur doit être au minium de 1280 pixels.\nLa hauteur doit être au minium de 720 pixels.");
}
} catch (Throwable e) {
// Catch throwable to be able to see NoClassDefFound and other hard issues
510,11 → 515,11
this.repaint();
}
 
public void showPriceEditor(TicketItem item, CaisseControler caisseControler) {
public void showPriceEditor(Article article, CaisseControler caisseControler) {
getControler().disableBarcodeReader();
System.out.println("CaisseFrame.showPriceEditor()");
this.invalidate();
final PriceEditorPanel panel = new PriceEditorPanel(this, item);
final PriceEditorPanel panel = new PriceEditorPanel(this, article);
 
final POSGlassPane glassPane2 = new POSGlassPane(panel, (getWidth() - panel.getPreferredSize().width) / 2, 100) {
@Override
580,16 → 585,4
this.validate();
this.repaint();
}
 
public void showPostalCodeFrame(CaissePanel caissePanel) {
System.out.println("CaisseFrame.showPostalCodeFrame()");
this.invalidate();
final PostalCodeEditorPanel panel = new PostalCodeEditorPanel(this, caissePanel);
final POSGlassPane glassPane2 = new POSGlassPane(panel, (getWidth() - panel.getPreferredSize().width) / 2, 100);
this.setGlassPane(glassPane2);
this.getGlassPane().setVisible(true);
this.validate();
this.repaint();
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ListeDesTicketsPanel.java
16,6 → 16,7
import org.openconcerto.erp.core.sales.pos.TicketPrinterConfiguration;
import org.openconcerto.erp.core.sales.pos.io.Printable;
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.RegisterFiles;
import org.openconcerto.erp.core.sales.pos.model.RegisterLog;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
22,6 → 23,7
import org.openconcerto.ui.DefaultListModel;
import org.openconcerto.ui.touch.ScrollableList;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Pair;
 
import java.awt.Color;
import java.awt.Component;
109,7 → 111,7
}
 
@Override
protected final List<Ticket> getReceipts() throws ParseException, IOException {
protected final List<Ticket> getReceipts() throws ParseException {
return this.getLog().parseReceipts();
}
 
158,22 → 160,22
try {
final RegisterLog lastLog = this.frame.getFiles().getLastLog();
final List<Ticket> receipts = lastLog.parseReceipts();
this.ticketLlistModel = new DefaultListModel();
this.ticketLlistModel.addElement(new X(lastLog, receipts));
this.ticketLlistModel.addElement(new XLite(lastLog, receipts));
ticketLlistModel = new DefaultListModel();
ticketLlistModel.addElement(new X(lastLog, receipts));
ticketLlistModel.addElement(new XLite(lastLog, receipts));
final Date previousDate = lastLog.getFirstRegisterEvent().getPreviousDate();
if (previousDate != null) {
final Calendar cal = Calendar.getInstance();
cal.setTime(previousDate);
this.ticketLlistModel.addElement(new Z(this.frame.getFiles(), cal));
ticketLlistModel.addElement(new Z(this.frame.getFiles(), cal));
}
this.ticketLlistModel.addAll(receipts);
ticketLlistModel.addAll(receipts);
 
} catch (Exception exn) {
ExceptionHandler.handle(this.frame, "Impossible de charger les tickets", exn);
}
final Font f = new Font(ARIAL_FONT, Font.PLAIN, 24);
this.ticketList = new ScrollableList(this.ticketLlistModel) {
ticketList = new ScrollableList(ticketLlistModel) {
@Override
public void paintCell(Graphics g, Object object, int index, boolean isSelected, int posY) {
g.setFont(f);
209,25 → 211,24
}
}
};
this.add(this.ticketList, c);
this.add(ticketList, c);
// Ticket
c.fill = GridBagConstraints.VERTICAL;
c.weightx = 0;
c.gridx++;
c.gridheight = 1;
c.insets = new Insets(10, 10, 10, 10);
this.ticketP = new TextAreaTicketPrinter();
ticketP = new TextAreaTicketPrinter();
 
JScrollPane scrollPane = new JScrollPane(this.ticketP);
JScrollPane scrollPane = new JScrollPane(ticketP);
scrollPane.setPreferredSize(new Dimension(400, 200));
scrollPane.setMinimumSize(new Dimension(400, 200));
this.add(scrollPane, c);
 
this.ticketList.addListSelectionListener(new ListSelectionListener() {
ticketList.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
Object selectedValue = ListeDesTicketsPanel.this.ticketList.getSelectedValue();
Object selectedValue = ticketList.getSelectedValue();
setSelectedTicket(selectedValue);
}
});
238,8 → 239,8
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
final Font font = new Font(ARIAL_FONT, Font.PLAIN, 46);
this.l = new JList(new String[] { "Imprimer", "Annuler le ticket" });
this.l.setCellRenderer(new ListCellRenderer() {
l = new JList(new String[] { "Imprimer", "Annuler" });
l.setCellRenderer(new ListCellRenderer() {
 
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
258,11 → 259,11
}
 
});
this.l.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.l.getSelectionModel().addListSelectionListener(this);
l.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
l.getSelectionModel().addListSelectionListener(this);
 
this.l.setFixedCellHeight(100);
this.add(this.l, c);
l.setFixedCellHeight(160);
this.add(l, c);
 
setFont(new Font(ARIAL_FONT, Font.BOLD, 24));
 
271,7 → 272,7
 
@Override
public void actionPerformed(ActionEvent e) {
ListeDesTicketsPanel.this.frame.showCaisse();
frame.showCaisse();
 
}
});
283,25 → 284,30
if (e.getValueIsAdjusting()) {
return;
}
Object selectedValue = this.ticketList.getSelectedValue();
int selectedIndex = this.l.getSelectedIndex();
Object selectedValue = ticketList.getSelectedValue();
int selectedIndex = l.getSelectedIndex();
if (selectedIndex == 0 && selectedValue != null) {
this.frame.getPOSConf().printOnceOnFirstPrinter(((Printable) selectedValue));
} else if (selectedIndex == 1 && selectedValue != null && selectedValue instanceof Ticket) {
} else if (selectedIndex == 1 && selectedValue != null) {
// Annulation du ticket
Ticket t = (Ticket) selectedValue;
this.frame.getControler().cancel(t);
 
for (Pair<Article, Integer> a : t.getArticles()) {
frame.getControler().addArticle(a.getFirst());
frame.getControler().setArticleCount(a.getFirst(), -a.getSecond());
frame.getControler().setArticleHT(a.getFirst(), a.getFirst().getPriceWithoutTax());
}
this.l.clearSelection();
frame.showCaisse();
}
l.clearSelection();
}
 
public void setSelectedTicket(Object selectedValue) {
this.ticketP.clear();
ticketP.clear();
if (selectedValue != null) {
this.frame.getPOSConf().print(((Printable) selectedValue), new TicketPrinterConfiguration() {
@Override
public TicketPrinter createTicketPrinter() {
return ListeDesTicketsPanel.this.ticketP;
return ticketP;
}
 
@Override
315,11 → 321,11
}
});
try {
this.ticketP.printBuffer();
ticketP.printBuffer();
} catch (Exception e1) {
e1.printStackTrace();
}
}
this.ticketList.setSelectedValue(selectedValue, true);
ticketList.setSelectedValue(selectedValue, true);
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ArticleSelector.java
36,7 → 36,7
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
public class ArticleSelector extends JPanel implements CaisseListener {
public class ArticleSelector extends JPanel implements ListSelectionListener, CaisseListener {
private ArticleModel model;
private ScrollableList list;
private StatusBar comp;
52,34 → 52,28
c.gridy = 0;
c.weightx = 1;
c.fill = GridBagConstraints.BOTH;
this.comp = new StatusBar();
this.comp.setLayout(new FlowLayout(FlowLayout.LEFT));
this.comp.setTitle("Articles");
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);
this.comp.add(bSwitch);
this.add(this.comp, c);
comp.add(bSwitch);
this.add(comp, c);
 
c.weighty = 1;
c.gridy++;
this.model = new ArticleModel();
this.model.setCategorie(null);
model = new ArticleModel();
model.setCategorie(null);
 
final Font f;
if (controller.getPOSConf().getScreenWidth() < 1280) {
f = new Font("Arial", Font.PLAIN, 18);
} else {
f = new Font("Arial", Font.PLAIN, 21);
}
 
this.list = new ScrollableList(this.model) {
final Font f = new Font("Arial", Font.PLAIN, 21);
list = new ScrollableList(model) {
int maxStringWidth = 0;
 
@Override
public void paint(Graphics g) {
 
if (this.maxStringWidth == 0) {
if (maxStringWidth == 0) {
g.setFont(f);
int w = this.getWidth();
int priceWidth = (int) g.getFontMetrics(f).getStringBounds(getPrice(BigDecimal.valueOf(999)), g).getWidth();
91,7 → 85,8
str += "a";
} while (strW < maxW);
 
this.maxStringWidth = Math.max(1, str.length() - 1);
maxStringWidth = Math.max(1, str.length() - 1);
System.out.println(w + " " + priceWidth + " " + maxStringWidth);
 
}
super.paint(g);
102,39 → 97,24
@Override
public void paintCell(Graphics g, Object object, int index, boolean isSelected, int posY) {
Article article = (Article) object;
paintArticle(f, g, article, isSelected, posY, this.getWidth(), this.getCellHeight(), this.maxStringWidth, getLeftMargin());
paintArticle(f, g, article, isSelected, posY, this.getWidth(), this.getCellHeight(), maxStringWidth, getLeftMargin());
 
}
};
 
this.list.setFixedCellHeight(64);
this.list.setOpaque(true);
this.add(this.list, c);
this.list.addListSelectionListener(new ListSelectionListener() {
list.setFixedCellHeight(64);
list.setOpaque(true);
this.add(list, c);
list.addListSelectionListener(this);
 
list.addMouseListener(new MouseAdapter() {
@Override
public void valueChanged(ListSelectionEvent e) {
Object sel = ArticleSelector.this.list.getSelectedValue();
if (sel != null && !e.getValueIsAdjusting()) {
Article article = (Article) sel;
controller.setArticleSelected(article);
}
 
}
});
 
this.list.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
 
Object sel = ArticleSelector.this.list.getSelectedValue();
int nb = e.getClickCount();
if (nb > 1) {
Object sel = list.getSelectedValue();
if (sel != null) {
int nb = e.getClickCount();
if (nb == 1) {
Article article = (Article) sel;
controller.addArticle(article);
} else if (nb > 1) {
Article article = (Article) sel;
controller.incrementArticle(article);
controller.setArticleSelected(article);
}
150,14 → 130,24
 
}
});
this.comp.addMouseListener(new MouseAdapter() {
comp.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
ArticleSelector.this.list.scrollToOffset(0);
list.scrollToOffset(0);
}
});
}
 
@Override
public void valueChanged(ListSelectionEvent e) {
Object sel = list.getSelectedValue();
if (sel != null && !e.getValueIsAdjusting()) {
Article article = (Article) sel;
controller.setArticleSelected(article);
controller.addArticle(article);
}
}
 
public ArticleModel getModel() {
return this.model;
}
165,22 → 155,22
@Override
public void caisseStateChanged() {
 
final Article articleSelected = this.controller.getArticleSelected();
final Article articleSelected = controller.getArticleSelected();
if (articleSelected == null) {
this.list.clearSelection();
list.clearSelection();
return;
}
 
Object selectedValue = null;
try {
selectedValue = this.list.getSelectedValue();
selectedValue = list.getSelectedValue();
} catch (Exception e) {
e.printStackTrace();
}
if (!articleSelected.equals(selectedValue)) {
Categorie c = articleSelected.getCategorie();
this.model.setCategorie(c);
this.list.setSelectedValue(articleSelected, true);
model.setCategorie(c);
list.setSelectedValue(articleSelected, true);
}
 
}
236,35 → 226,10
g.drawString(label, leftMargin, posY + 26);
g.drawString(label2, leftMargin, posY + 52);
}
 
if (isSelected) {
g.setColor(new Color(232, 242, 254));
} else {
g.setColor(Color.WHITE);
}
g.fillRect(cellWidth - wEuro - 12, posY + 1, wEuro + 12, cellHeight - 2);
 
// Price
if (isSelected) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
if (article.getSalesUnit() != null) {
String unit = "/" + article.getSalesUnit();
int wUnit = (int) g.getFontMetrics().getStringBounds(unit, g).getWidth();
g.drawString(euro, cellWidth - 5 - wEuro, posY + 28);
g.drawString(unit, cellWidth - 5 - wUnit, posY + 50);
} else {
g.drawString(euro, cellWidth - 5 - wEuro, posY + 39);
}
 
}
 
public int getLeftMargin() {
if (this.controller.getPOSConf().getScreenWidth() < 1280) {
return 3;
}
return 10;
}
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaissePanel.java
20,10 → 20,7
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
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.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.SQLTable.VirtualFields;
64,7 → 61,7
private ArticleSelectorPanel articleSelectorPanel;
private ArticleSearchPanel articleSearchPanel;
 
private JPanel selector;
private JPanel articleSelector;
 
public CaissePanel(final CaisseFrame caisseFrame) throws Exception {
final SQLElementDirectory dir = caisseFrame.getConf().getDirectory();
73,36 → 70,40
this.setBackground(Color.WHITE);
this.setOpaque(isOpaque());
GridBagConstraints c = new GridBagConstraints();
 
// Column 1
c.gridx = 0;
c.gridy = 0;
c.weightx = 0;
c.weighty = 0;
 
this.controler = new CaisseControler(caisseFrame);
 
c.fill = GridBagConstraints.HORIZONTAL;
this.st = createStatusBar(caisseFrame);
 
this.add(this.st, c);
 
TicketPanel t = new TicketPanel(this.controler);
// fillExampleArticle();
loadArticles(dir);
c.gridx = 0;
c.gridy++;
c.weightx = 0;
c.weighty = 1;
c.gridwidth = 1;
c.anchor = GridBagConstraints.SOUTHWEST;
c.fill = GridBagConstraints.NONE;
this.add(t, c);
// Column 2
 
c.fill = GridBagConstraints.BOTH;
c.gridx++;
c.gridy = 0;
c.weightx = 1;
c.gridy--;
c.gridheight = 2;
this.articleSelectorPanel = new ArticleSelectorPanel(this.controler);
this.articleSearchPanel = new ArticleSearchPanel(this.controler);
this.selector = this.articleSelectorPanel;
this.add(this.selector, c);
// Column 3
articleSelectorPanel = new ArticleSelectorPanel(this.controler);
articleSearchPanel = new ArticleSearchPanel(this.controler);
articleSelector = articleSelectorPanel;
this.add(articleSelector, c);
 
c.gridx++;
c.weightx = 0;
this.add(new PaiementPanel(this.controler), c);
113,11 → 114,7
final StatusBar s = new StatusBar();
s.setLayout(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints();
if (this.controler.getPOSConf().getScreenWidth() < 1280) {
c.insets = new Insets(0, 2, 0, 2);
} else {
c.insets = new Insets(0, 10, 0, 10);
}
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.NONE;
202,17 → 199,11
}
 
private void loadArticles(final SQLElementDirectory dir) {
final SQLSelect selUniteVente = new SQLSelect();
selUniteVente.addSelectStar(dir.getElement("UNITE_VENTE").getTable());
final Map<Integer, String> mapUniteVenteName = new HashMap<>();
for (SQLRow row : SQLRowListRSH.execute(selUniteVente)) {
mapUniteVenteName.put(row.getID(), row.getString("CODE"));
}
 
final Set<Integer> favoriteProductsIds = this.controler.loadFavoriteProductsIds();
final Set<Integer> favoriteProductsIds = controler.loadFavoriteProductsIds();
final List<Article> favoriteProducts = new ArrayList<>();
 
final Map<Integer, Categorie> categoriesMap = new HashMap<>();
final Map<Integer, Categorie> categoriesMap = new HashMap<Integer, Categorie>();
 
SQLElement eltFam = dir.getElement("FAMILLE_ARTICLE");
SQLElement eltArticle = dir.getElement("ARTICLE");
238,7 → 229,7
final SQLSelect selArticle = new SQLSelect();
final SQLTable tableArticle = eltArticle.getTable();
selArticle.addAllSelect(tableArticle.getFields(VirtualFields.PRIMARY_KEY.union(VirtualFields.ARCHIVE)));
selArticle.addAllSelect(tableArticle, Arrays.asList("ID_FAMILLE_ARTICLE", "NOM", "CODE", "CODE_BARRE", "ID_TAXE", "PV_HT", "PV_TTC", "ADDITIONAL_TICKET_COPY", "ID_UNITE_VENTE"));
selArticle.addAllSelect(tableArticle, Arrays.asList("ID_FAMILLE_ARTICLE", "NOM", "CODE", "CODE_BARRE", "ID_TAXE", "PV_HT", "PV_TTC", "ADDITIONAL_TICKET_COPY"));
selArticle.setWhere(new Where(tableArticle.getField("OBSOLETE"), "=", Boolean.FALSE).and(new Where(tableArticle.getField("MASQUE_CAISSE"), "=", Boolean.FALSE)));
 
final Categorie cUnclassified = new Categorie("Non classés", true);
261,9 → 252,6
a.setPriceWithoutTax(row.getBigDecimal("PV_HT"));
a.setPriceWithTax(row.getBigDecimal("PV_TTC"));
a.setAdditionalCopyRequested(row.getBoolean("ADDITIONAL_TICKET_COPY"));
if (row.getInt("ID_UNITE_VENTE") != 2) {
a.setSalesUnit(mapUniteVenteName.get(row.getInt("ID_UNITE_VENTE")));
}
final Integer idProduct = a.getId();
if (favoriteProductsIds.contains(idProduct)) {
favoriteProducts.add(a);
272,39 → 260,8
}
}
Categorie.setFavoriteProducts(favoriteProducts);
initCacheArticleMap(dir);
}
 
private static Map<Integer, SQLRowAccessor> cacheArticle = new HashMap<>();
 
public static SQLRowAccessor getArticleRowValuesFromCache(int id) {
return cacheArticle.get(id);
}
 
private void initCacheArticleMap(final SQLElementDirectory dir) {
final SQLTable tableArt = dir.getElement("ARTICLE").getTable();
SQLRowValues rowValsArt = new SQLRowValues(tableArt);
rowValsArt.putNulls(tableArt.getFieldsName());
final SQLTable tableArtCatComptable = dir.getElement("ARTICLE_CATEGORIE_COMPTABLE").getTable();
SQLRowValues rowValsArtCatComptable = new SQLRowValues(tableArtCatComptable);
rowValsArtCatComptable.putNulls(tableArtCatComptable.getFieldsName());
rowValsArtCatComptable.put("ID_ARTICLE", rowValsArt);
final SQLRowValues rowValsCaCompt = rowValsArtCatComptable.putRowValues("ID_CATEGORIE_COMPTABLE");
rowValsCaCompt.putNulls(rowValsCaCompt.getTable().getFieldsName());
 
final SQLRowValues rowValsFam = rowValsArt.putRowValues("ID_FAMILLE_ARTICLE");
rowValsFam.putNulls(rowValsFam.getTable().getFieldsName());
final SQLRowValues rowValuesFamP = rowValsFam.putRowValues("ID_FAMILLE_ARTICLE_PERE");
rowValuesFamP.putNulls(rowValuesFamP.getTable().getFieldsName());
 
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsArt);
List<SQLRowValues> res = fetcher.fetch();
for (SQLRowValues sqlRowValues : res) {
cacheArticle.put(sqlRowValues.getID(), sqlRowValues);
}
 
}
 
@Override
public void paint(Graphics g) {
System.err.println("CaissePanel.paint()" + this.getWidth() + " x " + this.getHeight());
322,12 → 279,9
g.drawString("Solde : " + new DecimalFormat("#0.00").format(this.controler.getClient().getSolde()), 20, 120);
 
}
int xPos = 300;
if (this.controler.getPOSConf().getScreenWidth() < 1280) {
xPos = 270;
}
 
// Prix
int x = xPos;
int x = 300;
int y = 110;
String euros;
String cents;
349,7 → 303,7
g.drawString(cents, x + (int) r.getWidth(), y);
// Paiement
y += 40;
x = xPos;
x = 300;
final int paye = this.controler.getPaidTotal();
euros = CaisseControler.getEuros(paye) + ".";
cents = CaisseControler.getCents(paye);
373,7 → 327,7
final boolean minimalHeight = this.getHeight() < 750;
if (!minimalHeight) {
y += 40;
x = xPos;
x = 300;
} else {
x = 140;
}
418,16 → 372,15
 
public void switchListMode() {
 
GridBagConstraints c = ((GridBagLayout) this.getLayout()).getConstraints(this.selector);
this.remove(this.selector);
GridBagConstraints c = ((GridBagLayout) this.getLayout()).getConstraints(articleSelector);
this.remove(articleSelector);
 
if (this.selector == this.articleSearchPanel) {
this.selector = this.articleSelectorPanel;
if (articleSelector == this.articleSearchPanel) {
articleSelector = this.articleSelectorPanel;
} else {
this.selector = this.articleSearchPanel;
articleSelector = this.articleSearchPanel;
}
System.err.println("CaissePanel.switchListMode()" + this.selector.getMinimumSize() + " " + this.selector.getPreferredSize() + " " + this.selector.getMaximumSize());
this.add(this.selector, c);
this.add(articleSelector, c);
this.validate();
this.repaint();
 
434,36 → 387,6
}
 
public CaisseControler getControler() {
return this.controler;
return controler;
}
 
public void validateTicket(final CaisseFrame caisseFrame) {
final Ticket savedReceipt;
try {
savedReceipt = CaissePanel.this.controler.saveAndClearTicket(caisseFrame.getFiles(), caisseFrame.getConf().getDirectory());
} catch (DifferentDayException ex) {
JOptionPane.showMessageDialog(CaissePanel.this, "Impossible de laisser la caisse ouverte plusieurs jours. Veuillez la clôturer pour pouvoir faire de nouveaux tickets.", "Erreur",
JOptionPane.ERROR_MESSAGE);
return;
} catch (Throwable ex) {
ExceptionHandler.handle(CaissePanel.this, "Erreur de sauvegarde des informations du ticket", ex);
return;
}
if (savedReceipt != null) {
// Valider
CaissePanel.this.controler.setLCD("Impression de", "votre ticket...", 0);
try {
caisseFrame.getPOSConf().print(savedReceipt, (savedReceipt.isAdditionnalCopyRequested() ? 1 : 0));
} catch (UnsatisfiedLinkError ex) {
JOptionPane.showMessageDialog(CaissePanel.this, "Erreur de configuration de la liaison à l'imprimante");
} catch (Throwable ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(CaissePanel.this, "Erreur d'impression du ticket");
}
 
CaissePanel.this.controler.setLCDDefaultDisplay(2);
} else {
System.err.println("CaissePanel.validateTicket() ticket non sauvé");
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TextAreaTicketPanel.java
23,10 → 23,7
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.DecimalUtils;
 
36,9 → 33,7
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.swing.JButton;
import javax.swing.JPanel;
82,7 → 77,6
}
 
private Ticket createTicket(SQLRow row) {
// TODO merger ce code avec CaissepPanel.loadArticles si possible
final Ticket t;
try {
t = new Ticket(new ReceiptCode(row.getString("NUMERO")), row.getDate("DATE"), row.getString("FILE_HASH_PREVIOUS"));
90,8 → 84,7
throw new IllegalStateException("Couldn't parse " + row, e);
}
 
final SQLElementDirectory directory = Configuration.getInstance().getDirectory();
SQLElement eltEncaisser = directory.getElement("ENCAISSER_MONTANT");
SQLElement eltEncaisser = Configuration.getInstance().getDirectory().getElement("ENCAISSER_MONTANT");
List<SQLRow> l = row.getReferentRows(eltEncaisser.getTable());
for (SQLRow row2 : l) {
long montant = row2.getLong("MONTANT");
113,35 → 106,20
t.addPaiement(p);
}
 
SQLElement eltArticle = directory.getElement("SAISIE_VENTE_FACTURE_ELEMENT");
 
final SQLSelect selUniteVente = new SQLSelect();
selUniteVente.addSelectStar(directory.getElement("UNITE_VENTE").getTable());
final Map<Integer, String> mapUniteVenteName = new HashMap<>();
for (SQLRow rowUniteVente : SQLRowListRSH.execute(selUniteVente)) {
mapUniteVenteName.put(rowUniteVente.getID(), rowUniteVente.getString("CODE"));
}
 
SQLElement eltArticle = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
List<SQLRow> l2 = row.getReferentRows(eltArticle.getTable());
Categorie c = new Categorie("");
for (SQLRow row2 : l2) {
Article a = new Article(c, row2.getString("NOM"), row2.getInt("ID_ARTICLE"));
if (row2.getInt("ID_UNITE_VENTE") != 2) {
a.setSalesUnit(mapUniteVenteName.get(row2.getInt("ID_UNITE_VENTE")));
}
BigDecimal ht = (BigDecimal) row2.getObject("PV_HT");
a.setPriceWithoutTax(ht);
int idTaxe = row2.getInt("ID_TAXE");
float tva = TaxeCache.getCache().getTauxFromId(idTaxe);
a.setPriceWithTax(ht.multiply(BigDecimal.valueOf(1.0 + (tva / 100.0D)), DecimalUtils.HIGH_PRECISION));
a.setPriceWithTax(ht.multiply(new BigDecimal(1.0 + (tva / 100.0D)), DecimalUtils.HIGH_PRECISION));
a.setIdTaxe(idTaxe);
t.addArticle(a);
if (a.getSalesUnit() == null) {
t.setArticleCount(a, new BigDecimal(row2.getInt("QTE")));
} else {
t.setArticleCount(a, row2.getBigDecimal("QTE_UNITAIRE"));
t.setArticleCount(a, row2.getInt("QTE"));
}
}
 
return t;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CategorieSelector.java
85,10 → 85,6
 
}
super.paint(g);
 
g.setColor(Color.LIGHT_GRAY);
g.drawLine(0, 0, 0, this.getHeight());
 
}
 
private int getLeftMargin() {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ArticleSelectorPanel.java
13,6 → 13,7
package org.openconcerto.erp.core.sales.pos.ui;
 
 
import java.awt.GridLayout;
 
import javax.swing.JPanel;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/PriceEditorPanel.java
15,7 → 15,6
 
import org.openconcerto.erp.core.common.ui.NumericTextField;
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.TicketItem;
 
import java.awt.Color;
import java.awt.GridBagConstraints;
33,7 → 32,7
import javax.swing.event.DocumentListener;
 
public class PriceEditorPanel extends JPanel {
private final transient TicketItem item;
private final transient Article article;
private final POSLabel labelPrice;
private final POSRadioButton rHT;
private final POSRadioButton rTTC;
45,8 → 44,8
private final NumericTextField discountTextField;
private final NumericKeypadPanel keyPad;
 
public PriceEditorPanel(final CaisseFrame caisseFrame, final TicketItem item) {
this.item = item;
public PriceEditorPanel(final CaisseFrame caisseFrame, final Article article) {
this.article = article;
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setLayout(new GridBagLayout());
65,59 → 64,59
// Line 2
c.gridy++;
c.gridwidth = 1;
this.rTTC = new POSRadioButton("prix TTC");
this.rTTC.setSelected(true);
rTTC = new POSRadioButton("prix TTC");
rTTC.setSelected(true);
c.weightx = 0;
this.add(this.rTTC, c);
this.ttcTextField = new NumericTextField();
this.ttcTextField.setFont(title.getFont());
this.ttcTextField.setValue(item.getArticle().getPriceWithTax());
this.ttcTextField.requestFocusInWindow();
this.add(rTTC, c);
ttcTextField = new NumericTextField();
ttcTextField.setFont(title.getFont());
ttcTextField.setValue(article.getPriceWithTax());
ttcTextField.requestFocusInWindow();
c.gridx++;
c.weightx = 1;
this.add(this.ttcTextField, c);
this.add(ttcTextField, c);
// Line 3
c.gridy++;
this.rHT = new POSRadioButton("prix HT");
rHT = new POSRadioButton("prix HT");
c.gridx = 0;
c.weightx = 0;
this.add(this.rHT, c);
this.htTextField = new NumericTextField();
this.htTextField.setValue(item.getArticle().getPriceWithoutTax());
this.htTextField.setFont(title.getFont());
this.add(rHT, c);
htTextField = new NumericTextField();
htTextField.setValue(article.getPriceWithoutTax());
htTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(this.htTextField, c);
this.add(htTextField, c);
// Line 4
c.gridy++;
this.rDiscountPercent = new POSRadioButton("remise en %");
rDiscountPercent = new POSRadioButton("remise en %");
c.gridx = 0;
c.weightx = 0;
this.add(this.rDiscountPercent, c);
this.discountPercentTextField = new NumericTextField();
this.discountPercentTextField.setValue(BigDecimal.ZERO);
this.discountPercentTextField.setFont(title.getFont());
this.add(rDiscountPercent, c);
discountPercentTextField = new NumericTextField();
discountPercentTextField.setValue(BigDecimal.ZERO);
discountPercentTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(this.discountPercentTextField, c);
this.add(discountPercentTextField, c);
// Line 5
this.rDiscount = new POSRadioButton("remise HT");
rDiscount = new POSRadioButton("remise HT");
c.gridx = 0;
c.weightx = 0;
c.gridy++;
this.add(this.rDiscount, c);
this.discountTextField = new NumericTextField();
this.discountTextField.setValue(BigDecimal.ZERO);
this.discountTextField.setFont(title.getFont());
this.add(rDiscount, c);
discountTextField = new NumericTextField();
discountTextField.setValue(BigDecimal.ZERO);
discountTextField.setFont(title.getFont());
c.gridx++;
c.weightx = 1;
this.add(this.discountTextField, c);
this.add(discountTextField, c);
 
final ButtonGroup group = new ButtonGroup();
group.add(this.rHT);
group.add(this.rTTC);
group.add(this.rDiscountPercent);
group.add(this.rDiscount);
group.add(rHT);
group.add(rTTC);
group.add(rDiscountPercent);
group.add(rDiscount);
//
//
c.gridy++;
124,14 → 123,13
c.gridx = 0;
c.gridwidth = 2;
final POSLabel labelPriceOld = new POSLabel("Ancien Prix : ");
labelPriceOld.setText(
"Ancien Prix : " + TicketCellRenderer.toString(item.getArticle().getPriceWithTax()) + "€ TTC, " + TicketCellRenderer.toString(item.getArticle().getPriceWithoutTax()) + "€ HT");
labelPriceOld.setText("Ancien Prix : " + TicketCellRenderer.toString(article.getPriceWithTax()) + "€ TTC, " + TicketCellRenderer.toString(article.getPriceWithoutTax()) + "€ HT");
this.add(labelPriceOld, c);
 
c.gridy++;
c.gridx = 0;
this.labelPrice = new POSLabel("Nouveau Prix : ");
this.add(this.labelPrice, c);
labelPrice = new POSLabel("Nouveau Prix : ");
this.add(labelPrice, c);
 
c.gridy++;
c.gridx = 0;
148,7 → 146,7
 
@Override
public void actionPerformed(ActionEvent e) {
caisseFrame.getControler().setArticleHT(item, getHTFromUI());
caisseFrame.getControler().setArticleHT(article, getHTFromUI());
caisseFrame.showCaisse();
}
});
170,10 → 168,10
c.insets = new Insets(20, 20, 30, 20);
// Line 1
c.gridheight = 5;
this.keyPad = new NumericKeypadPanel(this.ttcTextField);
this.add(this.keyPad, c);
keyPad = new NumericKeypadPanel(ttcTextField);
this.add(keyPad, c);
 
updatePrice(item.getArticle().getPriceWithoutTax());
updatePrice(article.getPriceWithoutTax());
updateTextFields();
//
final ActionListener listenerRadio = new ActionListener() {
228,11 → 226,11
if (this.rHT.isSelected()) {
r = this.htTextField.getValue();
} else if (this.rTTC.isSelected()) {
r = Article.computePriceWithoutTax(this.ttcTextField.getValue(), this.item.getArticle().getIdTaxe());
r = Article.computePriceWithoutTax(this.ttcTextField.getValue(), this.article.getIdTaxe());
} else if (this.rDiscountPercent.isSelected()) {
r = this.item.getArticle().getPriceWithoutTax().subtract(this.item.getArticle().getPriceWithoutTax().multiply(this.discountPercentTextField.getValue().divide(new BigDecimal(100))));
r = this.article.getPriceWithoutTax().subtract(this.article.getPriceWithoutTax().multiply(this.discountPercentTextField.getValue().divide(new BigDecimal(100))));
} else if (this.rDiscount.isSelected()) {
r = this.item.getArticle().getPriceWithoutTax().subtract(this.discountTextField.getValue());
r = this.article.getPriceWithoutTax().subtract(this.discountTextField.getValue());
}
} catch (Exception e) {
e.printStackTrace();
239,30 → 237,30
}
if (r == null) {
// fallback if something wrong
r = this.item.getArticle().getPriceWithoutTax();
r = this.article.getPriceWithoutTax();
}
return r;
}
 
private void updatePrice(BigDecimal ht) {
BigDecimal ttc = Article.computePriceWithTax(ht, this.item.getArticle().getIdTaxe());
this.labelPrice.setText("Nouveau Prix : " + TicketCellRenderer.toString(ttc) + "€ TTC, " + TicketCellRenderer.toString(ht) + "€ HT");
BigDecimal ttc = Article.computePriceWithTax(ht, this.article.getIdTaxe());
labelPrice.setText("Nouveau Prix : " + TicketCellRenderer.toString(ttc) + "€ TTC, " + TicketCellRenderer.toString(ht) + "€ HT");
}
 
private void updateTextFields() {
this.invalidate();
this.htTextField.setVisible(false);
this.ttcTextField.setVisible(false);
this.discountPercentTextField.setVisible(false);
this.discountTextField.setVisible(false);
if (this.rHT.isSelected()) {
enableTextField(this.htTextField);
} else if (this.rTTC.isSelected()) {
enableTextField(this.ttcTextField);
} else if (this.rDiscountPercent.isSelected()) {
enableTextField(this.discountPercentTextField);
} else if (this.rDiscount.isSelected()) {
enableTextField(this.discountTextField);
htTextField.setVisible(false);
ttcTextField.setVisible(false);
discountPercentTextField.setVisible(false);
discountTextField.setVisible(false);
if (rHT.isSelected()) {
enableTextField(htTextField);
} else if (rTTC.isSelected()) {
enableTextField(ttcTextField);
} else if (rDiscountPercent.isSelected()) {
enableTextField(discountPercentTextField);
} else if (rDiscount.isSelected()) {
enableTextField(discountTextField);
}
this.validate();
repaint();
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/ArticleSearchPanel.java
17,7 → 17,6
import org.openconcerto.erp.core.sales.pos.model.Categorie;
import org.openconcerto.ui.touch.ScrollableList;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
25,6 → 24,7
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;
39,6 → 39,7
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
45,7 → 46,7
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
 
public class ArticleSearchPanel extends JPanel implements CaisseListener {
public class ArticleSearchPanel extends JPanel implements ListSelectionListener, CaisseListener {
private final ScrollableList list;
private final CaisseControler controler;
private final JTextField textField = new JTextField();
56,23 → 57,14
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints();
final FilteredListModel model = new FilteredListModel();
final Font f1;
final Font f2;
 
if (this.controler.getPOSConf().getScreenWidth() < 1280) {
f1 = new Font("Arial", Font.PLAIN, 21);
f2 = new Font("Arial", Font.PLAIN, 14);
} else {
f1 = new Font("Arial", Font.PLAIN, 24);
f2 = new Font("Arial", Font.PLAIN, 16);
}
 
setBackground(new Color(230, 230, 230));
this.list = new ScrollableList(model) {
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.LIGHT_GRAY);
g.setColor(CaissePanel.LIGHT_BLUE);
g.drawLine(0, 0, 0, this.getHeight());
}
 
96,12 → 88,12
public void mouseReleased(MouseEvent event) {
if ((event.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
final Object obj = getSelectedValue();
if (obj instanceof Article) {
if (obj != null && obj instanceof Article) {
Article product = (Article) obj;
Categorie.toggleFavoriteState(product);
controler.saveFavoriteProductsIds(Categorie.getFavoriteProducts());
model.setFilter(ArticleSearchPanel.this.textField.getText());
ArticleSearchPanel.this.list.scrollToOffset(0);
model.setFilter(textField.getText());
list.scrollToOffset(0);
}
} else {
super.mouseReleased(event);
132,7 → 124,7
bar.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
ArticleSearchPanel.this.list.scrollToOffset(0);
list.scrollToOffset(0);
}
});
 
143,34 → 135,29
// List
c.weighty = 1;
c.gridy++;
this.list.setBackground(new Color(240, 240, 240));
this.add(this.list, c);
 
this.add(list, c);
// Separator
c.weighty = 0;
c.gridy++;
this.add(new JSeparator(JSeparator.HORIZONTAL), c);
 
JPanel pBottom = new JPanel();
pBottom.setOpaque(true);
pBottom.setBackground(CaissePanel.DARK_BLUE);
pBottom.setLayout(new BorderLayout(3, 3));
 
// Icon and text
 
c.weighty = 0;
c.gridy++;
c.insets = new Insets(3, 3, 3, 3);
final JLabel label = new JLabel(new ImageIcon(this.getClass().getResource("search.png")));
c.gridwidth = 1;
c.weightx = 0;
this.add(label, c);
 
pBottom.add(label, BorderLayout.WEST);
pBottom.setBorder(BorderFactory.createLineBorder(CaissePanel.DARK_BLUE, 3));
this.textField.setBorder(BorderFactory.createLineBorder(CaissePanel.DARK_BLUE, 1));
this.textField.setFont(f1);
 
this.textField.setFont(f1);
pBottom.add(this.textField, BorderLayout.CENTER);
c.gridy++;
textField.setBorder(BorderFactory.createLineBorder(CaissePanel.DARK_BLUE, 1));
textField.setFont(f1);
c.weightx = 1;
c.gridwidth = 2;
this.add(pBottom, c);
c.gridx++;
 
this.textField.getDocument().addDocumentListener(new DocumentListener() {
textField.setFont(f1);
this.add(textField, c);
textField.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
184,50 → 171,40
 
@Override
public void changedUpdate(DocumentEvent e) {
model.setFilter(ArticleSearchPanel.this.textField.getText());
model.setFilter(textField.getText());
controler.setArticleSelected(null);
}
});
this.list.addListSelectionListener(new ListSelectionListener() {
list.addListSelectionListener(this);
 
list.addMouseListener(new MouseAdapter() {
@Override
public void valueChanged(ListSelectionEvent e) {
Object sel = ArticleSearchPanel.this.list.getSelectedValue();
if (sel != null && !e.getValueIsAdjusting()) {
if (sel instanceof Article) {
public void mouseClicked(MouseEvent e) {
int nb = e.getClickCount();
if (nb > 1) {
Object sel = list.getSelectedValue();
if (sel != null) {
Article article = (Article) sel;
controler.incrementArticle(article);
controler.setArticleSelected(article);
 
}
}
 
}
});
}
 
this.list.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Object sel = ArticleSearchPanel.this.list.getSelectedValue();
if (sel != null) {
int nb = e.getClickCount();
if (nb == 1) {
public void valueChanged(ListSelectionEvent e) {
Object sel = list.getSelectedValue();
if (sel != null && !e.getValueIsAdjusting()) {
if (sel instanceof Article) {
Article article = (Article) sel;
controler.setArticleSelected(article);
controler.addArticle(article);
}
} else if (nb > 1) {
Article article = (Article) sel;
controler.incrementArticle(article);
controler.setArticleSelected(article);
}
}
 
}
});
 
}
 
public void paintCategorie(final Font f, Font f2, Graphics g, Categorie c, boolean isSelected, int posY, int cellWidth, int cellHeight) {
g.setFont(f);
 
271,7 → 248,7
if (c.getParent() == null) {
return null;
}
String storedString = this.categoryCache.get(c);
String storedString = categoryCache.get(c);
if (storedString != null) {
return storedString;
}
296,28 → 273,28
parent = c.getParent();
 
}
this.categoryCache.put(c, s);
categoryCache.put(c, s);
return s;
}
 
@Override
public void caisseStateChanged() {
final Article articleSelected = this.controler.getArticleSelected();
final Article articleSelected = controler.getArticleSelected();
System.err.println("ArticleSearchPanel.caisseStateChanged() article selected : " + articleSelected);
if (articleSelected == null) {
this.list.clearSelection();
list.clearSelection();
return;
}
Object selectedValue = null;
try {
selectedValue = this.list.getSelectedValue();
selectedValue = list.getSelectedValue();
} catch (Exception e) {
e.printStackTrace();
}
if (selectedValue == null || !articleSelected.equals(selectedValue)) {
boolean found = this.list.setSelectedValue(articleSelected, true);
boolean found = list.setSelectedValue(articleSelected, true);
if (!found) {
this.list.clearSelection();
list.clearSelection();
}
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/CaisseControler.java
27,10 → 27,10
import org.openconcerto.erp.core.sales.pos.model.RegisterLogEntry.ReceiptEntry;
import org.openconcerto.erp.core.sales.pos.model.RegisterState.Status;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.erp.core.sales.pos.model.TicketItem;
import org.openconcerto.erp.preferences.TemplateNXProps;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.Pair;
import org.openconcerto.utils.StringUtils;
 
import java.awt.event.KeyEvent;
59,7 → 59,7
private Paiement paiementSelected;
private Ticket t;
private Client client = Client.NONE;
private List<CaisseListener> listeners = new ArrayList<>();
private List<CaisseListener> listeners = new ArrayList<CaisseListener>();
 
private final BarcodeReader r;
private Paiement p1 = new Paiement(Paiement.ESPECES);
67,7 → 67,6
private Paiement p3 = new Paiement(Paiement.CHEQUE);
private final CaisseFrame caisseFrame;
private final POSDisplay lcd;
private TicketItem ticketItemSelected;
 
public CaisseControler(CaisseFrame caisseFrame) throws ParseException, JDOMException, IOException {
this.caisseFrame = caisseFrame;
96,9 → 95,9
this.r.start();
this.r.addBarcodeListener(this);
if (posConf.getLCDType().equals("serial")) {
this.lcd = new ESCSerialDisplay(posConf.getLCDPort());
lcd = new ESCSerialDisplay(posConf.getLCDPort());
} else {
this.lcd = new PrinterPOSDisplay(posConf.getLCDPort());
lcd = new PrinterPOSDisplay(posConf.getLCDPort());
}
this.setLCDDefaultDisplay(0);
}
120,7 → 119,7
}
 
void setArticleSelected(Article a) {
if (a != this.articleSelected) {
if (a != articleSelected) {
this.articleSelected = a;
this.paiementSelected = null;
fire();
130,7 → 129,6
void setPaiementSelected(Paiement p) {
this.paiementSelected = p;
this.articleSelected = null;
this.ticketItemSelected = null;
fire();
}
 
161,13 → 159,9
}
 
public Client getClient() {
return this.client;
return client;
}
 
public void setCodePostal(String codePostal) {
this.t.setCodePostal(codePostal);
}
 
// Articles
public void addArticle(Article a) {
this.t.addArticle(a);
231,20 → 225,20
 
//
 
public List<TicketItem> getItems() {
return this.t.getItems();
public List<Pair<Article, Integer>> getItems() {
return this.t.getArticles();
}
 
public BigDecimal getItemCount(Article article) {
public int getItemCount(Article article) {
return this.t.getItemCount(article);
}
 
public void clearArticle(Article article) {
this.t.clearArticle(article);
this.setTicketItemSelected(null);
this.setArticleSelected(null);
}
 
public void setArticleCount(Article article, BigDecimal count) {
public void setArticleCount(Article article, int count) {
this.t.setArticleCount(article, count);
this.setArticleSelected(null);
}
264,10 → 258,15
} else if (code.equalsIgnoreCase("annuler")) {
if (this.articleSelected != null) {
this.clearArticle(this.articleSelected);
} else if (this.paiementSelected != null) {
 
} else {
if (this.paiementSelected != null) {
this.paiementSelected.setMontantInCents(0);
// setPaiementSelected(null);
fire();
}
 
}
} else if (code.equalsIgnoreCase("valider")) {
 
} else if (code.equalsIgnoreCase("facture")) {
285,7 → 284,7
Ticket t = Ticket.getTicketFromCode(code, this.caisseFrame.getFiles());
if (t != null) {
System.err.println("CaisseControler.barcodeRead() barcode : " + code + " : receipt found :" + t.getNumber());
this.caisseFrame.showTickets(t);
caisseFrame.showTickets(t);
}
}
}
326,7 → 325,7
 
@Override
public void keyReceived(KeyEvent ee) {
// nothing
 
}
 
public static String getCents(int cents) {
338,7 → 337,9
}
 
public static String getEuros(int cents) {
return String.valueOf(cents / 100);
String s = String.valueOf(cents / 100);
 
return s;
}
 
public Ticket saveAndClearTicket(final RegisterFiles files, final SQLElementDirectory dir) throws IOException, SQLException {
348,16 → 349,16
final String fileHash = this.t.save(files, dir);
final Ticket res = this.t;
final int newIndex = this.t.getNumber() + 1;
this.t = new Ticket(getPOSConf().getPosID(), newIndex, fileHash);
this.p1 = new Paiement(Paiement.ESPECES);
this.p2 = new Paiement(Paiement.CB);
this.p3 = new Paiement(Paiement.CHEQUE);
t = new Ticket(getPOSConf().getPosID(), newIndex, fileHash);
p1 = new Paiement(Paiement.ESPECES);
p2 = new Paiement(Paiement.CB);
p3 = new Paiement(Paiement.CHEQUE);
this.t.addPaiement(this.p1);
this.t.addPaiement(this.p2);
this.t.addPaiement(this.p3);
this.setPaiementSelected(null);
this.setArticleSelected(null);
this.client = Client.NONE;
client = Client.NONE;
return res;
}
 
376,7 → 377,7
}
 
public void switchListMode() {
this.caisseFrame.mainPanel.switchListMode();
caisseFrame.mainPanel.switchListMode();
 
}
 
385,7 → 386,7
@Override
public void run() {
try {
CaisseControler.this.lcd.setMessage(line1, line2);
lcd.setMessage(line1, line2);
} catch (Exception e) {
e.printStackTrace();
}
392,22 → 393,17
}
};
final Timer timer = new Timer("LCD : " + line1, true);
timer.schedule(task, delay * 1000L);
timer.schedule(task, delay * 1000);
 
}
 
public void setLCDDefaultDisplay(int delay) {
if (this.t.getTotalInCents() > 0) {
if (t.getTotalInCents() > 0) {
int count = 0;
final List<TicketItem> articles = this.t.getItems();
for (TicketItem pair : articles) {
Article a = pair.getArticle();
if (a.getSalesUnit() == null) {
count += pair.getQty().intValue();
} else {
count++;
final List<Pair<Article, Integer>> articles = t.getArticles();
for (Pair<Article, Integer> pair : articles) {
count += pair.getSecond();
}
}
String line1;
if (count == 1) {
line1 = "1 article";
414,7 → 410,7
} else {
line1 = count + " articles";
}
int cents = this.t.getTotalInCents();
int cents = t.getTotalInCents();
setLCD(line1, "Total : " + TicketCellRenderer.centsToString(cents), delay);
} else {
setLCD(getPOSConf().getLCDLine1(), getPOSConf().getLCDLine2(), delay);
425,7 → 421,7
 
final String creditCardPort = getPOSConf().getCreditCardPort();
if (creditCardPort != null && creditCardPort.trim().length() > 2) {
final Thread thread = new Thread(new Runnable() {
final Thread t = new Thread(new Runnable() {
 
@Override
public void run() {
442,22 → 438,33
}
}
});
thread.setDaemon(true);
thread.start();
t.setDaemon(true);
t.start();
 
}
 
}
 
public void setArticleHT(TicketItem item, BigDecimal ht) {
final Article newArticle = new Article(item.getArticle());
newArticle.updatePriceWithoutTax(ht);
item.setArticle(newArticle);
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(TicketItem item) {
this.caisseFrame.showPriceEditor(item, this);
public void openPriceEditor(Article article) {
caisseFrame.showPriceEditor(article, this);
}
 
public void enableBarcodeReader() {
469,7 → 476,7
}
 
public boolean isTicketValid() {
return (!this.t.getItems().isEmpty()) && ((this.getTotal() >= 0 && this.getPaidTotal() >= this.getTotal()) || (this.getTotal() < 0 && this.getPaidTotal() == this.getTotal()));
return (!this.t.getArticles().isEmpty()) && ((this.getTotal() >= 0 && this.getPaidTotal() >= this.getTotal()) || (this.getTotal() < 0 && this.getPaidTotal() == this.getTotal()));
}
 
public Set<Integer> loadFavoriteProductsIds() {
508,43 → 515,4
}
}
 
public void setTicketItemSelected(TicketItem item) {
this.ticketItemSelected = item;
if (item == null) {
this.articleSelected = null;
} else {
this.articleSelected = item.getArticle();
this.paiementSelected = null;
}
fire();
 
}
 
public TicketItem getTicketItemSelected() {
return this.ticketItemSelected;
}
 
public void removeTicketItem(TicketItem item) {
this.t.removeTicketItem(item);
this.setTicketItemSelected(null);
}
 
public void cancel(Ticket ticket) {
this.t.clear();
// Annulation du ticket
for (TicketItem a : ticket.getItems()) {
final Article article = a.getArticle();
TicketItem item = new TicketItem(article, a.getQty().multiply(new BigDecimal(-1)));
this.t.addItem(item);
}
for (Paiement p : ticket.getPaiements()) {
final Paiement paiement = new Paiement(p.getType());
paiement.setMontantInCents(-1 * p.getMontantInCents());
this.t.addPaiement(paiement);
}
 
this.caisseFrame.showCaisse();
fire();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/RegisterSummary.java
23,7 → 23,6
import org.openconcerto.erp.core.sales.pos.model.RegisterState.Status;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
 
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
57,7 → 56,7
 
public abstract String getLabel();
 
protected abstract List<Ticket> getReceipts() throws ParseException, IOException;
protected abstract List<Ticket> getReceipts() throws ParseException;
 
@Override
public void print(TicketPrinter prt, int ticketWidth) {
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TicketPanel.java
17,8 → 17,8
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.RegisterState;
import org.openconcerto.erp.core.sales.pos.model.RegisterState.Status;
import org.openconcerto.erp.core.sales.pos.model.TicketItem;
import org.openconcerto.ui.touch.ScrollableList;
import org.openconcerto.utils.Pair;
 
import java.awt.Color;
import java.awt.Dimension;
45,27 → 45,27
 
public class TicketPanel extends JPanel implements CaisseListener {
 
private final DateFormat df = new SimpleDateFormat("' le' d MMMM à H:mm");
static private final DateFormat DF = new SimpleDateFormat("' le' EEEE d MMMM à H:mm:ss");
 
private final Image bg;
private final ListModel<TicketItem> dataModel;
private final List<ListDataListener> listeners = new ArrayList<>();
private final JLabel lTotal = new JLabel("", SwingConstants.RIGHT);
private final JLabel lNumero = new JLabel("", SwingConstants.LEFT);
 
private final ListModel dataModel;
private final List<ListDataListener> listeners = new ArrayList<ListDataListener>();
JLabel lTotal = new JLabel("", SwingConstants.RIGHT);
JLabel lNumero = new JLabel("", SwingConstants.LEFT);
private final CaisseControler controler;
 
private final ScrollableList list;
private int xOffset = 0;
 
TicketPanel(final CaisseControler controler) {
this.controler = controler;
this.controler.addCaisseListener(this);
if (this.controler.getPOSConf().getScreenWidth() < 1280) {
this.xOffset = -24;
}
 
this.setOpaque(false);
this.bg = new ImageIcon(TicketPanel.class.getResource("ticket.png")).getImage();
this.setLayout(null);
 
this.dataModel = new ListModel<TicketItem>() {
this.dataModel = new ListModel() {
 
@Override
public void addListDataListener(final ListDataListener l) {
73,7 → 73,7
}
 
@Override
public TicketItem getElementAt(final int index) {
public Object getElementAt(final int index) {
return controler.getItems().get(index);
}
 
95,22 → 95,22
@Override
public void paintCell(final Graphics g, final Object value, final int index, final boolean isSelected, final int posY) {
g.translate(0, posY);
this.renderer.paint(g, TicketPanel.this.list, (TicketItem) value, index, isSelected);
this.renderer.paint(g, TicketPanel.this.list, value, index, isSelected);
g.translate(0, -posY);
}
};
this.list.setOpaque(false);
this.list.setSize(315, 450);
this.list.setSize(276, 450);
this.list.setFixedCellHeight(40);
this.list.setLocation(30 + this.xOffset, 18);
this.list.setLocation(68, 18);
this.add(this.list);
 
this.lTotal.setSize(276 - 10, 32);
this.lTotal.setLocation(68 + this.xOffset, 500 - 32);
this.lTotal.setLocation(68, 500 - 32);
this.lTotal.setFont(new Font("Arial", Font.BOLD, 18));
this.add(this.lTotal);
this.lNumero.setSize(276 - 10, 32);
this.lNumero.setLocation(68 + this.xOffset, 500);
this.lNumero.setLocation(68, 500);
this.lNumero.setForeground(Color.DARK_GRAY);
this.lNumero.setFont(new Font("Arial", Font.BOLD, 12));
this.add(this.lNumero);
122,13 → 122,12
if (!e.getValueIsAdjusting()) {
final Object selectedValue = TicketPanel.this.list.getSelectedValue();
if (selectedValue != null) {
TicketItem item = (TicketItem) selectedValue;
controler.setTicketItemSelected(item);
final Article a = ((Pair<Article, Integer>) selectedValue).getFirst();
controler.setArticleSelected(a);
// If the category of the selected article does not match the current
// category of the categories list,
// then the corresponding article is not selected.
controler.setTicketItemSelected(item); // Dirty fix : use two refresh
 
controler.setArticleSelected(a); // Dirty fix : use two refresh
}
}
 
139,28 → 138,19
 
@Override
protected void paintComponent(final Graphics g) {
g.drawImage(this.bg, this.xOffset, 0, null);
g.drawImage(this.bg, 0, 0, null);
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
try {
final RegisterState registerState = this.controler.getCaisseFrame().getFiles().getLastLog().getRegisterState();
 
// Display caisse and Vendor ID
final String infoCaisseVendeur = "Caisse " + this.controler.getPOSConf().getPosID() + " Vendeur " + this.controler.getPOSConf().getUserID();
final String infoCaisse = (registerState.getStatus() == Status.OPEN ? "Ouverte" : "Fermée") + registerState.formatDate(this.df);
String InfoCaisseVendeur = "Caisse " + this.controler.getPOSConf().getPosID() + " Vendeur " + this.controler.getPOSConf().getUserID();
g.setColor(new Color(230, 230, 230));
if (this.controler.getPOSConf().getScreenWidth() < 1280) {
g.setFont(getFont().deriveFont(16.0f));
} else {
g.setFont(getFont().deriveFont(14.0f));
}
int w1 = g.getFontMetrics().stringWidth(infoCaisseVendeur);
int w2 = g.getFontMetrics().stringWidth(infoCaisse);
g.setFont(getFont().deriveFont(28.0f));
g.drawString(InfoCaisseVendeur, 20, this.getHeight() - 50);
 
int x = 330 - Math.max(w1, w2) + this.xOffset;
g.drawString(infoCaisseVendeur, x, this.getHeight() - 40);
g.setColor(Color.LIGHT_GRAY);
 
g.drawString(infoCaisse, x, this.getHeight() - 25);
g.setFont(getFont().deriveFont(18.0f));
final RegisterState registerState = this.controler.getCaisseFrame().getFiles().getLastLog().getRegisterState();
g.drawString("Caisse " + (registerState.getStatus() == Status.OPEN ? "ouverte" : "fermée") + registerState.formatDate(DF), 20, this.getHeight() - 25);
} catch (Exception e) {
POSConfiguration.getLogger().log(Level.WARNING, "Couldn't find register state", e);
}
167,28 → 157,14
super.paintComponent(g);
}
 
int getMinWidth() {
if (this.controler.getPOSConf().getScreenWidth() < 1280) {
return 330;
}
return 480;
}
 
int getMaxHeight() {
if (this.controler.getPOSConf().getScreenHeight() < 1000) {
return 550;
}
return 707;
}
 
@Override
public Dimension getMinimumSize() {
return new Dimension(getMinWidth(), 550);
return new Dimension(480, 550);
}
 
@Override
public Dimension getPreferredSize() {
return new Dimension(getMinWidth(), getMaxHeight());
return new Dimension(480, 707);
}
 
public void fire() {
213,7 → 189,7
}
try {
// Deja selectionné
if (this.list.getSelectedValue() != null && articleSelected.equals(((TicketItem) this.list.getSelectedValue()).getArticle())) {
if (this.list.getSelectedValue() != null && articleSelected != null && articleSelected.equals(((Pair<Article, Integer>) this.list.getSelectedValue()).getFirst())) {
return;
}
} catch (final Exception e) {
220,14 → 196,16
e.printStackTrace();
}
 
if (articleSelected != null) {
 
for (int i = 0; i < this.dataModel.getSize(); i++) {
final TicketItem item = this.dataModel.getElementAt(i);
if (item.getArticle().equals(articleSelected)) {
final Pair<Article, Integer> item = (Pair<Article, Integer>) this.dataModel.getElementAt(i);
if (item.getFirst().equals(articleSelected)) {
this.list.setSelectedValue(item, true);
break;
}
}
 
}
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/ui/TicketCellRenderer.java
14,8 → 14,8
package org.openconcerto.erp.core.sales.pos.ui;
 
import org.openconcerto.erp.core.sales.pos.model.Article;
import org.openconcerto.erp.core.sales.pos.model.TicketItem;
import org.openconcerto.ui.touch.ScrollableList;
import org.openconcerto.utils.Pair;
 
import java.awt.Color;
import java.awt.Component;
35,11 → 35,12
import javax.swing.ListCellRenderer;
import javax.swing.SwingConstants;
 
public class TicketCellRenderer implements ListCellRenderer<TicketItem> {
public class TicketCellRenderer implements ListCellRenderer {
 
@Override
public Component getListCellRendererComponent(JList<? extends TicketItem> list, TicketItem item, int index, boolean isSelected, boolean cellHasFocus) {
 
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());
GridBagConstraints c = new GridBagConstraints();
47,12 → 48,12
 
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 5, 5, 5);
final JLabel l1 = new JLabel(item.getArticle().toString(), SwingConstants.RIGHT);
final JLabel l1 = new JLabel(item.getSecond().toString(), SwingConstants.RIGHT);
 
p.add(l1, c);
c.gridx++;
c.weightx = 1;
Article article = item.getArticle();
Article article = item.getFirst();
final JLabel l2 = new JLabel(article.getName().toUpperCase(), SwingConstants.LEFT);
p.add(l2, c);
c.gridx++;
81,7 → 82,9
return p;
}
 
public void paint(Graphics g, ScrollableList list, TicketItem item, int index, boolean isSelected) {
public void paint(Graphics g, ScrollableList list, Object value, int index, boolean isSelected) {
@SuppressWarnings("unchecked")
final Pair<Article, Integer> item = (Pair<Article, Integer>) value;
 
if (isSelected) {
g.setColor(new Color(232, 242, 254));
94,34 → 97,20
g.setFont(new Font("Arial", Font.PLAIN, 16));
final int height = g.getFontMetrics().getMaxAscent() + g.getFontMetrics().getMaxDescent() + inset;
 
System.err.println("TicketCellRenderer.paint()" + item);
 
Article article = item.getArticle();
final BigDecimal qty = item.getQty();
String s1 = qty.toString();
if (article.getSalesUnit() != null) {
s1 = qty.toString() + article.getSalesUnit();
}
final String s1 = item.getSecond().toString();
g.drawString(s1, inset, height);
final int width1 = (int) g.getFontMetrics().getStringBounds("1999kg ", g).getWidth() + inset * 2;
final int width1 = (int) g.getFontMetrics().getStringBounds("999 ", g).getWidth() + inset * 2;
 
String s2 = article.getName().toUpperCase().trim();
 
final int maxLength = 15;
Article article = item.getFirst();
String s2 = article.getName().toUpperCase();
final int maxLength = 13;
if (s2.length() > maxLength)
s2 = s2.substring(0, maxLength + 1) + '…';
g.drawString(s2, width1 + inset, height);
 
final String s3 = centsToString(article.getPriceWithTax().multiply(qty).movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()) + "€";
final int width3 = (int) g.getFontMetrics().getStringBounds(s3, g).getWidth() + +inset;
g.drawString(s3, list.getWidth() - width3, height - 4);
 
g.setFont(g.getFont().deriveFont(12f));
final String s4 = qty.toPlainString() + " x " + centsToString(article.getPriceWithTax().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue());
 
final int width4 = (int) g.getFontMetrics().getStringBounds(s4, g).getWidth() + +inset;
g.drawString(s4, list.getWidth() - width4, height + 11);
 
final String s3 = centsToString(article.getPriceWithTax().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue());
final int width3 = (int) g.getFontMetrics().getStringBounds(s3, g).getWidth() + inset * 2;
g.drawString(s3, list.getWidth() - width3, height);
}
 
public static String centsToString(int cents) {
136,5 → 125,4
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/model/TicketItem.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/Article.java
31,8 → 31,6
private String barCode = "empty barcode";
private String code = "";
private final int id;
// unité de vente (null si à la pièce)
private String salesUnit;
private static Map<String, Article> codes = new HashMap<String, Article>();
 
public Article(Categorie s1, String string, int id) {
50,12 → 48,11
this.priceHT = a.priceHT;
this.barCode = a.barCode;
this.id = a.id;
this.salesUnit = a.salesUnit;
this.s.addArticle(this);
}
 
public boolean isAdditionalCopyRequested() {
return this.additionalCopyRequested;
return additionalCopyRequested;
}
 
public void setAdditionalCopyRequested(boolean additionalCopyRequested) {
117,7 → 114,7
 
@Override
public String toString() {
return "Article:" + this.name + " " + this.priceTTC + " cents" + "(HT:" + this.priceHT + ") " + getSalesUnit();
return "Article:" + this.name + " " + this.priceTTC + " cents" + "(HT:" + priceHT + ")";
}
 
public static Article getArticleFromBarcode(String code) {
142,20 → 139,12
}
 
public static BigDecimal computePriceWithTax(BigDecimal ht, int idTaxe) {
final BigDecimal tax = BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(idTaxe)).movePointLeft(2).add(BigDecimal.ONE);
final BigDecimal tax = new BigDecimal(TaxeCache.getCache().getTauxFromId(idTaxe)).movePointLeft(2).add(BigDecimal.ONE);
return ht.multiply(tax).setScale(2, RoundingMode.HALF_UP);
}
 
public static BigDecimal computePriceWithoutTax(BigDecimal ttc, int idTaxe) {
final BigDecimal tax = BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(idTaxe)).movePointLeft(2).add(BigDecimal.ONE);
final BigDecimal tax = new BigDecimal(TaxeCache.getCache().getTauxFromId(idTaxe)).movePointLeft(2).add(BigDecimal.ONE);
return ttc.divide(tax, DecimalUtils.HIGH_PRECISION).setScale(6, RoundingMode.HALF_UP);
}
 
public void setSalesUnit(String name) {
this.salesUnit = name;
}
 
public String getSalesUnit() {
return this.salesUnit;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/Ticket.java
24,7 → 24,6
import org.openconcerto.erp.core.sales.pos.io.Printable;
import org.openconcerto.erp.core.sales.pos.io.TicketPrinter;
import org.openconcerto.erp.core.sales.pos.model.RegisterFiles.HashMode;
import org.openconcerto.erp.core.sales.pos.ui.CaissePanel;
import org.openconcerto.erp.core.sales.pos.ui.TicketCellRenderer;
import org.openconcerto.erp.generationEcritures.GenerationEcritures;
import org.openconcerto.erp.generationEcritures.GenerationMvtVirement;
31,8 → 30,6
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLBackgroundTableCacheItem;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
39,6 → 36,7
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.Pair;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.XMLDateFormat;
 
68,14 → 66,14
private static final XMLDateFormat DATE_FMT = new XMLDateFormat();
 
// Propre a ticket
private final List<Paiement> paiements = new ArrayList<>();
private final List<TicketItem> items = new ArrayList<>();
private final List<Paiement> paiements = new ArrayList<Paiement>();
private final List<Pair<Article, Integer>> items = new ArrayList<Pair<Article, Integer>>();
private Calendar creationCal;
private Client client = Client.NONE;
private final int number;
private final String previousHash;
private boolean additionnalCopyRequested = false;
private String codePostal = "";
 
// Propre à la caisse
private final int caisseNumber;
 
96,15 → 94,6
}
}
 
public String getCodePostal() {
return this.codePostal;
}
 
public void setCodePostal(String codePostal) {
this.codePostal = codePostal;
 
}
 
public void setClient(final Client client) {
this.client = client;
}
113,11 → 102,15
return this.client;
}
 
public static Ticket parseFile(final File file) throws IOException {
public static Ticket parseFile(final File file) {
return parseFile(file, HashMode.REQUIRED);
}
 
public static Ticket parseFile(final File file, final HashMode hashMode) throws IOException {
public static Ticket parseFile(final File file, final HashMode hashMode) {
if (!file.exists()) {
return null;
}
 
try {
// XML Reading
 
138,12 → 131,10
final Ticket t = new Ticket(receiptCode, c, root.getAttributeValue("previousHash"));
t.setClient(new Client(Integer.parseInt(client), "", BigDecimal.ZERO));
 
t.setCodePostal(root.getAttributeValue("codePostal", ""));
 
// article
final List<Element> children = root.getChildren("article");
for (final Element element : children) {
final BigDecimal qte = new BigDecimal(element.getAttributeValue("qte"));
final int qte = Integer.parseInt(element.getAttributeValue("qte"));
final BigDecimal prix_unitaire_cents_ht = new BigDecimal(element.getAttributeValue("prixHT"));
final int idTaxe = Integer.parseInt(element.getAttributeValue("idTaxe"));
final BigDecimal prix_unitaire_cents = new BigDecimal(element.getAttributeValue("prix"));
151,7 → 142,6
final String name = element.getValue();
final String codebarre = element.getAttributeValue("codebarre");
final String codeArt = element.getAttributeValue("code");
final String salesUnit = element.getAttributeValue("unit");
final Categorie cat = new Categorie(categorie);
 
final String valueID = element.getAttributeValue("id");
163,8 → 153,7
art.setPriceWithoutTax(prix_unitaire_cents_ht);
art.setIdTaxe(idTaxe);
art.setBarCode(codebarre);
art.setSalesUnit(salesUnit);
final TicketItem line = new TicketItem(art, qte);
final Pair<Article, Integer> line = new Pair<Article, Integer>(art, qte);
t.items.add(line);
 
}
192,10 → 181,10
}
 
return t;
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException("Couldn't parse " + file, e);
} catch (final Exception e) {
System.err.println("Error with ticket : " + file + " : " + e.getMessage());
e.printStackTrace();
return null;
}
}
 
222,13 → 211,6
return this.previousHash;
}
 
public void clear() {
this.client = Client.NONE;
this.codePostal = "";
this.paiements.clear();
 
}
 
public final ReceiptCode getReceiptCode() {
// TODO replace our fields by one ReceiptCode
return new ReceiptCode(this.getCaisseNumber(), this.getCreationCal(), this.getNumber());
270,24 → 252,19
topLevel.setAttribute("previousHash", this.getPreviousHash());
topLevel.setAttribute("creationDate", DATE_FMT.format(c.getTime()));
topLevel.setAttribute("clientID", String.valueOf(this.client.getId()));
topLevel.setAttribute("codePostal", this.codePostal);
// Articles
for (final TicketItem item : this.items) {
for (final Pair<Article, Integer> item : this.items) {
final Element e = new Element("article");
e.setAttribute("qte", String.valueOf(item.getQty()));
e.setAttribute("qte", String.valueOf(item.getSecond()));
// Prix unitaire
final Article article = item.getArticle();
e.setAttribute("prix", String.valueOf(article.getPriceWithTax()));
e.setAttribute("prixHT", String.valueOf(article.getPriceWithoutTax()));
e.setAttribute("idTaxe", String.valueOf(article.getIdTaxe()));
e.setAttribute("categorie", article.getCategorie().getName());
e.setAttribute("codebarre", article.getBarCode());
e.setAttribute("code", article.getCode());
e.setAttribute("id", String.valueOf(article.getId()));
if (article.getSalesUnit() != null) {
e.setAttribute("unit", article.getSalesUnit());
}
e.setText(article.getName());
e.setAttribute("prix", String.valueOf(item.getFirst().getPriceWithTax()));
e.setAttribute("prixHT", String.valueOf(item.getFirst().getPriceWithoutTax()));
e.setAttribute("idTaxe", String.valueOf(item.getFirst().getIdTaxe()));
e.setAttribute("categorie", item.getFirst().getCategorie().getName());
e.setAttribute("codebarre", item.getFirst().getBarCode());
e.setAttribute("code", item.getFirst().getCode());
e.setAttribute("id", String.valueOf(item.getFirst().getId()));
e.setText(item.getFirst().getName());
topLevel.addContent(e);
}
// Paiements
383,13 → 360,13
final SimpleDateFormat df = new SimpleDateFormat("EEEE d MMMM yyyy à HH:mm", Locale.FRENCH);
prt.addToBuffer(DefaultTicketPrinter.formatCenter(maxWidth, "Le " + df.format(getCreationDate())));
prt.addToBuffer("");
List<TicketItem> itemsToPrint = new ArrayList<>(this.items);
Collections.sort(itemsToPrint, new Comparator<TicketItem>() {
List<Pair<Article, Integer>> itemsToPrint = new ArrayList<>(this.items);
Collections.sort(itemsToPrint, new Comparator<Pair<Article, Integer>>() {
 
@Override
public int compare(TicketItem o1, TicketItem o2) {
final Article p1 = o1.getArticle();
final Article p2 = o2.getArticle();
public int compare(Pair<Article, Integer> o1, Pair<Article, Integer> o2) {
final Article p1 = o1.getFirst();
final Article p2 = o2.getFirst();
final Categorie c1 = p1.getCategorie();
final Categorie c2 = p2.getCategorie();
if (c1.equals(c2)) {
407,9 → 384,8
}
});
Categorie currentCategorie = null;
for (final TicketItem item : this.items) {
final Article article = item.getArticle();
System.err.println("Ticket.print()" + item);
for (final Pair<Article, Integer> item : this.items) {
final Article article = item.getFirst();
if (currentCategorie == null || !currentCategorie.getName().equals(article.getCategorie().getName())) {
// Print category name, except for unknown
currentCategorie = article.getCategorie();
417,29 → 393,20
prt.addToBuffer(currentCategorie.getName(), TicketPrinter.BOLD);
}
}
final BigDecimal nb = item.getQty();
final Integer nb = item.getSecond();
final Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
final BigDecimal tauxTVA = BigDecimal.valueOf(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
final BigDecimal tauxTVA = new BigDecimal(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
final BigDecimal unitPrice = article.getPriceWithoutTax().multiply(tauxTVA, DecimalUtils.HIGH_PRECISION);
final BigDecimal multiply = article.getPriceWithoutTax().multiply(nb, DecimalUtils.HIGH_PRECISION).multiply(tauxTVA, DecimalUtils.HIGH_PRECISION);
final BigDecimal multiply = article.getPriceWithoutTax().multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION).multiply(tauxTVA, DecimalUtils.HIGH_PRECISION);
 
String qtyString = DefaultTicketPrinter.formatRight(MAX_QTE_WIDTH, String.valueOf(nb));
final String priceUnformated = TicketCellRenderer.centsToString(multiply.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue());
final String priceString = DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, priceUnformated);
final String qtyString = DefaultTicketPrinter.formatRight(MAX_QTE_WIDTH, String.valueOf(nb));
final String priceString = DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(multiply.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()));
String unitPriceString = "";
if (article.getSalesUnit() == null) {
if (nb.intValue() != 1) {
if (nb != 1) {
unitPriceString = DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(unitPrice.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()));
}
} else {
unitPriceString = DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, "");
if (nb.signum() >= 0) {
qtyString = DefaultTicketPrinter.formatRight(MAX_QTE_WIDTH, "1");
} else {
qtyString = DefaultTicketPrinter.formatRight(MAX_QTE_WIDTH, "-1");
}
}
if (article.getCode() != null && !article.getCode().isEmpty() && !article.getCode().equalsIgnoreCase(article.getName())) {
 
if (article.getCode() != null && !article.getCode().isEmpty()) {
// 2 lines
final String codeString = DefaultTicketPrinter.formatLeft(maxWidth - 2 - MAX_PRICE_WIDTH - MAX_QTE_WIDTH - 1 - unitPriceString.length(), article.getCode());
prt.addToBuffer(qtyString + " " + codeString + " " + unitPriceString + " " + priceString);
450,11 → 417,8
final String nameString = DefaultTicketPrinter.formatLeft(maxWidth - 2 - MAX_PRICE_WIDTH - MAX_QTE_WIDTH - 1 - unitPriceString.length(), article.getName());
prt.addToBuffer(qtyString + " " + nameString + " " + unitPriceString + " " + priceString);
}
if (article.getSalesUnit() != null) {
prt.addToBuffer(
" (" + nb.abs() + " " + article.getSalesUnit() + " x " + TicketCellRenderer.centsToString(unitPrice.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()) + ")");
 
}
}
 
final StringBuilder spacer = new StringBuilder();
for (int i = 0; i <= MAX_QTE_WIDTH; i++) {
496,20 → 460,16
type = "Remboursement ";
}
if (paiement.getType() == Paiement.CB) {
type += "CB";
type = "CB";
} else if (paiement.getType() == Paiement.CHEQUE) {
type += "par chèque";
type = "par chèque";
} else if (paiement.getType() == Paiement.ESPECES) {
type += "en espèces";
type = "en espèces";
} else if (paiement.getType() == Paiement.SOLDE) {
type += "depuis solde";
type = "depuis solde";
}
if (montantInCents > 0) {
type += " de " + TicketCellRenderer.centsToString(montantInCents);
} else {
type += " de " + TicketCellRenderer.centsToString(-montantInCents);
}
if (Math.abs(montantInCents) > 100) {
if (montantInCents > 100) {
type += " euros";
} else {
type += " euro";
521,7 → 481,7
if (getTotalInCents() < getPaidTotal()) {
final int montantInCents = getPaidTotal() - getTotalInCents();
String type = "Rendu : " + TicketCellRenderer.centsToString(montantInCents);
if (Math.abs(montantInCents) > 100) {
if (montantInCents > 100) {
type += " euros";
} else {
type += " euro";
565,25 → 525,23
}
 
public boolean isAdditionnalCopyRequested() {
return this.additionnalCopyRequested;
return additionnalCopyRequested;
}
 
public void addArticle(final Article a) {
System.err.println("Ticket.addArticle()" + a);
boolean alreadyExist = false;
if (a.isAdditionalCopyRequested()) {
this.additionnalCopyRequested = true;
}
if (a.getSalesUnit() == null) {
for (final TicketItem line : this.items) {
if (line.getArticle().equals(a)) {
for (final Pair<Article, Integer> line : this.items) {
if (line.getFirst().equals(a)) {
alreadyExist = true;
break;
}
}
}
 
if (!alreadyExist) {
final TicketItem line = new TicketItem(new Article(a), BigDecimal.ONE);
final Pair<Article, Integer> line = new Pair<Article, Integer>(new Article(a), 1);
this.items.add(line);
}
 
590,29 → 548,21
}
 
public void incrementArticle(final Article a) {
System.err.println("Ticket.incrementArticle()" + a.getName());
 
boolean alreadyExist = false;
if (a.getSalesUnit() == null) {
for (final TicketItem line : this.items) {
if (line.getArticle().equals(a)) {
for (final Pair<Article, Integer> line : this.items) {
if (line.getFirst().equals(a)) {
alreadyExist = true;
line.setQty(line.getQty().add(BigDecimal.ONE));
line.setSecond(line.getSecond() + 1);
break;
}
}
}
if (!alreadyExist) {
final TicketItem line = new TicketItem(a, BigDecimal.ONE);
final Pair<Article, Integer> line = new Pair<Article, Integer>(a, 1);
this.items.add(line);
}
 
}
 
public void addItem(TicketItem item) {
this.items.add(item);
}
 
public List<Paiement> getPaiements() {
return this.paiements;
}
631,19 → 581,14
calc.setServiceActive(bServiceActive != null && bServiceActive);
final int size = this.items.size();
for (int i = 0; i < size; i++) {
final TicketItem line = this.items.get(i);
final BigDecimal count = line.getQty();
final Article art = line.getArticle();
final Pair<Article, Integer> line = this.items.get(i);
final int count = line.getSecond();
final Article art = line.getFirst();
final SQLRowValues rowVals = new SQLRowValues(tableElt);
rowVals.put("T_PV_HT", art.getPriceWithoutTax().multiply(count));
if (art.getSalesUnit() != null) {
rowVals.put("QTE_UNITAIRE", count);
rowVals.put("QTE", BigDecimal.ONE);
} else {
rowVals.put("QTE", count.intValue());
}
rowVals.put("T_PV_HT", art.getPriceWithoutTax().multiply(new BigDecimal(count)));
rowVals.put("QTE", count);
rowVals.put("ID_TAXE", art.getIdTaxe());
calc.addLine(rowVals, CaissePanel.getArticleRowValuesFromCache(art.getId()), i, false);
calc.addLine(rowVals, tableArticle.getRow(art.getId()), i, false);
 
}
calc.checkResult();
650,14 → 595,14
return calc;
}
 
public List<TicketItem> getItems() {
public List<Pair<Article, Integer>> getArticles() {
return this.items;
}
 
public void clearArticle(final Article article) {
TicketItem toRemove = null;
for (final TicketItem line : this.items) {
if (line.getArticle().equals(article)) {
Pair<Article, Integer> toRemove = null;
for (final Pair<Article, Integer> line : this.items) {
if (line.getFirst().equals(article)) {
toRemove = line;
break;
}
667,46 → 612,32
}
}
 
public void removeTicketItem(TicketItem item) {
TicketItem toRemove = null;
for (final TicketItem line : this.items) {
if (line.equals(item)) {
toRemove = line;
break;
}
}
if (toRemove != null) {
this.items.remove(toRemove);
}
 
}
 
public void setArticleCount(final Article article, final BigDecimal count) {
public void setArticleCount(final Article article, final int count) {
// TODO Allow only if annulation?
// if (count <= 0) {
// this.clearArticle(article);
// return;
// }
TicketItem toModify = null;
for (final TicketItem line : this.items) {
if (line.getArticle().equals(article)) {
Pair<Article, Integer> toModify = null;
for (final Pair<Article, Integer> line : this.items) {
if (line.getFirst().equals(article)) {
toModify = line;
break;
}
}
if (toModify != null) {
toModify.setQty(count);
toModify.setSecond(count);
}
 
}
 
public BigDecimal getItemCount(final Article article) {
for (final TicketItem line : this.items) {
if (line.getArticle().equals(article)) {
return line.getQty();
public int getItemCount(final Article article) {
for (final Pair<Article, Integer> line : this.items) {
if (line.getFirst().equals(article)) {
return line.getSecond();
}
}
return BigDecimal.ZERO;
return 0;
}
 
public int getPaidTotal() {
718,14 → 649,14
}
 
public void removeArticle(final Article a) {
TicketItem lineToDelete = null;
for (final TicketItem line : this.items) {
if (line.getArticle().equals(a)) {
final BigDecimal count = line.getQty().add(BigDecimal.ONE);
if (count.signum() <= 0) {
Pair<Article, Integer> lineToDelete = null;
for (final Pair<Article, Integer> line : this.items) {
if (line.getFirst().equals(a)) {
final int count = line.getSecond() + 1;
if (count <= 0) {
lineToDelete = line;
}
line.setQty(count);
line.setSecond(count);
break;
}
}
820,5 → 751,4
 
getReceiptCode().markDeleted();
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/ReceiptCode.java
229,6 → 229,10
return this.dayIndex;
}
 
public final String getCodePrefix() {
return this.code.substring(0, this.code.length() - INDEX_FORMAT.getMinimumIntegerDigits());
}
 
public final String getCode() {
return this.code;
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/RegisterLog.java
163,9 → 163,8
*
* @return the list of current receipts in this.
* @throws ParseException if an entry couldn't be parsed.
* @throws IOException if the receipts couldn't be parsed.
*/
public final List<Ticket> parseReceipts() throws ParseException, IOException {
public final List<Ticket> parseReceipts() throws ParseException {
final List<Ticket> receipts = new ArrayList<>();
final Path toUse = this.getLogFile().getParent();
final List<ReceiptEntry> receiptEvents = this.getReceiptEvents();
173,13 → 172,7
int index = 1;
for (final ReceiptEntry receiptEntry : receiptEvents) {
final Path receiptFile = toUse.resolve(receiptEntry.getCode().getFileName());
final Ticket receipt;
try {
receipt = Ticket.parseFile(receiptFile.toFile(), HashMode.equalTo(receiptEntry.getFileHash()));
} catch (Exception e) {
throw new IOException("Couldn't parse file of " + receiptEntry + " : " + receiptFile, e);
}
assert receipt != null;
final Ticket receipt = Ticket.parseFile(receiptFile.toFile(), HashMode.equalTo(receiptEntry.getFileHash()));
if (!receipt.getCode().equals(receiptEntry.getCodeString()))
throw new IllegalStateException("Code mismatch");
if (!CompareUtils.equals(lastHash, receipt.getPreviousHash()))
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/RegisterFiles.java
78,10 → 78,6
public static final String STRUCT_VERSION_2013 = "v20131206";
public static final String STRUCT_VERSION = "v20171220";
 
private static final String PREVIOUS_SUBDIR = "previous";
private static final String CURRENT_SUBDIR = "current";
private static final String STAGING_SUBDIR = "staging";
 
private static final String LOG_FILENAME = "log.xml";
static final String HASH_SUFFIX = ".hash";
private static final String LOG_HASH_FILENAME = LOG_FILENAME + HASH_SUFFIX;
337,7 → 333,7
}
 
private final Path getDayDirToUse(final Path dayDir) throws IOException {
for (final Path subdir : new Path[] { dayDir.resolve(CURRENT_SUBDIR), dayDir.resolve(PREVIOUS_SUBDIR) }) {
for (final Path subdir : new Path[] { dayDir.resolve("current"), dayDir.resolve("previous") }) {
if (Files.exists(subdir)) {
final ValidState validity = getDayDirValidity(subdir);
if (validity.isValid())
417,9 → 413,9
if (dayDirToUse != null)
throw new IllegalStateException(cal.getTime() + " already open");
 
final Path stagingDir = dayDir.resolve(STAGING_SUBDIR);
final Path currentDir = stagingDir.resolveSibling(CURRENT_SUBDIR);
final Path prevDir = stagingDir.resolveSibling(PREVIOUS_SUBDIR);
final Path stagingDir = dayDir.resolve("staging");
final Path currentDir = stagingDir.resolveSibling("current");
final Path prevDir = stagingDir.resolveSibling("previous");
FileUtils.rm_R(stagingDir);
FileUtils.rm_R(currentDir);
FileUtils.rm_R(prevDir);
429,20 → 425,7
rootElem.addContent(new RegisterLogEntry.RegisterEntry(EventType.REGISTER_OPENING, cal.getTime(), userID, input.getPosID(), lastLocalHash, prevDate).toXML());
save(new Document(rootElem), stagingDir.resolve(LOG_FILENAME));
 
for (int i = 0; i < 5; i++) {
try {
Files.move(stagingDir, currentDir, StandardCopyOption.ATOMIC_MOVE);
break;
} catch (Exception e) {
e.printStackTrace();
try {
// Retry 5 times, because can fail under Windows
Thread.sleep(1000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
 
POSConfiguration.getLogger().log(Level.INFO, "Finished opening of FS state for register {0}", registerDB);
 
471,9 → 454,9
 
// e.g. 2017/12/21/current/
final Path toUse = lastLog.getLogFile().getParent();
final Path stagingDir = toUse.resolveSibling(STAGING_SUBDIR);
final Path currentDir = stagingDir.resolveSibling(CURRENT_SUBDIR);
final Path prevDir = stagingDir.resolveSibling(PREVIOUS_SUBDIR);
final Path stagingDir = toUse.resolveSibling("staging");
final Path currentDir = stagingDir.resolveSibling("current");
final Path prevDir = stagingDir.resolveSibling("previous");
 
FileUtils.rm_R(stagingDir);
FileUtils.copyDirectory(toUse, stagingDir, input.useHardLinks, StandardCopyOption.COPY_ATTRIBUTES);
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/model/RegisterDB.java
42,7 → 42,6
import org.openconcerto.utils.TimeUtils;
import org.openconcerto.utils.cc.ITransformer;
 
import java.io.IOException;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.ParseException;
219,7 → 218,7
 
// TODO monthly and yearly closures
 
public final DBState close(final POSConfiguration posConf, final RegisterLog log) throws SQLException, ParseException, IOException {
public final DBState close(final POSConfiguration posConf, final RegisterLog log) throws SQLException, ParseException {
final List<ReceiptEntry> receiptEvents = log.getReceiptEvents();
final RegisterEntry closureEntry = log.getLastRegisterEvent();
if (closureEntry.getType() != EventType.REGISTER_CLOSURE)
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/POSConfiguration.java
30,7 → 30,6
import org.openconcerto.erp.core.sales.pos.model.RegisterFiles.HashMode;
import org.openconcerto.erp.core.sales.pos.model.RegisterLogEntry.ReceiptEntry;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.erp.core.sales.pos.model.TicketItem;
import org.openconcerto.erp.core.sales.pos.model.TicketLine;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
42,12 → 41,10
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLDataSource;
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.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
58,6 → 55,7
import org.openconcerto.utils.BaseDirs;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Pair;
import org.openconcerto.utils.i18n.TranslationManager;
 
import java.io.File;
71,11 → 69,9
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Logger;
 
import javax.swing.JOptionPane;
122,8 → 118,6
private String LCDLine1 = "Bienvenue";
private String LCDLine2 = "ILM Informatique";
 
private boolean askPostalCode = false;
 
public static POSConfiguration createInstance() throws JDOMException, IOException {
POSConfiguration res = new POSConfiguration(getConfigFile(new File(".")));
res.loadConfiguration();
261,8 → 255,8
System.exit(2);
}
 
NouvelleConnexionAction.initCache(conf, -1);
TaxeCache.getCache();
NouvelleConnexionAction.initCache(conf);
 
return conf;
}
 
323,23 → 317,14
throw new IllegalArgumentException("Size mismatch");
 
final int defaultIDClient = getClientCaisse().getID();
final SQLElementDirectory directory = Configuration.getInstance().getDirectory();
SQLElement elt = directory.getElement("TICKET_CAISSE");
SQLElement eltFact = directory.getElement("SAISIE_VENTE_FACTURE_ELEMENT");
SQLElement eltEnc = directory.getElement("ENCAISSER_MONTANT");
SQLElement eltMode = directory.getElement("MODE_REGLEMENT");
SQLElement eltArticle = directory.getElement("ARTICLE");
SQLElement elt = Configuration.getInstance().getDirectory().getElement("TICKET_CAISSE");
SQLElement eltFact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
SQLElement eltEnc = Configuration.getInstance().getDirectory().getElement("ENCAISSER_MONTANT");
SQLElement eltMode = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
SQLElement eltArticle = Configuration.getInstance().getDirectory().getElement("ARTICLE");
final SQLDataSource ds = elt.getTable().getDBSystemRoot().getDataSource();
int imported = 0;
 
//
final SQLSelect selUniteVente = new SQLSelect();
selUniteVente.addSelectStar(directory.getElement("UNITE_VENTE").getTable());
final Map<String, Integer> mapUniteVenteName = new HashMap<>();
for (SQLRow row : SQLRowListRSH.execute(selUniteVente)) {
mapUniteVenteName.put(row.getString("CODE"), row.getID());
}
 
final Iterator<ReceiptEntry> entriesIter = entries == null ? null : entries.iterator();
for (Ticket ticket : tickets) {
SQLSelect sel = new SQLSelect();
362,9 → 347,6
rowVals.put("NUMERO", ticket.getCode());
rowVals.put("DATE", ticket.getCreationDate());
rowVals.put("ID_CAISSE", getPosID());
if (elt.getTable().contains("CODE_POSTAL")) {
rowVals.put("CODE_POSTAL", ticket.getCodePostal());
}
if (entry != null) {
rowVals.put("FILE_HASH", entry.getFileHash());
rowVals.put("FILE_HASH_PREVIOUS", ticket.getPreviousHash());
382,24 → 364,17
calc.setServiceActive(bServiceActive != null && bServiceActive);
 
// Articles
for (TicketItem item : ticket.getItems()) {
for (Pair<Article, Integer> item : ticket.getArticles()) {
SQLRowValues rowValsElt = new SQLRowValues(eltFact.getTable());
final Article article = item.getArticle();
final BigDecimal nb = item.getQty();
if (article.getSalesUnit() == null) {
rowValsElt.put("QTE", nb.intValue());
} else {
rowValsElt.put("QTE", 1);
rowValsElt.put("QTE_UNITAIRE", nb);
}
final Article article = item.getFirst();
final Integer nb = item.getSecond();
rowValsElt.put("QTE", nb);
rowValsElt.put("PV_HT", article.getPriceWithoutTax());
Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
BigDecimal tauxTVA = BigDecimal.valueOf(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
BigDecimal tauxTVA = new BigDecimal(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
 
final BigDecimal valueHT = article.getPriceWithoutTax().multiply(nb, DecimalUtils.HIGH_PRECISION);
if (article.getSalesUnit() != null) {
rowValsElt.put("ID_UNITE_VENTE", mapUniteVenteName.get(article.getSalesUnit()));
}
final BigDecimal valueHT = article.getPriceWithoutTax().multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION);
 
rowValsElt.put("T_PV_HT", valueHT);
rowValsElt.put("T_PV_TTC", valueHT.multiply(tauxTVA, DecimalUtils.HIGH_PRECISION));
rowValsElt.put("ID_TAXE", article.getIdTaxe());
474,7 → 449,7
false);
}
if (totalEnc > longValueTotal) {
final SQLTable table = directory.getElement("TYPE_REGLEMENT").getTable();
final SQLTable table = Configuration.getInstance().getDirectory().getElement("TYPE_REGLEMENT").getTable();
int idComptePceCaisse = table.getRow(TypeReglementSQLElement.ESPECE).getInt("ID_COMPTE_PCE_CLIENT");
if (idComptePceCaisse == table.getUndefinedID()) {
idComptePceCaisse = ComptePCESQLElement.getId(ComptePCESQLElement.getComptePceDefault("VenteEspece"));
545,13 → 520,15
stockUpdater.update();
}
 
public List<Ticket> allTickets() throws IOException {
public List<Ticket> allTickets() {
final List<Ticket> l = new ArrayList<Ticket>();
for (final File f : ReceiptCode.getReceiptsToImport(getPosID())) {
// old receipts have no hash files
final Ticket ticket = Ticket.parseFile(f, HashMode.NOT_REQUIRED);
if (ticket != null) {
l.add(ticket);
}
}
return l;
}
 
588,8 → 565,6
setCompanyID(Integer.valueOf(rootElement.getAttributeValue("societeID", "42")));
setPosID(Integer.valueOf(rootElement.getAttributeValue("caisseID", "2")));
setScanDelay(Integer.valueOf(rootElement.getAttributeValue("scanDelay", "80")));
setAskPostalCode(rootElement.getAttributeValue("askPostalCode", "false").equals("true"));
 
// screen
final List<Element> children = rootElement.getChildren("screen");
if (children != null) {
632,7 → 607,7
}
// ticket printers
final List<Element> printers = rootElement.getChildren("ticketPrinter");
if (!printers.isEmpty()) {
if (printers.size() > 0) {
configureTicketPrinter(this.ticketPrinterConf1, printers.get(0));
}
if (printers.size() > 1) {
674,7 → 649,6
configElement.setAttribute("societeID", String.valueOf(this.companyID));
configElement.setAttribute("caisseID", String.valueOf(this.posID));
configElement.setAttribute("scanDelay", String.valueOf(this.scanDelay));
configElement.setAttribute("askPostalCode", this.askPostalCode ? "true" : "false");
doc.addContent(configElement);
// screen size
final Element screenElement = new Element("screen");
825,12 → 799,4
public String getLCDType() {
return this.LCDType;
}
 
public boolean askPostalCode() {
return this.askPostalCode;
}
 
public void setAskPostalCode(boolean askPostalCode) {
this.askPostalCode = askPostalCode;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/pos/element/TicketCaisseSQLElement.java
30,7 → 30,6
static public final String UNARCHIVED_WHERE = SQLBase.quoteIdentifier("ARCHIVE") + " = " + 0;
static public final String DATE_WHERE = UNARCHIVED_WHERE + " and " + SQLBase.quoteIdentifier("FILE_HASH") + " is not null";
 
// needed until H2 databases are upgraded to use JS code
static public final class UniqueNumber_PartialUniqueTrigger extends PartialUniqueTrigger {
public UniqueNumber_PartialUniqueTrigger() {
super(Arrays.asList("NUMERO"), UNARCHIVED_WHERE);
37,7 → 36,6
}
}
 
// needed until H2 databases are upgraded to use JS code
static public final class UniqueDate_PartialUniqueTrigger extends PartialUniqueTrigger {
public UniqueDate_PartialUniqueTrigger() {
super(Arrays.asList("ID_CAISSE", "DATE"), DATE_WHERE);
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ImportFEC.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportSageEtendu.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ImportRImport.java
File deleted
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportFEC.java
42,10 → 42,10
 
public class ExportFEC extends AbstractExport {
 
public static final char ZONE_SEPARATOR = '\t';
public static final char RECORD_SEPARATOR = '\n';
private static final char ZONE_SEPARATOR = '\t';
private static final char RECORD_SEPARATOR = '\n';
private static final char REPLACEMENT = ' ';
public static final List<String> COLS = Arrays.asList("JournalCode", "JournalLib", "EcritureNum", "EcritureDate", "CompteNum", "CompteLib", "CompAuxNum", "CompAuxLib", "PieceRef", "PieceDate",
static private final List<String> COLS = Arrays.asList("JournalCode", "JournalLib", "EcritureNum", "EcritureDate", "CompteNum", "CompteLib", "CompAuxNum", "CompAuxLib", "PieceRef", "PieceDate",
"EcritureLib", "Debit", "Credit", "EcritureLet", "DateLet", "ValidDate", "Montantdevise", "Idevise");
 
private final DecimalFormat format = new DecimalFormat("##0.00", DecimalFormatSymbols.getInstance(Locale.FRANCE));
/trunk/OpenConcerto/src/org/openconcerto/erp/panel/compta/ExportPanel.java
87,12 → 87,6
return new ExportSageXimport(root);
}
},
SAGE_ETENDU("Sage Etendu") {
@Override
public AbstractExport createExport(DBRoot root) {
return new ExportSageEtendu(root);
}
},
CCMX("Cegid CCMX") {
@Override
public AbstractExport createExport(DBRoot root) {
/trunk/OpenConcerto/src/org/openconcerto/erp/model/MouseSheetXmlListeListener.java
14,8 → 14,6
package org.openconcerto.erp.model;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplate;
import org.openconcerto.erp.core.customerrelationship.mail.ValueListener;
import org.openconcerto.erp.generationDoc.AbstractSheetXml;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
29,7 → 27,6
import org.openconcerto.ui.EmailComposer;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.i18n.TranslationManager;
 
import java.awt.event.ActionEvent;
import java.io.File;
115,13 → 112,13
this.showHeader = showHeader;
}
 
protected void sendMail(EmailTemplate template, final AbstractSheetXml sheet, final boolean readOnly) {
protected void sendMail(final AbstractSheetXml sheet, final boolean readOnly) {
List<AbstractSheetXml> l = new ArrayList<>(1);
l.add(sheet);
sendMail(template, l, readOnly);
sendMail(l, readOnly);
}
 
protected void sendMail(EmailTemplate template, final List<AbstractSheetXml> sheets, final boolean readOnly) {
protected void sendMail(final List<AbstractSheetXml> sheets, final boolean readOnly) {
final Thread t = new Thread() {
@Override
public void run() {
234,10 → 231,6
public void run() {
try {
String subject = sheets.get(0).getReference();
if (template != null) {
subject = template.getTitle() + " " + sheets.get(0).getReference().trim();
}
subject = subject.trim();
if (subject.isEmpty()) {
final StringJoiner joiner = new StringJoiner(", ");
for (File f : files) {
245,14 → 238,7
}
subject = joiner.toString();
}
String message = getMailObject(sheets.get(0).getSQLRow());
if (template != null) {
if (template.getText().contains("{message}")) {
message = template.getText().replace("{message}", message);
} else {
message += template.getText();
}
}
final String message = getMailObject(sheets.get(0).getSQLRow());
EmailComposer.getInstance().compose(mailDest, subject, message, files.toArray(new File[files.size()]));
} catch (Exception e) {
ExceptionHandler.handle("Impossible d'envoyer le courriel!", e);
300,27 → 286,11
 
}
} else {
// ODS Viewer
if (this.previewIsVisible) {
l.add(new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent ev) {
try {
final AbstractSheetXml sheet = createAbstractSheet(IListe.get(ev).fetchSelectedRow());
final SQLTable table = IListe.get(ev).getSource().getPrimaryTable();
sheet.showPreviewDocument(TranslationManager.getInstance().getTranslationForAction("email"), new Runnable() {
 
@Override
public void run() {
EmailTemplate.askTemplate(IListe.get(ev), table.getDBRoot(), new ValueListener() {
 
@Override
public void valueSelected(Object value) {
sendMail((EmailTemplate) value, sheet, true);
}
});
 
}
});
createAbstractSheet(IListe.get(ev).fetchSelectedRow()).showPreviewDocument();
} catch (Exception e) {
ExceptionHandler.handle("Impossible d'ouvrir le fichier", e);
}
418,8 → 388,14
public RowAction getSendMail() {
return new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent ev) {
sendMail(ev, false);
final List<SQLRowValues> selectedRows = IListe.get(ev).getSelectedRows();
final SQLTable table = IListe.get(ev).getSource().getPrimaryTable();
final List<SQLRow> rows = new ArrayList<SQLRow>();
for (SQLRowValues r : selectedRows) {
rows.add(table.getRow(r.getID()));
}
sendMail(createAbstractSheets(rows), false);
}
}, false, "document.send.email") {
 
@Override
435,8 → 411,18
public RowAction getSendMailPDF() {
return new RowAction(new AbstractAction() {
public void actionPerformed(ActionEvent ev) {
sendMail(ev, true);
try {
final List<SQLRowValues> selectedRows = IListe.get(ev).getSelectedRows();
final SQLTable table = IListe.get(ev).getSource().getPrimaryTable();
final List<SQLRow> rows = new ArrayList<SQLRow>();
for (SQLRowValues r : selectedRows) {
rows.add(table.getRow(r.getID()));
}
sendMail(createAbstractSheets(rows), true);
} catch (Exception e) {
ExceptionHandler.handle("Impossible d'envoyer le(s) fichier(s)", e);
}
}
}, false, "document.pdf.send.email") {
 
@Override
510,21 → 496,4
}
};
}
 
private void sendMail(ActionEvent ev, boolean pdf) {
final List<SQLRowValues> selectedRows = IListe.get(ev).getSelectedRows();
final SQLTable table = IListe.get(ev).getSource().getPrimaryTable();
final List<SQLRow> rows = new ArrayList<>();
for (SQLRowValues r : selectedRows) {
rows.add(table.getRow(r.getID()));
}
 
EmailTemplate.askTemplate(IListe.get(ev), table.getDBRoot(), new ValueListener() {
 
@Override
public void valueSelected(Object value) {
sendMail((EmailTemplate) value, createAbstractSheets(rows), pdf);
}
});
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/importer/DataImporter.java
13,15 → 13,17
package org.openconcerto.erp.importer;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.openoffice.spreadsheet.Sheet;
import org.openconcerto.openoffice.spreadsheet.SpreadSheet;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesCluster.StoreMode;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.ooxml.XLSXDocument;
import org.openconcerto.utils.ooxml.XLSXSheet;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.utils.text.CSVReader;
import org.openconcerto.utils.text.CSVWriter;
import org.openconcerto.utils.text.CharsetHelper;
49,7 → 51,6
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.formula.eval.NotImplementedException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
58,13 → 59,13
public class DataImporter {
private boolean skipFirstLine = true;
private SQLTable table;
private final Map<Integer, ValueConverter> map = new HashMap<>();
private final Map<SQLField, List<Integer>> fieldMap = new HashMap<>();
private final Map<Integer, Constraint> constraints = new HashMap<>();
private List<SQLField> uniqueField = new ArrayList<>();
private List<SQLRowValues> valuesToUpdate = new ArrayList<>();
private List<SQLRowValues> valuesToInsert = new ArrayList<>();
private Map<ValueConverter, SQLField> foreignMap = new HashMap<>();
private final Map<Integer, ValueConverter> map = new HashMap<Integer, ValueConverter>();
private final Map<SQLField, List<Integer>> fieldMap = new HashMap<SQLField, List<Integer>>();
private final Map<Integer, Constraint> constraints = new HashMap<Integer, Constraint>();
private List<SQLField> uniqueField = new ArrayList<SQLField>();
private List<SQLRowValues> valuesToUpdate = new ArrayList<SQLRowValues>();
private List<SQLRowValues> valuesToInsert = new ArrayList<SQLRowValues>();
private Map<ValueConverter, SQLField> foreignMap = new HashMap<ValueConverter, SQLField>();
 
public DataImporter() {
}
77,6 → 78,43
this.table = table;
}
 
public static void main(String[] args) throws Exception {
System.setProperty(SQLBase.STRUCTURE_USE_XML, "true");
final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create();
Configuration.setInstance(conf);
try {
conf.getBase();
} catch (Exception e) {
e.printStackTrace();
}
 
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
comptaPropsConfiguration.setUpSocieteDataBaseConnexion(39);
UserManager.getInstance().setCurrentUser(2);
 
SQLTable table = Configuration.getInstance().getRoot().findTable("ARTICLE");
DataImporter importer = new DataImporter(table);
importer.skipFirstLine = false;
importer.map(0, table.getField("CODE"));
importer.map(8, table.getField("ID_FOURNISSEUR"));
importer.map(4, table.getField("NOM"));
importer.addContraint(0, new NotEmptyConstraint());
importer.addUniqueField(table.getField("CODE"));
// ArrayTableModel m = importer.createModelFromODS(new File("c:/products-en.ods"));
// ArrayTableModel m = importer.createModelFromCSV(new File("c:/products-en.csv"));
// ArrayTableModel m = importer.createModelFromCSV(new File("c:/products-en.scsv.csv"));
ArrayTableModel m = importer.createModelFromXLS(new File("c:/products-en.xls"), 0);
m.dump(0, 4);
m = importer.createConvertedModel(m);
System.out.println("Dump");
m.dump(0, 4);
importer.importFromModel(m);
System.out.println(importer.getValuesToInsert().size() + " rows to insert");
System.out.println(importer.getValuesToUpdate().size() + " rows to update");
// importer.commit();
 
}
 
public void commit() throws SQLException {
for (SQLRowValues row : this.valuesToInsert) {
row.getGraph().store(StoreMode.INSERT, false);
88,11 → 126,11
}
 
public List<SQLRowValues> getValuesToInsert() {
return this.valuesToInsert;
return valuesToInsert;
}
 
public List<SQLRowValues> getValuesToUpdate() {
return this.valuesToUpdate;
return valuesToUpdate;
}
 
public void addUniqueField(SQLField field) {
104,7 → 142,7
}
 
public void addContraint(int columnIndex, Constraint c) {
this.constraints.put(Integer.valueOf(columnIndex), c);
constraints.put(Integer.valueOf(columnIndex), c);
}
 
public void map(int columnIndex, SQLField field) {
118,17 → 156,17
public void map(int columnIndex, SQLField field, SQLField foreignField) {
final ValueConverter converter = new ValueConverter(foreignField);
map(columnIndex, foreignField, converter);
this.foreignMap.put(converter, field);
foreignMap.put(converter, field);
 
}
 
public void map(int columnIndex, SQLField field, ValueConverter converter) {
final Integer value = Integer.valueOf(columnIndex);
this.map.put(value, converter);
List<Integer> l = this.fieldMap.get(field);
map.put(value, converter);
List<Integer> l = fieldMap.get(field);
if (l == null) {
l = new ArrayList<>();
this.fieldMap.put(field, l);
l = new ArrayList<Integer>();
fieldMap.put(field, l);
} else if (!field.getType().getJavaType().equals(String.class)) {
throw new IllegalArgumentException("Mapping multiple column is only supoprted for String values");
}
157,12 → 195,12
}
}
int start = 0;
if (this.skipFirstLine) {
if (skipFirstLine) {
start = 1;
}
final List<List<Object>> rows = new ArrayList<>(rowCount - start);
final List<List<Object>> rows = new ArrayList<List<Object>>(rowCount - start);
for (int i = start; i < rowCount; i++) {
List<Object> row = new ArrayList<>();
List<Object> row = new ArrayList<Object>();
for (int j = 0; j < columnCount; j++) {
row.add(sheet.getValueAt(j, i));
}
172,45 → 210,16
return new ArrayTableModel(rows);
}
 
public ArrayTableModel createModelFromXLSXGM(File xlsFile, int sheetNumber) throws IOException {
XLSXDocument doc = XLSXDocument.createFromFile(xlsFile);
XLSXSheet sheet = doc.getSheet(sheetNumber);
final int rowCount = sheet.getRowCount();
final int columnCount = sheet.getColumnCount();
 
int start = 0;
if (this.skipFirstLine) {
start = 1;
}
final List<List<Object>> selectedRows = new ArrayList<>(rowCount - start);
for (int i = start; i < rowCount; i++) {
List<Object> row = new ArrayList<>();
for (int j = 0; j < columnCount; j++) {
row.add(sheet.getValueAt(j, i));
}
selectedRows.add(row);
}
 
return new ArrayTableModel(selectedRows);
 
}
 
public ArrayTableModel createModelFromXLS(File xlsFile, int sheetNumber) throws IOException {
final InputStream inputStream = new FileInputStream(xlsFile);
final POIFSFileSystem fileSystem = new POIFSFileSystem(new BufferedInputStream(inputStream));
final HSSFWorkbook workBook = new HSSFWorkbook(fileSystem);
final HSSFSheet sheet = workBook.getSheetAt(sheetNumber);
final List<List<Object>> rows = createFromExcel(workBook.getCreationHelper().createFormulaEvaluator(), sheet.rowIterator(), sheet.rowIterator());
workBook.close();
return new ArrayTableModel(rows);
 
}
 
private List<List<Object>> createFromExcel(FormulaEvaluator evaluator, Iterator<Row> rowsIterator1, Iterator<Row> rowsIterator2) {
Iterator<Row> rowsIterator = sheet.rowIterator();
int columnCount = 0;
int rowCount = 0;
while (rowsIterator1.hasNext()) {
Row row = rowsIterator1.next();
while (rowsIterator.hasNext()) {
Row row = rowsIterator.next();
int i = row.getPhysicalNumberOfCells();
if (i > columnCount) {
columnCount = i;
218,16 → 227,18
rowCount++;
}
// Extract data
rowsIterator = sheet.rowIterator();
int start = 0;
if (this.skipFirstLine) {
if (skipFirstLine) {
start = 1;
rowsIterator2.next();
rowsIterator.next();
}
final List<List<Object>> rows = new ArrayList<>(rowCount - start);
final List<List<Object>> rows = new ArrayList<List<Object>>(rowCount - start);
FormulaEvaluator evaluator = workBook.getCreationHelper().createFormulaEvaluator();
 
while (rowsIterator2.hasNext()) {
final Row row = rowsIterator2.next();
final List<Object> rowData = new ArrayList<>();
while (rowsIterator.hasNext()) {
final Row row = rowsIterator.next();
final List<Object> rowData = new ArrayList<Object>();
for (int i = 0; i < columnCount; i++) {
final Cell cell = row.getCell(i);
 
234,33 → 245,30
if (cell == null) {
rowData.add("");
} else {
CellValue cellValue = null;
try {
cellValue = evaluator.evaluate(cell);
} catch (NotImplementedException exception) {
exception.printStackTrace();
}
CellValue cellValue = evaluator.evaluate(cell);
if (cellValue == null) {
rowData.add("");
} else {
switch (cellValue.getCellTypeEnum()) {
case BOOLEAN:
switch (cellValue.getCellType()) {
case Cell.CELL_TYPE_BOOLEAN:
rowData.add(Boolean.valueOf(cellValue.getBooleanValue()));
break;
case NUMERIC:
case Cell.CELL_TYPE_NUMERIC:
 
if (HSSFDateUtil.isCellDateFormatted(cell)) {
System.out.println("Row No.: " + row.getRowNum() + " " + cell.getDateCellValue());
rowData.add(cell.getDateCellValue());
} else {
rowData.add(Double.valueOf(cellValue.getNumberValue()));
}
break;
case STRING:
case Cell.CELL_TYPE_STRING:
rowData.add(cellValue.getStringValue());
break;
case FORMULA:
case Cell.CELL_TYPE_FORMULA:
rowData.add(cell.getCellFormula());
break;
case BLANK:
case Cell.CELL_TYPE_BLANK:
rowData.add("");
break;
default:
275,7 → 283,9
rows.add(rowData);
 
}
return rows;
inputStream.close();
return new ArrayTableModel(rows);
 
}
 
public ArrayTableModel createModelFromCSV(File csvFile) throws IOException {
309,12 → 319,12
final int columnCount = lines.get(0).length;
 
int start = 0;
if (this.skipFirstLine) {
if (skipFirstLine) {
start = 1;
}
final List<List<Object>> rows = new ArrayList<>(rowCount - start);
final List<List<Object>> rows = new ArrayList<List<Object>>(rowCount - start);
for (int i = start; i < rowCount; i++) {
List<Object> row = new ArrayList<>();
List<Object> row = new ArrayList<Object>();
String[] values = lines.get(i);
for (int j = 0; j < columnCount; j++) {
row.add(values[j]);
337,23 → 347,23
 
public ArrayTableModel createConvertedModel(ArrayTableModel model) {
final int rowCount = model.getRowCount();
final ArrayList<Integer> colsUsed = new ArrayList<>(this.map.keySet());
colsUsed.addAll(this.constraints.keySet());
final ArrayList<Integer> colsUsed = new ArrayList<Integer>(map.keySet());
colsUsed.addAll(constraints.keySet());
 
final int columnCount = 1 + Collections.max(colsUsed);
 
final List<List<Object>> rows = new ArrayList<>(rowCount);
final List<List<Object>> rows = new ArrayList<List<Object>>(rowCount);
 
for (int i = 0; i < rowCount; i++) {
boolean validRow = true;
final List<Object> row = new ArrayList<>();
final List<Object> row = new ArrayList<Object>();
for (int j = 0; j < columnCount; j++) {
Object value = model.getValueAt(i, j);
ValueConverter converter = this.map.get(j);
ValueConverter converter = map.get(j);
if (converter != null) {
value = converter.convertFrom(value);
}
final Constraint constraint = this.constraints.get(j);
final Constraint constraint = constraints.get(j);
// Verification de la validité de la valeur à importer
if (constraint != null && !constraint.isValid(value)) {
validRow = false;
370,19 → 380,19
}
 
protected void customizeRowValuesToFetch(SQLRowValues vals) {
// Nothing
 
}
 
public void importFromModel(ArrayTableModel model) throws IOException {
final int rowCount = model.getRowCount();
// Load existing data for duplication check
final SQLRowValues vals = new SQLRowValues(this.table);
final SQLRowValues vals = new SQLRowValues(table);
 
for (SQLField field : this.fieldMap.keySet()) {
if (field.getTable().equals(this.table)) {
if (field.getTable().equals(table)) {
vals.put(field.getName(), null);
} else {
final Set<SQLField> foreignKeys = this.table.getForeignKeys(field.getTable());
final Set<SQLField> foreignKeys = table.getForeignKeys(field.getTable());
for (SQLField sqlField : foreignKeys) {
vals.put(sqlField.getName(), null);
}
389,15 → 399,17
}
}
customizeRowValuesToFetch(vals);
System.out.println("Fetching values");
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(vals);
List<SQLRowValues> existingRows = fetcher.fetch();
System.out.println("Computing cache");
final int existingRowsCount = existingRows.size();
final ValueConverter[] converters = this.map.values().toArray(new ValueConverter[this.map.size()]);
final ValueConverter[] converters = map.values().toArray(new ValueConverter[map.size()]);
 
// Une map <Object(valeur),SQLRowValues> pour chaque champs unique
Map<SQLField, Map<Object, SQLRowValues>> cache = new HashMap<>();
Map<SQLField, Map<Object, SQLRowValues>> cache = new HashMap<SQLField, Map<Object, SQLRowValues>>();
for (SQLField field : this.uniqueField) {
Map<Object, SQLRowValues> m = new HashMap<>();
Map<Object, SQLRowValues> m = new HashMap<Object, SQLRowValues>();
cache.put(field, m);
final String fieldName = field.getName();
for (int j = 0; j < existingRowsCount; j++) {
412,7 → 424,7
// Recherche d'existant
SQLRowValues existingRow = null;
for (SQLField field : this.uniqueField) {
List<Integer> cols = this.fieldMap.get(field);
List<Integer> cols = fieldMap.get(field);
Object objectToInsert = null;
for (Integer col : cols) {
Object v = model.getValueAt(i, col);
437,7 → 449,7
 
private void updateOrInsert(ArrayTableModel model, final ValueConverter[] converters, int i, SQLRowValues existingRow) {
 
final Map<String, Object> newValues = new HashMap<>();
final Map<String, Object> newValues = new HashMap<String, Object>();
if (existingRow != null) {
// Préremplissage de la map avec la row existante
newValues.putAll(existingRow.getAbsolutelyAll());
445,7 → 457,7
for (int j = 0; j < converters.length; j++) {
ValueConverter valueConverter = converters[j];
 
List<Integer> cols = this.fieldMap.get(valueConverter.getField());
List<Integer> cols = fieldMap.get(valueConverter.getField());
Object objectToInsert = null;
for (Integer col : cols) {
Object v = model.getValueAt(i, col);
459,11 → 471,11
 
final String fieldName = valueConverter.getFieldName();
if (objectToInsert != null || !valueConverter.isIgnoringEmptyValue()) {
if (valueConverter.getField().getTable().equals(this.table)) {
if (valueConverter.getField().getTable().equals(table)) {
newValues.put(fieldName, objectToInsert);
} else {
 
final SQLField sqlField = this.foreignMap.get(valueConverter);
final SQLField sqlField = foreignMap.get(valueConverter);
 
final Object value = newValues.get(sqlField.getName());
if (value == null || value instanceof SQLRowValues) {
478,21 → 490,26
}
}
}
final SQLRowValues rowVals = new SQLRowValues(this.table, newValues);
final SQLRowValues rowVals = new SQLRowValues(table, newValues);
patchRowValues(rowVals, model.getLineValuesAt(i), existingRow);
if (existingRow == null) {
this.valuesToInsert.add(rowVals);
} else {
}
// else if (!newValues.equals(existingRow.getAbsolutelyAll())) {
else {
this.valuesToUpdate.add(rowVals);
// for (SQLRowValues ref : rowVals.getReferentRows()) {
// this.valuesToUpdate.add(ref);
// }
}
}
 
public void doAfterImport() throws SQLException {
// Nothing
 
}
 
protected void patchRowValues(SQLRowValues rowVals, List<Object> lineValues, SQLRowValues existingRow) {
// Nothing
 
}
 
public void setSkipFirstLine(boolean skipFirstLine) {
514,10 → 531,8
return createModelFromCSV(file);
} else if (name.endsWith(".xls")) {
return createModelFromXLS(file, sheetNumber);
} else if (name.endsWith(".xlsx") || name.endsWith(".xlsm")) {
return createModelFromXLSXGM(file, sheetNumber);
}
throw new IllegalArgumentException("File format not supported. Please provide an ods, csv, xls or xlsx file.");
throw new IllegalArgumentException("File format not supported. Please provide an ods, csv or xls file.");
 
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/MailRelancePreferencePanel.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.
*/
/*
* Créé le 6 mars 2012
*/
package org.openconcerto.erp.preferences;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.sales.invoice.report.MailRelanceCreator;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.ui.preferences.JavaPrefPreferencePanel;
import org.openconcerto.ui.preferences.PrefView;
import org.openconcerto.utils.PrefType;
 
public class MailRelancePreferencePanel extends JavaPrefPreferencePanel {
public static String MAIL_RELANCE_DATE_PATTERN = "MailRelanceDatePattern";
public static String MAIL_RELANCE = "MailRelance";
public static String MAIL_RELANCE_OBJET = "MailRelanceObjet";
 
public MailRelancePreferencePanel() {
super("Email de relance client", null);
setPrefs(new SQLPreferences(((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete()));
}
 
@Override
protected void addViews() {
 
PrefView<String> viewExpandDate = new PrefView<String>(PrefType.STRING_TYPE, "Format des dates", MAIL_RELANCE_DATE_PATTERN);
PrefView<String> viewExpandObjet = new PrefView<String>(PrefType.STRING_TYPE, "Objet du mail de relance", MAIL_RELANCE_OBJET);
PrefView<String> viewExpandNom = new PrefView<String>(PrefType.STRING_TYPE, 2048, "Contenu du mail de relance", MAIL_RELANCE);
viewExpandDate.setDefaultValue("dd/MM/yyyy");
MailRelanceCreator mailCreator = new MailRelanceCreator();
viewExpandNom.setDefaultValue(mailCreator.getDefaultValue());
viewExpandObjet.setDefaultValue(mailCreator.getDefaultObject());
this.addView(viewExpandDate);
this.addView(viewExpandObjet);
this.addView(viewExpandNom);
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/TemplateNXProps.java
17,6 → 17,7
import org.openconcerto.erp.core.customerrelationship.customer.report.FicheClientXmlSheet;
import org.openconcerto.erp.core.edm.AttachmentSQLElement;
import org.openconcerto.erp.core.finance.accounting.report.BalanceSheet;
import org.openconcerto.erp.core.finance.accounting.report.GrandLivreSheet;
import org.openconcerto.erp.core.finance.accounting.report.GrandLivreSheetXML;
import org.openconcerto.erp.core.finance.accounting.report.JournauxSheetXML;
import org.openconcerto.erp.core.humanresources.payroll.report.EtatChargesPayeSheet;
/trunk/OpenConcerto/src/org/openconcerto/erp/preferences/GestionCommercialeGlobalPreferencePanel.java
29,13 → 29,11
 
public class GestionCommercialeGlobalPreferencePanel extends JavaPrefPreferencePanel {
public static String TRANSFERT_REF = "TransfertRef";
public static String COMMANDE_FOURNISSEUR_EN_COURS = "CommandeFournisseurEncours";
public static String TRANSFERT_MULTI_REF = "TransfertMultiRef";
public static String TRANSFERT_NO_REF = "TransfertNoRef";
public static String ACOMPTE_DEVIS = "AcompteDevis";
public static String ORDER_PACKAGING_MANAGEMENT = "OrderPackagingManagement";
public static String ADDRESS_SPEC = "AddressSpec";
public static String CATEGORIE_COMPTABLE_SPEC = "CategorieComptableSpec";
public static String GESTION_TIMBRE_FISCAL = "GestionTimbreFiscal";
public static String TAUX_TIMBRE_FISCAL = "TauxTimbreFiscal";
public static String BARCODE_INSERTION = "BarcodeInsertion";
71,10 → 69,6
orderQuoting.setDefaultValue(Boolean.FALSE);
this.addView(orderQuoting);
 
PrefView<Boolean> cmdEnCours = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Activer la gestion des commandes fournisseurs en cours", COMMANDE_FOURNISSEUR_EN_COURS);
cmdEnCours.setDefaultValue(Boolean.FALSE);
this.addView(cmdEnCours);
 
PrefView<Boolean> viewAcompteDevis = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Gérer les acomptes sur devis", ACOMPTE_DEVIS);
viewAcompteDevis.setDefaultValue(Boolean.FALSE);
this.addView(viewAcompteDevis);
83,10 → 77,6
addressSpec.setDefaultValue(Boolean.TRUE);
this.addView(addressSpec);
PrefView<Boolean> catComptableSpec = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Afficher les sélecteurs de catégorie comptable spécifique", CATEGORIE_COMPTABLE_SPEC);
catComptableSpec.setDefaultValue(Boolean.FALSE);
this.addView(catComptableSpec);
 
PrefView<Boolean> gestTimbreFisc = new PrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Activer la gestion du timbre fiscal", GESTION_TIMBRE_FISCAL);
gestTimbreFisc.setDefaultValue(Boolean.FALSE);
this.addView(gestTimbreFisc);
/trunk/OpenConcerto/src/org/openconcerto/erp/config/translation_fr.xml
179,8 → 179,7
<action id="sales.quote.create.customer.order" label="Transfert vers commande client" />
<action id="sales.quote.create.customer.delivery" label="Transfert vers bon de livraison" />
 
<action id="sales.quote.accept.create.customer.order"
label="Marquer comme accepté et Transfert en commande client" />
<action id="sales.quote.accept.create.customer.order" label="Marquer comme accepté et Transfert en commande client" />
<!-- Customer -->
<action id="customerrelationship.customer.label.print" label="Imprimer l'étiquette client" />
<action id="customerrelationship.customer.info.create" label="Créer la fiche client" />
221,7 → 220,6
<action id="supplychain.order.create.purchase" label="Transfert vers saisie achat" />
<action id="supplychain.order.valid" label="Marquer comme validée" />
<action id="supplychain.order.create.receipt" label="Transfert vers bon de réception" />
<action id="supplychain.invoice.clone" label="Créer à partir de" />
 
<!-- Customer order -->
<action id="sales.order.create.deliverynote" label="Transfert vers bon de livraison" />
249,9 → 247,9
<item id="customerrelationship.customer.identifier" label="Code" />
<item id="customerrelationship.customer.date" label="Date" />
<item id="customerrelationship.customer.customproduct" label="Réf. Art. Interne" />
<item id="customerrelationship.customer.customtarif" label="Remises client" />
 
 
 
<!-- Currency -->
<item id="currency.USD" label="Dollar américain" />
<item id="currency.EUR" label="Euro" />
292,7 → 290,7
<item id="autres.contributions.ligne" label="Autres contributions dues par l'employeur" />
<item id="csg.nonimp.ligne" label="CSG non imposable à l'impôt sur le revenu" />
<item id="csg.imp.ligne" label="CSG/CRDS imposable à l'impôt sur le revenu" />
<item id="allegement.cotisations.ligne" label="Allégement de cotisation" />
<item id="allegement.cotisations.ligne" label="Exonération de cotisations employeur" />
<item id="paye.simplifie.ignore" label="Ligne ignorée" />
 
<!-- Groupe Paye Simplifiée -->
307,6 → 305,6
<item id="cotisations.convention" label="COTISATIONS DE CONVENTION COLLECTIVE OU STATUAIRES" />
<item id="csg.nonimp" label="CSG/CRDS déductible de l'impôt sur le revenu" />
<item id="csg.imp" label="CSG/CRDS non déductible à l'impôt sur le revenu" />
<item id="allegement" label="Allégement de cotisation" />
<action id="email" label="Email" />
<item id="allegement" label="Exonération de cotisations employeur" />
 
</translation>
/trunk/OpenConcerto/src/org/openconcerto/erp/config/mappingCompta_fr.xml
1,11 → 1,5
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<element refid="sales.customer.product.qty.price" nameClass="masculine" name="tarif client">
<FIELD name="QUANTITE" label="Quantité" />
<FIELD name="ID_ARTICLE" label="Article" />
<FIELD name="ID_CLIENT" label="Client" />
<FIELD name="POURCENT_REMISE" label="% remise" />
</element>
<element refid="humanresources.payroll.advance" nameClass="masculine" name="acompte">
<FIELD name="ID_SALARIE" label="Salarié" />
<FIELD name="MONTANT" label="Montant" />
247,7 → 241,6
<element refid="sales.credit.note" nameClass="feminine" name="facture d'avoir" namePlural="factures d'avoir">
<FIELD name="ID_ADRESSE" label="Adresse fact. spéc." />
<FIELD name="ID_ADRESSE_LIVRAISON" label="Adresse livr. spéc." />
<FIELD name="ID_CATEGORIE_COMPTABLE" label="Cat. comptable spéc." />
<FIELD name="ID_CLIENT_DEPARTEMENT" label="Service" />
<FIELD name="ID_SECRETAIRE" label="Secrétaire" />
<FIELD name="ID_ECHEANCIER_CCI" label="Echeancier CCI" />
393,7 → 386,7
<FIELD name="DATE_NAISSANCE" label="Date de naissance" />
</element>
<element refid="bank" nameClass="feminine" name="banque">
<FIELD name="NOM" label="Banque" />
<FIELD name="NOM" label="Nom" />
<FIELD name="NUMERO_RUE" label="Numéro de rue" />
<FIELD name="VOIE" label="Voie" />
<FIELD name="RUE" label="Rue" />
480,7 → 473,6
<FIELD name="FRAIS_DOCUMENT_HT" label="Frais de document HT" />
<FIELD name="ID_ADRESSE" label="Adresse fact. spéc." />
<FIELD name="ID_ADRESSE_LIVRAISON" label="Adresse livr. spéc." />
<FIELD name="ID_CATEGORIE_COMPTABLE" label="Cat. comptable spéc." />
<FIELD name="ID_CLIENT_DEPARTEMENT" label="Service" />
<FIELD name="ID_CONTACT" label="Contact" />
<FIELD name="ID_TARIF" label="Tarif à appliquer" />
842,25 → 834,6
<FIELD name="FONCTION" label="Fonction" />
<FIELD name="N4DS" label="Contact pour la N4DS" />
</element>
<element refid="CONTACT_SALARIE" nameClass="masculine" name="contact salarié">
<FIELD name="PRENOM" label="Prénom du contact" />
<FIELD name="NOM" label="Nom du contact" />
<FIELD name="ID_TITRE_PERSONNEL" label="Titre" />
<FIELD name="TEL_DIRECT" label="Téléphone" />
<FIELD name="TEL_PERSONEL" label="Téléphone Personnel" />
<FIELD name="TEL_STANDARD" label="Téléphone du standard" />
<FIELD name="TEL_MOBILE" label="Portable" />
<FIELD name="EMAIL" label="Mail" />
<FIELD name="FAX" label="Fax" />
<FIELD name="FONCTION" label="Lien de parenté" />
<FIELD name="ID_SALARIE" label="Salarié" />
<FIELD name="NO_MAILING" label="Pas de mailing" />
<FIELD name="TYPE" label="Type" />
<FIELD name="SERVICE" label="Service" />
<FIELD name="PAYS" label="Pays" />
<FIELD name="ID_ADRESSE" label="Adresse" />
<FIELD name="DATE_NAISSANCE" label="Date de naissance" />
</element>
<element refid="humanresources.payroll.anticipation.contract" nameClass="masculine"
name="contrat de prévoyance, mutuelle, formation" namePlural="contrats de prévoyance, mutuelle, formation">
<FIELD name="REFERENCE" label="Référence du contrat de Prévoyance (S21.G00.15.001)" />
907,7 → 880,6
<element refid="humanresources.payroll.contract.employe" nameClass="masculine" name="contrat salarié"
namePlural="contrats salariés">
<FIELD name="NATURE" label="Nature de l'emploi (*)" titlelabel="Nature de l'emploi" />
<FIELD name="COMPLEMENT_PCS" label="Code complément PCS-ESE" />
<FIELD name="ID_CODE_EMPLOI" label="Catégorie socioprofessionnelle "
titlelabel="Code Catégorie socioprofessionnelle" />
<FIELD name="ID_CODE_CONTRAT_TRAVAIL" label="Contrat de travail" titlelabel="Code contrat" />
1017,7 → 989,6
<FIELD name="DATE_LIVRAISON_PREV" label="Livraison prévue le" />
<FIELD name="ID_ADRESSE" label="Adresse fact. spéc." />
<FIELD name="ID_ADRESSE_LIVRAISON" label="Adresse livr. spéc." />
<FIELD name="ID_CATEGORIE_COMPTABLE" label="Cat. comptable spéc." />
<FIELD name="ID_CLIENT_DEPARTEMENT" label="Service" />
<FIELD name="ACOMPTE_COMMANDE" label="Acompte" />
<FIELD name="ID_CONTACT" label="Contact" />
1305,7 → 1276,6
<FIELD name="ID_CLIENT_DEPARTEMENT" label="Service" />
<FIELD name="ID_ADRESSE" label="Adresse fact. spéc." />
<FIELD name="ID_ADRESSE_LIVRAISON" label="Adresse livr. spéc." />
<FIELD name="ID_CATEGORIE_COMPTABLE" label="Cat. comptable spéc." />
<FIELD name="CONTACT_MAIL_RAPPORT" label="Email dest. suppl." />
<FIELD name="SITE_DIFF" label="Site d'intervention différent du donneur d'ordre" />
<FIELD name="DESIGNATION_SITE" label="Désignation du site" />
1608,7 → 1578,6
</element>
<element refid="supplychain.order.invoice.purchase" nameClass="feminine" name="facture fournisseur"
namePlural="factures fournisseur">
<FIELD name="TVA_ADJUSTMENT" label="Ajustement de TVA" />
<FIELD name="ID_AVOIR_FOURNISSEUR" label="Avoir" />
<FIELD name="NET_A_PAYER" label="Net à payer" />
<FIELD name="ID_TAXE_PORT" label="Taxe sur port" />
1638,7 → 1607,6
</element>
<element refid="supplychain.orderinvoice.purchase.item" nameClass="masculine" name="élément de facture"
namePlural="éléments de facture">
<FIELD name="ID_COMPTE_PCE" label="Compte charge spécifique" />
<FIELD name="ID_DEPOT_STOCK" label="Dépôt Stock" />
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
1846,7 → 1814,6
<FIELD name="DATE_SORTIE" label="Date de sortie" />
<FIELD name="CODE_AT" label="Code AT" />
<FIELD name="CODE_SECTION_AT" label="Code section AT" />
<FIELD name="DUREE_FORFAIT" label="Durée du forfait" />
</element>
<element refid="finance.accounting.book" nameClass="masculine" name="journal">
<FIELD name="NOM" label="Journal" />
2250,7 → 2217,6
<FIELD name="TOTAL_TIMBRE_FISCAL" label="Total timbre" />
<FIELD name="ID_CLIENT_DEPARTEMENT" label="Service" />
<FIELD name="ID_ADRESSE_LIVRAISON" label="Adresse livr. spéc." />
<FIELD name="ID_CATEGORIE_COMPTABLE" label="Cat. comptable spéc." />
<FIELD name="ID_COMPTE_PCE_VENTE" label="Compte vente" />
<FIELD name="ID_ADRESSE" label="Adresse spécifique" />
<FIELD name="T_HA" label="Total achat" />
2303,7 → 2269,6
</element>
<element refid="sales.invoice.item" nameClass="masculine" name="article facturé" namePlural="articles facturés">
<FIELD name="ID_DEPOT_STOCK" label="Dépôt Stock" />
<FIELD name="ID_COMPTE_PCE" label="Compte vente spécifique" />
<FIELD name="ID_ECO_CONTRIBUTION" label="Code Eco-Contrib." />
<FIELD name="ECO_CONTRIBUTION" label="Dont Eco-Contrib." />
<FIELD name="T_ECO_CONTRIBUTION" label="Total Eco-Contrib." />
2387,7 → 2352,6
<FIELD name="NOM" label="Nom (*)" titlelabel="Nom" />
<FIELD name="PRENOM" label="Prénom (*)" titlelabel="Prénom" />
<FIELD name="ID_TITRE_PERSONNEL" label="Titre (*)" titlelabel="Titre" />
<FIELD name="ID_USER_COMMON" label="Utilisateur associé" titlelabel="Utilisateur associé" />
<FIELD name="CODE" label="Code (*)" titlelabel="Code" />
<FIELD name="NOM_JEUNE_FILLE" label="Nom de jeune fille" titlelabel="Nom jeune fille" />
<FIELD name="ID_ETAT_CIVIL" label="Etat civil" />
2532,12 → 2496,4
<FIELD name="ControlSum" label="Total des prélèvements" />
<FIELD name="XML" label="Message XML" />
</element>
<element refid="customerrelationship.mail.email.template" nameClass="masculine" name="modèle d'email"
namePlural="modèles d'email">
<FIELD name="NOM" label="Nom du modèle" />
<FIELD name="TITRE" label="Titre" />
<FIELD name="TEXTE" label="Texte" />
<FIELD name="FORMAT_DATE" label="Format de date" />
<FIELD name="PAR_DEFAUT" label="Par défaut" />
</element>
</ROOT>
/trunk/OpenConcerto/src/org/openconcerto/erp/config/translation_pl.xml
193,7 → 193,6
<!-- Supplier order -->
<action id="supplychain.order.create.purchase" label="Transfer do zakupów" />
<action id="supplychain.order.create.receipt" label="Transfer do zamówienia" />
<action id="supplychain.invoice.clone" label="Kopiuj z" />
 
<!-- Customer order -->
<action id="sales.order.create.deliverynote" label="Transfer WZ" />
/trunk/OpenConcerto/src/org/openconcerto/erp/config/Gestion.java
51,7 → 51,6
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.ThrowableHandler;
import org.openconcerto.utils.protocol.Helper;
import org.openconcerto.xml.FastXMLProperties;
 
import java.awt.AWTEvent;
import java.awt.Component;
205,9 → 204,6
}
 
public static void main(String[] args) {
System.setProperty("org.xml.sax.driver", "com.bluecast.xml.Piccolo");
System.setProperty("org.xml.sax.parser", "com.bluecast.xml.Piccolo");
System.setProperty("javax.xml.parsers.SAXParserFactory", "com.bluecast.xml.JAXPSAXParserFactory");
ComptaPropsConfiguration.checkJava();
// Check MacOS Sandbox
String cwd = new File(getProperty("user.dir")).toURI().toString();
414,7 → 410,7
 
if (fTOS.exists()) {
try {
FastXMLProperties.load(pTOS, new FileInputStream(fTOS));
pTOS.loadFromXML(new FileInputStream(fTOS));
} catch (Exception e1) {
e1.printStackTrace();
}
582,7 → 578,7
private static void saveProperties(File fTOS, Properties pTOS) {
try {
final FileOutputStream outputStream = new FileOutputStream(fTOS);
FastXMLProperties.store(pTOS, outputStream, "tos");
pTOS.storeToXML(outputStream, "tos", "UTF-8");
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
597,7 → 593,7
public boolean handle(String message, Throwable throwable) {
if (throwable == null)
return false;
throwable.printStackTrace();
 
final ByteArrayOutputStream out = new ByteArrayOutputStream();
throwable.printStackTrace(new PrintStream(out));
String s = new String(out.toByteArray());
638,7 → 634,7
return true;
}
 
else if (s.contains("No application is associated with the specified file for this operation") || s.contains("Error message: Package could not be registered")) {
else if (s.contains("No application is associated with the specified file for this operation")) {
JOptionPane.showMessageDialog(null, "Merci d'installer LibreOffice ou tout autre application succeptible d'ouvrir ce fichier");
return true;
} else if (s.contains("java.net.SocketTimeoutException: connect timed out")) {
/trunk/OpenConcerto/src/org/openconcerto/erp/config/ComptaPropsConfiguration.java
27,11 → 27,10
import org.openconcerto.erp.core.common.element.StyleSQLElement;
import org.openconcerto.erp.core.common.element.TitrePersonnelSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ClientDepartementSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactAdministratifSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactFournisseurSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactSalarieSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CompteClientTransactionSQLELement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement.ContactAdministratifSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement.ContactFournisseurSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CourrierClientSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerCategorySQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerSQLElement;
39,7 → 38,6
import org.openconcerto.erp.core.customerrelationship.customer.element.ReferenceClientSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.RelanceSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.TypeLettreRelanceSQLElement;
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplateSQLElement;
import org.openconcerto.erp.core.edm.AttachmentSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.AssociationAnalytiqueSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.AssociationCompteAnalytiqueSQLElement;
174,7 → 172,6
import org.openconcerto.erp.core.sales.product.element.ArticleFournisseurSecondaireSQLElement;
import org.openconcerto.erp.core.sales.product.element.ArticleTarifSQLElement;
import org.openconcerto.erp.core.sales.product.element.CoutRevientSQLElement;
import org.openconcerto.erp.core.sales.product.element.CustomerProductQtyPriceSQLElement;
import org.openconcerto.erp.core.sales.product.element.EcoContributionSQLElement;
import org.openconcerto.erp.core.sales.product.element.FamilleArticleSQLElement;
import org.openconcerto.erp.core.sales.product.element.FamilleEcoContributionSQLElement;
230,7 → 227,6
import org.openconcerto.erp.generationDoc.provider.AdresseVilleClientValueProvider;
import org.openconcerto.erp.generationDoc.provider.AdresseVilleNomClientValueProvider;
import org.openconcerto.erp.generationDoc.provider.ArticleCodeClientProvider;
import org.openconcerto.erp.generationDoc.provider.ArticleCodeFournisseurProvider;
import org.openconcerto.erp.generationDoc.provider.ConditionsReglementDetailsProvider;
import org.openconcerto.erp.generationDoc.provider.DateBLProvider;
import org.openconcerto.erp.generationDoc.provider.DateProvider;
244,7 → 240,6
import org.openconcerto.erp.generationDoc.provider.PrixUVProvider;
import org.openconcerto.erp.generationDoc.provider.PrixUnitaireProvider;
import org.openconcerto.erp.generationDoc.provider.PrixUnitaireRemiseProvider;
import org.openconcerto.erp.generationDoc.provider.QteTotalDocProvider;
import org.openconcerto.erp.generationDoc.provider.QteTotalProvider;
import org.openconcerto.erp.generationDoc.provider.RecapFactureProvider;
import org.openconcerto.erp.generationDoc.provider.RefClientValueProvider;
274,8 → 269,6
import org.openconcerto.erp.injector.CommandeCliCommandeSQLInjector;
import org.openconcerto.erp.injector.CommandeFactureAchatSQLInjector;
import org.openconcerto.erp.injector.CommandeFactureClientSQLInjector;
import org.openconcerto.erp.injector.CommandeFactureEltSQLInjector;
import org.openconcerto.erp.injector.CommandeFactureFournisseurSQLInjector;
import org.openconcerto.erp.injector.DevisBlEltSQLInjector;
import org.openconcerto.erp.injector.DevisBlSQLInjector;
import org.openconcerto.erp.injector.DevisCommandeFournisseurSQLInjector;
305,6 → 298,7
import org.openconcerto.sql.model.DBStructureItemNotFound;
import org.openconcerto.sql.model.DBSystemRoot;
import org.openconcerto.sql.model.FieldMapper;
import org.openconcerto.sql.model.LoadingListener;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLServer;
344,8 → 338,14
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
 
import javax.imageio.ImageIO;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
605,7 → 605,6
AdresseVilleNomClientValueProvider.register();
AdresseFullClientValueProvider.register();
QteTotalProvider.register();
QteTotalDocProvider.register();
StockLocationProvider.register();
RefClientValueProvider.register();
ModeDeReglementDetailsProvider.register();
619,10 → 618,62
RecapFactureProvider.register();
RestantAReglerProvider.register();
SaledTotalNotDiscountedProvider.register();
ArticleCodeFournisseurProvider.register();
}
 
@Override
protected void initSystemRoot(DBSystemRoot input) {
super.initSystemRoot(input);
if (!GraphicsEnvironment.isHeadless()) {
final JDialog f = new JOptionPane("Mise à jour des caches en cours...\nCette opération prend généralement moins d'une minute.", JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION,
null, new Object[] {}).createDialog("Veuillez patienter");
input.addLoadingListener(new LoadingListener() {
 
private int loadingCount = 0;
private final ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
final Thread thread = new Thread(r, "Loading listener thread");
thread.setDaemon(true);
return thread;
}
});
private ScheduledFuture<?> future = null;
 
@Override
public synchronized void loading(LoadingEvent evt) {
this.loadingCount += evt.isStarting() ? 1 : -1;
if (this.loadingCount < 0) {
throw new IllegalStateException();
} else if (this.loadingCount == 0) {
this.future.cancel(false);
this.future = null;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
f.setVisible(false);
f.dispose();
}
});
} else if (this.future == null) {
this.future = this.exec.