OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 57... Line 57...
57
import java.awt.GridBagLayout;
57
import java.awt.GridBagLayout;
58
import java.beans.PropertyChangeEvent;
58
import java.beans.PropertyChangeEvent;
59
import java.beans.PropertyChangeListener;
59
import java.beans.PropertyChangeListener;
60
import java.math.BigDecimal;
60
import java.math.BigDecimal;
61
import java.sql.SQLException;
61
import java.sql.SQLException;
-
 
62
import java.util.HashSet;
-
 
63
import java.util.List;
-
 
64
import java.util.Set;
62
 
65
 
63
import javax.swing.JLabel;
66
import javax.swing.JLabel;
64
import javax.swing.JPanel;
67
import javax.swing.JPanel;
65
import javax.swing.JScrollPane;
68
import javax.swing.JScrollPane;
66
import javax.swing.JTextField;
69
import javax.swing.JTextField;
67
import javax.swing.SwingConstants;
70
import javax.swing.SwingConstants;
-
 
71
import javax.swing.SwingUtilities;
68
import javax.swing.event.DocumentEvent;
72
import javax.swing.event.DocumentEvent;
69
import javax.swing.event.DocumentListener;
73
import javax.swing.event.DocumentListener;
70
import javax.swing.event.TableModelEvent;
74
import javax.swing.event.TableModelEvent;
71
import javax.swing.event.TableModelListener;
75
import javax.swing.event.TableModelListener;
72
 
76
 
Line 100... Line 104...
100
                // compteSel.setValue(rowCharge);
104
                // compteSel.setValue(rowCharge);
101
                // }
105
                // }
102
 
106
 
103
                int idModeRegl = rowFourn.getInt("ID_MODE_REGLEMENT");
107
                int idModeRegl = rowFourn.getInt("ID_MODE_REGLEMENT");
104
                if (idModeRegl > 1 && FactureFournisseurSQLComponent.this.eltModeRegl != null && getMode() == Mode.INSERTION) {
108
                if (idModeRegl > 1 && FactureFournisseurSQLComponent.this.eltModeRegl != null && getMode() == Mode.INSERTION) {
105
                    SQLElement sqlEltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
109
                    SQLElement sqlEltModeRegl = getElement().getDirectory().getElement("MODE_REGLEMENT");
106
                    SQLRow rowModeRegl = sqlEltModeRegl.getTable().getRow(idModeRegl);
110
                    SQLRow rowModeRegl = sqlEltModeRegl.getTable().getRow(idModeRegl);
107
                    SQLRowValues rowVals = rowModeRegl.createUpdateRow();
111
                    SQLRowValues rowVals = rowModeRegl.createUpdateRow();
108
                    rowVals.clearPrimaryKeys();
112
                    rowVals.clearPrimaryKeys();
109
                    FactureFournisseurSQLComponent.this.eltModeRegl.setValue(rowVals);
113
                    FactureFournisseurSQLComponent.this.eltModeRegl.setValue(rowVals);
110
                    System.err.println("Select Mode regl " + idModeRegl);
114
                    System.err.println("Select Mode regl " + idModeRegl);
Line 122... Line 126...
122
 
126
 
123
    public ElementComboBox getBoxFournisseur() {
127
    public ElementComboBox getBoxFournisseur() {
124
        return this.fourn;
128
        return this.fourn;
125
    }
129
    }
126
 
130
 
-
 
131
    @Override
-
 
132
    protected Set<String> createRequiredNames() {
-
 
133
        final Set<String> s = new HashSet<>(1);
-
 
134
        if (getTable().contains("ID_TYPE_CMD")) {
-
 
135
            s.add("ID_TYPE_CMD");
-
 
136
        }
-
 
137
        return s;
-
 
138
    }
-
 
139
 
127
    public void addViews() {
140
    public void addViews() {
128
        this.setLayout(new GridBagLayout());
141
        this.setLayout(new GridBagLayout());
129
        final GridBagConstraints c = new DefaultGridBagConstraints();
142
        final GridBagConstraints c = new DefaultGridBagConstraints();
130
 
143
 
131
        // Numero du commande
144
        // Numero du commande
Line 478... Line 491...
478
 
491
 
479
        DeviseField textPortHT = new DeviseField();
492
        DeviseField textPortHT = new DeviseField();
480
        ElementComboBox comboTaxePort = new ElementComboBox();
493
        ElementComboBox comboTaxePort = new ElementComboBox();
481
        DeviseField textRemiseHT = new DeviseField();
494
        DeviseField textRemiseHT = new DeviseField();
482
 
495
 
483
        if (getTable().contains("PORT_HT")) {
-
 
484
            addSQLObject(textPortHT, "PORT_HT");
-
 
485
            final JPanel panelPoids = new JPanel(new GridBagLayout());
496
        final JPanel panelPoids = new JPanel(new GridBagLayout());
486
            GridBagConstraints cPort = new DefaultGridBagConstraints();
497
        GridBagConstraints cPort = new DefaultGridBagConstraints();
-
 
498
        if (getTable().contains("PORT_HT")) {
-
 
499
            addSQLObject(textPortHT, "PORT_HT");
487
            cPort.gridx = 0;
500
            cPort.gridx = 0;
488
            cPort.weightx = 0;
501
            cPort.weightx = 0;
489
            panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort);
502
            panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort);
490
            textPortHT.setHorizontalAlignment(JTextField.RIGHT);
503
            textPortHT.setHorizontalAlignment(JTextField.RIGHT);
491
            cPort.gridx++;
504
            cPort.gridx++;
Line 560... Line 573...
560
        this.allowEditable("T_POIDS", false);
573
        this.allowEditable("T_POIDS", false);
561
 
574
 
562
        final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null,
575
        final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null,
563
                (getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null), null);
576
                (getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null), null);
564
 
577
 
-
 
578
        if (getTable().contains("TVA_ADJUSTMENT")) {
-
 
579
            final JTextField textTvaAdujs = new JTextField(15);
-
 
580
 
-
 
581
            JLabel labelTvaAdujst = new JLabel(getLabelFor("TVA_ADJUSTMENT"));
-
 
582
            labelTvaAdujst.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
583
 
-
 
584
            cPort.gridx = 0;
-
 
585
            cPort.gridy++;
-
 
586
            panelPoids.add(labelTvaAdujst, cPort);
-
 
587
            cPort.gridx++;
-
 
588
            panelPoids.add(textTvaAdujs, cPort);
-
 
589
            addView(textTvaAdujs, "TVA_ADJUSTMENT");
-
 
590
            totalTTC.setTextFixTVA(textTvaAdujs);
-
 
591
            textTvaAdujs.getDocument().addDocumentListener(new SimpleDocumentListener() {
-
 
592
                @Override
-
 
593
                public void update(final DocumentEvent e) {
-
 
594
                    final String text = textTvaAdujs.getText();
-
 
595
                    if (text != null && text.trim().length() > 0) {
-
 
596
                        if (!text.trim().equals("-")) {
-
 
597
                            BigDecimal tvaFix = new BigDecimal(text);
-
 
598
                            if (tvaFix.abs().compareTo(new BigDecimal(0.05)) > 0) {
-
 
599
                                final String limitedFix;
-
 
600
                                if (tvaFix.signum() > 0) {
-
 
601
                                    limitedFix = tvaFix.min(new BigDecimal(0.05)).toString();
-
 
602
                                } else {
-
 
603
                                    limitedFix = tvaFix.max(new BigDecimal(-0.05)).toString();
-
 
604
                                }
-
 
605
                                SwingUtilities.invokeLater(new Runnable() {
-
 
606
                                    @Override
-
 
607
                                    public void run() {
-
 
608
 
-
 
609
                                        textTvaAdujs.setText(limitedFix);
-
 
610
                                    }
-
 
611
                                });
-
 
612
                            }
-
 
613
                        }
-
 
614
                    }
-
 
615
                    totalTTC.updateTotal();
-
 
616
                }
-
 
617
            });
-
 
618
            DefaultGridBagConstraints.lockMinimumSize(textTvaAdujs);
-
 
619
        }
-
 
620
 
565
        c.gridx++;
621
        c.gridx++;
566
        c.gridy--;
622
        c.gridy--;
567
        c.gridwidth = GridBagConstraints.REMAINDER;
623
        c.gridwidth = GridBagConstraints.REMAINDER;
568
        c.gridheight = 2;
624
        c.gridheight = 2;
569
        c.anchor = GridBagConstraints.NORTHEAST;
625
        c.anchor = GridBagConstraints.NORTHEAST;
Line 856... Line 912...
856
            updateLabelTauxConversion();
912
            updateLabelTauxConversion();
857
        }
913
        }
