- } #if $conf->exists('enable_taxproducts')
-
- # XXX all this goes away with cust_bill_pay refactor
-
- $cust_bill_pkg{setup} = $cust_bill_pkg if $cust_bill_pkg->setup;
- $cust_bill_pkg{recur} = $cust_bill_pkg if $cust_bill_pkg->recur;
-
- #split setup and recur
- if ($cust_bill_pkg->setup && $cust_bill_pkg->recur) {
- my $cust_bill_pkg_recur = new FS::cust_bill_pkg { $cust_bill_pkg->hash };
- $cust_bill_pkg->set('details', []);
- $cust_bill_pkg->recur(0);
- $cust_bill_pkg->type('');
- $cust_bill_pkg{recur} = $cust_bill_pkg_recur;
- }
-
- #split usage from recur
- my $usage = $cust_bill_pkg->usage;
- if ($usage) {
- my $cust_bill_pkg_usage =
- new FS::cust_bill_pkg { $cust_bill_pkg{recur}->hash };
- $cust_bill_pkg_usage->recur($usage);
- $cust_bill_pkg{recur}->recur( $cust_bill_pkg{recur}->recur - $usage );
- $cust_bill_pkg{recur}->type( '' );
- $cust_bill_pkg{''} = $cust_bill_pkg_usage;
- }
-
- #subdivide usage by usage_class
- if (exists($cust_bill_pkg{''})) {
- foreach my $class (grep {$_} @classes) {
- my $usage = $cust_bill_pkg{''}->usage($class);
- my $cust_bill_pkg_usage =
- new FS::cust_bill_pkg { $cust_bill_pkg{''}->hash };
- $cust_bill_pkg_usage->recur($usage);
- $cust_bill_pkg{''}->recur( $cust_bill_pkg{''}->recur - $usage );
- $cust_bill_pkg{$class} = $cust_bill_pkg_usage;
+ } #if $conf->exists('enable_taxproducts') ...
+
+ my @display = ();
+ if ( $conf->exists('separate_usage') ) {
+ my $section = $cust_pkg->part_pkg->option('usage_section', 'Hush!');
+ my $summary = $cust_pkg->part_pkg->option('summarize_usage', 'Hush!');
+ push @display, new FS::cust_bill_pkg_display { type => 'S' };
+ push @display, new FS::cust_bill_pkg_display { type => 'R' };
+ push @display, new FS::cust_bill_pkg_display { type => 'U',
+ section => $section
+ };
+ if ($section && $summary) {
+ $display[2]->post_total('Y');
+ push @display, new FS::cust_bill_pkg_display { type => 'U',
+ summary => 'Y',
+ }