OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 180 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
Line 21... Line 21...
21
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
21
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
22
import org.openconcerto.erp.core.common.ui.DeviseField;
22
import org.openconcerto.erp.core.common.ui.DeviseField;
23
import org.openconcerto.erp.core.common.ui.TotalPanel;
23
import org.openconcerto.erp.core.common.ui.TotalPanel;
24
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
24
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
25
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
25
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
-
 
26
import org.openconcerto.erp.core.supplychain.order.element.CommandeSQLElement;
26
import org.openconcerto.erp.core.supplychain.order.element.DemandeAchatItemSQLElement;
27
import org.openconcerto.erp.core.supplychain.order.element.DemandeAchatItemSQLElement;
27
import org.openconcerto.erp.core.supplychain.order.ui.CommandeItemTable;
28
import org.openconcerto.erp.core.supplychain.order.ui.CommandeItemTable;
28
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
29
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
29
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
30
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
30
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
31
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
Line 698... Line 699...
698
        JTextField poids = new JTextField();
699
        JTextField poids = new JTextField();
699
        if (b) {
700
        if (b) {
700
            final JPanel panelPoids = new JPanel(new GridBagLayout());
701
            final JPanel panelPoids = new JPanel(new GridBagLayout());
701
            GridBagConstraints cPoids = new DefaultGridBagConstraints();
702
            GridBagConstraints cPoids = new DefaultGridBagConstraints();
702
            cPoids.weightx = 0;
703
            cPoids.weightx = 0;
703
            panelPoids.add(new JLabel(getLabelFor("T_POIDS")), cPoids);
704
            panelPoids.add(new JLabel(getLabelFor("T_POIDS"), SwingConstants.RIGHT), cPoids);
704
            cPoids.weightx = 1;
705
            cPoids.weightx = 1;
705
            textPoidsTotal.setEnabled(false);
706
            textPoidsTotal.setEnabled(false);
706
            textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
707
            textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
707
            textPoidsTotal.setDisabledTextColor(Color.BLACK);
708
            textPoidsTotal.setDisabledTextColor(Color.BLACK);
708
            cPoids.gridx++;
709
            cPoids.gridx++;
Line 726... Line 727...
726
        DeviseField textPortHT = new DeviseField();
727
        DeviseField textPortHT = new DeviseField();
727
        DeviseField textRemiseHT = new DeviseField();
728
        DeviseField textRemiseHT = new DeviseField();
728
        ElementComboBox comboTaxePort = new ElementComboBox(false, 10);
729
        ElementComboBox comboTaxePort = new ElementComboBox(false, 10);
729
 
730
 
730
        if (getTable().contains("PORT_HT")) {
731
        if (getTable().contains("PORT_HT")) {
731
 
-
 
732
            addSQLObject(textPortHT, "PORT_HT");
-
 
733
            final JPanel panelPoids = new JPanel(new GridBagLayout());
732
            final JPanel panelPoids = new JPanel(new GridBagLayout());
734
            GridBagConstraints cPort = new DefaultGridBagConstraints();
733
            GridBagConstraints cPort = new DefaultGridBagConstraints();
735
            cPort.gridx = 0;
734
            cPort.gridx = 0;
-
 
735
            cPort.fill = GridBagConstraints.HORIZONTAL;
-
 
736
            cPort.weightx = 0;
-
 
737
            // Condition frais de port
-
 
738
            if (getTable().getForeignTable("ID_FOURNISSEUR").contains("CONDITIONS_PORT")) {
-
 
739
                cPort.gridwidth = 2;
-
 
740
                final JLabel labelConditionPort = new JLabel();
-
 
741
                labelConditionPort.setVisible(false);
-
 
742
                panelPoids.add(labelConditionPort, cPort);
-
 
743
 
-
 
744
                fourn.addModelListener("wantedID", (evt) -> {
-
 
745
                    int wantedID = fourn.getWantedID();
-
 
746
 
-
 
747
                    if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
-
 
748
 
-
 
749
                        final SQLRow rowF = getTable().getForeignTable("ID_FOURNISSEUR").getRow(wantedID);
-
 
750
 
-
 
751
                        final String conditions = rowF.getString("CONDITIONS_PORT");
-
 
752
                        if (conditions.trim().length() > 0) {
-
 
753
                            labelConditionPort.setText(conditions);
-
 
754
                            labelConditionPort.setVisible(true);
-
 
755
                        } else {
-
 
756
                            labelConditionPort.setText("");
-
 
757
                            labelConditionPort.setVisible(false);
-
 
758
                        }
-
 
759
 
-
 
760
                    } else {
-
 
761
                        labelConditionPort.setText("");
-
 
762
                        labelConditionPort.setVisible(false);
-
 
763
                    }
-
 
764
 
-
 
765
                });
-
 
766
                cPort.gridwidth = 1;
-
 
767
                cPort.gridy++;
-
 
768
            }
-
 
769
            addSQLObject(textPortHT, "PORT_HT");
-
 
770
            cPort.gridx = 0;
736
            cPort.fill = GridBagConstraints.NONE;
771
            cPort.fill = GridBagConstraints.HORIZONTAL;
737
            cPort.weightx = 0;
772
            cPort.weightx = 0;
738
            panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort);
773
            panelPoids.add(new JLabel(getLabelFor("PORT_HT"), SwingConstants.RIGHT), cPort);
739
            textPortHT.setHorizontalAlignment(JTextField.RIGHT);
774
            textPortHT.setHorizontalAlignment(JTextField.RIGHT);
740
            cPort.gridx++;
775
            cPort.gridx++;
741
            cPort.weightx = 1;
776
            cPort.weightx = 1;
742
            panelPoids.add(textPortHT, cPort);
777
            panelPoids.add(textPortHT, cPort);
743
 
778
 
744
            cPort.gridy++;
779
            cPort.gridy++;
745
            cPort.gridx = 0;
780
            cPort.gridx = 0;
746
            cPort.weightx = 0;
781
            cPort.weightx = 0;
747
            addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT");
782
            addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT");
748
            panelPoids.add(new JLabel(getLabelFor("ID_TAXE_PORT")), cPort);
783
            panelPoids.add(new JLabel(getLabelFor("ID_TAXE_PORT"), SwingConstants.RIGHT), cPort);
749
            cPort.gridx++;
784
            cPort.gridx++;
750
            cPort.weightx = 1;
785
            cPort.weightx = 1;
751
            panelPoids.add(comboTaxePort, cPort);
786
            panelPoids.add(comboTaxePort, cPort);
752
 
787
 
753
            addSQLObject(textRemiseHT, "REMISE_HT");
788
            addSQLObject(textRemiseHT, "REMISE_HT");
754
            cPort.gridy++;
789
            cPort.gridy++;
755
            cPort.gridx = 0;
790
            cPort.gridx = 0;
756
            cPort.fill = GridBagConstraints.NONE;
791
            cPort.fill = GridBagConstraints.HORIZONTAL;
757
            cPort.weightx = 0;
792
            cPort.weightx = 0;
758
            panelPoids.add(new JLabel(getLabelFor("REMISE_HT")), cPort);
793
            panelPoids.add(new JLabel(getLabelFor("REMISE_HT"), SwingConstants.RIGHT), cPort);
759
            textRemiseHT.setHorizontalAlignment(JTextField.RIGHT);
794
            textRemiseHT.setHorizontalAlignment(JTextField.RIGHT);
760
            cPort.gridx++;
795
            cPort.gridx++;
761
            cPort.weightx = 1;
796
            cPort.weightx = 1;
762
            panelPoids.add(textRemiseHT, cPort);
797
            panelPoids.add(textRemiseHT, cPort);
763
 
798
 
Line 912... Line 947...
912
            } catch (SQLException e) {
947
            } catch (SQLException e) {
913
                ExceptionHandler.handle("Erreur lors de la mise à jour du stock!", e);
948
                ExceptionHandler.handle("Erreur lors de la mise à jour du stock!", e);
914
            }
949
            }
