invoice mode in PDF spools, RT#39587
[freeside.git] / FS / FS / cust_bill.pm
index 3ee6d47..79dbbba 100644 (file)
@@ -1115,9 +1115,8 @@ sub queueable_email {
   my $self = qsearchs('cust_bill', { 'invnum' => $opt{invnum} } )
     or die "invalid invoice number: " . $opt{invnum};
 
   my $self = qsearchs('cust_bill', { 'invnum' => $opt{invnum} } )
     or die "invalid invoice number: " . $opt{invnum};
 
-  if ( $opt{mode} ) {
-    $self->set('mode', $opt{mode});
-  }
+  $self->set('mode', $opt{mode})
+    if $opt{mode};
 
   my %args = map {$_ => $opt{$_}} 
              grep { $opt{$_} }
 
   my %args = map {$_ => $opt{$_}} 
              grep { $opt{$_} }
@@ -1258,6 +1257,10 @@ sub batch_invoice {
       batchnum => $bill_batch->batchnum,
       invnum   => $self->invnum,
   });
       batchnum => $bill_batch->batchnum,
       invnum   => $self->invnum,
   });
+  if ( $self->mode ) {
+    $opt->{mode} ||= $self->mode;
+    $opt->{mode} = $opt->{mode}->modenum if ref $opt->{mode};
+  }
   return $cust_bill_batch->insert($opt);
 }
 
   return $cust_bill_batch->insert($opt);
 }