correction stats devis
This commit is contained in:
@@ -142,23 +142,31 @@ def get_delais_pourcent(request, societe, groupe, datedeb):
|
|||||||
results = request.dbsession.execute(query, {'societe': societe, 'groupe': groupe, 'datedeb': datedeb.strftime("%Y-%m")})
|
results = request.dbsession.execute(query, {'societe': societe, 'groupe': groupe, 'datedeb': datedeb.strftime("%Y-%m")})
|
||||||
return results.fetchall()
|
return results.fetchall()
|
||||||
|
|
||||||
def get_nb_devis_fact(request, societe, datedeb):
|
def get_nb_devis_fact(request, societe, year):
|
||||||
|
|
||||||
query = """SELECT
|
query = """SELECT
|
||||||
SUM(IF (NOFACT > 0, 1, 0)) AS devis_fact,
|
SUM(IF (NOFACT > 0 AND year(date) = :year - 2, 1, 0)) AS devis_fact_y1,
|
||||||
SUM(IF (NOFACT <= 0, 1, 0)) AS devis_non_fact
|
SUM(IF (NOFACT <= 0 AND year(date) = :year - 2, 1, 0)) AS devis_non_fact_y1,
|
||||||
|
SUM(IF (NOFACT > 0 AND year(date) = :year - 1, 1, 0)) AS devis_fact_y2,
|
||||||
|
SUM(IF (NOFACT <= 0 AND year(date) = :year - 1, 1, 0)) AS devis_non_fact_y2,
|
||||||
|
SUM(IF (NOFACT > 0 AND year(date) = :year, 1, 0)) AS devis_fact_y3,
|
||||||
|
SUM(IF (NOFACT <= 0 AND year(date) = :year, 1, 0)) AS devis_non_fact_y3
|
||||||
FROM bddevfac.devis
|
FROM bddevfac.devis
|
||||||
WHERE societe = :societe AND date >= :datedeb;"""
|
WHERE societe = :societe;"""
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'datedeb': datedeb.strftime("%Y-%m")})
|
results = request.dbsession.execute(query, {'societe': societe, 'year': year})
|
||||||
return results.fetchall()
|
return results.fetchall()
|
||||||
|
|
||||||
def get_nb_fact_with_devis(request, societe, datedeb):
|
def get_nb_fact_with_devis(request, societe, year):
|
||||||
|
|
||||||
query = """SELECT
|
query = """SELECT
|
||||||
SUM(IF (NODEVIS > 0, 1, 0)) AS fact_w_devis,
|
SUM(IF (NODEVIS > 0 AND year(date) = :year - 2, 1, 0)) AS fact_w_devis_y1,
|
||||||
SUM(IF (NODEVIS <= 0, 1, 0)) AS fact_wo_devis
|
SUM(IF (NODEVIS <= 0 AND year(date) = :year - 2, 1, 0)) AS fact_wo_devis_y1,
|
||||||
|
SUM(IF (NODEVIS > 0 AND year(date) = :year - 1, 1, 0)) AS fact_w_devis_y2,
|
||||||
|
SUM(IF (NODEVIS <= 0 AND year(date) = :year - 1, 1, 0)) AS fact_wo_devis_y2,
|
||||||
|
SUM(IF (NODEVIS > 0 AND year(date) = :year, 1, 0)) AS fact_w_devis_y3,
|
||||||
|
SUM(IF (NODEVIS <= 0 AND year(date) = :year, 1, 0)) AS fact_wo_devis_y3
|
||||||
FROM bddevfac.facture
|
FROM bddevfac.facture
|
||||||
WHERE societe = :societe AND date >= :datedeb;"""
|
WHERE societe = :societe;"""
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'datedeb': datedeb.strftime("%Y-%m")})
|
results = request.dbsession.execute(query, {'societe': societe, 'year': year})
|
||||||
return results.fetchall()
|
return results.fetchall()
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,16 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- CAMENBERT DU NOMBRE DE DEVIS FACTURES -->
|
<!-- CAMENBERT DU NOMBRE DE DEVIS FACTURES -->
|
||||||
<div id="chart_devis_fact" style="width: 100%; height: 500px;"></div>
|
<div id="chart_devis_y1" style="width: 100%; height: 500px;"></div>
|
||||||
|
<div id="chart_devis_y2" style="width: 100%; height: 500px;"></div>
|
||||||
|
<div id="chart_devis_y3" style="width: 100%; height: 500px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- CAMEMBERT DU NOMBRE DE FACTURES AVEC DEVIS -->
|
<!-- CAMEMBERT DU NOMBRE DE FACTURES AVEC DEVIS -->
|
||||||
<div id="chart_fact" style="width: 100%; height: 500px;"></div>
|
<div id="chart_fact_y1" style="width: 100%; height: 500px;"></div>
|
||||||
|
<div id="chart_fact_y2" style="width: 100%; height: 500px;"></div>
|
||||||
|
<div id="chart_fact_y3" style="width: 100%; height: 500px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -32,28 +36,64 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
google.charts.load("current", {packages:["corechart"]});
|
google.charts.load("current", {packages:["corechart"]});
|
||||||
google.charts.setOnLoadCallback(drawChart);
|
google.charts.setOnLoadCallback(drawChart);
|
||||||
var dataSet_devis_fact = ${chart_devis_fact};
|
|
||||||
var dataSet_fact = ${chart_fact};
|
var dataSet_devis_y1 = ${chart_devis_y1};
|
||||||
|
var dataSet_devis_y2 = ${chart_devis_y2};
|
||||||
|
var dataSet_devis_y3 = ${chart_devis_y3};
|
||||||
|
|
||||||
|
var dataSet_fact_y1 = ${chart_fact_y1};
|
||||||
|
var dataSet_fact_y2 = ${chart_fact_y2};
|
||||||
|
var dataSet_fact_y3 = ${chart_fact_y3};
|
||||||
|
|
||||||
function drawChart() {
|
function drawChart() {
|
||||||
var data_devis_fact = google.visualization.arrayToDataTable(dataSet_devis_fact);
|
|
||||||
var data_fact = google.visualization.arrayToDataTable(dataSet_fact);
|
|
||||||
|
|
||||||
var options_devis_fact = {
|
var data_devis_y1 = google.visualization.arrayToDataTable(dataSet_devis_y1);
|
||||||
title: '${title}',
|
var data_devis_y2 = google.visualization.arrayToDataTable(dataSet_devis_y2);
|
||||||
|
var data_devis_y3 = google.visualization.arrayToDataTable(dataSet_devis_y3);
|
||||||
|
|
||||||
|
var data_fact_y1 = google.visualization.arrayToDataTable(dataSet_fact_y1);
|
||||||
|
var data_fact_y2 = google.visualization.arrayToDataTable(dataSet_fact_y2);
|
||||||
|
var data_fact_y3 = google.visualization.arrayToDataTable(dataSet_fact_y3);
|
||||||
|
|
||||||
|
var options_devis_y1 = {
|
||||||
|
title: '${title_devis1}',
|
||||||
|
pieHole: 0.4,
|
||||||
|
};
|
||||||
|
var options_devis_y2 = {
|
||||||
|
title: '${title_devis2}',
|
||||||
|
pieHole: 0.4,
|
||||||
|
};
|
||||||
|
var options_devis_y3 = {
|
||||||
|
title: '${title_devis3}',
|
||||||
pieHole: 0.4,
|
pieHole: 0.4,
|
||||||
};
|
};
|
||||||
|
|
||||||
var options_fact = {
|
var options_fact_y1 = {
|
||||||
title: '${title}',
|
title: '${title_fact2}',
|
||||||
|
pieHole: 0.4,
|
||||||
|
};
|
||||||
|
var options_fact_y2 = {
|
||||||
|
title: '${title_fact2}',
|
||||||
|
pieHole: 0.4,
|
||||||
|
};
|
||||||
|
var options_fact_y3 = {
|
||||||
|
title: '${title_fact3}',
|
||||||
pieHole: 0.4,
|
pieHole: 0.4,
|
||||||
};
|
};
|
||||||
|
|
||||||
var chart_devis_fact = new google.visualization.PieChart(document.getElementById('chart_devis_fact'));
|
var chart_devis_y1 = new google.visualization.PieChart(document.getElementById('chart_devis_y1'));
|
||||||
chart_devis_fact.draw(data_devis_fact, options_devis_fact);
|
chart_devis_y1.draw(data_devis_y1, options_devis_y1);
|
||||||
|
var chart_devis_y2 = new google.visualization.PieChart(document.getElementById('chart_devis_y2'));
|
||||||
|
chart_devis_y2.draw(data_devis_y2, options_devis_y2);
|
||||||
|
var chart_devis_y3 = new google.visualization.PieChart(document.getElementById('chart_devis_y3'));
|
||||||
|
chart_devis_y3.draw(data_devis_y3, options_devis_y3);
|
||||||
|
|
||||||
var chart_fact = new google.visualization.PieChart(document.getElementById('chart_fact'));
|
var chart_fact_y1 = new google.visualization.PieChart(document.getElementById('chart_fact_y1'));
|
||||||
chart_fact.draw(data_fact, options_fact);
|
chart_fact_y1.draw(data_fact_y1, options_fact_y1);
|
||||||
|
var chart_fact_y2 = new google.visualization.PieChart(document.getElementById('chart_fact_y2'));
|
||||||
|
chart_fact_y2.draw(data_fact_y2, options_fact_y2);
|
||||||
|
var chart_fact_y3 = new google.visualization.PieChart(document.getElementById('chart_fact_y3'));
|
||||||
|
chart_fact_y3.draw(data_fact_y3, options_fact_y3);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -413,9 +413,8 @@ def pourcentage_devis(request):
|
|||||||
societe = request.matchdict['societe']
|
societe = request.matchdict['societe']
|
||||||
url = request.route_url('delais_pourcentage', societe = societe)
|
url = request.route_url('delais_pourcentage', societe = societe)
|
||||||
|
|
||||||
datefin = date.today()
|
# année aujourd'hui
|
||||||
# debut = aujourd'hui - 11 mois
|
thisyear = date.today().year
|
||||||
datedeb = datefin + relativedelta(months=-11)
|
|
||||||
|
|
||||||
societes = ['PE','ME','PL']
|
societes = ['PE','ME','PL']
|
||||||
# si societe a été changé par le user
|
# si societe a été changé par le user
|
||||||
@@ -423,43 +422,76 @@ def pourcentage_devis(request):
|
|||||||
societe = request.params["societe"]
|
societe = request.params["societe"]
|
||||||
|
|
||||||
# lire le nb de devis facturés
|
# lire le nb de devis facturés
|
||||||
items = get_nb_devis_fact(request, societe, datedeb)
|
items = get_nb_devis_fact(request, societe, thisyear)
|
||||||
chart_devis_fact = []
|
chart_devis_y1 = []
|
||||||
|
chart_devis_y2 = []
|
||||||
|
chart_devis_y3 = []
|
||||||
# titre des colonnes
|
# titre des colonnes
|
||||||
chart_devis_fact.append(('Catégorie', 'Delais'))
|
chart_devis_y1.append(('Catégorie', 'Nb Devis facturés'))
|
||||||
title = 'POURCENTAGE DU NOMBRE DE DEVIS FACTURÉS'
|
chart_devis_y2.append(('Catégorie', 'Nb Devis facturés'))
|
||||||
|
chart_devis_y3.append(('Catégorie', 'Nb Devis facturés'))
|
||||||
|
title_devis1 = 'NB DEVIS ' + str(thisyear - 2)
|
||||||
|
title_devis2 = 'NB DEVIS ' + str(thisyear - 1)
|
||||||
|
title_devis3 = 'NB DEVIS ' + str(thisyear)
|
||||||
for item in items:
|
for item in items:
|
||||||
# construire la liste pour donut cible
|
d1 = ('Nb de devis facturés', item.devis_fact_y1)
|
||||||
#tooltipA = item.date + ' \nCA: '+str(item.A_ca) + ' €\nDossiers: '+str(round(item.A_nb))
|
chart_devis_y1.append(d1)
|
||||||
# ('+str(item.population)+')/n'
|
d1 = ('Nb de devis non facturés', item.devis_non_fact_y1)
|
||||||
d = ('Nb de devis facturés', round(item.devis_fact))
|
chart_devis_y1.append(d1)
|
||||||
chart_devis_fact.append(d)
|
|
||||||
d = ('Nb de devis non facturés', round(item.devis_non_fact))
|
d2 = ('Nb de devis facturés', item.devis_fact_y2)
|
||||||
chart_devis_fact.append(d)
|
chart_devis_y2.append(d2)
|
||||||
|
d2 = ('Nb de devis non facturés', item.devis_non_fact_y2)
|
||||||
|
chart_devis_y2.append(d2)
|
||||||
|
|
||||||
|
d3 = ('Nb de devis facturés', item.devis_fact_y3),
|
||||||
|
chart_devis_y3.append(d3)
|
||||||
|
d3 = ('Nb de devis non facturés', item.devis_non_fact_y3)
|
||||||
|
chart_devis_y3.append(d3)
|
||||||
|
|
||||||
# lire le nb de devis facturés
|
# lire le nb de devis facturés
|
||||||
items = get_nb_fact_with_devis(request, societe, datedeb)
|
items = get_nb_fact_with_devis(request, societe, thisyear)
|
||||||
chart_fact = []
|
chart_fact_y1 = []
|
||||||
|
chart_fact_y2 = []
|
||||||
|
chart_fact_y3 = []
|
||||||
# titre des colonnes
|
# titre des colonnes
|
||||||
chart_fact.append(('Catégorie', 'Delais'))
|
chart_fact_y1.append(('Catégorie', 'Nb Factures avec devis'))
|
||||||
title = 'POURCENTAGE DU NOMBRE DE FACTURES AVEC DEVIS'
|
chart_fact_y2.append(('Catégorie', 'Nb Factures avec devis'))
|
||||||
|
chart_fact_y3.append(('Catégorie', 'Nb Factures avec devis'))
|
||||||
|
title_fact1 = 'NB FACTURES ' + str(thisyear - 2)
|
||||||
|
title_fact2 = 'NB FACTURES ' + str(thisyear - 1)
|
||||||
|
title_fact3 = 'NB FACTURES ' + str(thisyear)
|
||||||
for item in items:
|
for item in items:
|
||||||
# construire la liste pour donut cible
|
d1 = ("Nb de factures avec devis", item.fact_w_devis_y1)
|
||||||
#tooltipA = item.date + ' \nCA: '+str(item.A_ca) + ' €\nDossiers: '+str(round(item.A_nb))
|
chart_fact_y1.append(d1)
|
||||||
# ('+str(item.population)+')/n'
|
d1 = ("Nb de factures sans devis", item.fact_wo_devis_y1)
|
||||||
d = ('Nb de factures avec devis', round(item.fact_w_devis))
|
chart_fact_y1.append(d1)
|
||||||
chart_fact.append(d)
|
|
||||||
d = ('Nb de factures sans devis', round(item.fact_wo_devis))
|
d2 = ("Nb de factures avec devis", item.fact_w_devis_y2)
|
||||||
chart_fact.append(d)
|
chart_fact_y2.append(d2)
|
||||||
|
d2 = ("Nb de factures sans devis", item.fact_wo_devis_y2)
|
||||||
|
chart_fact_y2.append(d2)
|
||||||
|
|
||||||
|
d3 = ("Nb de factures avec devis", item.fact_w_devis_y3)
|
||||||
|
chart_fact_y3.append(d3)
|
||||||
|
d3 = ("Nb de factures sans devis", item.fact_wo_devis_y3)
|
||||||
|
chart_fact_y3.append(d3)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'page_title': "Pourcentage de délais inférieurs à 2 jours",
|
'page_title': "Pourcentage de délais inférieurs à 2 jours",
|
||||||
'url': url,
|
'url': url,
|
||||||
'chart_devis_fact': json.dumps(chart_devis_fact),
|
'chart_devis_y1': json.dumps(chart_devis_y1),
|
||||||
'chart_fact': json.dumps(chart_fact),
|
'chart_devis_y2': json.dumps(chart_devis_y2),
|
||||||
'title': title,
|
'chart_devis_y3': json.dumps(chart_devis_y3),
|
||||||
|
'chart_fact_y1': json.dumps(chart_fact_y1),
|
||||||
|
'chart_fact_y2': json.dumps(chart_fact_y2),
|
||||||
|
'chart_fact_y3': json.dumps(chart_fact_y3),
|
||||||
|
'title_devis1': title_devis1,
|
||||||
|
'title_devis2': title_devis2,
|
||||||
|
'title_devis3': title_devis3,
|
||||||
|
'title_fact1': title_fact1,
|
||||||
|
'title_fact2': title_fact2,
|
||||||
|
'title_fact3': title_fact3,
|
||||||
'societes': societes,
|
'societes': societes,
|
||||||
'societe': societe,
|
'societe': societe,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user