OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 151 → Rev 156

/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/component/SaisieVenteFactureSQLComponent.java
64,6 → 64,7
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.sql.users.UserManager;
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.RowValuesTable;
73,9 → 74,9
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.TitledSeparator;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.component.InteractionMode;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.ProductInfo;
import org.openconcerto.utils.cc.IFactory;
import org.openconcerto.utils.text.SimpleDocumentListener;
 
83,7 → 84,6
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
148,10 → 148,18
int idCli = SaisieVenteFactureSQLComponent.this.comboClient.getWantedID();
if (idCli > 1) {
SQLRow rowCli = SaisieVenteFactureSQLComponent.this.client.getTable().getRow(idCli);
if (!rowCli.isForeignEmpty("ID_COMMERCIAL")) {
if (!isFilling() && !rowCli.isForeignEmpty("ID_COMMERCIAL")) {
comboCommercial.setValue(rowCli.getForeignID("ID_COMMERCIAL"));
}
 
if (rowCli.getFields().contains("ID_CATEGORIE_COMPTABLE") && rowCli.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowCli.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
totalTTC.setCategorieComptable(rowCli.getForeign("ID_CATEGORIE_COMPTABLE"));
tableFacture.setRowCatComptable(rowCli.getForeign("ID_CATEGORIE_COMPTABLE"));
} else {
totalTTC.setCategorieComptable(null);
tableFacture.setRowCatComptable(null);
}
 
if (getMode() == SQLComponent.Mode.INSERTION || !isFilling()) {
SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
int idModeRegl = rowCli.getInt("ID_MODE_REGLEMENT");
162,6 → 170,9
SaisieVenteFactureSQLComponent.this.eltModeRegl.setValue(rowValsModeRegl);
}
}
} else {
totalTTC.setCategorieComptable(null);
tableFacture.setRowCatComptable(null);
}
 
Where w = new Where(SaisieVenteFactureSQLComponent.this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE);
184,7 → 195,7
private PropertyChangeListener changeClientListener;
private ISQLCompteSelector compteSelService;
private JLabel labelCompteServ;
private ElementComboBox comboCommercial;
private ElementComboBox comboCommercial, comboPoleProduit;
private ElementComboBox comboVerificateur = new ElementComboBox();;
private SQLTable tableBanque = getTable().getTable(BanqueSQLElement.TABLENAME);
 
240,21 → 251,6
c.gridy++;
c.gridwidth = 1;
 
 
if (getTable().contains("ID_POLE_PRODUIT")) {
JLabel labelPole = new JLabel(getLabelFor("ID_POLE_PRODUIT"));
labelPole.setHorizontalAlignment(SwingConstants.RIGHT);
this.add(labelPole, c);
c.gridx++;
ElementComboBox pole = new ElementComboBox();
 
this.add(pole, c);
this.addSQLObject(pole, "ID_POLE_PRODUIT");
c.gridy++;
c.gridwidth = 1;
c.gridx = 0;
}
 
/*******************************************************************************************
* * RENSEIGNEMENTS
******************************************************************************************/
339,12 → 335,11
c.fill = GridBagConstraints.HORIZONTAL;
this.comboCommercial = new ElementComboBox(false);
// Commercial
String field;
field = "ID_COMMERCIAL";
this.addRequiredSQLObject(this.comboCommercial, "ID_COMMERCIAL");
c.gridx++;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c);
this.add(new JLabel(getLabelFor("ID_COMMERCIAL"), SwingConstants.RIGHT), c);
 
c.gridx++;
c.weightx = 1;
351,7 → 346,7
c.fill = GridBagConstraints.NONE;
 
this.add(this.comboCommercial, c);
this.addRequiredSQLObject(this.comboCommercial, field);
 
// Client
c.gridx = 0;
c.gridy++;
403,6 → 398,19
 
}
 
if (getTable().contains("ID_POLE_PRODUIT")) {
JLabel labelPole = new JLabel(getLabelFor("ID_POLE_PRODUIT"));
labelPole.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx++;
this.add(labelPole, c);
 
c.gridx++;
this.comboPoleProduit = new ElementComboBox();
this.add(this.comboPoleProduit, c);
this.addSQLObject(this.comboPoleProduit, "ID_POLE_PRODUIT");
DefaultGridBagConstraints.lockMinimumSize(this.comboPoleProduit);
}
 
if (
 
getTable().contains("ID_ECHEANCIER_CCI")) {
432,7 → 440,7
 
if (!isFilling()) {
SQLRow rowPole = selAffaire.getSelectedRow().getForeignRow("ID_POLE_PRODUIT");
comboCommercial.setValue(rowPole);
comboPoleProduit.setValue(rowPole);
}
} else {
echeancier.getRequest().setWhere(null);
715,7 → 723,69
}
});
}
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) {
 
JLabel labelFraisDocHT = new JLabel(getLabelFor("FRAIS_DOCUMENT_HT"));
labelFraisDocHT.setHorizontalAlignment(SwingConstants.RIGHT);
cFrais.gridx = 1;
cFrais.gridy++;
panelFrais.add(labelFraisDocHT, cFrais);
cFrais.gridx++;
panelFrais.add(textFraisDocHT, cFrais);
addView(textFraisDocHT, "FRAIS_DOCUMENT_HT");
 
JLabel labelTaxeFraisDocHT = new JLabel(getLabelFor("ID_TAXE_FRAIS_DOCUMENT"));
labelTaxeFraisDocHT.setHorizontalAlignment(SwingConstants.RIGHT);
cFrais.gridx = 1;
cFrais.gridy++;
panelFrais.add(labelTaxeFraisDocHT, cFrais);
cFrais.gridx++;
panelFrais.add(boxTaxeFraisDoc, cFrais);
this.addView(boxTaxeFraisDoc, "ID_TAXE_FRAIS_DOCUMENT", REQ);
 
boxTaxeFraisDoc.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
totalTTC.updateTotal();
}
});
 
textFraisDocHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void update(final DocumentEvent e) {
totalTTC.updateTotal();
}
});
 
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!isFilling()) {
final int wantedID = comboClient.getWantedID();
long l = 0;
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
 
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
SQLRow rowFrais = rowClient.getForeign("ID_FRAIS_DOCUMENT");
if (rowFrais != null && !rowFrais.isUndefined()) {
l = rowFrais.getLong("MONTANT_HT");
boxTaxeFraisDoc.setValue(rowFrais.getForeignID("ID_TAXE"));
}
textFraisDocHT.setValue(l);
}
}
}
});
}
 
