OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Comparer les révisions

Ignorer les espaces blanc Révision 169 → Révision 170

/trunk/Modules/Module Project/src/org/openconcerto/modules/project/panel/HistoriqueAffaireBilanPanel.java
Nouveau fichier
0,0 → 1,288
package org.openconcerto.modules.project.panel;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Collection;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
 
import org.openconcerto.erp.modules.ModuleFactory;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.ITableModel;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.GestionDevise;
 
public class HistoriqueAffaireBilanPanel extends JPanel {
 
private DecimalFormat decimalFormat = new DecimalFormat("0.00");
 
private double pourcentCommande = 0;
private final JLabel labelPourcentCommande = new JLabel("", SwingConstants.RIGHT);
 
private long montantCommandeClient = 0;
private final JLabel labelCommandeClient = new JLabel("", SwingConstants.RIGHT);
 
private long montantBudget = 0;
private final JLabel labelBudget = new JLabel("", SwingConstants.RIGHT);
 
private long montantCommande = 0;
private final JLabel labelCommande = new JLabel("", SwingConstants.RIGHT);
 
private long montantCommandeP = 0;
private final JLabel labelCommandeP = new JLabel("", SwingConstants.RIGHT);
 
private long montantFacturer = 0;
private final JLabel labelFacturer = new JLabel("", SwingConstants.RIGHT);
 
private long montantRegler = 0;
private final JLabel labelMontantRegler = new JLabel("", SwingConstants.RIGHT);
 
private long montantRemise = 0;
 
private long montantRestantFacturer = 0;
private final JLabel labelRestantFacturer = new JLabel("", SwingConstants.RIGHT);
 
private final JLabel labelAvoir = new JLabel("");
private String motifAvoir = "";
 
private long montantAchat = 0;
private final JLabel labelAchat = new JLabel("", SwingConstants.RIGHT);
 
private final JLabel labelPercentBilan = new JLabel("", SwingConstants.RIGHT);
 
private final JLabel labelPercentMargeHT = new JLabel("", SwingConstants.RIGHT);
 
private final JLabel labelPercentMBBilan = new JLabel("", SwingConstants.RIGHT);
 
private final JLabel labelPercentMBAchat = new JLabel("", SwingConstants.RIGHT);
 
private static ModuleFactory factory;
 
public HistoriqueAffaireBilanPanel() {
super();
 
setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.insets = new Insets(2, 2, 2, 75);
c.gridx = GridBagConstraints.RELATIVE;
 
c.gridwidth = GridBagConstraints.REMAINDER;
add(this.labelAvoir, c);
 
c.gridy++;
c.gridwidth = 1;
add(this.labelCommandeClient, c);
// add(this.labelCommandeP, c);
add(this.labelPercentMargeHT, c);
add(this.labelFacturer, c);
 
c.gridy++;
// add(this.labelPourcentCommande, c);
add(this.labelBudget, c);
add(this.labelCommande, c);
add(this.labelPercentMBBilan, c);
// add(this.labelMontantRegler, c);
 
c.gridy++;
// add(this.labelPercentBilan, c);
// add(this.labelPourcentCommande, c);
// add(this.labelAchat, c);
// add(this.labelPercentMBAchat, c);
// add(this.labelRestantFacturer, c);
 
// add(this.labelDemande);
//
// add(this.labelDemandeM);
//
// add(this.labelDemandeT);
//
// add(this.labelCommande);
//
// add(this.labelCommandeMonteur);
//
// add(this.labelCommandeTransporteur);
}
 
public synchronized void updateBilanPreBilan(final IListe listeCmdF) {
// if (rowAffaire == null || rowAffaire.isUndefined()) {
// this.montantCommande = 0;
// this.montantCommandeP = 0;
// return;
// }
long montant = 0;
 
if (listeCmdF != null) {
// Commande F
for (int i = 0; i < listeCmdF.getRowCount(); i++) {
final SQLRowValues rowAt = ITableModel.getLine(listeCmdF.getModel(), i).getRow();
 
montant += rowAt.getLong("T_HT");
}
}
 
this.montantCommande = montant;
 
updateLabels();
}
 
public synchronized void updateFacturer(final IListe liste, final IListe listeAvoir) {
// List<SQLRowAccessor> rows =
// liste.getSource().getLine(viewIndex)SelectedRows()Model().get;
if (liste == null || listeAvoir == null) {
return;
}
 
String motif = "";
long montant = 0;
BigDecimal montantRegler = BigDecimal.ZERO;
long montantRemise = 0;
for (int i = 0; i < liste.getRowCount(); i++) {
final SQLRowValues rowAt = ITableModel.getLine(liste.getModel(), i).getRow();
long ht = rowAt.getLong("T_HT");
long ttc = rowAt.getLong("T_TTC");
montant += ht;
 
// BigDecimal regler = new
// BigDecimal(calc.getReglement(rowAt.getForeign("ID_MOUVEMENT").getInt("ID_PIECE"),
// null));
// if (ht != ttc) {
// if (rowAt.getDate("DATE").getTime().compareTo(date2014) <= 0) {
// regler = regler.divide(new BigDecimal(1.196D), MathContext.DECIMAL128);
// } else {
// regler = regler.divide(new BigDecimal(1.2D), MathContext.DECIMAL128);
// }
// // regler = regler.divide(new BigDecimal(1.2D), MathContext.DECIMAL128);
// }
// montantRegler = montantRegler.add(regler);
 
}
 
// EncoursCalculator calc = new EncoursCalculator();
for (int i = 0; i < listeAvoir.getRowCount(); i++) {
final SQLRowValues rowAt = ITableModel.getLine(listeAvoir.getModel(), i).getRow();
if (rowAt.getBoolean("A_DEDUIRE")) {
montant -= rowAt.getLong("MONTANT_HT");
// montantRegler -= rowAt.getLong("MONTANT_TTC");
}
// else {
// long long1 = calc.getMontantAvoir(rowAt);
// montant -= long1;
// montantRemise += long1;
// motif += rowAt.getString("MOTIF") + "(-" + GestionDevise.currencyToString(long1,
// true) + " €)";
// }
}
this.motifAvoir = motif;
this.montantFacturer = montant;
this.montantRemise = montantRemise;
this.montantRegler = montantRegler.setScale(0, RoundingMode.HALF_UP).longValue();
updateLabels();
}
 
public synchronized void updateAchat(final IListe listeAchat, final IListe listeAchatAvoir) {
if (listeAchat == null) {
return;
}
final ITableModel model = listeAchat.getModel();
final ITableModel modelAvoir = listeAchatAvoir.getModel();
final Runnable r = new Runnable() {
@Override
public void run() {
// TODO Raccord de méthode auto-généré
long m = 0;
for (int i = 0; i < model.getRowCount(); i++) {
final SQLRowValues rowAt = model.getRow(i).getRow();
m += rowAt.getLong("MONTANT_HT");
}
 
for (int i = 0; i < modelAvoir.getRowCount(); i++) {
final SQLRowValues rowAt = modelAvoir.getRow(i).getRow();
m -= rowAt.getLong("MONTANT_HT");
}
montantAchat = m;
 
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
updateLabels();
}
});
}
};
model.invokeLater(r);
modelAvoir.invokeLater(r);
 
}
 
