From f00819a1745e6108bc3855e18b514cfc93d02aa9 Mon Sep 17 00:00:00 2001
From: "Bradley M. Kuhn" <bkuhn@ebb.org>
Date: Sun, 22 Jul 2018 15:22:16 -0700
Subject: [PATCH] Correct tax ticket processing.

---
 scripts/rt-outreachy-payment-next.plx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/rt-outreachy-payment-next.plx b/scripts/rt-outreachy-payment-next.plx
index 250ef48..599096e 100755
--- a/scripts/rt-outreachy-payment-next.plx
+++ b/scripts/rt-outreachy-payment-next.plx
@@ -70,7 +70,7 @@ sub GetLinksForTicket($) {
   my @linked;
   open(my $rtLinksFH, "-|", "$RT_CMD", "show", $ticketSpec . '/links');
   while (my $linksLine = <$rtLinksFH>) {
-    if ($linksLine =~ m%rt.*ticket/(\d+)\s*$%) {
+    if ($linksLine =~ m%rt.*(ticket/\d+)\s*,?\s*$%) {
       push(@linked, $1);
     }
   }
@@ -92,7 +92,6 @@ sub FindTaxTicketFromList(@) {
     close $rtQueueFH;
     last if defined $taxTicket;
   }
-  $taxTicket = "ticket/$taxTicket" if defined $taxTicket;
   return $taxTicket;
 }
 ###############################################################################
@@ -236,10 +235,15 @@ while (my $file = readdir $dh) {
   }
 
   my(@links) = GetLinksForTicket($ticket);
+  if ($VERBOSE > 5) {
+    print STDERR "\"$file\": \"$ticket\": Found the following links: " , join( ", ", @links), "\n";
+  }
   my $taxTicket = FindTaxTicketFromList(@links);
   if (not defined $taxTicket) {
     print STDERR "\"$file\": \"$ticket\": Skipped: no tax ticket found.\n";
+    next;
   }
+  print STDERR "\"$file\": \"$ticket\": found a tax ticket of \"$taxTicket\"\n" if ($VERBOSE > 5);
   my $taxTicketStatus = GetStatusFromTicket($taxTicket);
   if ($taxTicketStatus ne "resolved") {
     print STDERR "\"$file\": \"$ticket\": Tax Ticket: \"$taxTicket\": Skipped:  ",