diff --git a/scripts/rt-outreachy-payment-next.plx b/scripts/rt-outreachy-payment-next.plx index 419d6ea..44aeee8 100755 --- a/scripts/rt-outreachy-payment-next.plx +++ b/scripts/rt-outreachy-payment-next.plx @@ -316,7 +316,27 @@ LEDGER_ENTRY } else { system($RT_CMD, "edit", $ticket, 'set', 'Status=entered'); } - system($RT_CMD, "link", '-d', $reimbursementTicket, 'dependson', $TRAVEL_NOTICE_TICKET); + open(my $delTravelDependsFH, "-|", $RT_CMD, "link", '-d', + $reimbursementTicket, 'dependson', $TRAVEL_NOTICE_TICKET); + my $found; + while (my $line = <$delTravelDependsFH>) { + if ($line =~ /Link\s+not\s+found/i) { + $found = 0; + } elsif ($line =~ /no\s+longer\s+depends\s+on\s+Ticket/i) { + $found = 1; + } + last if defined $found; + } + close $delTravelDependsFH; + if (not defined $found) { + print STDERR "\"$file\": \"$ticket\": WARNING: unable to determin what to do about Travel ticket, $TRAVEL_NOTICE_TICKET... "; + } else { + # This means we already activiated this travel ticket, so we have to explain to the intern + open(my $travelTicketCorrespondFH, "|-", $RT_CMD, 'correspond', $reimbursementTicket, '-m', '-'); + print $rtCorrespondFH "Previously, you received notice about your travel stipend. Please be advised that due to your failure in your internship, you no longer have a travel stipend budget.\n\n"; + print $rtCorrespondFH @dd; + close $rtCorrespondFH; + } system($RT_CMD, "edit", $reimbursementTicket, 'set', 'Status=open'); system($RT_CMD, "edit", $reimbursementTicket, 'set', 'Status=rejected'); }