From 295ee4acd0c1c0e882bb1151b68fe3cdb3ae1c52 Mon Sep 17 00:00:00 2001 From: Eduard Carreras Date: Thu, 4 Apr 2024 13:28:35 +0200 Subject: [PATCH] =?UTF-8?q?A1:=20Millorem=20el=20c=C3=A0lcul=20de=20la=20p?= =?UTF-8?q?otencia=20adscrita?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libcnmc/cir_8_2021/FA1.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libcnmc/cir_8_2021/FA1.py b/libcnmc/cir_8_2021/FA1.py index 3b4eef47..98e0b427 100644 --- a/libcnmc/cir_8_2021/FA1.py +++ b/libcnmc/cir_8_2021/FA1.py @@ -712,8 +712,24 @@ def consumer(self): # potencia adscrita o_pot_ads = 0 - if cups.get('potencia_adscrita', False): + + if cups['force_potencia_adscrita']: o_pot_ads = cups['potencia_adscrita'] + else: + # Buscar butlletins vigents en data circular i agafgar el màxim + current_date = '{}-01-01'.format(self.year) + but_ids = self.connection.GiscedataButlleti.search([ + ('cups_id', '=', cups['id']), + '|', '|', '|', + '&', ('data', '=', False), ('data_vigencia', '=', False), + '&', ('data', '<=', current_date), ('data_vigencia', '=', False), + '&', ('data', '=', False), ('data_vigencia', '>=', current_date), + '&', ('data', '<=', current_date), ('data_vigencia', '>=', current_date), + ], 0, 0, False, {'active_test': False}) + o_pot_ads = max( + b['pot_max_admisible'] + for b in self.connection.GiscedataButlleti.read(but_ids, ['pot_max_admisible']) + ) if o_pot_ads < o_potencia: o_pot_ads = o_potencia