コード例 #1
0
ファイル: InvoiceGen.java プロジェクト: comitsrl/lar_361
  /**
   * Save Selection & return selecion Query or ""
   *
   * @return where clause like C_Order_ID IN (...)
   */
  public void saveSelection(IMiniTable miniTable) {
    log.info("");
    //  Array of Integers
    ArrayList<Integer> results = new ArrayList<Integer>();
    setSelection(null);

    //	Get selected entries
    int rows = miniTable.getRowCount();
    for (int i = 0; i < rows; i++) {
      IDColumn id = (IDColumn) miniTable.getValueAt(i, 0); //  ID in column 0
      //	log.fine( "Row=" + i + " - " + id);
      if (id != null && id.isSelected()) results.add(id.getRecord_ID());
    }

    if (results.size() == 0) return;
    log.config("Selected #" + results.size());
    setSelection(results);
  } //	saveSelection
コード例 #2
0
ファイル: InvoiceGen.java プロジェクト: comitsrl/lar_361
  /** Query Info */
  public void executeQuery(KeyNamePair docTypeKNPair, IMiniTable miniTable) {
    log.info("");
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
    //  Create SQL

    String sql = "";

    if (docTypeKNPair.getKey() == MOrder.Table_ID) {
      sql = getOrderSQL();
    } else {
      sql = getRMASql();
    }

    //  reset table
    int row = 0;
    miniTable.setRowCount(row);
    //  Execute
    try {
      PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
      pstmt.setInt(1, AD_Client_ID);
      ResultSet rs = pstmt.executeQuery();
      //
      while (rs.next()) {
        //  extend table
        miniTable.setRowCount(row + 1);
        //  set values
        miniTable.setValueAt(new IDColumn(rs.getInt(1)), row, 0); //  C_Order_ID
        miniTable.setValueAt(rs.getString(2), row, 1); //  Org
        miniTable.setValueAt(rs.getString(3), row, 2); //  DocType
        miniTable.setValueAt(rs.getString(4), row, 3); //  Doc No
        miniTable.setValueAt(rs.getString(5), row, 4); //  BPartner
        miniTable.setValueAt(rs.getTimestamp(6), row, 5); //  DateOrdered
        miniTable.setValueAt(rs.getBigDecimal(7), row, 6); //  TotalLines
        //  prepare next
        row++;
      }
      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql.toString(), e);
    }
    //
    miniTable.autoSize();
    //	statusBar.setStatusDB(String.valueOf(miniTable.getRowCount()));
  } //  executeQuery
