Compare commits
10 commits
b5bb608067
...
7d24d42788
Author | SHA1 | Date | |
---|---|---|---|
|
7d24d42788 | ||
|
927bb55547 | ||
|
a85a3777b3 | ||
|
6c2d685116 | ||
|
880da9360c | ||
|
ca31ce7c8f | ||
|
877f50996f | ||
|
5a16830b12 | ||
|
11d060a2fa | ||
|
8ac2663124 |
6 changed files with 91 additions and 34 deletions
|
@ -46,28 +46,27 @@ sub FindMostRecentPaymentMethodForTicket ($) {
|
||||||
$ticketSpec =~ s%^\s*ticket\s*/\s*%%;
|
$ticketSpec =~ s%^\s*ticket\s*/\s*%%;
|
||||||
open(my $rtShowFH, "-|", "$RT_CMD", "show", '-t', 'ticket', '-f', 'CF.{payment-method}', $ticketSpec);
|
open(my $rtShowFH, "-|", "$RT_CMD", "show", '-t', 'ticket', '-f', 'CF.{payment-method}', $ticketSpec);
|
||||||
my($ticketDataAgain, $value) = <$rtShowFH>;
|
my($ticketDataAgain, $value) = <$rtShowFH>;
|
||||||
|
|
||||||
close $rtShowFH;
|
close $rtShowFH;
|
||||||
|
chomp $value; $value =~ s/^\s*cf.\{payment-method\}\s*:\s+(.*)$/$1/i
|
||||||
chomp $value; $value =~ s/^\s*cf.{payment-method}\s*:\s+(.*)$/$1/i
|
|
||||||
or warn "$ticketSpec: Unknown value for payment-method of \"$value\"";
|
or warn "$ticketSpec: Unknown value for payment-method of \"$value\"";
|
||||||
|
|
||||||
if (not defined $value or $value =~ /^\s*$/) {
|
if (not defined $value or $value =~ /^\s*$/) {
|
||||||
$value = "NO-CF-SET";
|
$value = "NO-CF-SET";
|
||||||
} elsif ($value ne 'FX Wire') {
|
|
||||||
return $value unless $SHOW_AMOUNTS;
|
|
||||||
}
|
|
||||||
$ticketSpec =~ s%^\s*ticket\s*/\s*%%;
|
|
||||||
open($rtShowFH, "-|", "$RT_CMD", "show", $ticketSpec);
|
|
||||||
while (my $showLine = <$rtShowFH>) {
|
|
||||||
print STDERR "rt show line for $ticketSpec: $showLine" if ($VERBOSE >= 10);
|
|
||||||
$paymentMethod = lc($1)
|
|
||||||
if ($showLine =~ /^\s*PAYMENT\s+METHOD\s*:\s*(.*?)\s*$/);
|
|
||||||
# don't 'last' when found as we want the last one.
|
|
||||||
$AMOUNTS{$ticketSpec} = $1
|
|
||||||
if ($showLine =~ /^\s*(?:TOTAL|AMOUNT)(?:\s*TO\s*PAY)?\s*:\s*(.*?)\s*$/i);
|
|
||||||
}
|
}
|
||||||
|
if ($SHOW_AMOUNTS) {
|
||||||
|
open(my $rtShowFH, "-|", "$RT_CMD", "show", '-t', 'ticket', '-f', 'CF.{payment-amount}', $ticketSpec);
|
||||||
|
my($ticketDataYetAgain, $curAndAmount) = <$rtShowFH>;
|
||||||
close $rtShowFH;
|
close $rtShowFH;
|
||||||
return ($value eq 'FX Wire' or $value eq 'NO-CF-SET') ? "$value: $paymentMethod" : $value;
|
chomp $curAndAmount; $curAndAmount =~ s/^\s*cf.\{payment-amount\}\s*:\s+(.*)$/$1/i;
|
||||||
|
$ticketSpec =~ s%^\s*ticket\s*/\s*%%;
|
||||||
|
$curAndAmount = "USD -32767.69" if not defined $curAndAmount;
|
||||||
|
$curAndAmount =~ /^\s*([A-Z]{3,3})\s+([\-\d\,\.]+)(\s+\(\s*\$\s*[\-\d\,\.]+\s*\))?\s*$/
|
||||||
|
or die "Ticket, $ticketSpec, has amount of $curAndAmount";
|
||||||
|
($AMOUNTS{$ticketSpec}{currency}, $AMOUNTS{$ticketSpec}{amount}) = ($1, $2);
|
||||||
|
$AMOUNTS{$ticketSpec}{amount} =~ s/\$//g; $AMOUNTS{$ticketSpec}{amount} =~ s/,//g;
|
||||||
|
$AMOUNTS{$ticketSpec}{currency} =~ s/\s//g;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -101,23 +100,28 @@ foreach my $ticketSpec (@ticketSpecs) {
|
||||||
push(@{$payments{$paymentMethod}}, $ticketSpec);
|
push(@{$payments{$paymentMethod}}, $ticketSpec);
|
||||||
}
|
}
|
||||||
print "#" x 70, "\n";
|
print "#" x 70, "\n";
|
||||||
my ($overallTotal, $overallTotalOk) = (0.00, 1);
|
my $overallTotalOk = 1;
|
||||||
|
my %overallTotals;
|
||||||
foreach my $paymentMethod (sort { $a cmp $b } keys %payments) {
|
foreach my $paymentMethod (sort { $a cmp $b } keys %payments) {
|
||||||
print "$paymentMethod: Count: ", scalar(@{$payments{$paymentMethod}}), "\n";
|
print "$paymentMethod: Count: ", scalar(@{$payments{$paymentMethod}}), "\n";
|
||||||
print " Tickets: ", join(" ", map { s%^\s*ticket\s*/\s*%%; $_; } @{$payments{$paymentMethod}}), "\n";
|
print " Tickets: ", join(" ", map { s%^\s*ticket\s*/\s*%%; $_; } @{$payments{$paymentMethod}}), "\n";
|
||||||
my($subTotal, $subTotalOk) = (0.00, 1);
|
my $subTotalOk = 1;
|
||||||
|
my %subTotals;
|
||||||
if ($SUB_TOTALS) {
|
if ($SUB_TOTALS) {
|
||||||
foreach my $tix (@{$payments{$paymentMethod}}) {
|
foreach my $tix (@{$payments{$paymentMethod}}) {
|
||||||
$tix =~ s%^\s*ticket\s*/\s*%%;
|
$tix =~ s%^\s*ticket\s*/\s*%%;
|
||||||
my $val = $AMOUNTS{$tix};
|
my($currency, $val) = ($AMOUNTS{$tix}{currency}, $AMOUNTS{$tix}{amount});
|
||||||
print "$tix: $AMOUNTS{$tix}\n";
|
$subTotals{$currency} = 0.00 unless defined $subTotals{$currency};
|
||||||
$val =~ s/\$//g; $val =~ s/,//g; $val =~ s/\s//g;
|
print sprintf(" %5d: %.2f %3.3s\n", $tix, $val, $currency);
|
||||||
if ($val =~ /^[\d\.]+$/) { $subTotal += $val; } else { $subTotalOk = 0; }
|
if (defined $val and $val =~ /^[\d\.]+$/) { $subTotals{$currency} += $val; } else { $subTotalOk = 0; }
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($subTotalOk) {
|
if ($subTotalOk) {
|
||||||
print "SUBTOTAL for $paymentMethod: $subTotal\n";
|
print sprintf("%30s", "SUBTOTAL for $paymentMethod\n");
|
||||||
$overallTotal += $subTotal;
|
foreach my $currency (keys %subTotals) {
|
||||||
|
print sprintf("%30s %.2f %3.3s\n\n", " ", $subTotals{$currency}, $currency);
|
||||||
|
$overallTotals{$currency} = 0.00 unless defined $overallTotals{$currency};
|
||||||
|
$overallTotals{$currency} += $subTotals{$currency};
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$overallTotalOk = 0;
|
$overallTotalOk = 0;
|
||||||
}
|
}
|
||||||
|
@ -126,14 +130,19 @@ foreach my $paymentMethod (sort { $a cmp $b } keys %payments) {
|
||||||
if ($SHOW_AMOUNTS and not $SUB_TOTALS) {
|
if ($SHOW_AMOUNTS and not $SUB_TOTALS) {
|
||||||
print "Unable to find amounts for all tickets\n" if (scalar(@ticketSpecs) != scalar(keys %AMOUNTS));
|
print "Unable to find amounts for all tickets\n" if (scalar(@ticketSpecs) != scalar(keys %AMOUNTS));
|
||||||
foreach my $tix (sort { $a <=> $b} (keys %AMOUNTS)) {
|
foreach my $tix (sort { $a <=> $b} (keys %AMOUNTS)) {
|
||||||
my $val = $AMOUNTS{$tix};
|
foreach my $currency (keys %overallTotals) {
|
||||||
print "$tix: $AMOUNTS{$tix}\n";
|
my $val = $AMOUNTS{$tix}{$currency};
|
||||||
$val =~ s/\$//g; $val =~ s/,//g; $val =~ s/\s//g;
|
print sprintf("%5d: %.2f %3.3d\n", $tix, $val, $currency);
|
||||||
if ($val =~ /^[\d\.]+$/) { $overallTotal += $val; } else { $overallTotalOk = 0; }
|
$overallTotals{$currency} = 0.00 unless defined $overallTotals{$currency};
|
||||||
|
if ($val =~ /^[\d\.]+$/) { $overallTotals{$currency} += $val; } else { $overallTotalOk = 0; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($overallTotalOk and $SHOW_AMOUNTS) {
|
||||||
|
print sprintf("%30s:\n", "TOTAL AMOUNT");
|
||||||
|
foreach my $currency (keys %overallTotals) {
|
||||||
|
print sprintf("%30s %.2f %3.3s\n\n", " ", $overallTotals{$currency}, $currency);
|
||||||
}
|
}
|
||||||
print "\nTOTAL AMOUNT: $overallTotal\n" if $overallTotalOk;
|
|
||||||
} elsif ($SUB_TOTALS) {
|
|
||||||
print "\nTOTAL AMOUNT: $overallTotal\n" if $overallTotalOk;
|
|
||||||
}
|
}
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
|
|
|
@ -50,6 +50,7 @@ sub GetLinksForTicket($) {
|
||||||
my %linked;
|
my %linked;
|
||||||
open(my $rtLinksFH, "-|", "$RT_CMD", "show", $ticketSpec . '/links');
|
open(my $rtLinksFH, "-|", "$RT_CMD", "show", $ticketSpec . '/links');
|
||||||
my $type = 'NONE';
|
my $type = 'NONE';
|
||||||
|
print STDERR "rt-helper: GetLinksForTicket: starting\n" if ($VERBOSE > 9);
|
||||||
while (my $linksLine = <$rtLinksFH>) {
|
while (my $linksLine = <$rtLinksFH>) {
|
||||||
print STDERR "rt-helper: GetLinksForTicket: processing line: $linksLine\n" if ($VERBOSE > 9);
|
print STDERR "rt-helper: GetLinksForTicket: processing line: $linksLine\n" if ($VERBOSE > 9);
|
||||||
if ($linksLine =~ m%^([^:\s]+)\s*:%) {
|
if ($linksLine =~ m%^([^:\s]+)\s*:%) {
|
||||||
|
@ -127,7 +128,9 @@ sub FindReimbursementTicketFromList($@) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{ no autodie qw(:all);
|
||||||
close $rtReimburseFH;
|
close $rtReimburseFH;
|
||||||
|
}
|
||||||
last if defined $reimbursementTicket;
|
last if defined $reimbursementTicket;
|
||||||
}
|
}
|
||||||
return $reimbursementTicket;
|
return $reimbursementTicket;
|
||||||
|
|
|
@ -265,7 +265,8 @@ foreach my $ticket (@processList) {
|
||||||
} elsif ($line =~ /^\s*([^:]+)\s*:\s*(.+)$/) {
|
} elsif ($line =~ /^\s*([^:]+)\s*:\s*(.+)$/) {
|
||||||
my($key, $val) = ($1, $2);
|
my($key, $val) = ($1, $2);
|
||||||
# Note that this will take the last one used, since rt log gives ticket traffic IN ORDER.
|
# Note that this will take the last one used, since rt log gives ticket traffic IN ORDER.
|
||||||
if ($key =~ /(CONTRACTED NAME|PAYMENT NAME|PAYMENT METHOD)/i) {
|
$key =~ s/^\s*//; $key =~ s/\s*$//;
|
||||||
|
if ($key =~ /^(CONTRACTED NAME|PAYMENT NAME|PAYMENT METHOD)$/i) {
|
||||||
$paymentVals{$key} = $val;
|
$paymentVals{$key} = $val;
|
||||||
print STDERR "\"$ticket\": rt show $ticketNum line match: $key $val for $line\n" if ($VERBOSE > 7);
|
print STDERR "\"$ticket\": rt show $ticketNum line match: $key $val for $line\n" if ($VERBOSE > 7);
|
||||||
}
|
}
|
||||||
|
|
43
scripts/rt-reassign.plx
Executable file
43
scripts/rt-reassign.plx
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
# Copyright © 2020, Bradley M. Kuhn
|
||||||
|
# License: AGPL-3.0-or-later
|
||||||
|
# probably want to pipe in: rt ls -i "Status = 'needs-release-approval'" | xargs -I_ rt show -f DependsOn _/links | grep -Eo '[0-9]+,?' | sed -e 's/,$//'
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use autodie qw(:all);
|
||||||
|
my $RT_CMD = '/usr/bin/rt';
|
||||||
|
|
||||||
|
my($queue, $oldUser, $newUser) = @ARGV;
|
||||||
|
|
||||||
|
my $count = 0;
|
||||||
|
foreach my $id (<STDIN>) {
|
||||||
|
chomp $id;
|
||||||
|
my $line;
|
||||||
|
open(my $rtShowFH, "-|", "$RT_CMD", "show", '-t', 'ticket', '-f', 'Queue,id,status,owner', $id);
|
||||||
|
my %tixData;
|
||||||
|
while (my $line = <$rtShowFH>) {
|
||||||
|
die "$id: invalid line: $line" unless $line =~ /^(\S+)\s*:\s+(\S+)\s*$/;
|
||||||
|
$tixData{$1} = $2;
|
||||||
|
}
|
||||||
|
close $rtShowFH;
|
||||||
|
|
||||||
|
die "$tixData{id} is not $id" unless $tixData{id} =~ /$id/;
|
||||||
|
die "$id: missing status or Owner" unless defined $tixData{Status} and defined $tixData{Owner};
|
||||||
|
|
||||||
|
my $skip = 0;
|
||||||
|
if ($tixData{Queue} ne $queue) {
|
||||||
|
$skip++; print STDERR "$id: skipping since status $tixData{Queue}\n";
|
||||||
|
} elsif ($tixData{Status} ne 'open') {
|
||||||
|
$skip++; print STDERR "$id: skipping since status $tixData{Status} is not open\n"
|
||||||
|
} elsif ($tixData{Owner} ne $oldUser) {
|
||||||
|
$skip++; print STDERR "$id: skipping since status $tixData{Owner} is not $oldUser\n" unless $tixData{Owner} eq $oldUser;
|
||||||
|
}
|
||||||
|
next if $skip > 0;
|
||||||
|
print STDERR "$id: reassigning to $newUser\n";
|
||||||
|
system($RT_CMD, 'edit', $id, 'set', "Owner=$newUser");
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Reassigned $count tickets to $newUser from $oldUser\n";
|
1
scripts/rt-set-deadline-from-last-correspondence.plx
Normal file → Executable file
1
scripts/rt-set-deadline-from-last-correspondence.plx
Normal file → Executable file
|
@ -5,6 +5,7 @@
|
||||||
# This script finds the most recent correspondence from the requestor, and
|
# This script finds the most recent correspondence from the requestor, and
|
||||||
# sets the Due date out from that, based on the CLI input using Date::Manip
|
# sets the Due date out from that, based on the CLI input using Date::Manip
|
||||||
|
|
||||||
|
# should also add correspondence to note it wsa received. Easiest way to send template?
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue