X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=68571f77ebe5a2d7b63746dd93602d5ff4c742cb;hb=000f20dff74059f44950c7191beaab951aeae316;hp=4acdd85a3e0a1ef3a8a4ba878178fae2008cab9e;hpb=4396080ed2829ae0595f1fd777f39d090c9bcd7c;p=freeside.git diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 4acdd85a3..68571f77e 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -451,7 +451,7 @@ sub cust_credited { ; } -=item cust_bill_pay_pkgnum +=item cust_bill_pay_pkgnum PKGNUM Returns all payment applications (see L) for this invoice with matching pkgnum. @@ -467,7 +467,7 @@ sub cust_bill_pay_pkgnum { ); } -=item cust_credited_pkgnum +=item cust_credited_pkgnum PKGNUM Returns all applied credits (see L) for this invoice with matching pkgnum. @@ -794,8 +794,11 @@ sub generate_email { push @otherparts, build MIME::Entity 'Type' => 'text/csv', 'Encoding' => '7bit', - 'Data' => [ map { "$_\n" } $self->call_details ], + 'Data' => [ map { "$_\n" } + $self->call_details('prepend_billed_number' => 1) + ], 'Disposition' => 'attachment', + 'Filename' => 'usage-'. $self->invnum. '.csv', ; } @@ -3129,20 +3132,36 @@ sub _items_payments { } -=item call_details +=item call_details [ OPTION => VALUE ... ] Returns an array of CSV strings representing the call details for this invoice +The only option available is the boolean prepend_billed_number =cut sub call_details { - my $self = shift; - map { $_->details( 'format_function' => sub{ shift }, - 'escape_function' => sub{ return() }, - ) - } - grep { $_->pkgnum } - $self->cust_bill_pkg; + my ($self, %opt) = @_; + + my $format_function = sub { shift }; + + if ($opt{prepend_billed_number}) { + $format_function = sub { + my $detail = shift; + my $row = shift; + + $row->amount ? $row->phonenum. ",". $detail : '"Billed number",'. $detail; + + }; + } + + my @details = map { $_->details( 'format_function' => $format_function, + 'escape_function' => sub{ return() }, + ) + } + grep { $_->pkgnum } + $self->cust_bill_pkg; + my $header = $details[0]; + ( $header, grep { $_ ne $header } @details ); }