Search in sources :

Example 11 with QuotaBalanceVO

use of org.apache.cloudstack.quota.vo.QuotaBalanceVO in project cloudstack by apache.

the class QuotaManagerImpl method aggregateCreditBetweenDates.

private BigDecimal aggregateCreditBetweenDates(final AccountVO account, final Date startDate, final Date endDate) {
    BigDecimal aggrUsage = new BigDecimal(0);
    List<QuotaBalanceVO> creditsReceived = null;
    creditsReceived = _quotaBalanceDao.findCreditBalance(account.getAccountId(), account.getDomainId(), startDate, endDate);
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Credit entries count " + creditsReceived.size() + " on Before Date=" + endDate);
    }
    if (creditsReceived != null) {
        for (QuotaBalanceVO credit : creditsReceived) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Credit entry found " + credit);
                s_logger.debug("Total = " + aggrUsage);
            }
            aggrUsage = aggrUsage.add(credit.getCreditBalance());
        }
    }
    return aggrUsage;
}
Also used : QuotaBalanceVO(org.apache.cloudstack.quota.vo.QuotaBalanceVO) BigDecimal(java.math.BigDecimal)

Aggregations

QuotaBalanceVO (org.apache.cloudstack.quota.vo.QuotaBalanceVO)11 BigDecimal (java.math.BigDecimal)8 Date (java.util.Date)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 AccountVO (com.cloud.user.AccountVO)2 QuotaBalanceResponse (org.apache.cloudstack.api.response.QuotaBalanceResponse)2 QuotaAccountVO (org.apache.cloudstack.quota.vo.QuotaAccountVO)2 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)1 Account (com.cloud.user.Account)1 User (com.cloud.user.User)1 Filter (com.cloud.utils.db.Filter)1 Field (java.lang.reflect.Field)1 List (java.util.List)1 QuotaCreditsVO (org.apache.cloudstack.quota.vo.QuotaCreditsVO)1 QuotaUsageVO (org.apache.cloudstack.quota.vo.QuotaUsageVO)1 DateTime (org.joda.time.DateTime)1