OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 156 Rev 174
Line 20... Line 20...
20
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
20
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
21
import org.openconcerto.erp.core.common.ui.DeviseField;
21
import org.openconcerto.erp.core.common.ui.DeviseField;
22
import org.openconcerto.erp.core.common.ui.TotalPanel;
22
import org.openconcerto.erp.core.common.ui.TotalPanel;
23
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
23
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
24
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
24
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
-
 
25
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
25
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
26
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
26
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
27
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
27
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
28
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
28
import org.openconcerto.erp.core.sales.product.ui.ReliquatRowValuesTable;
29
import org.openconcerto.erp.core.sales.product.ui.ReliquatRowValuesTable;
29
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonItemSQLElement;
30
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonItemSQLElement;
Line 38... Line 39...
38
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
39
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
39
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
40
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
40
import org.openconcerto.erp.utils.TM;
41
import org.openconcerto.erp.utils.TM;
41
import org.openconcerto.sql.Configuration;
42
import org.openconcerto.sql.Configuration;
42
import org.openconcerto.sql.element.SQLElement;
43
import org.openconcerto.sql.element.SQLElement;
-
 
44
import org.openconcerto.sql.model.SQLBackgroundTableCache;
43
import org.openconcerto.sql.model.SQLRow;
45
import org.openconcerto.sql.model.SQLRow;
44
import org.openconcerto.sql.model.SQLRowAccessor;
46
import org.openconcerto.sql.model.SQLRowAccessor;
45
import org.openconcerto.sql.model.SQLRowValues;
47
import org.openconcerto.sql.model.SQLRowValues;
46
import org.openconcerto.sql.model.SQLSelect;
48
import org.openconcerto.sql.model.SQLSelect;
47
import org.openconcerto.sql.model.SQLTable;
49
import org.openconcerto.sql.model.SQLTable;
48
import org.openconcerto.sql.model.Where;
50
import org.openconcerto.sql.model.Where;
49
import org.openconcerto.sql.preferences.SQLPreferences;
51
import org.openconcerto.sql.preferences.SQLPreferences;
50
import org.openconcerto.sql.sqlobject.ElementComboBox;
52
import org.openconcerto.sql.sqlobject.ElementComboBox;
51
import org.openconcerto.sql.sqlobject.JUniqueTextField;
53
import org.openconcerto.sql.sqlobject.JUniqueTextField;
52
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
54
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
-
 
55
import org.openconcerto.sql.sqlobject.SQLTextCombo;
-
 
56
import org.openconcerto.sql.users.UserManager;
53
import org.openconcerto.sql.view.EditFrame;
57
import org.openconcerto.sql.view.EditFrame;
54
import org.openconcerto.sql.view.list.RowValuesTable;
58
import org.openconcerto.sql.view.list.RowValuesTable;
55
import org.openconcerto.sql.view.list.RowValuesTableModel;
59
import org.openconcerto.sql.view.list.RowValuesTableModel;
56
import org.openconcerto.ui.DefaultGridBagConstraints;
60
import org.openconcerto.ui.DefaultGridBagConstraints;
57
import org.openconcerto.ui.FormLayouter;
61
import org.openconcerto.ui.FormLayouter;
Line 103... Line 107...
103
    private final JTextField textPoidsTotal = new JTextField(6);
107
    private final JTextField textPoidsTotal = new JTextField(6);
104
    private final JTextField textNom = new JTextField(25);
108
    private final JTextField textNom = new JTextField(25);
105
    private final JDate date = new JDate(true);
109
    private final JDate date = new JDate(true);
106
    private final boolean displayDpt;
110
    private final boolean displayDpt;
107
    private final ElementComboBox comboDpt = new ElementComboBox();
111
    private final ElementComboBox comboDpt = new ElementComboBox();
-
 
112
    private ElementComboBox comboCommercial;
108
 
113
 
109
    public BonDeLivraisonSQLComponent() {
114
    public BonDeLivraisonSQLComponent() {
110
        super(Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON"));
115
        super(Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON"));
111
        SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
116
        SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
112
        this.displayDpt = prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false);
117
        this.displayDpt = prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false);
Line 123... Line 128...
123
        this.tableBonItem.getModel().clearRows();
128
        this.tableBonItem.getModel().clearRows();
124
        SQLRowValues rowVals = super.createDefaults();
129
        SQLRowValues rowVals = super.createDefaults();
125
        if (rowVals == null) {
130
        if (rowVals == null) {
126
            rowVals = new SQLRowValues(getTable());
131
            rowVals = new SQLRowValues(getTable());
127
        }
132
        }
-
 
133
        SQLElement eltComm = getElement().getForeignElement("ID_COMMERCIAL");
-
 
134
        int idUser = UserManager.getInstance().getCurrentUser().getId();
-
 
135
        SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
-
 
136
 
-
 
137
        if (rowsComm != null) {
-
 
138
            rowVals.put("ID_COMMERCIAL", rowsComm.getID());
-
 
139
        }
128
        if (getTable().contains("CREATE_VIRTUAL_STOCK")) {
140
        if (getTable().contains("CREATE_VIRTUAL_STOCK")) {
129
            rowVals.put("CREATE_VIRTUAL_STOCK", Boolean.TRUE);
141
            rowVals.put("CREATE_VIRTUAL_STOCK", Boolean.TRUE);
130
        }
142
        }
131
        if (getTable().contains("ID_TAXE_PORT")) {
143
        if (getTable().contains("ID_TAXE_PORT")) {
132
            SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
144
            SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
Line 305... Line 317...
305
                        addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE);
317
                        addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE);
306
                    }
318
                    }
