The output format for donations changed slightly when we switched to
Beancount at Conservancy from Ledger CLI. This change now assumes a
specific format of the output for the donations, and takes a
filehandle in the constructor to receive the data.
As such, this effectively makes it slightly less dependent on any
specific donation database, since as long as you can get it into the
format the regex herein expects onto a filehandle, it doesn't matter
what system you use underneath.
THis code originally had variable replacement like this, but when the inputs
started to be be fully MIME-encoded without any plain text, that stopped
working. Inputs we're using have that now, so this works again, and thus
this feature is restored.
Rename months_expired() to months_expired_at_return() and have the
method return an integer representing the month count rather than an
enum-like so that the API user has more flexibility with respect to
what they then do with the result. Thanks to Brett for the review
that suggested this, and for much of the clever math in this change.
The results produced by returning_report.py (which is updated here to
use the new API) are almost identical to the results produced before
the change. In rare cases (about 2-5% of the time) a supporter's
lapsed month count will fall into an adjacent bucket instead of the
one it fell into before, usually because the previous result was wrong
to begin with (due to the ugly days-per-3-months table that we used
previously, which this change thankfully eliminates).
A reporting script similar to status_report.py that uses the new
returning supporter method (added in 7aaba96) to provide a list of
how many supporters have started supporting again after lapsing,
bucketed by the number of months for which they had been lapsed.
A new public method, months_expired(), which is similar to the
existing status() in layout, but instead of returning whether the
supporter is new/active/lapsed/etc., it checks to see whether the
supporter is returning after having been lapsed, and if so, returns
the month range corresponding to how long they had been lapsed before
returning as a supporter in the current month.
These tests lay out the basic functionality for adding an email error.
BTW, I decided we need an entirely different but mirrored setup for
postal errors, since the database tables for email and postal addresses
are hard-coded.