OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
41 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
 /*
15
 * Créé le 20 janv. 2012
16
 */
17
package org.openconcerto.erp.core.supplychain.supplier.component;
18
 
19
import org.openconcerto.erp.config.ComptaPropsConfiguration;
63 ilm 20
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
41 ilm 21
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactItemTable;
22
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
23
import org.openconcerto.erp.model.ISQLCompteSelector;
24
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
25
import org.openconcerto.sql.Configuration;
26
import org.openconcerto.sql.element.BaseSQLComponent;
27
import org.openconcerto.sql.element.ElementSQLObject;
28
import org.openconcerto.sql.element.SQLElement;
61 ilm 29
import org.openconcerto.sql.model.SQLBackgroundTableCache;
41 ilm 30
import org.openconcerto.sql.model.SQLBase;
31
import org.openconcerto.sql.model.SQLRow;
32
import org.openconcerto.sql.model.SQLRowAccessor;
33
import org.openconcerto.sql.model.SQLRowValues;
34
import org.openconcerto.sql.model.SQLTable;
35
import org.openconcerto.sql.model.UndefinedRowValuesCache;
36
import org.openconcerto.sql.sqlobject.ElementComboBox;
37
import org.openconcerto.sql.sqlobject.SQLTextCombo;
38
import org.openconcerto.ui.DefaultGridBagConstraints;
39
import org.openconcerto.ui.FormLayouter;
40
import org.openconcerto.ui.TitledSeparator;
41
import org.openconcerto.ui.component.ITextArea;
93 ilm 42
import org.openconcerto.ui.component.InteractionMode;
41 ilm 43
 
94 ilm 44
import java.awt.Dimension;
45
import java.awt.GridBagConstraints;
46
import java.awt.GridBagLayout;
47
import java.awt.event.ActionListener;
48
import java.sql.SQLException;
49
 
50
import javax.swing.JCheckBox;
51
import javax.swing.JLabel;
52
import javax.swing.JPanel;
53
import javax.swing.JScrollPane;
54
import javax.swing.JTabbedPane;
55
import javax.swing.JTextField;
56
import javax.swing.SwingConstants;
57
 
