OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 73 Rev 149
Line 13... Line 13...
13
 
13
 
14
 package org.openconcerto.erp.core.finance.accounting.ui;
14
 package org.openconcerto.erp.core.finance.accounting.ui;
15
 
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
17
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
-
 
18
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
18
import org.openconcerto.erp.model.ISQLCompteSelector;
19
import org.openconcerto.erp.model.ISQLCompteSelector;
19
import org.openconcerto.sql.Configuration;
20
import org.openconcerto.sql.Configuration;
20
import org.openconcerto.sql.model.SQLBase;
21
import org.openconcerto.sql.model.SQLBase;
21
import org.openconcerto.sql.model.SQLRow;
22
import org.openconcerto.sql.model.SQLRow;
22
import org.openconcerto.sql.model.SQLRowAccessor;
23
import org.openconcerto.sql.model.SQLRowAccessor;
23
import org.openconcerto.sql.model.SQLRowValues;
24
import org.openconcerto.sql.model.SQLRowValues;
24
import org.openconcerto.sql.model.SQLTable;
25
import org.openconcerto.sql.model.SQLTable;
-
 
26
import org.openconcerto.sql.sqlobject.ElementComboBox;
-
 
27
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
25
import org.openconcerto.ui.DefaultGridBagConstraints;
28
import org.openconcerto.ui.DefaultGridBagConstraints;
26
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
29
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
27
 
30
 
28
import java.awt.GridBagConstraints;
31
import java.awt.GridBagConstraints;
29
import java.awt.GridBagLayout;
32
import java.awt.GridBagLayout;
30
import java.sql.SQLException;
33
import java.sql.SQLException;
31
 
34
 
-
 
35
import javax.swing.JCheckBox;
32
import javax.swing.JLabel;
36
import javax.swing.JLabel;
33
import javax.swing.JPanel;
37
import javax.swing.JPanel;
34
 
38
 
