fix one-time charge quantities &
authorivan <ivan>
Thu, 5 Jun 2008 20:09:21 +0000 (20:09 +0000)
committerivan <ivan>
Thu, 5 Jun 2008 20:09:21 +0000 (20:09 +0000)
FS/FS/cust_main.pm
FS/FS/part_pkg/flat.pm

index 1f2fe88..33788f3 100644 (file)
@@ -2107,6 +2107,7 @@ sub bill {
       ###
 
       my $setup = 0;
+      my $unitsetup = 0;
       if ( ! $cust_pkg->setup &&
            (
              ( $conf->exists('disable_setup_suspended_pkgs') &&
@@ -2125,6 +2126,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;
               #do need it, but it won't get written to the db
@@ -2136,7 +2139,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') &&
@@ -2240,11 +2245,14 @@ sub bill {
           warn "    charges (setup=$setup, recur=$recur); adding line items\n"
             if $DEBUG > 1;
           my $cust_bill_pkg = new FS::cust_bill_pkg {
-            'pkgnum'  => $cust_pkg->pkgnum,
-            'setup'   => $setup,
-            'recur'   => $recur,
-            'sdate'   => $sdate,
-            'edate'   => $cust_pkg->bill,
+            'pkgnum'    => $cust_pkg->pkgnum,
+            'setup'     => $setup,
+            'unitsetup' => $unitsetup,
+            'recur'     => $recur,
+            'unitrecur' => $unitrecur,
+            'quantity'  => $cust_pkg->quantity,
+            'sdate'     => $sdate,
+            'edate'     => $cust_pkg->bill,
             'details' => \@details,
           };
           $cust_bill_pkg->pkgpart_override($part_pkg->pkgpart)
index 1d93e55..3480964 100644 (file)
@@ -101,7 +101,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 {