public synchronized void updateCommandeClient(SQLRowAccessor rowAff) {
if (rowAff != null) {
Collection<? extends SQLRowAccessor> rowCmd = rowAff.getReferentRows(rowAff.getTable().getTable("COMMANDE_CLIENT"));
long cmd = 0;
long b = 0;
for (SQLRowAccessor r : rowCmd) {
cmd += r.getLong("T_HT");
Collection<? extends SQLRowAccessor> ref = r.getReferentRows(rowAff.getTable().getTable("CHIFFRAGE_COMMANDE_CLIENT"));
for (SQLRowAccessor sqlRowAccessor : ref) {
b += sqlRowAccessor.getBigDecimal("T_PA_HT").setScale(0, RoundingMode.HALF_UP).longValue();
}
}
 
this.montantBudget = b;
this.montantCommandeClient = cmd;
updateLabels();
}
}
 
public synchronized void updateDevis(SQLRowAccessor rowAff) {
if (rowAff != null) {
Collection<? extends SQLRowAccessor> rowCmd = rowAff.getReferentRows(rowAff.getTable().getTable("DEVIS"));
long cmd = 0;
for (SQLRowAccessor r : rowCmd) {
cmd += r.getLong("T_HA");
}
// this.montantBudget = cmd;
updateLabels();
}
}
 