307
                }
319
                }
308
            });
320
            });
309
        }
321
        }
-
 
322
        if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
-
 
323
            // cat spe
-
 
324
            final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
-
 
325
            catUI.addToUI(this, c);
-
 
326
            catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
-
 
327
 
-
 
328
                @Override
-
 
329
                public void propertyChange(PropertyChangeEvent evt) {
-
 
330
                    int wantedID = catUI.getCombo().getWantedID();
-
 
331
                    if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
-
 
332
                        tableBonItem.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
-
 
333
                    } else {
-
 
334
                        tableBonItem.setRowCatComptable(null);
-
 
335
                    }
-
 
336
                }
-
 
337
            });
-
 
338
        }
310
        if (getTable().contains("SPEC_LIVRAISON")) {
339
        if (getTable().contains("SPEC_LIVRAISON")) {
311
            // Date livraison
340
            // Date livraison
312
            c.gridx++;
341
            c.gridx++;
313
            c.fill = GridBagConstraints.HORIZONTAL;
342
            c.fill = GridBagConstraints.HORIZONTAL;
314
            c.weightx = 0;
343
            c.weightx = 0;
Line 360... Line 389...
360
                        if (rowClient.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowClient.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
389
                        if (rowClient.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowClient.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
361
                            tableBonItem.setRowCatComptable(rowClient.getForeign("ID_CATEGORIE_COMPTABLE"));
390
                            tableBonItem.setRowCatComptable(rowClient.getForeign("ID_CATEGORIE_COMPTABLE"));
362
                        } else {
391
                        } else {
363
                            tableBonItem.setRowCatComptable(null);
392
                            tableBonItem.setRowCatComptable(null);
364
                        }
393
                        }
-
 
394
                        if (!isFilling()) {
-
 
395
                            tableBonItem.setClient(rowClient, true);
-
 
396
                        }
-
 
397
 
365
                    } else {
398
                    } else {
366
                        comboContact.getRequest().setWhere(Where.FALSE);
399
                        comboContact.getRequest().setWhere(Where.FALSE);
367
                        tableBonItem.setRowCatComptable(null);
400
                        tableBonItem.setRowCatComptable(null);
-
 
401
                        if (!isFilling()) {
-
 
402
                            tableBonItem.setClient(null, true);
-
 
403
                        }
368
                        // DevisSQLComponent.this.table.setTarif(null, false);
404
                        // DevisSQLComponent.this.table.setTarif(null, false);
369
                    }
405
                    }
370
                }
406
                }
371
            });
407
            });
372
 
408
 
-
 
409
            // Commercial
-
 
410
            JLabel labelCommercial = new JLabel(getLabelFor("ID_COMMERCIAL"));
-
 
411
            labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
412
 
-
 
413
            c.gridx++;
-
 
414
            c.weightx = 0;
-
 
415
            this.add(labelCommercial, c);
-
 
416
 
-
 
417
            this.comboCommercial = new ElementComboBox(false, 25);
-
 
418
            this.comboCommercial.setListIconVisible(false);
-
 
419
            c.gridx++;
-
 
420
            c.fill = GridBagConstraints.NONE;
-
 
421
            c.weightx = 1;
-
 
422
            this.add(this.comboCommercial, c);
-
 
423
            addRequiredSQLObject(this.comboCommercial, "ID_COMMERCIAL");
-
 
424
 
373
        }
425
        }
374
 
426
 
375
        final ElementComboBox boxTarif = new ElementComboBox();
427
        final ElementComboBox boxTarif = new ElementComboBox();
376
        this.comboClient.addValueListener(new PropertyChangeListener() {
428
        this.comboClient.addValueListener(new PropertyChangeListener() {
377
            @Override
429
            @Override
Line 443... Line 495...
443
                public void propertyChange(PropertyChangeEvent evt) {
495
                public void propertyChange(PropertyChangeEvent evt) {
444
                    SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
496
                    SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
445
                    tableBonItem.setTarif(selectedRow, !isFilling());
497
                    tableBonItem.setTarif(selectedRow, !isFilling());
446
                }
498
                }
447
            });
499
            });
-
 
500
 
-
 
501
            if (getTable().contains("SERVI_PAR")) {
-
 
502
                // Commercial
-
 
503
                JLabel labelServi = new JLabel("Servi par");
-
 
504
                labelServi.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
505
                c.gridx++;
-
 
506
                c.weightx = 0;
-
 
507
                this.add(labelServi, c);
-
 
508
 
-
 
509
                SQLTextCombo comboServiPar = new SQLTextCombo();
-
 
510
                c.gridx++;
-
 
511
                c.fill = GridBagConstraints.NONE;
-
 
512
                c.weightx = 1;
-
 
513
                this.add(comboServiPar, c);
-
 
514
                addRequiredSQLObject(comboServiPar, "SERVI_PAR");
-
 
515
            }
448
        }
516
        }
449
 
517
 
450
        if (getTable().contains("A_ATTENTION")) {
518
        if (getTable().contains("A_ATTENTION")) {
451
            // Date livraison
519
            // Date livraison
452
            c.gridx++;
520
            c.gridx++;