summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cust_main.pm22
-rw-r--r--FS/FS/part_pkg/flat.pm8
2 files changed, 22 insertions, 8 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 259f650ce..875db6e3e 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -1952,6 +1952,7 @@ sub bill {
###
my $setup = 0;
+ my $unitsetup = 0;
if ( ! $cust_pkg->setup &&
(
( $conf->exists('disable_setup_suspended_pkgs') &&
@@ -1969,6 +1970,8 @@ sub bill {
return "$@ running calc_setup for $cust_pkg\n";
}
+ $unitsetup = $cust_pkg->part_pkg->unit_setup || $setup; #XXX uuh
+
$cust_pkg->setfield('setup', $time) unless $cust_pkg->setup;
}
@@ -1976,7 +1979,9 @@ sub bill {
# bill recurring fee
###
+ #XXX unit stuff here too
my $recur = 0;
+ my $unitrecur = 0;
my $sdate;
if ( $part_pkg->getfield('freq') ne '0' &&
! $cust_pkg->getfield('susp') &&
@@ -2072,13 +2077,16 @@ sub bill {
warn " charges (setup=$setup, recur=$recur); adding line items\n"
if $DEBUG > 1;
my $cust_bill_pkg = new FS::cust_bill_pkg ({
- 'invnum' => $invnum,
- 'pkgnum' => $cust_pkg->pkgnum,
- 'setup' => $setup,
- 'recur' => $recur,
- 'sdate' => $sdate,
- 'edate' => $cust_pkg->bill,
- 'details' => \@details,
+ 'invnum' => $invnum,
+ 'pkgnum' => $cust_pkg->pkgnum,
+ 'setup' => $setup,
+ 'unitsetup' => $unitsetup,
+ 'recur' => $recur,
+ 'unitrecur' => $unitrecur,
+ 'quantity' => $cust_pkg->quantity,
+ 'sdate' => $sdate,
+ 'edate' => $cust_pkg->bill,
+ 'details' => \@details,
});
$error = $cust_bill_pkg->insert;
if ( $error ) {
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index 96357c723..699b4d541 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -100,7 +100,13 @@ sub calc_setup {
my $quantity = $cust_pkg->quantity || 1;
- sprintf("%.2f", $quantity * $self->option('setup_fee') );
+ sprintf("%.2f", $quantity * $self->unit_setup($cust_pkg, $sdate, $details) );
+}
+
+sub unit_setup {
+ my($self, $cust_pkg, $sdate, $details ) = @_;
+
+ $self->option('setup_fee');
}
sub calc_recur {