Search in sources :

Example 1 with DNFH

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

the class FiscalDocumentPrint method printInvoice.

/**
 * Impresión de una factura.
 *
 * @param document
 *            factura imprimible creada a partir del documento oxp, si es
 *            null se crea una nueva a partir del documento oxp que está
 *            configurado. Dentro de este método se realiza un casting del
 *            documento parámetro hacia {@link Invoice} por lo que debe ser
 *            una instancia de esa clase sino se producirá un error en
 *            tiempo de ejecución.
 */
// TODO - Redesign this method
private void printInvoice(final Document document) throws FiscalPrinterStatusError, FiscalPrinterIOException, Exception {
    MInvoice mInvoice = (MInvoice) getOxpDocument();
    // Se valida el documento OXP.
    validateOxpDocument(mInvoice);
    /*
         * @emmie inicio - Impresion remito En caso de tratarse de una venta en
         * ctacte, se imprime el remito asocido a la factura ANTES de imprimir
         * la factura
         */
    final MOrder order = new MOrder(ctx, mInvoice.getC_Order_ID(), getTrxName());
    boolean printShipment = order.get_ValueAsBoolean("PrintShipment");
    if (printShipment && mInvoice.getC_PaymentTerm_ID() == PosOrderModel.PAYMENTTERMS_Account) {
        // Se recupera el remito de la primera linea (se asume 1 remito)
        int m_InOut_ID = mInvoice.getLines()[0].getM_InOutLine().getM_InOut_ID();
        final MInOut shipment = new MInOut(ctx, m_InOut_ID, getTrxName());
        // Crea el documento no-fiscal y luego obtiene todas las líneas del pedido
        final DNFH dnfh = createDNFH(shipment);
        // Se le indica al documento no-fiscal que no finalice la impresión
        dnfh.setPrintEnded(false);
        // Manda a imprimir el documento en la impresora fiscal
        getFiscalPrinter().printDocument(dnfh);
        // Guarda la info devuelta por el controlador
        saveShipmentData(shipment, dnfh);
    }
    // @emmie fin - Impresion remito
    // Se crea la factura imprimible en caso que no exista como parámetro
    final Invoice printeableInvoice;
    if (document != null) {
        printeableInvoice = (Invoice) document;
    } else {
        printeableInvoice = createInvoice(mInvoice);
    }
    // Se manda a imprimir la factura a la impresora fiscal.
    getFiscalPrinter().printDocument(printeableInvoice);
    // Se actualizan los datos de la factura de oxp.
    saveDocumentData(mInvoice, printeableInvoice);
}
Also used : MInOut(org.compiere.model.MInOut) MOrder(org.compiere.model.MOrder) Invoice(ar.com.ergio.print.fiscal.document.Invoice) MInvoice(org.compiere.model.MInvoice) MInvoice(org.compiere.model.MInvoice) DNFH(ar.com.ergio.print.fiscal.document.DNFH)

Example 2 with DNFH

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

the class FiscalDocumentPrint method doPrintShipmentDocument.

/**
 * Realiza la impresión del documento no fiscal homologado
 * con los artículos a entregar.
 *
 * @param args Arreglo con los argumentos requeridos por esta funcionalidad
 * @throws Exception
 */
private void doPrintShipmentDocument(final Object[] args) throws Exception {
    final MInOut shipment = (MInOut) args[0];
    // Informa el inicio de la impresión
    fireActionStarted(FiscalDocumentListener.AC_PRINT_DOCUMENT);
    // Crea el documento no fiscal y luego obtiene todas las líneas del pedido
    final DNFH dnfh = createDNFH(shipment);
    // Se asigna el documento OXP.
    setOxpDocument(shipment);
    // Manda a imprimir el documento en la impresora fiscal
    getFiscalPrinter().printDocument(dnfh);
    // Guarda la info devuelta por el controlador
    saveShipmentData(shipment, dnfh);
    // Se dispara el evento de impresión finalizada.
    fireDocumentPrintEndedOk();
}
Also used : MInOut(org.compiere.model.MInOut) DNFH(ar.com.ergio.print.fiscal.document.DNFH)

Example 3 with DNFH

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

the class FiscalDocumentPrint method createDNFH.

private DNFH createDNFH(final MInOut shipment) {
    final DNFH dnfh = new DNFH();
    // Se asigna el cliente.
    Customer customer = null;
    final MBPartner bPartner = new MBPartner(Env.getCtx(), shipment.getC_BPartner_ID(), null);
    if (bPartner != null) {
        customer = new Customer();
        // Se asigna la categoría de iva del cliente.
        LAR_TaxPayerType taxPayerType = LAR_TaxPayerType.getTaxPayerType(bPartner);
        customer.setIvaResponsibility(traduceTaxPayerType(taxPayerType.getName()));
        // Se asigna el nombre del cliente a partir del BPartner.
        customer.setName(bPartner.getName());
        // Se asigna el domicilio.
        final MLocation location = MLocation.getBPLocation(Env.getCtx(), shipment.getC_BPartner_Location_ID(), getTrxName());
        customer.setLocation(location.toString());
        // Se identifica al cliente con el C.U.I.T. configurado en el Bpartner.
        if (bPartner.getTaxID() != null && !bPartner.getTaxID().trim().equals("")) {
            customer.setIdentificationType(Customer.CUIT);
            customer.setIdentificationNumber(bPartner.getTaxID());
        }
    }
    dnfh.setCustomer(customer);
    // Recupera el numero de copias a imprimir
    int numberOfCopies = MSysConfig.getIntValue("LAR_Remitos_NumeroDeCopias", 0, Env.getAD_Client_ID(shipment.getCtx()));
    dnfh.setNumberOfCopies(numberOfCopies);
    // Cargar las lineas del remito
    loadDNFHLines(shipment, dnfh);
    return dnfh;
}
Also used : Customer(ar.com.ergio.print.fiscal.document.Customer) MBPartner(org.compiere.model.MBPartner) DNFH(ar.com.ergio.print.fiscal.document.DNFH) LAR_TaxPayerType(ar.com.ergio.model.LAR_TaxPayerType) MLocation(org.compiere.model.MLocation)

Aggregations

DNFH (ar.com.ergio.print.fiscal.document.DNFH)3 MInOut (org.compiere.model.MInOut)2 LAR_TaxPayerType (ar.com.ergio.model.LAR_TaxPayerType)1 Customer (ar.com.ergio.print.fiscal.document.Customer)1 Invoice (ar.com.ergio.print.fiscal.document.Invoice)1 MBPartner (org.compiere.model.MBPartner)1 MInvoice (org.compiere.model.MInvoice)1 MLocation (org.compiere.model.MLocation)1 MOrder (org.compiere.model.MOrder)1