A few more ticket lookup subs.

This commit is contained in:
Bradley M. Kuhn 2018-07-15 09:05:58 -07:00
parent 7685bfc61a
commit b48b6b3945

View file

@ -31,6 +31,34 @@ sub FindUniqueTicket(@) {
close $rtLsFH;
return $ticketSpec;
}
sub PaymentDateByTicket($$) {
my($ticketSpec, $paymentNumber) = @_;
open(my $rtPayFH, "-|", "$RT_CMD", "show", "-f", 'CF.{payment-' . $paymentNumber . '-sent}', $ticketSpec);
my $date;
while (my $payLine = <$rtPayFH>) {
chomp $payLine;
if ($payLine =~ /[\d\-]+/) {
$date = $payLine;
last;
}
}
close $rtPayFH;
return $date;
}
sub LedgerTagFromTicket($$) {
my($ticketSpec, $tag) = @_;
open(my $rtPayFH, "-|", "$RT_CMD", "show", "-f", 'CF.{ledger-tags}', $ticketSpec);
my $tagValue;
while (my $tagsLine = <$rtPayFH>) {
chomp $tagsLine;
if ($tagsLine =~ /^\s*;?$tag\s*:\s*(.+)\s*$/i) {
$tagValue = $1;
last;
}
}
close $rtPayFH;
return $tagValue;
}
GetOptions("paymentDir=s" => \$PAYMENT_DIR, "verbose=i" => \$VERBOSE, "interactive" => \$INTERACTIVE,
"paymentNumber=i" => \$PAYMENT_NUMBER, "rtCommand=s" => $RT_CMD);