Search in sources :

Example 1 with MRfQTopic

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

the class RfQCreate method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message (translated text)
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    MRfQ rfq = new MRfQ(getCtx(), p_C_RfQ_ID, get_TrxName());
    log.info("doIt - " + rfq + ", Send=" + p_IsSendRfQ);
    String error = rfq.checkQuoteTotalAmtOnly();
    if (error != null && error.length() > 0)
        throw new Exception(error);
    int counter = 0;
    int sent = 0;
    int notSent = 0;
    //	Get all existing responses
    MRfQResponse[] responses = rfq.getResponses(false, false);
    //	Topic
    MRfQTopic topic = new MRfQTopic(getCtx(), rfq.getC_RfQ_Topic_ID(), get_TrxName());
    MRfQTopicSubscriber[] subscribers = topic.getSubscribers();
    for (int i = 0; i < subscribers.length; i++) {
        MRfQTopicSubscriber subscriber = subscribers[i];
        boolean skip = false;
        //	existing response
        for (int r = 0; r < responses.length; r++) {
            if (subscriber.getC_BPartner_ID() == responses[r].getC_BPartner_ID() && subscriber.getC_BPartner_Location_ID() == responses[r].getC_BPartner_Location_ID()) {
                skip = true;
                break;
            }
        }
        if (skip)
            continue;
        //	Create Response
        MRfQResponse response = new MRfQResponse(rfq, subscriber);
        if (//	no lines
        response.get_ID() == 0)
            continue;
        counter++;
        if (p_IsSendRfQ) {
            commitEx();
            if (response.sendRfQ())
                sent++;
            else
                notSent++;
        }
    }
    //	for all subscribers
    String retValue = "@Created@ " + counter;
    if (p_IsSendRfQ)
        retValue += " - @IsSendRfQ@=" + sent + " - @Error@=" + notSent;
    return retValue;
}
Also used : MRfQTopicSubscriber(org.compiere.model.MRfQTopicSubscriber) MRfQTopic(org.compiere.model.MRfQTopic) MRfQ(org.compiere.model.MRfQ) MRfQResponse(org.compiere.model.MRfQResponse)

Aggregations

MRfQ (org.compiere.model.MRfQ)1 MRfQResponse (org.compiere.model.MRfQResponse)1 MRfQTopic (org.compiere.model.MRfQTopic)1 MRfQTopicSubscriber (org.compiere.model.MRfQTopicSubscriber)1