Skip to content

Crear lecturas ficticias de consumo al recibir únicamente totalizador con codigo de tarifas nuevas#288

Merged
eberloso merged 5 commits intomasterfrom
permitir_importar_f1_lectura_totalizador_td
Nov 4, 2025
Merged

Crear lecturas ficticias de consumo al recibir únicamente totalizador con codigo de tarifas nuevas#288
eberloso merged 5 commits intomasterfrom
permitir_importar_f1_lectura_totalizador_td

Conversation

@MarcCalvoC
Copy link
Contributor

@MarcCalvoC MarcCalvoC commented Oct 27, 2025

🚀 Objetivos

  • Permitir la importación de F1s con lecturas que tengan códigos de las lecturas nuevas (TD) y sean totalizadoras (90 y A0).

⚙️ Comportamiento Anterior

🔹 Caso Lecturas PRE TD

  • Se creaban lecturas ficticias con valor 0 para los periodos faltantes.
  • Esto evitaba que saltase la validación 3008.
  • Se calculaban ajustes para facturar el consumo correspondiente.

🔹 Caso Lecturas TD

  • No se creaban lecturas ficticias.
  • El F1 quedaba en fase 3 durante la importación debido a la validación 3008.

🆕 Comportamiento Nuevo

🔹 Caso Lecturas PRE TD

  • Se mantiene el mismo comportamiento que antes.

🔹 Caso Lecturas TD

Cuando la factura tiene el consumo repartido en varios periodos y el F1 incluye lecturas TD, se siguen estos pasos:

  1. Obtener lecturas por fecha

    • Determinar cuántas lecturas se están importando (para un contador concreto).
  2. Analizar cada fecha

    • Comprobar si la lectura es totalizadora (90 o A0).
    • Si no es totalizadora, pasar a la siguiente fecha.
  3. Crear lecturas a partir del totalizador

    • La lectura totalizadora pasa a ser la lectura de P1.
    • Crear lecturas ficticias para el resto de periodos.

📝 Notas

  • Esta actualización evita que los F1 queden en fase 3 al importar lecturas con código totalizador de las nuevas tarifas.
  • Se mantiene la compatibilidad con el comportamiento antiguo

@MarcCalvoC MarcCalvoC self-assigned this Oct 27, 2025
@MarcCalvoC MarcCalvoC requested a review from eberloso October 27, 2025 11:03
@eberloso eberloso requested a review from Copilot October 27, 2025 11:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to create fictitious consumption readings when receiving a totalized meter reading with new tariff codes. The main purpose is to handle cases where the ERP needs to generate fake readings because certain period-specific readings are not provided in the incoming data.

Key changes:

  • Extracted fake lecture creation logic into a dedicated method get_fake_lectures()
  • Added support for creating fake period readings (P1, P2, etc.) when receiving AE totalizer readings with new tariff codes
  • Added helper methods to detect AE totalizer readings and generate appropriate fake period readings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MarcCalvoC MarcCalvoC force-pushed the permitir_importar_f1_lectura_totalizador_td branch from c74abfc to d60581d Compare October 27, 2025 11:25
@MarcCalvoC MarcCalvoC changed the title Crear lecturas ficticias de consumo al recibir totalizador con codigo de tarifas nuevas Crear lecturas ficticias de consumo al recibir únicamente totalizador con codigo de tarifas nuevas Nov 4, 2025
@eberloso eberloso merged commit d070777 into master Nov 4, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants