Example #1
0
 def markPaid(self):
     unitId = request.POST['unitId']
     leaseId = request.POST['leaseId']
     amount = request.POST['amount']
     due = int(request.POST['due'])
     forMonth = int(request.POST['forMonth'])
     forYear = int(request.POST['forYear'])
     markLatePaid = request.POST['markLatePaid']
     
     result = {}
     if markLatePaid == '1':
         Transaction.record_late_paid(unitId,forMonth,forYear)
     else:
         companyId = request.environ.get("COMPANY_ID")
         now = datetime.datetime.today()
         id = str(uuid.uuid1())
         record = Unit.get_unit_info(unitId)
         
         curM = now.month
         curY = now.year
         
         if curM != forMonth or (curM == forMonth and curY != forYear):
             now = datetime.datetime.today()
             curHour = now.hour
             curMin = now.minute
             curSec = now.second
             date = datetime.datetime(forYear,forMonth,due,curHour,curMin,curSec)
         else:
             date = now
         
         Transaction.record_rent(
                                 id=str(uuid.uuid1()),
                                 companyid=companyId,
                                 propertyid=record[2],
                                 leaseid=leaseId,
                                 unitid=unitId,
                                 type='Rent',
                                 formonth=forMonth,
                                 foryear=forYear,
                                 date=date,
                                 income=1,
                                 name='Unit ' + record[0] + ', ' + record[1],
                                 amount=amount
                                 )
     
     return json.dumps(result)