From b479a6d68dd25802d9e7a2890581166526d219f4 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 3 Nov 2024 15:50:51 -0800 Subject: [PATCH] Handle complexities of lapsing soon --- scripts/calculate-renewal-rate.plx | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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);