X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=374cf7a12b085acf066aca83bb9a53515de507e9;hb=b70a4b7f41c84aefd7f273974db59e5c37fc368b;hp=92aa43f8e3bcc3122e775df21742c23183c6e58d;hpb=b2c8bade5422333233a28a91b8913598a015a7d4;p=freeside.git diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 92aa43f8e..374cf7a12 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -1931,6 +1931,24 @@ sub change { } +=item set_quantity QUANTITY + +Change the package's quantity field. This is the one package property +that can safely be changed without canceling and reordering the package +(because it doesn't affect tax eligibility). Returns an error or an +empty string. + +=cut + +sub set_quantity { + my $self = shift; + $self = $self->replace_old; # just to make sure + my $qty = shift; + ($qty =~ /^\d+$/ and $qty > 0) or return "bad package quantity $qty"; + $self->set('quantity' => $qty); + $self->replace; +} + use Storable 'thaw'; use MIME::Base64; sub process_bulk_cust_pkg { @@ -3337,6 +3355,12 @@ sub apply_usage { my $dbh = dbh; my $order = FS::Conf->new->config('cdr-minutes_priority'); + my $is_classnum; + if ( $classnum ) { + $is_classnum = ' part_pkg_usage_class.classnum = '.$classnum; + } else { + $is_classnum = ' part_pkg_usage_class.classnum IS NULL'; + } my @usage_recs = qsearch({ 'table' => 'cust_pkg_usage', 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)'. @@ -3346,7 +3370,7 @@ sub apply_usage { 'extra_sql' => " WHERE ( cust_pkg.pkgnum = $pkgnum OR ". " ( cust_pkg.custnum = $custnum AND ". " part_pkg_usage.shared IS NOT NULL ) ) AND ". - " part_pkg_usage_class.classnum = $classnum AND ". + $is_classnum . ' AND '. " cust_pkg_usage.minutes > 0", 'order_by' => " ORDER BY priority ASC", });