Esempio n. 1
0
def get_category_pie(year, month):
    record, year, month = data_aggregation(year, month)
    record = MouthCost(record, year, month)
    eat, other = record.web_category_pie()
    if year == 'null' or month == 'null':
        year = str(datetime.now().year)
        month = str(datetime.now().month)
    pie = draw.draw_category_pie(inner=eat[:NUMBER_WEB_CATEGORY_PIE_EAT],
                                 outside=other[:NUMBER_WEB_CATEGORY_PIE_OTHER],
                                 inner_title=f'{year}年{month}饮食报表',
                                 outer_title=f'{year}年{month}其他报表')
    return pie.dump_options()
def get_all_eat_other_record(year) -> tuple:
    """将指定年分的12个月的饮食和其他消费类别总计汇总"""
    eat_list = []
    other_list = []
    months = [month for month in range(1, 13)]
    for month in months:  # 将整年的所有饮食和其他消费合并
        record, year, month = data_aggregation(year=year, month=month)
        if record:
            manage = MouthCost(record, year, month)
            eat_cost, other_cost = manage.web_category_pie()
            eat_list.append(eat_cost)
            other_list.append(other_cost)
    return eat_list, other_list