Search in sources :

Example 11 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class GenerateShipmentOutBound method processingMovements.

public void processingMovements() {
    distributionOrders.entrySet().stream().forEach(entry -> {
        I_DD_Order distributionOrder = entry.getValue();
        List<Integer> orderIds = new ArrayList<Integer>();
        orderIds.add(distributionOrder.getDD_Order_ID());
        ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(MovementGenerate.getProcessId()).withSelectedRecordsIds(orderIds).withParameter(MWMInOutBound.COLUMNNAME_M_Warehouse_ID, distributionOrder.getM_Warehouse_ID()).withParameter(MMovement.COLUMNNAME_MovementDate, getMovementDate()).withoutTransactionClose().execute(get_TrxName());
        if (processInfo.isError())
            throw new AdempiereException(processInfo.getSummary());
        addLog(processInfo.getSummary());
        Arrays.stream(processInfo.getIDs()).forEach(recordId -> {
            MMovement movement = new MMovement(getCtx(), recordId, get_TrxName());
            if (movement != null && movement.get_ID() > 0)
                GenerateMovement.printDocument(movement, "Inventory Move Hdr (Example)", processInfo.getWindowNo());
            else
                throw new AdempiereException("@M_Movement_ID@ @NotFound@");
        });
    });
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) ArrayList(java.util.ArrayList) ProcessInfo(org.compiere.process.ProcessInfo) I_DD_Order(org.eevolution.model.I_DD_Order) MMovement(org.compiere.model.MMovement)

Example 12 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class ProcessBuilder method generateProcessInfo.

/**
     * Generate Process Info for this process
     */
private void generateProcessInfo(String trxName) {
    if (instance == null)
        generateProcessInstance();
    //	FR [ 244 ]
    boolean isSelection = selectedRecordsIds.size() > 0;
    processInfo = new ProcessInfo(title, processId, tableId, recordId, isManagedTransaction);
    processInfo.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    processInfo.setClassName(MProcess.get(context, processId).getClassname());
    processInfo.setTransactionName(trxName);
    processInfo.setIsSelection(isSelection);
    if (isExecuteUsingSystemRole) {
        processInfo.setAD_Client_ID(0);
        processInfo.setAD_User_ID(100);
    }
    ProcessInfoUtil.setParameterFromDB(processInfo);
    //	FR [ 352 ]
    if (isSelection) {
        processInfo.setSelectionKeys(selectedRecordsIds);
        if (selection != null && selection.size() > 0) {
            processInfo.setSelectionValues(selection);
            //TODO : The WProcessCtl and ServerProcessCtl not save selection and smart browser selection
            if (windowNo == 0)
                DB.createT_Selection_Browse(processInfo.getAD_PInstance_ID(), processInfo.getSelectionValues(), processInfo.getTransactionName());
        }
        //TODO : The WProcessCtl and ServerProcessCtl not save selection and smart browser selection
        if (// force the save selction the issue that not implement save selection
        windowNo == 0)
            DB.createT_Selection(processInfo.getAD_PInstance_ID(), processInfo.getSelectionKeys(), processInfo.getTransactionName());
    }
}
Also used : ProcessInfo(org.compiere.process.ProcessInfo)

Example 13 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class InvoiceGenFromShipment method generate.

/**************************************************************************
	 *	Generate Invoices
	 */
