lib-cl-sii-python icon indicating copy to clipboard operation
lib-cl-sii-python copied to clipboard

data.ref: update XML schemas of "factura electrónica"

Open yaselc opened this issue 3 years ago • 18 comments

Changelog:

  • SiiTypes_v10.xsd
    • 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)
  • DTE_v10.xsd
    • 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/SiiTypes_v10.xsd

Source of the new version of the file: cl-sii-extraoficial/archivos-oficiales@c89dec5

yaselc avatar Mar 09 '21 22:03 yaselc

@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

https://github.com/cl-sii-extraoficial/archivos-oficiales/issues/11

glarrain avatar Mar 10 '21 14:03 glarrain

please add the referenced files (both the old and the new one) to https://github.com/cl-sii-extraoficial/archivos-oficiales beforehand,

@glarrain should we use separate directories or separate commits will be enough?

yaselc avatar Mar 10 '21 20:03 yaselc

I'd like the following:

  1. the files that are updated and/or referenced here please upload them to https://github.com/cl-sii-extraoficial/archivos-oficiales
  2. update this PR (description, commits and code) with references to that repo, with permalinks (shorted if you want, but make sure the commit ID is included)

glarrain avatar Mar 11 '21 12:03 glarrain

I'd like the following:

  1. the files that are updated and/or referenced here please upload them to https://github.com/cl-sii-extraoficial/archivos-oficiales
  2. update this PR (description, commits and code) with references to that repo, with permalinks (shorted if you want, but make sure the commit ID is included)

@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 https://github.com/cl-sii-extraoficial/archivos-oficiales/pull/12, and when those changes are approved then I update this PR.

yaselc avatar Mar 15 '21 12:03 yaselc

Codecov Report

Merging #200 (88911a8) into develop (d9e4eab) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d9e4eab...88911a8. Read the comment docs.

codecov-io avatar Mar 31 '21 22:03 codecov-io

@glarrain @jtrh this PR is ready for your review 🙏

yaselc avatar Mar 31 '21 22:03 yaselc

@yaselc since this change might have a significant impact perhaps some validation with lots of real XML files would be appropriate. Also, I'm thinking that perhaps we should record somehow along the validation the "version" of XML schemas set. What do you think @jtrh ?

glarrain avatar Apr 06 '21 00:04 glarrain

Also, I'm thinking that perhaps we should record somehow along the validation the "version" of XML schemas set. What do you think @jtrh ?

@glarrain: What do you think about adding the package version (from setup.py) to the error message of the exception raised in cl_sii.libs.xml_utils.validate_xml_doc? Caveat: The information would only be guaranteed to be correct for Git-tagged releases, as any changes to the XSD files would not be reflected in the package version until the next release; however, the advantage of this idea is that it should be straightforward to implement, and does not require metadata such as the commit IDs or the checksums of the XSD files.

jtrh avatar Apr 06 '21 05:04 jtrh

Also, I'm thinking that perhaps we should record somehow along the validation the "version" of XML schemas set. What do you think @jtrh ?

@glarrain: What do you think about adding the package version (from setup.py) to the error message of the exception raised in cl_sii.libs.xml_utils.validate_xml_doc?

I like the concept. However, I think it is simpler to use the value cl_sii.__version__.

glarrain avatar Apr 06 '21 14:04 glarrain

Source of the old (current) DTE_v10.xsd and SiiTypes_v10.xsd is LibreDTE.

commit 8b51350cf0590ab7ba4a1390676f6b307395b950
Author: Germán Larraín <[email protected]>
Date:   Thu Jan 17 16:41:46 2019 -0300

    data.ref: update XML schemas of "factura electrónica"
    
    Update schemas from an unofficial source since the files available on
    SII's website are outdated with respect to the regulations (and even
    to the documentation PDFs published alongside).
    
    Source: repository/project "LibreDTE" at
    https://github.com/LibreDTE/libredte-lib
    
    Specific source per file:
    - 'schema_dte/DTE_v10.xsd':
      https://github.com/LibreDTE/libredte-lib/blob/c12f8845/schemas/DTE_v10.xsd
    - 'schema_dte/EnvioDTE_v10.xsd':
      https://github.com/LibreDTE/libredte-lib/blob/c12f8845/schemas/EnvioDTE_v10.xsd
    - 'schema_dte/SiiTypes_v10.xsd':
      https://github.com/LibreDTE/libredte-lib/blob/c12f8845/schemas/SiiTypes_v10.xsd
    - 'schema_iecv/LceCal_v10.xsd'
      https://github.com/LibreDTE/libredte-lib/blob/c12f8845/schemas/LceCal_v10.xsd
    - 'schema_iecv/LceCoCertif_v10.xsd'

jtrh avatar Apr 06 '21 22:04 jtrh

I love good commit messages, and it pays back to invest time in crafting them ;)

glarrain avatar Apr 08 '21 04:04 glarrain

@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).

glarrain avatar Apr 09 '21 13:04 glarrain

For example, some documents might validate correctly in an older version and not the latest.

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. It could still happen, but this could be solved using a completely different version of the entire library because most likely even the models need to change, not just the schemas.

yaselc avatar Apr 09 '21 14:04 yaselc

I think it's the other way around, these schemas are supposed to maintain backward compatibility

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.

glarrain avatar Apr 09 '21 14:04 glarrain

CC: @jtrobles-cdd

jtrh avatar May 05 '21 23:05 jtrh

@ycouce-cdd status?

glarrain-cdd avatar Jun 01 '21 22:06 glarrain-cdd

@ycouce-cdd status?

@glarrain-cdd After your last comments, I began to iterate on a new PR to version the XML schemas on https://github.com/fyntex/lib-cl-sii-python/pull/211 and put this on hold until it is decided which way we will go.

ycouce-cdd avatar Jun 01 '21 22:06 ycouce-cdd

[...] 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.

jtrobles-cdd avatar Jun 04 '21 16:06 jtrobles-cdd