protected String doIt() throws Exception {
  log.info("Selection=" + p_Selection + ", DateInvoiced="+ p_DateInvoiced+ ", AD_Org_ID="+ p_AD_Org_ID+ ", C_BPartner_ID="+ p_C_BPartner_ID+ ", M_InOut_ID="+ p_M_InOut_ID+ ", DocAction="+ p_docAction+ ", Consolidate="+ p_ConsolidateDocument);
  String sql=null;
  if (p_Selection) {
    sql="SELECT M_InOut.* FROM M_InOut, T_Selection " + "WHERE M_InOut.DocStatus='CO' AND M_InOut.IsSOTrx='Y' " + " AND M_InOut.M_InOut_ID = T_Selection.T_Selection_ID "+ " AND T_Selection.AD_PInstance_ID=? "+ "ORDER BY M_InOut.M_InOut_ID";
  }
 else {
    sql="SELECT * FROM M_InOut o " + "WHERE DocStatus IN('CO','CL') AND IsSOTrx='Y'";
    if (p_AD_Org_ID != 0)     sql+=" AND AD_Org_ID=?";
    if (p_C_BPartner_ID != 0)     sql+=" AND C_BPartner_ID=?";
    if (p_M_InOut_ID != 0)     sql+=" AND M_InOut_ID=?";
    sql+=" AND EXISTS (SELECT * FROM M_InOutLine ol " + "WHERE o.M_InOut_ID=ol.M_InOut_ID AND ol.IsInvoiced='N') " + "ORDER BY M_InOut_ID";
  }
  PreparedStatement pstmt=null;
  try {
    pstmt=DB.prepareStatement(sql,get_TrxName());
    int index=1;
    if (p_Selection) {
      pstmt.setInt(index,getAD_PInstance_ID());
    }
 else {
      if (p_AD_Org_ID != 0)       pstmt.setInt(index++,p_AD_Org_ID);
      if (p_C_BPartner_ID != 0)       pstmt.setInt(index++,p_C_BPartner_ID);
      if (p_M_InOut_ID != 0)       pstmt.setInt(index++,p_M_InOut_ID);
    }
  }
 catch (  Exception e) {
    log.log(Level.SEVERE,sql,e);
  }
  return generate(pstmt);
}

protected String doIt ( ) throws Exception { log . info ( "Selection=" + p_Selection + ", DateInvoiced=" + p_DateInvoiced + ", AD_Org_ID=" + p_AD_Org_ID + ", C_BPartner_ID=" + p_C_BPartner_ID + ", M_InOut_ID=" + p_M_InOut_ID + ", DocAction=" + p_docAction + ", Consolidate=" + p_ConsolidateDocument ) ; String sql = null ; if ( p_Selection ) { sql = "SELECT M_InOut.* FROM M_InOut, T_Selection " + "WHERE M_InOut.DocStatus='CO' AND M_InOut.IsSOTrx='Y' " + " AND M_InOut.M_InOut_ID = T_Selection.T_Selection_ID " + " AND T_Selection.AD_PInstance_ID=? " + "ORDER BY M_InOut.M_InOut_ID" ; } else { sql = "SELECT * FROM M_InOut o " + "WHERE DocStatus IN('CO','CL') AND IsSOTrx='Y'" ; if ( p_AD_Org_ID != 0 ) sql += " AND AD_Org_ID=?" ; if ( p_C_BPartner_ID != 0 ) sql += " AND C_BPartner_ID=?" ; if ( p_M_InOut_ID != 0 ) sql += " AND M_InOut_ID=?" ; sql += " AND EXISTS (SELECT * FROM M_InOutLine ol " + "WHERE o.M_InOut_ID=ol.M_InOut_ID AND ol.IsInvoiced='N') " + "ORDER BY M_InOut_ID" ; } PreparedStatement pstmt = null ; try { pstmt = DB . prepareStatement ( sql , get_TrxName ( ) ) ; int index = 1 ; if ( p_Selection ) { pstmt . setInt ( index , getAD_PInstance_ID ( ) ) ; } else { if ( p_AD_Org_ID != 0 ) pstmt . setInt ( index ++ , p_AD_Org_ID ) ; if ( p_C_BPartner_ID != 0 ) pstmt . setInt ( index ++ , p_C_BPartner_ID ) ; if ( p_M_InOut_ID != 0 ) pstmt . setInt ( index ++ , p_M_InOut_ID ) ; } } catch ( Exception e ) { log . log ( Level . SEVERE , sql , e ) ; } return generate ( pstmt ) ; }
generate invoices from shipments
