+my $set_default_detail = sub {
+ my ($cgi, $rate_detail) = @_;
+ if (!$rate_detail->dest_regionnum and !$rate_detail->cdrtypenum) {
+ # then this is a global default rate
+ # default_detailnum is no longer used, but maintain it anyway (and point
+ # it at the one with null cdrtypenum)
+ my $rate = $rate_detail->rate;
+ $rate->set('default_detailnum' => $rate_detail->ratedetailnum);
+ my $error = $rate->replace;
+ die "$error (setting default rate)\n" if $error;
+ }
+};
+