OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 156 Rev 174
Line 72... Line 72...
72
            }
72
            }
73
        }
73
        }
74
        return result;
74
        return result;
75
    }
75
    }
76
 
76
 
-
 
77
    /**
-
 
78
     * Fill productComponents with items (SQLrowAccessor of TABLE_ELEMENT)
-
 
79
     * 
-
 
80
     * @param items
-
 
81
     * @param productComponents
-
 
82
     * @param qte
-
 
83
     * @param index
-
 
84
     * @param level
-
 
85
     */
-
 
86
    public void fillProductComponent(List<? extends SQLRowAccessor> itemsTableElement, List<ProductComponent> productComponents, int qte, int index, int level) {
-
 
87
        if (level > 0) {
-
 
88
            for (int i = index; i < itemsTableElement.size(); i++) {
-
 
89
                SQLRowAccessor r = itemsTableElement.get(i);
-
 
90
 
-
 
91
                if (!r.getTable().contains("NIVEAU") || r.getInt("NIVEAU") >= level) {
-
 
92
                    // On ne calcul pas les stocks pour les éléments ayant des fils (le mouvement de
-
 
93
                    // stock
-
 
94
                    // des fils impactera les stocks automatiquement)
-
 
95
                    if (r.getTable().contains("NIVEAU")) {
-
 
96
                        if (i + 1 < itemsTableElement.size()) {
-
 
97
                            SQLRowAccessor rNext = itemsTableElement.get(i + 1);
-
 
98
                            if (rNext.getInt("NIVEAU") > r.getInt("NIVEAU")) {
-
 
99
                                fillProductComponent(itemsTableElement, productComponents, qte * r.getInt("QTE"), i + 1, rNext.getInt("NIVEAU"));
-
 
100
                                continue;
-
 
101
                            }
-
 
102
                        }
-
 
103
                    }
-
 
104
                    if ((!r.getTable().contains("NIVEAU") || r.getInt("NIVEAU") == level) && r.getForeign("ID_ARTICLE") != null && !r.isForeignEmpty("ID_ARTICLE")) {
-
 
105
                        productComponents.add(ProductComponent.createFrom(r, qte, r));
-
 
106
                    }
-
 
107
                } else if (r.getInt("NIVEAU") < level) {
-
 
108
                    // BREAK si on sort de l'article composé
-
 
109
                    break;
-
 
110
                }
-
 
111
            }
-
 
112
        }
-
 
113
    }
-
 
114
 
77
    public BigDecimal getUnitCostForQuantity(SQLRowAccessor rArticle, int qty) {
115
    public BigDecimal getUnitCostForQuantity(SQLRowAccessor rArticle, int qty) {
78
 
116
 
79
        Collection<? extends SQLRowAccessor> l = rArticle.getReferentRows(rArticle.getTable().getTable("ARTICLE_PRIX_REVIENT"));
117
        Collection<? extends SQLRowAccessor> l = rArticle.getReferentRows(rArticle.getTable().getTable("ARTICLE_PRIX_REVIENT"));
80
        BigDecimal result = null;
118
        BigDecimal result = null;
81
 
119
 
Line 244... Line 282...
244
            // get all childs
282
            // get all childs
245
            final SQLTable costTable = root.getTable("ARTICLE_ELEMENT");
283
            final SQLTable costTable = root.getTable("ARTICLE_ELEMENT");
246
 
284
 
247
            SQLRowValues rowVals = new SQLRowValues(costTable);
285
            SQLRowValues rowVals = new SQLRowValues(costTable);
248
 
286
 
249
            final SQLRowValues artRowValues = rowVals.putRowValues("ID_ARTICLE").putNulls("ID", "GESTION_STOCK", "CODE", "NOM", "ID_DEPOT_STOCK", "ID_UNITE_VENTE");
287
            final SQLRowValues artRowValues = rowVals.putRowValues("ID_ARTICLE").putNulls("ID", "GESTION_STOCK", "CODE", "NOM", "ID_DEPOT_STOCK", "ID_UNITE_VENTE", "ID_FOURNISSEUR");
250
            SQLRowValues stockRowVals = new SQLRowValues(root.getTable("STOCK"));
288
            SQLRowValues stockRowVals = new SQLRowValues(root.getTable("STOCK"));
251
            stockRowVals.putNulls("QTE_TH", "QTE_RECEPT_ATTENTE", "QTE_REEL", "QTE_LIV_ATTENTE", "ID_DEPOT_STOCK");
289
            stockRowVals.putNulls("QTE_TH", "QTE_RECEPT_ATTENTE", "QTE_REEL", "QTE_LIV_ATTENTE", "ID_DEPOT_STOCK");
252
            stockRowVals.put("ID_ARTICLE", artRowValues);
290
            stockRowVals.put("ID_ARTICLE", artRowValues);
253
            rowVals.putRowValues("ID_ARTICLE_PARENT").put("ID", null);
291
            rowVals.putRowValues("ID_ARTICLE_PARENT").put("ID", null);
254
            rowVals.put("QTE", null);
292
            rowVals.put("QTE", null);