858
 
914
 
859
    }
915
    }
860
 
916
 
-
 
917
    public void loadFactureExistante(int idFacture) {
-
 
918
 
-
 
919
        SQLElement fact = getElement();
-
 
920
        SQLElement factElt = getElement().getDirectory().getElement("FACTURE_FOURNISSEUR_ELEMENT");
-
 
921
 
-
 
922
        // On duplique la facture
-
 
923
        if (idFacture > 1) {
-
 
924
            SQLRow row = fact.getTable().getRow(idFacture);
-
 
925
            SQLRowValues rowVals = new SQLRowValues(fact.getTable());
-
 
926
            rowVals.put("ID_FOURNISSEUR", row.getInt("ID_FOURNISSEUR"));
-
 
927
            // if (getTable().contains("ID_NUMEROTATION_AUTO")) {
-
 
928
            // rowVals.put("NUMERO",
-
 
929
            // NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new
-
 
930
            // Date(), row.getForeign("ID_NUMEROTATION_AUTO")));
-
 
931
            // } else {
-
 
932
            // rowVals.put("NUMERO",
-
 
933
            // NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new
-
 
934
            // Date()));
-
 
935
            // }
-
 
936
            rowVals.put("NOM", row.getObject("NOM"));
-
 
937
            this.select(rowVals);
-
 
938
        }
-
 
939
 
-
 
940
        // On duplique les elements de facture
-
 
941
        List<SQLRow> myListItem = fact.getTable().getRow(idFacture).getReferentRows(factElt.getTable());
-
 
942
 
-
 
943
        if (myListItem.size() != 0) {
-
 
944
            this.table.getModel().clearRows();
-
 
945
 
-
 
946
            for (SQLRow rowElt : myListItem) {
-
 
947
 
-
 
948
                SQLRowValues rowVals = rowElt.createUpdateRow();
-
 
949
                rowVals.clearPrimaryKeys();
-
 
950
                this.table.getModel().addRow(rowVals);
-
 
951
                int rowIndex = this.table.getModel().getRowCount() - 1;
-
 
952
                this.table.getModel().fireTableModelModified(rowIndex);
-
 
953
            }
-
 
954
        } else {
-
 
955
            this.table.getModel().clearRows();
-
 
956
        }
-
 
957
        this.table.getModel().fireTableDataChanged();
-
 
958
        this.table.repaint();
-
 
959
    }
-
 
960
 
861
}
961
}