-
-
Notifications
You must be signed in to change notification settings - Fork 614
[17.0][IMP] l10n_es_aeat_sii_invoice_summary: Refactor to avoid overwrite when it is not necessary #4796
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
Open
carlosdauden
wants to merge
3
commits into
OCA:17.0
Choose a base branch
from
Tecnativa:17.0-IMP-l10n_es_aeat_sii_invoice_summary-simplified_invoice
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[17.0][IMP] l10n_es_aeat_sii_invoice_summary: Refactor to avoid overwrite when it is not necessary #4796
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
dbf16b3
[IMP] l10n_es_aeat_sii_invoice_summary: Refactor to avoid overwrite w…
carlosdauden 15be1c7
[IMP] l10n_es_aeat_sii_invoice_summary: Refactor to avoid overwrite w…
carlosdauden ab1b85c
[IMP] l10n_es_aeat_sii_invoice_summary: Añadir _is_aeat_unidentified_…
carlosdauden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto debería llamar a
_is_aeat_summary_invoice, ¿no? De todas formas, este método puede que se use en otros lados donde no interese igualarlas. Habría que pasar un contexto donde se quiere obtener esto y solo entonces igualarlo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, no se debe llamar a
_is_aeat_summary_invoiceporque, tal como está explicado en el comentario, el objetivo es que la estructura sea la misma de la factura simplificada independientemente del resto de condiciones que evalúa ese método.No, no es necesario pasar un contexto ya que no vamos a añadir código innecesario para un caso que no se va a dar.
Si alguna vez se da se deberá evaluar si se quiere mantener este enfoque o hay que cambiarlo, y en caso de querer mantenerlo una solución podría ser añadir ese contexto.
Si se te ocurre un caso real y concreto también podemos hacer ahora ese análisis, pero no porque puede que se use, ya que las posibilidades teóricas y las ocurrencias son infinitas, pero nuestro trabajo es aplicar el sentido común en contacto con la realidad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lo del contexto sí que lo considero necesario, ya que si tienes un método
_is_aeat_simplified_invoice, lo que esperas como programador es que ese método devuelva cuándo la factura es simplificada, no cuando es simplificada y cuando es una factura resumen, con lo que aunque ahora mismo no parece que afecte a ninguna otra cosa (que eso no lo sabes, porque otros han podido utilizar ese método en sus customizaciones), puede que en el futuro a nosotros mismos nos vaya eso en contra.Otra posible vía es la de tener en el módulo padre un método nuevo
_is_sii_simplified_structureo algo así, que sea el que se evalúa para enviar esa estructura básica, y entonces sea el que se sobreescribe aquí.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
¿En qué caso real una factura resumen no tiene el mismo trato que una factura simplificada?
Podemos no hacer absolutamente nada y que sea el usuario el que se asegure de que ambas cosas están marcadas para las facturas resumen, pero lo que se ha intentado es simplificar el código y cubrir el mayor número de casos sin que afecte a nadie que esté usando el módulo sin marcar las facturas resumen como simplificadas.
Antes de hacer el PR me he tomado mi tiempo analizando donde se utiliza cada método e intentando comprender cual es el comportamiento esperado.
En todas las llamadas al método
_is_aeat_simplified_invoice(SII, POS, VeriFactu, etc.) el comportamiento deseado es que las facturas resumen tengan la misma estructura que las simplificadas, por lo que añadir un contexto, un nuevo método o lo que sea va en contra del objetivo de simplificación, ya que habría que modificar todos esos módulos cuando lo que se busca es precisamente lo contrario.Si te parece, en lugar de teorizar sin mirar nada, puedes hacer un pequeño análisis para estudiar el caso concreto y evitas hacer perder más tiempo a las personas que ya lo han realizado.
Una vez hecho ese análisis puedes tomarte la libertad de cerrar el PR y abrir uno nuevo si lo consideras oportuno.
La realidad actual es que las facturas no se envían al SII correctamente y el código que hay es un despropósito (al que por cierto no se le pusieron problemas para fusionar).
Este PR tiene 2 commits en los que se resuelve el problema principal con dos enfoques distintos, siendo el último el óptimo, pero el primero es más conservador por si no se llegaba a entender la segunda opción.