OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 142 Rev 156
Line 14... Line 14...
14
 package org.openconcerto.erp.core.sales.credit.component;
14
 package org.openconcerto.erp.core.sales.credit.component;
15
 
15
 
16
import static org.openconcerto.utils.CollectionUtils.createSet;
16
import static org.openconcerto.utils.CollectionUtils.createSet;
17
 
17
 
18
import org.openconcerto.erp.config.ComptaPropsConfiguration;
18
import org.openconcerto.erp.config.ComptaPropsConfiguration;
19
import org.openconcerto.erp.core.common.component.SocieteCommonSQLElement;
-
 
20
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
19
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
21
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
20
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
22
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
21
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
23
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
22
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
-
 
23
import org.openconcerto.erp.core.common.element.SocieteCommonSQLElement;
24
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
24
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
25
import org.openconcerto.erp.core.common.ui.DeviseField;
25
import org.openconcerto.erp.core.common.ui.DeviseField;
26
import org.openconcerto.erp.core.common.ui.PanelFrame;
26
import org.openconcerto.erp.core.common.ui.PanelFrame;
27
import org.openconcerto.erp.core.common.ui.TotalPanel;
27
import org.openconcerto.erp.core.common.ui.TotalPanel;
28
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
28
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
Line 56... Line 56...
56
import org.openconcerto.sql.preferences.SQLPreferences;
56
import org.openconcerto.sql.preferences.SQLPreferences;
57
import org.openconcerto.sql.request.ComboSQLRequest;
57
import org.openconcerto.sql.request.ComboSQLRequest;
58
import org.openconcerto.sql.sqlobject.ElementComboBox;
58
import org.openconcerto.sql.sqlobject.ElementComboBox;
59
import org.openconcerto.sql.sqlobject.JUniqueTextField;
59
import org.openconcerto.sql.sqlobject.JUniqueTextField;
60
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
60
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
-
 
61
import org.openconcerto.sql.users.rights.UserRightsManager;
61
import org.openconcerto.sql.view.EditFrame;
62
import org.openconcerto.sql.view.EditFrame;
62
import org.openconcerto.sql.view.EditPanel.EditMode;
63
import org.openconcerto.sql.view.EditPanel.EditMode;
63
import org.openconcerto.ui.DefaultGridBagConstraints;
64
import org.openconcerto.ui.DefaultGridBagConstraints;
64
import org.openconcerto.ui.FormLayouter;
65
import org.openconcerto.ui.FormLayouter;
65
import org.openconcerto.ui.FrameUtil;
66
import org.openconcerto.ui.FrameUtil;
Line 97... Line 98...
97
import org.apache.commons.dbutils.handlers.ArrayListHandler;
98
import org.apache.commons.dbutils.handlers.ArrayListHandler;
98
 
99
 
