Search in sources :

Example 1 with FiscalDocumentPrint

use of ar.com.ergio.model.FiscalDocumentPrint in project lar_361 by comitsrl.

the class FiscalPrinterClosing method doIt.

@Override
protected String doIt() throws Exception {
    String msg = String.format("CloseType=%s FiscalPrinter=%d", closeType, lar_Fiscal_Printer_ID);
    log.info(msg);
    try {
        final FiscalDocumentPrint fdp = new FiscalDocumentPrint(lar_Fiscal_Printer_ID);
        fdp.addDocumentPrintListener(infoFiscalPrinter);
        fdp.setPrinterEventListener(infoFiscalPrinter);
        infoFiscalPrinter.setFiscalDocumentPrint(fdp);
        currentAction = new FiscalCloseAction(null, closeType, lar_Fiscal_Printer_ID);
        executeAction();
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    return resultMsg;
}
Also used : FiscalDocumentPrint(ar.com.ergio.model.FiscalDocumentPrint) FiscalCloseAction(ar.com.ergio.print.fiscal.action.FiscalCloseAction)

Example 2 with FiscalDocumentPrint

use of ar.com.ergio.model.FiscalDocumentPrint in project lar_361 by comitsrl.

the class PosBasePanel method printFiscalTicket.

protected boolean printFiscalTicket(final PO document) {
    log.info("Printing fiscal ticket for " + document);
    final SwingWorker worker = new SwingWorker() {

        @Override
        public Object construct() {
            boolean success = true;
            int c_DocType_ID = document.get_ValueAsInt("C_DocType_ID");
            try {
                final MDocType docType = new MDocType(m_ctx, c_DocType_ID, null);
                int lar_Fiscal_Printer_ID = docType.get_ValueAsInt("LAR_Fiscal_Printer_ID");
                log.info("doc type asociated " + docType);
                final FiscalDocumentPrint fdp = new FiscalDocumentPrint(lar_Fiscal_Printer_ID, infoFiscalPrinter, infoFiscalPrinter);
                log.info("fiscal document print created: " + fdp);
                infoFiscalPrinter.setFiscalDocumentPrint(fdp);
                success = printDocument(fdp, document);
            } catch (Exception e) {
                log.log(Level.SEVERE, "Fiscal printing error", e);
                success = false;
            }
            return Boolean.valueOf(success);
        }

        @Override
        public void finished() {
            boolean result = (Boolean) getValue();
            log.info("Finish fiscal printing thread. Printed Ok?: " + result);
            if (result) {
                newOrder();
            }
        }
    };
    worker.start();
    // Thread stops here until fiscal printing finished
    infoFiscalPrinter.setVisible(true);
    return (Boolean) worker.get();
}
Also used : FiscalDocumentPrint(ar.com.ergio.model.FiscalDocumentPrint) MDocType(org.compiere.model.MDocType) SwingWorker(org.compiere.apps.SwingWorker) FiscalDocumentPrint(ar.com.ergio.model.FiscalDocumentPrint) JposException(jpos.JposException)

Example 3 with FiscalDocumentPrint

use of ar.com.ergio.model.FiscalDocumentPrint in project lar_361 by comitsrl.

the class FiscalDocumentPrintManager method print.

/**
 */
public boolean print() {
    final SwingWorker worker = new SwingWorker() {

        @Override
        public Object construct() {
            boolean success = false;
            {
                try {
                    final MDocType docType = new MDocType(document.getCtx(), document.get_ValueAsInt("C_DocType_ID"), document.get_TrxName());
                    int lar_Fiscal_Printer_ID = docType.get_ValueAsInt("LAR_Fiscal_Printer_ID");
                    final FiscalDocumentPrint fdp = new FiscalDocumentPrint(lar_Fiscal_Printer_ID, infoFiscalPrinter, infoFiscalPrinter);
                    log.info("fiscal document print created: " + fdp);
                    infoFiscalPrinter.setFiscalDocumentPrint(fdp);
                    success = printDocument(fdp);
                } catch (Exception e) {
                    log.log(Level.SEVERE, "Error en la Impresi\u00f3n Fiscal", e);
                    success = false;
                }
            }
            return Boolean.valueOf(success);
        }

        @Override
        public void finished() {
            boolean result = (Boolean) getValue();
            log.info("Finaliza impresi\u00f3n fiscal. Impreso correctamente?: " + result);
        }
    };
    worker.start();
    // Thread stops here until fiscal printing finished
    infoFiscalPrinter.setVisible(true);
    return (Boolean) worker.get();
}
Also used : FiscalDocumentPrint(ar.com.ergio.model.FiscalDocumentPrint) MDocType(org.compiere.model.MDocType) SwingWorker(org.compiere.apps.SwingWorker)

Aggregations

FiscalDocumentPrint (ar.com.ergio.model.FiscalDocumentPrint)3 SwingWorker (org.compiere.apps.SwingWorker)2 MDocType (org.compiere.model.MDocType)2 FiscalCloseAction (ar.com.ergio.print.fiscal.action.FiscalCloseAction)1 JposException (jpos.JposException)1