Search in sources :

Example 61 with AdempiereUserError

use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.

the class MovementGenerate method doIt.

//	prepare
/**
	 * 	Generate Movements
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("Selection=" + p_Selection + ", M_Warehouse_ID=" + p_M_Warehouse_ID + ", C_BPartner_ID=" + p_C_BPartner_ID + ", Consolidate=" + p_ConsolidateDocument + ", IsUnconfirmed=" + p_IsUnconfirmedInOut + ", Movement=" + m_movementDate);
    if (p_M_Warehouse_ID == 0)
        throw new AdempiereUserError("@NotFound@ @M_Warehouse_ID@");
    if (p_Selection) {
        m_sql = "SELECT DD_Order.* FROM DD_Order, T_Selection " + "WHERE DD_Order.DocStatus='CO' AND DD_Order.AD_Client_ID=? " + "AND DD_Order.DD_Order_ID = T_Selection.T_Selection_ID " + "AND T_Selection.AD_PInstance_ID=? ";
    } else {
        m_sql = "SELECT * FROM DD_Order o " + "WHERE DocStatus='CO' " + //	No Offer,POS
        " AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType " + "WHERE DocBaseType='DOO')" + "	AND o.IsDropShip='N'" + //	No Manual
        " AND o.DeliveryRule<>'M'" + //	Open Order Lines with Warehouse
        " AND EXISTS (SELECT 1 FROM DD_OrderLine ol " + " WHERE ? IN (SELECT l.M_Warehouse_ID FROM M_Locator l WHERE l.M_Locator_ID=ol.M_Locator_ID) ";
        if (p_DatePromised != null)
            //	#2
            m_sql += " AND TRUNC(ol.DatePromised)<=?";
        m_sql += " AND o.DD_Order_ID=ol.DD_Order_ID AND ol.QtyOrdered<>ol.QtyIntransit)";
        //
        if (p_C_BPartner_ID != 0)
            //	#3
            m_sql += " AND o.C_BPartner_ID=?";
        m_sql += " ORDER BY M_Warehouse_ID, PriorityRule, M_Shipper_ID, C_BPartner_ID, C_BPartner_Location_ID, DD_Order_ID";
    }
    //	m_sql += " FOR UPDATE";
    PreparedStatement pstmt = null;
    try {
        pstmt = DB.prepareStatement(m_sql, get_TrxName());
        int index = 1;
        if (p_Selection) {
            pstmt.setInt(index++, Env.getAD_Client_ID(getCtx()));
            pstmt.setInt(index++, getAD_PInstance_ID());
        } else {
            pstmt.setInt(index++, p_M_Warehouse_ID);
            if (p_DatePromised != null)
                pstmt.setTimestamp(index++, p_DatePromised);
            if (p_C_BPartner_ID != 0)
                pstmt.setInt(index++, p_C_BPartner_ID);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, m_sql, e);
    }
    return generate(pstmt);
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError) PreparedStatement(java.sql.PreparedStatement) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 62 with AdempiereUserError

use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.

the class PP_Product_BOM_Check method raiseError.

// doIt
private void raiseError(String string, String hint) throws Exception {
    DB.rollback(false, get_TrxName());
    // parent
    MProduct xp = new MProduct(getCtx(), p_Record_ID, null);
    // set BOM not verified
    xp.setIsVerified(false);
    xp.saveEx();
    String msg = string;
    ValueNamePair pp = CLogger.retrieveError();
    if (pp != null)
        msg = pp.getName() + " - ";
    msg += hint;
    throw new AdempiereUserError(msg);
}
Also used : MProduct(org.compiere.model.MProduct) AdempiereUserError(org.compiere.util.AdempiereUserError) ValueNamePair(org.compiere.util.ValueNamePair)

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