-
Notifications
You must be signed in to change notification settings - Fork 11
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
data.ref: update XML schemas of "factura electrónica" #200
base: develop
Are you sure you want to change the base?
data.ref: update XML schemas of "factura electrónica" #200
Conversation
@yaselc please add the referenced files (both the old and the new one) to https://github.com/cl-sii-extraoficial/archivos-oficiales beforehand, so we can reference them here in a more stable way than we did previously |
cd8b08f
to
220b157
Compare
@glarrain should we use separate directories or separate commits will be enough? |
I'd like the following:
|
@glarrain yes, I realized that the changes had to be added in cl-sii-extraoficial/archivos-oficiales, but I had doubts about the structure. Here a single directory is used for the XML schemas, but in cl-sii-extraoficial/archivos-oficiales, they are separated by domain. Could you please, take a look at cl-sii-extraoficial/archivos-oficiales#12, and when those changes are approved then I update this PR. |
f2695c7
to
9620522
Compare
Codecov Report
@@ Coverage Diff @@
## develop #200 +/- ##
========================================
Coverage 81.07% 81.07%
========================================
Files 32 32
Lines 2536 2536
Branches 380 380
========================================
Hits 2056 2056
Misses 306 306
Partials 174 174 Continue to review full report at Codecov.
|
9620522
to
88911a8
Compare
- MD5 checksum: `82d426fc3bd5f3a29e61a1d07ed4d6dd`. | ||
- Retrieval date: 2021-03-31 | ||
- MD5 checksum: `33639f61ef3aa0ec785557b1c8778cea`. | ||
- Source: [cl-sii-extraoficial/archivos-oficiales@c89dec5](https://github.com/cl-sii-extraoficial/archivos-oficiales/pull/14/commits/c89dec54f664281721dcb77af327c4f6c58ec4ff) |
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.
IMO the reference should be a permalink to the specific file, not the commit
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.
Suggestions:
- Update each XSD file in a separate commit.
- In each commit message, include a permalink to the new and old original files.
- For example, in the commit for
DTE_v10.xsd
,- for the new file, include a link pointing to https://github.com/cl-sii-extraoficial/archivos-oficiales/blob/c89dec54f664281721dcb77af327c4f6c58ec4ff/src/code/rtc/2019-12-12-schema_cesion/schema_cesion/DTE_v10.xsd.
- for the old file, I'm not sure where I can find it in
cl-sii-extraoficial
.
- For example, in the commit for
- MD5 checksum: `82d426fc3bd5f3a29e61a1d07ed4d6dd`. | ||
- Retrieval date: 2021-03-31 | ||
- MD5 checksum: `33639f61ef3aa0ec785557b1c8778cea`. | ||
- Source: [cl-sii-extraoficial/archivos-oficiales@c89dec5](https://github.com/cl-sii-extraoficial/archivos-oficiales/pull/14/commits/c89dec54f664281721dcb77af327c4f6c58ec4ff) |
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.
- Source: [cl-sii-extraoficial/archivos-oficiales@c89dec5](https://github.com/cl-sii-extraoficial/archivos-oficiales/pull/14/commits/c89dec54f664281721dcb77af327c4f6c58ec4ff) | |
- Source: [cl-sii-extraoficial/archivos-oficiales@c89dec5](https://github.com/cl-sii-extraoficial/archivos-oficiales/blob/c89dec54f664281721dcb77af327c4f6c58ec4ff/src/code/rtc/2019-12-12-schema_cesion/2019-12-12-schema_cesion.zip) |
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.
Or:
- Source: [cl-sii-extraoficial/archivos-oficiales@c89dec5](https://github.com/cl-sii-extraoficial/archivos-oficiales/pull/14/commits/c89dec54f664281721dcb77af327c4f6c58ec4ff) | |
- Source: [cl-sii-extraoficial/archivos-oficiales@c89dec5](https://github.com/cl-sii-extraoficial/archivos-oficiales/tree/c89dec54f664281721dcb77af327c4f6c58ec4ff/src/code/rtc/2019-12-12-schema_cesion) |
@glarrain: What do you think about adding the package version (from |
I like the concept. However, I think it is simpler to use the value |
Source of the old (current)
|
I love good commit messages, and it pays back to invest time in crafting them ;) |
Update SiiTypes_v10.xsd from the official XML schemas of AEC (Archivo Electrónico de Cesión) Changelog: - Replaces CRLF line endings with LF. - `root`: A new simple type `Dec14_4-0Type` is added for non-negative decimals (admits 0) - `TipoTransCOMPRA`: The base type is changed and adds a restriction for the minimum and the maximum value (1 - 7) - `TipoTransVENTA`: Adds restriction for the minimum and maximum value (1 - 4) Source of the previous version of the file: repository/project "LibreDTE": https://github.com/LibreDTE/libredte-lib/blob/c12f8845/schemas/SiiTypes_v10.xsd Source of the new version of the file: [cl-sii-extraoficial/archivos-oficiales@c89dec5](https://github.com/cl-sii-extraoficial/archivos-oficiales/tree/c89dec54f664281721dcb77af327c4f6c58ec4ff/src/code/rtc/2019-12-12-schema_cesion)
Update DTE_v10.xsd from the official XML schemas of AEC (Archivo Electrónico de Cesión) Changelog: - Replaces CRLF line endings with LF. - `IdDoc`: Adds the element `TipoFactEsp` - `Receptor.Extranjero`: Adds the element `TipoDocID` - `IndServicio`: Adds a new item to the enumeration - `MntExeOtrMnda`: Type changed to `Dec14_4-0Type` - `MntTotOtrMnda`: Type changed to `Dec14_4-0Type` Source of the previous version of the file: repository/project "LibreDTE": https://github.com/LibreDTE/libredte-lib/blob/c12f8845/schemas/EnvioDTE_v10.xsd Source of the new version of the file: [cl-sii-extraoficial/archivos-oficiales@c89dec5](https://github.com/cl-sii-extraoficial/archivos-oficiales/tree/c89dec54f664281721dcb77af327c4f6c58ec4ff/src/code/rtc/2019-12-12-schema_cesion)
88911a8
to
94a2df1
Compare
cl_sii/libs/xml_utils.py
Outdated
@@ -1,476 +1,477 @@ | |||
""" |
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.
WARNING! Change of line terminators?
tests/test_dte_parse.py
Outdated
@@ -1,592 +1,599 @@ | |||
import difflib |
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.
WARNING! Change of line terminators?
795cffc
to
cc0a347
Compare
@@ -31,6 +31,7 @@ | |||
import signxml.exceptions | |||
import xml.parsers.expat | |||
import xml.parsers.expat.errors | |||
from cl_sii import __version__ |
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.
This does not seem right. libs modules should not depend on to the source package (cl_sii
in this case), but the other way around.
@@ -306,7 +307,7 @@ def validate_xml_doc(xml_schema: XmlSchema, xml_doc: XmlElement) -> None: | |||
# Simplest and safest way to get the error message. | |||
# Error example: | |||
# "Element 'DTE': No matching global declaration available for the validation root., line 2" # noqa: E501 | |||
validation_error_msg = str(exc) | |||
validation_error_msg = str(exc) + f". cl-sii Python lib version {__version__}" |
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.
Perhaps add an optional parameter to the function for specifying the xml_schema
version (string) (however the caller chooses to define it)
@@ -4,6 +4,7 @@ | |||
from datetime import date, datetime | |||
|
|||
import cl_sii.dte.constants | |||
from cl_sii import __version__ |
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.
It is confusing to override implicitly the local magic constants. An example of a popular pattern for this:
import cl_sii
LIB_CL_SII_VERSION = cl_sii.__version__
@jtrh @yaselc @yanosky I've thinking about this and I have a sense that having a single "version" of the XML schemas at a point in time might not be convenient. For example, some documents might validate correctly in an older version and not the latest. What if we have a directory for each "version" (it could be a sequential number/letter arbitrarily defined by us, taking care of not conveying the idea that comparing version numbers does not make sense; they are labels/IDs)? It would be up to the caller to decide which version to use ("explicit is better than implicit"). I think that could solve a number of issues that we've been discussing (and other we have not, yet). |
I think it's the other way around, these schemas are supposed to maintain backward compatibility, preventing old invoices from becoming out of date. The problem is to validate new invoices with old versions of the schema. I think using the last version should be always the recommendation. |
I think that SII loves to break the rules and we can not trust them in that regard. Also, it is perfectly possible (and makes sense) for them to introduce a schema for validating all invoices issued from a certain date onwards, and with which older documents wouldn't validate. |
CC: @jtrobles-cdd |
@ycouce-cdd status? |
@glarrain-cdd After your last comments, I began to iterate on a new PR to version the XML schemas on #211 and put this on hold until it is decided which way we will go. |
@ycouce-cdd I'll remove myself as a reviewer of this PR while it's on hold. Feel free to add me back if anything changes. |
Changelog:
SiiTypes_v10.xsd
root
: A new simple typeDec14_4-0Type
is added for non-negative decimals (admits 0)TipoTransCOMPRA
: The base type is changed and adds a restriction for the minimum and the maximum value (1 - 7)TipoTransVENTA
: Adds restriction for the minimum and maximum value (1 - 4)DTE_v10.xsd
IdDoc
: Adds the elementTipoFactEsp
Receptor.Extranjero
: Adds the elementTipoDocID
IndServicio
: Adds a new item to the enumerationMntExeOtrMnda
: Type changed toDec14_4-0Type
MntTotOtrMnda
: Type changed toDec14_4-0Type
Source of the previous version of the file:
repository/project "LibreDTE": https://github.com/LibreDTE/libredte-lib/blob/c12f8845/schemas/SiiTypes_v10.xsd
Source of the new version of the file:
cl-sii-extraoficial/archivos-oficiales@c89dec5