Asterisk 13 problem with billing ( in outbound calls with sip attended transfer )

Hi,

I am working with CDR in Asterisk 13 ( They did change in Asterisk 12 ) and I have a problem with billing at outbound calls when I transfer a outbound call to other extension using sip protocol attended transfer ( not core attended transfer ).

The situation it’s the same that I have read on “SIP Protocol Attended Transfer” section of this URL ( https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+CDR+Specification#Asterisk12CDRSpecification-Transfers ) , the linkedid it’s not the same on three CDR generated. It’s a problem because I use a custom field in CDR with the type of call outbound(billable)/internal/inbound . Asterisk generate three CDR :

1.- Marked as outbound with billsec between the outbound destination answer and the call it’s transfered.
2.- Marked as internal with billsec between the destination of the transferred call answer and the origin of transferred call ends the transfer.
3.- Unmarked with billsec the time of the destination transferred call it’s speaking with outbound destination.

*************************** 3. row ***************************
        src: 910000000
        dst: 
      start: 2017-08-30 18:08:31
     answer: 2017-08-30 18:08:31
        end: 2017-08-30 18:08:32
   duration: 100
    billsec: 100
disposition: ANSWERED
   uniqueid: 1504109301.164
   linkedid: 1504109301.163
   sequence: 208
custom_type: 
*************************** 2. row ***************************
        src: 208
        dst: 203
      start: 2017-08-30 18:08:29
     answer: 2017-08-30 18:08:30
        end: 2017-08-30 18:08:31
   duration: 2
    billsec: 1
disposition: ANSWERED
   uniqueid: 1504109309.165
   linkedid: 1504109309.165
   sequence: 206
custom_type: internal
*************************** 1. row ***************************
        src: 208
        dst: 910000000
      start: 2017-08-30 18:08:21
     answer: 2017-08-30 18:08:21
        end: 2017-08-30 18:08:31
   duration: 9
    billsec: 9
disposition: ANSWERED
   uniqueid: 1504109301.163
   linkedid: 1504109301.163
   sequence: 204
custom_type: outbound
3 rows in set (0.00 sec)

I try to aproach to the solution with this link ( https://community.freepbx.org/t/macro-hangupcall-custom-macro-hangupcall-problem/41422/2 ), using CHANNEL(hangup_handler_push) at the begining of the dialplan that asterisk use to contact with the extension that i want to transfer the call . Its go to a subroutine that store ${CONNECTEDLINE(number)} but this variable is the source and not the destination of the first call.
I am trying with ${REDIRECTING(…)} variable with the same result, and I have using the DumpChan function to watch all channel variables and not found the destination of a first call to store in the CDR.

It is possible to relate the three cdr’s to bill the total tiem of the outbound call?

Regards