예제 #1
0
파일: reports.py 프로젝트: weixiyen/Rentfox
 def get(self):
     unitId = request.POST['unitId']
     type = request.POST['type']
     
     transactions = Transaction.get_type(unitId, type)
     
     transactionInfo = []
     for transaction in transactions:
         date = transaction.date
         if transaction.income:
             transAmount = '$' + str('%.2f' % transaction.amount)
         else:
             transAmount = '- $' + str('%.2f' % transaction.amount)
         
         transObj = {
             'type': transaction.type,
             'amount': transAmount,
             'income': transaction.income,
             'month': date.month,
             'day': date.day,
             'year': date.year
         }
         transactionInfo.append(transObj)
     
     return json.dumps(transactionInfo)