From afb3bbc3400875e0c538be3160287114936537e6 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 12 Sep 2018 15:57:53 -0700 Subject: [PATCH] Handle activated travel reimbursement tickets properly. Travel reimbursement tickets might already be activated. We track activation by leaving them to "dependson" the main travel ticket, and hav them only refersto relationship once activated. In cases where the dependson link does not exist, then we should send notice upon failure when rejecting the ticket. --- scripts/rt-outreachy-payment-next.plx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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'); }