mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
added account atribute to callcost
This commit is contained in:
@@ -28,6 +28,7 @@ type Event interface {
|
||||
GetDirection() string
|
||||
GetOrigId() string
|
||||
GetSubject() string
|
||||
GetAccount() string
|
||||
GetDestination() string
|
||||
GetTOR() string
|
||||
GetUUID() string
|
||||
|
||||
@@ -39,6 +39,7 @@ const (
|
||||
CALL_DIRECTION = "Call-Direction"
|
||||
ORIG_ID = "variable_sip_call_id" //- originator_id - match cdrs
|
||||
SUBJECT = "variable_cgr_subject"
|
||||
ACCOUNT = ""
|
||||
DESTINATION = "variable_cgr_destination"
|
||||
TOR = "variable_cgr_tor"
|
||||
UUID = "Unique-ID" // -Unique ID for this call leg
|
||||
@@ -85,6 +86,9 @@ func (fsev *FSEvent) GetOrigId() string {
|
||||
func (fsev *FSEvent) GetSubject() string {
|
||||
return fsev.Fields[SUBJECT]
|
||||
}
|
||||
func (fsev *FSEvent) GetAccount() string {
|
||||
return fsev.Fields[ACCOUNT]
|
||||
}
|
||||
func (fsev *FSEvent) GetDestination() string {
|
||||
return fsev.Fields[DESTINATION]
|
||||
}
|
||||
|
||||
@@ -48,12 +48,13 @@ func (psl *PostgresLogger) Log(uuid string, cc *timespans.CallCost) {
|
||||
if err != nil {
|
||||
log.Printf("Error marshalling timespans to json: %v", err)
|
||||
}
|
||||
_, err = psl.db.Exec(fmt.Sprintf("INSERT INTO callcosts VALUES ('%s', '%s', '%s', '%s', '%s', %v, %v, '%s')",
|
||||
_, err = psl.db.Exec(fmt.Sprintf("INSERT INTO callcosts VALUES ('%s','%s', '%s', '%s', '%s', '%s', '%s', %v, %v, '%s')",
|
||||
uuid,
|
||||
cc.Destination,
|
||||
cc.Tenant,
|
||||
cc.TOR,
|
||||
cc.Subject,
|
||||
cc.Account,
|
||||
cc.Destination,
|
||||
cc.Cost,
|
||||
cc.ConnectFee,
|
||||
|
||||
@@ -51,6 +51,7 @@ func NewSession(ev Event, sm SessionManager) (s *Session) {
|
||||
Tenant: ev.GetTenant(),
|
||||
TOR: ev.GetTOR(),
|
||||
Subject: ev.GetSubject(),
|
||||
Account: ev.GetAccount(),
|
||||
Destination: ev.GetDestination(),
|
||||
TimeStart: startTime}
|
||||
s = &Session{uuid: ev.GetUUID(),
|
||||
@@ -108,7 +109,7 @@ func (s *Session) Disconnect() {
|
||||
|
||||
// Nice print for session
|
||||
func (s *Session) String() string {
|
||||
return fmt.Sprintf("%v: %s -> %s", s.callDescriptor.TimeStart, s.callDescriptor.Subject, s.callDescriptor.Destination)
|
||||
return fmt.Sprintf("%v: %s(%s) -> %s", s.callDescriptor.TimeStart, s.callDescriptor.Subject, s.callDescriptor.Account, s.callDescriptor.Destination)
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -104,6 +104,7 @@ func (dsd *DirectSessionDelegate) OnChannelHangupComplete(ev Event, s *Session)
|
||||
Tenant: lastCC.Tenant,
|
||||
TOR: lastCC.TOR,
|
||||
Subject: lastCC.Subject,
|
||||
Account: lastCC.Account,
|
||||
Destination: lastCC.Destination,
|
||||
Amount: -cost,
|
||||
}
|
||||
@@ -115,6 +116,7 @@ func (dsd *DirectSessionDelegate) OnChannelHangupComplete(ev Event, s *Session)
|
||||
Tenant: lastCC.Tenant,
|
||||
TOR: lastCC.TOR,
|
||||
Subject: lastCC.Subject,
|
||||
Account: lastCC.Account,
|
||||
Destination: lastCC.Destination,
|
||||
Amount: -seconds,
|
||||
}
|
||||
@@ -227,6 +229,7 @@ func (rsd *RPCSessionDelegate) OnChannelHangupComplete(ev Event, s *Session) {
|
||||
Tenant: lastCC.Tenant,
|
||||
TOR: lastCC.TOR,
|
||||
Subject: lastCC.Subject,
|
||||
Account: lastCC.Account,
|
||||
Destination: lastCC.Destination,
|
||||
Amount: -cost,
|
||||
}
|
||||
@@ -241,6 +244,7 @@ func (rsd *RPCSessionDelegate) OnChannelHangupComplete(ev Event, s *Session) {
|
||||
TOR: lastCC.TOR,
|
||||
Tenant: lastCC.Tenant,
|
||||
Subject: lastCC.Subject,
|
||||
Account: lastCC.Account,
|
||||
Destination: lastCC.Destination,
|
||||
Amount: -seconds,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user