4 use Date::Parse 'str2time';
7 FS::cdr::Import->dbi_import(
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', #
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', #
31 #'dst' => sub { $_[0]->{COUNTRY_CODE}. $_[0]->{NPA}.
32 # $_[0]->{NXX}. $_[0]->{LOCAL_NUMBER};
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'}
51 #'' => 'SALES_GROUP', #
53 #'userfield' => 'USER_1', #
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
70 'batch_name' => 'fusionpbx',