use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class PaymentTermValidate method doIt.
// prepare
/**
* Perform process.
* @return Message
* @throws Exception if not successful
*/
@Override
protected String doIt() throws Exception {
log.info("C_PaymentTerm_ID=" + getRecord_ID());
MPaymentTerm pt = new MPaymentTerm(getCtx(), getRecord_ID(), get_TrxName());
String msg = pt.validate();
pt.saveEx();
//
String validMsg = Msg.parseTranslation(getCtx(), "@OK@");
if (validMsg.equals(msg))
return msg;
throw new AdempiereUserError(msg);
}
use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class PeriodControlStatus method doIt.
// prepare
/**
* Process
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("C_PeriodControl_ID=" + p_C_PeriodControl_ID);
MPeriodControl pc = new MPeriodControl(getCtx(), p_C_PeriodControl_ID, get_TrxName());
if (pc.get_ID() == 0)
throw new AdempiereUserError("@NotFound@ @C_PeriodControl_ID@=" + p_C_PeriodControl_ID);
// Permanently closed
if (MPeriodControl.PERIODACTION_PermanentlyClosePeriod.equals(pc.getPeriodStatus()))
throw new AdempiereUserError("@PeriodStatus@ = " + pc.getPeriodStatus());
// No Action
if (MPeriodControl.PERIODACTION_NoAction.equals(pc.getPeriodAction()))
return "@OK@";
// Open
if (MPeriodControl.PERIODACTION_OpenPeriod.equals(pc.getPeriodAction()))
pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_Open);
// Close
if (MPeriodControl.PERIODACTION_ClosePeriod.equals(pc.getPeriodAction()))
pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_Closed);
// Close Permanently
if (MPeriodControl.PERIODACTION_PermanentlyClosePeriod.equals(pc.getPeriodAction()))
pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_PermanentlyClosed);
pc.setPeriodAction(MPeriodControl.PERIODACTION_NoAction);
//
boolean ok = pc.save();
// Reset Cache
CacheMgt.get().reset("C_PeriodControl", 0);
CacheMgt.get().reset("C_Period", pc.getC_Period_ID());
if (!ok)
return "@Error@";
return "@OK@";
}
use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class PeriodStatus method doIt.
// prepare
/**
* Process
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("C_Period_ID=" + p_C_Period_ID + ", PeriodAction=" + p_PeriodAction);
MPeriod period = new MPeriod(getCtx(), p_C_Period_ID, get_TrxName());
if (period.get_ID() == 0)
throw new AdempiereUserError("@NotFound@ @C_Period_ID@=" + p_C_Period_ID);
StringBuffer sql = new StringBuffer("UPDATE C_PeriodControl ");
sql.append("SET PeriodStatus='");
// Open
if (MPeriodControl.PERIODACTION_OpenPeriod.equals(p_PeriodAction))
sql.append(MPeriodControl.PERIODSTATUS_Open);
else // Close
if (MPeriodControl.PERIODACTION_ClosePeriod.equals(p_PeriodAction))
sql.append(MPeriodControl.PERIODSTATUS_Closed);
else // Close Permanently
if (MPeriodControl.PERIODACTION_PermanentlyClosePeriod.equals(p_PeriodAction))
sql.append(MPeriodControl.PERIODSTATUS_PermanentlyClosed);
else
return "-";
//
sql.append("', PeriodAction='N', Updated=SysDate,UpdatedBy=").append(getAD_User_ID());
// WHERE
sql.append(" WHERE C_Period_ID=").append(period.getC_Period_ID()).append(" AND PeriodStatus<>'P'").append(" AND PeriodStatus<>'").append(p_PeriodAction).append("'");
int no = DB.executeUpdate(sql.toString(), get_TrxName());
CacheMgt.get().reset("C_PeriodControl", 0);
CacheMgt.get().reset("C_Period", p_C_Period_ID);
return "@Updated@ #" + no;
}
use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class WorkflowValidate method doIt.
// prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
MWorkflow wf = MWorkflow.get(getCtx(), p_AD_Worlflow_ID);
log.info("WF=" + wf);
String msg = wf.validate();
wf.saveEx();
if (msg.length() > 0)
throw new AdempiereUserError(Msg.getMsg(getCtx(), "WorflowNotValid") + " - " + msg);
return wf.isValid() ? "@OK@" : "@Error@";
}
use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.
the class AcctSchemaCopyAcct method doIt.
// prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("SourceAcctSchema_ID=" + p_SourceAcctSchema_ID + ", TargetAcctSchema_ID=" + p_TargetAcctSchema_ID);
if (p_SourceAcctSchema_ID == 0 || p_TargetAcctSchema_ID == 0)
throw new AdempiereSystemError("ID=0");
if (p_SourceAcctSchema_ID == p_TargetAcctSchema_ID)
throw new AdempiereUserError("Must be different");
MAcctSchema source = MAcctSchema.get(getCtx(), p_SourceAcctSchema_ID, null);
if (source.get_ID() == 0)
throw new AdempiereSystemError("NotFound Source C_AcctSchema_ID=" + p_SourceAcctSchema_ID);
MAcctSchema target = new MAcctSchema(getCtx(), p_TargetAcctSchema_ID, get_TrxName());
if (target.get_ID() == 0)
throw new AdempiereSystemError("NotFound Target C_AcctSchema_ID=" + p_TargetAcctSchema_ID);
//
MAcctSchemaElement[] targetElements = target.getAcctSchemaElements();
if (targetElements.length == 0)
throw new AdempiereUserError("NotFound Target C_AcctSchema_Element");
// Accounting Element must be the same
MAcctSchemaElement sourceAcctElement = source.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_Account);
if (sourceAcctElement == null)
throw new AdempiereUserError("NotFound Source AC C_AcctSchema_Element");
MAcctSchemaElement targetAcctElement = target.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_Account);
if (targetAcctElement == null)
throw new AdempiereUserError("NotFound Target AC C_AcctSchema_Element");
if (sourceAcctElement.getC_Element_ID() != targetAcctElement.getC_Element_ID())
throw new AdempiereUserError("@C_Element_ID@ different");
if (MAcctSchemaGL.get(getCtx(), p_TargetAcctSchema_ID) == null)
copyGL(target);
if (MAcctSchemaDefault.get(getCtx(), p_TargetAcctSchema_ID) == null)
copyDefault(target);
return "@OK@";
}
Aggregations