From: Ivan Kohler Date: Wed, 4 Feb 2015 20:07:32 +0000 (-0800) Subject: Merge branch 'master' of git.freeside.biz:/home/git/freeside X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=5310efb6d40b32ae08ae78553fc8721693925da7;hp=e7e800e6b2a315171d7d8a9c1ff8bc7abb82f25b Merge branch 'master' of git.freeside.biz:/home/git/freeside --- diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index e26592cee..d8e46c5ab 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -2830,6 +2830,8 @@ sub _items_fee { my $self = shift; my %options = @_; my @cust_bill_pkg = grep { $_->feepart } $self->cust_bill_pkg; + my $escape_function = $options{escape_function}; + my @items; foreach my $cust_bill_pkg (@cust_bill_pkg) { # cache this, so we don't look it up again in every section @@ -2865,12 +2867,17 @@ sub _items_fee { foreach (sort keys(%base_invnums)) { next if $_ == $self->invnum; push @ext_desc, - $self->mt('from invoice \\#[_1] on [_2]', $_, $base_invnums{$_}); + &{$escape_function}( + $self->mt('from invoice #[_1] on [_2]', $_, $base_invnums{$_}) + ); } + my $desc = $part_fee->itemdesc_locale($self->cust_main->locale); + $desc = &{$escape_function}($desc); + push @items, { feepart => $cust_bill_pkg->feepart, amount => sprintf('%.2f', $cust_bill_pkg->setup + $cust_bill_pkg->recur), - description => $part_fee->itemdesc_locale($self->cust_main->locale), + description => $desc, ext_description => \@ext_desc # sdate/edate? }; diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 888e88bb8..068d0d1d3 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1900,7 +1900,14 @@ sub print_csv { if ( lc($opt{'format'}) eq 'billco' ) { my $lineseq = 0; - foreach my $item ( $self->_items_pkg ) { + my %items_opt = ( format => 'template', + escape_function => sub { shift } ); + # I don't know what characters billco actually tolerates in spool entries. + # Text::CSV will take care of delimiters, though. + + my @items = ( $self->_items_pkg(%items_opt), + $self->_items_fee(%items_opt) ); + foreach my $item (@items) { my $description = $item->{'description'}; if ( $item->{'_is_discount'} and exists($item->{ext_description}[0]) ) { diff --git a/FS/FS/part_event/Condition/has_referral_custnum.pm b/FS/FS/part_event/Condition/has_referral_custnum.pm index c50579411..f8a2b82ee 100644 --- a/FS/FS/part_event/Condition/has_referral_custnum.pm +++ b/FS/FS/part_event/Condition/has_referral_custnum.pm @@ -31,19 +31,22 @@ sub condition { my($self, $object, %opt) = @_; my $cust_main = $self->cust_main($object); + return 0 unless $cust_main; #sanity check + return 0 unless $cust_main->referral_custnum; + + my $referring_cust_main = $cust_main->referral_custnum_cust_main; + return 0 unless $referring_cust_main; #sanity check; + + #referring customer must sign up before referred customer + return 0 unless $cust_main->signupdate > $referring_cust_main->signupdate; if ( $self->option('active') ) { - return 0 unless $cust_main->referral_custnum; #check for no cust_main for referral_custnum? (deleted?) - return 0 unless $cust_main->referral_custnum_cust_main->status eq 'active'; - } else { - return 0 unless $cust_main->referral_custnum; # ? 1 : 0; + return 0 unless $referring_cust_main->status eq 'active'; } return 1 unless $self->option('check_bal'); - my $referring_cust_main = $cust_main->referral_custnum_cust_main; - #false laziness w/ balance_age_under my $under = $self->option('balance'); $under = 0 unless length($under); diff --git a/FS/FS/part_event/Condition/has_referral_pkgpart.pm b/FS/FS/part_event/Condition/has_referral_pkgpart.pm index 60ba7ccd5..7062f6c2e 100644 --- a/FS/FS/part_event/Condition/has_referral_pkgpart.pm +++ b/FS/FS/part_event/Condition/has_referral_pkgpart.pm @@ -1,6 +1,7 @@ package FS::part_event::Condition::has_referral_pkgpart; use base qw( FS::part_event::Condition ); +use FS::part_event::Condition::has_referral_custnum; #maybe i should be incorporated in has_referral_custnum use strict; @@ -19,10 +20,10 @@ sub option_fields { sub condition { my($self, $object, %opt) = @_; + return 0 unless FS::part_event::Condition::has_referral_custnum::condition($self, $object, %opt); + my $cust_main = $self->cust_main($object); - return 0 unless $cust_main->referral_custnum; - my $if_pkgpart = $self->option('if_pkgpart') || {}; grep $if_pkgpart->{ $_->pkgpart }, $cust_main->referral_custnum_cust_main->ncancelled_pkgs;