X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Frate_detail.pm;h=89333540121f86ef53a222b9f3f72d3da79319f1;hp=b7b23babe52843934c3cc5e4edbc36c30f1fbbf0;hb=HEAD;hpb=63a268637b2d51a8766412617724b9436439deb6 diff --git a/FS/FS/rate_detail.pm b/FS/FS/rate_detail.pm index b7b23babe..893335401 100644 --- a/FS/FS/rate_detail.pm +++ b/FS/FS/rate_detail.pm @@ -1,13 +1,13 @@ package FS::rate_detail; +use base qw(FS::Record); use strict; -use vars qw( @ISA $DEBUG $me ); +use vars qw( $DEBUG $me ); +use Tie::IxHash; use FS::Record qw( qsearch qsearchs dbh ); use FS::rate; use FS::rate_region; -use Tie::IxHash; - -@ISA = qw(FS::Record); +use FS::rate_time; $DEBUG = 0; $me = '[FS::rate_detail]'; @@ -54,6 +54,19 @@ inherits from FS::Record. The following fields are currently supported: =item classnum - usage class (see L) if any for this rate +=item ratetimenum - rating time period (see L) if any for this rate + +=item region_group - Group in region group for rate plan + +=item upstream_mult_charge - the multiplier to apply to the upstream price. +Defaults to zero, and should stay zero unless this rate is intended to include +a markup on pre-rated CDRs. + +=item upstream_mult_cost - the multiplier to apply to the upstream price to +calculate the wholesale cost. + =back =head1 METHODS @@ -118,16 +131,24 @@ sub check { $self->ut_numbern('ratedetailnum') || $self->ut_foreign_key('ratenum', 'rate', 'ratenum') || $self->ut_foreign_keyn('orig_regionnum', 'rate_region', 'regionnum' ) - || $self->ut_foreign_key('dest_regionnum', 'rate_region', 'regionnum' ) + || $self->ut_foreign_keyn('dest_regionnum', 'rate_region', 'regionnum' ) + || $self->ut_foreign_keyn('cdrtypenum', 'cdr_type', 'cdrtypenum' ) || $self->ut_number('min_included') #|| $self->ut_money('min_charge') #good enough for now... + || $self->ut_floatn('conn_charge') + || $self->ut_floatn('conn_cost') || $self->ut_float('min_charge') + || $self->ut_floatn('min_cost') || $self->ut_number('sec_granularity') || $self->ut_foreign_keyn('classnum', 'usage_class', 'classnum' ) + || $self->ut_enum('region_group', [ '', 'Y' ]) + + || $self->ut_floatn('upstream_mult_charge') + || $self->ut_floatn('upstream_mult_cost') ; return $error if $error; @@ -139,13 +160,6 @@ sub check { Returns the parent call plan (see L) associated with this call plan rate. -=cut - -sub rate { - my $self = shift; - qsearchs('rate', { 'ratenum' => $self->ratenum } ); -} - =item orig_region Returns the origination region (see L) associated with this @@ -179,10 +193,13 @@ with this call plan rate. sub dest_regionname { my $self = shift; - $self->dest_region->regionname; + my $dest_region = $self->dest_region; + $dest_region ? $dest_region->regionname : 'Global default'; + # should be 'Anywhere' or something, to indicate that it's the + # cross-region default } -=item dest_regionname +=item dest_prefixes_short Returns a short list of the prefixes for the destination region (see L) associated with this call plan rate. @@ -191,7 +208,32 @@ Returns a short list of the prefixes for the destination region sub dest_prefixes_short { my $self = shift; - $self->dest_region->prefixes_short; + my $dest_region = $self->dest_region; + $dest_region ? $dest_region->prefixes_short : ''; +} + +=item rate_time + +Returns the L object associated with this call +plan rate, if there is one. + +=cut + +sub rate_time { + my $self = shift; + $self->ratetimenum ? FS::rate_time->by_key($self->ratetimenum) : (); +} + +=item rate_time_name + +Returns the I field of the L object +associated with this rate plan. + +=cut + +sub rate_time_name { + my $self = shift; + $self->ratetimenum ? $self->rate_time->ratetimename : '(any time)'; } =item classname @@ -207,6 +249,20 @@ sub classname { $usage_class ? $usage_class->classname : ''; } +=item cdrtypename + +Returns the name of the CDR type (see Lcdrtypenum or return ''; + my $cdr_type = qsearchs('cdr_type', { cdrtypenum => $cdrtypenum }); + return $cdr_type ? $cdr_type->cdrtypename : $cdrtypenum; +} =back @@ -232,9 +288,32 @@ sub granularities { %granularities; } -use Storable qw(thaw); +=item conn_secs + + Returns an (ordered) hash of conn_sec => name pairs + +=cut + +tie my %conn_secs, 'Tie::IxHash', + '0' => 'connection', + '1' => 'first second', + '6' => 'first 6 seconds', + '30' => 'first 30 seconds', # '1/2 minute', + '60' => 'first minute', + '120' => 'first 2 minutes', + '180' => 'first 3 minutes', + '300' => 'first 5 minutes', +; + +sub conn_secs { + %conn_secs; +} + +=item process_edit_import + +=cut + use Data::Dumper; -use MIME::Base64; sub process_edit_import { my $job = shift; @@ -273,7 +352,7 @@ sub process_edit_import { my @pass_params = @{ $opt->{params} }; my %formats = %{ $opt->{formats} }; - my $param = thaw(decode_base64(shift)); + my $param = shift; warn Dumper($param) if $DEBUG; my $files = $param->{'uploaded_files'} @@ -311,6 +390,10 @@ sub process_edit_import { } +=item edit_import + +=cut + #false laziness w/ #FS::Record::batch_import, grep "edit_import" for differences #could be turned into callbacks or something use Text::CSV_XS; @@ -569,8 +652,6 @@ sub edit_import { } - - =back =head1 BUGS