OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 177 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.finance.accounting.ui;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
174 ilm 18
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
18 ilm 19
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
20
import org.openconcerto.erp.model.ISQLCompteSelector;
21
import org.openconcerto.sql.Configuration;
22
import org.openconcerto.sql.model.SQLBase;
23
import org.openconcerto.sql.model.SQLRow;
73 ilm 24
import org.openconcerto.sql.model.SQLRowAccessor;
18 ilm 25
import org.openconcerto.sql.model.SQLRowValues;
26
import org.openconcerto.sql.model.SQLTable;
156 ilm 27
import org.openconcerto.sql.request.SQLFieldTranslator;
18 ilm 28
import org.openconcerto.sql.sqlobject.ElementComboBox;
29
import org.openconcerto.ui.DefaultGridBagConstraints;
30
import org.openconcerto.ui.TitledSeparator;
31
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
32
 
33
import java.awt.GridBagConstraints;
34
import java.awt.GridBagLayout;
35
import java.awt.Insets;
36
import java.sql.SQLException;
37
 
38
import javax.swing.JLabel;
156 ilm 39
import javax.swing.JOptionPane;
18 ilm 40
import javax.swing.JPanel;
156 ilm 41
import javax.swing.SwingUtilities;
18 ilm 42
 
43
public class CompteGestCommPreferencePanel extends DefaultPreferencePanel {
44
 
177 ilm 45
    private ISQLCompteSelector selCompteCBAttente, selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteValeurEncaissement, selCompteAvanceClient, selCompteClient, selCompteVenteProduits,
142 ilm 46
            selCompteVenteService, selCompteTVACol, selCompteTVADed, selCompteTVAImmo, selCompteAchatIntra, selCompteFactor, selComptePortSoumis, selComptePortNonSoumis;
177 ilm 47
    private ElementComboBox selJrnlFactor, selJrnlValEnc, selJrnlCB;
18 ilm 48
    private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
49
    private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
50
    private SQLRowValues rowPrefCompteVals = new SQLRowValues(tablePrefCompte);
51
 
52
    public CompteGestCommPreferencePanel() {
53
        super();
54
 
55
        final SQLRow rowPrefCompte = tablePrefCompte.getRow(2);
56
        this.rowPrefCompteVals.loadAbsolutelyAll(rowPrefCompte);
57
 
58
        final Insets separatorInsets = new Insets(10, 2, 1, 2);
59
 
60
        this.setLayout(new GridBagLayout());
61
 
62
        final GridBagConstraints c = new DefaultGridBagConstraints();
63
        final Insets normalInsets = c.insets;
64
 
65
        c.fill = GridBagConstraints.HORIZONTAL;
66
        c.anchor = GridBagConstraints.WEST;
67
        c.gridx = 0;
68
        c.gridy = 0;
69
        c.gridwidth = 1;
70
        c.gridheight = 1;
71
        c.weightx = 1;
72
        c.weighty = 0;
73
 
74
        c.gridwidth = GridBagConstraints.REMAINDER;
75
 
76
        /*******************************************************************************************
77
         * SAISIE DES ACHATS
78
         ******************************************************************************************/
79
        TitledSeparator sep = new TitledSeparator("Saisie des Achats");
80
        c.gridwidth = GridBagConstraints.REMAINDER;
81
        this.add(sep, c);
82
        c.gridwidth = 1;
83
 
84
        // Compte Fournisseur
85
        c.gridy++;
86
        c.weightx = 0;
87
        this.add(new JLabel("Compte Fournisseur"), c);
88
        c.weightx = 1;
89
 
90
        c.gridx++;
91
        this.selCompteFourn = new ISQLCompteSelector();
92
        this.selCompteFourn.init();
93
        this.add(this.selCompteFourn, c);
94
 
95
        // Compte Achat
96
        c.gridy++;
97
        c.weightx = 0;
98
        c.gridx = 0;
99
        this.add(new JLabel("Compte Achat"), c);
100
        c.weightx = 1;
101
        c.gridx++;
102
        this.selCompteAchat = new ISQLCompteSelector();
103
        this.selCompteAchat.init();
104
        this.add(this.selCompteAchat, c);
105
 
106
        // Compte Achat intra
107
        c.gridy++;
108
        c.weightx = 0;
109
        c.gridx = 0;
110
        this.add(new JLabel("Compte Achat Intracommunautaire"), c);
111
        c.weightx = 1;
112
        c.gridx++;
113
        this.selCompteAchatIntra = new ISQLCompteSelector();
114
        this.selCompteAchatIntra.init();
115
        this.add(this.selCompteAchatIntra, c);
116
 
117
        /*******************************************************************************************
118
         * SAISIE DES VENTES
119
         ******************************************************************************************/
120
        c.gridy++;
121
        c.gridx = 0;
122
        TitledSeparator sepVenteC = new TitledSeparator("Saisie des ventes");
123
        c.gridwidth = GridBagConstraints.REMAINDER;
124
        c.insets = separatorInsets;
125
        this.add(sepVenteC, c);
126
        c.insets = normalInsets;
127
        c.gridwidth = 1;
128
 
129
        // Compte client
130
        c.gridy++;
131
        c.weightx = 0;
132
        this.add(new JLabel("Compte Client"), c);
133
        c.weightx = 1;
134
        c.gridx++;
135
 
136
        this.selCompteClient = new ISQLCompteSelector();
137
        this.selCompteClient.init();
138
        this.add(this.selCompteClient, c);
139
 
142 ilm 140
        // Avance Compte client
141
        c.gridy++;
149 ilm 142
        c.gridx = 0;
142 ilm 143
        c.weightx = 0;
144
        this.add(new JLabel("Compte Avance Client"), c);
145
        c.weightx = 1;
146
        c.gridx++;
147
 
148
        this.selCompteAvanceClient = new ISQLCompteSelector();
149
        this.selCompteAvanceClient.init();
150
        this.add(this.selCompteAvanceClient, c);
151
 
152
        // Valeur à l'encaissement
153
        c.gridy++;
149 ilm 154
        c.gridx = 0;
142 ilm 155
        c.weightx = 0;
156
        this.add(new JLabel("Compte dépôt chèque"), c);
157
        c.weightx = 1;
158
        c.gridx++;
159
 
160
        this.selCompteValeurEncaissement = new ISQLCompteSelector();
161
        this.selCompteValeurEncaissement.init();
162
        this.add(this.selCompteValeurEncaissement, c);
163
 
174 ilm 164
        // Journal
165
        c.gridy++;
166
        c.weightx = 0;
167
        c.gridx = 0;
168
        this.add(new JLabel("Journal dépôt chèque"), c);
169
        c.weightx = 1;
170
        c.gridx++;
171
        this.selJrnlValEnc = new ElementComboBox();
172
        this.selJrnlValEnc.init(Configuration.getInstance().getDirectory().getElement("JOURNAL"));
173
        this.add(this.selJrnlValEnc, c);
174
 
177 ilm 175
        // Journal
176
        c.gridy++;
177
        c.weightx = 0;
178
        c.gridx = 0;
179
        this.add(new JLabel("Journal CB Attente"), c);
180
        c.weightx = 1;
181
        c.gridx++;
182
        this.selJrnlCB = new ElementComboBox();
183
        this.selJrnlCB.init(Configuration.getInstance().getDirectory().getElement("JOURNAL"));
184
        this.add(this.selJrnlCB, c);
185
 
186
        c.gridy++;
187
        c.weightx = 0;
188
        c.gridx = 0;
189
        this.add(new JLabel("Compte CB Attente"), c);
190
        c.weightx = 1;
191
        c.gridx++;
192
        this.selCompteCBAttente = new ISQLCompteSelector();
193
        this.selCompteCBAttente.init();
194
        this.add(this.selCompteCBAttente, c);
195
 
18 ilm 196
        // Compte vente produits
197
        c.gridy++;
198
        c.weightx = 0;
199
        c.gridx = 0;
200
        this.add(new JLabel("Compte Vente de produits"), c);
201
        c.weightx = 1;
202
        c.gridx++;
203
        this.selCompteVenteProduits = new ISQLCompteSelector();
204
        this.selCompteVenteProduits.init();
205
        this.add(this.selCompteVenteProduits, c);
206
 
207
        // Compte vente service
208
        c.gridy++;
209
        c.weightx = 0;
210
        c.gridx = 0;
211
        this.add(new JLabel("Compte Vente de service"), c);
212
        c.weightx = 1;
213
        c.gridx++;
214
        this.selCompteVenteService = new ISQLCompteSelector();
215
        this.selCompteVenteService.init();
216
        this.add(this.selCompteVenteService, c);
217
 
218
        // Factor NATEXIS
219
        c.gridy++;
220
        c.weightx = 0;
221
        c.gridx = 0;
222
        this.add(new JLabel("Compte affacturage"), c);
223
        c.weightx = 1;
224
        c.gridx++;
225
        this.selCompteFactor = new ISQLCompteSelector();
226
        this.selCompteFactor.init();
227
        this.add(this.selCompteFactor, c);
228
 
229
        // Journal Factor NATEXIS
230
        c.gridy++;
231
        c.weightx = 0;
232
        c.gridx = 0;
233
        this.add(new JLabel("Journal affacturage"), c);
234
        c.weightx = 1;
235
        c.gridx++;
236
        this.selJrnlFactor = new ElementComboBox();
237
        this.selJrnlFactor.init(Configuration.getInstance().getDirectory().getElement("JOURNAL"));
238
        this.add(this.selJrnlFactor, c);
239
 
94 ilm 240
        /**
241
         * Frais de port sur vente
242
         */
243
 
244
        c.gridy++;
245
        c.gridx = 0;
246
        TitledSeparator sepPort = new TitledSeparator("Ports sur vente");
247
        c.insets = separatorInsets;
248
        c.gridwidth = GridBagConstraints.REMAINDER;
249
        this.add(sepPort, c);
250
        c.insets = normalInsets;
251
        c.gridwidth = 1;
252
 
253
        // Compte TVA Collectee
254
        c.gridy++;
255
        c.weightx = 0;
256
        this.add(new JLabel("Compte Port soumis à TVA"), c);
257
        c.weightx = 1;
258
        c.gridx++;
259
        this.selComptePortSoumis = new ISQLCompteSelector();
260
        this.selComptePortSoumis.init();
261
        this.add(this.selComptePortSoumis, c);
262
 
263
        // Compte TVA Deductible
264
        c.gridy++;
265
        c.weightx = 0;
266
        c.gridx = 0;
267
        this.add(new JLabel("Compte Port non soumis à TVA)"), c);
268
        c.weightx = 1;
269
        c.gridx++;
270
        this.selComptePortNonSoumis = new ISQLCompteSelector();
271
        this.selComptePortNonSoumis.init();
272
        this.add(this.selComptePortNonSoumis, c);
273
 
18 ilm 274
        /*******************************************************************************************
275
         * TVA
276
         ******************************************************************************************/
277
        c.gridy++;
278
        c.gridx = 0;
279
        TitledSeparator sepTVA = new TitledSeparator("TVA");
280
        c.insets = separatorInsets;
281
        c.gridwidth = GridBagConstraints.REMAINDER;
282
        this.add(sepTVA, c);
283
        c.insets = normalInsets;
284
        c.gridwidth = 1;
285
 
286
        // Compte TVA Collectee
287
        c.gridy++;
288
        c.weightx = 0;
289
        this.add(new JLabel("Compte TVA Collectée (Ventes)"), c);
290
        c.weightx = 1;
291
        c.gridx++;
292
        this.selCompteTVACol = new ISQLCompteSelector();
293
        this.selCompteTVACol.init();
294
        this.add(this.selCompteTVACol, c);
295
 
296
        // Compte TVA Deductible
297
        c.gridy++;
298
        c.weightx = 0;
299
        c.gridx = 0;
300
        this.add(new JLabel("Compte TVA déductible (Achats)"), c);
301
        c.weightx = 1;
302
        c.gridx++;
303
        this.selCompteTVADed = new ISQLCompteSelector();
304
        this.selCompteTVADed.init();
305
        this.add(this.selCompteTVADed, c);
306
 
307
        // Compte TVA intracommunautaire
308
        c.gridy++;
309
        c.weightx = 0;
310
        c.gridx = 0;
311
        this.add(new JLabel("Compte TVA due intracommunautaire"), c);
312
        c.weightx = 1;
313
        c.gridx++;
314
        this.selCompteTVAIntraComm = new ISQLCompteSelector();
315
        this.selCompteTVAIntraComm.init();
316
        this.add(this.selCompteTVAIntraComm, c);
317
 
318
        // Compte TVA intracommunautaire
319
        c.gridy++;
19 ilm 320
        c.weighty = 0;
18 ilm 321
        c.weightx = 0;
322
        c.gridx = 0;
323
        this.add(new JLabel("Compte TVA sur immobilisations"), c);
324
        c.weightx = 1;
325
        c.gridx++;
326
        this.selCompteTVAImmo = new ISQLCompteSelector();
327
        this.selCompteTVAImmo.init();
328
        this.add(this.selCompteTVAImmo, c);
329
 
330
        // Spacer
331
        c.weighty = 1;
332
        c.gridy++;
333
        this.add(new JPanel(), c);
334
 
335
        setValues();
336
    }
337
 
338
    public void storeValues() {
339
 
340
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_ACHAT", this.selCompteAchat.getValue());
341
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_ACHAT_INTRA", this.selCompteAchatIntra.getValue());
342
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_VENTE_PRODUIT", this.selCompteVenteProduits.getValue());
343
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_VENTE_SERVICE", this.selCompteVenteService.getValue());
344
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_FACTOR", this.selCompteFactor.getValue());
345
        final int selectedId = this.selJrnlFactor.getSelectedId();
346
        this.rowPrefCompteVals.put("ID_JOURNAL_FACTOR", (selectedId > 1) ? selectedId : 1);
174 ilm 347
 
348
        final int selectedIdEnc = this.selJrnlValEnc.getSelectedId();
349
        this.rowPrefCompteVals.put("ID_JOURNAL_VALEUR_ENCAISSEMENT", (selectedIdEnc > 1) ? selectedIdEnc : 1);
350
 
177 ilm 351
        final int selectedIdCB = this.selJrnlCB.getSelectedId();
352
        this.rowPrefCompteVals.put("ID_JOURNAL_CB_ATTENTE", (selectedIdCB > 1) ? selectedIdCB : 1);
353
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_CB_ATTENTE", this.selCompteCBAttente.getSelectedId() > 1 ? this.selCompteCBAttente.getSelectedId() : 1);
18 ilm 354
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_FOURNISSEUR", this.selCompteFourn.getValue());
355
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_CLIENT", this.selCompteClient.getValue());
142 ilm 356
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_AVANCE_CLIENT", this.selCompteAvanceClient.getValue());
357
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", this.selCompteValeurEncaissement.getValue());
18 ilm 358
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_ACHAT", this.selCompteTVADed.getValue());
359
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_VENTE", this.selCompteTVACol.getValue());
360
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_INTRA", this.selCompteTVAIntraComm.getValue());
361
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_IMMO", this.selCompteTVAImmo.getValue());
94 ilm 362
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_PORT_SOUMIS", this.selComptePortSoumis.getValue());
363
        this.rowPrefCompteVals.put("ID_COMPTE_PCE_PORT_NON_SOUMIS", this.selComptePortNonSoumis.getValue());
18 ilm 364
        try {
156 ilm 365
            final Object[] pb = this.rowPrefCompteVals.getInvalid();
366
            if (pb != null) {
367
                final SQLFieldTranslator trans = Configuration.getInstance().getTranslator();
368
                JOptionPane.showMessageDialog(SwingUtilities.getRoot(this), "Impossible de valider les modifications! Le champ <"
369
                        + trans.getLabelFor(this.rowPrefCompteVals.getTable().getField(pb[0].toString())) + "> pointe sur un compte invalide!(" + pb[1] + ")");
370
            } else {
371
                this.rowPrefCompteVals.update();
372
            }
18 ilm 373
        } catch (SQLException e) {
374
            e.printStackTrace();
375
        }
376
    }
377
 
378
    public void restoreToDefaults() {
379
 
380
        try {
381
            // Achats
382
            String compte;
383
 
384
            compte = ComptePCESQLElement.getComptePceDefault("Achats");
385
 
386
            int value = ComptePCESQLElement.getId(compte);
387
            this.selCompteAchat.setValue(value);
388
 
389
            // Achats Intra
390
            compte = ComptePCESQLElement.getComptePceDefault("AchatsIntra");
391
            value = ComptePCESQLElement.getId(compte);
392
            this.selCompteAchatIntra.setValue(value);
393
 
394
            // Ventes Produits
395
            compte = ComptePCESQLElement.getComptePceDefault("VentesProduits");
396
            value = ComptePCESQLElement.getId(compte);
397
            this.selCompteVenteProduits.setValue(value);
398
 
399
            // Ventes Services
400
            compte = ComptePCESQLElement.getComptePceDefault("VentesServices");
401
            value = ComptePCESQLElement.getId(compte);
402
            this.selCompteVenteService.setValue(value);
403
 
404
            // Ventes factor
405
            compte = ComptePCESQLElement.getComptePceDefault("Factor");
406
            value = ComptePCESQLElement.getId(compte);
407
            this.selCompteFactor.setValue(value);
408
 
409
            this.selJrnlFactor.setValue(GenerationMvtSaisieVenteFacture.journal);
174 ilm 410
            this.selJrnlValEnc.setValue(JournalSQLElement.BANQUES);
18 ilm 411
 
412
            // Fournisseurs
413
            compte = ComptePCESQLElement.getComptePceDefault("Fournisseurs");
414
            value = ComptePCESQLElement.getId(compte);
415
            this.selCompteFourn.setValue(value);
416
 
417
            // Client
418
            compte = ComptePCESQLElement.getComptePceDefault("Clients");
419
            value = ComptePCESQLElement.getId(compte);
420
            this.selCompteClient.setValue(value);
421
 
142 ilm 422
            // AvanceClient
423
            compte = ComptePCESQLElement.getComptePceDefault("AvanceClients");
424
            value = ComptePCESQLElement.getId(compte);
425
            this.selCompteAvanceClient.setValue(value);
426
 
427
            compte = ComptePCESQLElement.getComptePceDefault("ValeurEncaissement");
428
            value = ComptePCESQLElement.getId(compte);
429
            this.selCompteValeurEncaissement.setValue(value);
94 ilm 430
            // Port
431
            compte = ComptePCESQLElement.getComptePceDefault("PortVenteSoumisTVA");
432
            value = ComptePCESQLElement.getId(compte);
433
            this.selComptePortSoumis.setValue(value);
434
 
435
            // Port non soumis
436
            compte = ComptePCESQLElement.getComptePceDefault("PortVenteNonSoumisTVA");
437
            value = ComptePCESQLElement.getId(compte);
438
            this.selComptePortNonSoumis.setValue(value);
439
 
18 ilm 440
            // TVA Coll
441
            compte = ComptePCESQLElement.getComptePceDefault("TVACollectee");
442
            value = ComptePCESQLElement.getId(compte);
443
            this.selCompteTVACol.setValue(value);
444
 
445
            // TVA Ded
446
            compte = ComptePCESQLElement.getComptePceDefault("TVADeductible");
447
            value = ComptePCESQLElement.getId(compte);
448
            this.selCompteTVADed.setValue(value);
449
 
450
            // TVA IntraComm
451
            compte = ComptePCESQLElement.getComptePceDefault("TVAIntraComm");
452
            value = ComptePCESQLElement.getId(compte);
453
            this.selCompteTVAIntraComm.setValue(value);
454
 
455
            // TVA Immo
456
            compte = ComptePCESQLElement.getComptePceDefault("TVAImmo");
457
            value = ComptePCESQLElement.getId(compte);
458
            this.selCompteTVAImmo.setValue(value);
459
        } catch (Exception e) {
460
            e.printStackTrace();
461
        }
462
    }
463
 
464
    public String getTitleName() {
465
        return "Gestion commerciale";
466
    }
467
 
468
    private void setValues() {
469
 
470
        try {
471
 
73 ilm 472
            setComboValues(selCompteAchat, "ID_COMPTE_PCE_ACHAT", "Achats");
473
            setComboValues(selCompteAchatIntra, "ID_COMPTE_PCE_ACHAT_INTRA", "AchatsIntra");
474
            setComboValues(selCompteVenteProduits, "ID_COMPTE_PCE_VENTE_PRODUIT", "VentesProduits");
475
            setComboValues(selCompteVenteService, "ID_COMPTE_PCE_VENTE_SERVICE", "VentesServices");
476
            setComboValues(selCompteFactor, "ID_COMPTE_PCE_FACTOR", "Factor");
18 ilm 477
 
174 ilm 478
            {
479
                // Journal Factor
480
                int value = (this.rowPrefCompteVals.getObject("ID_JOURNAL_FACTOR") == null ? 1 : this.rowPrefCompteVals.getInt("ID_JOURNAL_FACTOR"));
481
                if (value <= 1) {
482
                    value = GenerationMvtSaisieVenteFacture.journal;
483
                }
484
                this.selJrnlFactor.setValue(value);
18 ilm 485
            }
177 ilm 486
 
174 ilm 487
            {
177 ilm 488
                // Journal CB
489
                int value = (this.rowPrefCompteVals.getObject("ID_JOURNAL_CB_ATTENTE") == null ? 1 : this.rowPrefCompteVals.getInt("ID_JOURNAL_CB_ATTENTE"));
490
                if (value > 1) {
491
                    this.selJrnlCB.setValue(value);
492
                }
493
 
494
                int valueCpt = (this.rowPrefCompteVals.getObject("ID_COMPTE_PCE_CB_ATTENTE") == null ? 1 : this.rowPrefCompteVals.getInt("ID_COMPTE_PCE_CB_ATTENTE"));
495
                if (valueCpt > 1) {
496
                    this.selCompteCBAttente.setValue(valueCpt);
497
                }
498
            }
499
            {
174 ilm 500
                // Journal Val enc
501
                int value = (this.rowPrefCompteVals.getObject("ID_JOURNAL_VALEUR_ENCAISSEMENT") == null ? 1 : this.rowPrefCompteVals.getInt("ID_JOURNAL_VALEUR_ENCAISSEMENT"));
502
                if (value <= 1) {
503
                    value = JournalSQLElement.BANQUES;
504
                }
505
                this.selJrnlValEnc.setValue(value);
506
            }
180 ilm 507
            setComboValues(this.selCompteFourn, "ID_COMPTE_PCE_FOURNISSEUR", "Fournisseurs");
508
            setComboValues(this.selCompteClient, "ID_COMPTE_PCE_CLIENT", "Clients");
509
            setComboValues(this.selCompteAvanceClient, "ID_COMPTE_PCE_AVANCE_CLIENT", "AvanceClients");
510
            setComboValues(this.selCompteValeurEncaissement, "ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", "ValeurEncaissement");
511
            setComboValues(this.selComptePortSoumis, "ID_COMPTE_PCE_PORT_SOUMIS", "PortVenteSoumisTVA");
512
            setComboValues(this.selComptePortNonSoumis, "ID_COMPTE_PCE_PORT_NON_SOUMIS", "PortVenteNonSoumisTVA");
513
            setComboValues(this.selCompteTVACol, "ID_COMPTE_PCE_TVA_VENTE", "TVACollectee");
514
            setComboValues(this.selCompteTVADed, "ID_COMPTE_PCE_TVA_ACHAT", "TVADeductible");
515
            setComboValues(this.selCompteTVAIntraComm, "ID_COMPTE_PCE_TVA_INTRA", "TVAIntraComm");
516
            setComboValues(this.selCompteTVAImmo, "ID_COMPTE_PCE_TVA_IMMO", "TVAImmo");
18 ilm 517
        } catch (Exception e) {
518
            e.printStackTrace();
519
        }
520
    }
73 ilm 521
 
522
    private void setComboValues(ISQLCompteSelector combo, String field, String defaultName) {
523
        int value = 1;
524
        SQLRowAccessor row = this.rowPrefCompteVals.getForeign(field);
525
        if (row == null || row.isUndefined()) {
526
            String compte = ComptePCESQLElement.getComptePceDefault(defaultName);
527
            value = ComptePCESQLElement.getId(compte);
528
        } else {
529
            value = row.getID();
530
        }
531
        combo.setValue(value);
532
    }
533
 
18 ilm 534
}