Update template from v3.2.1 to v.3.2.2

Add some new fields like:
- period date in invoice line
- extra information in line
- Company Register Data
This commit is contained in:
Bernat Brunet 2022-11-11 11:31:29 +01:00
parent 32f8d9b048
commit f6a0701988
6 changed files with 164 additions and 3498 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.facturae.es/Facturae/2014/v3.2.1/Facturae" targetNamespace="http://www.facturae.es/Facturae/2014/v3.2.1/Facturae" version="3.2.1">
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.facturae.gob.es/formato/Versiones/Facturaev3_2_2.xml" targetNamespace="http://www.facturae.gob.es/formato/Versiones/Facturaev3_2_2.xml" version="3.2.2">
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/>
<xs:element name="Facturae">
<xs:annotation>
@ -45,10 +45,10 @@
<!--XMLFacturae -->
<xs:complexType name="FileHeaderType">
<xs:sequence>
<xs:element name="SchemaVersion" type="SchemaVersionType" default="3.2.1">
<xs:element name="SchemaVersion" type="SchemaVersionType" default="3.2.2">
<xs:annotation>
<xs:documentation xml:lang="en"> Code indicating the XSD version used. There will be compatibility of versions. </xs:documentation>
<xs:documentation xml:lang="es"> Código que indica versión utilizada. Existirá compatibilidad de versiones. </xs:documentation>
<xs:documentation xml:lang="en"> Code indicating the XSD version used.</xs:documentation>
<xs:documentation xml:lang="es"> Código que indica versión utilizada.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Modality" type="ModalityType">
@ -136,8 +136,8 @@
</xs:element>
<xs:element name="TotalExecutableAmount" type="AmountType">
<xs:annotation>
<xs:documentation xml:lang="en"> Sum of the differences of the amounts (TotalOutstandingAmount and WithholdingAmount) of the file = Sum of the amounts TotalExecutableAmount, up to eight decimal points. It is the amount that is debited less any amount withheld as a performance guarantee.</xs:documentation>
<xs:documentation xml:lang="es"> Total a Ejecutar. Sumatorio de las diferencias de los importes (TotalOutstandingAmount y WithholdingAmount) del fichero = Sumatorio de los Importes TotalExecutableAmount, hasta ocho decimales. Es el importe que se adeuda minorado en un posible importe retenido en garantía de cumplimientos contractuales.</xs:documentation>
<xs:documentation xml:lang="en"> Sum of the amounts TotalExecutableAmount, up to eight decimal points.</xs:documentation>
<xs:documentation xml:lang="es"> Total a Ejecutar. Sumatorio de los Importes TotalExecutableAmount, hasta ocho decimales.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="InvoiceCurrencyCode" type="CurrencyCodeType">
@ -168,6 +168,12 @@
<xs:documentation xml:lang="es"> Texto de la cláusula de cesión.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="FactoringAssignmentDocument" type="FactoringAssignmentDocumentType" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation xml:lang="en"> Data to identify the online reference of the factoring documents</xs:documentation>
<xs:documentation xml:lang="es"> Datos para identificar la referencia electrónica de los documentos de cesión.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AssigneeType">
@ -413,6 +419,30 @@
<xs:documentation xml:lang="es"> Lengua. Código ISO 639-1:2002 Alpha-2 de la lengua en la que se emite el documento.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="InvoiceDescription" type="TextMax2500Type" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en"> Invoice's general description.</xs:documentation>
<xs:documentation xml:lang="es"> Descripción general de la factura.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ReceiverTransactionReference" type="TextMax20Type" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en"> Order reference.</xs:documentation>
<xs:documentation xml:lang="es"> Referencia de pedido.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="FileReference" type="TextMax20Type" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en"> Reference of the contract's file.</xs:documentation>
<xs:documentation xml:lang="es"> Código del expediente de contratación.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ReceiverContractReference" type="TextMax20Type" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en"> Reference of the receiver's contract.</xs:documentation>
<xs:documentation xml:lang="es"> Referencia del contrato del receptor.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ItemsType">
@ -492,6 +522,12 @@
<xs:documentation xml:lang="es"> Ampliación motivo de la rectificación. Descripción de las aclaraciones y motivos de la factura rectificativa. </xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="InvoiceIssueDate" type="xs:date" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en"> Date on which the corrective invoice is issued. Mandatory where "CorrectionMethod" takes the value "01" or "02"</xs:documentation>
<xs:documentation xml:lang="es"> Fecha de expedición de la factura rectificada. Valor obligatorio en el supuesto de que el valor de CorrectionMethod sea "01" o "02"</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- Invoices - Invoice - InvoiceIssueData -->
@ -845,8 +881,8 @@
</xs:element>
<xs:element name="TotalExecutableAmount" type="DoubleUpToEightDecimalType">
<xs:annotation>
<xs:documentation xml:lang="en"> Result: TotalOutstandingAmount - WithholdingAmount + Reimbursable expenses + Financial expenses. Up to eight points</xs:documentation>
<xs:documentation xml:lang="es"> Total a ejecutar. Resultado de: TotalOutstandingAmount - Total de Cantidades retenidas + TotalReimbursableExpenses + TotalFinancialExpenses. En Total de Cantidades retenidas se sumaran las cantidades especificadas en los bloques AmountsWithheld. Hasta ocho decimales. </xs:documentation>
<xs:documentation xml:lang="en"> Result: TotalOutstandingAmount - WithholdingAmount - PaymentInKindAmount + Reimbursable expenses + Financial expenses. Up to eight points</xs:documentation>
<xs:documentation xml:lang="es"> Total a ejecutar. Resultado de: TotalOutstandingAmount - WithholdingAmount - PaymentInKindAmount + TotalReimbursableExpenses + TotalFinancialExpenses. En Total de Cantidades retenidas se sumaran las cantidades especificadas en los bloques AmountsWithheld. Hasta ocho decimales. </xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="TotalReimbursableExpenses" type="DoubleUpToEightDecimalType" minOccurs="0">
@ -855,6 +891,12 @@
<xs:documentation xml:lang="es"> Total de suplidos. Hasta ocho decimales.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="PaymentInKind" type="PaymentInKindType" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en"> Payment in kind.</xs:documentation>
<xs:documentation xml:lang="es"> Pagos en especie.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- Invoices - Invoice - Items - InvoiceTotals - Subsidies -->
@ -1142,12 +1184,13 @@
<xs:enumeration value="jpg"/>
<xs:enumeration value="bmp"/>
<xs:enumeration value="tiff"/>
<xs:enumeration value="html"/>
</xs:restriction>
</xs:simpleType>
<!--
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// -->
<!--Complex Types reusados /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<!--Complex Types /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<!--////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<xs:complexType name="TaxIdentificationType">
<xs:sequence>
@ -1739,6 +1782,72 @@
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="FactoringAssignmentDocumentType">
<xs:sequence>
<xs:element name="DocumentCharacter" type="TextMax50Type">
<xs:annotation>
<xs:documentation xml:lang="en">Type of factoring document. Possible values: acuerdo de cesión, poder acreditativo de representación, otros</xs:documentation>
<xs:documentation xml:lang="es">Naturaleza del documento. Posibles valores: acuerdo de cesión, poder acreditativo de representación, otros</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="RepresentationIdentity" type="TextMax80Type" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en">Mandatory where DocumentCharacter takes the value "poder acreditativo de representación". Possible values: del cedente en el acuerdo de cesión, del cesionario en el acuerdo de cesión, de quien efectúa la notificación en nombre de cedente o cesionario.</xs:documentation>
<xs:documentation xml:lang="es">Es obligatorio en el caso de que el valor de DocumentCharacter sea "poder acreditativo de representación". Posibles valores: del cedente en el acuerdo de cesión, del cesionario en el acuerdo de cesión, de quien efectúa la notificación en nombre de cedente o cesionario.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="DocumentType" type="TextMax50Type">
<xs:annotation>
<xs:documentation xml:lang="en">Document's type. Possible values: escritura pública, documento privado</xs:documentation>
<xs:documentation xml:lang="es">Tipo de documento. Posibles valores: escritura pública, documento privado</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Repository" type="RepositoryType" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en">Repository data</xs:documentation>
<xs:documentation xml:lang="es">Datos del archivo electrónico usado</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RepositoryType">
<xs:sequence>
<xs:element name="RepositoryName" type="TextMax20Type">
<xs:annotation>
<xs:documentation xml:lang="en">Repository name which contains the factoring assigment documents. Possible values: CGN, ROLECE, REA, otros</xs:documentation>
<xs:documentation xml:lang="es">Archivo electrónico en el que estuviera anotado el factoring. Posibles valores: CGN, ROLECE, REA, otros</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="URL" type="TextMax250Type" minOccurs="0">
<xs:annotation>
<xs:documentation xml:lang="en">URL of the undefined repository. Mandatory where RepositoryName takes the value "otros"</xs:documentation>
<xs:documentation xml:lang="es">URL del archivo electrónico no definido. Es obligatorio en el caso de que el valor de RepositoryName sea "otros"</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Reference" type="TextMax250Type">
<xs:annotation>
<xs:documentation xml:lang="en">Reference or code of the document at the repository</xs:documentation>
<xs:documentation xml:lang="es">Referencia electrónica o código de verificación en el archivo electrónico</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PaymentInKindType">
<xs:sequence>
<xs:element name="PaymentInKindReason" type="TextMax2500Type">
<xs:annotation>
<xs:documentation xml:lang="en">Reason for the payment in kind</xs:documentation>
<xs:documentation xml:lang="es">Descripción del motivo por el que existe un pago en especie</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="PaymentInKindAmount" type="DoubleUpToEightDecimalType">
<xs:annotation>
<xs:documentation xml:lang="en">Total amount of the payment in kind</xs:documentation>
<xs:documentation xml:lang="es">Importe de los pagos en especie</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<!--Simple Types -->
<!--////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<!--Textos simples /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
@ -1751,7 +1860,7 @@
</xs:simpleType>
<xs:simpleType name="SchemaVersionType">
<xs:restriction base="xs:string">
<xs:enumeration value="3.2.1"/>
<xs:enumeration value="3.2.2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PostCodeType">
@ -2505,6 +2614,12 @@
<xs:documentation xml:lang="es">Vatio-WTT</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="36">
<xs:annotation>
<xs:documentation xml:lang="en">Kilowatt per hora-KWh</xs:documentation>
<xs:documentation xml:lang="es">Kilovatio por hora-KWh</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PaymentMeansType">

