Formato XML de Factura Electrónica 2019

Formato XML de Factura Electrónica 2019

El formato XML de la Factura Electrónica ha variado y con estos cambios ahora existen varias validaciones por parte de la SUNAT en el periodo 2019 que ya entraron en vigencia, por consiguiente nosotros hemos creado este artículo con el fin de brindar un apoyo a aquellos desarrolladores de sistemas que necesiten una guía más práctica para generar sus archivos XML. Estos cambios están reflejados hasta el día de 29/10/2019.

De seguro te ha salido mensaje como los siguientes al momento de recuperar el CDR generado por la Sunat:

<cbc:Note>4252 - El dato ingresado como atributo @listName es incorrecto. 
- Detalle: value='ticket: 05f1ff11-91e6-42c2-b746-5badf20cb335, 
error: Error en la linea: 1 :  (nodo: "/Invoice/cac:AdditionalDocumentReference/cbc:DocumentStatusCode@listName" 
valor: "SUNAT:Codigo de Tipo de Afectación del IGV")'</cbc:Note>

<cbc:Note>4255 - El dato ingresado como atributo @schemeName es incorrecto. 
- Detalle: value='ticket: 05f1ff11-91e6-42c2-b746-5badf20cb335, 
error: Error en la linea: 1 :  (nodo: "/Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID@schemeName" 
valor: "Tax Scheme Identifier")'</cbc:Note>

<cbc:Note>4256 - El dato ingresado como atributo @schemeAgencyName es incorrecto. 
- Detalle: value='ticket: 05f1ff11-91e6-42c2-b746-5badf20cb335, 
error: Error en la linea: 1 :  (nodo: "/Invoice/cac:PrepaidPayment/cbc:ID@schemeAgencyName" 
valor: "United Nations Economic Commission for Europe")'</cbc:Note>

Con este formato XML que adjunto a continuación encontrarás la solución a ello, esperemos que sea de gran apoyo este articulo.

