summaryrefslogtreecommitdiff
path: root/bin/find-overapplied
blob: 7973cef5b7da2d1adf9544bea67dec73120085f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl -w

use strict;
use Data::Dumper;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch);
use FS::cust_credit;
use FS::cust_pay;

my $user = shift or die &usage;
adminsuidsetup $user;

my @credits  = grep { $_->credited  < 0 } qsearch('cust_credit', {});
my @payments = grep { $_->unapplied < 0 } qsearch('cust_pay',    {});

if ( @credits ) {
  print scalar(@credits). " overapplied credits:\n". Dumper(@credits). "\n";
}

if ( @payments ) {
  print scalar(@payments). " overapplied payments:\n". Dumper(@payments). "\n";
}

sub usage {
  die "Usage:\n\n  find-overapplied user\n";
}