X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FTemplate_Mixin.pm;h=2dcf7d0e7d7a208d658cad1c0098c710a3cf9004;hp=79f6813d8bd6a41b570ab72d7d1d26b76e2c1ecd;hb=7565d61a5a62c57f34f4e3efd59d2e3211229181;hpb=f23d8e66afadf1ad8dd8a642a690434f4c0b562f diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 79f6813d8..2dcf7d0e7 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -563,6 +563,7 @@ sub print_generic { 'notice_name' => $notice_name, # escape? 'current_charges' => sprintf("%.2f", $self->charged), 'duedate' => $self->due_date2str('rdate'), #date_format? + 'duedate_long' => $self->due_date2str('long'), #customer info 'custnum' => $cust_main->display_custnum, @@ -602,6 +603,9 @@ sub print_generic { 'total_pages' => 1, ); + + #quotations have $name + $invoice_data{'name'} = $invoice_data{'payname'}; #localization $invoice_data{'emt'} = sub { &$escape_function($self->mt(@_)) }; @@ -1157,14 +1161,27 @@ sub print_generic { if ( $invoice_data{finance_section} && $section->{'description'} eq $invoice_data{finance_section} ); - $section->{'subtotal'} = $other_money_char. - sprintf('%.2f', $section->{'subtotal'}) - if $multisection; + if ( $multisection ) { + + if ( ref($section->{'subtotal'}) ) { - # continue some normalization - $section->{'amount'} = $section->{'subtotal'} - if $multisection; + $section->{'subtotal'} = + sprintf("$other_money_char%.2f to $other_money_char%.2f", + $section->{'subtotal'}[0], + $section->{'subtotal'}[1] + ); + + } else { + $section->{'subtotal'} = $other_money_char. + sprintf('%.2f', $section->{'subtotal'}) + + } + + # continue some normalization + $section->{'amount'} = $section->{'subtotal'} + + } if ( $section->{'description'} ) { push @buf, ( [ &$escape_function($section->{'description'}), '' ], @@ -1363,7 +1380,16 @@ sub print_generic { foreach ( @new_total_items ) { my ($item, $amount) = ($_->{'total_item'}, $_->{'total_amount'}); $_->{'total_item'} = &$embolden_function( $item ); - $_->{'total_amount'} = &$embolden_function( $other_money_char.$amount ); + + if ( ref($amount) ) { + $_->{'total_amount'} = &$embolden_function( + $other_money_char.$amount->[0]. ' to '. + $other_money_char.$amount->[1] + ); + } else { + $_->{'total_amount'} = &$embolden_function( $other_money_char.$amount ); + } + # but if it's multisection, don't append to @total_items. the adjust # section has all this stuff push @total_items, $_ if !$multisection; @@ -1642,24 +1668,24 @@ sub print_generic { die "no invoice_lines() functions in template?" if ( $format eq 'template' && !$wasfunc ); - if ($format eq 'template') { + if ( $invoice_lines ) { + $invoice_data{'total_pages'} = int( scalar(@buf) / $invoice_lines ); + $invoice_data{'total_pages'}++ + if scalar(@buf) % $invoice_lines; + } - if ( $invoice_lines ) { - $invoice_data{'total_pages'} = int( scalar(@buf) / $invoice_lines ); - $invoice_data{'total_pages'}++ - if scalar(@buf) % $invoice_lines; + #setup subroutine for the template + $invoice_data{invoice_lines} = sub { + my $lines = shift || scalar(@buf); + map { + scalar(@buf) + ? shift @buf + : [ '', '' ]; } + ( 1 .. $lines ); + }; - #setup subroutine for the template - $invoice_data{invoice_lines} = sub { - my $lines = shift || scalar(@buf); - map { - scalar(@buf) - ? shift @buf - : [ '', '' ]; - } - ( 1 .. $lines ); - }; + if ($format eq 'template') { my $lines; my @collect; @@ -2366,7 +2392,7 @@ sub generate_email { =item mimebuild_pdf Returns a list suitable for passing to MIME::Entity->build(), representing -this invoice as PDF attachment. +this quotation or invoice as PDF attachment. =cut @@ -2377,7 +2403,7 @@ sub mimebuild_pdf { 'Encoding' => 'base64', 'Data' => [ $self->print_pdf(@_) ], 'Disposition' => 'attachment', - 'Filename' => 'invoice-'. $self->invnum. '.pdf', + 'Filename' => $self->pdf_filename, ); }