Formato XML – Factura Electrónica Gravada
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ext:UBLExtensions>
    <ext:UBLExtension>
      <ext:ExtensionContent>
      <Signature Id="Sunat" xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>lmt4c+EFHCd7kbFsgjhDILTy3yg=</DigestValue></Reference></SignedInfo><SignatureValue>ZjOCE0WhoJuB1SIccNIqXMpHVdN99A1KK+rXZjmU3Zd8x7FLzzhxti0ouUC6BijWZHAAD6/e/yJ6/QV+9s8neqIZ9ZSIAr+6HEmCPxvH2EJfCAkBjxWKY48fitf+TnbE2yJe/zLDs/DZYSwvS+PT5a3o/iTrXTu2Y9uxIhDQn553DinIQHEvouqG4OFmAY/NlLK2Vi2vcLmzTTs6ONfVVS6iDL7CyIkWybAvuqPj1JBSfOYFluAGYMZ8WxRTC/FLHWQsrHOe9mjPDj9jSLRMb5Zg/bQ+vehSCUVjZazJ0Ja4mFS3J+fsTsiVDA2nEoLHAbIcAlPakHGfL7LdmTEy1A==</SignatureValue><KeyInfo><X509Data><X509SubjectName>OID.1.3.6.1.4.1.18838.1.1=10472847, CN=BUSINESS INTEGRITY AND MANAGEMENT SERVICES INTERNATIONAL COMPANY S.A.C., C=PE, S=LIMA, L=SAN BORJA, OU=Certificado de Representante Legal de Persona Juridica PE (FIRMA), E=zguerrero@bimsic.pe, G=ZANDRA, SN=XXX XXX, O=BUSINESS INTEGRITY AND MANAGEMENT SERVICES INTERNATIONAL COMPANY S.A.C., T=GERENTE GENERAL, Description=Reg. Pub.:  Inscripción:  Cargo:GERENTE GENERAL  Notario:PARTIDA ELECTRÓNICA N° XXXX Núm. Protocolo:  Fecha de Otorgamiento:25/02/2019, OID.2.5.4.97=20550409667, SERIALNUMBER=20550409667</X509SubjectName><X509Certificate>CODIGOCERTIFICADO</X509Certificate></X509Data></KeyInfo></Signature></ext:ExtensionContent>
    </ext:UBLExtension>
  </ext:UBLExtensions>
  <cbc:UBLVersionID>2.1</cbc:UBLVersionID>
  <cbc:CustomizationID>2.0</cbc:CustomizationID>
  <cbc:ProfileID schemeName="SUNAT:Identificador de Tipo de Operación" schemeAgencyName="PE:SUNAT" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo17">0101</cbc:ProfileID>
  <cbc:ID>F001-31</cbc:ID>
  <cbc:IssueDate>2019-10-31</cbc:IssueDate>
  <cbc:IssueTime>08:48:29</cbc:IssueTime>
  <cbc:DueDate>2019-10-31</cbc:DueDate>
  <cbc:InvoiceTypeCode listID="0101" listAgencyName="PE:SUNAT" listName="Tipo de Documento" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">01</cbc:InvoiceTypeCode>
  <cbc:Note languageLocaleID="1000">SON CUATROCIENTOS SESENTA Y 00/100 SOLES</cbc:Note>
  <cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listName="Currency" listAgencyName="United Nations Economic Commission for Europe">PEN</cbc:DocumentCurrencyCode>
  <cac:Signature>
    <cbc:ID>20550409667</cbc:ID>
    <cac:SignatoryParty>
      <cac:PartyIdentification>
        <cbc:ID>20550409667</cbc:ID>
      </cac:PartyIdentification>
      <cac:PartyName>
        <cbc:Name><![CDATA[BUSINESS INTEGRITY AND MANAGEMENT SERVICES INTERNATIONAL COMPANY S.A.C.]]></cbc:Name>
      </cac:PartyName>
    </cac:SignatoryParty>
    <cac:DigitalSignatureAttachment>
      <cac:ExternalReference>
        <cbc:URI>20550409667</cbc:URI>
      </cac:ExternalReference>
    </cac:DigitalSignatureAttachment>
  </cac:Signature>
  <cac:AccountingSupplierParty>
    <cac:Party>
      <cac:PartyIdentification>
        <cbc:ID schemeID="6" schemeName="Documento de Identidad" schemeAgencyName="PE:SUNAT" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">20550409667</cbc:ID>
      </cac:PartyIdentification>
      <cac:PartyName>
        <cbc:Name><![CDATA[BIMS INTERNATIONAL COMPANY S.A.C.]]></cbc:Name>
      </cac:PartyName>
      <cac:PartyLegalEntity>
        <cbc:RegistrationName><![CDATA[BUSINESS INTEGRITY AND MANAGEMENT SERVICES INTERNATIONAL COMPANY S.A.C.]]></cbc:RegistrationName>
        <cac:RegistrationAddress>
          <cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
        </cac:RegistrationAddress>
      </cac:PartyLegalEntity>
    </cac:Party>
  </cac:AccountingSupplierParty>
  <cac:AccountingCustomerParty>
    <cac:Party>
      <cac:PartyIdentification>
        <cbc:ID schemeID="6" schemeName="Documento de Identidad" schemeAgencyName="PE:SUNAT" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06">20603163622</cbc:ID>
      </cac:PartyIdentification>
      <cac:PartyLegalEntity>
        <cbc:RegistrationName><![CDATA[EMGIEM BC SOCIEDAD ANONIMA CERRADA]]></cbc:RegistrationName>
      </cac:PartyLegalEntity>
    </cac:Party>
  </cac:AccountingCustomerParty>
  <cac:DeliveryTerms>
    <cac:DeliveryLocation>
      <cac:Address>
        <cbc:StreetName>AV. SANTIAGO ANTUNEZ DE MAYOL URB. LOS PINARES NRO. 1357  - LIMA - LIMA - LOS OLIVOS</cbc:StreetName>
        <cbc:CitySubdivisionName />
        <cbc:CityName>LIMA</cbc:CityName>
        <cbc:CountrySubentity>LIMA</cbc:CountrySubentity>
        <cbc:CountrySubentityCode>150117</cbc:CountrySubentityCode>
        <cbc:District>LOS OLIVOS</cbc:District>
        <cac:Country>
          <cbc:IdentificationCode listID="ISO 3166-1" listAgencyName="United Nations Economic Commission for Europe" listName="Country">PE</cbc:IdentificationCode>
        </cac:Country>
      </cac:Address>
    </cac:DeliveryLocation>
  </cac:DeliveryTerms>
  <cac:TaxTotal>
    <cbc:TaxAmount currencyID="PEN">70.17</cbc:TaxAmount>
    <cac:TaxSubtotal>
      <cbc:TaxableAmount currencyID="PEN">389.83</cbc:TaxableAmount>
      <cbc:TaxAmount currencyID="PEN">70.17</cbc:TaxAmount>
      <cac:TaxCategory>
        <cbc:ID schemeID="UN/ECE 5305" schemeName="Tax Category Identifier" schemeAgencyName="United Nations Economic Commission for Europe">S</cbc:ID>
        <cac:TaxScheme>
          <cbc:ID schemeID="UN/ECE 5153" schemeAgencyID="6">1000</cbc:ID>
          <cbc:Name>IGV</cbc:Name>
          <cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
        </cac:TaxScheme>
      </cac:TaxCategory>
    </cac:TaxSubtotal>
  </cac:TaxTotal>
  <cac:LegalMonetaryTotal>
    <cbc:LineExtensionAmount currencyID="PEN">389.83</cbc:LineExtensionAmount>
    <cbc:TaxInclusiveAmount currencyID="PEN">460.00</cbc:TaxInclusiveAmount>
    <cbc:PayableAmount currencyID="PEN">460.00</cbc:PayableAmount>
  </cac:LegalMonetaryTotal>
  <cac:InvoiceLine>
    <cbc:ID>1</cbc:ID>
    <cbc:InvoicedQuantity unitCode="NIU" unitCodeListID="UN/ECE rec 20" unitCodeListAgencyName="United Nations Economic Commission for Europe">100.00</cbc:InvoicedQuantity>
    <cbc:LineExtensionAmount currencyID="PEN">389.83</cbc:LineExtensionAmount>
    <cac:PricingReference>
      <cac:AlternativeConditionPrice>
        <cbc:PriceAmount currencyID="PEN">4.60</cbc:PriceAmount>
        <cbc:PriceTypeCode listName="Tipo de Precio" listAgencyName="PE:SUNAT" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo16">01</cbc:PriceTypeCode>
      </cac:AlternativeConditionPrice>
    </cac:PricingReference>
    <cac:TaxTotal>
      <cbc:TaxAmount currencyID="PEN">70.17</cbc:TaxAmount>
      <cac:TaxSubtotal>
        <cbc:TaxableAmount currencyID="PEN">389.83</cbc:TaxableAmount>
        <cbc:TaxAmount currencyID="PEN">70.17</cbc:TaxAmount>
        <cac:TaxCategory>
          <cbc:ID schemeID="UN/ECE 5305" schemeName="Tax Category Identifier" schemeAgencyName="United Nations Economic Commission for Europe">S</cbc:ID>
          <cbc:Percent>18.00</cbc:Percent>
          <cbc:TaxExemptionReasonCode listAgencyName="PE:SUNAT" listName="Afectacion del IGV" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07">10</cbc:TaxExemptionReasonCode>
          <cac:TaxScheme>
            <cbc:ID schemeID="UN/ECE 5153" schemeName="Codigo de tributos" schemeAgencyName="PE:SUNAT">1000</cbc:ID>
            <cbc:Name>IGV</cbc:Name>
            <cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
          </cac:TaxScheme>
        </cac:TaxCategory>
      </cac:TaxSubtotal>
    </cac:TaxTotal>
    <cac:Item>
      <cbc:Description><![CDATA[PAPEL CONTOMETRO TERMICO 80X80X13]]></cbc:Description>
    </cac:Item>
    <cac:Price>
      <cbc:PriceAmount currencyID="PEN">3.90</cbc:PriceAmount>
    </cac:Price>
  </cac:InvoiceLine>
