From c2443bfcf7b0b8c62c90650588f65c0d2bf3bbc4 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Tue, 10 Dec 2019 09:37:38 -0800 Subject: [PATCH] Rework to handle multiple t-shirt designs. --- scripts/t-shirt-label-print.plx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/t-shirt-label-print.plx b/scripts/t-shirt-label-print.plx index dc07b91..08ae138 100644 --- a/scripts/t-shirt-label-print.plx +++ b/scripts/t-shirt-label-print.plx @@ -80,9 +80,14 @@ sub sortFunction($$) { } } my @typeList; -if ($T_SHIRT_STYLE == 0) { +my @oldTypeList; +if ($T_SHIRT_STYLE eq 'fy2018design') { + @typeList = qw/t-shirt-fy2018design-0/; + @oldTypeList = qw/t-shirt-0 t-shirt-1 t-shirt-extra-0 t-shirt-extra-1/; +} elsif ($T_SHIRT_STYLE == 0) { @typeList = qw/t-shirt-0 t-shirt-extra-0/; } elsif ($T_SHIRT_STYLE == 1) { + @oldTypeList = qw/t-shirt-0 t-shirt-extra-0/; @typeList = qw/t-shirt-1 t-shirt-extra-1/; } else { die "Unknown t-shirt style given: $T_SHIRT_STYLE"; @@ -100,9 +105,14 @@ foreach my $id (sort { sortFunction($a, $b); } @supporterIds) { } next if not defined $sizeNeeded; # If we don't need a size, we don't have a request. + my $shirtCount = 1; # Count 1 for the one we're about to send and... + foreach my $oldType (@oldTypeList) { + # ... cound each one off the old list + $shirtCount++ if (defined $sp->getRequest({ donorId => $id, requestType => $oldType})); + } 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_LIMIT\n" if $VERBOSE; + if ($amount < ($GIVING_LIMIT * $shirtCount)) { + print "Skipping $id request for $sizeNeeded because donor has requested $shirtCount shirts, only gave $amount and giving limit is $GIVING_LIMIT\n" if $VERBOSE; next; }