Difference between revisions of "Freeside:1.9:Documentation:Developer/FS/cdr"
From Freeside
(import from POD) |
(import from POD) |
||
Line 23: | Line 23: | ||
==METHODS== | ==METHODS== | ||
; new HASHREF | ; new HASHREF | ||
− | :Creates a new CDR. To add the CDR to the database, see [[ | + | :Creates a new CDR. To add the CDR to the database, see [[#insert|"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. | :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. |
Revision as of 17:23, 3 October 2007
NAME
FS::cdr - Object methods for cdr records
SYNOPSIS
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;
DESCRIPTION
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:
- acctid - primary key; calldate - Call timestamp (SQL timestamp); clid - Caller*ID with text; src - Caller*ID number / Source number; dst - Destination extension; dcontext - Destination context; channel - Channel used; dstchannel - Destination channel if appropriate; lastapp - Last application if appropriate; lastdata - Last application data; startdate - Start of call (UNIX-style integer timestamp); answerdate - Answer time of call (UNIX-style integer timestamp); enddate - End time of call (UNIX-style integer timestamp); duration - Total time in system, in seconds; billsec - Total time call is up, in seconds; disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY; amaflags - What flags to use: BILL, IGNORE etc, specified on a per channel basis like accountcode.; accountcode - CDR account number to use: account; uniqueid - Unique channel identifier (Unitel/RSLCOM Event ID); userfield - CDR user-defined field; cdr_type - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8); charged_party - Service number to be billed; upstream_currency - Wholesale currency from upstream; upstream_price - Wholesale price from upstream; upstream_rateplanid - Upstream rate plan ID; rated_price - Rated (or re-rated) price; distance - km (need units field?); islocal - Local - 1, Non Local = 0; calltypenum - Type of call - see FS::cdr_calltype; description - Description (cdr_type 7&8 only) (used for cust_bill_pkg.itemdesc); quantity - Number of items (cdr_type 7&8 only); carrierid - Upstream Carrier ID (see FS::cdr_carrier); upstream_rateid - Upstream Rate ID; svcnum - Link to customer service (see FS::cust_svc); freesidestatus - NULL, done (or something)
METHODS
- new HASHREF
- 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.
- insert
- Adds this record to the database. If there is an error, returns the error, otherwise returns false.
- delete
- Delete this record from the database.
- replace OLD_RECORD
- Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
- check
- 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.
- set_status_and_rated_price STATUS [ RATED_PRICE ]
- Sets the status to the provided string. If there is an error, returns the error, otherwise returns false.
- calldate_unix
- Parses the calldate in SQL string format and returns a UNIX timestamp.
- startdate_sql
- Parses the startdate in UNIX timestamp format and returns a string in SQL format.
- cdr_carrier
- Returns the FS::cdr_carrier object associated with this CDR, or false if no carrierid is defined.
- carriername
- Returns the carrier name (see FS::cdr_carrier), or the empty string if no FS::cdr_carrier object is assocated with this CDR.
- cdr_calltype
- Returns the FS::cdr_calltype object associated with this CDR, or false if no calltypenum is defined.
- calltypename
- Returns the call type name (see FS::cdr_calltype), or the empty string if no FS::cdr_calltype object is assocated with this CDR.
- cdr_upstream_rate
- Returns the upstream rate mapping (see FS::cdr_upstream_rate), or the empty string if no FS::cdr_upstream_rate object is associated with this CDR.
- _convergent_format COLUMN [ COUNTRYCODE ]
- Returns the number in COLUMN formatted as follows:
- If the country code does not match COUNTRYCODE (default "61"), it is returned unchanged.
- If the country code does match COUNTRYCODE (default "61"), it is removed. In addiiton, "0" is prepended unless the number starts with 13, 18 or 19. (???)
- downstream_csv [ OPTION => VALUE, ... ]
CLASS METHODS
- batch_import
BUGS
SEE ALSO
FS::Record, schema.html from the base documentation.