Search in sources :

Example 41 with ProcessInfo

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

the class PackOutTest method testPackOut.

public void testPackOut() {
    PackOut m_PackOut = new PackOut();
    PackInHandler m_PackInHandler = new PackInHandler();
    Trx m_trx = Trx.get(getTrxName(), true);
    int m_ad_process_id = IDFinder.get_IDWithColumn("ad_process", "Name", "PackOut", getAD_Client_ID(), getTrxName());
    int m_ad_table_id = IDFinder.get_IDWithColumn("ad_table", "Name", "AD_Package_Exp_ID", getAD_Client_ID(), getTrxName());
    //Create 2Pack Export Package
    MPackageExp m_MPackageExp = new MPackageExp(getCtx(), 0, getTrxName());
    m_MPackageExp.setName("testSqlStatement2Pack");
    m_MPackageExp.setIsActive(true);
    m_MPackageExp.setDescription("Test Output Package");
    m_MPackageExp.setEMail("wgheath@gmail.com");
    m_MPackageExp.setUserName("wgheath@gmail.com");
    m_MPackageExp.setFile_Directory("packages/");
    m_MPackageExp.setInstructions("use 2pack to import this package");
    m_MPackageExp.setReleaseNo(X_AD_Package_Exp_Detail.RELEASENO_NoSpecificRelease);
    m_MPackageExp.setVersion("1.0");
    m_MPackageExp.setPK_Version("1.0");
    boolean saveResult = m_MPackageExp.save();
    assertTrue("MPackageExp.save()", saveResult);
    X_AD_Package_Exp_Detail m_PackDetail = new X_AD_Package_Exp_Detail(getCtx(), 0, getTrxName());
    m_PackDetail.setAD_Org_ID(m_MPackageExp.getAD_Org_ID());
    m_PackDetail.setAD_Package_Exp_ID(m_MPackageExp.get_ID());
    m_MPackageExp.setIsActive(true);
    m_PackDetail.setType(X_AD_Package_Exp_Detail.TYPE_SQLStatement);
    m_PackDetail.setDBType("ALL");
    m_PackDetail.setSQLStatement("select * from ad_table");
    m_PackDetail.setDescription("2pack test sql statement");
    /*m_PackDetail.setFileName(rs.getString("FILENAME"));
		m_PackDetail.setAD_Client_ID(m_MPackageExp.getAD_Client_ID());
		m_PackDetail.setDescription(rs.getString("DESCRIPTION"));
		m_PackDetail.setTarget_Directory(rs.getString("TARGET_DIRECTORY"));
		m_PackDetail.setFile_Directory(rs.getString("FILE_DIRECTORY"));
		m_PackDetail.setDestination_Directory(rs.getString("DESTINATION_DIRECTORY"));
		m_PackDetail.setAD_Workflow_ID(rs.getInt("AD_WORKFLOW_ID"));
		m_PackDetail.setAD_Window_ID(rs.getInt("AD_WINDOW_ID"));
		m_PackDetail.setAD_Role_ID(rs.getInt("AD_ROLE_ID"));
		m_PackDetail.setAD_Process_ID(rs.getInt("AD_PROCESS_ID"));
		m_PackDetail.setAD_Menu_ID(rs.getInt("AD_MENU_ID"));
		m_PackDetail.setAD_ImpFormat_ID(rs.getInt("AD_IMPFORMAT_ID"));
		m_PackDetail.setAD_Workbench_ID(rs.getInt("AD_WORKBENCH_ID"));
		m_PackDetail.setAD_Table_ID(rs.getInt("AD_TABLE_ID"));
		m_PackDetail.setAD_Form_ID(rs.getInt("AD_FORM_ID"));
		m_PackDetail.setAD_ReportView_ID(rs.getInt("AD_REPORTVIEW_ID"));
		*/
    m_PackDetail.setLine(10);
    saveResult = m_PackDetail.save();
    assertTrue("X_AD_Package_Exp_Detail.save()", saveResult);
    int m_ad_record_id = IDFinder.get_IDWithColumn("ad_package_exp", "Name", "test2packJunit", getAD_Client_ID(), getTrxName());
    ProcessInfo m_ProcessInfo = new ProcessInfo("PackOut", m_ad_process_id, m_ad_table_id, m_MPackageExp.get_ID());
    m_PackOut.startProcess(getCtx(), m_ProcessInfo, m_trx);
    assertFalse("PackOut", m_ProcessInfo.isError());
    try {
        commit();
    } catch (Exception e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : PackInHandler(org.adempiere.pipo.PackInHandler) X_AD_Package_Exp_Detail(org.compiere.model.X_AD_Package_Exp_Detail) PackOut(org.adempiere.pipo.PackOut) Trx(org.compiere.util.Trx) ProcessInfo(org.compiere.process.ProcessInfo) MPackageExp(org.compiere.model.MPackageExp)

Example 42 with ProcessInfo

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

the class GenerateImmediateInvoice method doIt.

@Override
protected String doIt() throws Exception {
    //Create new Order for current date and Bill Partner
    ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(CreateOrderBasedOnAnother.getProcessId()).withTitle(CreateOrderBasedOnAnother.getProcessName()).withParentProcess(this).withParameter(CreateOrderBasedOnAnother.C_OrderSource_ID, order.get_ID()).withParameter(CreateOrderBasedOnAnother.Bill_BPartner_ID, getInvoicePartnerId()).withParameter(CreateOrderBasedOnAnother.DocSubTypeSO, getSOSubType()).withParameter(CreateOrderBasedOnAnother.DocAction, DocAction.ACTION_Complete).withParameter(CreateOrderBasedOnAnother.IsIncludePayments, isIncludePayments()).withParameter(CreateOrderBasedOnAnother.IsAllocated, isAllocated()).withoutTransactionClose().execute(get_TrxName());
    if (processInfo.isError())
        throw new AdempiereException(processInfo.getTitle() + " @ProcessRunError@ " + processInfo.getSummary());
    addLog(processInfo.getLogInfo());
    int newOrderId = processInfo.getRecord_ID();
    //Reverse The Sales Transaction for Source Order
    processInfo = ProcessBuilder.create(getCtx()).process(ReverseTheSalesTransaction.getProcessId()).withTitle(ReverseTheSalesTransaction.getProcessName()).withParentProcess(this).withParameter(ReverseTheSalesTransaction.C_Order_ID, order.get_ID()).withParameter(ReverseTheSalesTransaction.Bill_BPartner_ID, getInvoicePartnerId()).withParameter(ReverseTheSalesTransaction.IsShipConfirm, isipReceiptConfirmation()).withoutTransactionClose().execute(get_TrxName());
    if (processInfo.isError())
        throw new AdempiereException(processInfo.getTitle() + " @ProcessRunError@ " + processInfo.getSummary());
    addLog(processInfo.getLogInfo());
    getProcessInfo().setRecord_ID(newOrderId);
    return "@Ok@";
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) ProcessInfo(org.compiere.process.ProcessInfo)

Example 43 with ProcessInfo

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

the class ReverseTheSalesTransaction method cancelInvoices.

private void cancelInvoices() {
    for (MInOut customerReturn : customerReturns) {
        ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(// AD_Process_ID = 154
        "M_InOut_CreateInvoice").withTitle("Generate Invoice from Receipt").withRecordId(MInOut.Table_ID, customerReturn.getM_InOut_ID()).withoutTransactionClose().execute(get_TrxName());
        if (processInfo.isError()) {
            String errorMessage = Msg.parseTranslation(getCtx(), processInfo.getTitle() + " @ProcessRunError@ " + processInfo.getSummary() + " " + processInfo.getLogInfo());
            throw new AdempierePOSException(errorMessage);
        }
        addLog(processInfo.getLogInfo());
        for (MInvoice creditNote : getCreditNotes(customerReturn.getM_RMA_ID())) {
            if (creditNote != null && creditNote.getC_Invoice_ID() > 0) {
                creditNote.setDateInvoiced(today);
                creditNote.setDateAcct(today);
                creditNote.processIt(DocAction.ACTION_Complete);
                creditNote.saveEx();
                addLog(creditNote.getDocumentInfo());
            }
        }
    }
}
Also used : MInOut(org.compiere.model.MInOut) AdempierePOSException(org.adempiere.pos.AdempierePOSException) MInvoice(org.compiere.model.MInvoice) ProcessInfo(org.compiere.process.ProcessInfo)

Example 44 with ProcessInfo

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

the class CPOS method completeReturn.

/**
	 * Complete return material
	 * @param trxName
	 * @return String error Message
	 */
private String completeReturn(String trxName) {
    if (isDrafted() || isInProgress() || isInvalid()) {
        if (!processOrder(trxName, false, false)) {
            return Msg.parseTranslation(getCtx(), " @ProcessRunError@. " + "@order.no@: " + getDocumentNo() + ". @Process@: " + CommandManager.COMPLETE_DOCUMENT);
        }
        // For certain documents, there is no further processing
        String docSubTypeSO = getDocSubTypeSO();
        if ((docSubTypeSO.equals(MOrder.DocSubTypeSO_Standard) || docSubTypeSO.equals(MOrder.DocSubTypeSO_OnCredit) || docSubTypeSO.equals(MOrder.DocSubTypeSO_Warehouse)) && isCompleted())
            return "@POS.IsNotReturn@";
    }
    //	Create
    MOrder returnOrder = new MOrder(getCtx(), getC_Order_ID(), trxName);
    returnOrder.setInvoiceRule(MOrder.INVOICERULE_Immediate);
    returnOrder.setDeliveryRule(MOrder.DELIVERYRULE_Force);
    returnOrder.saveEx();
    List<Integer> selectionIds = new ArrayList<Integer>();
    selectionIds.add(returnOrder.get_ID());
    //Generate Return using InOutGenerate
    ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(199).withParameter(MOrder.COLUMNNAME_M_Warehouse_ID, getM_Warehouse_ID()).withParameter("Selection", true).withSelectedRecordsIds(selectionIds).withoutTransactionClose().execute(trxName);
    if (processInfo.isError()) {
        return processInfo.getLogInfo();
    }
    //Force the confirmation
    for (MInOut customerReturn : returnOrder.getShipments()) {
        customerReturn.processIt(DocAction.ACTION_Complete);
        customerReturn.saveEx();
        for (MInOutConfirm confirm : customerReturn.getConfirmations(true)) {
            for (MInOutLineConfirm confirmLine : confirm.getLines(true)) {
                confirmLine.setConfirmedQty(confirmLine.getTargetQty());
                confirmLine.saveEx();
            }
            confirm.processIt(DocAction.ACTION_Complete);
            confirm.saveEx();
        }
    }
    MOrder sourceOrder = (MOrder) returnOrder.getRef_Order();
    if (sourceOrder != null && returnOrder.getC_Order_ID() > 0) {
        if (sourceOrder.getInvoices().length > 0) {
            //Generate Credit note InvoiceGenerate
            processInfo = ProcessBuilder.create(getCtx()).process(134).withTitle(processInfo.getTitle()).withParameter("Selection", true).withSelectedRecordsIds(selectionIds).withParameter(MInvoice.COLUMNNAME_DocAction, MInvoice.DOCACTION_Complete).withoutTransactionClose().execute(trxName);
            //	Validate Error
            if (processInfo.isError()) {
                return processInfo.getLogInfo();
            }
        } else // if not exist invoice then return of payment
        {
            Timestamp today = new Timestamp(System.currentTimeMillis());
            // Create return payment
            MPayment payment = new MPayment(returnOrder.getCtx(), 0, returnOrder.get_TrxName());
            payment.setDateTrx(today);
            payment.setC_Order_ID(returnOrder.getC_Order_ID());
            payment.setC_BankAccount_ID(getC_BankAccount_ID());
            payment.setDateAcct(today);
            payment.addDescription(Msg.parseTranslation(returnOrder.getCtx(), " @C_Order_ID@ " + returnOrder.getDocumentNo()));
            payment.setIsReceipt(false);
            payment.setC_DocType_ID(MDocType.getDocType(MDocType.DOCBASETYPE_APPayment));
            payment.setAmount(returnOrder.getC_Currency_ID(), returnOrder.getGrandTotal());
            payment.setDocAction(DocAction.ACTION_Complete);
            payment.setDocStatus(DocAction.STATUS_Drafted);
            payment.setIsPrepayment(true);
            payment.saveEx();
            payment.processIt(DocAction.ACTION_Complete);
            payment.saveEx();
            returnOrder.setC_POS_ID(getC_POS_ID());
            returnOrder.saveEx();
            processInfo.addLog(0, null, null, payment.getDocumentInfo());
        }
    }
    setIsToPrint(true);
    //	Default return
    return null;
}
Also used : MInOut(org.compiere.model.MInOut) MOrder(org.compiere.model.MOrder) MInOutLineConfirm(org.compiere.model.MInOutLineConfirm) MPayment(org.compiere.model.MPayment) ArrayList(java.util.ArrayList) ProcessInfo(org.compiere.process.ProcessInfo) MInOutConfirm(org.compiere.model.MInOutConfirm) Timestamp(java.sql.Timestamp)

Example 45 with ProcessInfo

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

the class PayrollViaEMail method CreatePDF.

//	sendIndividualMail
private File CreatePDF(int bPartnerId) {
    File attachment = null;
    int AD_Process_ID = reportProcessId;
    MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, bPartnerId);
    instance.saveEx();
    ProcessInfo pi = new ProcessInfo("PH_SendEmail", AD_Process_ID);
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    //	Add Parameter - Selection=Y
    MPInstancePara ip = new MPInstancePara(instance, 10);
    ip.setParameter(X_HR_Process.COLUMNNAME_HR_Process_ID, payrollProcessId);
    ip.saveEx();
    pi.setRecord_ID(bPartnerId);
    pi.setIsBatch(true);
    MProcess worker = new MProcess(getCtx(), AD_Process_ID, get_TrxName());
    worker.processIt(pi, Trx.get(get_TrxName(), true));
    attachment = pi.getPDFReport();
    return attachment;
}
Also used : MPInstancePara(org.compiere.model.MPInstancePara) MPInstance(org.compiere.model.MPInstance) MProcess(org.compiere.model.MProcess) ProcessInfo(org.compiere.process.ProcessInfo) File(java.io.File)

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