コード例 #3
0
  public boolean completePayments(int docType_ID, String documentNo, Timestamp trxDate) {
    boolean success = false;

    message_error = "No se pudo completar los pagos";

    try {

      success = validatePayments();

      // create header

      caPayment = new X_CA_Payment(ctx, 0, null);
      caPayment.setC_BPartner_ID(m_bpartner.get_ID());
      caPayment.setDocumentNo(documentNo);
      caPayment.setC_DocType_ID(docType_ID);
      caPayment.setDateTrx(trxDate);
      caPayment.saveEx();

      // save lines

      // buscar tabla de prioridades
      // List<X_CA_PaymentPreference> priorities = new Query(ctx, X_CA_PaymentPreference.Table_Name,
      // "", null)
      // .setOnlyActiveRecords(true).setOrderBy("SeqNo").list();

      for (int tableRow = 0; tableRow <= paymentTable.getRowCount() - 1; tableRow++) {

        String type = getComboValue(tableRow, 0);

        if (!"AN".equals(type) && !"ME".equals(type))
          throw new AdempiereException("Indicar tipo de pago (Anual/Mensual)");

        String paymentType = getComboValue(tableRow, 1);
        String card = getComboValue(tableRow, 2);
        java.lang.Number quote = (java.lang.Number) paymentTable.getValueAt(tableRow, 3);
        Boolean hasinteres = (Boolean) paymentTable.getValueAt(tableRow, 4);
        String account = getComboValue(tableRow, 5);
        String reference = (String) paymentTable.getValueAt(tableRow, 6);
        java.lang.Number amount = (java.lang.Number) paymentTable.getValueAt(tableRow, 7);

        for (int studentRow = 0; studentRow <= studentTable.getRowCount() - 1; studentRow++) {

          String value = (String) studentTable.getValueAt(studentRow, INDEX_VALUE);
          I_C_BPartner student = studentList.get(value);
          Boolean doPay = (Boolean) studentTable.getValueAt(studentRow, 5);

          if (doPay) {
            MTimeExpenseLine currentSchedule = null;

            for (MTimeExpenseLine schedule : paymentSchedules) {
              if (schedule.getC_BPartner_ID() == student.getC_BPartner_ID()) {
                currentSchedule = schedule;
              }
            }

            if (currentSchedule == null) throw new AdempiereException("No existe programa de Pago");

            // generar nuevo pago
            MPayment payment = new MPayment(ctx, 0, null);

            payment.set_ValueOfColumn("CA_Payment_ID", caPayment.get_ID());
            payment.setC_DocType_ID(1000008); // pago, que siempre no, que es cobro
            payment.setC_BankAccount_ID(Integer.parseInt(account));

            payment.set_ValueOfColumn("SalesRep_ID", Env.getContextAsInt(ctx, "#AD_User_ID"));

            payment.setTenderType(paymentType);

            if ("K".equals(paymentType)
                || "Q".equals(paymentType)) // cheque nacional - internacional
            {
              payment.setCheckNo(reference);
            } else if ("A".equals(paymentType)) // Depósito directo
            {
              payment.setAccountNo(reference);
            } else if ("C".equals(paymentType)) // Tarjeta de Crédito
            {
              payment.setCreditCardType(card);
              payment.setCreditCardNumber(reference);
              payment.set_ValueOfColumn("NumberOfShares", new BigDecimal(String.valueOf(quote)));
              payment.set_ValueOfColumn("HasInterests", hasinteres);
            }

            payment.setC_BPartner_ID(student.getC_BPartner_ID());

            payment.setPayAmt(new BigDecimal(String.valueOf(getAmount(currentSchedule, type))));
            payment.setC_Order_ID(currentSchedule.get_ID());
            payment.setC_Currency_ID(100); // USD

            if (payment.getPayAmt().compareTo(new BigDecimal("0")) > 0) {
              payment.saveEx();
              payment.processIt(DocAction.ACTION_Complete);
            }
          }
        }
      }

      success = true;
    } catch (Exception e) {
      success = false;
      e.printStackTrace();
      message_error = e.getMessage();
    }

    return success;
  }
コード例 #4
0
ファイル: InvoiceGen.java プロジェクト: comitsrl/lar_361
 public void configureMiniTable(IMiniTable miniTable) {
   //  create Columns
   miniTable.addColumn("C_Order_ID");
   miniTable.addColumn("AD_Org_ID");
   miniTable.addColumn("C_DocType_ID");
   miniTable.addColumn("DocumentNo");
   miniTable.addColumn("C_BPartner_ID");
   miniTable.addColumn("DateOrdered");
   miniTable.addColumn("TotalLines");
   //
   miniTable.setMultiSelection(true);
   //  set details
   miniTable.setColumnClass(0, IDColumn.class, false, " ");
   miniTable.setColumnClass(1, String.class, true, Msg.translate(Env.getCtx(), "AD_Org_ID"));
   miniTable.setColumnClass(2, String.class, true, Msg.translate(Env.getCtx(), "C_DocType_ID"));
   miniTable.setColumnClass(3, String.class, true, Msg.translate(Env.getCtx(), "DocumentNo"));
   miniTable.setColumnClass(4, String.class, true, Msg.translate(Env.getCtx(), "C_BPartner_ID"));
   miniTable.setColumnClass(5, Timestamp.class, true, Msg.translate(Env.getCtx(), "DateOrdered"));
   miniTable.setColumnClass(6, BigDecimal.class, true, Msg.translate(Env.getCtx(), "TotalLines"));
   //
   miniTable.autoSize();
 }