@@ -2383,19 +2383,31 @@ def get_comptador_amb_lectures(self, tipus=None):
23832383 if c .get_lectures (tipus = t ):
23842384 comptador_amb_lectures = c
23852385 break
2386+ if comptador_amb_lectures :
2387+ break
2388+ if comptador_amb_lectures :
2389+ break
23862390
23872391 return comptador_amb_lectures
23882392
23892393 def get_fake_AS_lectures (self , period_start = 1 , comptador_base = None ):
23902394 res = []
23912395 # 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 ]])
2396+ conceptes_repercutibles_excedents = [x for x in (self .conceptos_repercutibles or []) if '7' == x .concepto_repercutible [0 ]]
2397+ te_autoconsum = (self .autoconsumo and self .autoconsumo .energia_excedentaria ) or conceptes_repercutibles_excedents
23932398 if not te_autoconsum :
23942399 return res
23952400 comptador_amb_lectures = self .get_comptador_amb_lectures ()
23962401 if comptador_amb_lectures :
23972402 base_info = comptador_amb_lectures .get_lectures_activa_entrant ()[0 ]
23982403 num_periodes = self .get_num_periodes_from_tarifa_and_tipus (tipus = 'S' )
2404+ # Mandanga per les tarifes antigues. Els excedents s'informaven com a conceptes repercutibles.
2405+ # Si no hem pogut obtenir el num periodes perque son tarifes antigues, i posem tants periodes com
2406+ # conceptes repercutibles tingui
2407+ if not num_periodes :
2408+ num_periodes = len (conceptes_repercutibles_excedents )
2409+ if not num_periodes :
2410+ return res
23992411 # Depending on period_start, P1 is skipped. If we have totalizer, it will be skipped, otherwise we need to
24002412 # create readings for each tariff period
24012413 for i in range (period_start , num_periodes + 1 ): # num_periodes not included, so we add 1
@@ -2694,7 +2706,7 @@ def get_maximetres_consumidor(self):
26942706
26952707 def get_num_periodes_from_tarifa_and_tipus (self , tipus = 'A' ):
26962708 tarifa_atr = self .datos_factura .tarifa_atr_fact
2697- nperiodes_td = PERIODES_PER_TARIFA .get (tarifa_atr , {}).get (tipus , None )
2709+ nperiodes_td = PERIODES_PER_TARIFA .get (tarifa_atr , {}).get (tipus , 0 )
26982710 return nperiodes_td
26992711
27002712 def get_periodes_from_tarifa_and_tipus (self , tipus = 'A' ):
0 commit comments