// Remise
JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT"));
labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT);
767,6 → 837,7
 
totalTTC = new TotalPanel(this.tableFacture, fieldTEco, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT, this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null,
(getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null), null);
totalTTC.setTextFraisDoc(textFraisDocHT, boxTaxeFraisDoc);
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
cBottom.gridx++;
cBottom.weightx = 1;
1156,7 → 1227,7
}
 
private void createCompteServiceAuto(int id) throws SQLException {
SQLRow rowPole = this.comboCommercial.getSelectedRow();
SQLRow rowPole = this.comboPoleProduit.getSelectedRow();
SQLRow rowVerif = this.comboVerificateur.getSelectedRow();
String verifInitiale = getInitialesFromVerif(rowVerif);
int idCpt = ComptePCESQLElement.getId("706" + rowPole.getString("CODE") + verifInitiale, "Service " + rowPole.getString("NOM") + " " + rowVerif.getString("NOM"));
1744,6 → 1815,10
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
vals.put("ID_TAXE_PORT", taxeDefault.getID());
}
if (getTable().contains("ID_TAXE_FRAIS_DOCUMENT")) {
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
vals.put("ID_TAXE_FRAIS_DOCUMENT", taxeDefault.getID());
}
vals.put("ID_COMPTE_PCE_SERVICE", idCompteVenteService);
System.err.println("Defaults " + vals);
return vals;
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/SaisieVenteFactureItemSQLElement.java
16,44 → 16,71
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.erp.preferences.DefaultNXProps;
import org.openconcerto.erp.rights.NXRights;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.sqlobject.ElementComboBox;
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.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.DefaultGridBagConstraints;
import org.openconcerto.ui.component.InteractionMode;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.cc.ITransformer;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.JLabel;
import javax.swing.JTextField;
 
public class SaisieVenteFactureItemSQLElement extends ComptaSQLConfElement {
 
public SaisieVenteFactureItemSQLElement() {
super("SAISIE_VENTE_FACTURE_ELEMENT", "un article facturé", "articles facturés");
private final ComptaPropsConfiguration conf;
 
public SaisieVenteFactureItemSQLElement(final ComptaPropsConfiguration conf) {
super(conf.getRootSociete().getTable("SAISIE_VENTE_FACTURE_ELEMENT"));
this.conf = conf;
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Transfert vers commande fournisseur") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLElement cmd = getDirectory().getElement("COMMANDE");
EditFrame f = new EditFrame(cmd, EditMode.CREATION);
f.getSQLComponent().select(transfertCommande(IListe.get(e).getSelectedRows()));
f.setVisible(true);
}
}, false);
action.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
getRowActions().add(action);
}
 
public SaisieVenteFactureItemSQLElement(String tableName, String singular, String plural) {
super(tableName, singular, plural);
public final ComptaPropsConfiguration getConf() {
return this.conf;
}
 
@Override
62,6 → 89,44
return "ID_SAISIE_VENTE_FACTURE";
}
 
