+ with open(temp.name, 'rb') as f:
+ content = f.read()
+ os.unlink(f.name)
+ return content, optout, payments
+
+ @classmethod
+ def send_receipt(cls, email, year, resend=False):
+ receipt = cls.generate_receipt(email, year)
+ if receipt:
+ content, optout, payments = receipt
+ ctx = {
+ "email": email,
+ "year": year,
+ "next_year": year + 1,
+ "total": sum(x['amount'] for x in payments),
+ "payments": payments,
+ "optout": optout,
+ "resend": resend,
+ }