OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 151 Rev 156
Line 81... Line 81...
81
            dayIndex = 1;
81
            dayIndex = 1;
82
        } else {
82
        } else {
83
            final ReceiptCode lastCode = lastReceiptEvent.getCode();
83
            final ReceiptCode lastCode = lastReceiptEvent.getCode();
84
            dayIndex = lastCode.getDayIndex() + 1;
84
            dayIndex = lastCode.getDayIndex() + 1;
85
        }
85
        }
-
 
86
        final POSConfiguration posConf = getPOSConf();
86
        this.t = new Ticket(POSConfiguration.getInstance().getPosID(), dayIndex, lastHash);
87
        this.t = new Ticket(posConf.getPosID(), dayIndex, lastHash);
87
 
88
 
88
        this.t.addPaiement(this.p1);
89
        this.t.addPaiement(this.p1);
89
        this.t.addPaiement(this.p2);
90
        this.t.addPaiement(this.p2);
90
        this.t.addPaiement(this.p3);
91
        this.t.addPaiement(this.p3);
91
 
92
 
92
        final int scanDelay = POSConfiguration.getInstance().getScanDelay();
93
        final int scanDelay = posConf.getScanDelay();
93
        this.r = new BarcodeReader(scanDelay);
94
        this.r = new BarcodeReader(scanDelay);
94
        this.r.start();
95
        this.r.start();
95
        this.r.addBarcodeListener(this);
96
        this.r.addBarcodeListener(this);
96
        if (POSConfiguration.getInstance().getLCDType().equals("serial")) {
97
        if (posConf.getLCDType().equals("serial")) {
97
            lcd = new ESCSerialDisplay(POSConfiguration.getInstance().getLCDPort());
98
            lcd = new ESCSerialDisplay(posConf.getLCDPort());
98
        } else {
99
        } else {
99
            lcd = new PrinterPOSDisplay(POSConfiguration.getInstance().getLCDPort());
100
            lcd = new PrinterPOSDisplay(posConf.getLCDPort());
100
        }
101
        }
101
        this.setLCDDefaultDisplay(0);
102
        this.setLCDDefaultDisplay(0);
102
    }
103
    }
103
 
104
 
104
    public final CaisseFrame getCaisseFrame() {
105
    public final CaisseFrame getCaisseFrame() {
105
        return this.caisseFrame;
106
        return this.caisseFrame;
106
    }
107
    }
107
 
108
 
-
 
109
    protected final POSConfiguration getPOSConf() {
-
 
110
        return getCaisseFrame().getPOSConf();
-
 
111
    }
-
 
112
 
108
    public Article getArticleSelected() {
113
    public Article getArticleSelected() {
109
        return this.articleSelected;
114
        return this.articleSelected;
110
    }
115
    }
111
 
116
 
112
    public Paiement getPaiementSelected() {
117
    public Paiement getPaiementSelected() {
Line 342... Line 347...
342
            return null;
347
            return null;
343
        this.t.setCreationCal(Calendar.getInstance());
348
        this.t.setCreationCal(Calendar.getInstance());
344
        final String fileHash = this.t.save(files, dir);
349
        final String fileHash = this.t.save(files, dir);
345
        final Ticket res = this.t;
350
        final Ticket res = this.t;
346
        final int newIndex = this.t.getNumber() + 1;
351
        final int newIndex = this.t.getNumber() + 1;
347
        t = new Ticket(POSConfiguration.getInstance().getPosID(), newIndex, fileHash);
352
        t = new Ticket(getPOSConf().getPosID(), newIndex, fileHash);
348
        p1 = new Paiement(Paiement.ESPECES);
353
        p1 = new Paiement(Paiement.ESPECES);
349
        p2 = new Paiement(Paiement.CB);
354
        p2 = new Paiement(Paiement.CB);
350
        p3 = new Paiement(Paiement.CHEQUE);
355
        p3 = new Paiement(Paiement.CHEQUE);
351
        this.t.addPaiement(this.p1);
356
        this.t.addPaiement(this.p1);
352
        this.t.addPaiement(this.p2);
357
        this.t.addPaiement(this.p2);
Line 361... Line 366...
361
        return this.t.getNumber();
366
        return this.t.getNumber();
362
    }
367
    }
363
 
368
 
364
    public void openDrawer() {
369
    public void openDrawer() {
365
        try {
370
        try {
366
            final TicketPrinter prt = POSConfiguration.getInstance().getTicketPrinterConfiguration1().createTicketPrinter();
371
            final TicketPrinter prt = getPOSConf().getTicketPrinterConfiguration1().createTicketPrinter();
367
            prt.openDrawer();
372
            prt.openDrawer();
368
        } catch (Exception e) {
373
        } catch (Exception e) {
369
            e.printStackTrace();
374
            e.printStackTrace();
370
        }
375
        }
371
 
376
 
Line 406... Line 411...
406
                line1 = count + " articles";
411
                line1 = count + " articles";
407
            }
412
            }
408
            int cents = t.getTotalInCents();
413
            int cents = t.getTotalInCents();
409
            setLCD(line1, "Total : " + TicketCellRenderer.centsToString(cents), delay);
414
            setLCD(line1, "Total : " + TicketCellRenderer.centsToString(cents), delay);
410
        } else {
415
        } else {
411
            setLCD(POSConfiguration.getInstance().getLCDLine1(), POSConfiguration.getInstance().getLCDLine2(), delay);
416
            setLCD(getPOSConf().getLCDLine1(), getPOSConf().getLCDLine2(), delay);
412
        }
417
        }
413
    }
418
    }
414
 
419
 
415
    public void sendCBRequest(final Paiement p) {
420
    public void sendCBRequest(final Paiement p) {
416
 
421
 
417
        final String creditCardPort = POSConfiguration.getInstance().getCreditCardPort();
422
        final String creditCardPort = getPOSConf().getCreditCardPort();
418
        if (creditCardPort != null && creditCardPort.trim().length() > 2) {
423
        if (creditCardPort != null && creditCardPort.trim().length() > 2) {
419
            final Thread t = new Thread(new Runnable() {
424
            final Thread t = new Thread(new Runnable() {
420
 
425
 
421
                @Override
426
                @Override
422
                public void run() {
427
                public void run() {