% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>
FS::cdr - Object methods for cdr records
use FS::cdr;
$record = new FS::cdr \%hash;
$record = new FS::cdr { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
An FS::cdr object represents an Call Data Record, typically from a telephony system or provider of some sort. FS::cdr inherits from FS::Record. The following fields are currently supported:
Creates a new CDR. To add the CDR to the database, see "insert".
Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the hash method.
Adds this record to the database. If there is an error, returns the error, otherwise returns false.
Delete this record from the database.
Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
Checks all fields to make sure this is a valid CDR. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
Note: Unlike most types of records, we don't want to "reject" a CDR and we want to process them as quickly as possible, so we allow the database to check most of the data.
Returns true when the cdr represents a toll free number and false otherwise.
By default, inspects the dst field, but an optional column name can be passed to inspect other field.
If the charged_party field is already set, does nothing. Otherwise:
If the cdr-charged_party-accountcode config option is enabled, sets the charged_party to the accountcode.
Otherwise sets the charged_party normally: to the src field in most cases, or to the dst field if it is a toll free number.
Sets the status to the provided string. If there is an error, returns the error, otherwise returns false.
If status is being changed from 'rated' to some other status, also removes any usage allocations to this CDR.
Sets the status and rated price.
Available options are: inbound, rated_pretty_dst, rated_regionname, rated_seconds, rated_minutes, rated_granularity, rated_ratedetailnum, rated_classnum, rated_ratename. If rated_ratedetailnum is provided, will also set a recalculated "rate_cost" in the rated_cost field after the other fields are set (does not work with inbound.)
If there is an error, returns the error, otherwise returns false.
Returns two scalars, the countrycode and the rest of the number.
Options are passed as name-value pairs. Currently available options are:
The column containing the number to be parsed. Defaults to dst.
The digits for international dialing. Defaults to '011' The value '+' is always recognized.
The digits for domestic long distance dialing. Defaults to '1'
Rates this CDR according and sets the status to 'rated'.
Available options are: part_pkg, svcnum, plan_included_min, detail_included_min_hashref.
part_pkg is required.
If svcnum is specified, will also associate this CDR with the specified svcnum.
plan_included_min should be set to a scalar reference of the number of included minutes and will be decremented by the rated minutes of this CDR.
detail_included_min_hashref should be set to an empty hashref at the start of a month's rating and then preserved across CDRs.
Rates an already-rated CDR according to the cost fields from the rate plan.
Returns the amount.
Parses the calldate in SQL string format and returns a UNIX timestamp.
Parses the startdate in UNIX timestamp format and returns a string in SQL format.
Returns the FS::cdr_carrier object associated with this CDR, or false if no carrierid is defined.
Returns the carrier name (see FS::cdr_carrier), or the empty string if no FS::cdr_carrier object is assocated with this CDR.
Returns the FS::cdr_calltype object associated with this CDR, or false if no calltypenum is defined.
Returns the call type name (see FS::cdr_calltype), or the empty string if no FS::cdr_calltype object is assocated with this CDR.
Returns a string of formatted call details for display on an invoice.
Options:
format
charge - override the 'rated_price' field of the CDR
seconds - override the 'billsec' field of the CDR
count - number of usage events included in this record, for summary formats
ratename - name of the rate table used to rate this call
granularity
Returns an ordered list of key value pairs containing invoice format names as keys (for use with part_pkg::voip_cdr) and "pretty" format names as values.
Returns a scalar containing the CSV column header for invoice format FORMAT.
Clears cdr and any associated cdr_termination statuses - used for CDR reprocessing.
Returns an ordered list of key value pairs containing import format names as keys (for use with batch_import) and "pretty" format names as values.
Imports CDR records. Available options are:
Returns an SQL condition to search for CDRs with an IP address within RANGE. FIELD is either 'src_ip_addr' or 'dst_ip_addr'. RANGE should be in the form "a.b.c.d-e.f.g.h' (dotted quads), where any of the leftmost octets of the second address can be omitted if they're the same as the first address.
FS::Record, schema.html from the base documentation.