OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 142 Rev 177
Line 12... Line 12...
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.core.sales.account;
14
 package org.openconcerto.erp.core.sales.account;
15
 
15
 
16
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
16
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
-
 
17
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable.TypeCalcul;
17
import org.openconcerto.erp.core.common.ui.Acompte;
18
import org.openconcerto.erp.core.common.ui.Acompte;
18
import org.openconcerto.erp.core.common.ui.AcompteField;
19
import org.openconcerto.erp.core.common.ui.AcompteField;
19
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable.TypeCalcul;
-
 
20
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
20
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
21
import org.openconcerto.erp.core.sales.invoice.ui.FactureSituationItemTable;
21
import org.openconcerto.erp.core.sales.invoice.ui.FactureSituationItemTable;
-
 
22
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
-
 
23
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
-
 
24
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
-
 
25
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
22
import org.openconcerto.sql.element.GlobalMapper;
26
import org.openconcerto.sql.element.GlobalMapper;
23
import org.openconcerto.sql.element.SQLElement;
27
import org.openconcerto.sql.element.SQLElement;
24
import org.openconcerto.sql.model.SQLRow;
28
import org.openconcerto.sql.model.SQLRow;
25
import org.openconcerto.sql.model.SQLRowAccessor;
29
import org.openconcerto.sql.model.SQLRowAccessor;
26
import org.openconcerto.sql.model.SQLRowValues;
30
import org.openconcerto.sql.model.SQLRowValues;
-
 
31
import org.openconcerto.sql.preferences.SQLPreferences;
27
import org.openconcerto.ui.group.Group;
32
import org.openconcerto.ui.group.Group;
28
import org.openconcerto.utils.DecimalUtils;
33
import org.openconcerto.utils.DecimalUtils;
-
 
34
import org.openconcerto.utils.ExceptionHandler;
29
import org.openconcerto.utils.Tuple2;
35
import org.openconcerto.utils.Tuple2;
30
 
36
 
31
import java.math.BigDecimal;
37
import java.math.BigDecimal;
32
import java.math.RoundingMode;
38
import java.math.RoundingMode;
-
 
39
import java.sql.SQLException;
33
import java.util.Collection;
40
import java.util.Collection;
34
import java.util.Date;
41
import java.util.Date;
35
import java.util.HashSet;
42
import java.util.HashSet;
36
import java.util.List;
43
import java.util.List;
37
import java.util.Set;
44
import java.util.Set;
Line 64... Line 71...
64
        return rowVals;
71
        return rowVals;
65
    }
72
    }
66
 
73
 
67
    @Override
74
    @Override
68
    public int insert(SQLRow order) {
75
    public int insert(SQLRow order) {
69
        return super.insert(order);
76
        int id = super.insert(order);
-
 
77
        try {
-
 
78
            updateStock(id);
-
 
79
        } catch (SQLException e) {
-
 
80
            ExceptionHandler.handle("Erreur lors de la mise à jour du stock.", e);
-
 
81
            e.printStackTrace();
-
 
82
        }
-
 
83
        return id;
-
 
84
    }
-
 
85
 
-
 
86
    @Override
-
 
87
    public void update() {
-
 
88
        super.update();
-
 
89
        try {
-
 
90
            updateStock(getSelectedID());
-
 
91
        } catch (SQLException e) {
-
 
92
            ExceptionHandler.handle("Erreur lors de la mise à jour du stock.", e);
-
 
93
            e.printStackTrace();
-
 
94
        }
70
    }
95
    }
71
 
96
 
72
    @Override
97
    @Override
73
    public void importFrom(List<SQLRowValues> rows) {
98
    public void importFrom(List<SQLRowValues> rows) {
74
 
99
 
Line 112... Line 137...
112
            }
137
            }
113
        }
138
        }
114
        return l;
139
        return l;
115
    }
140
    }
116
 
141
 
-
 
142
    protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
-
 
143
        return "Saisie vente facture N°" + row.getString("NUMERO");
-
 
144
    }
-
 
145
 
-
 
146
    /**
-
 
147
     * Mise à jour des stocks pour chaque article composant la facture
-
 
148
     * 
-
 
149
     * @throws SQLException
-
 
150
     */
-
 
151
    private void updateStock(int id) throws SQLException {
-
 
152
 
-
 
153
        SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
-
 
154
        if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) {
-
 
155
            SQLRow row = getTable().getRow(id);
-
 
156
            StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
-
 
157
 
-
 
158
                @Override
-
 
159
                public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
-
 
160
                    return getLibelleStock(rowOrigin, rowElt);
-
 
161
                }
-
 
162
            }, row, row.getReferentRows(getTable().getTable("SAISIE_VENTE_FACTURE_ELEMENT")),
-
 
163
                    getTable().contains("CREATE_VIRTUAL_STOCK") && row.getBoolean("CREATE_VIRTUAL_STOCK") ? TypeStockUpdate.REAL_VIRTUAL_DELIVER : TypeStockUpdate.REAL_DELIVER);
-
 
164
 
-
 
165
            stockUpdater.update();
-
 
166
 
-
 
167
        }
-
 
168
    }
-
 
169
 
117
    // @Override
170
    // @Override
118
    // public Component addView(MutableRowItemView rowItemView, String fields, Object specObj) {
171
    // public Component addView(MutableRowItemView rowItemView, String fields, Object specObj) {
119
    //
172
    //
120
    // if (fields.contains("ID_POLE_PRODUIT") && countPole == 0) {
173
    // if (fields.contains("ID_POLE_PRODUIT") && countPole == 0) {
121
    // countPole++;
174
    // countPole++;