Exemple #1
0
def agent_accounts_dashboard(context):
    request = context['request']
    bp = request.user.get_business_profile()
    data, created = AgentDataCache.objects.get_or_create(businessprofile__pk=bp.pk)

    commission_levels = settings.AGENT_COMMISSION_LEVELS
    deal_price_eur__sum = deal_agent_price_sum(bp)
    current_level_i, perc = commission_level(deal_price_eur__sum=deal_price_eur__sum, levels=commission_levels)

    current_commission_level, next_commission_level = level_progress(commission_levels, current_level_i,
                                                                     deal_price_eur__sum)

    return {
        'request': request,
        'num_recruited': data.num_recruited,
        'num_sold_products': data.num_sold_products,
        'num_interested': data.num_interested,
        'num_active': data.num_active,
        'num_completed': data.num_completed,
        'num_canceled': data.num_canceled,
        'next_commission_level': next_commission_level,
        'current_commission_level': current_commission_level
    }