diff options
author | ivan <ivan> | 2009-03-24 02:40:04 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-03-24 02:40:04 +0000 |
commit | 0c5236c40f0205a35470175db8449f178d021c1b (patch) | |
tree | 15dd5012dd1f0eba9124f747bc23a0fbc35c902f | |
parent | 0ee9888a7dd943aefb4726b4004c2b4f9f238873 (diff) |
bulk price plan: label as Name <email>, supress extraneous service list, RT#3519
-rw-r--r-- | FS/FS/Record.pm | 4 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 20 | ||||
-rw-r--r-- | FS/FS/cust_svc.pm | 21 | ||||
-rw-r--r-- | FS/FS/h_cust_svc.pm | 12 | ||||
-rw-r--r-- | FS/FS/part_pkg.pm | 3 | ||||
-rw-r--r-- | FS/FS/part_pkg/bulk.pm | 20 |
6 files changed, 57 insertions, 23 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index ad6613e64..f35fe4c1a 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1444,7 +1444,7 @@ sub ut_money { =item ut_text COLUMN Check/untaint text. Alphanumerics, spaces, and the following punctuation -symbols are currently permitted: ! @ # $ % & ( ) - + ; : ' " , . ? / = [ ] +symbols are currently permitted: ! @ # $ % & ( ) - + ; : ' " , . ? / = [ ] < > May not be null. If there is an error, returns the error, otherwise returns false. @@ -1456,7 +1456,7 @@ sub ut_text { #warn "notexist ". \¬exist. "\n"; #warn "AUTOLOAD ". \&AUTOLOAD. "\n"; $self->getfield($field) - =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)$/ + =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]\<\>]+)$/ or return gettext('illegal_or_empty_text'). " $field: ". $self->getfield($field); $self->setfield($field,$1); diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 70c7a7f9c..0dbe1b906 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -2593,8 +2593,11 @@ sub _items_cust_bill_pkg { my $description = $desc; $description .= ' Setup' if $cust_bill_pkg->recur != 0; - my @d = map &{$escape_function}($_), - $cust_pkg->h_labels_short($self->_date); + my @d = (); + push @d, map &{$escape_function}($_), + $cust_pkg->h_labels_short($self->_date) + unless $cust_pkg->part_pkg->hide_svc_detail; + push @d, $cust_bill_pkg->details(%details_opt) if $cust_bill_pkg->recur == 0; @@ -2617,12 +2620,17 @@ sub _items_cust_bill_pkg { " - ". time2str("%x", $cust_bill_pkg->edate). ")"; } + my @d = (); + #at least until cust_bill_pkg has "past" ranges in addition to #the "future" sdate/edate ones... see #3032 - my @d = map &{$escape_function}($_), - $cust_pkg->h_labels_short($self->_date); - #$cust_bill_pkg->edate, - #$cust_bill_pkg->sdate), + push @d, map &{$escape_function}($_), + $cust_pkg->h_labels_short($self->_date) + #$cust_bill_pkg->edate, + #$cust_bill_pkg->sdate), + unless $cust_pkg->part_pkg->hide_svc_detail + || $cust_bill_pkg->itemdesc; + push @d, $cust_bill_pkg->details(%details_opt); push @b, { diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 42681a0e9..316af4eaf 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -369,23 +369,34 @@ Usage example: my($label, $value, $svcdb) = $cust_svc->label; +=item label_long + +Like the B<label> method, except the second item in the list ("meaningful +identifier") may be longer - typically, a full name is included. + =cut -sub label { +sub label { shift->_label('svc_label', @_); } +sub label_long { shift->_label('svc_label_long', @_); } + +sub _label { my $self = shift; - carp "FS::cust_svc::label called on $self" if $DEBUG; + my $method = shift; my $svc_x = $self->svc_x or return "can't find ". $self->part_svc->svcdb. '.svcnum '. $self->svcnum; - $self->_svc_label($svc_x); + $self->$method($svc_x); } +sub svc_label { shift->_svc_label('label', @_); } +sub svc_label_long { shift->_svc_label('label_long', @_); } + sub _svc_label { - my( $self, $svc_x ) = ( shift, shift ); + my( $self, $method, $svc_x ) = ( shift, shift, shift ); ( $self->part_svc->svc, - $svc_x->label(@_), + $svc_x->$method(@_), $self->part_svc->svcdb, $self->svcnum ); diff --git a/FS/FS/h_cust_svc.pm b/FS/FS/h_cust_svc.pm index 921be3ab9..4be6a7714 100644 --- a/FS/FS/h_cust_svc.pm +++ b/FS/FS/h_cust_svc.pm @@ -52,9 +52,15 @@ If a service is found, returns a list consisting of: =cut -sub label { +sub label { shift->_label('svc_label', @_); } +sub label_long { shift->_label('svc_label_long', @_); } + +sub _label { my $self = shift; - carp "FS::h_cust_svc::label called on $self" if $DEBUG; + my $method = shift; + + #carp "FS::h_cust_svc::_label called on $self" if $DEBUG; + warn "FS::h_cust_svc::_label called on $self for $method" if $DEBUG; my $svc_x = $self->h_svc_x(@_); return () unless $svc_x; my $part_svc = $self->part_svc; @@ -65,7 +71,7 @@ sub label { } my @label; - eval { @label = $self->_svc_label($svc_x, @_); }; + eval { @label = $self->$method($svc_x, @_); }; if ($@) { carp 'while resolving history record for svcdb/svcnum ' . diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 7c8c67835..1c23b1876 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -945,6 +945,9 @@ sub plan_info { \%plans; } +#fallback for everything except bulk.pm +sub hide_svc_detail { 0; } + =item format OPTION DATA Returns data formatted according to the function 'format' described diff --git a/FS/FS/part_pkg/bulk.pm b/FS/FS/part_pkg/bulk.pm index 749f05409..d01bd4e7f 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 = ( @@ -45,6 +45,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 +55,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_long( $$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,7 +71,7 @@ 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 ) @@ -88,6 +90,10 @@ sub calc_recur { sprintf("%.2f", $self->base_recur($cust_pkg) + $total_svc_charge ); } +sub hide_svc_detail { + 1; +} + sub is_free_options { qw( setup_fee recur_fee svc_setup_fee svc_recur_fee ); } |