Search in sources :

Example 21 with FiscalPacket

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

the class HasarFiscalPrinter method loadCustomerData.

/**
 * 	Ejecuta el comando para asignar los datos del comprador en caso
 *	de que el comprador exista.
 */
protected FiscalPacket loadCustomerData(final Customer customer) throws FiscalPrinterStatusError, FiscalPrinterIOException {
    FiscalPacket response = null;
    if (customer != null) {
        // nulls en los campos por un String espacio " ".
        if (customer.getIvaResponsibility() == Customer.CONSUMIDOR_FINAL) {
            customer.setName(customer.getName() == null ? " " : customer.getName());
            customer.setLocation(customer.getLocation() == null ? " " : customer.getLocation());
            customer.setIdentificationNumber(customer.getIdentificationNumber() == null ? " " : customer.getIdentificationNumber());
        }
        execute(cmdSetCustomerData(customer.getName(), customer.getIdentificationNumber(), traduceIvaResponsibility(customer.getIvaResponsibility()), traduceIdentificationType(customer.getIdentificationType()), customer.getLocation()));
    }
    return response;
}
Also used : FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Example 22 with FiscalPacket

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

the class HasarFiscalPrinter method cmdPerceptions.

public FiscalPacket cmdPerceptions(String description, BigDecimal amount, BigDecimal alicuotaIVA) {
    FiscalPacket cmd = createFiscalPacket(CMD_PERCEPTIONS);
    int i = 1;
    if (alicuotaIVA == null)
        cmd.setText(i++, "**.**", false);
    else
        cmd.setNumber(i++, alicuotaIVA, 2, 2, false);
    cmd.setText(i++, description, 20, false);
    cmd.setPerceptionAmount(i++, amount, false);
    return cmd;
}
Also used : FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Example 23 with FiscalPacket

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

the class HasarFiscalPrinter method cmdPrintQuotationItem.

public FiscalPacket cmdPrintQuotationItem(String description, Integer display) {
    FiscalPacket cmd = createFiscalPacket(CMD_PRINT_QUOTATION_ITEM);
    int i = 1;
    cmd.setText(i++, description, 120, false);
    cmd.setNumber(i++, display, true);
    return cmd;
}
Also used : FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Example 24 with FiscalPacket

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

the class HasarFiscalPrinter method cmdSetComSpeed.

public FiscalPacket cmdSetComSpeed(Long speed) {
    FiscalPacket cmd = createFiscalPacket(CMD_SET_COM_SPEED);
    int i = 1;
    cmd.setLong(i++, speed);
    return cmd;
}
Also used : FiscalPacket(ar.com.ergio.print.fiscal.FiscalPacket)

Example 25 with FiscalPacket

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

the class HasarFiscalPrinter method printDocument.

public void printDocument(DebitNote debitNote) throws FiscalPrinterStatusError, FiscalPrinterIOException, DocumentException {
    Customer customer = debitNote.getCustomer();
    FiscalPacket response;
    // Se valida la nota de débito.
    debitNote.validate();
    try {
        setCancelAllowed(false);
        // ////////////////////////////////////////////////////////////
        // Se setean los datos del comprador.
        // Comando: @SetCustomerData
        loadCustomerData(customer);
        // Comando: @SetEmbarkNumber
        if (debitNote.hasPackingSlipNumber())
            execute(cmdSetEmbarkNumber(1, debitNote.getPackingSlipNumber()));
        // ////////////////////////////////////////////////////////////
        // Se abre el documento fiscal.
        // Comando: @OpenFiscalReceipt
        response = execute(cmdOpenFiscalReceipt(traduceDocumentType(Document.DT_DEBIT_NOTE, debitNote.getLetter())));
        setLastDocumentNo("");
        setCancelAllowed(true);
        setDocumentOpened(true);
        // Comando: @PrintFiscalText
        for (String observation : debitNote.getObservations()) {
            execute(cmdPrintFiscalText(observation, null));
        }
        // ////////////////////////////////////////////////////////////
        // Se cargan los ítems de la nota de débito.
        // Comando: @PrintLineItem
        loadDocumentLineItems(debitNote);
        // ////////////////////////////////////////////////////////////
        // Se carga la percepción de la note de crédito
        loadDocumentPerception(debitNote);
        // ////////////////////////////////////////////////////////////
        // Se cierra el comprobante fiscal.
        // Comando: @CloseFiscalReceipt
        response = execute(cmdCloseFiscalReceipt(null));
        setDocumentOpened(false);
        // Se obtiene el número de comprobante emitido.
        setLastDocumentNo(response.getString(3));
        debitNote.setDocumentNo(getLastDocumentNo());
        // Se obtiene el número del CAI.
        if (debitNote.getLetter().equals(Document.DOC_LETTER_A))
            ;
        debitNote.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 : Customer(ar.com.ergio.print.fiscal.document.Customer) FiscalPrinterIOException(ar.com.ergio.print.fiscal.exception.FiscalPrinterIOException) 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