Find lapsed large donors separately and report.

This generates a report for particular large donors who are lapsed.
This commit is contained in:
Bradley M. Kuhn 2016-12-31 17:51:21 -08:00
parent fda04200df
commit 7d39d40e61

View file

@ -208,6 +208,9 @@ foreach my $type (keys %lapsedCounter) {
$headerInfo .= "\n"; $headerInfo .= "\n";
my $emailText .= $headerInfo; my $emailText .= $headerInfo;
my $allStaffEmailText = $headerInfo; my $allStaffEmailText = $headerInfo;
my $bigDonorEmailText = "\n LAPSED BIG DONORS\n" .
" =================\n";
$emailText .= "\n RENEWAL DUE COUNT BY MONTH\n"; $emailText .= "\n RENEWAL DUE COUNT BY MONTH\n";
$emailText .= "\n ==========================\n"; $emailText .= "\n ==========================\n";
$allStaffEmailText .= "\n RENEWAL DUE COUNT BY MONTH\n"; $allStaffEmailText .= "\n RENEWAL DUE COUNT BY MONTH\n";
@ -233,11 +236,19 @@ foreach my $cat (sort { $a cmp $b } @lapseCategories) {
startDate => $THREE_YEARS_AGO, endDate => $TODAY); startDate => $THREE_YEARS_AGO, endDate => $TODAY);
my $twoYearTot = $sp->donorTotalGaveInPeriod(donorId => $sup->{supporterId}, my $twoYearTot = $sp->donorTotalGaveInPeriod(donorId => $sup->{supporterId},
startDate => $TWO_YEARS_AGO, endDate => $TODAY); startDate => $TWO_YEARS_AGO, endDate => $TODAY);
my $oneYearTot = $sp->donorTotalGaveInPeriod(donorId => $sup->{supporterId},
startDate => $ONE_YEAR_AGO, endDate => $TODAY);
$emailText .= " $sup->{expiresOn}: $sup->{supporterId}, $sup->{ledgerEntityId}, $sup->{displayName}, "; $emailText .= " $sup->{expiresOn}: $sup->{supporterId}, $sup->{ledgerEntityId}, $sup->{displayName}, ";
$emailText .= "2YrTot: \$" . sprintf("%.2f", $twoYearTot). ", 3YrTot: \$" . sprintf("%.2f", $threeYearTot); $emailText .= "2YrTot: \$" . sprintf("%.2f", $twoYearTot). ", 3YrTot: \$" . sprintf("%.2f", $threeYearTot);
$emailText .= ", Emails: " . join(", ", @{$sup->{emails}}); $emailText .= ", Emails: " . join(", ", @{$sup->{emails}});
$emailText .= "\n"; $emailText .= "\n";
if ( ($threeYearTot / 3) > $BIG_DONOR_CUTOFF or ($twoYearTot / 2) > $BIG_DONOR_CUTOFF or
$oneYearTot > $BIG_DONOR_CUTOFF) {
$bigDonorEmailText .= " $sup->{expiresOn}: $sup->{supporterId}, $sup->{ledgerEntityId}, $sup->{displayName}, ";
$bigDonorEmailText .= "1YrTot: \$" . sprintf("%.2f", $oneYearTot) . "2YrTot: \$" .
sprintf("%.2f", $twoYearTot). ", 3YrTot: \$" . sprintf("%.2f", $threeYearTot);
$bigDonorEmailText .= ", Emails: " . join(", ", @{$sup->{emails}}) . "\n";
}
} }
$emailText .= "\n"; $emailText .= "\n";
} }
@ -273,3 +284,19 @@ open(SENDMAIL, "|/usr/lib/sendmail -f \"$FROM_ADDRESS\" -oi -oem -- $ALL_STAFF_A
die "unable to run sendmail: $!"; die "unable to run sendmail: $!";
print SENDMAIL $allStaffEmail->as_string; print SENDMAIL $allStaffEmail->as_string;
close SENDMAIL; close SENDMAIL;
my $bigDonorLapsedEmail = Email::MIME->create(
header_str => [
To => $FROM_ADDRESS,
From => $FROM_ADDRESS,
Subject => "Big Donors Lapsed/Lapsing Soon (for $TODAY)" ],
attributes => {
content_type => 'text/plain',
charset => 'utf-8',
encoding => "quoted-printable",
disposition => 'inline' },
body_str => $bigDonorEmailText);
open(SENDMAIL, "|/usr/lib/sendmail -f \"$FROM_ADDRESS\" -oi -oem -- $FROM_ADDRESS") or
die "unable to run sendmail: $!";
print SENDMAIL $bigDonorLapsedEmail->as_string;
close SENDMAIL;