OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 80 Rev 83
Line 271... Line 271...
271
        for (Pair<Article, Integer> item : this.items) {
271
        for (Pair<Article, Integer> item : this.items) {
272
            final Article article = item.getFirst();
272
            final Article article = item.getFirst();
273
            final Integer nb = item.getSecond();
273
            final Integer nb = item.getSecond();
274
            Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
274
            Float tauxFromId = TaxeCache.getCache().getTauxFromId(article.getIdTaxe());
275
            BigDecimal tauxTVA = new BigDecimal(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
275
            BigDecimal tauxTVA = new BigDecimal(tauxFromId).movePointLeft(2).add(BigDecimal.ONE);
276
 
-
 
277
            BigDecimal multiply = article.getPriceHTInCents().multiply(new BigDecimal(nb), MathContext.DECIMAL128).multiply(tauxTVA, MathContext.DECIMAL128);
276
            BigDecimal multiply = article.getPriceHTInCents().multiply(new BigDecimal(nb), MathContext.DECIMAL128).multiply(tauxTVA, MathContext.DECIMAL128);
-
 
277
 
-
 
278
            if (article.getCode() != null && !article.getCode().isEmpty()) {
-
 
279
                // 2 lines
278
            prt.addToBuffer(DefaultTicketPrinter.formatRight(MAX_QTE_WIDTH, String.valueOf(nb)) + " "
280
                final String qtyString = DefaultTicketPrinter.formatRight(MAX_QTE_WIDTH, String.valueOf(nb));
-
 
281
                final String codeString = DefaultTicketPrinter.formatLeft(maxWidth - 2 - MAX_PRICE_WIDTH - MAX_QTE_WIDTH, article.getCode());
-
 
282
                final String priceString = DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(multiply.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()));
-
 
283
                prt.addToBuffer(qtyString + " " + codeString + " " + priceString);
-
 
284
                final String nameString = DefaultTicketPrinter.formatLeft(maxWidth - MAX_QTE_WIDTH - 1, article.getName());
-
 
285
                prt.addToBuffer("      " + nameString);
-
 
286
            } else {
-
 
287
                // 1 line
-
 
288
                final String qtyString = DefaultTicketPrinter.formatRight(MAX_QTE_WIDTH, String.valueOf(nb));
279
                    + DefaultTicketPrinter.formatLeft(maxWidth - 2 - MAX_PRICE_WIDTH - MAX_QTE_WIDTH, article.getName()) + " "
289
                final String nameString = DefaultTicketPrinter.formatLeft(maxWidth - 2 - MAX_PRICE_WIDTH - MAX_QTE_WIDTH, article.getName());
280
                    + DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(multiply.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue())));
290
                final String priceString = DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(multiply.movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue()));
-
 
291
                prt.addToBuffer(qtyString + " " + nameString + " " + priceString);
-
 
292
            }
-
 
293
 
281
        }
294
        }
282
 
295
 
283
        StringBuilder spacer = new StringBuilder();
296
        StringBuilder spacer = new StringBuilder();
284
        for (int i = 0; i <= MAX_QTE_WIDTH; i++) {
297
        for (int i = 0; i <= MAX_QTE_WIDTH; i++) {
285
            spacer.append(' ');
298
            spacer.append(' ');
286
        }
299
        }
287
        for (int i = 0; i < maxWidth - MAX_QTE_WIDTH - 1; i++) {
300
        for (int i = 0; i < maxWidth - MAX_QTE_WIDTH - 1; i++) {
288
            spacer.append('=');
301
            spacer.append('=');
289
        }
302
        }
290
        prt.addToBuffer(spacer.toString());
303
        prt.addToBuffer(spacer.toString());
-
 
304
 
-
 
305
        final TotalCalculator calc = getTotalCalculator();
-
 
306
        int totalTTCInCents = calc.getTotalTTC().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
-
 
307
        int totalTVHAInCents = calc.getTotalTVA().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
-
 
308
 
-
 
309
 
-
 
310
        prt.addToBuffer(
-
 
311
                DefaultTicketPrinter.formatRight(maxWidth - MAX_PRICE_WIDTH, "MONTANT TOTAL TTC (Euros) : ")
291
        prt.addToBuffer(DefaultTicketPrinter.formatRight(maxWidth - 8, "Total") + DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(getTotal())),
312
                        + DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(totalTTCInCents)),
292
                DefaultTicketPrinter.BOLD);
313
                DefaultTicketPrinter.BOLD);
-
 
