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") {