915
 
950
 
916
            // generation du document
951
            // generation du document
-
 
952
            final SQLRow row = getTable().getRow(idCommande);
917
            final CommandeXmlSheet sheet = new CommandeXmlSheet(getTable().getRow(idCommande));
953
            final CommandeXmlSheet sheet = new CommandeXmlSheet(row);
918
            sheet.createDocumentAsynchronous();
954
            sheet.createDocumentAsynchronous();
919
            sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
955
            sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true, getElement(), row);
920
 
956
 
921
            // incrémentation du numéro auto
957
            // incrémentation du numéro auto
922
            if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
958
            if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
923
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
959
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
924
                int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()));
960
                int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(getElement().getClass()));
Line 932... Line 968...
932
                }
968
                }
933
            }
969
            }
934
            DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
970
            DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
935
            elt.updateStatus(getTable(), getTable().getTable("COMMANDE_ELEMENT"), idCommande);
971
            elt.updateStatus(getTable(), getTable().getTable("COMMANDE_ELEMENT"), idCommande);
936
 
972
 
-
 
973
            ((CommandeSQLElement) getElement()).fireInsertedCmdListener(row);
-
 
974
 
937
            if (attempt > 0) {
975
            if (attempt > 0) {
938
                SwingUtilities.invokeLater(new Runnable() {
976
                SwingUtilities.invokeLater(new Runnable() {
939
                    public void run() {
977
                    public void run() {
940
                        JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
978
                        JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
941
                    }
979
                    }
Line 998... Line 1036...
998
 
1036
 
999
        DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
1037
        DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
1000
        elt.updateStatus(getTable(), getTable().getTable("COMMANDE_ELEMENT"), getSelectedID());
1038
        elt.updateStatus(getTable(), getTable().getTable("COMMANDE_ELEMENT"), getSelectedID());
1001
 
1039
 
1002
        // generation du document
1040
        // generation du document
-
 
1041
        final SQLRow row = getTable().getRow(id);
1003
        final CommandeXmlSheet sheet = new CommandeXmlSheet(getTable().getRow(id));
1042
        final CommandeXmlSheet sheet = new CommandeXmlSheet(row);
1004
        sheet.createDocumentAsynchronous();
1043
        sheet.createDocumentAsynchronous();
1005
        sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
1044
        sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true, getElement(), row);
1006
 
1045
 
1007
    }
1046
    }
1008
 
1047
 
1009
    protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
1048
    protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
1010
        return "Commande fournisseur N°" + row.getString("NUMERO");
1049
        return "Commande fournisseur N°" + row.getString("NUMERO");