use strict;
use base qw( FS::o2m_Common FS::Record );
-use vars qw( $DEBUG );
use FS::Record qw( qsearch qsearchs );
use FS::pkg_class;
use FS::cust_bill_pkg_display;
use FS::agent;
use FS::part_fee_usage;
-$DEBUG = 0;
+our $DEBUG = 0;
+our $default_class;
=head1 NAME
=item disabled - 'Y' if the fee is disabled
=item classnum - the L<FS::pkg_class> that the fee belongs to, for reporting
+and placement on multisection invoices. Unlike packages, fees I<must> be
+assigned to a class; they will default to class named "Fees", which belongs
+to the same invoice section that normally contains taxes.
=item taxable - 'Y' if this fee should be considered a taxable sale.
Currently, taxable fees will be treated like they exist at the customer's
$self->set('amount', 0) unless $self->amount;
$self->set('percent', 0) unless $self->percent;
+ $default_class ||= qsearchs('pkg_class', { classname => 'Fees' })
+ or die "default package fee class not found; run freeside-upgrade to continue.\n";
+
+ if (!$self->get('classnum')) {
+ $self->set('classnum', $default_class->classnum);
+ }
+
my $error =
$self->ut_numbern('feepart')
|| $self->ut_textn('comment')
# if this is a percentage fee and has line item fractions,
# adjust them to be proportional and to add up correctly.
- if ( @item_base ) {
+ # don't try this if we're charging on a zero-amount set of line items.
+ if ( scalar(@item_base) > 0 and $total_base > 0 ) {
my $cents = $amount * 100;
# not necessarily the same as percent
my $multiplier = $amount / $total_base;