-sub append_cust_bill_pkgs {
- my $self = shift;
- my($cust_pkg, $sdate, $details, $param ) = @_;
- return []
- unless $self->option('separate_usage', 'Hush!');
-
- my @details = ();
- my $charges = $self->calc_usage($cust_pkg, $sdate, \@details, $param);
-
- return []
- unless $charges; # unless @details?
-
- my @cust_bill_pkg = ();
-
- my $want_summary = $self->option('summarize_usage', 'Hush!') &&
- $self->option('usage_section', 'Hush!');
-
- push @cust_bill_pkg, new FS::cust_bill_pkg {
- 'pkgnum' => $cust_pkg->pkgnum,
- 'setup' => 0,
- 'unitsetup' => 0,
- 'recur' => sprintf( "%.2f", $charges), # hmmm
- 'unitrecur' => 0,
- 'quantity' => $cust_pkg->quantity,
- 'sdate' => $$sdate,
- 'edate' => $cust_pkg->bill, # already fiddled
- 'itemdesc' => 'Usage charges', # configurable?
- 'duplicate' => 'Y',
- }
- if $want_summary;
-
- push @cust_bill_pkg, new FS::cust_bill_pkg {
- 'pkgnum' => $cust_pkg->pkgnum,
- 'setup' => 0,
- 'unitsetup ' => 0,
- 'recur' => sprintf( "%.2f", $charges), # hmmm
- 'unitrecur ' => 0,
- 'quantity' => $cust_pkg->quantity,
- 'sdate' => $$sdate,
- 'edate' => $cust_pkg->bill, # already fiddled
- 'itemdesc' => 'Usage charges', # configurable?
- 'section' => $self->option('usage_section', 'Hush!'),
- 'details' => \@details,
- 'post_total' => ( $want_summary ? 'Y' : '' ),
- };
-
-
- return [ @cust_bill_pkg ];
-}
-