314
        prt.addToBuffer(
-
 
315
                DefaultTicketPrinter.formatRight(maxWidth - MAX_PRICE_WIDTH, "Dont TVA : ") + DefaultTicketPrinter.formatRight(MAX_PRICE_WIDTH, TicketCellRenderer.centsToString(totalTVHAInCents)),
-
 
316
                DefaultTicketPrinter.NORMAL);
293
        prt.addToBuffer("");
317
        prt.addToBuffer("");
294
        //
318
        //
295
        for (Paiement paiement : this.paiements) {
319
        for (Paiement paiement : this.paiements) {
296
 
320
 
297
            String type = "";
321
            String type = "";
Line 312... Line 336...
312
                }
336
                }
313
                prt.addToBuffer(type);
337
                prt.addToBuffer(type);
314
            }
338
            }
315
        }
339
        }
316
        // Montant Rendu
340
        // Montant Rendu
317
        if (getTotal() < getPaidTotal()) {
341
        if (getTotalInCents() < getPaidTotal()) {
318
            int montantInCents = getPaidTotal() - getTotal();
342
            int montantInCents = getPaidTotal() - getTotalInCents();
319
            String type = "Rendu : " + TicketCellRenderer.centsToString(montantInCents);
343
            String type = "Rendu : " + TicketCellRenderer.centsToString(montantInCents);
320
            if (montantInCents > 100) {
344
            if (montantInCents > 100) {
321
                type += " euros";
345
                type += " euros";
322
            } else {
346
            } else {
323
                type += " euro";
347
                type += " euro";
Line 331... Line 355...
331
            prt.addToBuffer(line);
355
            prt.addToBuffer(line);
332
        }
356
        }
333
        prt.addToBuffer("");
357
        prt.addToBuffer("");
334
        prt.addToBuffer(getCode(), DefaultTicketPrinter.BARCODE);
358
        prt.addToBuffer(getCode(), DefaultTicketPrinter.BARCODE);
335
        prt.addToBuffer("");
359
        prt.addToBuffer("");
336
        prt.addToBuffer("Nous utilisons le logiciel OpenConcerto.");
360
        prt.addToBuffer("Ticket créé par l'ERP OpenConcerto.");
337
        prt.addToBuffer("Logiciel libre, open source et gratuit!");
-
 
-
 
361
 
338
        try {
362
        try {
339
            prt.printBuffer();
363
            prt.printBuffer();
340
        } catch (Exception e) {
364
        } catch (Exception e) {
341
            e.printStackTrace();
365
            e.printStackTrace();
342
        }
366
        }
Line 396... Line 420...
396
 
420
 
397
    public List<Paiement> getPaiements() {
421
    public List<Paiement> getPaiements() {
398
        return this.paiements;
422
        return this.paiements;
399
    }
423
    }
400
 
424
 
401
    public int getTotal() {
425
    public int getTotalInCents() {
-
 
426
        final TotalCalculator calc = getTotalCalculator();
-
 
427
        return calc.getTotalTTC().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
-
 
428
    }
-
 
429
 
-
 
430
    public TotalCalculator getTotalCalculator() {
402
        final SQLTable tableElt = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().findTable("SAISIE_VENTE_FACTURE_ELEMENT");
431
        final SQLTable tableElt = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().findTable("SAISIE_VENTE_FACTURE_ELEMENT");
403
        final TotalCalculator calc = new TotalCalculator("T_PA_HT", "T_PV_HT", null);
432
        final TotalCalculator calc = new TotalCalculator("T_PA_HT", "T_PV_HT", null);
404
        final String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
433
        final String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
405
        final Boolean bServiceActive = Boolean.valueOf(val);
434
        final Boolean bServiceActive = Boolean.valueOf(val);
406
        calc.setServiceActive(bServiceActive != null && bServiceActive);
435
        calc.setServiceActive(bServiceActive != null && bServiceActive);
Line 415... Line 444...
415
            rowVals.put("ID_TAXE", art.idTaxe);
444
            rowVals.put("ID_TAXE", art.idTaxe);
416
            calc.addLine(rowVals, tableArticle.getRow(art.getId()), i, false);
445
            calc.addLine(rowVals, tableArticle.getRow(art.getId()), i, false);
417
 
446
 
418
        }
447
        }
419
        calc.checkResult();
448
        calc.checkResult();
420
        return calc.getTotalTTC().movePointRight(2).setScale(0, RoundingMode.HALF_UP).intValue();
449
        return calc;
421
    }
450
    }
422
 
451
 
423
    public List<Pair<Article, Integer>> getArticles() {
452
    public List<Pair<Article, Integer>> getArticles() {
424
        return this.items;
453
        return this.items;
425
    }
454
    }