private void updateLabels() {
long mbP = this.montantCommandeClient - this.montantCommandeP;
final long mbB = this.montantCommandeClient - this.montantCommande;
long mbA = this.montantFacturer - this.montantAchat;
 
final double percentMBPreBilan = Math.round((this.montantCommandeClient == 0 ? 0 : (double) mbP / (double) this.montantCommandeClient) * 10000.0D) / 100.0D;
final double percentMBBilan = Math.round((this.montantCommandeClient == 0 ? 0 : (double) mbB / (double) this.montantCommandeClient) * 10000.0D) / 100.0D;
final double percentMBAchat = Math.round((this.montantFacturer == 0 || this.montantAchat == 0 ? 0 : (double) mbA / (double) this.montantFacturer) * 10000.0D) / 100.0D;
 
SwingUtilities.invokeLater(new Runnable() {
public void run() {
HistoriqueAffaireBilanPanel.this.labelAvoir.setText(motifAvoir);
HistoriqueAffaireBilanPanel.this.labelPourcentCommande.setText(decimalFormat.format(pourcentCommande) + "% des commandes livrées");
 
// HistoriqueAffaireBilanPanel.this.labelPercentMBPreBilan.setText(decimalFormat.format(percentMBPreBilan)
// + "% MB Prébilan");
HistoriqueAffaireBilanPanel.this.labelPercentMBBilan.setText(decimalFormat.format(percentMBBilan) + "% MB sur commande");
HistoriqueAffaireBilanPanel.this.labelPercentMBAchat.setText(decimalFormat.format(percentMBAchat) + "% MB Achats");
HistoriqueAffaireBilanPanel.this.labelCommandeClient.setText("Montant du marché : " + GestionDevise.currencyToString(montantCommandeClient) + "€");
HistoriqueAffaireBilanPanel.this.labelFacturer.setText("Montant facturé : " + GestionDevise.currencyToString(montantFacturer) + "€");
HistoriqueAffaireBilanPanel.this.labelAchat.setText("Total Achats : " + GestionDevise.currencyToString(montantAchat) + "€");
HistoriqueAffaireBilanPanel.this.labelCommandeP.setText("Total PréBilan : " + GestionDevise.currencyToString(montantCommandeP) + "€");
HistoriqueAffaireBilanPanel.this.labelCommande.setText("Total Commandes F. : " + GestionDevise.currencyToString(montantCommande) + "€");
HistoriqueAffaireBilanPanel.this.labelBudget.setText("Budget chiffré à : " + GestionDevise.currencyToString(montantBudget) + "€");
HistoriqueAffaireBilanPanel.this.labelMontantRegler.setText("Règlements effectués : " + GestionDevise.currencyToString(montantRegler) + "€");
HistoriqueAffaireBilanPanel.this.labelRestantFacturer.setText("Reste à facturer : " + GestionDevise.currencyToString(montantCommandeClient - montantFacturer - montantRemise) + "€");
HistoriqueAffaireBilanPanel.this.labelPercentMargeHT.setText("Marge HT : " + GestionDevise.currencyToString(mbB) + "€");
}
});
 
}
}
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/Module.java
375,11 → 375,16
 
