[freeside-commits] freeside/FS/FS rate.pm,1.7,1.8
Ivan,,,
ivan at wavetail.420.am
Fri Oct 24 14:31:40 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv10740/FS/FS
Modified Files:
rate.pm
Log Message:
adding prepaid self-service hooks, RT#4100
Index: rate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/rate.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rate.pm 29 Jan 2007 16:16:49 -0000 1.7
+++ rate.pm 24 Oct 2008 21:31:37 -0000 1.8
@@ -269,16 +269,52 @@
$self->SUPER::check;
}
-=item dest_detail REGIONNUM | RATE_REGION_OBJECTD
+=item dest_detail REGIONNUM | RATE_REGION_OBJECTD | HASHREF
Returns the rate detail (see L<FS::rate_detail>) for this rate to the
-specificed destination.
+specificed destination. Destination can be specified as an FS::rate_detail
+object or regionnum (see L<FS::rate_detail>), or as a hashref with two keys:
+I<countrycode> and I<phonenum>.
=cut
sub dest_detail {
my $self = shift;
- my $regionnum = ref($_[0]) ? shift->regionnum : shift;
+
+ my $regionnum;
+ if ( ref($_[0]) eq 'HASH' ) {
+
+ my $countrycode = $_->{'countrycode'};
+ my $phonenum = $_->{'phonenum'};
+
+ #find a rate prefix, first look at most specific (4 digits) then 3, etc.,
+ # finally trying the country code only
+ my $rate_prefix = '';
+ for my $len ( reverse(1..6) ) {
+ $rate_prefix = qsearchs('rate_prefix', {
+ 'countrycode' => $countrycode,
+ #'npa' => { op=> 'LIKE', value=> substr($number, 0, $len) }
+ 'npa' => substr($phonenum, 0, $len),
+ } ) and last;
+ }
+ $rate_prefix ||= qsearchs('rate_prefix', {
+ 'countrycode' => $countrycode,
+ 'npa' => '',
+ });
+
+ #
+ #die "Can't find rate for call $to_or_from +$countrycode $number\n"
+ die "Can't find rate for +$countrycode $phonenum\n"
+ unless $rate_prefix;
+
+ $regionnum = $rate_prefix->regionnum;
+
+ #$rate_region = $rate_prefix->rate_region;
+
+ } else {
+ $regionnum = ref($_[0]) ? shift->regionnum : shift;
+ }
+
qsearchs( 'rate_detail', { 'ratenum' => $self->ratenum,
'dest_regionnum' => $regionnum, } );
}
More information about the freeside-commits
mailing list