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
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;
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 };
}
=head1 DESCRIPTION
-An FS::cust_bill_pkg_display object represents line item display information.
-FS::cust_bill_pkg_display inherits from FS::Record. The following fields are
-currently supported:
+An FS::cust_bill_pkg_display object represents an instruction to display a
+line item in a specific invoice section. FS::cust_bill_pkg_display inherits
+from FS::Record and is many-to-one with FS::cust_bill_pkg (invoice line
+items).
-=over 4
-
-=item billpkgdisplaynum
+The following fields are currently supported:
-primary key
-
-=item billpkgnum
+=over 4
-billpkgnum
+=item billpkgdisplaynum - primary key
-=item section
+=item billpkgnum - the line item number (L<FS::cust_bill_pkg> foreign key)
-section
+=item section - the section name where this item should be shown. Defaults
+to the package category name, if there is one.
=cut
+# actually it defaults to null, but then calling ->section will return the
+# category name.
sub section {
my ( $self, $value ) = @_;
if ( defined($value) ) {
}
}
-=item post_total
+=item post_total - 'Y' to have this item shown in a "late" section (below
+the invoice totals).
-post_total
+=item type - Which portion of the item's charges to show in the specified
+position. 'S' to show setup fees (including tax and one-time charge),
+'R' to show the non-usage recurring charge, 'U' to show the usage charge,
+null to show all three as a single amount.
-=item type
-
-type
-
-=item summary
-
-summary
+=item summary - 'Y' to show a usage summary of this line item. This has
+the following effects if type = 'U':
+- The description will always be "Usage charges" rather than the package name.
+- Service labels and usage details (CDRs) are hidden.
+- It will only display on multisection invoices.
=back
=item new HASHREF
-Creates a new line item display object. To add the record to the database, see L<"insert">.
+Creates a new line item display object. To add the record to the database,
+see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
=head1 BUGS
-
=head1 SEE ALSO
L<FS::Record>, L<FS::cust_bill_pkg>, schema.html from the base documentation.