Giving limit for donor to receive t-shirt.

Analysis of IRS rules indicate that sometimes, a thank-you gift can't be
sent unless the percentage the gift is of the donation meets a certain
threshold.

This change allows the caller of this script to implement that sort of
threshold.
This commit is contained in:
Bradley M. Kuhn 2016-01-08 13:10:20 -08:00
parent e43b6e34ae
commit cf8cc36045

View file

@ -13,12 +13,12 @@ use Supporters;
my $LEDGER_CMD = "/usr/local/bin/ledger";
if (@ARGV != 3 and @ARGV != 4) {
print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <SIZE_COUNTS> <OUTPUT_DIRECTORY> <VERBOSE>\n";
if (@ARGV != 4 and @ARGV != 5) {
print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <GIVING_LIMIT> <SIZE_COUNTS> <OUTPUT_DIRECTORY> <VERBOSE>\n";
exit 1;
}
my($SUPPORTERS_SQLITE_DB_FILE, $SIZE_COUNTS, $OUTPUT_DIRECTORY, $VERBOSE) = @ARGV;
my($SUPPORTERS_SQLITE_DB_FILE, $GIVING_LIMIT, $SIZE_COUNTS, $OUTPUT_DIRECTORY, $VERBOSE) = @ARGV;
$VERBOSE = 0 if not defined $VERBOSE;
open(SIZE_COUNTS, "<", $SIZE_COUNTS);
@ -75,6 +75,13 @@ foreach my $id (@supporterIds) {
}
}
next if not defined $sizeNeeded; # If we don't need a size, we don't have a request.
my $amount = $sp->donorTotalGaveInPeriod(donorId => $id);
if ($amount < $GIVING_LIMIT) {
print "Skipping $id request for $sizeNeeded because donor only gave $amount and giving limit is $GIVING\n" if $VERBOSE;
next;
}
my(@postalAddresses) = $sp->getPostalAddresses($id);
my $latexPostal = latex_encode($postalAddresses[0]);
if ($latexPostal =~ /unmatched/) {