Search in sources :

Example 1 with ImprimeTicketCompra

use of ar.com.comit.print.javapos.ImprimeTicketCompra in project lar_361 by comitsrl.

the class PosSubPanel method printTicket.

// actionPerformed
/**
 * 	Print Ticket
 *  @author Comunidad de Desarrollo OpenXpertya
 *  *Basado en Codigo Original Modificado, Revisado y Optimizado de:
 *  *Copyright (c) ConSerTi
 */
public void printTicket() {
    if (p_posPanel.m_order == null)
        return;
    final MOrder order = p_posPanel.m_order;
    boolean isFiscal = false;
    boolean isElectronic = false;
    boolean isJavaPOS = p_pos.get_ValueAsBoolean("IsJavaPOS");
    int reportType = 0;
    int documentId = 0;
    String impresoraFactura = "";
    if (order != null) {
        if (p_pos.get_ValueAsBoolean("IsShipment")) {
            // /// Procesa Remitos /////
            final MInOut shipment = p_posPanel.m_order.getShipments()[0];
            int C_DocType_ID = shipment.getC_DocType_ID();
            isFiscal = LAR_Utils.isFiscalDocType(C_DocType_ID);
            if (isFiscal) {
                // ImpresiĆ³n fiscal del de remito generado
                if (!p_posPanel.printFiscalTicket(shipment)) {
                    log.log(Level.SEVERE, "Error in Fiscal Printing Ticket");
                    return;
                }
            } else {
                reportType = ReportEngine.SHIPMENT;
                documentId = order.getC_Order_ID();
            }
        } else {
            // /// Procesa Facturas /////
            final MInvoice invoice = p_posPanel.m_order.getInvoices()[0];
            int C_DocType_ID = invoice.getC_DocType_ID();
            isFiscal = LAR_Utils.isFiscalDocType(C_DocType_ID);
            isElectronic = MDocType.isElectronicDocType(C_DocType_ID);
            // Si DocType es fiscal se utiliza el controlador fiscal
            if (isFiscal && !isElectronic) {
                // ImpresiĆ³n fiscal de factura
                if (!p_posPanel.printFiscalTicket(invoice)) {
                    log.log(Level.SEVERE, "Error en impresi\u00f3n de factura fiscal");
                    return;
                }
            } else {
                reportType = ReportEngine.INVOICE;
                documentId = invoice.getC_Invoice_ID();
                if (isElectronic) {
                    ReportCtl.startDocumentPrint(reportType, null, documentId, null, Env.getWindowNo(this), true, impresoraFactura);
                }
            }
        }
        // Si no se trata de un documento fiscal, se imprime de forma tradicional
        if (!isFiscal) {
            if (isJavaPOS) {
                final MInvoice invoice = p_posPanel.m_order.getInvoices()[0];
                final ImprimeTicketCompra ticketCompra = new ImprimeTicketCompra(invoice);
                try {
                    ticketCompra.imprimir();
                    // @fchiappano Imprimir ticket de envio a domicilio.
                    if (p_posPanel.m_order.get_ValueAsBoolean("ImprimirEnvio")) {
                        final ImprimeTicketEnvio ticketEnvio = new ImprimeTicketEnvio(order);
                        ticketEnvio.imprimir();
                    }
                } catch (JposException e) {
                    log.log(Level.SEVERE, "Error al imprimir v\u00eda Java POS", e);
                }
            }
            p_posPanel.newOrder();
            ReportCtl.startDocumentPrint(reportType, documentId, null, Env.getWindowNo(this), false);
        }
        p_posPanel.stopGlassPane();
    }
// if (order != null)
}
Also used : MInOut(org.compiere.model.MInOut) MOrder(org.compiere.model.MOrder) JposException(jpos.JposException) MInvoice(org.compiere.model.MInvoice) ImprimeTicketCompra(ar.com.comit.print.javapos.ImprimeTicketCompra) ImprimeTicketEnvio(ar.com.comit.print.javapos.ImprimeTicketEnvio)

Aggregations

ImprimeTicketCompra (ar.com.comit.print.javapos.ImprimeTicketCompra)1 ImprimeTicketEnvio (ar.com.comit.print.javapos.ImprimeTicketEnvio)1 JposException (jpos.JposException)1 MInOut (org.compiere.model.MInOut)1 MInvoice (org.compiere.model.MInvoice)1 MOrder (org.compiere.model.MOrder)1