41 ilm 58
public class FournisseurSQLComponent extends BaseSQLComponent {
59
 
60
    public FournisseurSQLComponent(SQLElement elt) {
61
        super(elt);
62
    }
63
 
64
    JCheckBox checkEnlevement;
65
    ElementSQLObject comp2;
66
    TitledSeparator sep2;
67
    private ContactItemTable table;
68
    private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT_FOURNISSEUR").getTable();
69
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
70
 
71
    public void addViews() {
72
        this.setLayout(new GridBagLayout());
73
        final GridBagConstraints c = new DefaultGridBagConstraints();
74
 
75
        // Code
80 ilm 76
        JLabel labelCode = new JLabel("Code", SwingConstants.RIGHT);
41 ilm 77
        JTextField textCode = new JTextField();
78
        c.gridx = 0;
79
        c.gridy++;
80
        c.weightx = 0;
81
        c.weighty = 0;
82
        this.add(labelCode, c);
83
        c.gridx++;
84
        c.weightx = 0.5;
85
        this.add(textCode, c);
86
 
87
        c.gridy++;
88
        c.gridx = 0;
89
        c.weightx = 0;
90
        // Raison sociale
80 ilm 91
        JLabel labelRS = new JLabel("Forme juridique", SwingConstants.RIGHT);
41 ilm 92
        SQLTextCombo textType = new SQLTextCombo();
93
        JTextField textNom = new JTextField();
94
 
95
        this.add(labelRS, c);
96
        c.gridx++;
97
        c.weightx = 0.5;
98
        this.add(textType, c);
99
 
100
        // Tel
80 ilm 101
        JLabel labelTel = new JLabel(getLabelFor("TEL"), SwingConstants.RIGHT);
102
        JTextField textTel = new JTextField(15);
41 ilm 103
        c.gridx++;
104
        c.weightx = 0;
105
        c.weighty = 0;
80 ilm 106
 
41 ilm 107
        this.add(labelTel, c);
108
        c.gridx++;
80 ilm 109
 
41 ilm 110
        c.weightx = 0.5;
111
        this.add(textTel, c);
112
 
113
        // Nom
114
        c.gridy++;
115
        c.gridx = 0;
116
        c.weightx = 0;
117
        String fieldNom = "NOM";
118
        if (getTable().contains("NOM_SOCIETE")) {
119
            fieldNom = "NOM_SOCIETE";
120
        }
80 ilm 121
        this.add(new JLabel(getLabelFor(fieldNom), SwingConstants.RIGHT), c);
41 ilm 122
        c.gridx++;
80 ilm 123
 
41 ilm 124
        c.weightx = 0.5;
125
        this.add(textNom, c);
126
        this.addRequiredSQLObject(textNom, fieldNom);
127
 
128
        // Fax
129
        c.gridx++;
130
        c.weightx = 0;
80 ilm 131
        this.add(new JLabel(getLabelFor("FAX"), SwingConstants.RIGHT), c);
41 ilm 132
        c.gridx++;
80 ilm 133
 
41 ilm 134
        c.weightx = 0.5;
135
        JTextField textFax = new JTextField();
136
        this.add(textFax, c);
137
 
138
        // Mail
139
        c.gridy++;
140
        c.gridx = 0;
141
        c.weightx = 0;
80 ilm 142
        c.gridwidth = 1;
143
        this.add(new JLabel(getLabelFor("MAIL"), SwingConstants.RIGHT), c);
41 ilm 144
        c.gridx++;
80 ilm 145
 
41 ilm 146
        c.weightx = 0.5;
147
        JTextField textMail = new JTextField();
148
        this.add(textMail, c);
149
        this.addView(textMail, "MAIL");
150
 
151
        // Tel P
152
        c.gridx++;
153
        c.weightx = 0;
80 ilm 154
 
155
        this.add(new JLabel(getLabelFor("TEL_P"), SwingConstants.RIGHT), c);
41 ilm 156
        c.gridx++;
157
        c.weightx = 0.5;
158
        JTextField textTelP = new JTextField();
159
        this.add(textTelP, c);
160
        this.addView(textTelP, "TEL_P");
161
        // Langue
162
        c.gridy++;
163
        c.gridx = 0;
164
        c.weightx = 0;
80 ilm 165
        this.add(new JLabel(getLabelFor("ID_LANGUE"), SwingConstants.RIGHT), c);
41 ilm 166
        c.gridx++;
167
        c.weightx = 0.5;
168
        ElementComboBox langue = new ElementComboBox(true, 35);
169
        this.add(langue, c);
170
        this.addView(langue, "ID_LANGUE");
171
 
172
        // Resp
173
        c.gridx++;
174
        c.weightx = 0;
80 ilm 175
        this.add(new JLabel(getLabelFor("RESPONSABLE"), SwingConstants.RIGHT), c);
41 ilm 176
        c.gridx++;
177
        c.weightx = 0.5;
178
        JTextField textResp = new JTextField();
179
        this.add(textResp, c);
180
        this.addView(textResp, "RESPONSABLE");
144 ilm 181
 
182
        // Siret
183
        c.gridy++;
184
        c.gridx = 0;
185
        c.weightx = 0;
186
        this.add(new JLabel(getLabelFor("SIRET"), SwingConstants.RIGHT), c);
187
        c.gridx++;
188
        c.weightx = 0.5;
189
        JTextField textSiret = new JTextField();
190
        ;
191
        this.add(textSiret, c);
192
        this.addView(textSiret, "SIRET");
193
 
194
        // tva
195
        c.gridx++;
196
        c.weightx = 0;
197
        this.add(new JLabel(getLabelFor("NUMERO_TVA"), SwingConstants.RIGHT), c);
198
        c.gridx++;
199
        c.weightx = 0.5;
200
        JTextField textNumeroTVA = new JTextField();
201
        this.add(textNumeroTVA, c);
202
        this.addView(textNumeroTVA, "NUMERO_TVA");
203
 
80 ilm 204
        c.gridx = 1;
41 ilm 205
        c.gridy++;
206
        JCheckBox boxUE = new JCheckBox(getLabelFor("UE"));
207
        this.add(boxUE, c);
208
 
83 ilm 209
        if (getTable().contains("ID_DEVISE")) {
210
            c.gridx++;
211
            c.weightx = 0;
212
            this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);
213
            c.gridx++;
214
            c.weightx = 0.5;
215
            ElementComboBox devise = new ElementComboBox(true, 35);
216
            this.add(devise, c);
217
            this.addView(devise, "ID_DEVISE");
218
        }
219
 
94 ilm 220
        if (getTable().contains("ALG_REGISTRE")) {
221
            c.gridy++;
222
            c.gridx = 0;
223
            c.weightx = 0;
224
            this.add(new JLabel(getLabelFor("ALG_REGISTRE"), SwingConstants.RIGHT), c);
225
            c.gridx++;
226
            c.weightx = 1;
227
            JTextField fieldRegistre = new JTextField(20);
228
            this.add(fieldRegistre, c);
229
            this.addView(fieldRegistre, "ALG_REGISTRE");
230
 
231
            c.gridx++;
232
            c.weightx = 0;
233
            this.add(new JLabel(getLabelFor("ALG_MATRICULE"), SwingConstants.RIGHT), c);
234
            c.gridx++;
235
            c.weightx = 1;
236
            JTextField fieldMatricule = new JTextField(20);
237
            this.add(fieldMatricule, c);
238
            this.addView(fieldMatricule, "ALG_MATRICULE");
239
 
240
            c.gridy++;
241
            c.gridx = 0;
242
            c.weightx = 0;
243
            this.add(new JLabel(getLabelFor("ALG_ARTICLE"), SwingConstants.RIGHT), c);
244
            c.gridx++;
245
            c.weightx = 1;
246
            JTextField fieldArticle = new JTextField(20);
247
            this.add(fieldArticle, c);
248
            this.addView(fieldArticle, "ALG_ARTICLE");
249
        }
250
 
41 ilm 251
        // Champ Module
252
        c.gridx = 0;
253
        c.gridy++;
254
        c.gridwidth = GridBagConstraints.REMAINDER;
63 ilm 255
        final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
41 ilm 256
        this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
257
        this.add(addP, c);
258
 
94 ilm 259
        // Tabbed
260
        JTabbedPane tabbedPane = new JTabbedPane();
261
 
41 ilm 262
        JPanel panelAdresse = new JPanel(new GridBagLayout());
132 ilm 263
        panelAdresse.setOpaque(false);
41 ilm 264
        GridBagConstraints cAdr = new DefaultGridBagConstraints();
265
        // Adresse
266
        TitledSeparator sep = new TitledSeparator("Adresse");
132 ilm 267
        sep.setOpaque(false);
41 ilm 268
        panelAdresse.add(sep, cAdr);
269
 
270
        this.sep2 = new TitledSeparator("Adresse d'enlévement");
132 ilm 271
        this.sep2.setOpaque(false);
41 ilm 272
        cAdr.gridx = GridBagConstraints.RELATIVE;
273
        panelAdresse.add(this.sep2, cAdr);
274
 
275
        //
276
 
277
        this.addView("ID_ADRESSE", REQ + ";" + DEC + ";" + SEP);
278
 
279
        cAdr.gridy++;
94 ilm 280
        cAdr.fill = GridBagConstraints.HORIZONTAL;
281
        cAdr.weightx = 1;
132 ilm 282
        final ElementSQLObject view = (ElementSQLObject) this.getView("ID_ADRESSE");
283
        view.setOpaque(false);
284
        panelAdresse.add(view, cAdr);
41 ilm 285
 
286
        // Selection de 2eme adresse
287
        this.addView("ID_ADRESSE_E", DEC);
288
        cAdr.gridx = GridBagConstraints.RELATIVE;
289
        this.comp2 = (ElementSQLObject) this.getView("ID_ADRESSE_E");
290
        this.comp2.setCreated(true);
132 ilm 291
        this.comp2.setOpaque(false);
41 ilm 292
        panelAdresse.add(this.comp2, cAdr);
293
 
294
        this.checkEnlevement = new JCheckBox("Adresse d'enlèvement identique");
132 ilm 295
        this.checkEnlevement.setOpaque(false);
94 ilm 296
        cAdr.gridx = 0;
297
        cAdr.gridy++;
298
        cAdr.gridwidth = GridBagConstraints.REMAINDER;
299
        panelAdresse.add(this.checkEnlevement, cAdr);
300
        tabbedPane.add("Adresses", panelAdresse);
41 ilm 301
 
302
        this.checkEnlevement.setSelected(true);
303
        this.sep2.setVisible(false);
304
        this.checkEnlevement.addActionListener(new ActionListener() {
305
 
306
            public void actionPerformed(java.awt.event.ActionEvent e) {
307
                System.out.println("Click");
308
                if (checkEnlevement.isSelected()) {
309
                    System.out.println("Mode 1");
93 ilm 310
                    comp2.setEditable(InteractionMode.DISABLED);
41 ilm 311
                    comp2.setCreated(false);
312
                    sep2.setVisible(false);
313
                } else {
314
                    System.out.println("Mode 2");
93 ilm 315
                    comp2.setEditable(InteractionMode.READ_WRITE);
41 ilm 316
                    comp2.setCreated(true);
317
                    sep2.setVisible(true);
318
                }
319
            };
320
        });
321
 
322
        // Contact
94 ilm 323
        JPanel panelContact = new JPanel(new GridBagLayout());
149 ilm 324
        panelContact.setOpaque(false);
41 ilm 325
        this.table = new ContactItemTable(this.defaultContactRowVals);
149 ilm 326
        this.table.setOpaque(false);
41 ilm 327
        this.table.setPreferredSize(new Dimension(this.table.getSize().width, 150));
94 ilm 328
        GridBagConstraints cContact = new DefaultGridBagConstraints();
329
        cContact.fill = GridBagConstraints.BOTH;
330
        cContact.weightx = 1;
331
        cContact.weighty = 1;
332
        panelContact.add(this.table, cContact);
333
        tabbedPane.add("Contacts", panelContact);
41 ilm 334
        c.gridx = 0;
335
        c.gridy++;
149 ilm 336
        c.anchor = GridBagConstraints.NORTHWEST;
41 ilm 337
        c.fill = GridBagConstraints.BOTH;
338
        c.gridwidth = GridBagConstraints.REMAINDER;
94 ilm 339
        this.add(tabbedPane, c);
41 ilm 340
 
149 ilm 341
        // Mode de réglement
41 ilm 342
        TitledSeparator reglSep = new TitledSeparator(getLabelFor("ID_MODE_REGLEMENT"));
149 ilm 343
        c.gridwidth = 2;
41 ilm 344
        c.gridy++;
345
        c.gridx = 0;
346
        this.add(reglSep, c);
347
 
348
        c.gridy++;
349
        c.gridx = 0;
80 ilm 350
        c.fill = GridBagConstraints.NONE;
41 ilm 351
        this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
352
        ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
353
        this.add(eltModeRegl, c);
354
 
149 ilm 355
        //
356
        {
357
            c.gridx = 2;
358
            c.gridy--;
359
            c.gridwidth = 2;
360
            c.fill = GridBagConstraints.BOTH;
361
            TitledSeparator ribSep = new TitledSeparator("Coordonnées bancaires");
362
 
363
            this.add(ribSep, c);
364
 
365
            final JPanel pCoordonneesBancaires = new JPanel();
366
            pCoordonneesBancaires.setLayout(new GridBagLayout());
367
            GridBagConstraints c2 = new DefaultGridBagConstraints();
368
 
369
            c2.gridy++;
370
            // IBAN
371
            JLabel labelIBAN = new JLabel("IBAN", SwingConstants.RIGHT);
372
            JTextField textIBAN = new JTextField(40);
373
            c2.weightx = 0;
374
            pCoordonneesBancaires.add(labelIBAN, c2);
375
            c2.gridx++;
376
            c2.weightx = 1;
377
            pCoordonneesBancaires.add(textIBAN, c2);
378
 
379
            // BIC
380
            JLabel labelBIC = new JLabel("BIC", SwingConstants.RIGHT);
180 ilm 381
            JTextField textBIC = new JTextField(20);
149 ilm 382
            c2.gridx = 0;
383
            c2.gridy++;
384
            c2.weightx = 0;
385
            pCoordonneesBancaires.add(labelBIC, c2);
386
            c2.gridx++;
387
            c2.weightx = 1;
388
            c2.fill = GridBagConstraints.NONE;
389
            pCoordonneesBancaires.add(textBIC, c2);
390
            c.gridy++;
391
            c.fill = GridBagConstraints.HORIZONTAL;
392
            this.add(pCoordonneesBancaires, c);
393
 
394
            this.addView(textIBAN, "IBAN");
395
            this.addView(textBIC, "BIC");
396
        }
41 ilm 397
        // Compte associé
398
 
399
        c.gridx = 0;
400
        c.gridy++;
401
        c.weightx = 1;
402
        c.weighty = 0;
80 ilm 403
        c.fill = GridBagConstraints.HORIZONTAL;
41 ilm 404
        c.gridwidth = GridBagConstraints.REMAINDER;
80 ilm 405
        TitledSeparator sepCompteCharge = new TitledSeparator("Comptes associés");
406
        this.add(sepCompteCharge, c);
41 ilm 407
 
80 ilm 408
        final JPanel panel = new JPanel(new GridBagLayout());
409
        final GridBagConstraints c2 = new DefaultGridBagConstraints();
410
        panel.add(new JLabel("Compte fournisseur associé", SwingConstants.RIGHT), c2);
41 ilm 411
        ISQLCompteSelector compteSel = new ISQLCompteSelector(true);
412
        c2.gridx++;
413
        c2.weightx = 1;
414
        panel.add(compteSel, c2);
80 ilm 415
        c2.gridx = 0;
416
        c2.gridy++;
417
        c2.weightx = 0;
418
        panel.add(new JLabel(getLabelFor("ID_COMPTE_PCE_CHARGE"), SwingConstants.RIGHT), c2);
419
        ISQLCompteSelector compteSelCharge = new ISQLCompteSelector(true);
420
        c2.gridx++;
421
        c2.weightx = 1;
422
        panel.add(compteSelCharge, c2);
61 ilm 423
        addView(compteSelCharge, "ID_COMPTE_PCE_CHARGE");
424
 
425
        c.gridwidth = GridBagConstraints.REMAINDER;
426
        c.gridy++;
427
        c.gridx = 0;
428
        c.weightx = 1;
429
        c.anchor = GridBagConstraints.NORTHWEST;
80 ilm 430
        this.add(panel, c);
61 ilm 431
 
149 ilm 432
        c.gridwidth = 1;
433
        c.gridy++;
434
        c.gridx = 0;
435
        c.weightx = 1;
436
        c.anchor = GridBagConstraints.NORTHWEST;
437
 
41 ilm 438
        // INfos
439
        c.gridx = 0;
440
        c.gridy++;
441
        c.gridheight = 1;
442
        c.weightx = 1;
443
        c.anchor = GridBagConstraints.WEST;
444
        c.gridwidth = GridBagConstraints.REMAINDER;
445
        this.add(new TitledSeparator(getLabelFor("INFOS")), c);
446
 
447
        c.gridy++;
448
        c.weightx = 1;
449
        c.weighty = 1;
450
        c.fill = GridBagConstraints.BOTH;
451
        ITextArea infos = new ITextArea();
452
        final JScrollPane scrollPane = new JScrollPane(infos);
453
        scrollPane.setBorder(null);
454
        this.add(scrollPane, c);
455
        this.addView(infos, "INFOS");
456
 
457
        this.addSQLObject(textType, "TYPE");
458
 
459
        this.addSQLObject(textCode, "CODE");
460
        this.addSQLObject(textTel, "TEL");
461
        this.addSQLObject(textFax, "FAX");
462
        this.addSQLObject(boxUE, "UE");
463
        this.addRequiredSQLObject(compteSel, "ID_COMPTE_PCE");
464
        // this.addRequiredPrivateForeignField(adresse,"ID_ADRESSE");
465
 
466
        // this.addSQLObject(adresse, "VILLE");
467
        /***********************************************************************************
468
         * this.addSQLObject(new JTextField(), "NUMERO_CANTON"); this.addSQLObject(new JTextField(),
469
         * "NUMERO_COMMUNE");
470
         */
471
 
472
        // Select Compte fournisseur par defaut
473
        final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
474
        final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
475
        final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
476
        int idCompteFourn = rowPrefsCompte.getInt("ID_COMPTE_PCE_FOURNISSEUR");
477
        if (idCompteFourn <= 1) {
478
            try {
479
                idCompteFourn = ComptePCESQLElement.getIdComptePceDefault("Fournisseurs");
480
            } catch (Exception e) {
481
                e.printStackTrace();
482
            }
483
        }
484
 
485
        compteSel.setValue(idCompteFourn);
486
    }
