private boolean createOrder(WebUser wu,WebBasket wb){
  m_order=new MOrder(m_ctx,0,null);
  log.fine("AD_Client_ID=" + m_order.getAD_Client_ID() + ",AD_Org_ID="+ m_order.getAD_Org_ID()+ " - "+ m_order);
  m_order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Prepay);
  m_order.setPaymentRule(MOrder.PAYMENTRULE_CreditCard);
  m_order.setDeliveryRule(MOrder.DELIVERYRULE_AfterReceipt);
  m_order.setInvoiceRule(MOrder.INVOICERULE_Immediate);
  m_order.setIsSelfService(true);
  if (wb.getM_PriceList_ID() > 0)   m_order.setM_PriceList_ID(wb.getM_PriceList_ID());
  if (wb.getSalesRep_ID() != 0)   m_order.setSalesRep_ID(wb.getSalesRep_ID());
  m_order.setC_BPartner_ID(wu.getC_BPartner_ID());
  m_order.setC_BPartner_Location_ID(wu.getC_BPartner_Location_ID());
  m_order.setAD_User_ID(wu.getAD_User_ID());
  m_order.setSendEMail(true);
  m_order.setDocAction(MOrder.DOCACTION_Prepare);
  m_order.saveEx();
  log.fine("ID=" + m_order.getC_Order_ID() + ", DocNo="+ m_order.getDocumentNo());
  ArrayList<WebBasketLine> lines=wb.getLines();
  for (int i=0; i < lines.size(); i++) {
    WebBasketLine wbl=lines.get(i);
    MOrderLine ol=new MOrderLine(m_order);
    ol.setM_Product_ID(wbl.getM_Product_ID(),true);
    ol.setQty(wbl.getQuantity());
    ol.setPrice();
    ol.setPrice(wbl.getPrice());
    ol.setTax();
    ol.saveEx();
  }
  boolean ok=m_order.processIt(MOrder.DOCACTION_Prepare);
  m_order.saveEx();
  if (!wu.isCustomer()) {
    wu.setIsCustomer(true);
    wu.save();
  }
  BigDecimal amt=m_order.getGrandTotal();
  log.info("Amt=" + amt);
  return ok;
}

private boolean createOrder ( WebUser wu , WebBasket wb ) { m_order = new MOrder ( m_ctx , 0 , null ) ; log . fine ( "AD_Client_ID=" + m_order . getAD_Client_ID ( ) + ",AD_Org_ID=" + m_order . getAD_Org_ID ( ) + " - " + m_order ) ; m_order . setC_DocTypeTarget_ID ( MOrder . DocSubTypeSO_Prepay ) ; m_order . setPaymentRule ( MOrder . PAYMENTRULE_CreditCard ) ; m_order . setDeliveryRule ( MOrder . DELIVERYRULE_AfterReceipt ) ; m_order . setInvoiceRule ( MOrder . INVOICERULE_Immediate ) ; m_order . setIsSelfService ( true ) ; if ( wb . getM_PriceList_ID ( ) > 0 ) m_order . setM_PriceList_ID ( wb . getM_PriceList_ID ( ) ) ; if ( wb . getSalesRep_ID ( ) != 0 ) m_order . setSalesRep_ID ( wb . getSalesRep_ID ( ) ) ; m_order . setC_BPartner_ID ( wu . getC_BPartner_ID ( ) ) ; m_order . setC_BPartner_Location_ID ( wu . getC_BPartner_Location_ID ( ) ) ; m_order . setAD_User_ID ( wu . getAD_User_ID ( ) ) ; m_order . setSendEMail ( true ) ; m_order . setDocAction ( MOrder . DOCACTION_Prepare ) ; m_order . saveEx ( ) ; log . fine ( "ID=" + m_order . getC_Order_ID ( ) + ", DocNo=" + m_order . getDocumentNo ( ) ) ; ArrayList < WebBasketLine > lines = wb . getLines ( ) ; for ( int i = 0 ; i < lines . size ( ) ; i ++ ) { WebBasketLine wbl = lines . get ( i ) ; MOrderLine ol = new MOrderLine ( m_order ) ; ol . setM_Product_ID ( wbl . getM_Product_ID ( ) , true ) ; ol . setQty ( wbl . getQuantity ( ) ) ; ol . setPrice ( ) ; ol . setPrice ( wbl . getPrice ( ) ) ; ol . setTax ( ) ; ol . saveEx ( ) ; } boolean ok = m_order . processIt ( MOrder . DOCACTION_Prepare ) ; m_order . saveEx ( ) ; if ( ! wu . isCustomer ( ) ) { wu . setIsCustomer ( true ) ; wu . save ( ) ; } BigDecimal amt = m_order . getGrandTotal ( ) ; log . info ( "Amt=" + amt ) ; return ok ; }
create order from basket