5
README
View File

@ -7,10 +7,13 @@ branches). Maybe these patches are required for the module to work.
.. _trytond-patches project: https://bitbucket.org/nantic/trytond-patches
The Facturaev3_2_1-offline.xsd is the same that Facturaev3_2_1.xsd but gets the
The FacturaevX_X_X-offline.xml is the same that FacturaevX_X_X.xml but gets the
xmldsig-core-schema.xsd file from local because it fails to download from
w3.org website.
The file are obtained from:
https://www.facturae.gob.es/formato/Paginas/formato.aspx
Installing
----------

View File

@ -25,8 +25,8 @@ from trytond import backend
from trytond.i18n import gettext
from trytond.exceptions import UserError
# Get from XSD scheme of Facturae 3.2.1
# http://www.facturae.gob.es/formato/Versiones/Facturaev3_2_1.xml
# Get from XSD scheme of Facturae 3.2.2
# http://www.facturae.gob.es/formato/Versiones/Facturaev3_2_2.xml
RECTIFICATIVE_REASON_CODES = [
("01", "Invoice number", "Número de la factura"),
("02", "Invoice serial number", "Serie de la factura"),
@ -110,8 +110,8 @@ FACe_REQUIRED_FIELDS = ['facturae_person_type', 'facturae_residence_type']
_slugify_strip_re = re.compile(r'[^\w\s-]')
_slugify_hyphenate_re = re.compile(r'[-\s]+')
DEFAULT_FACTURAE_TEMPLATE = 'template_facturae_3.2.1.xml'
DEFAULT_FACTURAE_SCHEMA = 'Facturaev3_2_1-offline.xsd'
DEFAULT_FACTURAE_TEMPLATE = 'template_facturae_3.2.2.xml'
DEFAULT_FACTURAE_SCHEMA = 'Facturaev3_2_2-offline.xml'
def slugify(value):

View File

@ -1,7 +1,8 @@
{% from "template_facturae_macros.xml" import administrative_center, address, contact %}<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<namespace:Facturae xmlns:namespace="http://www.facturae.es/Facturae/2014/v3.2.1/Facturae" xmlns:namespace2="http://uri.etsi.org/01903/v1.2.2#" xmlns:namespace3="http://www.w3.org/2000/09/xmldsig#">
{% from "template_facturae_macros.xml" import administrative_center, address, contact, registration_data %}
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<namespace:Facturae xmlns:namespace="http://www.facturae.gob.es/formato/Versiones/Facturaev3_2_2.xml" xmlns:namespace2="http://uri.etsi.org/01903/v1.2.2#" xmlns:namespace3="http://www.w3.org/2000/09/xmldsig#">
<FileHeader>
<SchemaVersion>3.2.1</SchemaVersion>
<SchemaVersion>3.2.2</SchemaVersion>
<Modality>I</Modality>
{# The invoice is signed by Issuer (the company, only supported out invoices) #}
<InvoiceIssuerType>EM</InvoiceIssuerType>
@ -58,7 +59,9 @@
{% if invoice.company.party.trade_name %}
<TradeName>{{ invoice.company.party.trade_name[:40] }}</TradeName>
{% endif %}
{# RegistrationData optional: not supported #}
{% if invoice.company %}
{{ registration_data(invoice.company) }}
{% endif %}
{% if invoice.company.party.addresses %}
{{ address(invoice.company.party.addresses[0]) }}
{% endif %}
@ -92,7 +95,6 @@
{% if invoice.party.trade_name %}
<TradeName>{{ invoice.party.trade_name[:40] }}</TradeName>
{% endif %}
{# RegistrationData optional: not supported #}
{{ address(invoice.invoice_address) }}
{% if invoice.party.contact_mechanisms %}
{{ contact(invoice.party) }}
@ -105,7 +107,6 @@
{% if invoice.party.name.split(' ') | length > 2 %}
<SecondSurname>{{ invoice.party.name and invoice.party.name.split(' ', 2)[2][:40] }}</SecondSurname>
{% endif %}
{# RegistrationData optional: not supported #}
{{ address(invoice.invoice_address) }}
{% if invoice.party.contact_mechanisms %}
{{ contact(invoice.party) }}
@ -140,16 +141,15 @@
<StartDate>{{ invoice.credited_invoices[0].move.period.start_date.isoformat() }}</StartDate>
<EndDate>{{ invoice.credited_invoices[0].move.period.end_date.isoformat() }}</EndDate>
</TaxPeriod>
{# TODO: Methods not supported:
- 02 (solo se
anotan los detalles ya rectificados)
- 03 (Rectificación por
descuento por volumen de operaciones durante un periodo)
{# TODO: Methods not supported:
- 02 (solo se anotan los detalles ya rectificados)
- 03 (Rectificación por descuento por volumen de operaciones durante un periodo)
- 04 (Autorizadas por la Agencia Tributaria)
#}
<CorrectionMethod>01</CorrectionMethod>
<CorrectionMethodDescription>Rectificación íntegra</CorrectionMethodDescription>
{# AdditionalReasonDescription optional: not supported #}
{# TODO: InvoiceIssueDate: Nuevo campo para definir la fecha de expedición de la factura rectificada. Valor obligatorio en el supuesto de que la etiqueta CorrectionMethod tome los valores “01” o “02” #}
</Corrective>
{% endif %}
</InvoiceHeader>
@ -251,7 +251,6 @@
- FileReference, FileDate
- SequenceNumber
- DeliveryNotesReferences (account_invoice_stock)
- LineItemPeriod
- TransactionDate
- Extensions
#}
@ -321,6 +320,12 @@
</Tax>
{% endfor %}
</TaxesOutputs>
{% if line.origin and line.origin.contract %}
<LineItemPeriod>
<StartDate>{{ line.origin.start_date }}</StartDate>
<EndDate>{{ line.origin.end_date }}</EndDate>
</LineItemPeriod>
{% endif %}
{% if line.taxes_additional_line_item_information or line.note %}
<AdditionalLineItemInformation>
{% if line.taxes_additional_line_item_information %}

View File

@ -58,3 +58,17 @@
#}
</ContactDetails>
{% endmacro %}
{% macro registration_data(company) %}
{% if company.registration_data_location %}
<RegistrationData>
<Book>{{ company.registration_data_book[:20] or '0' }}</Book>
<RegisterOfCompaniesLocation>{{ company.registration_data_location[:20] }}</RegisterOfCompaniesLocation>
<Sheet>{{ company.registration_data_sheet[:20] }}</Sheet>
<Folio>{{ company.registration_data_folio[:20] }}</Folio>
<Section>{{ company.registration_data_section[:20] }}</Section>
<Volume>{{ company.registration_data_volume[:20] }}</Volume>
<AdditionalRegistrationData>{{ company.registration_data_additional[:20] }}</AdditionalRegistrationData>
</RegistrationData>
{% endif %}
{% endmacro %}