35
public class CompteCloturePreferencePanel extends DefaultPreferencePanel {
39
public class CompteCloturePreferencePanel extends DefaultPreferencePanel {
36
    private ISQLCompteSelector selCompteOuverture, selCompteFermeture, selCompteResultat, selCompteResultatPerte;
40
    private ISQLCompteSelector selCompteOuverture, selCompteFermeture, selCompteResultat, selCompteResultatPerte;
-
 
41
    private SQLRequestComboBox selJournal;
-
 
42
    private JCheckBox boxCompteSolde;
37
    private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
43
    private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
38
    private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
44
    private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
39
    private SQLRowValues rowPrefCompteVals = new SQLRowValues(tablePrefCompte);
45
    private SQLRowValues rowPrefCompteVals = new SQLRowValues(tablePrefCompte);
40
 
46
 
41
    public CompteCloturePreferencePanel() {
47
    public CompteCloturePreferencePanel() {
Line 86... Line 92...
86
        c.gridx++;
92
        c.gridx++;
87
        this.selCompteResultatPerte = new ISQLCompteSelector();
93
        this.selCompteResultatPerte = new ISQLCompteSelector();
88
        this.selCompteResultatPerte.init();
94
        this.selCompteResultatPerte.init();
89
        this.add(this.selCompteResultatPerte, c);
95
        this.add(this.selCompteResultatPerte, c);
90
 
96
 
-
 
97
        // Compte résultat
-
 
98
        c.gridy++;
-
 
99
        c.gridx = 0;
-
 
100
        c.weightx = 0;
-
 
101
        this.add(new JLabel("Journal des à nouveaux"), c);
-
 
102
        c.weightx = 1;
-
 
103
        c.gridx++;
-
 
104
        this.selJournal = new SQLRequestComboBox(false);
-
 
105
        this.selJournal.uiInit(Configuration.getInstance().getDirectory().getElement("JOURNAL").createComboRequest());
-
 
106
        this.add(this.selJournal, c);
-
 
107
 
-
 
108
        // Compte résultat
-
 
109
        c.gridy++;
-
 
110
        c.gridx = 0;
-
 
111
        c.weightx = 0;
-
 
112
        this.add(new JLabel("Générer des écritures de fermetures et d'à nouveaux pour les comptes soldés"), c);
-
 
113
        c.weightx = 1;
-
 
114
        c.gridx++;
-
 
115
        this.boxCompteSolde = new JCheckBox();
-
 
116
        this.boxCompteSolde.setSelected(true);
-
 
117
        this.add(this.boxCompteSolde, c);
-
 
118
 
91
        // Spacer
119
        // Spacer
92
 
120
 
93
        JPanel p = new JPanel();
121
        JPanel p = new JPanel();
94
        p.setOpaque(false);
122
        p.setOpaque(false);
95
        c.gridy++;
123
        c.gridy++;
Line 102... Line 130...
102
 
130
 
103
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_BILAN_O", this.selCompteOuverture.getValue());
131
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_BILAN_O", this.selCompteOuverture.getValue());
104
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_BILAN_F", this.selCompteFermeture.getValue());
132
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_BILAN_F", this.selCompteFermeture.getValue());
105
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_RESULTAT", this.selCompteResultat.getValue());
133
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_RESULTAT", this.selCompteResultat.getValue());
106
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_RESULTAT_PERTE", this.selCompteResultat.getValue());
134
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_RESULTAT_PERTE", this.selCompteResultat.getValue());
-
 
135
        this.rowPrefCompteVals.put("ID_JOURNAL_AN", this.selJournal.getValue());
-
 
136
        this.rowPrefCompteVals.put("CREATE_NUL_SOLDE_ECR", this.boxCompteSolde.isSelected());
107
 
137
 
108
        try {
138
        try {
109
            this.rowPrefCompteVals.update();
139
            this.rowPrefCompteVals.update();
110
        } catch (SQLException e) {
140
        } catch (SQLException e) {
111
            e.printStackTrace();
141
            e.printStackTrace();
Line 135... Line 165...
135
            // Resultat
165
            // Resultat
136
            compte = ComptePCESQLElement.getComptePceDefault("ResultatPerte");
166
            compte = ComptePCESQLElement.getComptePceDefault("ResultatPerte");
137
            value = ComptePCESQLElement.getId(compte);
167
            value = ComptePCESQLElement.getId(compte);
138
            this.selCompteResultatPerte.setValue(value);
168
            this.selCompteResultatPerte.setValue(value);
139
 
169
 
-
 
170
            // AN
-
 
171
            this.selJournal.setValue(JournalSQLElement.OD);
-
 
172
 
-
 
173
            this.boxCompteSolde.setSelected(true);
-
 
174
 
140
        } catch (Exception e) {
175
        } catch (Exception e) {
141
            e.printStackTrace();
176
            e.printStackTrace();
142
        }
177
        }
143
    }
178
    }
144
 
179
 
Line 188... Line 223...
188
            } else {
223
            } else {
189
                value = rowResultatP.getID();
224
                value = rowResultatP.getID();
190
            }
225
            }
191
            this.selCompteResultatPerte.setValue(value);
226
            this.selCompteResultatPerte.setValue(value);
192
 
227
 
-
 
228
            // Journal
-
 
229
            SQLRowAccessor rowJ = this.rowPrefCompteVals.getForeign("ID_JOURNAL_AN");
-
 
230
            if (rowJ == null || rowJ.isUndefined()) {
-
 
231
                value = JournalSQLElement.OD;
-
 
232
            } else {
-
 
233
                value = rowJ.getID();
-
 
234
            }
-
 
235
            this.selJournal.setValue(value);
-
 
236
 
-
 
237
            // Journal
-
 
238
            boolean b = true;
-
 
239
            if (this.rowPrefCompteVals.getObject("CREATE_NUL_SOLDE_ECR") != null) {
-
 
240
                b = this.rowPrefCompteVals.getBoolean("CREATE_NUL_SOLDE_ECR");
-
 
241
            }
-
 
242
            this.boxCompteSolde.setSelected(b);
-
 
243
 
193
        } catch (Exception e) {
244
        } catch (Exception e) {
194
            e.printStackTrace();
245
            e.printStackTrace();
195
        }
246
        }
196
    }
247
    }
197
}
248
}