示例#1
0
    def get(self,sid,year,month):
        print year
        print month
        branch = BranchAccount.query.filter_by(year=year).filter_by(month=month).filter_by(sid=sid).first()
        schema = BranchSchema()

        if branch is not None:
            return Response(schema.dumps(branch,sort_keys=True,indent=1).data,mimetype='application/json')
示例#2
0
    def get(self):
        branch = BranchAccount.query.all()
        schema1 = BranchSchema(many=True)
        #branch_list = eval(schema1.dumps(branch).data)
        branch_list = json.loads(schema1.dumps(branch).data)

        for dic in branch_list:
            dic_data = eval(dic['data'])
            dic['income'] = dic_data['A14']
            dic['outcome'] = str(eval(dic_data['A30']) + eval(dic_data['A52']) + eval(dic_data['A54']) + eval(dic_data['A56']) + eval(dic_data['A57']))
            st = Store.query.filter_by(sid=dic['sid']).first()
            if st.users.count() > 1:
                dic['shareholder'] = map(lambda x:x.username,list(st.users))
            else:
                if list(st.users) != []:
                    dic['shareholder'] = st.users[0].username
                else:
                    continue

            del dic['data']
             
        
        return Response(json.dumps(branch_list,indent=1),mimetype='application/json')
示例#3
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')