template_invoice.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <?xml version='1.0' encoding='utf-8'?>
  2. <odoo>
  3. <data>
  4. <template id="template_invoice_main_post">
  5. <T:TicketBai xmlns:T="urn:ticketbai:emision">
  6. <t t-call="l10n_es_edi_tbai.template_invoice_bundle"/>
  7. </T:TicketBai>
  8. </template>
  9. <template id="template_invoice_main_cancel">
  10. <T:AnulaTicketBai xmlns:T="urn:ticketbai:anulacion">
  11. <t t-call="l10n_es_edi_tbai.template_invoice_bundle"/>
  12. </T:AnulaTicketBai>
  13. </template>
  14. <template id="template_invoice_bundle">
  15. <Cabecera>
  16. <IDVersionTBAI t-out="tbai_version"/>
  17. </Cabecera>
  18. <Sujetos t-if="is_emission">
  19. <t t-call="l10n_es_edi_tbai.template_invoice_sujetos"/>
  20. </Sujetos>
  21. <Factura t-if="is_emission">
  22. <t t-call="l10n_es_edi_tbai.template_invoice_factura"/>
  23. </Factura>
  24. <IDFactura t-if="not is_emission">
  25. <t t-call="l10n_es_edi_tbai.template_invoice_sujetos"/>
  26. <t t-call="l10n_es_edi_tbai.template_invoice_factura"/>
  27. </IDFactura>
  28. <HuellaTBAI>
  29. <EncadenamientoFacturaAnterior t-if="chain_prev_invoice">
  30. <t t-set="seq_and_num" t-value="chain_prev_invoice._get_l10n_es_tbai_sequence_and_number()"/>
  31. <SerieFacturaAnterior t-out="seq_and_num[0]"/>
  32. <NumFacturaAnterior t-out="seq_and_num[1]"/>
  33. <t t-set="sig_and_date" t-value="chain_prev_invoice._get_l10n_es_tbai_signature_and_date()"/>
  34. <FechaExpedicionFacturaAnterior t-out="format_date(sig_and_date[1])"/>
  35. <SignatureValueFirmaFacturaAnterior t-out="sig_and_date[0][:100]"/>
  36. </EncadenamientoFacturaAnterior>
  37. <Software>
  38. <LicenciaTBAI t-out="license_number"/>
  39. <EntidadDesarrolladora>
  40. <NIF t-out="license_nif"/>
  41. </EntidadDesarrolladora>
  42. <Nombre t-out="software_name"/>
  43. <Version t-out="software_version"/>
  44. </Software>
  45. <NumSerieDispositivo>TEST-DEVICE-001</NumSerieDispositivo>
  46. </HuellaTBAI>
  47. </template>
  48. <template id="template_invoice_sujetos">
  49. <Emisor>
  50. <NIF t-out="sender_vat"/>
  51. <ApellidosNombreRazonSocial t-out="sender.name"/>
  52. </Emisor>
  53. <Destinatarios t-if="is_emission and recipient">
  54. <IDDestinatario>
  55. <NIF t-if="recipient.get('nif')" t-out="recipient['nif']"/>
  56. <IDOtro t-else="">
  57. <CodigoPais t-if="recipient.get('alt_id_country')" t-out="recipient['alt_id_country']"/>
  58. <IDType t-out="recipient['alt_id_type']"/>
  59. <ID t-out="recipient['alt_id_number']"/>
  60. </IDOtro>
  61. <t t-set="partner" t-value="recipient['partner']"/>
  62. <ApellidosNombreRazonSocial t-out="partner.name"/>
  63. <CodigoPostal t-out="partner.zip"/>
  64. <Direccion t-out="recipient['partner_address']"/>
  65. </IDDestinatario>
  66. </Destinatarios>
  67. <VariosDestinatarios t-if="is_emission">N</VariosDestinatarios> <!-- Odoo does not support multi-recipient invoices (TBAI does)-->
  68. <EmitidaPorTercerosODestinatario t-if="is_emission">N</EmitidaPorTercerosODestinatario>
  69. </template>
  70. <template id="template_invoice_factura">
  71. <t t-set="is_simplified" t-value="invoice._is_l10n_es_tbai_simplified()"/>
  72. <CabeceraFactura>
  73. <t t-set="seq_and_num" t-value="invoice._get_l10n_es_tbai_sequence_and_number()"/>
  74. <SerieFactura t-out="seq_and_num[0]"/>
  75. <NumFactura t-out="seq_and_num[1]"/>
  76. <t t-if="is_emission">
  77. <FechaExpedicionFactura t-out="format_date(datetime_now)"/>
  78. <HoraExpedicionFactura t-out="format_time(datetime_now)"/>
  79. <FacturaSimplificada t-out="'S' if is_simplified else 'N'"/>
  80. </t>
  81. <FechaExpedicionFactura t-else="" t-out="format_date(invoice._get_l10n_es_tbai_signature_and_date()[1])"/>
  82. <t t-if="is_refund">
  83. <FacturaEmitidaSustitucionSimplificada t-out="'S' if (is_simplified and recipient) else 'N'"/>
  84. <FacturaRectificativa>
  85. <Codigo t-out="credit_note_code"/>
  86. <Tipo>I</Tipo>
  87. <!-- NOTE: could also allow credit note Tipo 'S' (optional, tipo I already supported by SII)
  88. <ImporteRectificacionSustitutiva>
  89. <BaseRectificada>180.00</BaseRectificada>
  90. <CuotaRectificada>20.21</CuotaRectificada>
  91. </ImporteRectificacionSustitutiva> -->
  92. </FacturaRectificativa>
  93. <FacturasRectificadasSustituidas>
  94. <IDFacturaRectificadaSustituida>
  95. <!-- NOTE: could support issuing a single credit note for multiple invoices (optional) -->
  96. <t t-set="seq_and_num" t-value="credit_note_invoice._get_l10n_es_tbai_sequence_and_number()"/>
  97. <SerieFactura t-out="seq_and_num[0]"/>
  98. <NumFactura t-out="seq_and_num[1]"/>
  99. <FechaExpedicionFactura t-out="format_date(credit_note_invoice._get_l10n_es_tbai_signature_and_date()[1])"/>
  100. </IDFacturaRectificadaSustituida>
  101. </FacturasRectificadasSustituidas>
  102. </t>
  103. </CabeceraFactura>
  104. <DatosFactura t-if="is_emission">
  105. <DescripcionFactura t-out="invoice.invoice_origin or 'manual'"/>
  106. <DetallesFactura>
  107. <IDDetalleFactura t-foreach="invoice_lines" t-as="line_values">
  108. <t t-set="line" t-value="line_values['line']"/>
  109. <DescripcionDetalle t-out="line_values['description']"/>
  110. <Cantidad t-out="format_float(line.quantity)"/>
  111. <ImporteUnitario t-out="format_float(line_values['unit_price'])"/>
  112. <Descuento t-out="format_float(line_values['discount'])"/>
  113. <ImporteTotal t-out="format_float(line_values['total'])"/>
  114. </IDDetalleFactura>
  115. </DetallesFactura>
  116. <ImporteTotalFactura t-out="format_float(amount_total)"/>
  117. <!-- <RetencionSoportada/> NOTE (potentially has to be computed/decided manually) -->
  118. <!-- <BaseImponibleACoste/> NOTE (only applicable with ClaveRegimenIvaOpTrascendencia 06, not supported yet) -->
  119. <Claves>
  120. <IDClave t-foreach="regime_key" t-as="key">
  121. <ClaveRegimenIvaOpTrascendencia t-out="key"/>
  122. </IDClave>
  123. </Claves>
  124. </DatosFactura>
  125. <TipoDesglose t-if="is_emission">
  126. <DesgloseFactura t-if="'DesgloseFactura' in invoice_info">
  127. <t t-call="l10n_es_edi_tbai.template_invoice_desglose">
  128. <t t-set="desglose" t-value="invoice_info['DesgloseFactura']"/>
  129. </t>
  130. </DesgloseFactura>
  131. <DesgloseTipoOperacion t-else="">
  132. <t t-set="invoice_info" t-value="invoice_info['DesgloseTipoOperacion']"/>
  133. <PrestacionServicios t-if="invoice_info.get('PrestacionServicios')">
  134. <t t-call="l10n_es_edi_tbai.template_invoice_desglose">
  135. <t t-set="desglose" t-value="invoice_info['PrestacionServicios']"/>
  136. </t>
  137. </PrestacionServicios>
  138. <Entrega t-if="invoice_info.get('Entrega')">
  139. <t t-call="l10n_es_edi_tbai.template_invoice_desglose">
  140. <t t-set="desglose" t-value="invoice_info['Entrega']"/>
  141. </t>
  142. </Entrega>
  143. </DesgloseTipoOperacion>
  144. </TipoDesglose>
  145. </template>
  146. <template id="template_invoice_desglose">
  147. <Sujeta t-if="desglose.get('Sujeta')">
  148. <t t-set="sujeta" t-value="desglose['Sujeta']"/>
  149. <Exenta t-if="sujeta.get('Exenta')">
  150. <DetalleExenta t-foreach="sujeta['Exenta']['DetalleExenta']" t-as="exenta">
  151. <CausaExencion t-out="exenta['CausaExencion']"/>
  152. <BaseImponible t-out="format_float(exenta['BaseImponible'])"/>
  153. </DetalleExenta>
  154. </Exenta>
  155. <NoExenta t-if="sujeta.get('NoExenta')">
  156. <DetalleNoExenta t-if="desglose['S1']">
  157. <TipoNoExenta t-out="'S1'"/>
  158. <DesgloseIVA>
  159. <DetalleIVA t-foreach="desglose['S1']" t-as="detalle">
  160. <BaseImponible t-out="format_float(detalle['BaseImponible'])"/>
  161. <TipoImpositivo t-out="format_float(detalle['TipoImpositivo'])"/>
  162. <CuotaImpuesto t-out="format_float(detalle['CuotaRepercutida'])"/>
  163. <TipoRecargoEquivalencia t-if="detalle.get('TipoRecargoEquivalencia')" t-out="format_float(detalle['TipoRecargoEquivalencia'])"/>
  164. <CuotaRecargoEquivalencia t-if="detalle.get('CuotaRecargoEquivalencia')" t-out="format_float(detalle['CuotaRecargoEquivalencia'])"/>
  165. <OperacionEnRecargoDeEquivalenciaORegimenSimplificado t-out="'S' if is_simplified else 'N'"/>
  166. </DetalleIVA>
  167. </DesgloseIVA>
  168. </DetalleNoExenta>
  169. <DetalleNoExenta t-if="desglose['S2']">
  170. <TipoNoExenta t-out="'S2'"/>
  171. <DesgloseIVA>
  172. <DetalleIVA t-foreach="desglose['S2']" t-as="detalle">
  173. <BaseImponible t-out="format_float(detalle['BaseImponible'])"/>
  174. </DetalleIVA>
  175. </DesgloseIVA>
  176. </DetalleNoExenta>
  177. </NoExenta>
  178. </Sujeta>
  179. <NoSujeta t-if="desglose.get('NoSujeta')">
  180. <t t-set="no_sujeta" t-value="desglose['NoSujeta']"/>
  181. <DetalleNoSujeta>
  182. <Causa>RL</Causa>
  183. <!-- NOTE: Causa should be
  184. 'OT' if 'the' ClaveRegimenIvaOpTrascendencia == 10
  185. 'RL' if 'some' ClaveRegimenIvaOpTrascendencia == 08
  186. BUT those are not supported yet-->
  187. <Importe t-out="no_sujeta.get('ImportePorArticulos7_14_Otros')"/>
  188. <Importe t-out="no_sujeta.get('ImporteTAIReglasLocalizacion')"/>
  189. </DetalleNoSujeta>
  190. </NoSujeta>
  191. </template>
  192. <template id="template_digital_signature">
  193. <ds:Signature t-att-Id="dsig['signature_id']" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  194. <ds:SignedInfo>
  195. <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
  196. <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
  197. <ds:Reference t-att-Id="dsig['reference_uri']" Type="http://www.w3.org/2000/09/xmldsig#Object" URI="">
  198. <ds:Transforms>
  199. <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
  200. </ds:Transforms>
  201. <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
  202. <ds:DigestValue></ds:DigestValue>
  203. </ds:Reference>
  204. <ds:Reference Type="http://uri.etsi.org/01903#SignedProperties" t-attf-URI="##{dsig['sigproperties_id']}">
  205. <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
  206. <ds:DigestValue></ds:DigestValue>
  207. </ds:Reference>
  208. <ds:Reference t-attf-URI="##{dsig['keyinfo_id']}">
  209. <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
  210. <ds:DigestValue></ds:DigestValue>
  211. </ds:Reference>
  212. </ds:SignedInfo>
  213. <ds:SignatureValue></ds:SignatureValue>
  214. <ds:KeyInfo t-att-Id="dsig['keyinfo_id']">
  215. <ds:X509Data>
  216. <ds:X509Certificate t-out="dsig['x509_certificate']"/>
  217. </ds:X509Data>
  218. <ds:KeyValue>
  219. <ds:RSAKeyValue>
  220. <ds:Modulus t-out="dsig['public_modulus']"/>
  221. <ds:Exponent t-out="dsig['public_exponent']"/>
  222. </ds:RSAKeyValue>
  223. </ds:KeyValue>
  224. </ds:KeyInfo>
  225. <ds:Object>
  226. <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" t-attf-Target="##{dsig['signature_id']}">
  227. <xades:SignedProperties t-att-Id="dsig['sigproperties_id']">
  228. <xades:SignedSignatureProperties>
  229. <xades:SigningTime t-out="dsig['iso_now']"/>
  230. <xades:SigningCertificateV2>
  231. <xades:Cert>
  232. <xades:CertDigest>
  233. <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
  234. <ds:DigestValue t-out="dsig['sigcertif_digest']"/>
  235. </xades:CertDigest>
  236. <xades:IssuerSerial>
  237. <ds:X509IssuerName t-out="dsig['x509_issuer_description']"/>
  238. <ds:X509SerialNumber t-out="dsig['x509_serial_number']"/>
  239. </xades:IssuerSerial>
  240. </xades:Cert>
  241. </xades:SigningCertificateV2>
  242. <xades:SignaturePolicyIdentifier>
  243. <xades:SignaturePolicyId>
  244. <xades:SigPolicyId>
  245. <xades:Identifier t-out="dsig['sigpolicy_url']"/>
  246. </xades:SigPolicyId>
  247. <xades:SigPolicyHash>
  248. <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
  249. <ds:DigestValue t-out="dsig['sigpolicy_digest']"/>
  250. </xades:SigPolicyHash>
  251. </xades:SignaturePolicyId>
  252. </xades:SignaturePolicyIdentifier>
  253. </xades:SignedSignatureProperties>
  254. </xades:SignedProperties>
  255. </xades:QualifyingProperties>
  256. </ds:Object>
  257. </ds:Signature>
  258. </template>
  259. </data>
  260. </odoo>