X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg.pm;h=826569b2507c3c1990b24e0c9d759c07b1a0ea07;hb=fd4322f01b8c53b3f1f9e54ca15184930b0443de;hp=20c8e5a553ac80cb903352a5295e205922195625;hpb=962cd26e8e33bf3653cca439dbd9bd52f46bad29;p=freeside.git diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index 20c8e5a55..826569b25 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -581,9 +581,10 @@ appropriate FS::cust_bill_pkg_display objects. Options are passed as a list of name/value pairs. Options are: -part_pkg: FS::part_pkg object from the +part_pkg: FS::part_pkg object from this line item's package. -real_pkgpart: if this line item comes from a bundled package, the pkgpart of the owning package. Otherwise the same as the part_pkg's pkgpart above. +real_pkgpart: if this line item comes from a bundled package, the pkgpart +of the owning package. Otherwise the same as the part_pkg's pkgpart above. =cut @@ -594,13 +595,19 @@ sub set_display { my $conf = new FS::Conf; + # whether to break this down into setup/recur/usage my $separate = $conf->exists('separate_usage'); + my $usage_mandate = $part_pkg->option('usage_mandate', 'Hush!') || $cust_pkg->part_pkg->option('usage_mandate', 'Hush!'); # or use the category from $opt{'part_pkg'} if its not bundled? my $categoryname = $cust_pkg->part_pkg->categoryname; + # if we don't have to separate setup/recur/usage, or put this in a + # package-specific section, or display a usage summary, then don't + # even create one of these. The item will just display in the unnamed + # section as a single line plus details. return $self->set('display', []) unless $separate || $categoryname || $usage_mandate; @@ -608,34 +615,46 @@ sub set_display { my %hash = ( 'section' => $categoryname ); + # whether to put usage details in a separate section, and if so, which one my $usage_section = $part_pkg->option('usage_section', 'Hush!') || $cust_pkg->part_pkg->option('usage_section', 'Hush!'); + # whether to show a usage summary line (total usage charges, no details) my $summary = $part_pkg->option('summarize_usage', 'Hush!') || $cust_pkg->part_pkg->option('summarize_usage', 'Hush!'); if ( $separate ) { + # create lines for setup and (non-usage) recur, in the main section push @display, new FS::cust_bill_pkg_display { type => 'S', %hash }; push @display, new FS::cust_bill_pkg_display { type => 'R', %hash }; } else { + # display everything in a single line push @display, new FS::cust_bill_pkg_display { type => '', %hash, + # and if usage_mandate is enabled, hide details + # (this only works on multisection invoices...) ( ( $usage_mandate ) ? ( 'summary' => 'Y' ) : () ), }; } if ($separate && $usage_section && $summary) { + # create a line for the usage summary in the main section push @display, new FS::cust_bill_pkg_display { type => 'U', summary => 'Y', %hash, }; } + if ($usage_mandate || ($usage_section && $summary) ) { $hash{post_total} = 'Y'; } if ($separate || $usage_mandate) { + # show call details for this line item in the usage section. + # if usage_mandate is on, this will display below the section subtotal. + # this also happens if usage is in a separate section and there's a + # summary in the main section, though I'm not sure why. $hash{section} = $usage_section if $usage_section; push @display, new FS::cust_bill_pkg_display { type => 'U', %hash }; } @@ -894,7 +913,7 @@ sub paid_sql { my $paid = "( SELECT COALESCE(SUM(cust_bill_pay_pkg.amount),0) FROM cust_bill_pay_pkg JOIN cust_bill_pay USING (billpaynum) WHERE cust_bill_pay_pkg.billpkgnum = cust_bill_pkg.billpkgnum - $s $e$setuprecur )"; + $s $e $setuprecur )"; if ( $opt{no_usage} ) { # cap the amount paid at the sum of non-usage charges,