Esempio n. 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
Esempio n. 2
0
 /**
  * Before Save. Calculate converted amt
  *
  * @param newRecord new
  * @return true
  */
 @Override
 protected boolean beforeSave(boolean newRecord) {
   //	Calculate Converted Amount
   if (newRecord || is_ValueChanged("ExpenseAmt") || is_ValueChanged("C_Currency_ID")) {
     if (getC_Currency_ID() == getC_Currency_Report_ID()) setConvertedAmt(getExpenseAmt());
     else {
       setConvertedAmt(
           MConversionRate.convert(
               getCtx(),
               getExpenseAmt(),
               getC_Currency_ID(),
               getC_Currency_Report_ID(),
               getDateExpense(),
               0,
               getAD_Client_ID(),
               getAD_Org_ID()));
     }
   }
   if (isTimeReport()) {
     setExpenseAmt(Env.ZERO);
     setConvertedAmt(Env.ZERO);
   }
   return true;
 } //	beforeSave