OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 177
Line 13... Line 13...
13
 
13
 
14
 package org.openconcerto.erp.core.sales.invoice.ui;
14
 package org.openconcerto.erp.core.sales.invoice.ui;
15
 
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.config.Gestion;
17
import org.openconcerto.erp.config.Gestion;
18
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
-
 
19
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
18
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
20
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
19
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
21
import org.openconcerto.erp.core.customerrelationship.customer.element.RelanceSQLElement;
-
 
22
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
20
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
23
import org.openconcerto.erp.core.finance.payment.component.EncaisserMontantSQLComponent;
21
import org.openconcerto.erp.core.finance.payment.component.EncaisserMontantSQLComponent;
-
 
22
import org.openconcerto.erp.core.sales.invoice.element.EcheanceClientSQLElement;
24
import org.openconcerto.erp.rights.ComptaUserRight;
23
import org.openconcerto.erp.rights.ComptaUserRight;
25
import org.openconcerto.erp.rights.NXRights;
24
import org.openconcerto.erp.rights.NXRights;
26
import org.openconcerto.sql.Configuration;
25
import org.openconcerto.sql.Configuration;
27
import org.openconcerto.sql.element.SQLElement;
26
import org.openconcerto.sql.element.SQLElement;
28
import org.openconcerto.sql.model.SQLBase;
27
import org.openconcerto.sql.model.SQLBase;
29
import org.openconcerto.sql.model.SQLRow;
28
import org.openconcerto.sql.model.SQLRow;
30
import org.openconcerto.sql.model.SQLRowValues;
29
import org.openconcerto.sql.model.SQLRowValues;
31
import org.openconcerto.sql.model.SQLTable;
30
import org.openconcerto.sql.model.SQLTable;
32
import org.openconcerto.sql.users.rights.UserRightsManager;
31
import org.openconcerto.sql.users.rights.UserRightsManager;
33
import org.openconcerto.sql.view.EditFrame;
32
import org.openconcerto.sql.view.EditFrame;
34
import org.openconcerto.sql.view.EditPanelListener;
-
 
35
import org.openconcerto.sql.view.IListPanel;
33
import org.openconcerto.sql.view.IListPanel;
36
import org.openconcerto.sql.view.IListener;
34
import org.openconcerto.sql.view.IListener;
37
import org.openconcerto.sql.view.list.IListe;
35
import org.openconcerto.sql.view.list.IListe;
38
import org.openconcerto.ui.DefaultGridBagConstraints;
36
import org.openconcerto.ui.DefaultGridBagConstraints;
39
import org.openconcerto.utils.ExceptionHandler;
-
 
40
 
37
 
41
import java.awt.GridBagConstraints;
38
import java.awt.GridBagConstraints;
42
import java.awt.GridBagLayout;
39
import java.awt.GridBagLayout;
43
import java.awt.event.ActionEvent;
40
import java.awt.event.ActionEvent;
44
import java.awt.event.ActionListener;
41
import java.awt.event.ActionListener;
45
import java.awt.event.MouseAdapter;
42
import java.awt.event.MouseAdapter;
46
import java.awt.event.MouseEvent;
43
import java.awt.event.MouseEvent;
47
import java.sql.SQLException;
-
 
48
import java.util.ArrayList;
44
import java.util.ArrayList;
49
import java.util.Arrays;
45
import java.util.Arrays;
50
import java.util.Date;
-
 
51
import java.util.List;
46
import java.util.List;
52
 
47
 
53
import javax.swing.JButton;
48
import javax.swing.JButton;
54
import javax.swing.JCheckBox;
49
import javax.swing.JCheckBox;
55
import javax.swing.JOptionPane;
50
import javax.swing.JOptionPane;
Line 128... Line 123...
128
        if (UserRightsManager.getCurrentUserRights().haveRight(NXRights.GESTION_ENCAISSEMENT.getCode())) {
123
        if (UserRightsManager.getCurrentUserRights().haveRight(NXRights.GESTION_ENCAISSEMENT.getCode())) {
129
            c.gridx++;
124
            c.gridx++;
130
            this.add(this.relancer, c);
125
            this.add(this.relancer, c);
131
            this.relancer.addActionListener(new ActionListener() {
126
            this.relancer.addActionListener(new ActionListener() {
132
                public void actionPerformed(ActionEvent e) {
127
                public void actionPerformed(ActionEvent e) {
133
                    relanceClient();
128
                    ((EcheanceClientSQLElement) panelEcheances.getElement()).relanceClient(getListPanelEcheancesClients().getListe().getSelectedRow().asRow());
134
                }
129
                }
135
            });
130
            });
136
        }
131
        }
