Search in sources :

Example 6 with MRfQResponse

use of org.compiere.model.MRfQResponse in project adempiere by adempiere.

the class RfQResponseCComplete method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    MRfQResponse response = new MRfQResponse(getCtx(), p_C_RfQResponse_ID, get_TrxName());
    log.info("doIt - " + response);
    //
    String error = response.checkComplete();
    if (error != null && error.length() > 0)
        throw new Exception(error);
    //
    response.saveEx();
    return "OK";
}
Also used : MRfQResponse(org.compiere.model.MRfQResponse)

Example 7 with MRfQResponse

use of org.compiere.model.MRfQResponse in project adempiere by adempiere.

the class RfQResponseInvite method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    MRfQResponse response = new MRfQResponse(getCtx(), p_C_RfQResponse_ID, get_TrxName());
    log.info("doIt - " + response);
    String error = response.getRfQ().checkQuoteTotalAmtOnly();
    if (error != null && error.length() > 0)
        throw new Exception(error);
    //	Send it
    if (response.sendRfQ())
        return "OK";
    //
    return "@Error@";
}
Also used : MRfQResponse(org.compiere.model.MRfQResponse)

Example 8 with MRfQResponse

use of org.compiere.model.MRfQResponse in project adempiere by adempiere.

the class RfQResponseRank method doIt.

//	prepare
/**
	 * 	Process.
	 * 	<pre>
	 * 	- ignore 0 or invalid responses
	 * 	- rank among qty
	 * 	- for selected PO qty select winner
	 * 	- if all lines are winner - select that
	 *  </pre> 
	 *	@return message
	 */
protected String doIt() throws Exception {
    MRfQ rfq = new MRfQ(getCtx(), p_C_RfQ_ID, get_TrxName());
    if (rfq.get_ID() == 0)
        throw new IllegalArgumentException("No RfQ found");
    log.info(rfq.toString());
    String error = rfq.checkQuoteTotalAmtOnly();
    if (error != null && error.length() > 0)
        throw new Exception(error);
    //	Get Completed, Active Responses
    MRfQResponse[] responses = rfq.getResponses(true, true);
    log.fine("doIt - #Responses=" + responses.length);
    if (responses.length == 0)
        throw new IllegalArgumentException("No completed RfQ Responses found");
    if (responses.length == 1) {
        responses[0].setIsSelectedWinner(true);
        responses[0].saveEx();
        return "Only one completed RfQ Response found";
    }
    //	Rank
    if (rfq.isQuoteTotalAmtOnly())
        rankResponses(rfq, responses);
    else
        rankLines(rfq, responses);
    return "# " + responses.length;
}
Also used : MRfQ(org.compiere.model.MRfQ) MRfQResponse(org.compiere.model.MRfQResponse)

Example 9 with MRfQResponse

use of org.compiere.model.MRfQResponse in project adempiere by adempiere.

the class RfQResponseRank method rankResponses.

//	rankLines
/**************************************************************************
	 * 	Rank Response based on Header
	 *	@param rfq RfQ
	 *	@param responses responses
	 */
private void rankResponses(MRfQ rfq, MRfQResponse[] responses) {
    int ranking = 1;
    //	Responses Ordered by Price
    for (int ii = 0; ii < responses.length; ii++) {
        MRfQResponse response = responses[ii];
        if (response.getPrice() != null && response.getPrice().compareTo(Env.ZERO) > 0) {
            if (response.isSelectedWinner() != (ranking == 1))
                response.setIsSelectedWinner(ranking == 1);
            response.setRanking(ranking);
            //
            ranking++;
        } else {
            response.setRanking(999);
            if (response.isSelectedWinner())
                response.setIsSelectedWinner(false);
        }
        response.saveEx();
        log.fine("rankResponse - " + response);
    }
}
Also used : MRfQResponse(org.compiere.model.MRfQResponse)

Example 10 with MRfQResponse

use of org.compiere.model.MRfQResponse in project adempiere by adempiere.

the class RfQServlet method doPost.

//	streamAttachment
/**************************************************************************
	 *  Process the HTTP Post request
	 *
	 *  @param request request
	 *  @param response response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.info("From " + request.getRemoteHost() + " - " + request.getRemoteAddr());
    //	Log.setTraceLevel(9);
    //	WebEnv.dump(request);
    //	WebEnv.dump(request.getSession());
    //  Get Session attributes
    HttpSession session = request.getSession(true);
    session.removeAttribute(WebSessionCtx.HDR_MESSAGE);
    //
    Properties ctx = JSPEnv.getCtx(request);
    WebUser wu = (WebUser) session.getAttribute(WebUser.NAME);
    if (wu == null) {
        log.warning("doPost - no web user");
        if (!response.isCommitted())
            //	entry
            response.sendRedirect("loginServlet?ForwardTo=note.jsp");
        return;
    }
    int C_RfQResponse_ID = WebUtil.getParameterAsInt(request, P_RfQResponse_ID);
    int C_RfQ_ID = WebUtil.getParameterAsInt(request, "C_RfQ_ID");
    MRfQResponse rfqResponse = new MRfQResponse(ctx, C_RfQResponse_ID, null);
    if (C_RfQResponse_ID == 0 || rfqResponse == null || rfqResponse.get_ID() != C_RfQResponse_ID) {
        WebUtil.createForwardPage(response, "RfQ Response not found", "rfqs.jsp", 5);
        return;
    }
    if (wu.getC_BPartner_ID() != rfqResponse.getC_BPartner_ID()) {
        WebUtil.createForwardPage(response, "Your RfQ Response not found", "rfqs.jsp", 5);
        return;
    }
    //	Update Data
    String msg = updateResponse(request, rfqResponse);
    session.setAttribute(WebSessionCtx.HDR_MESSAGE, msg);
    String url = "/rfqDetails.jsp?C_RfQ_ID=" + C_RfQ_ID;
    //
    log.info("doGet - Forward to " + url);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(request, response);
}
Also used : HttpSession(javax.servlet.http.HttpSession) MRfQResponse(org.compiere.model.MRfQResponse) WebUser(org.compiere.util.WebUser) Properties(java.util.Properties) RequestDispatcher(javax.servlet.RequestDispatcher)

Aggregations

MRfQResponse (org.compiere.model.MRfQResponse)10 MRfQ (org.compiere.model.MRfQ)5 BigDecimal (java.math.BigDecimal)2 MBPartner (org.compiere.model.MBPartner)2 MRfQResponseLine (org.compiere.model.MRfQResponseLine)2 MRfQResponseLineQty (org.compiere.model.MRfQResponseLineQty)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Properties (java.util.Properties)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 HttpSession (javax.servlet.http.HttpSession)1 MOrder (org.compiere.model.MOrder)1 MOrderLine (org.compiere.model.MOrderLine)1 MRfQLine (org.compiere.model.MRfQLine)1 MRfQLineQty (org.compiere.model.MRfQLineQty)1 MRfQTopic (org.compiere.model.MRfQTopic)1 MRfQTopicSubscriber (org.compiere.model.MRfQTopicSubscriber)1 WebUser (org.compiere.util.WebUser)1