diff options
author | ivan <ivan> | 2009-03-24 02:36:31 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-03-24 02:36:31 +0000 |
commit | 9006e983ebf98b2000a812ab01f99dcb2335534c (patch) | |
tree | 7189499ce30fe71046170119f05f5cc7858213ca | |
parent | 42682206b4ba30de01c82743042f5fb9d48a93ed (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 | 22 | ||||
-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, 56 insertions, 26 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 2d0263b22..0e8275b72 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1944,7 +1944,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. @@ -1956,7 +1956,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 6fac0a946..77f0dd30f 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -2832,8 +2832,10 @@ 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; @@ -2862,16 +2864,18 @@ 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 = (); push @d, map &{$escape_function}($_), - $cust_pkg->h_labels_short($self->_date) - #$cust_bill_pkg->edate, - #$cust_bill_pkg->sdate), - ; - - @d = () if ($cust_bill_pkg->itemdesc || $is_summary); + $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 + || $is_summary; + push @d, $cust_bill_pkg->details(%details_opt) unless ($is_summary || $type && $type eq 'R'); diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 320f78aa0..c4a75f77a 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -375,23 +375,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 e03043698..d280d53fe 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 ef24b5343..81696fcfa 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -1116,6 +1116,9 @@ sub calc_remain { 0; } sub calc_cancel { 0; } sub calc_units { 0; } +#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 809559509..7c81138c1 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 ); } |