OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 174 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 584... Line 584...
584
                ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
584
                ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
585
 
585
 
586
                    @Override
586
                    @Override
587
                    public void run() {
587
                    public void run() {
588
                        try {
588
                        try {
589
                            updateStock(idBonFinal);
589
                            ((BonReceptionSQLElement) getElement()).updateStock(idBonFinal);
590
                            ((BonReceptionSQLElement) getElement()).updateCmdElement(((BonReceptionSQLElement) getElement()).getCmdFrom(idBonFinal), idBonFinal);
590
                            ((BonReceptionSQLElement) getElement()).updateCmdElement(((BonReceptionSQLElement) getElement()).getCmdFrom(idBonFinal), idBonFinal);
591
                        } catch (Exception e) {
591
                        } catch (Exception e) {
592
                            ExceptionHandler.handle("Update error", e);
592
                            ExceptionHandler.handle("Update error", e);
593
                        }
593
                        }
594
                    }
594
                    }
Line 596... Line 596...
596
 
596
 
597
                DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
597
                DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
598
                elt.updateStatus(getTable(), getTable().getTable("BON_RECEPTION_ELEMENT"), idBon);
598
                elt.updateStatus(getTable(), getTable().getTable("BON_RECEPTION_ELEMENT"), idBon);
599
 
599
 
600
                // generation du document
600
                // generation du document
-
 
601
                final SQLRow row = getTable().getRow(idBonFinal);
601
                final BonReceptionXmlSheet sheet = new BonReceptionXmlSheet(getTable().getRow(idBonFinal));
602
                final BonReceptionXmlSheet sheet = new BonReceptionXmlSheet(row);
602
                sheet.createDocumentAsynchronous();
603
                sheet.createDocumentAsynchronous();
603
                sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
604
                sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true, getElement(), row);
604
 
605
 
605
            } catch (Exception e) {
606
            } catch (Exception e) {
606
                throw new IllegalStateException(e);
607
                throw new IllegalStateException(e);
607
            }
608
            }
608
        }
609
        }
Line 669... Line 670...
669
        if (receipt == count) {
670
        if (receipt == count) {
670
            JOptionPane.showMessageDialog(null, "Attention tous les articles ont déjà été réceptionné!");
671
            JOptionPane.showMessageDialog(null, "Attention tous les articles ont déjà été réceptionné!");
671
        }
672
        }
672
    }
673
    }
673
 
674
 
-
 
675
    public void removeZeroQtyLines() {
-
 
676
        int count = this.tableBonItem.getModel().getRowCount() - 1;
-
 
677
        for (int i = count; i >= 0; i--) {
-
 
678
            final SQLRowValues rowValuesAt = this.tableBonItem.getModel().getRowValuesAt(i);
-
 
679
            if (rowValuesAt.getInt("QTE") == 0) {
-
 
680
                this.tableBonItem.getModel().removeRowAt(i);
-
 
681
            }
-
 
682
        }
-
 
683
    }
-
 
684
 
674
    @Override
685
    @Override
675
    public void update() {
686
    public void update() {
676
 
687
 
677
        if (!this.textNumeroUnique.checkValidation()) {
688
        if (!this.textNumeroUnique.checkValidation()) {
678
            ExceptionHandler.handle("Impossible d'ajouter, numéro de bon de livraison existant.");
689
            ExceptionHandler.handle("Impossible d'ajouter, numéro de bon de livraison existant.");
Line 698... Line 709...
698
                @Override
709
                @Override
699
                public void run() {
710
                public void run() {
700
                    try {
711
                    try {
701
 
712
 
702
                        // Mise à jour du stock
713
                        // Mise à jour du stock
703
                        updateStock(id);
714
                        ((BonReceptionSQLElement) getElement()).updateStock(id);
704
                        ((BonReceptionSQLElement) getElement()).updateCmdElement(cmdFrom, id);
715
                        ((BonReceptionSQLElement) getElement()).updateCmdElement(cmdFrom, id);
705
 
716
 
706
                        DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
717
                        DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
707
                        elt.updateStatus(getTable(), getTable().getTable("BON_RECEPTION_ELEMENT"), id);
718
                        elt.updateStatus(getTable(), getTable().getTable("BON_RECEPTION_ELEMENT"), id);
708
 
719
 
Line 714... Line 725...
714
 
725
 
715
            DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
726
            DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
716
            elt.updateStatus(getTable(), getTable().getTable("BON_RECEPTION_ELEMENT"), id);
727
            elt.updateStatus(getTable(), getTable().getTable("BON_RECEPTION_ELEMENT"), id);
717
 
728
 
718
            // generation du document
729
            // generation du document
-
 
730
            final SQLRow row = getTable().getRow(id);
719
            final BonReceptionXmlSheet sheet = new BonReceptionXmlSheet(getTable().getRow(id));
731
            final BonReceptionXmlSheet sheet = new BonReceptionXmlSheet(row);
720
            sheet.createDocumentAsynchronous();
732
            sheet.createDocumentAsynchronous();
721
            sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
733
            sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true, getElement(), row);
722
 
734
 
723
        }
735
        }
724
    }
736
    }
725
 
737
 
726
    /**
738
    /**
Line 773... Line 785...
773
            }
785
            }
774
 
786
 
775
        }
787
        }
776
    }
788
    }
777
 
789
 
778
    protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
-
 
779
        return "Bon de réception N°" + row.getString("NUMERO");
-
 
780
    }
-
 
781
 
-
 
782
    /**
-
 
783
     * Mise à jour des stocks pour chaque article composant du bon
-
 
784
     * 
-
 
785
     * @throws SQLException
-
 
786
     */
-
 
787
    private void updateStock(int id) throws SQLException {
-
 
788
 
-
 
789
        SQLRow row = getTable().getRow(id);
-
 
790
        StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
-
 
791
 
-
 
792
            @Override
-
 
793
            public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
-
 
794
 
-
 
795
                return getLibelleStock(rowOrigin, rowElt);
-
 
796
            }
-
 
797
        }, row, row.getReferentRows(getTable().getTable("BON_RECEPTION_ELEMENT")),
-
 
798
                getTable().contains("CREATE_VIRTUAL_STOCK") && row.getBoolean("CREATE_VIRTUAL_STOCK") ? TypeStockUpdate.REAL_VIRTUAL_RECEPT : TypeStockUpdate.REAL_RECEPT);
-
 
799
 
-
 
800
        if (getTable().getDBRoot().contains("RELIQUAT_BR")) {
-
 
801
            List<SQLRow> l = row.getReferentRows(getTable().getTable("RELIQUAT_BR").getField("ID_BON_RECEPTION_ORIGINE"));
-
 
802
            for (SQLRow sqlRow : l) {
-
 
803
                stockUpdater.addReliquat(sqlRow.getForeign("ID_ARTICLE"), sqlRow.getInt("QTE"), sqlRow.getBigDecimal("QTE_UNITAIRE"));
-
 
804
            }
-
 
805
        }
-
 
806
 
-
 
807
        stockUpdater.update();
-
 
808
 
-
 
809
    }
-
 
810
 
-
 
811
    @Override
790
    @Override
812
    public void select(SQLRowAccessor r) {
791
    public void select(SQLRowAccessor r) {
813
        super.select(r);
792
        super.select(r);
814
        if (this.tableBonReliquatItem != null) {
793
        if (this.tableBonReliquatItem != null) {
815
            this.tableBonReliquatItem.getRowValuesTable().clear();
794
            this.tableBonReliquatItem.getRowValuesTable().clear();