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";
}
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@";
}
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;
}
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);
}
}
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);
}
Aggregations