I want to look at putting a suggestion on the Asterisk Github related to call transfers and the affect it has on CDR records. I would like to first understand what other affects it might have.
I have recently changes voice services provider and they don’t accommodate a reporting based on the from header in the sip invite and customer are looking for per extension/endpoint costing report.
This is simple enough for outgoing calls made and using the CDR table.
Where I am running into problems is customer receiving calls and then having to Attendant transfer the calls to external numbers.
Incoming call CDR record data has source and destination (DID call received on) and billsec
Extension/Endpoint makes and outgoing call to a number, either via speed dial or entering the number. CDR record has the source(endpoint) and destination number with billsec.
Attendant transfer happens that links the incoming caller and external number with each other but the CDR record data of the incoming call gets updated and billsec changes. The outgoing call CDR record ends and gets written to the CDR table.
I would like to rather see the attendant transfer data continue on the external call and not on the incoming caller.
This will fix billing/cost calculations from the CDR table.
Blind transfers also do have a problem with the CDR destination not changing and thus affecting incorrect billing. However I suspect I might be able to resolve this using the ResetCDR application.
What can it affect:
Call recordings.
I use mixmonitor to record using options
a: Append to the file instead of overwriting it.
b: Only save audio to the file while the channel is bridged.
I suspect mixmonitor application will have to change to accommodate the change to the CDR. So that the uniqueid for the second external call will append the conversation.
Changing the way CDRs works is not something we generally entertain. We’ve been down the road before multiple times, and because CDRs are fundamentally business logic many people disagree on how they should work and look.
If CDRs don’t work as you want, then the suggestion I always give is use CEL events and your own business logic to make your own CDRs how you want.
also the dialplan and cdr/cel config allow you to add custom filds cel_custom.conf, cdr_custom.conf, CELGenUserEvent() and CDR()
we have i our config added that we want to log this header X-CID
so when we recive a call and i do not have a X-CID we create one and add it to all transfers and queue, therby linking all call legs together
if you neet to write your own code to do billing on the cdr files I strongly reconend that you use CEL as it is a mutch better format for handeling complex calls (redirect, transfers, pickup, queues)
In CEL table I can see the channel2_uniqueid is the uniqueid of the external call. This is were my skill ends and I can’t figure out how to match the data so that I can alter the billing table:
I will have to update this table billsec and duration by the amount of time from the time call is transferred to when it ends.
I changed the script to look for calls transferred or forwarded and using the lastdata column to get the number and calculate the correct cost on it, rather than the dst.
INSERT INTO trunkcost SELECT cdr.uniqueid, cdr.duration, cdr.billsec, d.cost, d.destination_name, d.planname FROM cdr LEFT JOIN trunkcost USING (uniqueid) LEFT JOIN tarrif_plan AS p ON cdr.dstchannel REGEXP p.trunkname LEFT JOIN tarrif_rate_domestic AS d ON SUBSTRING(cdr.lastdata, 7, 10) REGEXP d.areacode WHERE trunkcost.uniqueid is null AND trunkname is not null and (p.planname = d.planname) and disposition = ‘ANSWERED’ and calldate > ‘2024-06-20’ group by uniqueid;
I still have some calls that don’t have cost values and some calls billsec are incorrect just because of the way attendant transfer and blind transfer functions.