OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 152 → Rev 151

/trunk/Modules/Module Project/src/org/openconcerto/modules/project/CmdToBrSQLInjector.java
File deleted
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/ProjectImportExport.java
File deleted
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/Module.java
1,15 → 1,8
package org.openconcerto.modules.project;
 
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
20,12 → 13,9
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
 
61,9 → 51,7
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;
import org.openconcerto.sql.model.SQLTableEvent;
import org.openconcerto.sql.model.SQLTableEvent.Mode;
71,12 → 59,9
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Link.Direction;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.SQLCreateTable;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.column.ColumnFooterRenderer;
86,13 → 71,10
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.cc.IExnClosure;
import org.openconcerto.utils.cc.IClosure;
import org.openconcerto.utils.cc.ITransformer;
import org.openconcerto.utils.i18n.TranslationManager;
 
99,8 → 81,8
public final class Module extends AbstractModule {
 
public static final String PROJECT_TABLENAME = "AFFAIRE";
private List<String> listTableAffaire = Arrays.asList("DEMANDE_PRIX", "BON_RECEPTION", "DEMANDE_ACHAT_ELEMENT", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT", "BON_DE_LIVRAISON", "COMMANDE_CLIENT",
"DEVIS", "COMMANDE", "SAISIE_ACHAT", "AVOIR_FOURNISSEUR");
private List<String> listTableAffaire = Arrays.asList("DEMANDE_PRIX", "DEMANDE_ACHAT_ELEMENT", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT", "BON_DE_LIVRAISON", "COMMANDE_CLIENT", "DEVIS", "COMMANDE",
"SAISIE_ACHAT", "AVOIR_FOURNISSEUR");
 
public Module(ModuleFactory f) throws IOException {
super(f);
108,7 → 90,7
}
 
@Override
protected void install(DBContext ctxt) throws SQLException, IOException {
protected void install(DBContext ctxt) {
super.install(ctxt);
 
if (ctxt.getLastInstalledVersion() == null) {
139,25 → 121,34
alter.addForeignColumn("ID_AFFAIRE", createTable);
}
}
 
ctxt.manipulateData(new IExnClosure<DBRoot, SQLException>() {
 
ctxt.manipulateData(new IClosure<DBRoot>() {
@Override
public void executeChecked(DBRoot input) throws SQLException {
public void executeChecked(DBRoot input) {
// Undefined Affaire
SQLTable tableAff = input.getTable(PROJECT_TABLENAME);
SQLRowValues rowVals = new SQLRowValues(tableAff);
try {
rowVals.insert();
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
}
 
// Etat Affaire
SQLTable tableTypeAffaire = input.getTable("TYPE_AFFAIRE");
rowVals = new SQLRowValues(tableTypeAffaire);
try {
rowVals.put("NOM", "Indéfini");
rowVals.insert();
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
}
 
// Etat Affaire
SQLTable tableEtatAffaire = input.getTable("ETAT_AFFAIRE");
rowVals = new SQLRowValues(tableEtatAffaire);
try {
rowVals.put("NOM", "Indéfini");
rowVals.insert();
 
180,11 → 171,14
rowVals.clear();
rowVals.put("NOM", "Dossier clos");
rowVals.insert();
} catch (SQLException exn) {
exn.printStackTrace();
}
});
 
}
});
}
}
 
}
 
313,7 → 307,6
histo.getFrame().setVisible(true);
}
}, false) {
 
@Override
public boolean enabledFor(IListeEvent evt) {
if (evt.getSelectedRows().size() == 1) {
357,7 → 350,6
histo.getFrame().setVisible(true);
}
}, false) {
 
@Override
public boolean enabledFor(IListeEvent evt) {
if (evt.getSelectedRows().size() == 1) {
390,17 → 382,13
return CollectionUtils.createSet(new FieldPath(p, "NUMERO"));
}
});
new CmdToBrSQLInjector();
 
new QuoteToOrderSQLInjector();
new QuoteToInvoiceSQLInjector();
new OrderToInvoiceSQLInjector();
}
 
public static JFrame checkAffaire(int id) {
return checkAffaire(id, true);
}
 
public static JFrame checkAffaire(int id, final boolean createCommandeClient) {
public void checkAffaire(int id) {
final SQLTable tableDevis = Configuration.getInstance().getRoot().findTable("DEVIS");
final SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
final SQLRow row = tableDevis.getRow(id);
408,44 → 396,6
if (rowAffaire == null || rowAffaire.isUndefined()) {
if (row.getInt("ID_ETAT_DEVIS") == EtatDevisSQLElement.ACCEPTE) {
// FIXME Vérifier si le devis n'est pas déjà rattaché à une affaire
 
JPanel p = new JPanel(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
p.add(new JLabel("Voulez vous intégrer ce devis sur une affaire existante?"), c);
c.gridy++;
c.gridwidth = 1;
p.add(new JLabel("Rattacher à l'affaire : "), c);
c.gridx++;
final SQLRequestComboBox box = new SQLRequestComboBox();
final ComboSQLRequest comboRequest = Configuration.getInstance().getDirectory().getElement("AFFAIRE").getComboRequest(true);
Where w = new Where(comboRequest.getPrimaryTable().getField("ID_CLIENT"), "=", row.getForeignID("ID_CLIENT"));
comboRequest.setWhere(w);
box.uiInit(comboRequest);
p.add(box, c);
c.gridy++;
c.gridx = 0;
final JButton buttonApply = new JButton("Appliquer");
JButton buttonAnnuler = new JButton("Nouvelle affaire");
p.add(buttonApply, c);
buttonApply.setEnabled(false);
box.addValueListener(new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonApply.setEnabled(box.getSelectedRow() != null);
 
}
});
c.gridx++;
p.add(buttonAnnuler, c);
final PanelFrame f = new PanelFrame(p, "Affection d'un devis à une affaire");
 
buttonAnnuler.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent ae) {
f.dispose();
final SQLTable table = tableDevis.getTable(PROJECT_TABLENAME);
final SQLRowValues rowVals = new SQLRowValues(table);
 
473,42 → 423,13
rowValsDevis.put("ID_AFFAIRE", rowVals);
 
try {
int id = rowVals.commit().getID();
row.fetchValues();
if (createCommandeClient) {
Configuration.getInstance().getDirectory().getElement(DevisSQLElement.class).transfertCommandeClient(Arrays.asList(row.asRowValues()));
EditFrame frame = new EditFrame(Configuration.getInstance().getDirectory().getElement("AFFAIRE"), EditMode.MODIFICATION);
frame.selectionId(id);
FrameUtil.showPacked(frame);
}
rowVals.commit();
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
}
}
});
 
buttonApply.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
f.dispose();
 
SQLRowValues rowValsDevis = row.asRowValues();
rowValsDevis.put("ID_AFFAIRE", box.getSelectedId());
 
try {
rowValsDevis.commit();
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
}
}
});
FrameUtil.show(f);
return f;
}
 
} else if (row.getInt("ID_ETAT_DEVIS") != EtatDevisSQLElement.ACCEPTE) {
SQLRowValues rowVals = rowAffaire.asRowValues();
rowVals.putEmptyLink("ID_DEVIS");
518,7 → 439,6
exn.printStackTrace();
}
}
return null;
}
 
List<Integer> idsAsked = new ArrayList<Integer>();
581,7 → 501,6
checkAffaire(selectedRow.getID());
}
}, false, "project.accept") {
 
public boolean enabledFor(List<SQLRowValues> selection) {
if (selection != null && selection.size() == 1) {
if (selection.get(0).getInt("ID_ETAT_DEVIS") == EtatDevisSQLElement.EN_ATTENTE) {
590,15 → 509,13
}
return false;
};
 
};
}
 
@Override
protected void setupComponents(final ComponentsContext ctxt) {
 
DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
List<String> table2check = Arrays.asList("BON_RECEPTION", "DEMANDE_PRIX", "DEMANDE_ACHAT_ELEMENT");
List<String> table2check = Arrays.asList("DEMANDE_PRIX", "DEMANDE_ACHAT_ELEMENT");
for (String table : table2check) {
if (root.contains(table)) {
SQLTable tableCR = root.getTable(table);
618,7 → 535,6
}
}
}
 
for (String table : this.listTableAffaire) {
if (!table.equalsIgnoreCase("DEVIS"))
ctxt.putAdditionalField(table, "ID_AFFAIRE");
651,152 → 567,164
}
}, MainFrame.CREATE_MENU);
 
addMenuImportExport(ctxt);
// ctxt.addMenuItem(new AbstractAction("Export Affaire") {
// @Override
// public void actionPerformed(ActionEvent e) {
// ProjectImportExport importExport = new
// ProjectImportExport(ctxt.getElement("AFFAIRE").getTable().getDBRoot());
// importExport.export();
// }
// }, MainFrame.HELP_MENU);
//
// ctxt.addMenuItem(new AbstractAction("Import Affaire") {
// @Override
// public void actionPerformed(ActionEvent e) {
// ProjectImportExport importExport = new
// ProjectImportExport(ctxt.getElement("AFFAIRE").getTable().getDBRoot());
// importExport.importProjects();
// }
// }, MainFrame.HELP_MENU);
//
// ctxt.addMenuItem(new AbstractAction("Fix ID_AFFAIRE") {
// @Override
// public void actionPerformed(ActionEvent e) {
// {
// SQLTable tableCmd = ctxt.getElement("COMMANDE_CLIENT").getTable();
// SQLSelect selBadCmd = new SQLSelect();
// selBadCmd.addSelect(tableCmd.getKey());
// selBadCmd.addSelect(tableCmd.getField("ID_AFFAIRE"));
// SQLSelectJoin joinTR = selBadCmd.addBackwardJoin("RIGHT", "tr",
// tableCmd.getTable().getTable("TR_DEVIS").getField("ID_COMMANDE_CLIENT"), null);
// SQLSelectJoin joinDevis = selBadCmd.addJoin("LEFT",
// joinTR.getJoinedTable().getField("ID_DEVIS"));
// SQLSelectJoin joinAff = selBadCmd.addBackwardJoin("LEFT", "aff",
// tableCmd.getTable().getTable("AFFAIRE").getField("ID_DEVIS"), null);
// selBadCmd.addSelect(joinAff.getJoinedTable().getKey());
//
// selBadCmd.setWhere(Where.isNull(tableCmd.getField("ID_AFFAIRE")));
// System.err.println(selBadCmd.asString());
//
// List<Object[]> result = (List<Object[]>)
// tableCmd.getDBSystemRoot().getDataSource().executeA(selBadCmd.asString());
// try {
// for (Object[] objects : result) {
// if (objects[2] != null && objects[2].toString().trim().length() > 0)
// tableCmd.getRow(((Number)
// objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number)
// objects[2]).intValue()).commit();
// }
// } catch (SQLException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//
// // List<SQLRow> list = SQLRowListRSH.execute(selBadVF);
// }
// {
// SQLTable tableVF = ctxt.getElement("SAISIE_VENTE_FACTURE").getTable();
// SQLSelect selBadVF = new SQLSelect();
// selBadVF.addSelect(tableVF.getKey());
// selBadVF.addSelect(tableVF.getField("ID_AFFAIRE"));
// SQLSelectJoin joinTR = selBadVF.addBackwardJoin("RIGHT", "tr",
// tableVF.getTable().getTable("TR_COMMANDE_CLIENT").getField("ID_SAISIE_VENTE_FACTURE"),
// null);
// SQLSelectJoin joinCmd = selBadVF.addJoin("LEFT",
// joinTR.getJoinedTable().getField("ID_COMMANDE_CLIENT"));
// selBadVF.addSelect(joinCmd.getJoinedTable().getField("ID_AFFAIRE"));
//
// selBadVF.setWhere(Where.isNull(tableVF.getField("ID_AFFAIRE")));
// System.err.println(selBadVF.asString());
// List<Object[]> result = (List<Object[]>)
// tableVF.getDBSystemRoot().getDataSource().executeA(selBadVF.asString());
// try {
// for (Object[] objects : result) {
// if (objects[2] != null && objects[2].toString().trim().length() > 0)
// tableVF.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE",
// ((Number) objects[2]).intValue()).commit();
// }
// } catch (SQLException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
// }
// }
// }, MainFrame.CREATE_MENU);
//
// ctxt.addMenuItem(new AbstractAction("Recalcul Total achat facture prorata") {
// @Override
// public void actionPerformed(ActionEvent e) {
//
// {
// final SQLTable table = ctxt.getElement("SAISIE_VENTE_FACTURE").getTable();
// SQLRowValues rowValsFact = new SQLRowValues(table);
// rowValsFact.putNulls("SOLDE", "PARTIAL", "T_HA", "T_HT");
//
// final SQLTable tableCmd = ctxt.getElement("COMMANDE_CLIENT").getTable();
// SQLRowValues rowValsCmd = new SQLRowValues(tableCmd);
// rowValsCmd.putNulls("T_HT");
//
// final SQLTable tableCmdElt = ctxt.getElement("COMMANDE_CLIENT_ELEMENT").getTable();
// SQLRowValues rowValsCmdElt = new SQLRowValues(tableCmdElt);
// rowValsCmdElt.put("ID_COMMANDE_CLIENT", rowValsCmd);
// rowValsCmdElt.putNulls("T_PA_HT", "NIVEAU");
//
// final SQLTable tableTR = table.getTable("TR_COMMANDE_CLIENT");
// SQLRowValues rowValsTR = new SQLRowValues(tableTR);
// rowValsTR.put("ID_SAISIE_VENTE_FACTURE", rowValsFact);
// rowValsTR.put("ID_COMMANDE_CLIENT", rowValsCmd);
//
// SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsFact);
// fetcher.appendSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
// @Override
// public SQLSelect transformChecked(SQLSelect input) {
// Where w = new Where(table.getField("SOLDE"), "=", Boolean.TRUE);
// w = w.or(new Where(table.getField("PARTIAL"), "=", Boolean.TRUE));
// input.setWhere(w);
// return input;
// }
// });
//
// List<SQLRowValues> rowVals = fetcher.fetch();
//
// for (SQLRowValues sqlRowValues : rowVals) {
// // Recuperation de la commande
// final Collection<SQLRowValues> referentRows = sqlRowValues.getReferentRows(tableTR);
// if (!referentRows.isEmpty()) {
// SQLRowAccessor rowTR = referentRows.iterator().next();
// SQLRowAccessor rowCmd = rowTR.getForeign("ID_COMMANDE_CLIENT");
// final long htCmd = rowCmd.getLong("T_HT");
// if (htCmd != 0) {
//
// BigDecimal totalHA = BigDecimal.ZERO;
// Collection<? extends SQLRowAccessor> elt = rowCmd.getReferentRows(tableCmdElt);
// for (SQLRowAccessor sqlRowAccessor : elt) {
// if (sqlRowAccessor.getInt("NIVEAU") == 1) {
// totalHA = totalHA.add(sqlRowAccessor.getBigDecimal("T_PA_HT"));
// }
// }
// BigDecimal prorata = new BigDecimal((double) sqlRowValues.getLong("T_HT") / (double)
// htCmd);
// try {
// sqlRowValues.createEmptyUpdateRow().put("T_HA",
// totalHA.multiply(prorata).movePointRight(2).setScale(0,
// RoundingMode.HALF_UP).longValue()).update();
// } catch (SQLException e1) {
// e1.printStackTrace();
// }
// }
// }
// }
// }
// }
// }, MainFrame.CREATE_MENU);
 
}
 
