diff --git a/scripts/calculate-renewal-rate.plx b/scripts/calculate-renewal-rate.plx index 153c708..00da1a0 100644 --- a/scripts/calculate-renewal-rate.plx +++ b/scripts/calculate-renewal-rate.plx @@ -35,7 +35,19 @@ my $yearTot = 0.00; my %specialContributions; foreach my $supporterId (@supporterIds) { my $expiresOn = $sp->supporterExpirationDate($supporterId); + my $type = $sp->getType($supporterId); + # Lapses soon calculation is complicated. Annuals can use the how far in + # advance setting, but we really can't with monthlies. For all we know, a + # monthly donation is about to come in for them, so until they reach their + # 60-day expired mark, which is already included in the expiration date by + # the library, we have to assume they're donation is coming in. my $isLapsed = ( (not defined $expiresOn) or $expiresOn lt $TODAY); + my $lapsesSoon; + if (defined $expiresOn) { + $lapsesSoon = ($expiresOn le $HOW_FAR_IN_ADVANCE) if ($type =~ /ann/i); + $lapsesSoon = ($expiresOn lt $TODAY) if ($type =~ /month/i); + } + $expiresOn = "NO-FULL-SIGNUP" if not defined $expiresOn; if (not $isLapsed) { my $lastYearGave = $sp->donorTotalGaveInPeriod(donorId => $supporterId, startDate => $ONE_YEAR_AGO, endDate => $TODAY);