Esempio n. 1
0
def GetMonthOrderCount():
    ###Tổng đơn hàng trong ngày
    month_orders = RevenueRep.GetOrdersInMonth()
    res_month_order_count = dict({
        'label': 'month_order_count',
        'value': len(month_orders)
    })
    return res_month_order_count
Esempio n. 2
0
def GetTotalRevenueInMonth():
    ### Tổng doanh thu trong tháng
    month_orders = RevenueRep.GetOrdersInMonth()
    month_total_revenue = 0.0
    for order in month_orders:
        month_total_revenue += order.total

    res_month_total_revenue = dict({
        'label': 'month_total_revenue',
        'value': month_total_revenue
    })
    return res_month_total_revenue
Esempio n. 3
0
def GetPercentageMonthRevenueToPrevMonth():
    ### Doanh thu so voi81 tháng trước
    month_orders = RevenueRep.GetOrdersInMonth()
    prev_month_orders = RevenueRep.GetOrdersInPrevMonth()
    month_total_revenue = 0.0
    prev_month_total_revenue = 0.0
    for order in month_orders:
        month_total_revenue += order.total

    for order in prev_month_orders:
        prev_month_total_revenue += order.total

    percentage_month_revenue_to_prev_month = 1 if prev_month_total_revenue == 0 else round(
        (month_total_revenue / prev_month_total_revenue), 4)
    res_percentage_month_revenue_to_prev_month = dict({
        'label':
        "res_percentage_month_revenue_to_prev_month",
        'value':
        percentage_month_revenue_to_prev_month
    })
    return res_percentage_month_revenue_to_prev_month
Esempio n. 4
0
def GetGrowPercentageToPrevMonth():
    ### Tốc độ tăng trường doanh thu so với tháng trước
    month_orders = RevenueRep.GetOrdersInMonth()
    prev_month_orders = RevenueRep.GetOrdersInPrevMonth()
    month_total_revenue = 0.0
    prev_month_total_revenue = 0.0
    for order in month_orders:
        month_total_revenue += order.total

    for order in prev_month_orders:
        prev_month_total_revenue += order.total

    grow_percentage_to_prev_month = 1 if prev_month_total_revenue == 0 else round(
        (month_total_revenue / prev_month_total_revenue), 4) - 1

    if prev_month_total_revenue == month_total_revenue:
        grow_percentage_to_prev_month = 0
    res_grow_percentage_to_prev_month = dict({
        'label':
        'grow_percentage_to_prev_month',
        'value':
        grow_percentage_to_prev_month
    })
    return res_grow_percentage_to_prev_month