OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 156 Rev 174
Line 58... Line 58...
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.HashMap;
62
import java.util.HashMap;
-
 
63
import java.util.HashSet;
63
import java.util.List;
64
import java.util.List;
64
import java.util.Map;
65
import java.util.Map;
-
 
66
import java.util.Set;
65
 
67
 
66
import javax.swing.JCheckBox;
68
import javax.swing.JCheckBox;
67
import javax.swing.JLabel;
69
import javax.swing.JLabel;
-
 
70
import javax.swing.JOptionPane;
68
import javax.swing.JPanel;
71
import javax.swing.JPanel;
69
import javax.swing.JScrollPane;
72
import javax.swing.JScrollPane;
70
import javax.swing.JTextField;
73
import javax.swing.JTextField;
71
import javax.swing.SwingConstants;
74
import javax.swing.SwingConstants;
72
import javax.swing.SwingUtilities;
75
import javax.swing.SwingUtilities;
Line 89... Line 92...
89
    public BonReceptionSQLComponent() {
92
    public BonReceptionSQLComponent() {
90
        super(Configuration.getInstance().getDirectory().getElement("BON_RECEPTION"));
93
        super(Configuration.getInstance().getDirectory().getElement("BON_RECEPTION"));
91
    }
94
    }
92
 
95
 
93
    @Override
96
    @Override
-
 
97
    protected Set<String> createRequiredNames() {
-
 
98
        final Set<String> s = new HashSet<>(1);
-
 
99
        if (getTable().contains("ID_TYPE_CMD")) {
-
 
100
            s.add("ID_TYPE_CMD");
-
 
101
        }
-
 
102
        return s;
-
 
103
    }
-
 
104
 
-
 
105
    @Override
94
    protected SQLRowValues createDefaults() {
106
    protected SQLRowValues createDefaults() {
95
        this.tableBonItem.getModel().clearRows();
107
        this.tableBonItem.getModel().clearRows();
96
        this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
108
        this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
97
        SQLRowValues rowVals = new SQLRowValues(getTable());
109
        SQLRowValues rowVals = new SQLRowValues(getTable());
98
        rowVals.put("T_DEVISE", 0L);
110
        rowVals.put("T_DEVISE", 0L);
Line 626... Line 638...
626
                    }
638
                    }
627
                }
639
                }
628
            }
640
            }
629
        }
641
        }
630
        int count = this.tableBonItem.getModel().getRowCount();
642
        int count = this.tableBonItem.getModel().getRowCount();
-
 
643
        int receipt = 0;
-
 
644
 
631
        for (int i = 0; i < count; i++) {
645
        for (int i = 0; i < count; i++) {
632
            SQLRowValues r = this.tableBonItem.getModel().getRowValuesAt(i);
646
            SQLRowValues r = this.tableBonItem.getModel().getRowValuesAt(i);
633
            SQLRowValues rowTR = map.get(r.getForeignID("ID_ARTICLE"));
647
            SQLRowValues rowTR = map.get(r.getForeignID("ID_ARTICLE"));
634
            if (rowTR != null && !rowTR.isUndefined()) {
648
            if (rowTR != null && !rowTR.isUndefined()) {
635
                if (r.getInt("QTE") > 0) {
649
                if (r.getInt("QTE") > 0) {
636
                    if (NumberUtils.areNumericallyEqual(r.getBigDecimal("QTE_UNITAIRE"), BigDecimal.ONE) || r.getInt("QTE") > 1) {
650
                    if (NumberUtils.areNumericallyEqual(r.getBigDecimal("QTE_UNITAIRE"), BigDecimal.ONE) || r.getInt("QTE") > 1) {
-
 
651
                        int value = r.getInt("QTE") - rowTR.getInt("QTE");
-
 
652
                        if ((value <= 0)) {
-
 
653
                            receipt++;
-
 
654
                        }
-
 
655
 
637
                        this.tableBonItem.getModel().putValue(r.getInt("QTE") - rowTR.getInt("QTE"), i, "QTE");
656
                        this.tableBonItem.getModel().putValue(Math.max(0, value), i, "QTE");
-
 
657
                    } else {
-
 
658
                        BigDecimal subtract = r.getBigDecimal("QTE_UNITAIRE").subtract(rowTR.getBigDecimal("QTE_UNITAIRE"));
-
 
659
                        if (subtract.signum() <= 0) {
-
 
660
                            receipt++;
-
 
661
                        }
-
 
662
                        this.tableBonItem.getModel().putValue(subtract.max(BigDecimal.ZERO), i, "QTE_UNITAIRE");
-
 
663
                    }
638
                    } else {
664
                } else {
639
                        this.tableBonItem.getModel().putValue(r.getBigDecimal("QTE_UNITAIRE").subtract(rowTR.getBigDecimal("QTE_UNITAIRE")), i, "QTE_UNITAIRE");
665
                    receipt++;
640
                    }
666
                }
641
                }
667
            }
642
            }
668
        }
-
 
669
        if (receipt == count) {
-
 
670
            JOptionPane.showMessageDialog(null, "Attention tous les articles ont déjà été réceptionné!");
643
        }
671
        }
644
    }
672
    }
645
 
673
 
646
    @Override
674
    @Override
647
    public void update() {
675
    public void update() {