示例#1
0
文件: rent.py 项目: weixiyen/Rentfox
    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('')
示例#2
0
 def addExpense(self):
     errorslist = self.validate()
     
     if errorslist:
         obj = {
             'errors': errorslist
         }
         return json.dumps(obj)
     
     expenseType = request.POST['expenseType']
     payTo = request.POST['payTo']
     expenseAmount = '-'+request.POST['expenseAmount']
     expenseDate = request.POST['expenseDate']
     contactType = request.POST['contactType']
     contactId = request.POST['contactId']
     companyId = request.environ.get("COMPANY_ID")
     now = datetime.datetime.today()
     curHour = now.hour
     curMin = now.minute
     curSec = now.second
     date = expenseDate.split('/')
     date = datetime.datetime(int(date[2]),int(date[0]),int(date[1]),curHour,curMin,curSec)
     
     if contactType == 'unit':
         leaseId = Lease.get_current_of_unit(contactId)
         if not leaseId:
             leaseId = None
         unitInfo = Unit.get_unit_info(contactId)
         propertyId = unitInfo[2]
         payTo = payTo.split('#')
         prop = payTo[0]
         prop = prop.strip()
         unit = payTo[1]
         payTo = prop + ' #' + unit
         
         Transaction.create(
                                 id=str(uuid.uuid1()),
                                 leaseid=leaseId,
                                 unitid=contactId,
                                 companyid=companyId,
                                 propertyid=propertyId,
                                 type=expenseType,
                                 name=payTo,
                                 amount=expenseAmount,
                                 date=date
                                 )
     elif contactType == 'property':
         Transaction.create(
                                 id=str(uuid.uuid1()),
                                 companyid=companyId,
                                 propertyid=contactId,
                                 type=expenseType,
                                 name=payTo,
                                 amount=expenseAmount,
                                 date=date
                                 )
     elif contactType == 'tenant':
         leaseId = Tenant_lease.get_lease_of_tenant(contactId)
         if not leaseId:
             leaseId = None
         record = Tenant.get_tenantInfo(contactId)
         if record:
             unitId = record[0]
             propertyId = record[1]
         else:
             unitId = None
             propertyId = None
         Transaction.create(
                                 id=str(uuid.uuid1()),
                                 leaseid=leaseId,
                                 unitid=unitId,
                                 companyid=companyId,
                                 propertyid=propertyId,
                                 type=expenseType,
                                 name=payTo,
                                 amount=expenseAmount,
                                 date=date
                                 )
     elif contactType == 'contact':
         Transaction.create(
                                 id=str(uuid.uuid1()),
                                 contactid=contactId,
                                 companyid=companyId,
                                 type=expenseType,
                                 name=payTo,
                                 amount=expenseAmount,
                                 date=date
                                 )
     else:
         Transaction.create(
                                 id=str(uuid.uuid1()),
                                 companyid=companyId,
                                 type=expenseType,
                                 name=payTo,
                                 amount=expenseAmount,
                                 date=date
                                 )
     return json.dumps('')