add debugging and ->finish() before ->disconnect call
[freeside.git] / FS / FS / cust_pay.pm
index eee263a..388aef7 100644 (file)
@@ -12,6 +12,7 @@ use Text::Template;
 use FS::UID qw( getotaker );
 use FS::Misc qw( send_email );
 use FS::Record qw( dbh qsearch qsearchs );
+use FS::CurrentUser;
 use FS::payby;
 use FS::cust_main_Mixin;
 use FS::payinfo_transaction_Mixin;
@@ -374,7 +375,7 @@ returns the error, otherwise returns false.  Called by the insert method.
 sub check {
   my $self = shift;
 
-  $self->otaker(getotaker) unless ($self->otaker);
+  $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum;
 
   my $error =
     $self->ut_numbern('paynum')
@@ -458,12 +459,15 @@ sub send_receipt {
 
     my $error = '';
 
-    if( $conf->exists('payment_receipt_msgnum') ) {
+    if ( $conf->exists('payment_receipt_msgnum')
+         && $conf->config('payment_receipt_msgnum')
+       )
+    {
       my $msg_template = 
           FS::msg_template->by_key($conf->config('payment_receipt_msgnum'));
       $error = $msg_template->send('cust_main'=> $cust_main, 'object'=> $self);
-    }
-    elsif ( $conf->exists('payment_receipt_email') ) {
+
+    elsif ( $conf->exists('payment_receipt_email') ) {
       my $receipt_template = new Text::Template (
         TYPE   => 'ARRAY',
         SOURCE => [ map "$_\n", $conf->config('payment_receipt_email') ],
@@ -506,8 +510,7 @@ sub send_receipt {
         'body'    => [ $receipt_template->fill_in( HASH => \%fill_in ) ],
       );
 
-    } 
-    else { # no payment_receipt_msgnum or payment_receipt_email
+    } else { # no payment_receipt_msgnum or payment_receipt_email
 
       my $queue = new FS::queue {
          'paynum' => $self->paynum,