OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 149 Rev 156
Line 114... Line 114...
114
            }
114
            }
115
 
115
 
116
            @Override
116
            @Override
117
            public Set<FieldPath> getPaths() {
117
            public Set<FieldPath> getPaths() {
118
                final Path p = new PathBuilder(eltCmd.getTable()).addTable("COMMANDE_CLIENT_ELEMENT").build();
118
                final Path p = new PathBuilder(eltCmd.getTable()).addTable("COMMANDE_CLIENT_ELEMENT").build();
119
                return CollectionUtils.createSet(new FieldPath(p, "QTE_LIVREE"), new FieldPath(p, "QTE"), new FieldPath(p, "QTE_UNITAIRE"), new FieldPath(p, "LIVRE_FORCED"),
119
                return CollectionUtils.createSet(new FieldPath(p, "ID_ARTICLE"), new FieldPath(p, "PV_HT"), new FieldPath(p, "QTE_LIVREE"), new FieldPath(p, "QTE"), new FieldPath(p, "QTE_UNITAIRE"),
120
                        new FieldPath(p, "LIVRE"));
120
                        new FieldPath(p, "LIVRE_FORCED"), new FieldPath(p, "LIVRE"));
121
            }
121
            }
122
        };
122
        };
123
        tableSource.getColumns().add(colLiv2);
123
        tableSource.getColumns().add(colLiv2);
124
        colLiv2.setRenderer(new PercentTableCellRenderer());
124
        colLiv2.setRenderer(new PercentTableCellRenderer());
125
 
125
 
Line 153... Line 153...
153
        Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("COMMANDE_CLIENT_ELEMENT"));
153
        Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("COMMANDE_CLIENT_ELEMENT"));
154
        BigDecimal totalQte = BigDecimal.ZERO;
154
        BigDecimal totalQte = BigDecimal.ZERO;
155
        BigDecimal totalQteL = BigDecimal.ZERO;
155
        BigDecimal totalQteL = BigDecimal.ZERO;
156
        for (SQLRowAccessor row : rows) {
156
        for (SQLRowAccessor row : rows) {
157
            BigDecimal qte = row.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(row.getInt("QTE")));
157
            BigDecimal qte = row.getBigDecimal("QTE_UNITAIRE").multiply(new BigDecimal(row.getInt("QTE")));
-
 
158
            // On ne prend en compte que les articles ou les lignes différentes de 0
-
 
159
            if (!row.isForeignEmpty("ID_ARTICLE") || row.getBigDecimal("PV_HT").signum() != 0) {
158
            totalQte = totalQte.add(qte);
160
                totalQte = totalQte.add(qte);
159
            if (row.getBoolean("LIVRE_FORCED") || row.getBoolean("LIVRE")) {
161
                if (row.getBoolean("LIVRE_FORCED") || row.getBoolean("LIVRE")) {
160
                totalQteL = totalQteL.add(qte);
162
                    totalQteL = totalQteL.add(qte);
161
            } else if (row.getBigDecimal("QTE_LIVREE") != null) {
163
                } else if (row.getBigDecimal("QTE_LIVREE") != null) {
162
                final BigDecimal qteLivree = row.getBigDecimal("QTE_LIVREE");
164
                    final BigDecimal qteLivree = row.getBigDecimal("QTE_LIVREE");
163
                if (qteLivree != null) {
165
                    if (qteLivree != null) {
164
                    totalQteL = totalQteL.add(qteLivree);
166
                        totalQteL = totalQteL.add(qteLivree);
165
                }
167
                    }
166
            }
168
                }
167
        }
169
            }
-
 
170
        }
168
        if (totalQte.signum() != 0) {
171
        if (totalQte.signum() != 0) {
169
            return totalQteL.divide(totalQte, DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
172
            return totalQteL.divide(totalQte, DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP);
170
        } else {
173
        } else {
171
            return BigDecimal.ONE.movePointRight(2);
174
            return BigDecimal.ONE.movePointRight(2);
172
        }
175
        }