private void addMenuImportExport(final MenuContext ctxt) {
////
 
ctxt.addMenuItem(new AbstractAction("Export Affaire") {
@Override
public void actionPerformed(ActionEvent e) {
ProjectImportExport importExport = new ProjectImportExport(ctxt.getElement("AFFAIRE").getTable().getDBRoot());
importExport.export();
}
}, MainFrame.HELP_MENU);
protected void start() {
 
ctxt.addMenuItem(new AbstractAction("Import Affaire") {
@Override
public void actionPerformed(ActionEvent e) {
ProjectImportExport importExport = new ProjectImportExport(ctxt.getElement("AFFAIRE").getTable().getDBRoot());
importExport.importProjects();
}
}, MainFrame.HELP_MENU);
 
ctxt.addMenuItem(new AbstractAction("Fix ID_AFFAIRE") {
@Override
public void actionPerformed(ActionEvent e) {
{
SQLTable tableCmd = ctxt.getElement("COMMANDE_CLIENT").getTable();
SQLSelect selBadCmd = new SQLSelect();
selBadCmd.addSelect(tableCmd.getKey());
selBadCmd.addSelect(tableCmd.getField("ID_AFFAIRE"));
SQLSelectJoin joinTR = selBadCmd.addBackwardJoin("RIGHT", "tr", tableCmd.getTable().getTable("TR_DEVIS").getField("ID_COMMANDE_CLIENT"), null);
SQLSelectJoin joinDevis = selBadCmd.addJoin("LEFT", joinTR.getJoinedTable().getField("ID_DEVIS"));
SQLSelectJoin joinAff = selBadCmd.addBackwardJoin("LEFT", "aff", tableCmd.getTable().getTable("AFFAIRE").getField("ID_DEVIS"), null);
selBadCmd.addSelect(joinAff.getJoinedTable().getKey());
 
selBadCmd.setWhere(Where.isNull(tableCmd.getField("ID_AFFAIRE")));
System.err.println(selBadCmd.asString());
 
List<Object[]> result = (List<Object[]>) tableCmd.getDBSystemRoot().getDataSource().executeA(selBadCmd.asString());
try {
for (Object[] objects : result) {
if (objects[2] != null && objects[2].toString().trim().length() > 0)
tableCmd.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number) objects[2]).intValue()).commit();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
 
// List<SQLRow> list = SQLRowListRSH.execute(selBadVF);
}
{
SQLTable tableVF = ctxt.getElement("SAISIE_VENTE_FACTURE").getTable();
SQLSelect selBadVF = new SQLSelect();
selBadVF.addSelect(tableVF.getKey());
selBadVF.addSelect(tableVF.getField("ID_AFFAIRE"));
SQLSelectJoin joinTR = selBadVF.addBackwardJoin("RIGHT", "tr", tableVF.getTable().getTable("TR_COMMANDE_CLIENT").getField("ID_SAISIE_VENTE_FACTURE"), null);
SQLSelectJoin joinCmd = selBadVF.addJoin("LEFT", joinTR.getJoinedTable().getField("ID_COMMANDE_CLIENT"));
selBadVF.addSelect(joinCmd.getJoinedTable().getField("ID_AFFAIRE"));
 
selBadVF.setWhere(Where.isNull(tableVF.getField("ID_AFFAIRE")));
System.err.println(selBadVF.asString());
List<Object[]> result = (List<Object[]>) tableVF.getDBSystemRoot().getDataSource().executeA(selBadVF.asString());
try {
for (Object[] objects : result) {
if (objects[2] != null && objects[2].toString().trim().length() > 0)
tableVF.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number) objects[2]).intValue()).commit();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}, MainFrame.CREATE_MENU);
 
ctxt.addMenuItem(new AbstractAction("Recalcul Total achat facture prorata") {
@Override
public void actionPerformed(ActionEvent e) {
 
{
final SQLTable table = ctxt.getElement("SAISIE_VENTE_FACTURE").getTable();
SQLRowValues rowValsFact = new SQLRowValues(table);
rowValsFact.putNulls("SOLDE", "PARTIAL", "T_HA", "T_HT");
 
final SQLTable tableCmd = ctxt.getElement("COMMANDE_CLIENT").getTable();
SQLRowValues rowValsCmd = new SQLRowValues(tableCmd);
rowValsCmd.putNulls("T_HT");
 
final SQLTable tableCmdElt = ctxt.getElement("COMMANDE_CLIENT_ELEMENT").getTable();
SQLRowValues rowValsCmdElt = new SQLRowValues(tableCmdElt);
rowValsCmdElt.put("ID_COMMANDE_CLIENT", rowValsCmd);
rowValsCmdElt.putNulls("T_PA_HT", "NIVEAU");
 
final SQLTable tableTR = table.getTable("TR_COMMANDE_CLIENT");
SQLRowValues rowValsTR = new SQLRowValues(tableTR);
rowValsTR.put("ID_SAISIE_VENTE_FACTURE", rowValsFact);
rowValsTR.put("ID_COMMANDE_CLIENT", rowValsCmd);
 
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsFact);
fetcher.appendSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
@Override
public SQLSelect transformChecked(SQLSelect input) {
Where w = new Where(table.getField("SOLDE"), "=", Boolean.TRUE);
w = w.or(new Where(table.getField("PARTIAL"), "=", Boolean.TRUE));
input.setWhere(w);
return input;
}
});
 
List<SQLRowValues> rowVals = fetcher.fetch();
 
for (SQLRowValues sqlRowValues : rowVals) {
// Recuperation de la commande
final Collection<SQLRowValues> referentRows = sqlRowValues.getReferentRows(tableTR);
if (!referentRows.isEmpty()) {
SQLRowAccessor rowTR = referentRows.iterator().next();
SQLRowAccessor rowCmd = rowTR.getForeign("ID_COMMANDE_CLIENT");
final long htCmd = rowCmd.getLong("T_HT");
if (htCmd != 0) {
 
BigDecimal totalHA = BigDecimal.ZERO;
Collection<? extends SQLRowAccessor> elt = rowCmd.getReferentRows(tableCmdElt);
for (SQLRowAccessor sqlRowAccessor : elt) {
if (sqlRowAccessor.getInt("NIVEAU") == 1) {
totalHA = totalHA.add(sqlRowAccessor.getBigDecimal("T_PA_HT"));
}
}
BigDecimal prorata = new BigDecimal((double) sqlRowValues.getLong("T_HT") / (double) htCmd);
try {
sqlRowValues.createEmptyUpdateRow().put("T_HA", totalHA.multiply(prorata).movePointRight(2).setScale(0, RoundingMode.HALF_UP).longValue()).update();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
}
}
}
}, MainFrame.CREATE_MENU);
}
 
@Override
protected void start() {
 
final JComponent quoteComponent = createQuotePanel();
final JComponent orderComponent = createOrderPanel();
MainFrame.getInstance().getTabbedPane().addTab("Commandes en cours", orderComponent);
/trunk/Modules/Module Project/.settings/org.eclipse.jdt.core.prefs
1,7 → 1,11
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.source=1.6
/trunk/Modules/Module Project/.classpath
2,6 → 2,6
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenConcerto"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Time Tracking/src/org/openconcerto/modules/timetracking/Module.java
3,7 → 3,6
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
60,7 → 59,7
}
 
@Override
protected void install(DBContext ctxt) throws SQLException, IOException {
protected void install(DBContext ctxt) {
super.install(ctxt);
if (!ctxt.getRoot().findTable("AFFAIRE").contains("ENVOI_MAIL_AUTO")) {
final AlterTableRestricted alter = ctxt.getAlterTable("AFFAIRE");
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/panel/FacturesAboPanel.java
75,13 → 75,11
 
idMvt = sqlRowAccessor.getInt("ID_MOUVEMENT");
 
if (idMvt > 1) {
// on supprime tout ce qui est lié à la facture
System.err.println("Archivage des fils");
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE");
eltEcr.archiveMouvementProfondeur(idMvt, false);
}
}
 
System.err.println("Regeneration des ecritures");
if (idMvt > 1) {
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/panel/AboPanel.java
240,7 → 240,6
SubscriptionChecker checker = new SubscriptionChecker(elt.getTable());
Map<SQLRow, Calendar> listLastCreateElt = checker.check();
 
Date today = new Date();
for (SQLRow rowAbonnement : listLastCreateElt.keySet()) {
 
// FIXME On recupere des abonnements archives (à tester sur BD 2Si)
250,9 → 249,8
Calendar date = listLastCreateElt.get(rowAbonnement);
if (date == null) {
date = rowsCmd.getDate("DATE");
date.add(Calendar.MONTH, rowAbonnement.getInt("NB_MOIS_" + type));
}
date.add(Calendar.MONTH, rowAbonnement.getInt("NB_MOIS_" + type));
while (date.getTime().compareTo(today) < 0) {
 
// Si l'abonnement n'est pas expiré
if (rowAbonnement.getObject("DATE_FIN_" + type) == null || date.compareTo(rowAbonnement.getDate("DATE_FIN_" + type)) <= 0) {
272,9 → 270,7
ExceptionHandler.handle("Erreur lors de la création " + elt.getSingularName() + " d'abonnement.", exn);
}
}
date.add(Calendar.MONTH, rowAbonnement.getInt("NB_MOIS_" + type));
}
}
}
}
}
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/Module.java
2,7 → 2,6
 
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Calendar;
 
