Ejemplo n.º 1
0
  // DESDE AQUI AGREGADO POR GHUCHET
  private void completarMovimiento(MMovement move) {
    // Preparar el movimiento
    move.setDocAction(X_M_Movement.DOCACTION_Prepare);
    DocumentEngine.processIt(move, X_M_Movement.DOCACTION_Prepare);
    move.save();
    commit();
    move.load(get_TrxName());
    if (move.getDocStatus().equals("IN")) {
      ADialog.error(EnvConstants.WINDOW_INFO, new Container(), "NoLines");
    } else {

      // Aca debo actualizar las cantidades aprobadas
      String sql =
          "SELECT QtyRequired, XX_ApprovedQty FROM M_MOVEMENTLINE WHERE M_MOVEMENT_ID = "
              + move.getM_Movement_ID();
      PreparedStatement ps_1 =
          DB.prepareStatement(
              sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, null);
      ResultSet rs_1 = null;
      // System.out.println(sql);
      int qty_required = 0;
      try {
        rs_1 = ps_1.executeQuery();
        while (rs_1.next()) {
          qty_required = rs_1.getInt("QtyRequired");
          rs_1.updateInt("XX_ApprovedQty", qty_required);
          rs_1.updateRow();
        }
      } catch (Exception e) {
        e.printStackTrace();

      } finally {
        try {
          rs_1.close();
          ps_1.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }

      move.setXX_Status("PE");
      move.setXX_RequestDate(move.getUpdated());
      move.save();

      // Se envian correos dependiendo del tipo de documento
      enviarCorreoATienda(move, Env.getCtx().getContextAsInt("#XX_L_MT_PTRANSFERAPPROVAL_ID"));
    }
  }
 /**
  * ************************************************************************ Process document
  *
  * @param processAction document action
  * @return true if performed
  */
 @Override
 public boolean processIt(String processAction) {
   m_processMsg = null;
   DocumentEngine engine = new DocumentEngine(this, getDocStatus());
   return engine.processIt(processAction, getDocAction());
 } //	processIt