public String generate(IStatusBar statusBar, KeyNamePair docTypeKNPair, String docActionSelected) {
    String info = "";
    String trxName = Trx.createTrxName("IVG");
    //trx needs to be committed too
    Trx trx = Trx.get(trxName, true);
    //  prevents from being called twice
    setSelectionActive(false);
    statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateGen"));
    statusBar.setStatusDB(String.valueOf(getSelection().size()));
    //	Prepare Process
    int AD_Process_ID = 0;
    if (docTypeKNPair.getKey() == MInOut.Table_ID) {
        // HARDCODED- AD_Process.Value=C_Invoice_Generate_from_Shipment; class=org.adempiere.process.InvoiceGenerateFromShipment
        AD_Process_ID = 53345;
    } else {
    //        	AD_Process_ID = 52002; // AD_Process.Value=C_Invoice_GenerateRMA (Manual); class=org.adempiere.process.InvoiceGenerateRMA
    }
    MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
    if (!instance.save()) {
        info = Msg.getMsg(Env.getCtx(), "ProcessNoInstance");
        return info;
    }
    //insert selection
    StringBuffer insert = new StringBuffer();
    insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
    int counter = 0;
    for (Integer selectedId : getSelection()) {
        counter++;
        if (counter > 1)
            insert.append(" UNION ");
        insert.append("SELECT ");
        insert.append(instance.getAD_PInstance_ID());
        insert.append(", ");
        insert.append(selectedId);
        insert.append(" FROM DUAL ");
        if (counter == 1000) {
            if (DB.executeUpdate(insert.toString(), trxName) < 0) {
                //  not translated!
                String msg = "No Invoices";
                info = msg;
                log.config(msg);
                trx.rollback();
                return info;
            }
            insert = new StringBuffer();
            insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
            counter = 0;
        }
    }
    if (counter > 0) {
        if (DB.executeUpdate(insert.toString(), trxName) < 0) {
            //  not translated!
            String msg = "No Invoices";
            info = msg;
            log.config(msg);
            trx.rollback();
            return info;
        }
    }
    ProcessInfo pi = new ProcessInfo("", AD_Process_ID);
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    //	Add Parameters
    MPInstancePara para = new MPInstancePara(instance, 10);
    para.setParameter("Selection", "Y");
    if (!para.save()) {
        //  not translated
        String msg = "No Selection Parameter added";
        info = msg;
        log.log(Level.SEVERE, msg);
        return info;
    }
    para = new MPInstancePara(instance, 20);
    para.setParameter("DocAction", docActionSelected);
    if (!para.save()) {
        //  not translated
        String msg = "No DocAction Parameter added";
        info = msg;
        log.log(Level.SEVERE, msg);
        return info;
    }
    setTrx(trx);
    setProcessInfo(pi);
    return info;
}
Also used : MPInstancePara(org.compiere.model.MPInstancePara) MPInstance(org.compiere.model.MPInstance) Trx(org.compiere.util.Trx) ProcessInfo(org.compiere.process.ProcessInfo)

Example 14 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class CPOS method generateInvoice.

/**
	 * Generate Invoice
	 * @param trxName
	 * @return void
	 */
private void generateInvoice(String trxName) {
    List<Integer> selectionIds = new ArrayList<Integer>();
    selectionIds.add(getC_Order_ID());
    //Generate InvoiceGenerate
    ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(134).withTitle(Msg.parseTranslation(getCtx(), "@InvGenerateGen@")).withParameter("Selection", true).withParameter(MInvoice.COLUMNNAME_DocAction, DocAction.ACTION_Complete).withSelectedRecordsIds(selectionIds).withoutTransactionClose().execute(trxName);
    if (processInfo.isError())
        throw new AdempiereException(processInfo.getSummary());
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) ArrayList(java.util.ArrayList) ProcessInfo(org.compiere.process.ProcessInfo)

Example 15 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class POSGenericTicketHandler method printTicket.

@Override
public void printTicket() {
    try {
        ProcessInfo info = new ProcessInfo(null, 0);
        info.setTransactionName(getPOS().get_TrxName());
        if (!getPOS().isInvoiced()) {
            ReportCtl.startDocumentPrint(ReportEngine.ORDER, null, getPOS().getC_Order_ID(), null, getPOS().getWindowNo(), false, null, info);
        } else {
            for (MInvoice invoice : getPOS().getOrder().getInvoices()) {
                ReportCtl.startDocumentPrint(ReportEngine.INVOICE, null, invoice.getC_Invoice_ID(), null, getPOS().getWindowNo(), false, null, info);
            }
        }
    } catch (Exception e) {
        throw new AdempierePOSException("PrintTicket - Error Printing Ticket");
    }
}
Also used : AdempierePOSException(org.adempiere.pos.AdempierePOSException) MInvoice(org.compiere.model.MInvoice) ProcessInfo(org.compiere.process.ProcessInfo) AdempierePOSException(org.adempiere.pos.AdempierePOSException)

Aggregations

ProcessInfo (org.compiere.process.ProcessInfo)65 MPInstance (org.compiere.model.MPInstance)21 Trx (org.compiere.util.Trx)17 AdempiereException (org.adempiere.exceptions.AdempiereException)14 MPInstancePara (org.compiere.model.MPInstancePara)12 ReportEngine (org.compiere.print.ReportEngine)11 File (java.io.File)10 MProcess (org.compiere.model.MProcess)9 ProcessCtl (org.compiere.apps.ProcessCtl)8 SQLException (java.sql.SQLException)6 Timestamp (java.sql.Timestamp)6 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)5 ServletException (javax.servlet.ServletException)4 MBrowse (org.adempiere.model.MBrowse)4 PrintInfo (org.compiere.model.PrintInfo)4 ProcessInfoParameter (org.compiere.process.ProcessInfoParameter)4 Properties (java.util.Properties)3 MMovement (org.compiere.model.MMovement)3 PO (org.compiere.model.PO)3