137
 
132
 
138
        // Bouton Encaisser
133
        // Bouton Encaisser
Line 270... Line 265...
270
        this.relancer.setEnabled(false);
265
        this.relancer.setEnabled(false);
271
        this.encaisser.setEnabled(false);
266
        this.encaisser.setEnabled(false);
272
 
267
 
273
    }
268
    }
274
 
269
 
275
    private void relanceClient() {
-
 
276
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
-
 
277
        final SQLElement relanceElt = Configuration.getInstance().getDirectory().getElement("RELANCE");
-
 
278
 
-
 
279
        final SQLRow rowSource = this.panelEcheances.getListe().fetchSelectedRow();
-
 
280
 
-
 
281
        if (rowSource != null) {
-
 
282
            int idMvtSource = MouvementSQLElement.getSourceId(rowSource.getInt("ID_MOUVEMENT"));
-
 
283
            SQLRow rowMvtSource = base.getTable("MOUVEMENT").getRow(idMvtSource);
-
 
284
 
-
 
285
            if (!rowMvtSource.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
-
 
286
                this.relancer.setEnabled(false);
-
 
287
                return;
-
 
288
            }
-
 
289
 
-
 
290
            if (this.editRelance == null) {
-
 
291
                this.editRelance = new EditFrame(relanceElt);
-
 
292
                this.editRelance.setIconImages(Gestion.getFrameIcon());
-
 
293
                this.editRelance.addEditPanelListener(new EditPanelListener() {
-
 
294
 
-
 
295
                    public void cancelled() {
-
 
296
                        // rien
-
 
297
                    }
-
 
298
 
-
 
299
                    public void modified() {
-
 
300
                        // rien
-
 
301
                    }
-
 
302
 
-
 
303
                    public void deleted() {
-
 
304
                        // rien
-
 
305
                    }
-
 
306
 
-
 
307
                    public void inserted(int id) {
-
 
308
                        int nbRelance = rowSource.getInt("NOMBRE_RELANCE");
-
 
309
                        nbRelance++;
-
 
310
 
-
 
311
                        SQLRowValues rowValsEch = new SQLRowValues(rowSource.getTable());
-
 
312
                        rowValsEch.put("NOMBRE_RELANCE", nbRelance);
-
 
313
                        rowValsEch.put("DATE_LAST_RELANCE", new Date());
-
 
314
 
-
 
315
                        try {
-
 
316
                            rowValsEch.update(rowSource.getID());
-
 
317
                            relanceElt.getTable().getRow(id).createEmptyUpdateRow().put("ID_ECHEANCE_CLIENT", rowSource.getID()).commit();
-
 
318
                        } catch (SQLException e1) {
-
 
319
                            ExceptionHandler.handle("erreur lors de la mise à jour du nombre de relances", e1);
-
 
320
                        }
-
 
321
                    }
-
 
322
                });
-
 
323
            }
-
 
324
 
-
 
325
            SQLRowValues rowVals = new SQLRowValues(relanceElt.getTable());
-
 
326
            rowVals.put("ID_SAISIE_VENTE_FACTURE", rowMvtSource.getInt("IDSOURCE"));
-
 
327
            rowVals.put("MONTANT", rowSource.getObject("MONTANT"));
-
 
328
            rowVals.put("ID_CLIENT", rowSource.getInt("ID_CLIENT"));
-
 
329
            rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(RelanceSQLElement.class, new Date()));
-
 
330
            this.editRelance.getSQLComponent().select(rowVals);
-
 
331
 
-
 
332
            this.editRelance.pack();
-
 
333
            this.editRelance.setVisible(true);
-
 
334
        } else {
-
 
335
            Thread.dumpStack();
-
 
336
        }
-
 
337
    }
-
 
338
 
-
 
339
    public IListPanel getListPanelEcheancesClients() {
270
    public IListPanel getListPanelEcheancesClients() {
340
        return this.panelEcheances;
271
        return this.panelEcheances;
341
    }
272
    }
342
}
273
}