use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class TabCopy method doIt.
// prepare
/**
* Process
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("To AD_Tab_ID=" + p_AD_TabTo_ID + ", From=" + p_AD_TabFrom_ID);
MTab from = new MTab(getCtx(), p_AD_TabFrom_ID, get_TrxName());
if (from.get_ID() == 0)
throw new AdempiereUserError("@NotFound@ (from->) @AD_Tab_ID@");
MTab to = new MTab(getCtx(), p_AD_TabTo_ID, get_TrxName());
if (to.get_ID() == 0)
throw new AdempiereUserError("@NotFound@ (to<-) @AD_Tab_ID@");
if (from.getAD_Table_ID() != to.getAD_Table_ID())
throw new AdempiereUserError("@Error@ @AD_Table_ID@");
int count = 0;
MField[] oldFields = from.getFields(false, get_TrxName());
for (int i = 0; i < oldFields.length; i++) {
MField oldField = oldFields[i];
MField newField = new MField(to, oldField);
if (newField.save())
count++;
else
throw new AdempiereUserError("@Error@ @AD_Field_ID@");
}
return "@Copied@ #" + count;
}
use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class RequisitionPOCreate method doIt.
// prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
// Specific
if (p_M_Requisition_ID != 0) {
log.info("M_Requisition_ID=" + p_M_Requisition_ID);
MRequisition req = new MRequisition(getCtx(), p_M_Requisition_ID, get_TrxName());
if (!MRequisition.DOCSTATUS_Completed.equals(req.getDocStatus())) {
throw new AdempiereUserError("@DocStatus@ = " + req.getDocStatus());
}
MRequisitionLine[] lines = req.getLines();
for (int i = 0; i < lines.length; i++) {
if (lines[i].getC_OrderLine_ID() == 0) {
process(lines[i]);
}
}
closeOrder();
return "";
}
// single Requisition
//
log.info("AD_Org_ID=" + p_AD_Org_ID + ", M_Warehouse_ID=" + p_M_Warehouse_ID + ", DateDoc=" + p_DateDoc_From + "/" + p_DateDoc_To + ", DateRequired=" + p_DateRequired_From + "/" + p_DateRequired_To + ", PriorityRule=" + p_PriorityRule + ", AD_User_ID=" + p_AD_User_ID + ", M_Product_ID=" + p_M_Product_ID + ", ConsolidateDocument" + p_ConsolidateDocument);
ArrayList<Object> params = new ArrayList<Object>();
StringBuffer whereClause = new StringBuffer("C_OrderLine_ID IS NULL");
if (p_AD_Org_ID > 0) {
whereClause.append(" AND AD_Org_ID=?");
params.add(p_AD_Org_ID);
}
if (p_M_Product_ID > 0) {
whereClause.append(" AND M_Product_ID=?");
params.add(p_M_Product_ID);
} else if (p_M_Product_Category_ID > 0) {
whereClause.append(" AND EXISTS (SELECT 1 FROM M_Product p WHERE M_RequisitionLine.M_Product_ID=p.M_Product_ID").append(" AND p.M_Product_Category_ID=?)");
params.add(p_M_Product_Category_ID);
}
if (p_C_BP_Group_ID > 0) {
whereClause.append(" AND (").append("M_RequisitionLine.C_BPartner_ID IS NULL").append(" OR EXISTS (SELECT 1 FROM C_BPartner bp WHERE M_RequisitionLine.C_BPartner_ID=bp.C_BPartner_ID AND bp.C_BP_Group_ID=?)").append(")");
params.add(p_C_BP_Group_ID);
}
//
// Requisition Header
whereClause.append(" AND EXISTS (SELECT 1 FROM M_Requisition r WHERE M_RequisitionLine.M_Requisition_ID=r.M_Requisition_ID").append(" AND r.DocStatus=?");
params.add(MRequisition.DOCSTATUS_Completed);
if (p_M_Warehouse_ID > 0) {
whereClause.append(" AND r.M_Warehouse_ID=?");
params.add(p_M_Warehouse_ID);
}
if (p_DateDoc_From != null) {
whereClause.append(" AND r.DateDoc >= ?");
params.add(p_DateDoc_From);
}
if (p_DateDoc_To != null) {
whereClause.append(" AND r.DateDoc <= ?");
params.add(p_DateDoc_To);
}
if (p_DateRequired_From != null) {
whereClause.append(" AND r.DateRequired >= ?");
params.add(p_DateRequired_From);
}
if (p_DateRequired_To != null) {
whereClause.append(" AND r.DateRequired <= ?");
params.add(p_DateRequired_To);
}
if (p_PriorityRule != null) {
whereClause.append(" AND r.PriorityRule >= ?");
params.add(p_PriorityRule);
}
if (p_AD_User_ID > 0) {
whereClause.append(" AND r.AD_User_ID=?");
params.add(p_AD_User_ID);
}
// End Requisition Header
whereClause.append(")");
//
// ORDER BY clause
StringBuffer orderClause = new StringBuffer();
if (!p_ConsolidateDocument) {
orderClause.append("M_Requisition_ID, ");
}
orderClause.append("(SELECT DateRequired FROM M_Requisition r WHERE M_RequisitionLine.M_Requisition_ID=r.M_Requisition_ID),");
orderClause.append("M_Product_ID, C_Charge_ID, M_AttributeSetInstance_ID");
POResultSet<MRequisitionLine> rs = new Query(getCtx(), MRequisitionLine.Table_Name, whereClause.toString(), get_TrxName()).setParameters(params).setOrderBy(orderClause.toString()).setClient_ID().scroll();
try {
while (rs.hasNext()) {
process(rs.next());
}
} finally {
DB.close(rs);
rs = null;
}
closeOrder();
return "";
}
use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class RequestReOpen method doIt.
// prepare
/**
* Process It
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
MRequest request = new MRequest(getCtx(), p_R_Request_ID, get_TrxName());
log.info(request.toString());
if (request.get_ID() == 0)
throw new AdempiereUserError("@NotFound@ @R_Request_ID@ " + p_R_Request_ID);
// set default status
request.setR_Status_ID();
request.setProcessed(false);
if (request.save() && !request.isProcessed())
return "@OK@";
return "@Error@";
}
use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class BankTransfer method doIt.
// prepare
/**
* Perform process.
* @return Message (translated text)
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
log.info("From Bank=" + p_From_C_BankAccount_ID + " - To Bank=" + p_To_C_BankAccount_ID + " - C_BPartner_ID=" + p_C_BPartner_ID + "- C_Charge_ID= " + p_C_Charge_ID + " - Amount=" + p_Amount + " - DocumentNo=" + p_DocumentNo + " - Description=" + p_Description + " - Statement Date=" + p_StatementDate + " - Date Account=" + p_DateAcct);
if (p_To_C_BankAccount_ID == 0 || p_From_C_BankAccount_ID == 0)
throw new IllegalArgumentException("Banks required");
if (p_DocumentNo == null || p_DocumentNo.length() == 0)
throw new IllegalArgumentException("Document No required");
if (p_To_C_BankAccount_ID == p_From_C_BankAccount_ID)
throw new AdempiereUserError("Banks From and To must be different");
if (p_C_BPartner_ID == 0)
throw new AdempiereUserError("Business Partner required");
if (p_C_Currency_ID == 0)
throw new AdempiereUserError("Currency required");
if (p_C_Charge_ID == 0)
throw new AdempiereUserError("Business Partner required");
if (p_Amount.compareTo(new BigDecimal(0)) == 0)
throw new AdempiereUserError("Amount required");
// Login Date
if (p_StatementDate == null)
p_StatementDate = Env.getContextAsDate(getCtx(), "#Date");
if (p_StatementDate == null)
p_StatementDate = new Timestamp(System.currentTimeMillis());
if (p_DateAcct == null)
p_DateAcct = p_StatementDate;
generateBankTransfer();
return "@Created@ = " + m_created;
}
use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class CreatePeriods method doIt.
// prepare
/**
* Process
*
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
MPPPeriodDefinition definition = new MPPPeriodDefinition(getCtx(), p_M_PeriodDefinition_ID, get_TrxName());
if (p_M_PeriodDefinition_ID == 0 || definition.get_ID() != p_M_PeriodDefinition_ID)
throw new AdempiereUserError("@NotFound@: @M_PeriodDefinition_ID@ - " + p_M_PeriodDefinition_ID);
log.info(definition.toString());
//
if (definition.createPeriods(null, p_StartDate, p_DateFormat, p_NoPeriods))
return "@OK@";
return "@Error@";
}
Aggregations