コード例 #1
0
 /**
  * Set Amount (Callout)
  *
  * @param windowNo window
  * @param columnName changed column
  */
 private void setAmt(int windowNo, String columnName) {
   //	get values
   BigDecimal ExpenseAmt = getExpenseAmt();
   int C_Currency_From_ID = getC_Currency_ID();
   int C_Currency_To_ID = getCtx().getContextAsInt("$C_Currency_ID");
   Timestamp DateExpense = getDateExpense();
   //
   log.fine("Amt=" + ExpenseAmt + ", C_Currency_ID=" + C_Currency_From_ID);
   //	Converted Amount = Unit price
   BigDecimal ConvertedAmt = ExpenseAmt;
   //	convert if required
   if (ConvertedAmt.signum() != 0 && C_Currency_To_ID != C_Currency_From_ID) {
     ConvertedAmt =
         MConversionRate.convert(
             getCtx(),
             ConvertedAmt,
             C_Currency_From_ID,
             C_Currency_To_ID,
             DateExpense,
             0,
             getAD_Client_ID(),
             getAD_Org_ID());
   }
   setConvertedAmt(ConvertedAmt);
   log.fine("ConvertedAmt=" + ConvertedAmt);
 } //	setAmt
コード例 #2
0
ファイル: MPeriod.java プロジェクト: WilkerDiaz/Compiere
  /**
   * Is Period Open for Doc Base Type
   *
   * @param DocBaseType document base type
   * @param dateAcct accounting date
   * @return error message or null
   */
  public String isOpen(String DocBaseType, Timestamp dateAcct) {
    if (!isActive()) {
      s_log.warning("Period not active: " + getName());
      return "@C_Period_ID@ <> @IsActive@";
    }

    MAcctSchema as = MClient.get(getCtx(), getAD_Client_ID()).getAcctSchema();
    if (as != null && as.isAutoPeriodControl()) {
      if (!as.isAutoPeriodControlOpen(dateAcct)) return "@PeriodClosed@ - @AutoPeriodControl@";
      //	We are OK
      Timestamp today = new Timestamp(System.currentTimeMillis());
      if (isInPeriod(today) && as.getC_Period_ID() != getC_Period_ID()) {
        as.setC_Period_ID(getC_Period_ID());
        as.save();
      }
      return null;
    }

    //	Standard Period Control
    if (DocBaseType == null) {
      log.warning(getName() + " - No DocBaseType");
      return "@NotFound@ @DocBaseType@";
    }
    MPeriodControl pc = getPeriodControl(DocBaseType);
    if (pc == null) {
      log.warning(getName() + " - Period Control not found for " + DocBaseType);
      return "@NotFound@ @C_PeriodControl_ID@: " + DocBaseType;
    }
    log.fine(getName() + ": " + DocBaseType);
    if (pc.isOpen()) return null;
    return "@PeriodClosed@ - @C_PeriodControl_ID@ (" + DocBaseType + ", " + dateAcct + ")";
  } //	isOpen
コード例 #3
0
  /**
   * Set Resource Assignment - Callout
   *
   * @param oldS_ResourceAssignment_ID old value
   * @param newS_ResourceAssignment_ID new value
   * @param windowNo window
   * @throws Exception
   */
  @UICallout
  public void setS_ResourceAssignment_ID(
      String oldS_ResourceAssignment_ID, String newS_ResourceAssignment_ID, int windowNo)
      throws Exception {
    if (newS_ResourceAssignment_ID == null || newS_ResourceAssignment_ID.length() == 0) return;
    int S_ResourceAssignment_ID = Integer.parseInt(newS_ResourceAssignment_ID);
    if (S_ResourceAssignment_ID == 0) return;
    //
    super.setS_ResourceAssignment_ID(S_ResourceAssignment_ID);

    int M_Product_ID = 0;
    String Name = null;
    String Description = null;
    BigDecimal Qty = null;
    String sql =
        "SELECT p.M_Product_ID, ra.Name, ra.Description, ra.Qty "
            + "FROM S_ResourceAssignment ra"
            + " INNER JOIN M_Product p ON (p.S_Resource_ID=ra.S_Resource_ID) "
            + "WHERE ra.S_ResourceAssignment_ID=?";
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, get_Trx());
      pstmt.setInt(1, S_ResourceAssignment_ID);
      rs = pstmt.executeQuery();
      if (rs.next()) {
        M_Product_ID = rs.getInt(1);
        Name = rs.getString(2);
        Description = rs.getString(3);
        Qty = rs.getBigDecimal(4);
      }
    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
    log.fine(
        "S_ResourceAssignment_ID=" + S_ResourceAssignment_ID + " - M_Product_ID=" + M_Product_ID);
    if (M_Product_ID != 0) {
      setM_Product_ID(M_Product_ID);
      if (Description != null) Name += " (" + Description + ")";
      if (!".".equals(Name)) setDescription(Name);
      if (Qty != null) setQty(Qty);
    }
  } //	setS_ResourceAssignment_ID
コード例 #4
0
ファイル: MPeriod.java プロジェクト: WilkerDiaz/Compiere
 /**
  * After Save
  *
  * @param newRecord new
  * @param success success
  * @return success
  */
 @Override
 protected boolean afterSave(boolean newRecord, boolean success) {
   if (newRecord) {
     //	SELECT Value FROM AD_Ref_List WHERE AD_Reference_ID=183
     MDocType[] types = MDocType.getOfClient(getCtx());
     int count = 0;
     ArrayList<String> baseTypes = new ArrayList<String>();
     for (MDocType type : types) {
       String DocBaseType = type.getDocBaseType();
       if (baseTypes.contains(DocBaseType)) continue;
       MPeriodControl pc = new MPeriodControl(this, DocBaseType);
       if (pc.save()) count++;
       baseTypes.add(DocBaseType);
     }
     log.fine("PeriodControl #" + count);
   }
   return success;
 } //	afterSave