@Override
protected Object show_(SQLRowAccessor r) {
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(elt.getTable().getTable("AFFAIRE"));
if (rows.size() == 1) {
return rows.iterator().next().getString("NUMERO");
final SQLRowAccessor foreignAff = r.getForeign("ID_AFFAIRE");
if (foreignAff != null && !foreignAff.isUndefined()) {
return foreignAff.getString("NUMERO");
} else {
return "";
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(elt.getTable().getTable("AFFAIRE"));
if (rows.size() == 1) {
return rows.iterator().next().getString("NUMERO");
} else {
return "";
}
}
}
 
386,8 → 391,9
@Override
public Set<FieldPath> getPaths() {
SQLTable table = elt.getTable();
Path p = new Path(table).add(table.getTable("AFFAIRE"), Direction.REFERENT);
return CollectionUtils.createSet(new FieldPath(p, "NUMERO"));
Path pDev = new Path(table).add(table.getField("ID_AFFAIRE"));
Path pAff = new Path(table).add(table.getTable("AFFAIRE"), Direction.REFERENT);
return CollectionUtils.createSet(new FieldPath(pDev, "NUMERO"), new FieldPath(pAff, "NUMERO"));
}
});
new CmdToBrSQLInjector();
499,9 → 505,12
 
try {
rowValsDevis.commit();
row.fetchValues();
if (createCommandeClient) {
Configuration.getInstance().getDirectory().getElement(DevisSQLElement.class).transfertCommandeClient(Arrays.asList(row.asRowValues()));
}
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
ExceptionHandler.handle("Erreur lors de la création de la commande client!", exn);
}
}
});
673,61 → 682,61
importExport.importProjects();
}
}, MainFrame.HELP_MENU);
if (false) {
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());
 
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());
 
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<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"));
 