487
 
488
    @Override
489
    public void select(SQLRowAccessor r) {
490
        if (r != null && r.isForeignEmpty("ID_ADRESSE_E")) {
491
            this.checkEnlevement.setSelected(true);
93 ilm 492
            this.comp2.setEditable(InteractionMode.DISABLED);
41 ilm 493
            this.comp2.setCreated(false);
494
            this.sep2.setVisible(false);
495
        } else {
496
            this.checkEnlevement.setSelected(false);
93 ilm 497
            this.comp2.setEditable(InteractionMode.READ_WRITE);
41 ilm 498
            this.comp2.setCreated(true);
499
            this.sep2.setVisible(true);
500
        }
501
 
502
        if (r != null) {
73 ilm 503
            this.table.insertFrom("ID_" + this.getTable().getName(), r.asRowValues());
41 ilm 504
            this.defaultContactRowVals.put("TEL_DIRECT", r.getString("TEL"));
505
            this.defaultContactRowVals.put("FAX", r.getString("FAX"));
506
        }
507
 
508
        super.select(r);
509
    }
510
 
511
    @Override
512
    public void update() {
513
        // TODO Raccord de méthode auto-généré
514
        super.update();
515
        this.table.updateField("ID_" + this.getTable().getName(), getSelectedID());
516
    }
