+ if ( $basis eq 'usage' ) {
+
+ my %part_fee_usage = map { $_->classnum => $_ } $self->part_fee_usage;
+
+ foreach my $item (@items) { # cust_bill_pkg objects
+ my $usage_fee = 0;
+ $item->regularize_details;
+ my $details;
+ if ( $item->billpkgnum ) {
+ $details = [
+ qsearch('cust_bill_pkg_detail', { billpkgnum => $item->billpkgnum })
+ ];
+ } else {
+ $details = $item->get('details') || [];
+ }
+ foreach my $d (@$details) {
+ # if there's a usage fee defined for this class...
+ next if $d->amount eq '' # not a real usage detail
+ or $d->amount == 0 # zero charge, probably shouldn't charge fee
+ ;
+ my $p = $part_fee_usage{$d->classnum} or next;
+ $usage_fee += ($d->amount * $p->percent / 100)
+ + $p->amount;
+ # we'd create detail records here if we were doing that
+ }
+ # bypass @item_base entirely
+ push @item_fee, $usage_fee;
+ $amount += $usage_fee;
+ }
+
+ } # if $basis eq 'usage'
+