From 75a9f8228149e0db5dac553e47fc363ce0c205df Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Tue, 13 Sep 2022 12:19:41 +0200
Subject: [PATCH] [update] contribution report: do not count invoices without
 bordereau_id for CG Scop

---
 report/scop_contribution_report.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/report/scop_contribution_report.py b/report/scop_contribution_report.py
index cb32d10..4986c5e 100644
--- a/report/scop_contribution_report.py
+++ b/report/scop_contribution_report.py
@@ -95,3 +95,16 @@ class ScopContributionReport(models.Model):
         ]
         domain += add_domain
         return domain
+
+    def _where_invoice(self):
+        """
+        Hérite la fonction parente pour ne prendre que les factures/avoirs rattachés à
+        un bordereau pour la CG Scop et toutes pour les autres sociétés
+        """
+        where_str = super()._where_invoice()
+        where_str += """
+            AND (
+                (i.company_id = 1 AND i.bordereau_id is not null) OR (i.company_id != 1)
+            )
+        """
+        return where_str
-- 
GitLab