-
-
Notifications
You must be signed in to change notification settings - Fork 303
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
[10.0] pyxb 1.2.6 #998
[10.0] pyxb 1.2.6 #998
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
--- Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd.orig 2019-02-12 12:10:42.024629978 +0100 | ||
+++ Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd 2019-02-13 18:16:23.629695305 +0100 | ||
@@ -4,7 +4,7 @@ | ||
xmlns="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" | ||
targetNamespace="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" | ||
version="1.2"> | ||
- <xsd:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/> | ||
+ <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/> | ||
|
||
<xs:element name="FatturaElettronica" type="FatturaElettronicaType"> | ||
<xs:annotation> | ||
@@ -413,6 +413,11 @@ | ||
<xs:documentation>Parcella</xs:documentation> | ||
</xs:annotation> | ||
</xs:enumeration> | ||
+ <xs:enumeration value="TD20"> | ||
+ <xs:annotation> | ||
+ <xs:documentation>Autofattura</xs:documentation> | ||
+ </xs:annotation> | ||
+ </xs:enumeration> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="TipoRitenutaType"> | ||
@@ -1158,62 +1163,62 @@ | ||
</xs:simpleType> | ||
<xs:simpleType name="String10Type"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="(\p{IsBasicLatin}{1,10})" /> | ||
+ <xs:pattern value="(\p{IsBasicLatin}{0,10})" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String15Type"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="(\p{IsBasicLatin}{1,15})" /> | ||
+ <xs:pattern value="(\p{IsBasicLatin}{0,15})" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String20Type"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="(\p{IsBasicLatin}{1,20})" /> | ||
+ <xs:pattern value="(\p{IsBasicLatin}{0,20})" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String35Type"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="(\p{IsBasicLatin}{1,35})" /> | ||
+ <xs:pattern value="(\p{IsBasicLatin}{0,35})" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String60Type"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="(\p{IsBasicLatin}{1,60})" /> | ||
+ <xs:pattern value="(\p{IsBasicLatin}{0,60})" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String80Type"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="(\p{IsBasicLatin}{1,80})" /> | ||
+ <xs:pattern value="(\p{IsBasicLatin}{0,80})" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String100Type"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="(\p{IsBasicLatin}{1,100})" /> | ||
+ <xs:pattern value="(\p{IsBasicLatin}{0,100})" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String60LatinType"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,60}" /> | ||
+ <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{0,60}" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String80LatinType"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,80}" /> | ||
+ <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{0,80}" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String100LatinType"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,100}" /> | ||
+ <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{0,100}" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String200LatinType"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,200}" /> | ||
+ <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{0,200}" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="String1000LatinType"> | ||
<xs:restriction base="xs:normalizedString"> | ||
- <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,1000}" /> | ||
+ <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{0,1000}" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="ProvinciaType"> | ||
@@ -1265,18 +1270,17 @@ | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="Amount8DecimalType"> | ||
- <xs:restriction base="xs:decimal"> | ||
+ <xs:restriction base="xs:string"> | ||
<xs:pattern value="[\-]?[0-9]{1,11}\.[0-9]{2,8}" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="Amount2DecimalType"> | ||
- <xs:restriction base="xs:decimal"> | ||
+ <xs:restriction base="xs:string"> | ||
<xs:pattern value="[\-]?[0-9]{1,11}\.[0-9]{2}" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="RateType"> | ||
- <xs:restriction base="xs:decimal"> | ||
- <xs:maxInclusive value="100.00" /> | ||
+ <xs:restriction base="xs:string"> | ||
<xs:pattern value="[0-9]{1,3}\.[0-9]{2}" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
@@ -1320,7 +1324,7 @@ | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="QuantitaType"> | ||
- <xs:restriction base="xs:decimal"> | ||
+ <xs:restriction base="xs:string"> | ||
<xs:pattern value="[0-9]{1,12}\.[0-9]{2,8}" /> | ||
</xs:restriction> | ||
</xs:simpleType> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Informazioni riguardanti la fatturazione elettronica | ||
|
||
## Incongruenze rispetto alle specifiche del file xsd | ||
|
||
* StringNNType: nelle specifiche da 1 a NN, lo SDI accetta da 0 a N | ||
* Amount8DecimalType, Amount2DecimalType, RateType, QuantitaType sono xs:decimal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modificare da There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stessa cosa di su (la modifica c'era già), il problema è che xs:decimal non permette trailing zeros quindi 5.00 lo rappresenta come 5.0 quando crea una fattura forse si può aggiungere |
||
ma la specifica vieta gli zeri finali, quindi li modifichiamo in xs:string | ||
|
||
## Istruzioni per generazione nuovi bindings | ||
|
||
* Scaricare il relativo xsd in locale | ||
* Applicare la patch allegata, adattarla se necessario | ||
* Generare i bindings utilizzando: `pyxbgen schema.xsd` | ||
* Rimuovere i riferimenti locali dai file py con il comando (adattando l'url se differente): | ||
|
||
`sed -i -e "s,$(pwd),https://www\.fatturapa\.gov\.it/export/fatturazione/sdi/fatturapa/v1\.2\.1,g" *.py` | ||
|
||
* rinominare `binding.py` in `fatturapa_v_1_2.py` | ||
* in cima ai files generati sostiture il commento con il nome del file con la seguente riga: | ||
`# flake8: noqa` | ||
* nel file `fatturapa_v_1_2` individuare la classe `DataFatturaType` ed aggiungere il seguente metodo: | ||
* sostituire i files precedenti | ||
|
||
```python | ||
# remove tzinfo from parsed dates or pyxb will fail the comparison | ||
def __new__(cls, *args, **kwargs): | ||
result = super(DataFatturaType, cls).__new__(cls, *args, **kwargs) | ||
return result.replace(tzinfo=None) | ||
``` | ||
|
||
La patch dell'xsd modifica il range di caratteri delle stringhe portandolo da 1-N a 0-N, | ||
trasforma in stringhe i decimali che hanno bisogno di zeri finali, | ||
inoltre aggiungere il tipo documento TD20 (Autofattura). | ||
|
||
Per la 1.2.1 inoltre corregge un errore di namespace. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015-2016 Lorenzo Battistini - Agile Business Group | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
import logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
# pyxb is referenced in several in top-level statements in | ||
# fatturapa_v_1_1, so we guard the import of the entire file | ||
try: | ||
from . import fatturapa_v_1_1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sherpya intendi qui? il try c'era mica già? temo comunque che il controllo fatto da Travis richieda il try dovunque ci siano import There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quello è un refuso nel codice corrente, nella mia pr ora è così: import logging
_logger = logging.getLogger(__name__)
try:
from . import fatturapa_v_1_2
except Exception as e: # ImportError or pyxb.PyXBVersionError
_logger.warning('%s: %s' % (e.__class__.__name__, e)) e se non hai pyxb 1.2.6:
|
||
except ImportError: | ||
_logger.debug('Cannot `import pyxb`.') # Avoid init error if not installed | ||
from . import fatturapa_v_1_2 | ||
except Exception as e: # ImportError or pyxb.PyXBVersionError | ||
_logger.warning('%s: %s' % (e.__class__.__name__, e)) |
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.
Ok il file da cui parti è https://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2.1/Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd, ma dove hai trovato quello che SDI accetta o meno? (Posto che non dovrebbero essercene accidenti a loro)
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.
non l'ho trovato io, è già nel codice corrente ma fatto direttamente nel codice python generato (vedi cb063e9#diff-f548cc151f6b5372dd653cb1c1378ba0)
Li ho riportati nell'xsd per minimizzare le modifiche al file generato
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.
Concordo che è la soluzione più pulita, ma mi chiedevo il motivo di questi aggiustamenti, forse @eLBati lo sai?
Se avessimo un
xsd
di cosa accetta SDI sarebbe perfetto, ma forse esiste e solo io non lo trovo.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.
non c'è, ho visto su un pdf una fantomatica 1.3 ma non trovo l'xsd, io credo abbiano fatto la specifica ma poi nella pratica accettano anche stringa vuota
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.
@SimoRubi ti chiedi da quale XSD sia stato generato l'attuale
fatturapa_v_1_2.py
? Penso da versioni precedenti dell'XSD pubblicato su https://www.fatturapa.gov.it/export/fatturazione/it/normativa/f-2.htmThere 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.
Non esattamente @eLBati, mi (e ti) chiedo il motivo delle modifiche al file cb063e9#diff-f548cc151f6b5372dd653cb1c1378ba0, in particolare come mai le stringhe sono passate da
{1, x}
a{0, x}
?E' stato per a una nuova versione del XSD o altro?
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.
@SimoRubi il motivo è nel commento:
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.
Quindi sono modifiche fatte su base empirica? Cioè gli XML inviati a SDI fallivano quindi hai cambiato il codice? Speravo fossero dedotti da una qualche specifica su cosa accetta SDI
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.
Ciò che accetta SDI è qui https://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2.1/Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd
Quindi nello specifico
[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,60}
.Il problema è che per pyXB (o meglio per python) la stringa
" "
non passa tale espressione, mentre per SDI sì