X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fbulk.pm;h=69fe98e92781d4500e6c0a2ddc05d109b7d0d328;hb=e17528c356bb137bcff4c6934a2c7e254202838e;hp=63d344d6d61ebbea21d3c9de0f67eac5360b3058;hpb=e3dffa23a03cd9f88946ceb78bc75ada29bc013a;p=freeside.git diff --git a/FS/FS/part_pkg/bulk.pm b/FS/FS/part_pkg/bulk.pm index 63d344d6d..69fe98e92 100644 --- a/FS/FS/part_pkg/bulk.pm +++ b/FS/FS/part_pkg/bulk.pm @@ -7,7 +7,7 @@ use FS::part_pkg::flat; @ISA = qw(FS::part_pkg::flat); -$DEBUG = 0; +$DEBUG = 1; $me = '[FS::part_pkg::bulk]'; %info = ( @@ -35,6 +35,7 @@ $me = '[FS::part_pkg::bulk]'; 'weight' => 50, ); +#some false laziness-ish w/agent.pm... not a lot sub calc_recur { my($self, $cust_pkg, $sdate, $details ) = @_; @@ -45,6 +46,9 @@ sub calc_recur { my $last_bill = $cust_pkg->last_bill; + return sprintf("%.2f", $self->base_recur($cust_pkg) ) + unless $$sdate > $last_bill; + my $total_svc_charge = 0; warn "$me billing for bulk services from ". time2str('%x', $last_bill). @@ -52,16 +56,15 @@ sub calc_recur { if $DEBUG; # END START - foreach my $h_svc ( $cust_pkg->h_cust_svc( $$sdate, $last_bill ) ) { + foreach my $h_cust_svc ( $cust_pkg->h_cust_svc( $$sdate, $last_bill ) ) { - my @label = $h_svc->label( $$sdate, $last_bill ); + my @label = $h_cust_svc->label_long( $$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_details = $label[0]. ': '. $label[1]. ': '; my $svc_charge = 0; - my $svc_start = $h_svc->date_inserted; + my $svc_start = $h_cust_svc->date_inserted; if ( $svc_start < $last_bill ) { $svc_start = $last_bill; } elsif ( $svc_setup_fee ) { @@ -69,23 +72,32 @@ sub calc_recur { $svc_details .= $money_char. sprintf('%.2f setup, ', $svc_setup_fee); } - my $svc_end = $h_svc->date_deleted; + my $svc_end = $h_cust_svc->date_deleted; $svc_end = ( !$svc_end || $svc_end > $$sdate ) ? $$sdate : $svc_end; - $svc_charge = $self->option('svc_recur_fee') * ( $svc_end - $svc_start ) - / ( $$sdate - $last_bill ); + my $recur_charge = + $self->option('svc_recur_fee') * ( $svc_end - $svc_start ) + / ( $$sdate - $last_bill ); - $svc_details .= $money_char. sprintf('%.2f', $svc_charge ). + $svc_details .= $money_char. sprintf('%.2f', $recur_charge ). ' ('. time2str('%x', $svc_start). ' - '. time2str('%x', $svc_end ). ')' - if $self->option('svc_recur_fee'); + if $recur_charge; + + $svc_charge += $recur_charge; push @$details, $svc_details; $total_svc_charge += $svc_charge; } - sprintf("%.2f", $self->base_recur($cust_pkg) + $total_svc_charge ); + sprintf('%.2f', $self->base_recur($cust_pkg) + $total_svc_charge ); +} + +sub can_discount { 0; } + +sub hide_svc_detail { + 1; } sub is_free_options {