Search in sources :

Example 46 with AdempiereUserError

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);
}
Also used : MPaymentTerm(org.compiere.model.MPaymentTerm) AdempiereUserError(org.compiere.util.AdempiereUserError)

Example 47 with AdempiereUserError

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@";
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError) MPeriodControl(org.compiere.model.MPeriodControl)

Example 48 with AdempiereUserError

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;
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError) MPeriod(org.compiere.model.MPeriod)

Example 49 with AdempiereUserError

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@";
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError)

Example 50 with AdempiereUserError

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@";
}
Also used : MAcctSchema(org.compiere.model.MAcctSchema) AdempiereUserError(org.compiere.util.AdempiereUserError) AdempiereSystemError(org.compiere.util.AdempiereSystemError) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

Aggregations

AdempiereUserError (org.compiere.util.AdempiereUserError)62 PreparedStatement (java.sql.PreparedStatement)9 BigDecimal (java.math.BigDecimal)8 Timestamp (java.sql.Timestamp)8 AdempiereSystemError (org.compiere.util.AdempiereSystemError)8 ResultSet (java.sql.ResultSet)7 MBPartner (org.compiere.model.MBPartner)7 MClient (org.compiere.model.MClient)5 MWarehouse (org.compiere.model.MWarehouse)5 MProduct (org.compiere.model.MProduct)4 ValueNamePair (org.compiere.util.ValueNamePair)4 MUser (org.compiere.model.MUser)3 X_T_Replenish (org.compiere.model.X_T_Replenish)3 MPrintFormat (org.compiere.print.MPrintFormat)3 File (java.io.File)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 MAcctSchema (org.compiere.model.MAcctSchema)2 MBPartnerLocation (org.compiere.model.MBPartnerLocation)2 MColumn (org.compiere.model.MColumn)2 MCommission (org.compiere.model.MCommission)2