OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 174 Rev 177
Line 212... Line 212...
212
 
212
 
213
            @Override
213
            @Override
214
            public void actionPerformed(ActionEvent e) {
214
            public void actionPerformed(ActionEvent e) {
215
 
215
 
216
                buttonUpdate.setEnabled(false);
216
                buttonUpdate.setEnabled(false);
217
                defaultLabel = label.getText();
-
 
218
                BigDecimal qteReel = fieldReel.getValue();
217
                BigDecimal qteReel = fieldReel.getValue();
219
 
218
 
220
                List<String> multipleRequestsHundred = new ArrayList<String>(100);
219
                List<String> multipleRequestsHundred = new ArrayList<String>(100);
221
                boolean usePrice = mvtStockTable.contains("PRICE");
220
                boolean usePrice = mvtStockTable.contains("PRICE");
222
                List<StockItem> stockItems = new ArrayList<StockItem>();
221
                List<StockItem> stockItems = new ArrayList<StockItem>();
223
                final Date dateValue = date.getValue();
222
                final Date dateValue = date.getValue();
224
 
223
 
225
                final SQLRow selectedRowArticle = comboArticle.getSelectedRow();
224
                final SQLRow selectedRowArticle = comboArticle.getSelectedRow();
226
 
225
 
-
 
226
                final SQLRow selectedRowDepotDepart = comboStockDepart.getSelectedRow();
-
 
227
                final SQLRow selectedRowDepotArrivee = comboStockArrive.getSelectedRow();
227
                {
228
                {
228
                    // DEPART
229
                    // DEPART
229
                    final SQLRow selectedRowDepotDepart = comboStockDepart.getSelectedRow();
-
 
230
                    final SQLRowAccessor rowStockDepart = ProductComponent.findOrCreateStock(selectedRowArticle, selectedRowDepotDepart);
230
                    final SQLRowAccessor rowStockDepart = ProductComponent.findOrCreateStock(selectedRowArticle, selectedRowDepotDepart);
231
                    StockItem item = new StockItem(selectedRowArticle, rowStockDepart);
231
                    StockItem item = new StockItem(selectedRowArticle, rowStockDepart);
232
                    if (!item.isStockInit()) {
232
                    if (!item.isStockInit()) {
233
                        SQLRowValues rowVals = new SQLRowValues(mvtStockTable.getTable("STOCK"));
233
                        SQLRowValues rowVals = new SQLRowValues(mvtStockTable.getTable("STOCK"));
234
                        rowVals.put("ID_ARTICLE", selectedRowArticle.getID());
234
                        rowVals.put("ID_ARTICLE", selectedRowArticle.getID());
Line 243... Line 243...
243
                        item = new StockItem(selectedRowArticle, rowStockDepart);
243
                        item = new StockItem(selectedRowArticle, rowStockDepart);
244
                    }
244
                    }
245
                    stockItems.add(item);
245
                    stockItems.add(item);
246
                    double diff = -qteReel.doubleValue();
246
                    double diff = -qteReel.doubleValue();
247
                    item.updateQty(diff, TypeStockMouvement.REEL);
247
                    item.updateQty(diff, TypeStockMouvement.REEL);
248
                    multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, label.getText(), true, usePrice));
248
                    multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), true, usePrice));
249
 
249
 
250
                    item.updateQty(diff, TypeStockMouvement.THEORIQUE);
250
                    item.updateQty(diff, TypeStockMouvement.THEORIQUE);
251
                    multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, label.getText(), false, usePrice));
251
                    multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), false, usePrice));
252
 
252
 
253
                    multipleRequestsHundred.add(item.getUpdateRequest());
253
                    multipleRequestsHundred.add(item.getUpdateRequest());
254
                }
254
                }
255
                // ARRIVEE
255
                // ARRIVEE
256
                {
256
                {
257
                    final SQLRow selectedRowDepotArrivee = comboStockArrive.getSelectedRow();
-
 
258
                    final SQLRowAccessor rowStockArrivee = ProductComponent.findOrCreateStock(selectedRowArticle, selectedRowDepotArrivee);
257
                    final SQLRowAccessor rowStockArrivee = ProductComponent.findOrCreateStock(selectedRowArticle, selectedRowDepotArrivee);
259
 
258
 
260
                    StockItem item = new StockItem(selectedRowArticle, rowStockArrivee);
259
                    StockItem item = new StockItem(selectedRowArticle, rowStockArrivee);
261
                    if (!item.isStockInit()) {
260
                    if (!item.isStockInit()) {
262
                        SQLRowValues rowVals = new SQLRowValues(mvtStockTable.getTable("STOCK"));
261
                        SQLRowValues rowVals = new SQLRowValues(mvtStockTable.getTable("STOCK"));
Line 272... Line 271...
272
                        item = new StockItem(selectedRowArticle, rowStockArrivee);
271
                        item = new StockItem(selectedRowArticle, rowStockArrivee);
273
                    }
272
                    }
274
                    stockItems.add(item);
273
                    stockItems.add(item);
275
                    double diff = qteReel.doubleValue();
274
                    double diff = qteReel.doubleValue();
276
                    item.updateQty(diff, TypeStockMouvement.REEL);
275
                    item.updateQty(diff, TypeStockMouvement.REEL);
277
                    multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, label.getText(), true, usePrice));
276
                    multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), true, usePrice));
278
 
277
 
279
                    item.updateQty(diff, TypeStockMouvement.THEORIQUE);
278
                    item.updateQty(diff, TypeStockMouvement.THEORIQUE);
280
                    multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, label.getText(), false, usePrice));
279
                    multipleRequestsHundred.add(getMvtRequest(dateValue, BigDecimal.ZERO, diff, item, getLabel(label.getText(), selectedRowDepotDepart, selectedRowDepotArrivee), false, usePrice));
281
 
280
 
282
                    multipleRequestsHundred.add(item.getUpdateRequest());
281
                    multipleRequestsHundred.add(item.getUpdateRequest());
283
                }
282
                }
284
 
283
 
285
                try {
284
                try {
Line 316... Line 315...
316
                ((JFrame) SwingUtilities.getRoot(TransfertStockPanel.this)).dispose();
315
                ((JFrame) SwingUtilities.getRoot(TransfertStockPanel.this)).dispose();
317
            }
316
            }
318
        });
317
        });
319
    }
318
    }
320
 
319
 
-
 
320
    private String getLabel(String label, SQLRowAccessor fromDepot, SQLRowAccessor toDepot) {
-
 
321
 
-
 
322
        return label + " de " + fromDepot.getString("NOM") + " vers " + toDepot.getString("NOM");
-
 
323
 
-
 
324
    }
-
 
325
 
321
    private String getMvtRequest(Date time, BigDecimal prc, double qteFinal, StockItem item, String label, boolean reel, boolean usePrice) {
326
    private String getMvtRequest(Date time, BigDecimal prc, double qteFinal, StockItem item, String label, boolean reel, boolean usePrice) {
322
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
327
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
323
        String mvtStockQuery = "INSERT INTO " + mvtStockTableQuoted + " (\"QTE\",\"DATE\",\"ID_ARTICLE\",\"ID_STOCK\",\"NOM\",\"REEL\",\"ORDRE\"";
328
        String mvtStockQuery = "INSERT INTO " + mvtStockTableQuoted + " (\"QTE\",\"DATE\",\"ID_ARTICLE\",\"ID_STOCK\",\"NOM\",\"REEL\",\"ORDRE\"";
324
 
329
 
325
        if (usePrice && prc != null) {
330
        if (usePrice && prc != null) {