invoice_lines() fix
[freeside.git] / FS / FS / cust_bill.pm
index 75e2b17..23e8731 100644 (file)
@@ -793,7 +793,7 @@ sub realtime_bop {
   if ( $transaction->is_success() ) {
 
     my %method2payby = (
-      ' CC'    => 'CARD',
+      'CC'     => 'CARD',
       'ECHECK' => 'CHEK',
       'LEC'    => 'LECB',
     );
@@ -1032,9 +1032,9 @@ sub print_text {
   or die "cannot load config file $templatefile";
   $invoice_lines = 0;
   my $wasfunc = 0;
-  foreach ( grep /invoice_lines\(\d+\)/, @invoice_template ) { #kludgy
-    /invoice_lines\((\d+)\)/;
-    $invoice_lines += $1;
+  foreach ( grep /invoice_lines\(\d*\)/, @invoice_template ) { #kludgy
+    /invoice_lines\((\d*)\)/;
+    $invoice_lines += $1 || scalar(@buf);
     $wasfunc=1;
   }
   die "no invoice_lines() functions in template?" unless $wasfunc;
@@ -1092,16 +1092,14 @@ sub print_text {
        #  );
 
   #and subroutine for the template
-
   sub FS::cust_bill::_template::invoice_lines {
-    my $lines = shift or return @buf;
+    my $lines = shift || scalar(@buf);
     map { 
       scalar(@buf) ? shift @buf : [ '', '' ];
     }
     ( 1 .. $lines );
   }
 
-
   #and fill it in
   $FS::cust_bill::_template::page = 1;
   my $lines;
@@ -1121,7 +1119,7 @@ sub print_text {
 
 =head1 VERSION
 
-$Id: cust_bill.pm,v 1.54 2002-11-19 22:48:02 ivan Exp $
+$Id: cust_bill.pm,v 1.57 2002-12-17 21:31:20 ivan Exp $
 
 =head1 BUGS