From 125372862f039430a1b20377566e8f702cb2b1a5 Mon Sep 17 00:00:00 2001
From: Remi <remi@le-filament.com>
Date: Fri, 19 Jan 2018 18:02:00 +0100
Subject: [PATCH] Fix way of calculating CA

---
 models/lefilament_tdb.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/models/lefilament_tdb.py b/models/lefilament_tdb.py
index bba7603..804042e 100644
--- a/models/lefilament_tdb.py
+++ b/models/lefilament_tdb.py
@@ -38,7 +38,7 @@ class LeFilamentTdb(models.Model):
 				
 				##############    CA    ################
 				# FACTURÉ
-				self.env.cr.execute("select sum(amount_untaxed) from account_invoice where state!='draft' and type='out_invoice' and date >= date_trunc('month', %s) and date < date_trunc('month', %s + interval '1' month);", (date_tdb, date_tdb) )
+				self.env.cr.execute("select sum(amount_untaxed_signed) from account_invoice where state!='draft' and (type='out_invoice' or type='out_refund') and date >= date_trunc('month', %s) and date < date_trunc('month', %s + interval '1' month);", (date_tdb, date_tdb) )
 				ca_mois = self.env.cr.fetchone()[0]
 
 				##############    COMMANDES    ################
@@ -125,7 +125,7 @@ class LeFilamentTdb(models.Model):
 		self._cr.execute("""
 			SELECT
             	(select count(*) from account_invoice) as id,
-            	(select sum(amount_untaxed) from account_invoice where state!='draft' and type='out_invoice' and date >= date_trunc('year', current_date) and date < date_trunc('year', current_date + interval '1' year) ) as facture, 
+            	(select sum(amount_untaxed_signed) from account_invoice where state!='draft' and (type='out_invoice' or type='out_refund') and date >= date_trunc('year', current_date) and date < date_trunc('year', current_date + interval '1' year) ) as facture, 
             	(select sum(residual_company_signed) from account_invoice where state!='draft' and type='out_invoice' ) as a_encaisser, 
             	(select sum(residual_company_signed) from account_invoice where state!='draft' and type='in_invoice' ) as a_payer, 
             	(select sum(planned_revenue*probability/100) from crm_lead where active=True and (date_deadline < date_trunc('year', current_date  + interval '1' year) or date_deadline is null) ) as pipe, 
-- 
GitLab