X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_fee.pm;h=370005c1577065c73463fd44ee9b33d9d585f897;hb=6d47b55c98b1a8e145a4b63579e148241c65b6ed;hp=186fb346efef84e17c74374687c16d88b9f8a023;hpb=a0e00fa0547e99893c735ab3dbdacdb2bb054f5a;p=freeside.git diff --git a/FS/FS/part_fee.pm b/FS/FS/part_fee.pm index 186fb346e..370005c15 100644 --- a/FS/FS/part_fee.pm +++ b/FS/FS/part_fee.pm @@ -4,6 +4,7 @@ use strict; use base qw( FS::o2m_Common FS::Record ); use vars qw( $DEBUG ); use FS::Record qw( qsearch qsearchs ); +use FS::cust_bill_pkg_display; $DEBUG = 0; @@ -265,6 +266,8 @@ sub lineitem { ' FROM cust_bill_pkg WHERE billpkgnum = ?'; @item_base = map { FS::Record->scalar_sql($sql, $_->billpkgnum) } @items; + + $amount += $total_base * $self->percent / 100; } } else { # the fee applies to _this_ invoice. It has no payments or credits, so @@ -275,6 +278,8 @@ sub lineitem { $total_base = $cust_bill->charged; @item_base = map { $_->setup + $_->recur } @items; + + $amount += $total_base * $self->percent / 100; } } @@ -371,11 +376,19 @@ sub lineitem { # set the amount that we'll charge $cust_bill_pkg->set( $self->setuprecur, $amount ); + # create display record + my $categoryname = ''; if ( $self->classnum ) { my $pkg_category = $self->pkg_class->pkg_category; - $cust_bill_pkg->set('section' => $pkg_category->categoryname) - if $pkg_category; + $categoryname = $pkg_category->categoryname if $pkg_category; } + my $displaytype = ($self->setuprecur eq 'setup') ? 'S' : 'R'; + my $display = FS::cust_bill_pkg_display->new({ + type => $displaytype, + section => $categoryname, + # post_total? summary? who the hell knows? + }); + $cust_bill_pkg->set('display', [ $display ]); # if this is a percentage fee and has line item fractions, # adjust them to be proportional and to add up correctly. @@ -480,6 +493,19 @@ sub tax_rates { return @taxes; } +=item categoryname + +Returns the package category name, or the empty string if there is no package +category. + +=cut + +sub categoryname { + my $self = shift; + my $pkg_class = $self->pkg_class; + $pkg_class ? $pkg_class->categoryname : ''; +} + sub part_pkg_taxoverride {} # we don't do overrides here sub has_taxproduct {