From 3ae50113ba75f6e1feb56106ff94b1417d40fb5e Mon Sep 17 00:00:00 2001
From: ivan <ivan>
Date: Sat, 30 May 2009 02:31:38 +0000
Subject: [PATCH] require svc_acct-usage_threshold to be set explicitly, don't
 default to 80%

---
 FS/FS/Conf.pm     | 2 +-
 FS/FS/svc_acct.pm | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index bcf7bbaee..df9d9066e 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1946,7 +1946,7 @@ worry that config_items is freeside-specific and icky.
   {
     'key'         => 'svc_acct-usage_threshold',
     'section'     => 'billing',
-    'description' => 'The threshold (expressed as percentage) of acct.seconds or acct.up|down|totalbytes at which a warning message is sent to a service holder.  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.  Defaults to 80.',
+    'description' => 'The threshold (expressed as percentage) of acct.seconds or acct.up|down|totalbytes at which a warning message is sent to a service holder.  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.',
     'type'        => 'text',
   },
 
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 03678c570..af490d9d0 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -558,12 +558,13 @@ sub insert {
       my %values = $part_pkg->usage_valuehash;
       my $multiplier = $conf->exists('svc_acct-usage_threshold') 
                          ? 1 - $conf->config('svc_acct-usage_threshold')/100
-                         : 0.20;
+                         : 0.20; #doesn't matter
 
       foreach ( keys %values ) {
         next if $self->getfield($_);
         $self->setfield( $_, $values{$_} );
-        $self->setfield( $_. '_threshold', int( $values{$_} * $multiplier ) );
+        $self->setfield( $_. '_threshold', int( $values{$_} * $multiplier ) )
+          if $conf->exists('svc_acct-usage_threshold');
       }
 
     }
-- 
2.20.1