Adapt script to figure out problems with t-shirts
This commit is contained in:
parent
23487b3907
commit
010543c685
1 changed files with 24 additions and 5 deletions
|
@ -9,6 +9,11 @@ use Encode qw(encode decode);
|
||||||
|
|
||||||
use Supporters;
|
use Supporters;
|
||||||
|
|
||||||
|
use Date::Manip::DM5;
|
||||||
|
|
||||||
|
my $TODAY = UnixDate(ParseDate("today"), '%Y-%m-%d');
|
||||||
|
my $ONE_YEAR_AGO = UnixDate(DateCalc(ParseDate("today"), "- 1 year"), '%Y-%m-%d');
|
||||||
|
|
||||||
my $LEDGER_CMD = "/usr/local/bin/ledger";
|
my $LEDGER_CMD = "/usr/local/bin/ledger";
|
||||||
|
|
||||||
if (@ARGV < 5 ) {
|
if (@ARGV < 5 ) {
|
||||||
|
@ -28,13 +33,27 @@ my(@supporterIds) = $sp->findDonor({});
|
||||||
|
|
||||||
foreach my $id (@supporterIds) {
|
foreach my $id (@supporterIds) {
|
||||||
my $amount = $sp->donorTotalGaveInPeriod(donorId => $id);
|
my $amount = $sp->donorTotalGaveInPeriod(donorId => $id);
|
||||||
if ($amount > 120.00) { # Ok, so they gave more than the minimum
|
my $lastGaveDate = $sp->donorLastGave($id);
|
||||||
|
my $firstGaveDate = $sp->donorFirstGave($id);
|
||||||
|
if ($amount > 180.00 and $lastGaveDate ne $firstGaveDate and $firstGaveDate le $ONE_YEAR_AGO) { # Ok, so they gave more than the minimum a year later
|
||||||
my $ledgerEntityId = $sp->getLedgerEntityId($id);
|
my $ledgerEntityId = $sp->getLedgerEntityId($id);
|
||||||
my $lastGaveDate = $sp->donorLastGave($id);
|
my $type = $sp->{ledgerData}{ledgerData}{__TYPE__};
|
||||||
my $firstGaveDate = $sp->donorFirstGave($id);
|
my $shirt1 = $sp->getRequest({ donorId => $id, requestType => 't-shirt-1' });
|
||||||
if ($lastGaveDate ne $firstGaveDate) {
|
my $shirt0 = $sp->getRequest({ donorId => $id, requestType => 't-shirt-0' });
|
||||||
print "$ledgerEntityId gave total of $amount, firstGave $firstGaveDate, last Gave $lastGaveDate\n";
|
if (not defined $shirt0 and not defined $shirt1) {
|
||||||
|
print "NEVER WANTED SHIRT: ";
|
||||||
|
} elsif (defined $shirt0 and not defined $shirt1) {
|
||||||
|
if (not defined $shirt0->{fulfillDate}) {
|
||||||
|
print "NEEDS 2 SHIRTS, 2ND SHIRT REQUEST MISSING: ";
|
||||||
|
} else {
|
||||||
|
print "NEEDS 1 SHIRT, 2ND SHIRT REQUEST MISSING: ";
|
||||||
|
}
|
||||||
|
} elsif (defined $shirt1 and not defined $shirt0) {
|
||||||
|
print "NEEDS WEIRDNESS ATTENTION, NO SHIRT0 REQUEST BUT THERE IS A SHIRT1 REQUEST: ";
|
||||||
|
} elsif (defined $shirt1 and defined $shirt0) {
|
||||||
|
print "ALL OK, 2 SHIRTS, WITH REQUESTS: ";
|
||||||
}
|
}
|
||||||
|
print " $ledgerEntityId gave total of $amount, firstGave $firstGaveDate, last Gave $lastGaveDate\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
Loading…
Reference in a new issue