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());
}
}
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@";
}
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());
}
}
}
}
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;
}
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;
}
Aggregations