also retry cards when user clicks "Bill now" (closes: Bug#417)
authorivan <ivan>
Mon, 10 Jun 2002 22:48:03 +0000 (22:48 +0000)
committerivan <ivan>
Mon, 10 Jun 2002 22:48:03 +0000 (22:48 +0000)
FS/FS/cust_main.pm
httemplate/misc/bill.cgi

index 8a0124a..b6600fb 100644 (file)
@@ -485,6 +485,7 @@ sub replace {
   if ( $self->payby eq 'CARD' &&
        grep { $self->get($_) ne $old->get($_) } qw(payinfo paydate payname) ) {
     # card info has changed, want to retry realtime_card invoice events
+    #false laziness w/collect
     foreach my $cust_bill_event (
       grep {
              #$_->part_bill_event->plan eq 'realtime-card'
@@ -500,6 +501,7 @@ sub replace {
         return "error scheduling invoice events for retry: $error";
       }
     }
+    #eslaf
 
   }
 
@@ -1192,6 +1194,8 @@ invoice_time - Use this time when deciding when to print invoices and
 late notices on those invoices.  The default is now.  It is specified as a UNIX timestamp; see L<perlfunc/"time">).  Also see L<Time::Local> and L<Date::Parse>
 for conversion functions.
 
+retry_card - Retry cards even when not scheduled by invoice events.
+
 batch_card - This option is deprecated.  See the invoice events web interface
 to control whether cards are batched or run against a realtime gateway.
 
@@ -1224,6 +1228,26 @@ sub collect {
     return '';
   }
 
+  if ( exists($options{'retry_card'}) && $options{'retry_card'} ) {
+    #false laziness w/replace
+    foreach my $cust_bill_event (
+      grep {
+             #$_->part_bill_event->plan eq 'realtime-card'
+             $_->part_bill_event->eventcode eq '$cust_bill->realtime_card();'
+               && $_->status eq 'done'
+               && $_->statustext
+           }
+        $self->open_cust_bill->cust_bill_event
+    ) {
+      my $error = $cust_bill_event->retry;
+      if ( $error ) {
+        $dbh->rollback if $oldAutoCommit;
+        return "error scheduling invoice events for retry: $error";
+      }
+    }
+    #eslaf
+  }
+
   foreach my $cust_bill ( $self->cust_bill ) {
 
     #this has to be before next's
@@ -1242,6 +1266,7 @@ sub collect {
 
     next unless $amount > 0;
 
+
     foreach my $part_bill_event (
       sort {    $a->seconds   <=> $b->seconds
              || $a->weight    <=> $b->weight
index 6f523a5..f048e55 100755 (executable)
@@ -18,9 +18,10 @@ unless ( $error ) {
 
   $error = $cust_main->collect(
   #                             'invoice-time'=>$time,
-  #                             'batch_card'=> 'yes',
-                               'batch_card'=> 'no',
-                               'report_badcard'=> 'yes',
+                               #'batch_card'=> 'yes',
+                               #'batch_card'=> 'no',
+                               #'report_badcard'=> 'yes',
+                               'retry_card' => 'yes',
                               );
 }
 #&eidiot($error) if $error;