99
public class AvoirClientSQLComponent extends TransfertBaseSQLComponent implements ActionListener {
100
public class AvoirClientSQLComponent extends TransfertBaseSQLComponent implements ActionListener {
100
 
101
 
101
    protected PanelOOSQLComponent panelGestDoc;
102
    protected PanelOOSQLComponent panelGestDoc;
-
 
103
    private TotalPanel totalTTC;
102
    private JTextField textNom;
104
    private JTextField textNom;
103
    private JDate date;
105
    private JDate date;
104
    private JUniqueTextField textNumero;
106
    private JUniqueTextField textNumero;
105
    private AbstractArticleItemTable table;
107
    private AbstractArticleItemTable table;
106
    private JCheckBox boxAdeduire = new JCheckBox(getLabelFor("A_DEDUIRE"));
108
    private JCheckBox boxAdeduire = new JCheckBox(getLabelFor("A_DEDUIRE"));
Line 125... Line 127...
125
    private PropertyChangeListener listenerModeReglDefaut = new PropertyChangeListener() {
127
    private PropertyChangeListener listenerModeReglDefaut = new PropertyChangeListener() {
126
        public void propertyChange(PropertyChangeEvent arg0) {
128
        public void propertyChange(PropertyChangeEvent arg0) {
127
            int idCli = AvoirClientSQLComponent.this.comboClient.getWantedID();
129
            int idCli = AvoirClientSQLComponent.this.comboClient.getWantedID();
128
            if (idCli > 1) {
130
            if (idCli > 1) {
129
                SQLRow rowCli = AvoirClientSQLComponent.this.tableClient.getRow(idCli);
131
                SQLRow rowCli = AvoirClientSQLComponent.this.tableClient.getRow(idCli);
130
                if (!rowCli.isForeignEmpty("ID_COMMERCIAL")) {
132
                if (!isFilling() && !rowCli.isForeignEmpty("ID_COMMERCIAL")) {
131
                    comboCommercial.setValue(rowCli.getForeignID("ID_COMMERCIAL"));
133
                    comboCommercial.setValue(rowCli.getForeignID("ID_COMMERCIAL"));
132
                }
134
                }
-
 
135
                if (rowCli.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowCli.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
-
 
136
                    totalTTC.setCategorieComptable(rowCli.getForeign("ID_CATEGORIE_COMPTABLE"));
-
 
137
                } else {
-
 
138
                    totalTTC.setCategorieComptable(null);
-
 
139
                }
133
                SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
140
                SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
134
                int idModeRegl = rowCli.getInt("ID_MODE_REGLEMENT");
141
                int idModeRegl = rowCli.getInt("ID_MODE_REGLEMENT");
135
                if (!isFilling() && idModeRegl > 1 && AvoirClientSQLComponent.this.eltModeRegl.isCreated()) {
142
                if (!isFilling() && idModeRegl > 1 && AvoirClientSQLComponent.this.eltModeRegl.isCreated()) {
136
                    SQLRow rowModeRegl = sqleltModeRegl.getTable().getRow(idModeRegl);
143
                    SQLRow rowModeRegl = sqleltModeRegl.getTable().getRow(idModeRegl);
137
                    SQLRowValues rowValsModeRegl = rowModeRegl.createUpdateRow();
144
                    SQLRowValues rowValsModeRegl = rowModeRegl.createUpdateRow();
138
                    rowValsModeRegl.clearPrimaryKeys();
145
                    rowValsModeRegl.clearPrimaryKeys();
139
                    AvoirClientSQLComponent.this.eltModeRegl.setValue(rowValsModeRegl);
146
                    AvoirClientSQLComponent.this.eltModeRegl.setValue(rowValsModeRegl);
140
                }
147
                }
-
 
148
            } else {
-
 
149
                totalTTC.setCategorieComptable(null);
141
            }
150
            }
142
        }
151
        }
143
    };
152
    };
144
    private final ElementComboBox boxTarif = new ElementComboBox();
153
    private final ElementComboBox boxTarif = new ElementComboBox();
145
    private PropertyChangeListener changeClientListener = new PropertyChangeListener() {
154
    private PropertyChangeListener changeClientListener = new PropertyChangeListener() {
Line 155... Line 164...
155
                final SQLField fieldForeignClient = getTable().getDBRoot().findTable("CONTACT").getField("ID_CLIENT");
164
                final SQLField fieldForeignClient = getTable().getDBRoot().findTable("CONTACT").getField("ID_CLIENT");
156
                Where wC = new Where(fieldForeignClient, "=", SQLRow.NONEXISTANT_ID);
165
                Where wC = new Where(fieldForeignClient, "=", SQLRow.NONEXISTANT_ID);
157
                    wC = wC.or(new Where(getTable().getDBRoot().findTable("CONTACT").getField("ID_CLIENT"), "=", id));
166
                    wC = wC.or(new Where(getTable().getDBRoot().findTable("CONTACT").getField("ID_CLIENT"), "=", id));
158
                selectContact.getRequest().setWhere(wC);
167
                selectContact.getRequest().setWhere(wC);
159
 
168
 
-
 
169
                if (row.getObject("ID_CATEGORIE_COMPTABLE") != null && !row.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
-
 
170
                    table.setRowCatComptable(row.getForeign("ID_CATEGORIE_COMPTABLE"));
-
 
171
                } else {
-
 
172
                    table.setRowCatComptable(null);
-
 
173
                }
-
 
174
 
160
                if (!isFilling() && comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {
175
                if (!isFilling() && comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {
161
 
176
 
162
                    // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
177
                    // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
163
                    // if (foreignRow.isUndefined() &&
178
                    // if (foreignRow.isUndefined() &&
164
                    // !row.getForeignRow("ID_DEVISE").isUndefined()) {
179
                    // !row.getForeignRow("ID_DEVISE").isUndefined()) {
Line 178... Line 193...
178
                        boxTarif.setValue(foreignRow.getID());
193
                        boxTarif.setValue(foreignRow.getID());
179
                    }
194
                    }
180
                }
195
                }
181
 
196
 
182
            } else {
197
            } else {
-
 
198
                table.setRowCatComptable(null);
183
                selectContact.getRequest().setWhere(Where.FALSE);
199
                selectContact.getRequest().setWhere(Where.FALSE);
184
            }
200
            }
185
            // }
201
            // }
186
        }
202
        }
187
    };
203
    };
Line 659... Line 675...
659
        addRequiredSQLObject(fieldService, "MONTANT_SERVICE");
675
        addRequiredSQLObject(fieldService, "MONTANT_SERVICE");
660
        //
676
        //
661
        JTextField poids = new JTextField();
677
        JTextField poids = new JTextField();
662
        if (getTable().getFieldsName().contains("T_POIDS"))
678
        if (getTable().getFieldsName().contains("T_POIDS"))
663
            addSQLObject(poids, "T_POIDS");
679
            addSQLObject(poids, "T_POIDS");
664
        final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, poids, null);
680
        this.totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, poids, null);
665
        totalTTC.setOpaque(false);
681
        totalTTC.setOpaque(false);
666
        c.gridx++;
682
        c.gridx++;
667
        c.gridy = 0;
683
        c.gridy = 0;
668
        c.gridheight = 2;
684
        c.gridheight = 2;
669
        c.fill = GridBagConstraints.BOTH;
685
        c.fill = GridBagConstraints.BOTH;
Line 961... Line 977...
961
            // ne pas supprimer l'ID de rVals pour qu'on puisse UPDATE
977
            // ne pas supprimer l'ID de rVals pour qu'on puisse UPDATE
962
            vals.setID(rVals.getID());
978
            vals.setID(rVals.getID());
963
            super.select(vals);
979
            super.select(vals);
964
            rVals.remove("ID_CLIENT");
980
            rVals.remove("ID_CLIENT");
965
            super.select(rVals);
981
            super.select(rVals);
-
 
982
 
-
 
983
 
966
        } else {
984
        } else {
967
            super.select(r);
985
            super.select(r);
968
        }
986
        }
969
 
987
 
970
    }
988
    }