add cust_pkg-change_pkgpart-bill_now option to bill the new package immediately on...
authorivan <ivan>
Sun, 29 Nov 2009 23:18:07 +0000 (23:18 +0000)
committerivan <ivan>
Sun, 29 Nov 2009 23:18:07 +0000 (23:18 +0000)
FS/FS/Conf.pm
FS/FS/cust_pkg.pm

index d186d04..3aaa667 100644 (file)
@@ -1911,6 +1911,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'cust_pkg-change_pkgpart-bill_now',
+    'section'     => '',
+    'description' => "When changing packages, bill the new package immediately.  Useful for prepaid situations with RADIUS where an Expiration attribute base don the package must be present at all times.",
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'disable_autoreverse',
     'section'     => 'BIND',
     'description' => 'Disable automatic synchronization of reverse-ARPA entries.',
index fbd6a13..8bbf376 100644 (file)
@@ -1207,11 +1207,21 @@ sub change {
   #Good to go, cancel old package.
   $error = $self->cancel( quiet=>1 );
   if ($error) {
-    $dbh->rollback;
+    $dbh->rollback if $oldAutoCommit;
     return $error;
   }
 
+  if ( $conf->exists('cust_pkg-change_pkgpart-bill_now') ) {
+    #$self->cust_main
+    my $error = $cust_pkg->cust_main->bill( 'pkg_list' => [ $cust_pkg ] );
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return $error;
+    }
+  }
+
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
   $cust_pkg;
 
 }