Search in sources :

Example 31 with FiscalPacket

use of ar.com.ergio.print.fiscal.FiscalPacket in project lar_361 by comitsrl.

the class HasarFiscalPrinter method cmdCloseFiscalReceipt.

public FiscalPacket cmdCloseFiscalReceipt(Integer copies) {
    FiscalPacket cmd = createFiscalPacket(CMD_CLOSE_FISCAL_RECEIPT);
    int i = 1;
    cmd.setNumber(i++, copies, true);
    return cmd;
}
Also used : FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Example 32 with FiscalPacket

use of ar.com.ergio.print.fiscal.FiscalPacket in project lar_361 by comitsrl.

the class HasarFiscalPrinter method printDocument.

public void printDocument(Invoice invoice) throws FiscalPrinterStatusError, FiscalPrinterIOException, DocumentException {
    Customer customer = invoice.getCustomer();
    FiscalPacket response;
    // Se valida la factura.
    invoice.validate();
    try {
        setCancelAllowed(false);
        // ////////////////////////////////////////////////////////////
        // Se setean los datos del comprador.
        // Comando: @SetCustomerData
        loadCustomerData(customer);
        // Comando: @SetEmbarkNumber
        if (invoice.hasPackingSlipNumber()) {
            execute(cmdSetEmbarkNumber(1, invoice.getPackingSlipNumber()));
        }
        // ////////////////////////////////////////////////////////////
        // Se abre el documento fiscal.
        // Comando: @OpenFiscalReceipt
        response = execute(cmdOpenFiscalReceipt(traduceDocumentType(Document.DT_INVOICE, invoice.getLetter())));
        setLastDocumentNo("");
        setCancelAllowed(true);
        setDocumentOpened(true);
        // Comando: @PrintFiscalText
        for (String observation : invoice.getObservations()) {
            execute(cmdPrintFiscalText(observation, null));
        }
        // ////////////////////////////////////////////////////////////
        // Se cargan los ítems de la factura.
        // Comando: @PrintLineItem
        loadDocumentLineItems(invoice);
        // ////////////////////////////////////////////////////////////
        // Se cargan los descuentos de la factura.
        loadDocumentDiscounts(invoice);
        // ////////////////////////////////////////////////////////////
        // load invoice perception
        loadDocumentPerception(invoice);
        // ////////////////////////////////////////////////////////////
        // Se calcula el subtotal.
        // Comando: @Subtotal
        execute(cmdSubtotal(true, null));
        // Comando: @TotalTender
        for (Payment payment : invoice.getPayments()) {
            execute(cmdTotalTender(payment.getDescription(), payment.getAmount(), false, null));
            setCancelAllowed(false);
        }
        // ////////////////////////////////////////////////////////////
        // Se cierra el comprobante fiscal.
        // Comando: @CloseFiscalReceipt
        response = execute(cmdCloseFiscalReceipt(null));
        setDocumentOpened(false);
        // Chequeo de impuestos
        checkTaxes(invoice);
        // Se obtiene el número de comprobante emitido.
        setLastDocumentNo(response.getString(3));
        invoice.setDocumentNo(getLastDocumentNo());
        // Se obtiene el número del CAI.
        if (invoice.getLetter().equals(Document.DOC_LETTER_A))
            ;
        invoice.setCAINumber(getCAINumber(response));
        // Se indica al manejador de eventos que la impresión ha finalizado.
        firePrintEnded();
    } catch (FiscalPrinterIOException e) {
        // Si ocurrió algún error se intenta cancelar el documento
        // actual y se relanza la excepción.
        cancelCurrentDocument();
        throw e;
    }
}
Also used : Payment(ar.com.ergio.print.fiscal.document.Payment) Customer(ar.com.ergio.print.fiscal.document.Customer) FiscalPrinterIOException(ar.com.ergio.print.fiscal.exception.FiscalPrinterIOException) FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Example 33 with FiscalPacket

use of ar.com.ergio.print.fiscal.FiscalPacket in project lar_361 by comitsrl.

the class HasarFiscalPrinter method cmdLastItemDiscount.

public FiscalPacket cmdLastItemDiscount(String description, BigDecimal amount, boolean substract, boolean baseAmount, Integer display) {
    FiscalPacket cmd = createFiscalPacket(CMD_LAST_ITEM_DISCOUNT);
    int i = 1;
    cmd.setText(i++, description, 50, false);
    cmd.setPerceptionAmount(i++, amount, false);
    cmd.setBoolean(i++, substract, "m", "M", false);
    cmd.setNumber(i++, display, true);
    cmd.setBoolean(i++, baseAmount, "x", "T", false);
    return cmd;
}
Also used : FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Example 34 with FiscalPacket

use of ar.com.ergio.print.fiscal.FiscalPacket in project lar_361 by comitsrl.

the class HasarFiscalPrinter method cmdOpenFiscalReceipt.

public FiscalPacket cmdOpenFiscalReceipt(String docType) {
    FiscalPacket cmd = createFiscalPacket(CMD_OPEN_FISCAL_RECEIPT);
    int i = 1;
    cmd.setText(i++, docType, false);
    cmd.setText(i++, "T", true);
    return cmd;
}
Also used : FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Example 35 with FiscalPacket

use of ar.com.ergio.print.fiscal.FiscalPacket in project lar_361 by comitsrl.

the class HasarFiscalPrinter method cmdSetHeaderTrailer.

public FiscalPacket cmdSetHeaderTrailer(int line, String text) {
    FiscalPacket cmd = createFiscalPacket(CMD_SET_HEADER_TRAILER);
    int i = 1;
    cmd.setNumber(i++, line, false);
    cmd.setText(i++, text, 120, false);
    return cmd;
}
Also used : FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Aggregations

FiscalPacket (ar.com.ergio.print.fiscal.FiscalPacket)39 FiscalPrinterIOException (ar.com.ergio.print.fiscal.exception.FiscalPrinterIOException)5 Customer (ar.com.ergio.print.fiscal.document.Customer)4 Payment (ar.com.ergio.print.fiscal.document.Payment)1 FiscalPrinterStatusError (ar.com.ergio.print.fiscal.exception.FiscalPrinterStatusError)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1