From 48ec393a019cc30cb5e78b8e3e73241ee5c4e331 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 22 Jul 2018 16:35:35 -0700 Subject: [PATCH] Support lookup of reimbursement ticket --- scripts/rt-outreachy-payment-next.plx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/rt-outreachy-payment-next.plx b/scripts/rt-outreachy-payment-next.plx index 0729ac8..06b209f 100755 --- a/scripts/rt-outreachy-payment-next.plx +++ b/scripts/rt-outreachy-payment-next.plx @@ -95,6 +95,27 @@ sub FindTaxTicketFromList(@) { return $taxTicket; } ############################################################################### +sub FindReimbursementTicketFromList(@) { + my $reimbursementTicket; + foreach my $ticket (@_) { + $ticket =~ s%\s*ticket/?\s*(\d+)\s*%$1%; + open(my $rtReimburseFH, "-|", "$RT_CMD", "ls", "-i", 'Queue = accounts-payable AND ' . + "Subject LIKE 'reimbursement' and Subject LIKE 'travel' and id = " . $ticket); + while (my $reimburseLine = <$rtReimburseFH>) { + if ($reimburseLine =~ m%\s*ticket\s*/?\s*(\d+)\s*$%) { + my $tt = $1; + if ($tt == $ticket) { + $reimbursementTicket = $ticket; + last; + } + } + } + close $rtReimburseFH; + last if defined $reimbursementTicket; + } + return $reimbursementTicket; +} +############################################################################### sub GetStatusFromTicket($) { my($ticketSpec) = @_; my $status; @@ -260,6 +281,11 @@ while (my $file = readdir $dh) { print STDERR "\"$file\": \"$ticket\": Skipped: no tax ticket found.\n"; next; } + my $reimbursementTicket = FindReimbursementTicketFromList(@links); + if (not defined $reimbursementTicket) { + print STDERR "\"$file\": \"$ticket\": Skipped: no reimbursement 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") {