mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
first real data tests
This commit is contained in:
BIN
data/test.kch
BIN
data/test.kch
Binary file not shown.
@@ -30,6 +30,13 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{"TOR": "0","CstmId":"1","Subject":"1000","DestinationPrefix":"service", "ActivationPeriods": [
|
||||
{"ActivationTime": "2012-01-01T00:00:00Z", "Intervals": [
|
||||
{"BillingUnit":60,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":1,"StartTime":"","EndTime":""}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{"TOR": "0","CstmId":"vdf","Subject":"minutosu","DestinationPrefix":"0723", "ActivationPeriods": [
|
||||
{"ActivationTime": "2012-01-01T00:00:00Z", "Intervals": [
|
||||
{"BillingUnit":60,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":1,"StartTime":"","EndTime":""}
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
{"Id":"nationale", "Prefixes":["0256","0257","0723","0740"]},
|
||||
{"Id":"retea", "Prefixes":["0723","0724"]},
|
||||
{"Id":"mobil", "Prefixes":["0723","0740"]},
|
||||
{"Id":"radu", "Prefixes":["0723045326"]}
|
||||
{"Id":"radu", "Prefixes":["0723045326"]},
|
||||
{"Id":"freeswitch", "Prefixes":["service"]}
|
||||
]
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
[{"Seconds":100,"Priority":10,"Price":0.01,"DestinationId":"nationale"}, {"Seconds":1000,"Priority":20,"Price":0,"DestinationId":"retea"}],
|
||||
"VolumeDiscountThresholds":
|
||||
[{"Volume": 100, "Discount": 10},{"Volume": 500, "Discount": 15},{"Volume": 1000, "Discount": 20}]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
[{"Seconds":10,"Priority":10,"Price":0.01,"DestinationId":"nationale"},
|
||||
{"Seconds":100,"Priority":20,"Price":0,"DestinationId":"retea"}]},
|
||||
{"Id":"broker","Credit":0,"SmsCredit":0,"Traffic":0,"VolumeDiscountSeconds":0,"ReceivedCallSeconds":0,"ResetDayOfTheMonth":10,"TariffPlanId":"seara","MinuteBuckets":
|
||||
[{"Seconds":10,"Priority":10,"Price":0.01,"DestinationId":"nationale"},
|
||||
{"Seconds":100,"Priority":20,"Price":0,"DestinationId":"retea"}]},
|
||||
{"Id":"1000","Credit":0,"SmsCredit":0,"Traffic":0,"VolumeDiscountSeconds":0,"ReceivedCallSeconds":0,"ResetDayOfTheMonth":10,"TariffPlanId":"seara","MinuteBuckets":
|
||||
[{"Seconds":10,"Priority":10,"Price":0.01,"DestinationId":"nationale"},
|
||||
{"Seconds":100,"Priority":20,"Price":0,"DestinationId":"retea"}]}
|
||||
]
|
||||
|
||||
@@ -56,6 +56,7 @@ func (dsd *DirectSessionDelegate) OnHeartBeat(ev *Event) {
|
||||
|
||||
func (dsd *DirectSessionDelegate) OnChannelAnswer(ev *Event, s *Session) {
|
||||
s.callDescriptor.Amount = DEBIT_PERIOD.Seconds()
|
||||
s.callDescriptor.SetStorageGetter(storageGetter)
|
||||
remainingSeconds, err := s.callDescriptor.GetMaxSessionTime()
|
||||
if remainingSeconds == 0 || err != nil {
|
||||
log.Print("No credit left: Disconnect!")
|
||||
@@ -70,6 +71,7 @@ func (dsd *DirectSessionDelegate) OnChannelHangupComplete(ev *Event, s *Session)
|
||||
}
|
||||
|
||||
func (dsd *DirectSessionDelegate) LoopAction(s *Session, cd *timespans.CallDescriptor) {
|
||||
cd.SetStorageGetter(storageGetter)
|
||||
cc, err := cd.Debit()
|
||||
if err != nil {
|
||||
log.Printf("Could not complete debit opperation: %v", err)
|
||||
|
||||
@@ -99,6 +99,7 @@ func (sm *SessionManager) OnHeartBeat(ev *Event) {
|
||||
func (sm *SessionManager) OnChannelAnswer(ev *Event) {
|
||||
if sm.sessionDelegate != nil {
|
||||
s := NewSession(ev, sm.sessionDelegate)
|
||||
sm.sessions = append(sm.sessions, s)
|
||||
sm.sessionDelegate.OnChannelAnswer(ev, s)
|
||||
} else {
|
||||
log.Print("answer")
|
||||
|
||||
@@ -20,7 +20,7 @@ package timespans
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// "log"
|
||||
"log"
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
@@ -298,12 +298,17 @@ func (cd *CallDescriptor) GetMaxSessionTime() (seconds float64, err error) {
|
||||
// from user's money budget.
|
||||
func (cd *CallDescriptor) Debit() (cc *CallCost, err error) {
|
||||
cc, err = cd.GetCost()
|
||||
if err != nil {
|
||||
log.Printf("error getting cost %v", err)
|
||||
}
|
||||
if userBudget, err := cd.getUserBudget(); err == nil && userBudget != nil {
|
||||
if cc.Cost != 0 || cc.ConnectFee != 0 {
|
||||
userBudget.debitMoneyBudget(cd.storageGetter, cc.Cost+cc.ConnectFee)
|
||||
}
|
||||
for _, ts := range cc.Timespans {
|
||||
userBudget.debitMinutesBudget(cd.storageGetter, ts.MinuteInfo.Quantity, cd.DestinationPrefix)
|
||||
if ts.MinuteInfo != nil {
|
||||
userBudget.debitMinutesBudget(cd.storageGetter, ts.MinuteInfo.Quantity, cd.DestinationPrefix)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user