X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FBilling.pm;h=a15c990c975dd76b0e0218af395a7b84c58ca4e0;hp=5ce94fe1c832fa87078ae8be36289277507fd6fe;hb=e1c6b4af716fecad943bf282b50c0d459b986720;hpb=6767c91fd38ea1d8e609e57f6c46c2b9da233f70 diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index 5ce94fe1c..a15c990c9 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -564,7 +564,7 @@ sub bill { my $object = $event_fee->cust_event->cust_X; my $part_fee = $event_fee->part_fee; my $cust_bill; - if ( $object->isa('FS::cust_main') ) { + if ( $object->isa('FS::cust_main') or $object->isa('FS::cust_pkg') ) { # Not the real cust_bill object that will be inserted--in particular # there are no taxes yet. If you want to charge a fee on the total # invoice amount including taxes, you have to put the fee on the next @@ -575,6 +575,15 @@ sub bill { 'charged' => ${ $total_setup{$pass} } + ${ $total_recur{$pass} }, }); + + # If this is a package event, only apply the fee to line items + # from that package. + if ($object->isa('FS::cust_pkg')) { + $cust_bill->set('cust_bill_pkg', + [ grep { $_->pkgnum == $object->pkgnum } @cust_bill_pkg ] + ); + } + } elsif ( $object->isa('FS::cust_bill') ) { # simple case: applying the fee to a previous invoice (late fee, # etc.) @@ -591,7 +600,7 @@ sub bill { # also skip if it's disabled next if $part_fee->disabled eq 'Y'; # calculate the fee - my $fee_item = $event_fee->part_fee->lineitem($cust_bill); + my $fee_item = $part_fee->lineitem($cust_bill) or next; # link this so that we can clear the marker on inserting the line item $fee_item->set('cust_event_fee', $event_fee); push @fee_items, $fee_item;