#use FS::rate;
use FS::rate_prefix;
-@ISA = qw(FS::part_pkg);
+@ISA = qw(FS::part_pkg::flat);
-$DEBUG = 0;
+$DEBUG = 1;
%info = (
- 'name' => 'VoIP rating by plan of CDR records in an SQL RADIUS radacct table',
- 'fields' => {
- 'setup_fee' => { 'name' => 'Setup fee for this package',
- 'default' => 0,
- },
- 'recur_flat' => { 'name' => 'Base monthly charge for this package',
- 'default' => 0,
- },
- 'ratenum' => { 'name' => 'Rate plan',
- 'type' => 'select',
- 'select_table' => 'rate',
- 'select_key' => 'ratenum',
- 'select_label' => 'ratename',
- },
- },
- 'fieldorder' => [qw( setup_fee recur_flat ratenum )],
- 'weight' => 40,
+ 'name' => 'VoIP rating by plan of CDR records in an SQL RADIUS radacct table',
+ 'fields' => {
+ 'setup_fee' => { 'name' => 'Setup fee for this package',
+ 'default' => 0,
+ },
+ 'recur_flat' => { 'name' => 'Base monthly charge for this package',
+ 'default' => 0,
+ },
+ 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
+ ' of service at cancellation',
+ 'type' => 'checkbox',
+ },
+ 'ratenum' => { 'name' => 'Rate plan',
+ 'type' => 'select',
+ 'select_table' => 'rate',
+ 'select_key' => 'ratenum',
+ 'select_label' => 'ratename',
+ },
+ 'ignore_unrateable' => { 'name' => 'Ignore calls for which not rate prefix can be found (otherwise they are fatal)',
+ 'type' => 'checkbox',
+ },
+ },
+ 'fieldorder' => [qw( setup_fee recur_flat unused_credit ratenum ignore_unrateable )],
+ 'weight' => 40,
);
sub calc_setup {
$countrycode = '1';
}
+ warn "rating call to +$countrycode $dest" if $DEBUG;
+
#find a rate prefix, first look at most specific (4 digits) then 3, etc.,
# finally trying the country code only
my $rate_prefix = '';
'countrycode' => $countrycode,
'npa' => '',
});
- die "Can't find rate for call to countrycode $countrycode number $dest\n"
- unless $rate_prefix;
+
+ unless ( $rate_prefix ) {
+ if ( $self->option('ignore_unrateable') ) {
+ warn " skipping unrateable call to +$countrycode $dest";
+ next;
+ } else {
+ die "Can't find rate for call to +$countrycode $dest\n"
+ }
+ }
my $regionnum = $rate_prefix->regionnum;
'dest_regionnum' => $regionnum,
} );
+ warn " found rate for regionnum $regionnum ".
+ "and rate detail $rate_detail"
+ if $DEBUG;
+
###
# find the price and add detail to the invoice
###
$charges += $charge;
}
+ warn " adding details on charge to invoice: ".
+ join(' - ',
+ "+$countrycode $dest",
+ $rate_prefix->rate_region->regionname,
+ $minutes.'m',
+ '$'.$charge,
+ )
+ if $DEBUG;
+
push @$details,
#[
join(' - ',
0;
}
+sub base_recur {
+ my($self, $cust_pkg) = @_;
+ $self->option('recur_flat');
+}
+
1;