From e87ed4fcd396af86ea8b498f9df19cb3ad97f08f Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Fri, 10 Aug 2012 19:49:41 +0300 Subject: [PATCH] return at least the credit --- timespans/userbalance.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timespans/userbalance.go b/timespans/userbalance.go index 698ba548c..48d5059e9 100644 --- a/timespans/userbalance.go +++ b/timespans/userbalance.go @@ -67,6 +67,8 @@ func (a AmountTooBig) Error() string { Returns user's available minutes for the specified destination */ func (ub *UserBalance) getSecondsForPrefix(prefix string) (seconds, credit float64, bucketList bucketsorter) { + credit = ub.BalanceMap[CREDIT+OUTBOUND] + Logger.Debug(fmt.Sprintf("Initial credit: %v from %+v", credit, ub.BalanceMap)) if len(ub.MinuteBuckets) == 0 { // Logger.Debug("There are no minute buckets to check for user: ", ub.Id) return @@ -85,8 +87,6 @@ func (ub *UserBalance) getSecondsForPrefix(prefix string) (seconds, credit float } } bucketList.Sort() // sorts the buckets according to priority, precision or price - credit = ub.BalanceMap[CREDIT+OUTBOUND] - Logger.Debug(fmt.Sprintf("Initial credit: %v from %+v", credit, ub.BalanceMap)) for _, mb := range bucketList { s := mb.GetSecondsForCredit(credit) credit -= s * mb.Price