import javax.swing.AbstractAction;
50,7 → 49,7
}
 
@Override
protected void install(DBContext ctxt) throws SQLException, IOException {
protected void install(DBContext ctxt) {
super.install(ctxt);
 
if (ctxt.getLastInstalledVersion() == null) {
83,6 → 82,21
createTable.addColumn("NB_MOIS_COMMANDE", "int DEFAULT 3");
createTable.addColumn("CREATE_COMMANDE", "boolean DEFAULT false");
 
// ctxt.manipulateData(new IClosure<DBRoot>() {
// @Override
// public void executeChecked(DBRoot input) {
// // Undefined Affaire
// SQLRowValues rowVals = new SQLRowValues(input.getTable("ABONNEMENT"));
// try {
// rowVals.insert();
// } catch (SQLException exn) {
// // TODO Bloc catch auto-généré
// exn.printStackTrace();
// }
//
// }
// });
 
AlterTableRestricted alterNumero = ctxt.getAlterTable("NUMEROTATION_AUTO");
alterNumero.addVarCharColumn("ABONNEMENT_FORMAT", 128);
alterNumero.addIntegerColumn("ABONNEMENT_START", 1);
99,9 → 113,6
alterCmd.addForeignColumn("ID_ABONNEMENT", createTable);
alterCmd.addColumn("CREATION_AUTO_VALIDER", "boolean DEFAULT false");
 
ctxt.executeSQL();
SQLRowValues rowVals = new SQLRowValues(ctxt.getRoot().getTable("ABONNEMENT"));
rowVals.insert();
}
 
}
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/SubscriptionChecker.java
47,8 → 47,6
vals.put("NUMERO", null);
vals.put("DATE", null);
vals.put("ID_ABONNEMENT", null);
vals.put("PREVISIONNELLE", null);
vals.put("CREATION_AUTO_VALIDER", null);
 
final SQLRowValuesListFetcher fetcher = new SQLRowValuesListFetcher(vals);
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
94,7 → 92,7
Calendar calStartFact = sqlRow.getDate("DATE_DEBUT_" + this.type);
SQLRowValues rowFact = map.get(sqlRow.getID());
if (rowFact != null) {
if (rowFact.getObject("PREVISIONNELLE") != null && !rowFact.getBoolean("PREVISIONNELLE")) {
if (rowFact.getObject("CREATION_AUTO_VALIDER") != null && rowFact.getBoolean("CREATION_AUTO_VALIDER")) {
calStartFact = rowFact.getDate("DATE");
} else {
// Si le dernier element de l'abonnement n'a pas été validé on ne crée pas