// 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();
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();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}, MainFrame.CREATE_MENU);
 
}, MainFrame.CREATE_MENU);
}
ctxt.addMenuItem(new AbstractAction("Recalcul Total achat facture prorata") {
@Override
public void actionPerformed(ActionEvent e) {
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/ProjectHistory.java
3,17 → 3,10
*/
package org.openconcerto.modules.project;
 
import java.awt.Component;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
20,9 → 13,9
import java.util.List;
import java.util.Map;
 
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
 
29,17 → 22,22
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.reports.history.ui.ListeHistoriquePanel;
import org.openconcerto.erp.core.supplychain.order.action.ImportProductsToOrder;
import org.openconcerto.modules.project.panel.HistoriqueAffaireBilanPanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLBase;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.SQLTableEvent;
import org.openconcerto.sql.model.SQLTableModifiedListener;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.sql.view.IListPanel;
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.PanelFrame;
import org.openconcerto.ui.SwingThreadUtils;
import org.openconcerto.ui.state.WindowStateManager;
import org.openconcerto.utils.cc.ITransformer;
 
public class ProjectHistory {
private PanelFrame panelFrame;
63,12 → 61,16
final Map<String, List<String>> mapList = new LinkedHashMap<String, List<String>>();
mapList.put("Devis", Arrays.asList("DEVIS"));
mapList.put("Bons de commande", Arrays.asList("COMMANDE_CLIENT"));
mapList.put("Chiffrage", Arrays.asList("CHIFFRAGE_COMMANDE_CLIENT"));
mapList.put("Factures", Arrays.asList("SAISIE_VENTE_FACTURE"));
mapList.put("Avoirs", Arrays.asList("AVOIR_CLIENT"));
mapList.put("Demandes d'achat", Arrays.asList("DEMANDE_ACHAT_ELEMENT"));
mapList.put("Demandes de prix", Arrays.asList("DEMANDE_PRIX"));
mapList.put("Commandes", Arrays.asList("COMMANDE"));
mapList.put("Bons de réception", Arrays.asList("BON_RECEPTION"));
mapList.put("Achats", Arrays.asList("SAISIE_ACHAT"));
// mapList.put("Factures fournisseurs", Arrays.asList("FACTURE_FOURNISSEUR"));
mapList.put("Avoirs fournisseurs", Arrays.asList("AVOIR_FOURNISSEUR"));
 
if (Configuration.getInstance().getRoot().findTable("AFFAIRE_TEMPS") != null) {
mapList.put("Temps", Arrays.asList("AFFAIRE_TEMPS"));
76,12 → 78,31
 
mapList.putAll(moduleTab);
 
final HistoriqueAffaireBilanPanel bilanPanel = new HistoriqueAffaireBilanPanel();
 
final ComboSQLRequest request = new org.openconcerto.sql.request.ComboSQLRequest(b.getTable("AFFAIRE"), Arrays.asList("NUMERO", "ID_CLIENT"));
if (b.getTable("AFFAIRE").contains("ID_SOCIETE_COMMON")) {
 
final int socID = comptaPropsConfiguration.getSocieteID();
request.setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
@Override
public SQLSelect transformChecked(SQLSelect input) {
Where w = new Where(b.getTable("AFFAIRE").getField("ID_SOCIETE_COMMON"), "=", (Object) null).or(new Where(b.getTable("AFFAIRE").getField("ID_SOCIETE_COMMON"), "=", 1))
.or(new Where(b.getTable("AFFAIRE").getField("ID_SOCIETE_COMMON"), "=", socID));
 
input.andWhere(w);
return input;
}
});
}
request.setUndefLabel("Toutes les affaires");
request.setFieldSeparator(" ");
Map<String, String> splitter = new HashMap<String, String>();
splitter.put("DEMANDE_ACHAT_ELEMENT", "ID_FAMILLE_ARTICLE");
Map<SQLTable, SQLField> fieldLink = new HashMap<SQLTable, SQLField>();
fieldLink.put(b.getTable("CHIFFRAGE_COMMANDE_CLIENT"), b.getTable("CHIFFRAGE_COMMANDE_CLIENT").getField("ID_COMMANDE_CLIENT"));
this.listPanel = new ListeHistoriquePanel("Affaires", request, mapList, bilanPanel, fieldLink, "Toutes les affaires", true, null, null, splitter);
 
this.listPanel = new ListeHistoriquePanel("Affaires", request, mapList, null, null, "Toutes les affaires", true, null, null);
 
final IListPanel listeDevis = listPanel.getIListePanelFromTableName("DEVIS");
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridy = 4;
97,43 → 118,6
}
});
 
final IListPanel listeDmdAchat = listPanel.getIListePanelFromTableName("DEMANDE_ACHAT_ELEMENT");
PredicateRowAction actionDrop = new PredicateRowAction(new AbstractAction("Importer depuis Fichier Inventor") {
 
@Override
public void actionPerformed(ActionEvent e) {
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
final FileDialog fd = new FileDialog(frame, "Import fichier inventor", FileDialog.LOAD);
fd.setFilenameFilter(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".xls");
}
});
fd.setVisible(true);
if (fd.getFile() != null) {
 
ImportProductsToOrder importer = new ImportProductsToOrder();
 
int a = JOptionPane.showConfirmDialog(frame, "Etes vous sûr de vouloir importer ces éléments dans l'affaire N°" + listPanel.getSelectedRow().getString("NUMERO") + "?",
"Import invertor", JOptionPane.YES_NO_OPTION);
if (a == JOptionPane.YES_OPTION) {
importer.setRowAffaire(listPanel.getSelectedRow());
try {
importer.importFile(new File(fd.getDirectory(), fd.getFile()), b.getTable("DEMANDE_ACHAT_ELEMENT").getDBRoot());
listeDmdAchat.getListe().getModel().updateAll();
} catch (IOException e1) {
org.openconcerto.utils.ExceptionHandler.handle("Erreur lors de l'import du fichier!", e1);
} catch (SQLException e1) {
org.openconcerto.utils.ExceptionHandler.handle("Erreur lors de l'import du fichier!", e1);
}
}
}
}
}, true);
actionDrop.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
listeDmdAchat.getListe().addIListeAction(actionDrop);
 
