Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permitir decidir si cuadrar ajustes al obtener lecturas #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions gestionatr/input/messages/F1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ def get_dates_inici_i_final(self):

return data_inici, data_final

def get_lectures(self, tipus=None, force_no_transforma_no_td_a_td=False):
def get_lectures(self, tipus=None, force_no_transforma_no_td_a_td=False, force_no_quadrar_ajust=False):
"""Retorna totes les lectures en una llista de Lectura"""
lectures = []
try:
Expand All @@ -1660,7 +1660,9 @@ def get_lectures(self, tipus=None, force_no_transforma_no_td_a_td=False):
lectures.extend(self.factura.get_fake_AS_p2_lectures())

if not force_no_transforma_no_td_a_td and self.factura:
lectures = self.factura.transforma_no_td_a_td(lectures, tipus=tipus)
lectures = self.factura.transforma_no_td_a_td(
lectures, tipus=tipus, force_no_quadrar_ajust=force_no_quadrar_ajust
)
lectures = sorted(lectures, key=lambda x: x.lectura_desde.fecha)
return lectures

Expand All @@ -1682,6 +1684,9 @@ def get_lectures_energia(self):
def get_lectures_maximetre(self):
return self.get_lectures(['M'])

def get_lectures_energia_sense_activa_entrant(self):
return self.get_lectures(['S', 'R', 'RC'])


class MultiModeloAparato(ModeloAparato):
"""This is to solve the perfectly reasonable decision made by a certain
Expand Down Expand Up @@ -1959,7 +1964,7 @@ def informacion_al_consumidor(self):
return InformacionAlConsumidor(self.factura.InformacionAlConsumidor)
return None

def transforma_no_td_a_td(self, lectures, tipus=None):
def transforma_no_td_a_td(self, lectures, tipus=None, force_no_quadrar_ajust=False):
if self.datos_factura.tarifa_atr_fact not in TARIFES_TD:
return lectures

Expand All @@ -1974,9 +1979,14 @@ def transforma_no_td_a_td(self, lectures, tipus=None):
res = []
for t in tipus_lectures:
lectures_td = self.get_lectures_amb_periodes_td(lectures, t)
lectures_amb_ajustos = self.get_lectures_amb_ajust_quadrat_amb_consum(t, lectures=lectures_td, motiu_ajust='97')
for aux in lectures_amb_ajustos.values():
res.extend(aux)
# By default
if not force_no_quadrar_ajust:
lectures_amb_ajustos = self.get_lectures_amb_ajust_quadrat_amb_consum(t, lectures=lectures_td, motiu_ajust='97')
for aux in lectures_amb_ajustos.values():
res.extend(aux)
else:
res.extend(lectures_td)

return res

def get_lectures_amb_periodes_td(self, lectures, tipus):
Expand Down