Ejemplo n.º 1
0
 def get(self,year,month):
     print year
     print month
     head = HeadAccount.query.filter_by(year=year).filter_by(month=month).first()
     schema = HeadSchema()
      
     if head is not None:
         #head.data = eval(head.data)
         return Response(schema.dumps(head,sort_keys=True,indent=1).data,mimetype='application/json')
         #return Response(schema.dumps(head,indent=1).data,mimetype='application/json')
     else:
         return jsonify({'get':'fail'})
Ejemplo n.º 2
0
 def get(self,year):
     list1 = []
     data_list2 = []
     schema1 = BranchSchema(many=True)
     schema2 = HeadSchema()
     for i in range(0,12):
         data_list = []
         month = i + 1
         branch = BranchAccount.query.filter_by(year=year).filter_by(month=month)
         head = HeadAccount.query.filter_by(year=year).filter_by(month=month).first()
         if head is not None:
             branch_list = json.loads(schema1.dumps(branch,sort_keys=True).data)
             head_list = json.loads(schema2.dumps(head,sort_keys=True).data)
             num = len(branch_list)
             for i in range(0,num):
                 data_list.append(eval(branch_list[i]['data']))
             #data_list.append(eval(head_list['data']))
             data = year_sum(data_list)
             d1 = eval(data)
             d1['A56'] = str(round(float(d1['A56'])+float(eval(head_list['data'])['A56']),2))
             d1['A57'] = str(round(float(d1['A57'])+float(eval(head_list['data'])['A57']),2))
             d1['A58'] = str(round(float(d1['A58'])-float(eval(head_list['data'])['A56'])-float(eval(head_list['data'])['A57']),2))
             data = str(d1)
             data_sum = {'month':month,'data':data}                
             list1.append(data_sum)
         else:
             continue
     list1 = map(lambda x:{'month':x['month'],'data':sort_dic_str(eval(x['data']))},list1)
     num = len(list1)
     for j in range(0,num):
         data_list2.append(eval(list1[j]['data']))
     
     data2 = year_sum(data_list2)
     dic = {'month':13,'data':data2}
     list1.append(dic)
     return Response(json.dumps(list1,indent=1,sort_keys=True),mimetype='application/json')