OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 155 → Rev 156

/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);
}
}
});