Ajout libellé clients + retrait CA internes
This commit is contained in:
@@ -90,8 +90,6 @@ def get_ca_clients_12m(request, societe, datedeb, datefin):
|
||||
SUM(IF(typecli = 'E', 1, 0)) AS E_nb,
|
||||
SUM(IF(typecli = 'G', totalht, 0)) AS G_ca,
|
||||
SUM(IF(typecli = 'G', 1, 0)) AS G_nb,
|
||||
SUM(IF(typecli = 'I', totalht, 0)) AS I_ca,
|
||||
SUM(IF(typecli = 'I', 1, 0)) AS I_nb,
|
||||
SUM(IF(typecli = 'P', totalht, 0)) AS P_ca,
|
||||
SUM(IF(typecli = 'P', 1, 0)) AS P_nb,
|
||||
SUM(IF(typecli = 'R', totalht, 0)) AS R_ca,
|
||||
@@ -108,15 +106,15 @@ def get_ca_clients_3y(request, societe, datedeb):
|
||||
date2 = datedeb + relativedelta(years=-1)
|
||||
date3 = datedeb + relativedelta(years=-2)
|
||||
|
||||
query = """SELECT typecli,
|
||||
query = """SELECT LIB,
|
||||
SUM(IF (date_format(date, '%Y') = :date_n-2, TOTALHT, 0)) as Annee1,
|
||||
SUM(IF (date_format(date, '%Y') = :date_n-2, 1, 0)) as Count1,
|
||||
SUM(IF (date_format(date, '%Y') = :date_n-1, TOTALHT, 0)) as Annee2,
|
||||
SUM(IF (date_format(date, '%Y') = :date_n-1, 1, 0)) as Count2,
|
||||
SUM(IF (date_format(date, '%Y') = :date_n, TOTALHT, 0)) as Annee3,
|
||||
SUM(IF (date_format(date, '%Y') = :date_n, 1, 0)) as Count3
|
||||
FROM bddevfac.facture
|
||||
WHERE societe=:societe GROUP BY typecli;"""
|
||||
FROM bddevfac.facture JOIN bddevfac.p_type ON bddevfac.facture.typecli = bddevfac.p_type.CODE
|
||||
WHERE societe=:societe AND typecli <> 'I' GROUP BY typecli;"""
|
||||
results = request.dbsession.execute(query, {'societe': societe, 'date_n': date3.strftime("%Y"), 'date_n-1': date2.strftime("%Y"), 'date_n': datedeb.strftime("%Y")})
|
||||
return results.fetchall()
|
||||
|
||||
|
||||
@@ -250,22 +250,21 @@ def ca_clients(request):
|
||||
print(datedeb)
|
||||
chart_ca_12m = []
|
||||
# titre des colonnes
|
||||
chart_ca_12m.append(('Mois', 'A', { 'type':'string','role': 'tooltip'}, 'E', { 'type':'string','role': 'tooltip'},
|
||||
'G', { 'type':'string','role': 'tooltip'}, 'I', { 'type':'string','role': 'tooltip'}, 'P', { 'type':'string','role': 'tooltip'},
|
||||
'R', { 'type':'string','role': 'tooltip'}, 'S', { 'type':'string','role': 'tooltip'}))
|
||||
chart_ca_12m.append(('Mois', 'ASSURANCES', { 'type':'string','role': 'tooltip'}, 'EXPERTS', { 'type':'string','role': 'tooltip'},
|
||||
'GROUPEMENT', { 'type':'string','role': 'tooltip'}, 'PARTICULIER', { 'type':'string','role': 'tooltip'},
|
||||
'REGIES', { 'type':'string','role': 'tooltip'}, 'SOCIETE', { 'type':'string','role': 'tooltip'}))
|
||||
title = 'CA / MOIS'
|
||||
for item in items:
|
||||
# construire la liste pour donut cible
|
||||
tooltipA = item.date + ' \nCA: '+str(item.A_ca) + ' €\nDossiers: '+str(round(item.A_nb))
|
||||
tooltipE = item.date + ' \nCA: '+str(item.E_ca) + ' €\nDossiers: '+str(round(item.E_nb))
|
||||
tooltipG = item.date + ' \nCA: '+str(item.G_ca) + ' €\nDossiers: '+str(round(item.G_nb))
|
||||
tooltipI = item.date + ' \nCA: '+str(item.I_ca) + ' €\nDossiers: '+str(round(item.I_nb))
|
||||
tooltipP = item.date + ' \nCA: '+str(item.P_ca) + ' €\nDossiers: '+str(round(item.P_nb))
|
||||
tooltipR = item.date + ' \nCA: '+str(item.R_ca) + ' €\nDossiers: '+str(round(item.R_nb))
|
||||
tooltipS = item.date + ' \nCA: '+str(item.S_ca) + ' €\nDossiers: '+str(round(item.S_nb))
|
||||
# ('+str(item.population)+')/n'
|
||||
d = (item.mois, float(item.A_ca), tooltipA, float(item.E_ca), tooltipE, float(item.G_ca), tooltipG,
|
||||
float(item.I_ca), tooltipI, float(item.P_ca), tooltipP, float(item.R_ca), tooltipR, float(item.S_ca), tooltipS)
|
||||
float(item.P_ca), tooltipP, float(item.R_ca), tooltipR, float(item.S_ca), tooltipS)
|
||||
chart_ca_12m.append(d)
|
||||
|
||||
# debut = aujourd'hui - 11 mois
|
||||
@@ -286,15 +285,15 @@ def ca_clients(request):
|
||||
title3 = 'CA ' + datedeb.strftime("%Y")
|
||||
for item in items:
|
||||
# construire la liste pour donut cible
|
||||
tooltip_y1 = item.typecli + ' \nCA: '+str(item.Annee1) + ' €\nDossiers: '+str(round(item.Count1))
|
||||
tooltip_y2 = item.typecli + ' \nCA: '+str(item.Annee2) + ' €\nDossiers: '+str(round(item.Count1))
|
||||
tooltip_y3 = item.typecli + ' \nCA: '+str(item.Annee3) + ' €\nDossiers: '+str(round(item.Count1))
|
||||
tooltip_y1 = item.LIB + ' \nCA: '+str(item.Annee1) + ' €\nDossiers: '+str(round(item.Count1))
|
||||
tooltip_y2 = item.LIB + ' \nCA: '+str(item.Annee2) + ' €\nDossiers: '+str(round(item.Count1))
|
||||
tooltip_y3 = item.LIB + ' \nCA: '+str(item.Annee3) + ' €\nDossiers: '+str(round(item.Count1))
|
||||
# ('+str(item.population)+')/n'
|
||||
d1 = (item.typecli, float(item.Annee1), tooltip_y1)
|
||||
d1 = (item.LIB, float(item.Annee1), tooltip_y1)
|
||||
chart_ca_3y_1.append(d1)
|
||||
d2 = (item.typecli, float(item.Annee2), tooltip_y2)
|
||||
d2 = (item.LIB, float(item.Annee2), tooltip_y2)
|
||||
chart_ca_3y_2.append(d2)
|
||||
d3 = (item.typecli, float(item.Annee3), tooltip_y3)
|
||||
d3 = (item.LIB, float(item.Annee3), tooltip_y3)
|
||||
chart_ca_3y_3.append(d3)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user