Search in sources :

Example 1 with PosOrderGlobalVoiding

use of ar.com.ergio.process.PosOrderGlobalVoiding in project lar_361 by comitsrl.

the class LAR_Validator method anularOperación.

// Marcos Zúñiga -end
/**
 * Anular toda la operación de venta (OV - Recibos - Factura y Remito).
 *
 * @param invoice
 */
private void anularOperación(final MInvoice invoice, final String documentNo, final String fiscalreceiptnumber) {
    SwingWorker worker = new SwingWorker() {

        private String errorMsg = null;

        @Override
        public Object construct() {
            // Crea parámetro que se enviará al proceso
            final ProcessInfoParameter param = new ProcessInfoParameter("C_Order_ID", invoice.getC_Order_ID(), "", "", "");
            // Crea información del proceso
            int AD_Process_ID = 3000037;
            final ProcessInfo pi = new ProcessInfo("PosOrderGlobalVoiding", AD_Process_ID);
            pi.setParameter(new ProcessInfoParameter[] { param });
            // Crea una instancia de proceso (para registro y
            // sincronizacion)
            final MPInstance pinstance = new MPInstance(Env.getCtx(), 0, null);
            pinstance.setAD_Process_ID(AD_Process_ID);
            pinstance.setRecord_ID(0);
            pinstance.save();
            // Conecta el proceso con la instancia de proceso
            pi.setAD_PInstance_ID(pinstance.get_ID());
            // Crea el proceso a ejecutar
            final PosOrderGlobalVoiding process = new PosOrderGlobalVoiding();
            log.info("Iniciando proceso global de anulaci\u00f3n");
            return process.startProcess(Env.getCtx(), pi, null);
        }

        // construct
        @Override
        public void finished() {
            boolean success = (Boolean) getValue();
            if (!success) {
                ADialog.error(0, Env.getWindow(0), errorMsg);
            } else {
                ADialog.warn(0, Env.getWindow(0), "Número de Documento " + documentNo + " duplicado.", "Operación anulada.");
                // Corregir Secuencia.
                MSequence.setFiscalDocTypeNextNroComprobante(invoice.getC_DocType().getDefiniteSequence_ID(), Integer.parseInt(fiscalreceiptnumber) + 1, null);
            }
        }
    };
    // new SwingWorker
    worker.start();
    worker.finished();
}
Also used : ProcessInfoParameter(org.compiere.process.ProcessInfoParameter) PosOrderGlobalVoiding(ar.com.ergio.process.PosOrderGlobalVoiding) MPInstance(org.compiere.model.MPInstance) SwingWorker(org.compiere.apps.SwingWorker) ProcessInfo(org.compiere.process.ProcessInfo)

Example 2 with PosOrderGlobalVoiding

use of ar.com.ergio.process.PosOrderGlobalVoiding in project lar_361 by comitsrl.

the class PosBasePanel method voidDocuments.

/**
 * Invoca la anulación de los documentos generados debido a un error en la
 * impresión fiscal
 */
private void voidDocuments() {
    SwingWorker worker = new SwingWorker() {

        private String errorMsg = null;

        @Override
        public Object construct() {
            // Crea parámetro que se enviará al proceso
            final ProcessInfoParameter param = new ProcessInfoParameter("C_Order_ID", m_order.getC_Order_ID(), "", "", "");
            // Crea información del proceso
            int AD_Process_ID = 3000037;
            final ProcessInfo pi = new ProcessInfo("PosOrderGlobalVoiding", AD_Process_ID);
            pi.setParameter(new ProcessInfoParameter[] { param });
            // Crea una instancia de proceso (para registro y sincronizacion)
            final MPInstance pinstance = new MPInstance(m_ctx, 0, null);
            pinstance.setAD_Process_ID(AD_Process_ID);
            pinstance.setRecord_ID(0);
            pinstance.save();
            // Conecta el proceso con la instancia de proceso
            pi.setAD_PInstance_ID(pinstance.get_ID());
            // Crea el proceso a ejecutar
            final PosOrderGlobalVoiding process = new PosOrderGlobalVoiding();
            log.info("Iniciando proceso global de anulaci\u00f3n");
            return process.startProcess(m_ctx, pi, null);
        }

        @Override
        public void finished() {
            boolean success = (Boolean) getValue();
            if (!success) {
                ADialog.error(getWindowNo(), PosBasePanel.this, errorMsg);
                if (ADialog.ask(getWindowNo(), PosBasePanel.this, Msg.parseTranslation(m_ctx, "@RetryVoidInvoice@"))) {
                    // Re intenta anular los documentos.
                    voidDocuments();
                } else {
                    newOrder();
                    stopGlassPane();
                }
            } else {
                newOrder();
                stopGlassPane();
            }
        }
    };
    // new SwingWorker
    startGlassPane("VoidingInvoice");
    worker.start();
}
Also used : ProcessInfoParameter(org.compiere.process.ProcessInfoParameter) PosOrderGlobalVoiding(ar.com.ergio.process.PosOrderGlobalVoiding) MPInstance(org.compiere.model.MPInstance) SwingWorker(org.compiere.apps.SwingWorker) ProcessInfo(org.compiere.process.ProcessInfo) FiscalDocumentPrint(ar.com.ergio.model.FiscalDocumentPrint)

Aggregations

PosOrderGlobalVoiding (ar.com.ergio.process.PosOrderGlobalVoiding)2 SwingWorker (org.compiere.apps.SwingWorker)2 MPInstance (org.compiere.model.MPInstance)2 ProcessInfo (org.compiere.process.ProcessInfo)2 ProcessInfoParameter (org.compiere.process.ProcessInfoParameter)2 FiscalDocumentPrint (ar.com.ergio.model.FiscalDocumentPrint)1