/**
* Transfert d'une commande en commande fournisseur
*
* @param commandeID
*/
public SQLRowValues transfertCommande(List<SQLRowValues> factItems) {
SQLTable tableCmd = getDirectory().getElement("COMMANDE").getTable();
SQLTable tableCmdElt = getDirectory().getElement("COMMANDE_ELEMENT").getTable();
SQLRowValues rowCmd = new SQLRowValues(tableCmd);
 
final Map<Integer, SQLRowValues> map = new HashMap<Integer, SQLRowValues>();
for (SQLRowAccessor sqlRow : factItems) {
// on récupére l'article qui lui correspond
SQLRow sqlRowFetch = sqlRow.asRow();
sqlRowFetch.fetchValues();
if (sqlRowFetch.getObject("ID_ARTICLE") != null && !sqlRowFetch.getForeign("ID_ARTICLE").isUndefined()) {
int idArt = sqlRowFetch.getForeignID("ID_ARTICLE");
if (map.containsKey(idArt)) {
SQLRowValues rowValsElt = map.get(idArt);
rowValsElt.put("QTE", rowValsElt.getInt("QTE") + sqlRowFetch.getInt("QTE"));
} else {
SQLInjector inj = SQLInjector.getInjector(sqlRowFetch.getForeign("ID_ARTICLE").getTable(), tableCmdElt);
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(sqlRowFetch.getForeign("ID_ARTICLE").asRow()));
rowValsElt.put("ID_STYLE", sqlRowFetch.getObject("ID_STYLE"));
rowValsElt.put("QTE", sqlRowFetch.getObject("QTE"));
rowValsElt.put("T_POIDS", sqlRowFetch.getLong("POIDS") * rowValsElt.getInt("QTE"));
rowValsElt.put("T_PA_HT", ((BigDecimal) sqlRowFetch.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
rowValsElt.put("T_PA_TTC",
((BigDecimal) sqlRowFetch.getObject("T_PA_HT")).multiply(new BigDecimal((sqlRowFetch.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)), DecimalUtils.HIGH_PRECISION));
rowValsElt.put("ID_COMMANDE", rowCmd);
map.put(idArt, rowValsElt);
}
}
 
}
return rowCmd;
}
 
/*
* (non-Javadoc)
*
266,6 → 331,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".item";
return createCodeOfPackage() + ".item";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/SaisieVenteFactureSQLElement.java
22,6 → 22,7
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
import org.openconcerto.erp.core.sales.account.PartialInvoiceEditGroup;
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent;
import org.openconcerto.erp.core.sales.account.VenteFactureSoldeEditGroup;
28,6 → 29,7
import org.openconcerto.erp.core.sales.account.VenteFactureSoldeSQLComponent;
import org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent;
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
import org.openconcerto.erp.core.sales.invoice.ui.DateReglementRenderer;
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;
88,6 → 90,7
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Date;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
628,4 → 631,9
 
});
}
 
@Override
protected String createCode() {
return "sales.invoice";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/EcheanceClientSQLElement.java
427,7 → 427,7
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".commitment";
return createCodeOfPackage() + ".commitment";
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/TransferInvoiceSQLElement.java
45,6 → 45,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".transfer";
return createCodeOfPackage() + ".transfer";
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/ReportingVenteXmlSheet.java
17,6 → 17,7
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.AliasedTable;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLSelect;
87,17 → 88,18
protected void createListeValues() {
 
SQLSelect sel = new SQLSelect();
sel.addRawSelect("SUM(\"QTE\"*\"QTE_UNITAIRE\")", "q");
final SQLTable tableItemFact = eltFactItem.getTable();
sel.addSelect(tableItemFact.getField("T_PA_HT"), "SUM");
sel.addSelect(tableItemFact.getField("T_PV_HT"), "SUM");
sel.addSelect(tableItemFact.getField("T_PV_TTC"), "SUM");
AliasedTable tableAlias = new AliasedTable(tableItemFact, "eltTable");
sel.addRawSelect("SUM(\"eltTable\".\"QTE\"*\"eltTable\".\"QTE_UNITAIRE\")", "q");
sel.addSelect(tableAlias.getField("T_PA_HT"), "SUM");
sel.addSelect(tableAlias.getField("T_PV_HT"), "SUM");
sel.addSelect(tableAlias.getField("T_PV_TTC"), "SUM");
final SQLTable tableArt = eltFactItem.getForeignElement("ID_ARTICLE").getTable();
sel.addSelect(tableItemFact.getField("ID_ARTICLE"));
sel.addSelect(tableAlias.getField("ID_ARTICLE"));
 
final SQLSelectJoin joinFact = sel.addJoin("LEFT", tableItemFact.getField("ID_" + eltFact.getTable().getName()));
final SQLSelectJoin joinFact = sel.addJoin("LEFT", tableAlias.getField("ID_" + eltFact.getTable().getName()));
 
Where wA = new Where(tableArt.getKey(), "=", tableItemFact.getField("ID_ARTICLE"));
Where wA = new Where(tableArt.getKey(), "=", tableAlias.getField("ID_ARTICLE"));
Where w = new Where(joinFact.getJoinedTable().getField("DATE"), this.du, this.au);
 
if (idS != null && idS.size() > 0) {
108,7 → 110,7
}
sel.setWhere(wA.and(w));
 
sel.addGroupBy(tableItemFact.getField("ID_ARTICLE"));
sel.addGroupBy(tableAlias.getField("ID_ARTICLE"));
 
List<Object[]> result = eltFact.getTable().getDBSystemRoot().getDataSource().executeA(sel.asString());
 
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/ReportingClientPanel.java
New file
0,0 → 1,119
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.sales.invoice.report;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.EmailComposer;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
public class ReportingClientPanel extends JPanel {
 
public ReportingClientPanel() {
super(new GridBagLayout());
 
JLabelBold title = new JLabelBold("Génération d'un relevé des factures d'un client");
 
JLabel labelCom = new JLabel("Relevé du client");
 
final ElementComboBox box = new ElementComboBox(true);
SQLElement element = Configuration.getInstance().getDirectory().getElement("CLIENT");
ComboSQLRequest comboRequest = element.getComboRequest(true);
// comboRequest.setUndefLabel("Tous");
box.init(element, comboRequest);
 
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(title, c);
c.gridy++;
c.gridwidth = 1;
this.add(labelCom, c);
c.gridx++;
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(box, c);
 
c.gridy++;
c.gridx = 0;
c.gridwidth = 1;
this.add(new JLabel("Facture émises entre le"), c);
final JDate d1 = new JDate();
c.gridx++;
this.add(d1, c);
c.gridx++;
this.add(new JLabel("et le"), c);
final JDate d2 = new JDate();
c.gridx++;
this.add(d2, c);
 
final JButton buttonValid = new JButton(new AbstractAction("Valider") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
new Thread() {
public void run() {
 
final SQLRow selectedClient = box.getSelectedRow();
ReportingClientXml sheet = new ReportingClientXml(selectedClient, d1.getValue(), d2.getValue());
try {
sheet.createDocument();
// sheet.showPrintAndExport(false, false, false);
 
String mail = selectedClient.getString("MAIL");
 
try {
EmailComposer.getInstance().compose(mail, "", "", sheet.getGeneratedFile());
} catch (Exception exn) {
ExceptionHandler.handle(null, "Impossible de créer le courriel", exn);
}
 
} catch (Exception e) {
ExceptionHandler.handle("Une erreur est survenue lors de la création du document", e);
}
};
}.start();
 
}
});
c.gridx++;
this.add(buttonValid, c);
 
// Listener enabled/disabled button
buttonValid.setEnabled(false);
box.addModelListener("wantedID", new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent arg0) {
buttonValid.setEnabled(box.getWantedID() != SQLRow.NONEXISTANT_ID && box.getWantedID() != box.getRequest().getPrimaryTable().getUndefinedID());
}
});
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/ReportingClientXml.java
New file
0,0 → 1,209
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.sales.invoice.report;
 
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.utils.cc.ITransformer;
 
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
 
public class ReportingClientXml extends AbstractListeSheetXml {
 
public static final String TEMPLATE_ID = "ReportingClient";
public static final String TEMPLATE_PROPERTY_NAME = DEFAULT_PROPERTY_NAME;
 
private final Calendar toDay = Calendar.getInstance();
private final Date d1, d2;
private DateFormat format;
 
public ReportingClientXml(SQLRow rowClient, Date d1, Date d2) {
super(rowClient);
this.d1 = d1;
this.d2 = d2;
}
 
@Override
protected void createListeValues() {
final SQLTable table = Configuration.getInstance().getDirectory().getElement("CLIENT").getTable();
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.putNulls("NOM");
 
final SQLTable tableFacture = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE").getTable();
SQLRowValues rowValsF = new SQLRowValues(tableFacture);
rowValsF.put("ID_CLIENT", rowVals);
rowValsF.putNulls("NUMERO", "NOM", "T_HT", "T_TTC", "DATE", "INFOS");
 
final SQLTable tableEch = Configuration.getInstance().getDirectory().getElement("ECHEANCE_CLIENT").getTable();
SQLRowValues rowValsE = new SQLRowValues(tableEch);
rowValsE.put("ID_SAISIE_VENTE_FACTURE", rowValsF);
rowValsE.putNulls("REGLE", "DATE", "MONTANT", "REG_COMPTA", "DATE_LAST_RELANCE");
 
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsF);
 
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
 
Where w = new Where(tableFacture.getField("ID_CLIENT"), "=", row.getID());
if (d1 != null || d2 != null) {
if (d1 == null) {
w = w.and(new Where(tableFacture.getField("DATE"), "<=", d2));
} else if (d2 == null) {
w = w.and(new Where(tableFacture.getField("DATE"), ">=", d1));
} else {
w = w.and(new Where(tableFacture.getField("DATE"), d1, d2));
}
}
input.setWhere(w);
return input;
}
});
 
List<SQLRowValues> l = fetcher.fetch();
 
this.mapAllSheetValues = new HashMap<Integer, Map<String, Object>>();
Map<String, Object> mapValues = new HashMap<String, Object>();
mapValues.put("CLIENT", this.row.getString("NOM"));
mapValues.put("DATE", toDay.getTime());
 
String upTo = "Invoices up to ";
String since = "Invoices since ";
String between = "Invoices between ";
String and = " and ";
if (this.row.getObject("ID_LANGUE") != null && this.row.getInt("ID_LANGUE") == 2) {
 
upTo = "Factures jusqu'au ";
since = "Factures depuis le ";
between = "Factures entre le ";
and = " et le ";
format = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);
} else {
format = new SimpleDateFormat("d MMMM yyyy", Locale.US);
// format = DateFormat.getDateInstance(DateFormat.LONG, Locale.US);
}
 
if (d1 != null || d2 != null) {
if (d1 == null) {
mapValues.put("PERIOD", upTo + format.format(d2));
} else if (d2 == null) {
mapValues.put("PERIOD", since + format.format(d1));
 
} else {
mapValues.put("PERIOD", between + format.format(d1) + and + format.format(d2));
}
}
 
this.mapAllSheetValues.put(0, mapValues);
 
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
 
this.listAllSheetValues.put(0, values);
this.styleAllSheetValues = new HashMap<Integer, Map<Integer, String>>();
Map<Integer, String> styles = new HashMap<Integer, String>();
this.styleAllSheetValues.put(0, styles);
 
Map<String, Object> total = new HashMap<String, Object>();
total.put("NUMERO_FACTURE", "TOTAL");
double totalTTC = 0;
double totalDu = 0;
for (SQLRowValues sqlRowValues : l) {
Map<String, Object> line = new HashMap<String, Object>();
line.put("NUMERO_FACTURE", sqlRowValues.getObject("NUMERO"));
line.put("INFOS", sqlRowValues.getObject("INFOS"));
line.put("NOM", sqlRowValues.getObject("NOM"));
 
Calendar c = sqlRowValues.getDate("DATE");
line.put("DATE", c.getTime());
 
final double ttc = sqlRowValues.getLong("T_TTC") / 100.0D;
line.put("T_TTC", ttc);
 
double du = 0;
 
// Client
SQLRowAccessor rowC = sqlRowValues.getForeign("ID_CLIENT");
if (rowC != null && !rowC.isUndefined()) {
line.put("CLIENT", rowC.getObject("NOM"));
}
 
Calendar dateEch = Calendar.getInstance();
dateEch.setTime(c.getTime());
// Echeance
Collection<SQLRowValues> echeances = sqlRowValues.getReferentRows(tableEch);
for (SQLRowValues sqlRowValues2 : echeances) {
if (!sqlRowValues2.getBoolean("REGLE") && !sqlRowValues2.getBoolean("REG_COMPTA")) {
du += sqlRowValues2.getLong("MONTANT") / 100.0D;
dateEch = sqlRowValues2.getDate("DATE");
}
}
 
line.put("ECHEANCE", dateEch.getTime());
 
line.put("DU", du);
line.put("REGLE", ttc - du);
 
totalTTC += ttc;
totalDu += du;
 
if (du == 0) {
styles.put(values.size(), "Normal");
} else {
if (!toDay.after(dateEch)) {
styles.put(values.size(), "Titre 1");
} else {
styles.put(values.size(), "Titre 2");
}
}
values.add(line);
}
 
total.put("T_TTC", totalTTC);
total.put("DU", totalDu);
total.put("REGLE", totalTTC - totalDu);
styles.put(values.size(), "Titre 3");
values.add(total);
 
}
 
@Override
public String getDefaultTemplateId() {
 
return TEMPLATE_ID;
}
 
@Override
public String getName() {
// TODO Auto-generated method stub
return "ReportingClient" + this.row.getString("NOM");
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/EtatStockInventaireXmlSheet.java
New file
0,0 → 1,277
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.sales.invoice.report;
 
import org.openconcerto.erp.generationDoc.AbstractListeSheetXml;
import org.openconcerto.erp.preferences.PrinterNXProps;
import org.openconcerto.sql.element.SQLElement;
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.Where;
 
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
 
public class EtatStockInventaireXmlSheet extends AbstractListeSheetXml {
 
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
 
public static final String TEMPLATE_ID = "EtatStockInventaire";
public static final String TEMPLATE_PROPERTY_NAME = DEFAULT_PROPERTY_NAME;
 
private Date date;
private SQLElement eltArticle;
private SQLElement eltStock;
 
public EtatStockInventaireXmlSheet(SQLRow etatStock) {
super();
this.row = etatStock;
 
this.printer = PrinterNXProps.getInstance().getStringProperty("BonPrinter");
 
}
 
@Override
public String getStoragePathP() {
return "Autres";
}
 
@Override
public String getDefaultTemplateId() {
return TEMPLATE_ID;
};
 
@Override
public String getName() {
if (this.date == null) {
this.date = new Date();
}
return "EtatStocks" + this.date.getTime();
}
 
protected void createListeValues() {
 
SQLRowValues rowVals = new SQLRowValues(this.row.getTable().getTable("ETAT_STOCK_ELEMENT"));
rowVals.put("QTE", null);
SQLRowValues rowValsArt = rowVals.putRowValues("ID_ARTICLE");
rowValsArt.put("ID_FAMILLE_ARTICLE", null);
rowValsArt.put("CODE", null);
rowValsArt.put("NOM", null);
rowValsArt.put("PA_HT", null);
rowValsArt.put("PV_HT", null);
 
SQLRowValuesListFetcher fetch = SQLRowValuesListFetcher.create(rowVals);
List<SQLRowValues> values = fetch.fetch(new Where(rowVals.getTable().getField("ID_ETAT_STOCK"), "=", this.row.getID()));
 
final SQLTable tableF = this.row.getTable().getTable("FAMILLE_ARTICLE");
SQLSelect selFam = new SQLSelect();
selFam.addSelect(tableF.getKey());
selFam.addSelect(tableF.getField("NOM"));
selFam.addSelect(tableF.getField("ID_FAMILLE_ARTICLE_PERE"));
 
List<SQLRow> fam = SQLRowListRSH.execute(selFam);
Map<Integer, SQLRow> mapF = new HashMap<Integer, SQLRow>();
for (SQLRow sqlRow : fam) {
mapF.put(sqlRow.getID(), sqlRow);
}
 
final SQLTable tableFourn = this.row.getTable().getTable("FOURNISSEUR");
SQLSelect selFourn = new SQLSelect();
selFourn.addSelect(tableFourn.getKey());
selFourn.addSelect(tableFourn.getField("NOM"));
 
List<SQLRow> fourn = SQLRowListRSH.execute(selFourn);
Map<Integer, SQLRow> mapFourn = new HashMap<Integer, SQLRow>();
for (SQLRow sqlRow : fourn) {
mapFourn.put(sqlRow.getID(), sqlRow);
}
 
Map<String, Line> linesFamilles = new HashMap<String, Line>();
Map<Line, Map<Line, List<Line>>> myValues = new TreeMap<Line, Map<Line, List<Line>>>(new Comparator<Line>() {
@Override
public int compare(Line o1, Line o2) {
return o1.getNomArt().compareTo(o2.getNomArt());
}
});
Line lineTotal = new Line("Total", "", BigDecimal.ZERO, BigDecimal.ZERO);
final HashMap<Integer, String> style = new HashMap<Integer, String>();
for (SQLRowValues vals : values) {
BigDecimal qte = vals.getBigDecimal("QTE");
 
SQLRowAccessor rowValsArticle = vals.getForeign("ID_ARTICLE");
BigDecimal ha = rowValsArticle.getBigDecimal("PA_HT").multiply(qte);
 
int idFamille = rowValsArticle.getForeignID("ID_FAMILLE_ARTICLE");
SQLRow rowF = mapF.get(idFamille);
Line lineArt = new Line(rowF == null || rowF.isUndefined() ? "Sans famille" : rowF.getString("NOM"), rowValsArticle.getString("NOM"), rowValsArticle.getString("CODE"), ha, qte);
 
// Init des lines familles
 
final Line lineF, lineSF;
if (rowF == null) {
if (!linesFamilles.containsKey("Undef")) {
linesFamilles.put("Undef", new Line("Sans famille", "", BigDecimal.ZERO, BigDecimal.ZERO));
linesFamilles.put("Undef-Undef", new Line("", "", BigDecimal.ZERO, BigDecimal.ZERO));
}
lineF = linesFamilles.get("Undef");
lineSF = linesFamilles.get("Undef-Undef");
} else if (rowF.getObject("ID_FAMILLE_ARTICLE_PERE") == null || rowF.isForeignEmpty("ID_FAMILLE_ARTICLE_PERE")) {
if (!linesFamilles.containsKey(String.valueOf(rowF.getID()))) {
linesFamilles.put(String.valueOf(rowF.getID()), new Line(rowF.getString("NOM"), "", BigDecimal.ZERO, BigDecimal.ZERO));
linesFamilles.put(String.valueOf(rowF.getID()) + "-Undef", new Line("", "", BigDecimal.ZERO, BigDecimal.ZERO));
}
if (!linesFamilles.containsKey(String.valueOf(rowF.getID()) + "-Undef")) {
linesFamilles.put(String.valueOf(rowF.getID()) + "-Undef", new Line("", "", BigDecimal.ZERO, BigDecimal.ZERO));
}
lineF = linesFamilles.get(String.valueOf(rowF.getID()));
lineSF = linesFamilles.get(String.valueOf(rowF.getID()) + "-Undef");
} else {
if (!linesFamilles.containsKey(String.valueOf(rowF.getID()))) {
linesFamilles.put(String.valueOf(rowF.getID()), new Line(rowF.getString("NOM"), "", BigDecimal.ZERO, BigDecimal.ZERO));
}
if (!linesFamilles.containsKey(String.valueOf(rowF.getForeignID("ID_FAMILLE_ARTICLE_PERE")))) {
SQLRow rowSF = mapF.get(rowF.getForeignID("ID_FAMILLE_ARTICLE_PERE"));
linesFamilles.put(String.valueOf(rowF.getForeignID("ID_FAMILLE_ARTICLE_PERE")), new Line(rowSF.getString("NOM"), "", BigDecimal.ZERO, BigDecimal.ZERO));
}
lineF = linesFamilles.get(String.valueOf(rowF.getForeignID("ID_FAMILLE_ARTICLE_PERE")));
lineSF = linesFamilles.get(String.valueOf(rowF.getID()));
}
 
// init values
if (!myValues.containsKey(lineF)) {
myValues.put(lineF, new TreeMap<Line, List<Line>>(new Comparator<Line>() {
@Override
public int compare(Line o1, Line o2) {
return o1.getNomArt().compareTo(o2.getNomArt());
}
}));
myValues.get(lineF).put(lineSF, new ArrayList<Line>());
}
Map<Line, List<Line>> mapSF = myValues.get(lineF);
if (!mapSF.containsKey(lineSF)) {
mapSF.put(lineSF, new ArrayList<Line>());
}
 
// Store values
List<Line> lines = mapSF.get(lineSF);
lines.add(lineArt);
lineTotal.add(lineArt);
lineF.add(lineArt);
lineSF.add(lineArt);
 
}
 
// Sort Values
List<Map<String, Object>> listValues = new ArrayList<Map<String, Object>>();
 
for (Line f : myValues.keySet()) {
listValues.add(f.getMapXMLSheet());
style.put(style.keySet().size(), "Titre 1");
Map<Line, List<Line>> sfs = myValues.get(f);
for (Line sf : sfs.keySet()) {
// listValues.add(sf.getMapXMLSheet());
// style.put(style.keySet().size(), "Titre 2");
List<Line> vals = sfs.get(sf);
Collections.sort(vals, new Comparator<Line>() {
@Override
public int compare(Line o1, Line o2) {
return o1.getNomArt().compareTo(o2.getNomArt());
}
});
for (Line line : vals) {
listValues.add(line.getMapXMLSheet());
style.put(style.keySet().size(), "Normal");
}
}
}
 
listValues.add(lineTotal.getMapXMLSheet());
style.put(style.keySet().size(), "Titre 1");
 
final Map<String, Object> valuesSheet = new HashMap<String, Object>();
valuesSheet.put("DATE", "Au " + dateFormat.format(new Date()));
//
this.listAllSheetValues.put(0, listValues);
 
this.styleAllSheetValues.put(0, style);
this.mapAllSheetValues.put(0, valuesSheet);
}
 
class Line {
private final String nomArt;
private final String codeArt;
private final String famille;
private BigDecimal totalHA;
private BigDecimal qte;
 
public Line(String nomArt, String codeArt, BigDecimal totalHA, BigDecimal qte) {
this("", nomArt, codeArt, totalHA, qte);
}
 
public Line(String famille, String nomArt, String codeArt, BigDecimal totalHA, BigDecimal qte) {
this.famille = famille;
this.nomArt = nomArt;
this.codeArt = codeArt;
this.totalHA = totalHA;
this.qte = qte;
}
 
public BigDecimal getQte() {
return qte;
}
 
public String getCodeArt() {
return codeArt;
}
 
public String getNomArt() {
return nomArt;
}
 
public BigDecimal getTotalHA() {
return totalHA;
}
 
public void add(Line l) {
this.totalHA = this.totalHA.add(l.getTotalHA());
this.qte = this.qte.add(l.getQte());
}
 
public Map<String, Object> getMapXMLSheet() {
Map<String, Object> m = new HashMap<String, Object>();
m.put("FAMILLE", this.famille);
m.put("CODE", getCodeArt());
m.put("NOM", getNomArt());
m.put("QTE", getQte());
m.put("TOTAL_HA", getTotalHA());
return m;
}
 
}
 
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/NouveauSaisieVenteFactureAcompteAction.java
13,24 → 13,17
package org.openconcerto.erp.core.sales.invoice.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauSaisieVenteFactureAcompteAction extends NouveauSaisieVenteFactureAction {
 
public class NouveauSaisieVenteFactureAcompteAction extends CreateFrameAbstractAction {
 
public NouveauSaisieVenteFactureAcompteAction() {
super();
this.putValue(Action.NAME, "Facture");
public NouveauSaisieVenteFactureAcompteAction(final PropsConfiguration conf) {
super(conf);
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE").createComponent(VenteFactureSituationSQLComponent.ID), EditMode.CREATION);
protected String getComponentID() {
return VenteFactureSituationSQLComponent.ID;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/ListeDesFactureItemsAction.java
13,16 → 13,19
package org.openconcerto.erp.core.sales.invoice.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.action.CreateIListFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.IListPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
import java.awt.GridBagConstraints;
29,27 → 32,33
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class ListeDesFactureItemsAction extends CreateIListFrameAbstractAction<SaisieVenteFactureItemSQLElement> {
 
public class ListeDesFactureItemsAction extends CreateFrameAbstractAction {
public ListeDesFactureItemsAction(final ComptaPropsConfiguration conf) {
super(conf, SaisieVenteFactureItemSQLElement.class);
}
 
public ListeDesFactureItemsAction() {
super();
this.putValue(Action.NAME, "Liste des articles facturés");
@Override
protected SQLTableModelSource createTableSource() {
final SQLTableModelSource res = super.createTableSource();
res.getReq().setWhere(new Where(getElem().getTable().getField("ID_SAISIE_VENTE_FACTURE"), ">", 1));
return res;
}
 
public JFrame createFrame() {
final SQLElement element = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
@Override
protected IListPanel instantiateListPanel(SQLTableModelSource tableSource, String panelVariant) {
return new ListeViewPanel(tableSource.getElem(), new IListe(tableSource));
}
@Override
protected void initFrame(IListFrame frame) {
final SQLElement element = this.getElem();
 
IListe liste = new IListe(element.getTableSource(true));
final ListeViewPanel listeAddPanel = new ListeViewPanel(element, liste);
listeAddPanel.getListe().getRequest().setWhere(new Where(element.getTable().getField("ID_SAISIE_VENTE_FACTURE"), ">", 1));
List<SQLField> l = new ArrayList<SQLField>();
l.add(element.getTable().getField("QTE"));
l.add(element.getTable().getField("T_PA_HT"));
l.add(element.getTable().getField("T_PV_HT"));
l.add(element.getTable().getField("T_PV_TTC"));
final IListPanel listeAddPanel = frame.getPanel();
IListTotalPanel total = new IListTotalPanel(listeAddPanel.getListe(), l);
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridy = 2;
58,8 → 67,6
c.anchor = GridBagConstraints.EAST;
c.fill = GridBagConstraints.NONE;
listeAddPanel.add(total, c);
IListFrame frame = new IListFrame(listeAddPanel);
frame.setTextTitle("Liste des articles facturés");
frame.getPanel().getListe().setModificationAllowed(false);
frame.getPanel().setAddVisible(false);
frame.getPanel().setSearchFullMode(true);
70,7 → 77,5
c.gridy++;
c.anchor = GridBagConstraints.CENTER;
frame.getPanel().add(datePanel, c);
 
return frame;
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/GenEtatStockAction.java
32,7 → 32,8
ReportingStockXmlSheet sheet = new ReportingStockXmlSheet(false);
 
sheet.createDocumentAsynchronous().get();
sheet.showPrintAndExport(true, false, false, false, false);
sheet.openDocument(false);
 
} catch (Exception e) {
ExceptionHandler.handle("Erreur de traitement", e);
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/NouveauSaisieVenteFactureItemAction.java
13,22 → 13,14
package org.openconcerto.erp.core.sales.invoice.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.action.CreateEditFrameAbstractAction;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauSaisieVenteFactureItemAction extends CreateEditFrameAbstractAction<SaisieVenteFactureItemSQLElement> {
 
public class NouveauSaisieVenteFactureItemAction extends CreateFrameAbstractAction {
 
public NouveauSaisieVenteFactureItemAction() {
super();
this.putValue(Action.NAME, "Test élément d'une saisie de vente avec facture");
public NouveauSaisieVenteFactureItemAction(final PropsConfiguration conf) {
super(conf, SaisieVenteFactureItemSQLElement.class);
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/NouveauSaisieVenteFactureAction.java
13,22 → 13,14
package org.openconcerto.erp.core.sales.invoice.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.action.CreateEditFrameAbstractAction;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauSaisieVenteFactureAction extends CreateEditFrameAbstractAction<SaisieVenteFactureSQLElement> {
 
public class NouveauSaisieVenteFactureAction extends CreateFrameAbstractAction {
 
public NouveauSaisieVenteFactureAction() {
super();
this.putValue(Action.NAME, "Facture");
public NouveauSaisieVenteFactureAction(final PropsConfiguration conf) {
super(conf, SaisieVenteFactureSQLElement.class);
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/action/NouveauSaisieVenteComptoirAction.java
13,22 → 13,14
package org.openconcerto.erp.core.sales.invoice.action;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.erp.action.CreateEditFrameAbstractAction;
import org.openconcerto.erp.core.sales.pos.element.SaisieVenteComptoirSQLElement;
import org.openconcerto.sql.PropsConfiguration;
 
import javax.swing.Action;
import javax.swing.JFrame;
public class NouveauSaisieVenteComptoirAction extends CreateEditFrameAbstractAction<SaisieVenteComptoirSQLElement> {
 
public class NouveauSaisieVenteComptoirAction extends CreateFrameAbstractAction {
 
public NouveauSaisieVenteComptoirAction() {
super();
this.putValue(Action.NAME, "Saisie Vente Comptoir");
public NouveauSaisieVenteComptoirAction(final PropsConfiguration conf) {
super(conf, SaisieVenteComptoirSQLElement.class);
}
 
@Override
public JFrame createFrame() {
return new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_COMPTOIR"));
}
}
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListeDesEcheancesClientsPanel.java
36,6 → 36,7
import org.openconcerto.sql.view.IListener;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ExceptionHandler;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
60,7 → 61,8
private ListPanelEcheancesClients panelEcheances;
private EditFrame editEncaisse = null;
private EditFrame editRelance = null;
private JButton relancer, encaisser;
private JButton relancer;
private JButton encaisser;
 
public ListeDesEcheancesClientsPanel() {
this(false);
147,23 → 149,26
public void actionPerformed(ActionEvent e) {
 
List<Integer> selectedIds = ListeDesEcheancesClientsPanel.this.panelEcheances.getListe().getSelection().getSelectedIDs();
List<SQLRow> selectedRows = new ArrayList<SQLRow>(selectedIds.size());
List<SQLRow> selectedRows = new ArrayList<>(selectedIds.size());
int idCpt = -1;
int idClient = -1;
int idCptTiers = -1;
String tiers = "";
boolean showMessage = false;
 
String numeroFact = "";
StringBuilder numerosFacturesBuilders = new StringBuilder();
for (Integer integer : selectedIds) {
final SQLRow row = ListeDesEcheancesClientsPanel.this.panelEcheances.getListe().getSource().getPrimaryTable().getRow(integer);
// System.err.println("ListeDesEcheancesClientsPanel.ListeDesEcheancesClientsPanel().new
// ActionListener() {...}.actionPerformed()"
// + row);
 
selectedRows.add(row);
 
tiers = row.getString("TIERS");
String nom = row.getForeignRow("ID_MOUVEMENT").getForeignRow("ID_PIECE").getString("NOM");
numeroFact += " " + nom;
 
numerosFacturesBuilders.append(nom);
numerosFacturesBuilders.append(' ');
 
SQLRow rowClient = row.getForeignRow("ID_CLIENT");
if (rowClient != null && !rowClient.isUndefined()) {
int idTmp = rowClient.getInt("ID_COMPTE_PCE");
int idCliTmp = rowClient.getID();
if (idCpt > -1 && idCpt != idTmp) {
179,6 → 184,11
idClient = idCliTmp;
}
}
SQLRow rowCptTiers = row.getForeignRow("ID_COMPTE_PCE_TIERS");
if (rowCptTiers != null && !rowCptTiers.isUndefined()) {
idCptTiers = rowCptTiers.getID();
}
}
if (showMessage) {
int answer = JOptionPane.showConfirmDialog(null, "Attention vous avez sélectionné des factures ayant des clients différents. Voulez vous continuer?");
if (answer != JOptionPane.YES_OPTION) {
193,9 → 203,14
}
 
SQLRowValues rowVals = new SQLRowValues(encaisseElt.getTable());
 
if (idClient > -1) {
rowVals.put("ID_CLIENT", idClient);
rowVals.put("NOM", numeroFact);
}
rowVals.put("NOM", numerosFacturesBuilders.toString().trim());
rowVals.put("TIERS", tiers);
if (idCptTiers > -1) {
rowVals.put("ID_COMPTE_PCE_TIERS", idCptTiers);
}
 
final EncaisserMontantSQLComponent sqlComponent = (EncaisserMontantSQLComponent) ListeDesEcheancesClientsPanel.this.editEncaisse.getSQLComponent();
 
210,15 → 225,18
 
// Gestion de la souris
this.panelEcheances.getJTable().addMouseListener(new MouseAdapter() {
 
@Override
public void mousePressed(MouseEvent mE) {
 
if (mE.getButton() == MouseEvent.BUTTON1) {
// Mise à jour de l'echeance sur la frame de reglement
// si cette derniere est cree
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLRow row = panelEcheances.getListe().getSelectedRow().asRow();
if (mE.getButton() == MouseEvent.BUTTON1) {
 
final SQLRowValues selectedRow = panelEcheances.getListe().getSelectedRow();
final SQLRow row = selectedRow.asRow();
if (row == null) {
JOptionPane.showMessageDialog(ListeDesEcheancesClientsPanel.this, "Selection", "Merci de sélectionner une ligne", JOptionPane.PLAIN_MESSAGE);
return;
}
if (ListeDesEcheancesClientsPanel.this.editEncaisse != null) {
final SQLRowValues rowVals = new SQLRowValues(base.getTable("ENCAISSER_MONTANT"));
rowVals.put("ID_ECHEANCE_CLIENT", row.getID());
237,19 → 255,13
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLTable tableEch = base.getTable("ECHEANCE_CLIENT");
final SQLRow rowEch = tableEch.getRow(id);
final int idMvtSource = MouvementSQLElement.getSourceId(rowEch.getInt("ID_MOUVEMENT"));
final SQLRow rowMvtSource = base.getTable("MOUVEMENT").getRow(idMvtSource);
 
int idMvtSource = MouvementSQLElement.getSourceId(rowEch.getInt("ID_MOUVEMENT"));
SQLRow rowMvtSource = base.getTable("MOUVEMENT").getRow(idMvtSource);
 
if (!rowMvtSource.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
ListeDesEcheancesClientsPanel.this.relancer.setEnabled(false);
} else {
ListeDesEcheancesClientsPanel.this.relancer.setEnabled(true);
}
ListeDesEcheancesClientsPanel.this.relancer.setEnabled(rowMvtSource.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE"));
ListeDesEcheancesClientsPanel.this.encaisser.setEnabled(true);
} else {
ListeDesEcheancesClientsPanel.this.relancer.setEnabled(false);
 
ListeDesEcheancesClientsPanel.this.encaisser.setEnabled(false);
}
 
260,16 → 272,13
 
}
 
private SQLRow rowSource;
 
private void relanceClient() {
 
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final SQLElement relanceElt = Configuration.getInstance().getDirectory().getElement("RELANCE");
 
this.rowSource = this.panelEcheances.getListe().fetchSelectedRow();
final SQLRow rowSource = this.panelEcheances.getListe().fetchSelectedRow();
 
if (this.rowSource != null) {
if (rowSource != null) {
int idMvtSource = MouvementSQLElement.getSourceId(rowSource.getInt("ID_MOUVEMENT"));
SQLRow rowMvtSource = base.getTable("MOUVEMENT").getRow(idMvtSource);
 
284,16 → 293,18
this.editRelance.addEditPanelListener(new EditPanelListener() {
 
public void cancelled() {
// rien
}
 
public void modified() {
// rien
}
 
public void deleted() {
// rien
}
 
public void inserted(int id) {
System.err.println("INSERTED " + id + " -- " + rowSource.getID());
int nbRelance = rowSource.getInt("NOMBRE_RELANCE");
nbRelance++;
 
305,7 → 316,7
rowValsEch.update(rowSource.getID());
relanceElt.getTable().getRow(id).createEmptyUpdateRow().put("ID_ECHEANCE_CLIENT", rowSource.getID()).commit();
} catch (SQLException e1) {
e1.printStackTrace();
ExceptionHandler.handle("erreur lors de la mise à jour du nombre de relances", e1);
}
}
});
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/ListeDesVentesPanel.java
22,6 → 22,7
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement.GenerationResult;
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement.IgnoreReason;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.erp.core.sales.pos.ui.TextAreaTicketPanel;
import org.openconcerto.erp.utils.TM;
import org.openconcerto.sql.Configuration;
32,6 → 33,7
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.request.UpdateBuilder;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.ITableModel;
158,7 → 160,7
// TODO dialog with label informing of the successful creation of message for n
// invoices/n2 messages too far in the future/n3 messages with collection date
// changed and having a button to open the file chooser
new SwingWorker<GenerationResult, Object>() {
new SwingWorker<GenerationResult, Void>() {
@Override
protected GenerationResult doInBackground() throws Exception {
return sepaMsgElem.generateXML(selectedIDs);
191,17 → 193,16
tmMap.put("missingInfoCount", missingInfoCount);
final StringBuilder msg = new StringBuilder(256);
msg.append(TM.getTM().trM("sddMessage.generation.someIgnored", tmMap));
msg.append('\n');
if (futureCount > 0) {
msg.append("- ");
msg.append("\n- ");
msg.append(TM.getTM().trM("sddMessage.generation.someIgnored.future", tmMap));
}
if (duplicateCount > 0) {
msg.append("- ");
msg.append("\n- ");
msg.append(TM.getTM().trM("sddMessage.generation.someIgnored.duplicateMandate", tmMap));
}
if (missingInfoCount > 0) {
msg.append("- ");
msg.append("\n- ");
msg.append(TM.getTM().trM("sddMessage.generation.someIgnored.missingInfo", tmMap));
}
final int messageType = duplicateCount == 0 ? JOptionPane.WARNING_MESSAGE : JOptionPane.ERROR_MESSAGE;
214,6 → 215,26
}.execute();
}
}, false, true).setPredicate(IListeEvent.getNonEmptySelectionPredicate()));
// TODO remove once we have a join with {SENT, OK, DEFINITIVE_ERROR, TRANSIENT_ERROR}
this.listeFact.getListe().addIListeAction(new RowAction.PredicateRowAction(new AbstractAction("Prélever à nouveau", null) {
@Override
public void actionPerformed(ActionEvent e) {
final IListe l = IListe.get(e);
if (JOptionPane.showConfirmDialog(l, "Voulez-vous vraiment prélever à nouveau les factures sélectionnées ? Cette action est définitive.", "Prélever à nouveau",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION)
return;
final List<Integer> selectedIDs = l.getSelection().getSelectedIDs();
final UpdateBuilder upd = new UpdateBuilder(l.getSource().getPrimaryTable());
upd.setObject(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME, upd.getTable().getForeignTable(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME).getUndefinedIDNumber());
upd.setObject(SaisieVenteFactureSQLElement.END2END_FIELD_NAME, "");
// don't allow to debit already payed invoices
upd.setWhere(new Where(upd.getTable().getKey(), selectedIDs).and(Where.isNull(upd.getTable().getField("DATE_REGLEMENT"))));
 
upd.getTable().getDBSystemRoot().getDataSource().execute(upd.asString());
for (final Integer id : selectedIDs)
upd.getTable().fireTableModified(id, upd.getFieldsNames());
}
}, false, true).setPredicate(IListeEvent.getNonEmptySelectionPredicate()));
this.listeFact.setOpaque(false);
this.listeFact.getListe().setModificationAllowed(true);
final JTable tableFact = this.listeFact.getListe().getJTable();
299,7 → 320,15
@Override
protected void handleAction(JButton source, ActionEvent evt) {
if (source == this.buttonModifier) {
new PanelFrame(new TextAreaTicketPanel(this.getListe().fetchSelectedRow()), "Ticket").setVisible(true);
POSConfiguration posConf = POSConfiguration.getInstance();
try {
if (posConf == null)
posConf = POSConfiguration.setInstance();
} catch (Exception e) {
ExceptionHandler.handle(source, "Impossible d'initialiser la configuration de la caisse", e);
return;
}
new PanelFrame(new TextAreaTicketPanel(posConf, this.getListe().fetchSelectedRow()), "Ticket").setVisible(true);
} else {
super.handleAction(source, evt);
}