</Invoice>

Espero que este artículo haya sido de utilidad para ustedes. Te recordamos que nosotros brindamos la solución integral de facturación electrónicas. Cualquier duda o comentario pueden escribirme al email: jubillus@bimsic.pe

Saludos. John Ubillus.

Share this Post: Facebook Twitter Pinterest Google Plus StumbleUpon Reddit RSS Email

Related Posts

6 Comments

  1. Gracias por el aporte.

    Hola.
    Al enviarlo a https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl arroja el siguiente error:
    Debe consignar el tipo de operación – Detalle: xxx.xxx.xxx value=’ticket: 1572604309615 error: INFO: 3205 (nodo: «/» valor: «»)’

    ¿A qué puede ser debido? ¿Es posible que el servicio de pruebas no esté funcionando correctamente?
    Gracias por tu ayuda.

    • Buen día David con respecto a tu consulta te informamos que lamentablemente en el ambiente de pruebas de la SUNAT no contempla todas las validaciones, éstas se encuentra cargadas directamente en el ambiente de producción.
      Nosotros ya hemos realizado el envío en producción con este formato y funciona perfectamente. Claro que en este ejemplo no tiene contemplada la firma digital la cual deberás de adjuntarla en tu XML.
      Saludos cordiales.

  2. Pingback: Archivos de Validación XML - BIMSIC - Consultora de TI

  3. Gracias nuevamente. Puedo entender que no contemple todas las validaciones pero (suponiendo que el tipo de operación se refiere a la etiqueta cbc:ProfileID) no es de recibo que arroje un error inexistente ya esta etiqueta sí que existe:

    0101.

    Aunque, por otra parte, en los atributos de la etiqueta (siguiendo las indicaciones de la guía: guia+xml+factura+version 2-1+1+0 (2)_0.pdf) se señala el esquema del catálogo 17 (con códigos de 2 dígitos) cuando, en realidad, el formato que utiliza es el del catálogo 51 (4 dígitos).

    Sobre mi envío: Bueno, sí, no es exactamente el de tu ejemplo. Yo genero uno nuevo que firmo con un certificado de pruebas que he obtenido en llama.pe, pero me imagino que la firma no sea la razón del rechazo.

    Me inclino a pensar en un error de SUNAT porque, por otra parte, sí que acepta la versión 2.0 pero esta versión, por lo que he leído por ahí, ya no es operativa ¿verdad?

    Gracias por tu apoyo; eres muy amable.

Leave a Comment