517
 
518
    @Override
519
    public int insert(SQLRow order) {
520
        // TODO Raccord de méthode auto-généré
521
        int id = super.insert(order);
522
        this.table.updateField("ID_" + this.getTable().getName(), id);
523
        return id;
524
    }
525
 
526
    @Override
527
    protected SQLRowValues createDefaults() {
528
        SQLRowValues vals = new SQLRowValues(this.getTable());
529
        SQLRowAccessor r;
530
        this.checkEnlevement.setSelected(true);
531
        this.sep2.setVisible(false);
532
        try {
533
            r = ModeReglementDefautPrefPanel.getDefaultRow(false);
534
            SQLElement eltModeReglement = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
535
            if (r.getID() > 1) {
536
                SQLRowValues rowVals = eltModeReglement.createCopy(r.getID());
537
                System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT"));
538
                vals.put("ID_MODE_REGLEMENT", rowVals);
539
            }
540
        } catch (SQLException e) {
541
            System.err.println("Impossible de sélectionner le mode de règlement par défaut du client.");
542
            e.printStackTrace();
543
        }
61 ilm 544
 
545
        // Select Compte charge par defaut
546
        final SQLTable tablePrefCompte = getTable().getTable("PREFS_COMPTE");
547
        final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
548
        // compte Achat
549
        int idCompteAchat = rowPrefsCompte.getInt("ID_COMPTE_PCE_ACHAT");
550
        if (idCompteAchat <= 1) {
551
            try {
552
                idCompteAchat = ComptePCESQLElement.getIdComptePceDefault("Achats");
553
            } catch (Exception e) {
554
                e.printStackTrace();
555
            }
556
        }
557
        vals.put("ID_COMPTE_PCE_CHARGE", idCompteAchat);
41 ilm 558
        return vals;
559
    }
560
 
561
}