RT#18439: Sorting routers alphabetically, routers disappear
[freeside.git] / bin / find-overapplied
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Data::Dumper;
5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch);
7 use FS::cust_credit;
8 use FS::cust_pay;
9
10 my $user = shift or die &usage;
11 adminsuidsetup $user;
12
13 my @credits  = grep { $_->credited  < 0 } qsearch('cust_credit', {});
14 my @payments = grep { $_->unapplied < 0 } qsearch('cust_pay',    {});
15
16 if ( @credits ) {
17   print scalar(@credits). " overapplied credits:\n". Dumper(@credits). "\n";
18 }
19
20 if ( @payments ) {
21   print scalar(@payments). " overapplied payments:\n". Dumper(@payments). "\n";
22 }
23
24 sub usage {
25   die "Usage:\n\n  find-overapplied user\n";
26 }
27