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