final IListPanel listeCmd = listPanel.getIListePanelFromTableName("COMMANDE_CLIENT");
final ProjectHistoryCmdBottomPanel cmdPanel = new ProjectHistoryCmdBottomPanel();
 
163,13 → 147,95
// History
this.panelFrame = new PanelFrame(this.listPanel, "Historique affaires");
this.panelFrame.addWindowListener(new WindowAdapter() {
 
public void windowClosing(WindowEvent e) {
listPanel.removeAllTableListener();
};
 
});
 
this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 
final SQLTableModifiedListener cmdClientListener = new SQLTableModifiedListener() {
 
@Override
public void tableModified(SQLTableEvent evt) {
if (bilanPanel != null) {
final SQLRowAccessor selectedRow = ProjectHistory.this.listPanel.getSelectedRow();
if (selectedRow != null) {
bilanPanel.updateCommandeClient(selectedRow.asRow());
}
}
}
};
final SQLTableModifiedListener devisListener = new SQLTableModifiedListener() {
 
@Override
public void tableModified(SQLTableEvent evt) {
if (bilanPanel != null) {
final SQLRowAccessor selectedRow = ProjectHistory.this.listPanel.getSelectedRow();
if (selectedRow != null) {
bilanPanel.updateDevis(selectedRow.asRow());
}
}
}
};
this.panelFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
listPanel.removeAllTableListener();
b.getTable("COMMANDE_CLIENT").removeTableModifiedListener(cmdClientListener);
b.getTable("DEVIS").removeTableModifiedListener(devisListener);
};
});
 
b.getTable("COMMANDE_CLIENT").addTableModifiedListener(cmdClientListener);
b.getTable("DEVIS").addTableModifiedListener(devisListener);
 
this.listPanel.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent arg0) {
 
final SQLRowAccessor selectedRow = ProjectHistory.this.listPanel.getSelectedRow();
if (selectedRow != null) {
bilanPanel.updateCommandeClient(selectedRow.asRow());
bilanPanel.updateDevis(selectedRow.asRow());
bilanPanel.updateBilanPreBilan(ProjectHistory.this.listPanel.getIListeFromTableName("COMMANDE"));
}
}
});
 
this.listPanel.addListenerTable(new TableModelListener() {
public void tableChanged(TableModelEvent arg0) {
final SQLRowAccessor selectedRow = ProjectHistory.this.listPanel.getSelectedRow();
if (selectedRow != null) {
bilanPanel.updateBilanPreBilan(ProjectHistory.this.listPanel.getIListeFromTableName("COMMANDE"));
}
}
}, "COMMANDE");
 
this.listPanel.addListenerTable(new TableModelListener() {
public void tableChanged(TableModelEvent arg0) {
bilanPanel.updateAchat(ProjectHistory.this.listPanel.getIListeFromTableName("SAISIE_ACHAT"), ProjectHistory.this.listPanel.getIListeFromTableName("AVOIR_FOURNISSEUR"));
}
}, "SAISIE_ACHAT");
this.listPanel.addListenerTable(new TableModelListener() {
public void tableChanged(TableModelEvent arg0) {
bilanPanel.updateAchat(ProjectHistory.this.listPanel.getIListeFromTableName("SAISIE_ACHAT"), ProjectHistory.this.listPanel.getIListeFromTableName("AVOIR_FOURNISSEUR"));
}
}, "AVOIR_FOURNISSEUR");
 
this.listPanel.addListenerTable(new TableModelListener() {
public void tableChanged(TableModelEvent arg0) {
bilanPanel.updateFacturer(ProjectHistory.this.listPanel.getIListeFromTableName("SAISIE_VENTE_FACTURE"), ProjectHistory.this.listPanel.getIListeFromTableName("AVOIR_CLIENT"));
}
}, "SAISIE_VENTE_FACTURE");
 
this.listPanel.addListenerTable(new TableModelListener() {
public void tableChanged(TableModelEvent arg0) {
bilanPanel.updateFacturer(ProjectHistory.this.listPanel.getIListeFromTableName("SAISIE_VENTE_FACTURE"), ProjectHistory.this.listPanel.getIListeFromTableName("AVOIR_CLIENT"));
}
}, "AVOIR_CLIENT");
}
 
public PanelFrame getFrame() {
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/translation_fr.xml
1,3 → 1,3
<translation lang="fr">
<action id="project.accept" label="Marquer comme accepté" />
<action id="project.accept" label="Marquer comme accepté et transfert en commande client" />
</translation>
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/element/ProjectSQLElement.java
8,6 → 8,7
 
import javax.swing.SwingUtilities;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.sql.Configuration;
16,7 → 17,10
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.request.ComboSQLRequest;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.JUniqueTextField;
import org.openconcerto.sql.view.EditFrame;
24,6 → 28,7
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.cc.ITransformer;
 
public class ProjectSQLElement extends ComptaSQLConfElement {
 
35,6 → 40,9
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_CLIENT");
if (getTable().contains("ID_SOCIETE_COMMON")) {
l.add("ID_SOCIETE_COMMON");
}
l.add("ID_TYPE_AFFAIRE");
l.add("NUMERO");
l.add("ID_ETAT_AFFAIRE");
43,6 → 51,25
return l;
}
 
protected void _initComboRequest(ComboSQLRequest req) {
super._initComboRequest(req);
if (getTable().contains("ID_SOCIETE_COMMON")) {
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
final int socID = comptaPropsConfiguration.getSocieteID();
req.setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
Where w = new Where(getTable().getField("ID_SOCIETE_COMMON"), "=", (Object) null).or(new Where(getTable().getField("ID_SOCIETE_COMMON"), "=", 1))
.or(new Where(getTable().getField("ID_SOCIETE_COMMON"), "=", socID));
 
input.andWhere(w);
return input;
}
});
}
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
77,7 → 104,9
this.addView("ID_CLIENT", "1;" + REQ);
this.addView("ID_COMMERCIAL", "1");
this.addView("ID_DEVIS", "1");
 
if (getTable().contains("ID_SOCIETE_COMMON")) {
this.addView("ID_SOCIETE_COMMON", "1");
}
this.addView("ID_TYPE_AFFAIRE", "1;left");
final ElementComboBox boxEtatAffaire = new ElementComboBox();
this.addView(boxEtatAffaire, "ID_ETAT_AFFAIRE", "1;left;" + REQ);
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/element/ProjectStateSQLElement.java
1,6 → 1,6
package org.openconcerto.modules.project.element;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
9,11 → 9,11
import org.openconcerto.utils.ListMap;
 
public class ProjectStateSQLElement extends ComptaSQLConfElement {
public static int A_TRAITER = 2;
public static int EN_COURS = 3;
public static int TRAITEMENT_TERMINE = 4;
public static int A_FACTURER = 5;
public static int DOSSIER_CLOS = 6;
public static final int A_TRAITER = 2;
public static final int EN_COURS = 3;
public static final int TRAITEMENT_TERMINE = 4;
public static final int A_FACTURER = 5;
public static final int DOSSIER_CLOS = 6;
 
public ProjectStateSQLElement() {
super("ETAT_AFFAIRE", "un état affaire", "états affaires");
21,16 → 21,12
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
return Arrays.asList("NOM");
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
return Arrays.asList("NOM");
}
 
@Override
50,6 → 46,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".state";
return "project.state";
}
}
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/element/ProjectTypeSQLElement.java
1,6 → 1,6
package org.openconcerto.modules.project.element;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
16,16 → 16,12
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
return Arrays.asList("NOM");
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
return l;
return Arrays.asList("NOM");
}
 
@Override
45,6 → 41,6
 
@Override
protected String createCode() {
return createCodeFromPackage() + ".kind";
return "project.type";
}
}