summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main/Billing.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-02-27 14:04:52 -0800
committerMark Wells <mark@freeside.biz>2014-02-27 15:08:21 -0800
commita0e00fa0547e99893c735ab3dbdacdb2bb054f5a (patch)
tree2784c6564ab363606a606fbbac56539006bb16a1 /FS/FS/cust_main/Billing.pm
parent55190e4a18ff318cf2a0ac2eb6abaf7a3b95e087 (diff)
package fees and usage-based fees, #27687, #25899
Diffstat (limited to 'FS/FS/cust_main/Billing.pm')
-rw-r--r--FS/FS/cust_main/Billing.pm13
1 files changed, 11 insertions, 2 deletions
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index a7e7d19..8d38992 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;