X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=46809f9a0a8c3bd805009d3ad0cf827ac5a27e62;hb=673b9a458d9138523026963df6fa3b4683e09bae;hp=8b34cb9187271c94050ffdcd7408eb25bc1147e2;hpb=c160bc6f05b17d8084addc4d638ebc908c9ec0e6;p=freeside.git diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 8b34cb918..46809f9a0 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -11,8 +11,9 @@ use String::ShellQuote; use HTML::Entities; use Locale::Country; use FS::UID qw( datasrc ); -use FS::Record qw( qsearch qsearchs ); use FS::Misc qw( send_email send_fax ); +use FS::Record qw( qsearch qsearchs ); +use FS::cust_main_Mixin; use FS::cust_main; use FS::cust_bill_pkg; use FS::cust_credit; @@ -25,7 +26,7 @@ use FS::part_pkg; use FS::cust_bill_pay; use FS::part_bill_event; -@ISA = qw( FS::Record ); +@ISA = qw( FS::cust_main_Mixin FS::Record ); $DEBUG = 0; @@ -105,6 +106,13 @@ Invoices are normally created by calling the bill method of a customer object sub table { 'cust_bill'; } +sub cust_linked { $_[0]->cust_main_custnum; } +sub cust_unlinked_msg { + my $self = shift; + "WARNING: can't find cust_main.custnum ". $self->custnum. + ' (cust_bill.invnum '. $self->invnum. ')'; +} + =item insert Adds this invoice to the database ("Posts" the invoice). If there is an error, @@ -417,7 +425,10 @@ sub generate_email { my $path = "$FS::UID::conf_dir/conf.$FS::UID::datasrc"; my $file; - if ( [ -e "$path/logo_". $args{'_template'}. ".png" ] ) { + if ( defined($args{'_template'}) && length($args{'_template'}) + && -e "$path/logo_". $args{'_template'}. ".png" + ) + { $file = "$path/logo_". $args{'_template'}. ".png"; } else { $file = "$path/logo.png"; @@ -553,8 +564,8 @@ sub mimebuild_pdf { =item send [ TEMPLATENAME [ , AGENTNUM [ , INVOICE_FROM ] ] ] -Sends this invoice to the destinations configured for this customer: send -emails or print. See L. +Sends this invoice to the destinations configured for this customer: sends +email, prints and/or faxes. See L. TEMPLATENAME, if specified, is the name of a suffix for alternate invoices. @@ -1774,17 +1785,25 @@ sub print_html { # 'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc", ); - $invoice_data{'returnaddress'} = - length( $conf->config_orbase('invoice_htmlreturnaddress', $template) ) - ? join("\n", $conf->config('invoice_htmlreturnaddress', $template) ) - : join("\n", map { - s/~/ /g; - s/\\\\\*?\s*$/
/; - s/\\hyphenation\{[\w\s\-]+\}//; - $_; - } - $conf->config_orbase('invoice_latexreturnaddress', $template) - ); + if ( + defined( $conf->config_orbase('invoice_htmlreturnaddress', $template) ) + && length( $conf->config_orbase('invoice_htmlreturnaddress', $template) ) + ) { + $invoice_data{'returnaddress'} = + join("\n", $conf->config('invoice_htmlreturnaddress', $template) ); + } else { + $invoice_data{'returnaddress'} = + join("\n", map { + s/~/ /g; + s/\\\\\*?\s*$/
/; + s/\\hyphenation\{[\w\s\-]+\}//; + $_; + } + $conf->config_orbase( 'invoice_latexreturnaddress', + $template + ) + ); + } my $countrydefault = $conf->config('countrydefault') || 'US'; if ( $cust_main->country eq $countrydefault ) { @@ -1794,20 +1813,26 @@ sub print_html { encode_entities(code2country($cust_main->country)); } - $invoice_data{'notes'} = - length($conf->config_orbase('invoice_htmlnotes', $template)) - ? join("\n", $conf->config_orbase('invoice_htmlnotes', $template) ) - : join("\n", map { - s/%%(.*)$//; - s/\\section\*\{\\textsc\{(.)(.*)\}\}/

$1<\/font>\U$2<\/b>/; - s/\\begin\{enumerate\}/

    /; - s/\\item /
  1. /; - s/\\end\{enumerate\}/<\/ol>/; - s/\\textbf\{(.*)\}/$1<\/b>/; - $_; - } - $conf->config_orbase('invoice_latexnotes', $template) - ); + if ( + defined( $conf->config_orbase('invoice_htmlnotes', $template) ) + && length( $conf->config_orbase('invoice_htmlnotes', $template) ) + ) { + $invoice_data{'notes'} = + join("\n", $conf->config_orbase('invoice_htmlnotes', $template) ); + } else { + $invoice_data{'notes'} = + join("\n", map { + s/%%(.*)$//; + s/\\section\*\{\\textsc\{(.)(.*)\}\}/

    $1<\/font>\U$2<\/b>/; + s/\\begin\{enumerate\}/

      /; + s/\\item /
    1. /; + s/\\end\{enumerate\}/<\/ol>/; + s/\\textbf\{(.*)\}/$1<\/b>/; + $_; + } + $conf->config_orbase('invoice_latexnotes', $template) + ); + } # #do variable substitutions in notes # $invoice_data{'notes'} = @@ -1816,12 +1841,18 @@ sub print_html { # $conf->config_orbase('invoice_latexnotes', $suffix) # ); + if ( + defined( $conf->config_orbase('invoice_htmlfooter', $template) ) + && length( $conf->config_orbase('invoice_htmlfooter', $template) ) + ) { $invoice_data{'footer'} = - length($conf->config_orbase('invoice_htmlfooter', $template)) - ? join("\n", $conf->config_orbase('invoice_htmlfooter', $template) ) - : join("\n", map { s/~/ /g; s/\\\\\*?\s*$/
      /; $_; } - $conf->config_orbase('invoice_latexfooter', $template) - ); + join("\n", $conf->config_orbase('invoice_htmlfooter', $template) ); + } else { + $invoice_data{'footer'} = + join("\n", map { s/~/ /g; s/\\\\\*?\s*$/
      /; $_; } + $conf->config_orbase('invoice_latexfooter', $template) + ); + } $invoice_data{'po_line'} = ( $cust_main->payby eq 'BILL' && $cust_main->payinfo )