Correct tax ticket processing.

This commit is contained in:
Bradley M. Kuhn 2018-07-22 15:22:16 -07:00
parent 2598a6f739
commit f00819a174

View file

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