use Tie::IxHash;
use Time::Local qw( timelocal timelocal_nocheck );
use MIME::Entity;
-use FS::UID qw( getotaker dbh driver_name );
+use FS::UID qw( dbh driver_name );
use FS::Misc qw( send_email );
use FS::Record qw( qsearch qsearchs fields );
use FS::CurrentUser;
}
+=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 {
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)'.
'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",
});