add business-onlinepayment-currency config setting, RT#13904
[freeside.git] / FS / FS / bill_batch.pm
index 136db0d..7300f45 100644 (file)
@@ -4,6 +4,7 @@ use strict;
 use vars qw( @ISA $me $DEBUG );
 use FS::Record qw( qsearch qsearchs dbh );
 use FS::cust_bill_batch;
+use CAM::PDF;
 
 @ISA = qw( FS::Record );
 $me = '[ FS::bill_batch ]';
@@ -53,9 +54,6 @@ Typeset the entire batch as a PDF file.  Returns the PDF as a string.
 =cut
 
 sub print_pdf {
-  eval 'use CAM::PDF';
-  warn "Failed to load CAM::PDF: '$@'\n" if $@;
-
   my $self = shift;
   my $job = shift;
   $job->update_statustext(0) if $job;
@@ -82,6 +80,7 @@ sub print_pdf {
       die $error if $error;
     }
   }
+  $job->update_statustext(100, 'Combining invoices') if $job;
 
   return $pdf_out->toPDF;
 }
@@ -130,6 +129,11 @@ sub process_print_pdf {
   my $batch = FS::bill_batch->by_key($param->{batchnum});
   die "batch '$param->{batchnum}' not found!\n" if !$batch;
 
+  if ( $param->{'close'} ) {
+    my $error = $batch->close;
+    die $error if $error;
+  }
+
   my $pdf = $batch->print_pdf($job);
   $batch->pdf($pdf);
   my $error = $batch->replace;