use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class InventoryCountUpdate method doIt.
// prepare
/**
* Process
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("M_Inventory_ID=" + getRecord_ID());
MInventory inventory = new MInventory(getCtx(), getRecord_ID(), get_TrxName());
if (inventory.get_ID() == 0)
throw new AdempiereSystemError("Not found: M_Inventory_ID=" + getRecord_ID());
// Multiple Lines for one item
String sql = "UPDATE M_InventoryLine SET IsActive='N' " + "WHERE M_Inventory_ID=" + getRecord_ID() + " AND (M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID) IN " + "(SELECT M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID " + "FROM M_InventoryLine " + "WHERE M_Inventory_ID=" + getRecord_ID() + " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID " + "HAVING COUNT(*) > 1)";
int multiple = DB.executeUpdate(sql, get_TrxName());
log.info("Multiple=" + multiple);
int deleteInventoryMA = MInventoryLineMA.deleteInventoryMA(getRecord_ID(), get_TrxName());
log.info("DeletedMA=" + deleteInventoryMA);
// ASI
sql = "UPDATE M_InventoryLine l " + "SET (QtyBook,QtyCount) = " + "(SELECT QtyOnHand, " + (isUpdateCountQty() ? "s.QtyOnHand" : "l.QtyCount") + " FROM M_Storage s " + "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID" + " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)," + " Updated=SysDate," + " UpdatedBy=" + getAD_User_ID() + //
" WHERE M_Inventory_ID=" + getRecord_ID() + " AND EXISTS (SELECT * FROM M_Storage s " + "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID" + " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)";
int no = DB.executeUpdate(sql, get_TrxName());
log.info("Update with ASI=" + no);
// No ASI
int noMA = updateWithMA();
// Set Count to Zero
if (isUpdateCountQty() && "Z".equals(getSetInventoryCountto())) {
sql = "UPDATE M_InventoryLine l " + "SET QtyCount=0 " + "WHERE M_Inventory_ID=" + getRecord_ID();
no = DB.executeUpdate(sql, get_TrxName());
log.info("Set Count to Zero=" + no);
}
if (multiple > 0)
return "@M_InventoryLine_ID@ - #" + (no + noMA) + " --> @InventoryProductMultiple@";
return "@M_InventoryLine_ID@ - #" + no;
}
use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class ReplenishReport method doIt.
// prepare
/**
* Perform process.
* @return Message
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
log.info("M_Warehouse_ID=" + p_M_Warehouse_ID + ", C_BPartner_ID=" + p_C_BPartner_ID + " - ReplenishmentCreate=" + p_ReplenishmentCreate + ", C_DocType_ID=" + p_C_DocType_ID);
if (p_ReplenishmentCreate != null && p_C_DocType_ID == 0)
throw new AdempiereUserError("@FillMandatory@ @C_DocType_ID@");
MWarehouse wh = MWarehouse.get(getCtx(), p_M_Warehouse_ID);
if (wh.get_ID() == 0)
throw new AdempiereSystemError("@FillMandatory@ @M_Warehouse_ID@");
//
prepareTable();
fillTable(wh);
//
if (p_ReplenishmentCreate == null)
return "OK";
//
MDocType dt = MDocType.get(getCtx(), p_C_DocType_ID);
if (!dt.getDocBaseType().equals(p_ReplenishmentCreate))
throw new AdempiereSystemError("@C_DocType_ID@=" + dt.getName() + " <> " + p_ReplenishmentCreate);
//
if (p_ReplenishmentCreate.equals("POO"))
createPO();
else if (p_ReplenishmentCreate.equals("POR"))
createRequisition();
else if (p_ReplenishmentCreate.equals("MMM"))
createMovements();
else if (p_ReplenishmentCreate.equals("DOO"))
createDO();
return m_info;
}
use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class WorkflowMoveToClient method doIt.
// prepare
/**
* Process
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("doIt - AD_Client_ID=" + p_AD_Client_ID + ", AD_Workflow_ID=" + p_AD_Workflow_ID);
int changes = 0;
// WF
String sql = "UPDATE AD_Workflow SET AD_Client_ID=" + p_AD_Client_ID + " WHERE AD_Client_ID=0 AND EntityType NOT IN ('D','C')" + " AND AD_Workflow_ID=" + p_AD_Workflow_ID;
int no = DB.executeUpdate(sql, get_TrxName());
if (no == -1)
throw new AdempiereSystemError("Error updating Workflow");
changes += no;
// Node
sql = "UPDATE AD_WF_Node SET AD_Client_ID=" + p_AD_Client_ID + " WHERE AD_Client_ID=0 AND EntityType NOT IN ('D','C')" + " AND AD_Workflow_ID=" + p_AD_Workflow_ID;
no = DB.executeUpdate(sql, get_TrxName());
if (no == -1)
throw new AdempiereSystemError("Error updating Workflow Node");
changes += no;
// Node Next
sql = "UPDATE AD_WF_NodeNext SET AD_Client_ID=" + p_AD_Client_ID + " WHERE AD_Client_ID=0 AND EntityType NOT IN ('D','C')" + " AND (AD_WF_Node_ID IN (SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID=" + p_AD_Workflow_ID + ") OR AD_WF_Next_ID IN (SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID=" + p_AD_Workflow_ID + "))";
no = DB.executeUpdate(sql, get_TrxName());
if (no == -1)
throw new AdempiereSystemError("Error updating Workflow Transition");
changes += no;
// Node Parameters
sql = "UPDATE AD_WF_Node_Para SET AD_Client_ID=" + p_AD_Client_ID + " WHERE AD_Client_ID=0 AND EntityType NOT IN ('D','C')" + " AND AD_WF_Node_ID IN (SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID=" + p_AD_Workflow_ID + ")";
no = DB.executeUpdate(sql, get_TrxName());
if (no == -1)
throw new AdempiereSystemError("Error updating Workflow Node Parameters");
changes += no;
// Node Next Condition
sql = "UPDATE AD_WF_NextCondition SET AD_Client_ID=" + p_AD_Client_ID + " WHERE AD_Client_ID=0 AND EntityType NOT IN ('D','C')" + " AND AD_WF_NodeNext_ID IN (" + "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext " + "WHERE AD_WF_Node_ID IN (SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID=" + p_AD_Workflow_ID + ") OR AD_WF_Next_ID IN (SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID=" + p_AD_Workflow_ID + "))";
no = DB.executeUpdate(sql, get_TrxName());
if (no == -1)
throw new AdempiereSystemError("Error updating Workflow Transition Condition");
changes += no;
return "@Updated@ - #" + changes;
}
use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class UpdateQuantityCount method doIt.
// prepare
/**
* Process
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("M_Inventory_ID=" + p_M_Inventory_ID);
m_inventory = new MInventory(getCtx(), p_M_Inventory_ID, get_TrxName());
if (m_inventory.get_ID() == 0)
throw new AdempiereSystemError("Not found: M_Inventory_ID=" + p_M_Inventory_ID);
if (m_inventory.isProcessed())
throw new AdempiereSystemError("@M_Inventory_ID@ @Processed@");
// Update Quantity Count
String sql1 = "UPDATE M_InventoryLine l " + "SET QtyCount=COALESCE(SecondCountQty,FirstCountQty) + PickedQty " + "WHERE M_Inventory_ID=" + p_M_Inventory_ID;
int no = DB.executeUpdate(sql1, get_TrxName());
log.info("Update Quantity Count #" + no);
//
return "@M_Inventory_ID@ - #" + no;
}
use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class TabCreateFields method doIt.
// prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
MTab tab = new MTab(getCtx(), p_AD_Tab_ID, get_TrxName());
if (p_AD_Tab_ID == 0 || tab == null || tab.get_ID() == 0)
throw new AdempiereSystemError("@NotFound@: @AD_Tab_ID@ " + p_AD_Tab_ID);
log.info(tab.toString());
//
int count = 0;
String sql = "SELECT * FROM AD_Column c " + "WHERE NOT EXISTS (SELECT * FROM AD_Field f " + "WHERE c.AD_Column_ID=f.AD_Column_ID" + // #1
" AND c.AD_Table_ID=?" + // #2
" AND f.AD_Tab_ID=?)" + // #3
" AND AD_Table_ID=?" + " AND NOT (Name LIKE 'Created%' OR Name LIKE 'Updated%')" + " AND IsActive='Y' " + "ORDER BY Name";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, tab.getAD_Table_ID());
pstmt.setInt(2, tab.getAD_Tab_ID());
pstmt.setInt(3, tab.getAD_Table_ID());
rs = pstmt.executeQuery();
while (rs.next()) {
MColumn column = new MColumn(getCtx(), rs, get_TrxName());
//
MField field = new MField(tab);
field.setColumn(column);
if ("D".equals(column.getEntityType()))
field.setEntityType(tab.getEntityType());
else
field.setEntityType(column.getEntityType());
if (column.isKey())
field.setIsDisplayed(false);
if (field.save()) {
addLog(0, null, null, column.getName());
count++;
}
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return "@Created@ #" + count;
}
Aggregations