[freeside-commits] freeside/FS/FS svc_acct.pm,1.260,1.261

Ivan,,, ivan at wavetail.420.am
Fri May 29 20:14:15 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv12047

Modified Files:
	svc_acct.pm 
Log Message:
add ability for prepaid packages to have usage limits and cancel if they're hit, RT#4995

Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.260
retrieving revision 1.261
diff -u -d -r1.260 -r1.261
--- svc_acct.pm	30 May 2009 02:31:39 -0000	1.260
+++ svc_acct.pm	30 May 2009 03:14:12 -0000	1.261
@@ -1772,6 +1772,28 @@
   die "Can't update $column for svcnum". $self->svcnum
     if $rv == 0;
 
+  #overlimit_action eq 'cancel' handling
+  my $cust_pkg = $self->cust_svc->cust_pkg;
+  if ( $cust_pkg
+       && $cust_pkg->part_pkg->option('overlimit_action', 1) eq 'cancel' 
+       && $op eq '-' && &{$op2condition{$op}}($self, $column, $amount)
+     )
+  {
+
+    my $error = $cust_pkg->cancel; #XXX should have a reason
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return "Error cancelling: $error";
+    }
+
+    #nothing else is relevant if we're cancelling, so commit & return success
+    warn "$me update successful; committing\n"
+      if $DEBUG;
+    $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+    return '';
+
+  }
+
   my $action = $op2action{$op};
 
   if ( &{$op2condition{$op}}($self, $column, $amount) &&



More information about the freeside-commits mailing list