Hi Iñaki,
I checked the code and made test calls that span multiple profiles. The calculus is correct.
The confusion likely arises because StartTime is printed in each span, while it is the StartTime of the call itself and not of the span.
Finally the sum of all spans equals the duration of the call. If you have data that contradicts this I would be happy to look at it again.
Regards, Adrian
>>>>>>>>>>
Hi, CDRTool can calculate the price of a call involving various spans (rates). But it does it wrongly since the start time for each span is set to the start time of the call, so the price is much higher than the correct one.
An example: This is a call of more than 3 days of duration. Note that in spans 2, 3 and 4 the "StartTime" is 2008-02-16 15:57:05 in all (the start time of
the call), and note also that the "Duration" of spans 2, 3 and 4 are the sum of each span and its previous spans:
-- Span: 1 Duration: 28975 s StartTime: 2008-02-16 15:57:05 (Europe/Madrid) ProfileId: 01 Festivo for weekend RateId: Reducida for 0-24h Rate: 0.0100 / 60 s Price: 4.8292 -- Span: 2 Duration: 115375 s <---- WRONG !!! StartTime: 2008-02-16 15:57:05 (Europe/Madrid) <---- WRONG !!! ProfileId: 01 Festivo for weekend RateId: Reducida for 0-24h Rate: 0.0100 / 60 s Price: 19.2292 -- Span: 3 Duration: 144175 s <---- WRONG !!! StartTime: 2008-02-16 15:57:05 (Europe/Madrid) <---- WRONG !!! ProfileId: 01 Laboral for weekday RateId: Reducida for 0-8h Rate: 0.0100 / 60 s Price: 24.0292 -- Span: 4 Duration: 229878 s <---- WRONG !!! StartTime: 2008-02-16 15:57:05 (Europe/Madrid) <---- WRONG !!! ProfileId: 01 Laboral for weekday RateId: Normal for 8-22h Rate: 0.0300 / 60 s Price: 114.9390 -- Total: 163.0765
El Tuesday 19 February 2008 11:23:47 Adrian Georgescu escribió:
Hi Iñaki,
I checked the code and made test calls that span multiple profiles. The calculus is correct.
The confusion likely arises because StartTime is printed in each span, while it is the StartTime of the call itself and not of the span.
Finally the sum of all spans equals the duration of the call. If you have data that contradicts this I would be happy to look at it again.
Hi again, I've calculated it again and it's completely correct, but maybe a little confusing. Let me explain with a real example:
A call 24 hours long envolving various spans:
This is what CDRTool logs:
CDRTool says: **************
Start time: 2008-02-19 14:00:00 Stop time: 2008-02-20 14:00:00 Duration: 24:00:00 (86400 s) PRICE: 24,00 €
Span: 1 Duration: 28800 s StartTime: 2008-02-19 14:00:00 (Europe/Madrid) ProfileId: 01 Laboral for weekday RateId: Normal for 8-22h Rate: 0.0300 / 60 s Price: 14.4000 -- Span: 2 Duration: 36000 s StartTime: 2008-02-19 14:00:00 (Europe/Madrid) ProfileId: 01 Laboral for weekday RateId: Reducida for 22-24h Rate: 0.0100 / 60 s Price: 6.0000 -- Span: 3 Duration: 21600 s StartTime: 2008-02-19 14:00:00 (Europe/Madrid) ProfileId: 01 Laboral for weekday RateId: Reducida for 0-8h Rate: 0.0100 / 60 s Price: 3.6000
As you see, CDRTool sees 3 spans, while I considere there are 4 spans, but now I understand that it's an interpretation issue: CDRTools groups all the spans for the same rateid in an unique span. This is what I understand calculating manually:
I see: ****************
Start time: 2008-02-19 14:00:00 Stop time: 2008-02-20 14:00:00 Duration: 24:00:00 (86400 s)
span: 1 - From: 2008-02-19 14:00:00 - To: 2008-02-19 22:00:00 - Duration: 28800 s - Rate: (8-22h) 0.03/60s - Price: 14,4
span: 2 - From: 2008-02-19 22:00:00 - To: 2008-02-19 24:00:00 - Duration: 7200 s - Rate: (22-24h) 0.01/60s - Price: 1,2
span: 3 - From: 2008-02-20 0:00:00 - To: 2008-02-20 8:00:00 - Duration: 28800 s - Rate: (0-8h) 0.01/60s - Price: 4,8
span: 4 - From: 2008-02-20 8:00:00 - To: 2008-02-20 14:00:00 - Duration: 21600 s - Rate: (8-22h) 0.03/60s - Price: 3,6
TOTAL: ****** - Duration: 86400 s - PRICE: 24.00 €
So it's ok, thanks a lot for your help. ;)