7f09578d4a58d9fa86459e32502df014b39f6f81
[freeside.git] / FS / bin / freeside-cdr-freeswitch
1 #!/usr/bin/perl
2
3 use strict;
4 use Date::Parse 'str2time';
5 use FS::cdr::Import;
6
7 FS::cdr::Import->dbi_import(
8   'dbd'          => 'Pg',
9   'database'     => 'fusionpbx',
10   'table'        => 'v_xml_cdr',
11   'primary_key'  => 'uuid',
12   'column_map'   => { #freeside => fusionpbx
13     #'cdrid'             => 'uuid', #Primary key
14     #'' => 'CALL_SESSION_ID', # Call Session Id (unique per call session – GUID)
15     'uniqueid'          => 'uuid', #
16     #'' => 'ENTRY_TYPE', #
17     'accountcode'       => 'accountcode', #
18     #'' => 'ACCOUNT', #
19     #'' => 'ACCOUNT_GROUP', #
20     'startdate'         => sub { str2time(shift->{'start_stamp'}); },
21     'answerdate'        => sub { str2time(shift->{'answer_stamp'}); },
22     'enddate'           => sub { str2time(shift->{'end_stamp'}); },
23     #'' => 'PARENT_ACCOUNT_ID', #
24     #'' => 'PARENT_ACCOUNT', #
25     #'' => 'LOGIN_NAME', #
26     #varchars not ints 'upstream_rateid' => 'RATE_SCHEDULE', #
27     #varchars not ints 'upstream_rateplanid' => 'RATE_PLAN', #
28     'channel' => 'NODE', #
29     #'' => 'NODE_TYPE', #
30     #'' => 'ORIGIN', #
31     #'dst'               => sub { $_[0]->{COUNTRY_CODE}. $_[0]->{NPA}.
32     #                             $_[0]->{NXX}. $_[0]->{LOCAL_NUMBER};
33     #                           },
34     #'description'       => 'DESCRIPTION', # or upstream_dst_regionname ?
35     #'' => 'PER_CALL_CHARGE', #
36     #'' => 'PER_MINUTE_CHARGE', #
37     #'' => 'PER_CALL_SURCHARGE', #
38     #'' => 'PER_MINUTE_SURCHARGE', #
39     'duration'          => 'duration', #
40     'billsec'           => sub { int( shift->{'billsec'} * 60 + .49 ); }, #
41     #'upstream_price'    => 'AMOUNT', #
42     #'' => 'PACKAGED_BALANCE_INDEX', #
43     #'upstream_currency' => 'CURRENCY', #
44     #'' => 'CONVERSION_RATE', #
45     'lastapp'           => 'last_app', #
46     #'src'               => 'ANI', # 'clid' => 'ANI', #
47     'dst'               => sub { $_[0]->{'COUNTRY_CODE'} !~ /^1/
48                                    ? "011". $_[0]->{'DETAIL'}
49                                    : $_[0]->{'DETAIL'};
50                                },
51     #'' => 'SALES_GROUP', #
52     #'' => 'TAX_GROUP', #
53     #'userfield'         => 'USER_1', #
54     #'' => 'USER_2', #
55     #'' => 'USER_3', #
56     #'' => 'USER_4', #
57     #'' => 'USER_5', #
58     #'' => 'USER_6', #
59     #'' => 'USER_7', #
60     #'' => 'USER_8', #
61     #'' => 'USER_9', #
62     #'' => 'USER_10', #
63     #'' => 'INFO_DIGITS', # VARCHAR(3) Info digits from the inbound leg, if applicable
64     #'' => 'RATE_INTERVAL', # TINYINT Rate interval used to bill the call (default: 60 seconds) ... create a new "upstream_granularity" field if we need this
65     #'' => 'DISCONNECT_CHARGE', # DECIMAL(15,4) The disconnect charge billed for the call
66     #'' => 'BILLING_DELAY', # SMALLINT Billing delay associated with the call
67     #'' => 'GRACE_PERIOD', # SMALLINT Grace period associated with the call
68     #'' => 'ACCOUNT_TYPE', # Account type from ACCOUNT_TYPES table
69   },
70   'batch_name' => 'fusionpbx',
71 );
72
73 1;