From bc8994ba1c24f68d24576986d29ff8322d00a8ed Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Tue, 8 Dec 2015 17:21:00 +0530 Subject: [PATCH] CLOUDSTACK-9122: latest credit entries should be incorporated when the balance is calculated --- .../cloudstack/quota/QuotaManagerImpl.java | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/framework/quota/src/org/apache/cloudstack/quota/QuotaManagerImpl.java b/framework/quota/src/org/apache/cloudstack/quota/QuotaManagerImpl.java index d7c301e1beac..b039e26a9b57 100644 --- a/framework/quota/src/org/apache/cloudstack/quota/QuotaManagerImpl.java +++ b/framework/quota/src/org/apache/cloudstack/quota/QuotaManagerImpl.java @@ -214,29 +214,18 @@ public void processQuotaBalanceForAccount(final AccountVO account, final List 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; } @Override