From: ivan Date: Fri, 13 May 2005 15:06:18 +0000 (+0000) Subject: fix picking up alternate invoice_latexnotes_* files, and expand country codes on... X-Git-Tag: BEFORE_FINAL_MASONIZE~539 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=d33c75b60d9cb9f7155635dc2cd25307f06d947f fix picking up alternate invoice_latexnotes_* files, and expand country codes on invoices. and oops, print_html changes slipped in last commit too. well, they were ready anyway. --- diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 010d698d6..fe5a653c0 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1,13 +1,14 @@ package FS::cust_bill; use strict; -use vars qw( @ISA $conf $money_char ); +use vars qw( @ISA $DEBUG $conf $money_char ); use vars qw( $invoice_lines @buf ); #yuck use Date::Format; use Text::Template 1.20; use File::Temp 0.14; 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 ); @@ -22,6 +23,8 @@ use FS::cust_bill_event; @ISA = qw( FS::Record ); +$DEBUG = 1; + #ask FS::UID to run this stuff for us later FS::UID->install_callback( sub { $conf = new FS::Conf; @@ -1029,8 +1032,10 @@ sub print_text { if $cust_main->address2; $FS::cust_bill::_template::address[$l++] = $cust_main->city. ", ". $cust_main->state. " ". $cust_main->zip; - $FS::cust_bill::_template::address[$l++] = $cust_main->country - unless $cust_main->country eq 'US'; + + my $countrydefault = $conf->config('countrydefault') || 'US'; + $FS::cust_bill::_template::address[$l++] = code2country($cust_main->country) + unless $cust_main->country eq $countrydefault; # #overdue? (variable for the template) # $FS::cust_bill::_template::overdue = ( @@ -1083,6 +1088,8 @@ sub print_latex { my( $self, $today, $template ) = @_; $today ||= time; + warn "FS::cust_bill::print_latex called on $self with suffix $template\n" + if $DEBUG; my $cust_main = $self->cust_main; $cust_main->payname( $cust_main->first. ' '. $cust_main->getfield('last') ) @@ -1132,6 +1139,7 @@ sub print_latex { my %invoice_data = ( 'invnum' => $self->invnum, 'date' => time2str('%b %o, %Y', $self->_date), + 'today' => time2str('%b %o, %Y', $today), 'agent' => _latex_escape($cust_main->agent->agent), 'payname' => _latex_escape($cust_main->payname), 'company' => _latex_escape($cust_main->company), @@ -1140,7 +1148,6 @@ sub print_latex { 'city' => _latex_escape($cust_main->city), 'state' => _latex_escape($cust_main->state), 'zip' => _latex_escape($cust_main->zip), - 'country' => _latex_escape($cust_main->country), 'footer' => join("\n", $conf->config('invoice_latexfooter') ), 'smallfooter' => join("\n", $conf->config('invoice_latexsmallfooter') ), 'returnaddress' => $returnaddress, @@ -1151,14 +1158,20 @@ sub print_latex { ); my $countrydefault = $conf->config('countrydefault') || 'US'; - $invoice_data{'country'} = '' if $invoice_data{'country'} eq $countrydefault; + if ( $cust_main->country eq $countrydefault ) { + $invoice_data{'country'} = ''; + } else { + $invoice_data{'country'} = _latex_escape(code2country($cust_main->country)); + } #do variable substitutions in notes $invoice_data{'notes'} = join("\n", map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b } - $conf->config_orbase('invoice_latexnotes', $suffix) + $conf->config_orbase('invoice_latexnotes', $template) ); + warn "invoice notes: ". $invoice_data{'notes'}. "\n" + if $DEBUG; $invoice_data{'footer'} =~ s/\n+$//; $invoice_data{'smallfooter'} =~ s/\n+$//; @@ -1604,7 +1617,6 @@ sub print_html { 'city' => encode_entities($cust_main->city), 'state' => encode_entities($cust_main->state), 'zip' => encode_entities($cust_main->zip), - 'country' => encode_entities($cust_main->country), # 'footer' => join("\n", $conf->config('invoice_latexfooter') ), # 'smallfooter' => join("\n", $conf->config('invoice_latexsmallfooter') ), 'returnaddress' => $returnaddress, @@ -1615,6 +1627,14 @@ sub print_html { ); my $countrydefault = $conf->config('countrydefault') || 'US'; + if ( $cust_main->country eq $countrydefault ) { + $invoice_data{'country'} = ''; + } else { + $invoice_data{'country'} = + encode_entities(code2country($cust_main->country)); + } + + my $countrydefault = $conf->config('countrydefault') || 'US'; $invoice_data{'country'} = '' if $invoice_data{'country'} eq $countrydefault; # #do variable substitutions in notes