summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-11-29 23:18:09 +0000
committerivan <ivan>2009-11-29 23:18:09 +0000
commit5ea4ab534ffc97be4f7bd3cb6371ab930a30cbdc (patch)
tree4457fd49b27965d890c52a315200e1246c14c0d5
parent03b9780d9ce339f5d27ae899ea476232568bf2ef (diff)
add cust_pkg-change_pkgpart-bill_now option to bill the new package immediately on package changes. Useful for prepaid situations with RADIUS where an Expiration attribute base don the package must be present at all times. RT#6692
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/cust_pkg.pm12
2 files changed, 18 insertions, 1 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 96a7a664e..f3c1cb92f 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1893,6 +1893,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.',
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index e195ed87d..58cca6d53 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -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;
}