Exemplo n.º 1
0
def get_project_used_list(self, year, company):
    query = build_query(self, year, company)
    
    rows= []
    c = connection.cursor()
    try:
        c.execute(query)
        rows = dictfetchall(c)
    finally:
        c.close()
    
    sum_line = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
   
    index = 0
    for line in rows:
        index += 1
        line['index'] = index
        sum_line[0] += (line['online_before_amount'] or 0)
        sum_line[1] += line['one_month'] or 0
        sum_line[2] += line['two_month'] or 0
        sum_line[3] += line['three_month']
        sum_line[4] += line['four_month']
        sum_line[5] += line['five_month']
        sum_line[6] += line['six_month']
        sum_line[7] += line['seven_month']
        sum_line[8] += line['eight_month']
        sum_line[9] += line['night_month']
        sum_line[10] += line['ten_month']
        sum_line[11] += line['eleven_month']
        sum_line[12] += line['twelve_month']
        
        line['total'] = (line['online_before_amount'] or 0) + (line['one_month'] or 0) + (line['two_month'] or 0)+  \
                        line['three_month'] + line['four_month'] + line['five_month'] + line['six_month'] +  \
                        line['seven_month'] + line['eight_month'] + line['night_month'] + line['ten_month'] + \
                        line['eleven_month'] + line['twelve_month']
        
        percent = line['total']/line['estimate_total'] * Decimal(100.0) if line['total'] != 0 and line['estimate_total'] != 0 and line['estimate_total'] is not None else 0.00
        
        line['percent'] = ("%.2f" % percent)
        sum_line[13] += (line['total'] or 0)
        
        
        
    result = {}
    result['lines'] = rows
    if len(rows) > 0:
        result['sum_line'] = sum_line
    
    result['year'] = str(year)
    result['company'] = company
    return result
Exemplo n.º 2
0
def get_project_apply_list(project, category, material_name):
    query = build_query(project, category, material_name)
    
    rows= []
    c = connection.cursor()
    try:
        c.execute(query)
        rows = dictfetchall(c)
    finally:
        c.close()
        
    result = {}
    result['lines'] = rows
    result['project_name'] = project
    result['category_name'] = category
    result['material_name'] = material_name
    return result
Exemplo n.º 3
0
def get_project_apply_list(project, category, material_name):
    query = build_query(project, category, material_name)

    rows = []
    c = connection.cursor()
    try:
        c.execute(query)
        rows = dictfetchall(c)
    finally:
        c.close()

    result = {}
    result['lines'] = rows
    result['project_name'] = project
    result['category_name'] = category
    result['material_name'] = material_name
    return result