Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / FS / FS / cust_pay_batch.pm
index a4b4957..8f31e4d 100644 (file)
@@ -129,6 +129,8 @@ and replace methods.
 sub check {
   my $self = shift;
 
+  my $conf = new FS::Conf;
+
   my $error = 
       $self->ut_numbern('paybatchnum')
     || $self->ut_numbern('trancode') #deprecated
@@ -137,7 +139,9 @@ sub check {
     || $self->ut_number('custnum')
     || $self->ut_text('address1')
     || $self->ut_textn('address2')
-    || $self->ut_text('city')
+    || ($conf->exists('cust_main-no_city_in_address') 
+        ? $self->ut_textn('city') 
+        : $self->ut_text('city'))
     || $self->ut_textn('state')
   ;
 
@@ -265,15 +269,15 @@ sub approve {
   my %opt = @_;
   my $paybatchnum = $new->paybatchnum;
   my $old = qsearchs('cust_pay_batch', { paybatchnum => $paybatchnum })
-    or return "paybatchnum $paybatchnum not found";
+    or return "cannot approve, paybatchnum $paybatchnum not found";
   # leave these restrictions in place until TD EFT is converted over
   # to B::BP
-  return "paybatchnum $paybatchnum already resolved ('".$old->status."')" 
+  return "cannot approve paybatchnum $paybatchnum, already resolved ('".$old->status."')" 
     if $old->status;
   $new->status('Approved');
   my $error = $new->replace($old);
   if ( $error ) {
-    return "error updating status of paybatchnum $paybatchnum: $error\n";
+    return "error approving paybatchnum $paybatchnum: $error\n";
   }
   my $cust_pay = new FS::cust_pay ( {
       'custnum'   => $new->custnum,
@@ -319,7 +323,7 @@ sub decline {
 
   my $paybatchnum = $new->paybatchnum;
   my $old = qsearchs('cust_pay_batch', { paybatchnum => $paybatchnum })
-    or return "paybatchnum $paybatchnum not found";
+    or return "cannot decline, paybatchnum $paybatchnum not found";
   if ( $old->status ) {
     # Handle the case where payments are rejected after the batch has been 
     # approved.  FS::pay_batch::import_results won't allow results to be 
@@ -346,7 +350,7 @@ sub decline {
     }
     else {
       # normal case: refuse to do anything
-      return "paybatchnum $paybatchnum already resolved ('".$old->status."')";
+      return "cannot decline paybatchnum $paybatchnum, already resolved ('".$old->status."')";
     }
   } # !$old->status
   $new->status('Declined');
@@ -354,7 +358,7 @@ sub decline {
   $new->failure_status($failure_status);
   my $error = $new->replace($old);
   if ( $error ) {
-    return "error updating status of paybatchnum $paybatchnum: $error\n";
+    return "error declining paybatchnum $paybatchnum: $error\n";
   }
   my $due_cust_event = $new->cust_main->due_cust_event(
     'eventtable'  => 'cust_pay_batch',