X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcdr.pm;h=67c5c1c2ab36bbb025ec47cbc38ab6a87cb9e300;hp=8307b287e3ce87c51c4029ed0bf67a2329d009b0;hb=caf4bbf142bc25fa583e258ac3e1724a9eee8d5b;hpb=bd73a121f43bea3bf2ea576be109a680827676b9 diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index 8307b287e..67c5c1c2a 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -246,25 +246,7 @@ sub check { $self->billsec( $self->enddate - $self->answerdate ); } - my $conf = new FS::Conf; - - unless ( $self->charged_party ) { - - if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){ - - $self->charged_party( $self->accountcode ); - - } else { - - if ( $self->dst =~ /^(\+?1)?8[02-8]{2}/ ) { - $self->charged_party($self->dst); - } else { - $self->charged_party($self->src); - } - - } - - } + $self->set_charged_party; #check the foreign keys even? #do we want to outright *reject* the CDR? @@ -287,6 +269,43 @@ sub check { $self->SUPER::check; } +=item set_charged_party + +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. + +=cut + +sub set_charged_party { + my $self = shift; + + unless ( $self->charged_party ) { + + my $conf = new FS::Conf; + + if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){ + + $self->charged_party( $self->accountcode ); + + } else { + + if ( $self->dst =~ /^(\+?1)?8[02-8]{2}/ ) { + $self->charged_party($self->dst); + } else { + $self->charged_party($self->src); + } + + } + + } + +} + =item set_status_and_rated_price STATUS [ RATED_PRICE ] Sets the status to the provided string. If there is an error, returns the