diff options
| author | levinse <levinse> | 2011-05-05 00:53:41 +0000 | 
|---|---|---|
| committer | levinse <levinse> | 2011-05-05 00:53:41 +0000 | 
| commit | 5e9dda2c5757c63ac51f53e651977f7ea41006ed (patch) | |
| tree | d6fa36a2e0056a6529fef2c230d4bd2faa2cbf33 | |
| parent | 3e01db10352a025538da91ec103b2c2ce562b11b (diff) | |
add a CDR import format to allow importing of some Freeside-generated CDRs, RT12078
| -rw-r--r-- | FS/FS/cdr/freeside_description_default.pm | 66 | 
1 files changed, 66 insertions, 0 deletions
| diff --git a/FS/FS/cdr/freeside_description_default.pm b/FS/FS/cdr/freeside_description_default.pm new file mode 100644 index 000000000..bc4e89f54 --- /dev/null +++ b/FS/FS/cdr/freeside_description_default.pm @@ -0,0 +1,66 @@ +package FS::cdr::freeside_description_default; + +use strict; +use vars qw( @ISA %info $tmp_mon $tmp_mday $tmp_year ); +use Time::Local; +use FS::cdr; + +@ISA = qw(FS::cdr); + +%info = ( +  'name'          => 'Freeside default with description field as destination', +  'weight'        => 25, +  'header'        => 1, +  'import_fields' => [ +    'charged_party',     # Billed number +    'src',               # Caller + +    # Date (YYYY/MM/DD) +    sub { my($cdr, $date) = @_; +          $date =~ /^(\d\d(\d\d)?)\/(\d{1,2})\/(\d{1,2})$/ +            or die "unparsable date: $date"; #maybe we shouldn't die... +          ($tmp_mday, $tmp_mon, $tmp_year) = ( $4, $3-1, $1 ); +        }, + +    # Time (HH:MM:SS (AM/PM)) +    sub { my($cdr, $time) = @_; +          $time =~ /^(\d{1,2}):(\d{1,2}):(\d{1,2}) (AM|PM)$/ +            or die "unparsable time: $time"; #maybe we shouldn't die... +          my $hour = $1; +          $hour += 12 if $4 eq 'PM'; +          $cdr->startdate( +            timelocal($3, $2, $hour ,$tmp_mday, $tmp_mon, $tmp_year) +          ); +        }, + +    # Number +    sub { +        my($cdr, $number) = @_; +        $number =~ /(\d+)$/  +            or die "unparsable number: $number"; #maybe we shouldn't die... +        $cdr->dst($1); +    },            + +    'description',      # Destination (regionname) + +    # Duration +    sub { +        my($cdr, $duration) = @_; +        $duration =~ /^(\d{1,2})m (\d{1,2})s$/ +            or die "unparsable duration: $duration"; #maybe we shouldn't die... +        my $sec = $1*60 + $2; +        $cdr->duration($sec); +        $cdr->billsec($sec); +    }, + +    # Price +    sub { +        my($cdr, $amount) = @_; +        $amount =~ s/\$//g; +        $cdr->upstream_price($amount); +    } + +  ], +); + + | 
