From 010547b20037d12a123379517265259ff235f33c Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 20 Aug 2012 11:15:01 +0300 Subject: [PATCH] used debit method instead of code duplication --- timespans/calldesc.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/timespans/calldesc.go b/timespans/calldesc.go index acd3d9b19..865696c28 100644 --- a/timespans/calldesc.go +++ b/timespans/calldesc.go @@ -367,24 +367,7 @@ func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) { rs, _ := time.ParseDuration(fmt.Sprintf("%vs", remainingSeconds)) cd.TimeEnd = cd.TimeStart.Add(rs) } - cc, err = cd.GetCost() - if err != nil { - Logger.Err(fmt.Sprintf("error getting cost for key %v: %v", cd.GetUserBalanceKey(), err)) - return - } - Logger.Debug(fmt.Sprintf("Debiting from %v, value: %v", cd.GetUserBalanceKey(), cc.Cost+cc.ConnectFee)) - if userBalance, err := cd.getUserBalance(); err == nil && userBalance != nil { - defer storageGetter.SetUserBalance(userBalance) - if cc.Cost != 0 || cc.ConnectFee != 0 { - userBalance.debitBalance(CREDIT, cc.Cost+cc.ConnectFee, true) - } - for _, ts := range cc.Timespans { - if ts.MinuteInfo != nil { - userBalance.debitMinutesBalance(ts.MinuteInfo.Quantity, cd.Destination, true) - } - } - } - return + return cd.Debit() } /*