diff --git a/models/lefilament_tdb.py b/models/lefilament_tdb.py index d1a84af1ba97dd8abba005e19c0902099c3f90a8..493989e21aa36c1680851d94dc16ed7b41429876 100644 --- a/models/lefilament_tdb.py +++ b/models/lefilament_tdb.py @@ -191,10 +191,12 @@ class LeFilamentTdb(models.Model): tresorerie = self._cr.dictfetchall() self._cr.execute("""SELECT - sum(es.total_amount) as cca - from hr_expense_sheet es, hr_expense e - where es.id = e.sheet_id and e.payment_mode='own_account' and es.state!='done';""") - cca = self._cr.fetchone()[0] + (select sum(es.total_amount) as fonds_propres from hr_expense_sheet es, hr_expense e where es.id = e.sheet_id and e.payment_mode='own_account' and es.state!='done') as cca, + (select sum(capital) as capital from hr_employee) as capital;""") + fonds_propres = self._cr.dictfetchall()[0] - return { 'tresorerie': tresorerie, 'cca': cca } + if not fonds_propres['cca']: + fonds_propres['cca'] = 0 + + return { 'tresorerie': tresorerie, 'fonds_propres': fonds_propres } diff --git a/static/src/js/tresorerie.js b/static/src/js/tresorerie.js index 5f754ef893f0f18854c512ec769014ce1955bc87..f1a803816ae447242102ee411fd1a3bd046e7efa 100644 --- a/static/src/js/tresorerie.js +++ b/static/src/js/tresorerie.js @@ -51,6 +51,7 @@ odoo.define('lefilament_tdb.tresorerie', function (require) { var variation = []; var treso = []; var cca = []; + var fonds_propres = [] var labels = []; var tabLength = this.values.tresorerie.length - 1; @@ -69,28 +70,48 @@ odoo.define('lefilament_tdb.tresorerie', function (require) { entree.push(this.values.tresorerie[i].entree); sortie.push(this.values.tresorerie[i].sortie * (-1) ); variation.push(this.values.tresorerie[i].variation); - cca.push(this.values.cca); + cca.push(this.values.fonds_propres.cca); + fonds_propres.push(this.values.fonds_propres.cca+this.values.fonds_propres.capital); labels.push(moment(this.values.tresorerie[i].mois).format('MMM YYYY')); } - - console.log(this.values); var datasets = [ - { label: 'Trésorerie', data: treso.slice(tabLength-11, tabLength+1), backgroundColor: 'transparent',borderColor: '#5E8ED5' }, - { label: 'CCA', data: cca, backgroundColor: 'transparent',borderColor: '#FFA063' }, - { label: 'Variation', data: variation, backgroundColor: 'rgba(255, 197, 98, 0.3)',borderColor: '#FFC562' }, - { label: 'Entrées', data: entree, backgroundColor: 'rgba(81, 210, 183, 0.3)', borderColor: '#51d2b7' }, - { label: 'Sorties', data: sortie, backgroundColor: 'rgba(249, 96, 117, 0.3)', borderColor: '#F96075' }, + { label: 'Trésorerie', data: treso.slice(tabLength-11, tabLength+1), backgroundColor: 'transparent',borderColor: '#5E8ED5', }, + { label: 'CCA', data: cca, backgroundColor: 'transparent',borderColor: '#FFA063', borderWidth: 1, radius: 0, }, + { label: 'Fonds Propres', data: fonds_propres, backgroundColor: 'transparent',borderColor: '#A65520', borderWidth: 1, radius: 0, }, + { label: 'Variation', data: variation, backgroundColor: 'rgba(255, 197, 98, 0.3)',borderColor: '#FFC562', borderWidth: 1, radius: 1, }, + { label: 'Entrées', data: entree, backgroundColor: 'rgba(81, 210, 183, 0.3)', borderColor: '#51d2b7', borderWidth: 1, radius: 1, }, + { label: 'Sorties', data: sortie, backgroundColor: 'rgba(249, 96, 117, 0.3)', borderColor: '#F96075', borderWidth: 1, radius: 1, }, ]; - // var label = 'Année ' + moment(Date.now()).format('YYYY'); + var options = { + scales: { + yAxes: [{ + ticks: { + beginAtZero:true, + } + }] + }, + tooltips: { + backgroundColor: 'rgba(255,255,255,0.8)', + titleFontStyle: 'normal', + titleFontColor: '#999', + bodyFontColor: '#777', + callbacks: { + label: function(tooltipItems, data) { + return ' ' + (tooltipItems.yLabel / 1000).toLocaleString('fr', { maximumFractionDigits: 1 }) + ' k€'; + } + } + }, + responsive: true, + } this.targetData = { labels : labels, datasets : datasets }; - var myLineChart = new Chart(this.ctx, { type: 'line', data: this.targetData, } ); + var myLineChart = new Chart(this.ctx, { type: 'line', data: this.targetData, options: options } ); },