[freeside-commits] freeside/FS/FS/part_pkg bulk.pm,1.1,1.2

Ivan,,, ivan at wavetail.420.am
Tue Feb 12 22:02:27 PST 2008


Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv17976

Modified Files:
	bulk.pm 
Log Message:
yup, bulk price plan appears to be working

Index: bulk.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/bulk.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- bulk.pm	1 Dec 2007 01:29:03 -0000	1.1
+++ bulk.pm	13 Feb 2008 06:02:25 -0000	1.2
@@ -1,12 +1,15 @@
 package FS::part_pkg::bulk;
 
 use strict;
-use vars qw(@ISA %info);
+use vars qw(@ISA $DEBUG $me %info);
 use Date::Format;
 use FS::part_pkg::flat;
 
 @ISA = qw(FS::part_pkg::flat);
 
+$DEBUG = 0;
+$me = '[FS::part_pkg::bulk]';
+
 %info = (
   'name' => 'Bulk billing based on number of active services',
   'fields' => {
@@ -44,18 +47,26 @@
 
   my $total_svc_charge = 0;
 
+  warn "$me billing for bulk services from ". time2str('%x', $last_bill).
+                                      " to ". time2str('%x', $$sdate). "\n"
+    if $DEBUG;
+
                                            #   END      START
   foreach my $h_svc ( $cust_pkg->h_cust_svc( $$sdate, $last_bill ) ) {
 
+    my @label = $h_svc->label( $$sdate, $last_bill );
+    die "fatal: no historical label found, wtf?" unless scalar(@label); #?
+    #my $svc_details = $label[0].': '. $label[1]. ': ';
+    my $svc_details = $label[1]. ': ';
+
     my $svc_charge = 0;
-    my $svc_details = $h_svc->label. ': ';
 
     my $svc_start = $h_svc->date_inserted;
     if ( $svc_start < $last_bill ) {
       $svc_start = $last_bill;
     } elsif ( $svc_setup_fee ) {
       $svc_charge += $svc_setup_fee;
-      $details .= $money_char. sprintf('%.2f setup, ', $svc_setup_fee);
+      $svc_details .= $money_char. sprintf('%.2f setup, ', $svc_setup_fee);
     }
 
     my $svc_end = $h_svc->date_deleted;
@@ -64,12 +75,12 @@
     $svc_charge = $self->option('svc_recur_fee') * ( $svc_end - $svc_start )
                                                  / ( $$sdate  - $last_bill );
 
-    $details .= $money_char. sprintf('%.2f', $svc_charge ).
-                ' ('.  time2str('%x', $svc_start).
-                ' - '. time2str('%x', $svc_end  ). ')'
-    if $self->option('svc_recur_fee');
+    $svc_details .= $money_char. sprintf('%.2f', $svc_charge ).
+                    ' ('.  time2str('%x', $svc_start).
+                    ' - '. time2str('%x', $svc_end  ). ')'
+      if $self->option('svc_recur_fee');
 
-    push @$details, $details;
+    push @$details, $svc_details;
     $total_svc_charge += $svc_charge;
 
   }
@@ -81,3 +92,5 @@
   qw( setup_fee recur_fee svc_setup_fee svc_recur_fee );
 }
 
+1;
+



More information about the freeside-commits mailing list