Skip to content

Commit dee7af5

Browse files
committed
chore: better code
1 parent edff092 commit dee7af5

File tree

1 file changed

+22
-9
lines changed
  • gestionatr/input/messages

1 file changed

+22
-9
lines changed

gestionatr/input/messages/F1.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,18 +2369,31 @@ def get_fake_pX_lectura(self, tipus, periode, base_info, lectura_desde=0, lectur
23692369

23702370
return new_integrador
23712371

2372-
def get_fake_AS_lectures(self, period_start=1, comptador_base=None):
2373-
res = []
2372+
def get_comptador_amb_lectures(self, tipus=None):
2373+
"""
2374+
Retorna el primer comptador que tingui les lectures del tipus inidcat
2375+
Si cap comptador té lectures del primer tipus, es repeteix el procés amb el seguent tipus
2376+
"""
2377+
if tipus is None:
2378+
tipus = ['S', 'A']
23742379
comptador_amb_lectures = None
23752380
for medida in self.medidas:
2376-
for c in medida.modelos_aparatos:
2377-
if c.get_lectures_activa_entrant():
2378-
comptador_amb_lectures = c
2379-
break
2381+
for t in tipus:
2382+
for c in medida.modelos_aparatos:
2383+
if c.get_lectures(tipus=t):
2384+
comptador_amb_lectures = c
2385+
break
2386+
2387+
return comptador_amb_lectures
2388+
2389+
def get_fake_AS_lectures(self, period_start=1, comptador_base=None):
2390+
res = []
2391+
# Si no te autoconsum no creem lectures d'excedents
2392+
te_autoconsum = (self.autoconsumo and self.autoconsumo.energia_excedentaria) or ([x for x in (self.conceptos_repercutibles or []) if '7' == x.concepto_repercutible[0]])
2393+
if not te_autoconsum:
2394+
return res
2395+
comptador_amb_lectures = self.get_comptador_amb_lectures()
23802396
if comptador_amb_lectures:
2381-
te_autoconsum = (self.autoconsumo and self.autoconsumo.energia_excedentaria) or ([x for x in (self.conceptos_repercutibles or []) if '7' == x.concepto_repercutible[0]])
2382-
if not te_autoconsum:
2383-
return res
23842397
base_info = comptador_amb_lectures.get_lectures_activa_entrant()[0]
23852398
num_periodes = self.get_num_periodes_from_tarifa_and_tipus(tipus='S')
23862399
# Depending on period_start, P1 is skipped. If we have totalizer, it will be skipped, otherwise we need to

0 commit comments

Comments
 (0)