[freeside-commits] freeside/FS/FS svc_acct.pm, 1.217.2.26, 1.217.2.27

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


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

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	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.217.2.26
retrieving revision 1.217.2.27
diff -u -d -r1.217.2.26 -r1.217.2.27
--- svc_acct.pm	30 May 2009 02:31:38 -0000	1.217.2.26
+++ svc_acct.pm	30 May 2009 03:14:35 -0000	1.217.2.27
@@ -1687,6 +1687,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