Ejemplo n.º 1
0
    def markLate(self):
        unitId = request.POST['unitId']
        latefee = request.POST['latefee']
        forMonth = request.POST['forMonth']
        forYear = request.POST['forYear']
        date = request.POST['date']
        latefeeNum = latefee.replace('$','')
        Transaction.record_latefee(unitId,latefeeNum,forMonth,forYear,date)
        
        remind = True if request.POST['remind'] == 'true' and float(latefeeNum) > 0.0 else False
        if remind:
            tenants = Tenant_lease.get_tenants_from_unit(unitId)
            emails = [tenant.email for tenant in tenants]
            subj = '{0} - late fee owed'.format(request.environ.get('COMPANY_NAME'))
            msg = """\
Dear Tenant,

This is a notice from your landlord that your rent was turned in late.

Amount owed: ${0}

Please pay this amount promptly.

Thanks,

{1}
""".format(latefee, request.environ.get('COMPANY_NAME'))
            mailman.send(emails, subj, msg)
        
        return json.dumps('')