fix missing fill-in values on invoices resulting from skewed hash ($conf->config...
[freeside.git] / FS / FS / cust_bill.pm
index 1f6f85b..4dc15ca 100644 (file)
@@ -1843,7 +1843,7 @@ sub print_latex {
   }
 
   my %invoice_data = (
-    'company_name'    => $conf->config('company_name'),
+    'company_name'    => scalar( $conf->config('company_name') ),
     'company_address' => join("\n", $conf->config('company_address') ). "\n",
     'custnum'         => $self->custnum,
     'invnum'          => $self->invnum,
@@ -2244,7 +2244,7 @@ sub print_html {
     or die 'While compiling ' . $templatefile . ': ' . $Text::Template::ERROR;
 
   my %invoice_data = (
-    'company_name'    => $conf->config('company_name'),
+    'company_name'    => scalar( $conf->config('company_name') ),
     'company_address' => join("\n", $conf->config('company_address') ). "\n",
     'custnum'         => $self->custnum,
     'invnum'          => $self->invnum,
@@ -2431,6 +2431,11 @@ sub print_html {
     push @{$invoice_data{'total_items'}}, $total;
   }
 
+  warn "filling in HTML template for invoice ". $self->invnum. "\n"
+    if $DEBUG;
+  warn join("\n", map "  $_ => ".$invoice_data{$_}, keys %invoice_data ). "\n"
+    if $DEBUG > 1;
+
   $html_template->fill_in( HASH => \%invoice_data);
 }
 
@@ -2879,7 +2884,7 @@ sub search_sql {
     #$orderby = 'ORDER BY cust_bill.custnum ASC, cust_bill._date DESC';
 
     my @newest_where = map { my $x = $_;
-                             $x = s/\bcust_bill\./newest_cust_bill./g;
+                             $x =~ s/\bcust_bill\./newest_cust_bill./g;
                              $x;
                            }
                            grep ! /^cust_main./, @search;
@@ -2887,6 +2892,7 @@ sub search_sql {
                          ? ' AND '. join(' AND ', @newest_where)
                         : '';
 
+
     push @search, "cust_bill._date = (
       SELECT(MAX(newest_cust_bill._date)) FROM cust_bill AS newest_cust_bill
         WHERE newest_cust_bill.custnum = cust_bill.custnum