Ir al contenido
ReferenciaErrores
Sello del hash e6sTM3UFTtTk+hRAdB78dxx0O8E=07-credit-note-void · DIGESTVALUE · e6sTM3UFTtTk+hRAdB78dxx0O8E= ·

Ejemplos / Nota de crédito (07) / Caso 12 de 21

Nota de crédito por anulación de la operación

Nota de crédito que anula la operación completa (motivo 01).

Firma este JSON con el certificado de prueba y tu DigestValue tiene que ser e6sTM3UFTtTk+hRAdB78dxx0O8E=. El sello es ese valor, dibujado.

Los tres archivos, en el repositorio: el JSON de entrada, el XML sin firmar y el XML firmado.

Entrada en JSON

Marcadas, las líneas que cambian respecto del caso más parecido, Nota de crédito por devolución parcial; lo igual queda plegado.

fixtures/07-credit-note-void.json
{  "kind": "note",  "ubl_version": "2.1",  "document_type": "07",  "series": "FC01",  "number": "1",
MostrarOcultar las líneas 7 a 44
  "issue_date": "2026-10-15T10:30:00-05:00",  "currency": "PEN",  "note": {    "reason_code": "01",    "reason": "ANULACION DE LA OPERACION",    "affected_document_type": "01",    "affected_document_number": "F001-1"  },  "issuer": {    "ruc": "20123456789",    "legal_name": "EMPRESA DEMO ORACULO S.A.C.",    "trade_name": "DEMO ORACULO",    "email": "facturacion@example.com",    "telephone": "014000000",    "address": {      "ubigeo": "150101",      "country_code": "PE",      "department": "LIMA",      "province": "LIMA",      "district": "LIMA",      "urbanization": "-",      "street": "AV. EJEMPLO 123",      "establishment_code": "0000"    }  },  "customer": {    "document_type": "6",    "document_number": "20000000001",    "legal_name": "CLIENTE DEMO S.A.",    "address": {      "ubigeo": "150122",      "country_code": "PE",      "department": "LIMA",      "province": "LIMA",      "district": "MIRAFLORES",      "street": "CALLE CLIENTE 456"    }  },
  "totals": {    "taxed": "125.42",    "igv": "22.58",    "total_taxes": "22.58",    "sale_value": "125.42",    "subtotal": "148.00",    "payable": "148.00"  },  "lines": [    {      "unit": "ZZ",      "quantity": "2",      "product_code": "SRV001",      "sunat_product_code": "10191509",      "description": "Servicio de consultoria",      "unit_value": "50.00",      "igv_base": "100.00",      "igv_rate": "18.00",      "igv": "18.00",      "affectation": "10",      "total_taxes": "18.00",      "unit_price": "59.00",      "line_value": "100.00"    },    {      "unit": "NIU",      "quantity": "1",      "product_code": "LIC001",      "sunat_product_code": "10191509",      "description": "Licencia mensual",      "unit_value": "25.42",      "igv_base": "25.42",      "igv_rate": "18.00",      "igv": "4.58",      "affectation": "10",      "total_taxes": "4.58",      "unit_price": "30.00",      "line_value": "25.42"    }  ],  "legends": [    {      "code": "1000",      "value": "SON CIENTO CUARENTA Y OCHO CON 00/100 SOLES"    }  ]}

XML sin firmar

Marcadas, las líneas que cambian respecto de Nota de crédito por devolución parcial.

tests/vectors/07-credit-note-void.unsigned.xml
<?xml version="1.0" encoding="utf-8"?><CreditNote xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">  <ext:UBLExtensions>    <ext:UBLExtension>      <ext:ExtensionContent/>    </ext:UBLExtension>  </ext:UBLExtensions>  <cbc:UBLVersionID>2.1</cbc:UBLVersionID>  <cbc:CustomizationID>2.0</cbc:CustomizationID>  <cbc:ID>FC01-1</cbc:ID>  <cbc:IssueDate>2026-10-15</cbc:IssueDate>  <cbc:IssueTime>10:30:00</cbc:IssueTime>  <cbc:Note languageLocaleID="1000"><![CDATA[SON CIENTO CUARENTA Y OCHO CON 00/100 SOLES]]></cbc:Note>
MostrarOcultar las líneas 14 a 110
  <cbc:DocumentCurrencyCode>PEN</cbc:DocumentCurrencyCode>  <cac:DiscrepancyResponse>    <cbc:ReferenceID>F001-1</cbc:ReferenceID>    <cbc:ResponseCode>01</cbc:ResponseCode>    <cbc:Description>ANULACION DE LA OPERACION</cbc:Description>  </cac:DiscrepancyResponse>  <cac:BillingReference>    <cac:InvoiceDocumentReference>      <cbc:ID>F001-1</cbc:ID>      <cbc:DocumentTypeCode>01</cbc:DocumentTypeCode>    </cac:InvoiceDocumentReference>  </cac:BillingReference>  <cac:Signature>    <cbc:ID>IDSignKG</cbc:ID>    <cac:SignatoryParty>      <cac:PartyIdentification>        <cbc:ID>20123456789</cbc:ID>      </cac:PartyIdentification>      <cac:PartyName>        <cbc:Name><![CDATA[EMPRESA DEMO ORACULO S.A.C.]]></cbc:Name>      </cac:PartyName>    </cac:SignatoryParty>    <cac:DigitalSignatureAttachment>      <cac:ExternalReference>        <cbc:URI>#signatureKG</cbc:URI>      </cac:ExternalReference>    </cac:DigitalSignatureAttachment>  </cac:Signature>  <cac:AccountingSupplierParty>    <cac:Party>      <cac:PartyIdentification>        <cbc:ID schemeID="6">20123456789</cbc:ID>      </cac:PartyIdentification>      <cac:PartyName>        <cbc:Name><![CDATA[DEMO ORACULO]]></cbc:Name>      </cac:PartyName>      <cac:PartyLegalEntity>        <cbc:RegistrationName><![CDATA[EMPRESA DEMO ORACULO S.A.C.]]></cbc:RegistrationName>        <cac:RegistrationAddress>          <cbc:ID>150101</cbc:ID>          <cbc:AddressTypeCode>0000</cbc:AddressTypeCode>          <cbc:CitySubdivisionName>-</cbc:CitySubdivisionName>          <cbc:CityName>LIMA</cbc:CityName>          <cbc:CountrySubentity>LIMA</cbc:CountrySubentity>          <cbc:District>LIMA</cbc:District>          <cac:AddressLine>            <cbc:Line><![CDATA[AV. EJEMPLO 123]]></cbc:Line>          </cac:AddressLine>          <cac:Country>            <cbc:IdentificationCode>PE</cbc:IdentificationCode>          </cac:Country>        </cac:RegistrationAddress>      </cac:PartyLegalEntity>      <cac:Contact>        <cbc:Telephone>014000000</cbc:Telephone>        <cbc:ElectronicMail>facturacion@example.com</cbc:ElectronicMail>      </cac:Contact>    </cac:Party>  </cac:AccountingSupplierParty>  <cac:AccountingCustomerParty>    <cac:Party>      <cac:PartyIdentification>        <cbc:ID schemeID="6">20000000001</cbc:ID>      </cac:PartyIdentification>      <cac:PartyLegalEntity>        <cbc:RegistrationName><![CDATA[CLIENTE DEMO S.A.]]></cbc:RegistrationName>        <cac:RegistrationAddress>          <cbc:ID>150122</cbc:ID>          <cac:AddressLine>            <cbc:Line><![CDATA[CALLE CLIENTE 456]]></cbc:Line>          </cac:AddressLine>          <cac:Country>            <cbc:IdentificationCode>PE</cbc:IdentificationCode>          </cac:Country>        </cac:RegistrationAddress>      </cac:PartyLegalEntity>    </cac:Party>  </cac:AccountingCustomerParty>  <cac:TaxTotal>    <cbc:TaxAmount currencyID="PEN">22.58</cbc:TaxAmount>    <cac:TaxSubtotal>      <cbc:TaxableAmount currencyID="PEN">125.42</cbc:TaxableAmount>      <cbc:TaxAmount currencyID="PEN">22.58</cbc:TaxAmount>      <cac:TaxCategory>        <cac:TaxScheme>          <cbc:ID>1000</cbc:ID>          <cbc:Name>IGV</cbc:Name>          <cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>        </cac:TaxScheme>      </cac:TaxCategory>    </cac:TaxSubtotal>  </cac:TaxTotal>  <cac:LegalMonetaryTotal>    <cbc:PayableAmount currencyID="PEN">148.00</cbc:PayableAmount>  </cac:LegalMonetaryTotal>  <cac:CreditNoteLine>    <cbc:ID>1</cbc:ID>
    <cbc:CreditedQuantity unitCode="ZZ">2</cbc:CreditedQuantity>    <cbc:LineExtensionAmount currencyID="PEN">100.00</cbc:LineExtensionAmount>
MostrarOcultar las líneas 113 a 147
    <cac:PricingReference>      <cac:AlternativeConditionPrice>        <cbc:PriceAmount currencyID="PEN">59</cbc:PriceAmount>        <cbc:PriceTypeCode>01</cbc:PriceTypeCode>      </cac:AlternativeConditionPrice>    </cac:PricingReference>    <cac:TaxTotal>      <cbc:TaxAmount currencyID="PEN">18.00</cbc:TaxAmount>      <cac:TaxSubtotal>        <cbc:TaxableAmount currencyID="PEN">100.00</cbc:TaxableAmount>        <cbc:TaxAmount currencyID="PEN">18.00</cbc:TaxAmount>        <cac:TaxCategory>          <cbc:Percent>18</cbc:Percent>          <cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>          <cac:TaxScheme>            <cbc:ID>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[Servicio de consultoria]]></cbc:Description>      <cac:SellersItemIdentification>        <cbc:ID>SRV001</cbc:ID>      </cac:SellersItemIdentification>      <cac:CommodityClassification>        <cbc:ItemClassificationCode>10191509</cbc:ItemClassificationCode>      </cac:CommodityClassification>    </cac:Item>    <cac:Price>      <cbc:PriceAmount currencyID="PEN">50</cbc:PriceAmount>    </cac:Price>  </cac:CreditNoteLine>
  <cac:CreditNoteLine>    <cbc:ID>2</cbc:ID>    <cbc:CreditedQuantity unitCode="NIU">1</cbc:CreditedQuantity>    <cbc:LineExtensionAmount currencyID="PEN">25.42</cbc:LineExtensionAmount>    <cac:PricingReference>      <cac:AlternativeConditionPrice>        <cbc:PriceAmount currencyID="PEN">30</cbc:PriceAmount>        <cbc:PriceTypeCode>01</cbc:PriceTypeCode>      </cac:AlternativeConditionPrice>    </cac:PricingReference>    <cac:TaxTotal>      <cbc:TaxAmount currencyID="PEN">4.58</cbc:TaxAmount>      <cac:TaxSubtotal>        <cbc:TaxableAmount currencyID="PEN">25.42</cbc:TaxableAmount>        <cbc:TaxAmount currencyID="PEN">4.58</cbc:TaxAmount>        <cac:TaxCategory>          <cbc:Percent>18</cbc:Percent>          <cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>          <cac:TaxScheme>            <cbc:ID>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[Licencia mensual]]></cbc:Description>      <cac:SellersItemIdentification>        <cbc:ID>LIC001</cbc:ID>      </cac:SellersItemIdentification>      <cac:CommodityClassification>        <cbc:ItemClassificationCode>10191509</cbc:ItemClassificationCode>      </cac:CommodityClassification>    </cac:Item>    <cac:Price>      <cbc:PriceAmount currencyID="PEN">25.42</cbc:PriceAmount>    </cac:Price>  </cac:CreditNoteLine></CreditNote>

Formateado para leerlo. «Copiar» copia el archivo tal como está en el repositorio, en una línea.

Firma

Firmado con el certificado de prueba del SDK, el que baja la guía de inicio.

Sello del hash e6sTM3UFTtTk+hRAdB78dxx0O8E=

e6sTM3UFTtTk+hRAdB78dxx0O8E=

Si tu DigestValue es este, tu XML es el mismo que el del SDK. Con el certificado de prueba el SignatureValue también coincide; con el tuyo cambia, porque depende de tu clave.

DigestValue
e6sTM3UFTtTk+hRAdB78dxx0O8E=
SignatureValue
A910p9NX32FNJsia1hMS9HjSo2cc1AT7S6gs4ZTbtT4zcrCYac7pZZ55MegsOdplBjKhA7l52syn6cL7PDC0Il+O7y4vEVeIEH6b0U6pkTNuoV9gOu+SheGvH8+UX9cM/H/WqhMhbJ4KPtyyby4+gmUGc++zZq9LmI4EfsCjEvdfdnvYQ4C4KDaiuErmNR1mT4qF3eLah6jePP40slXib3auWkjYNwSv8r/xgzo4lHjZrW6hqIlCMz0KgzileFKqQi9EVPenlMsLknJdbX62Ka58V5kr8a+5bwAbzW4mqAzsBJWpWKwNTL3JAgUvsfAwGcnp7Ga2mMspD4nIrkRtGw==

XML firmado

tests/vectors/07-credit-note-void.signed.xml
<?xml version="1.0" encoding="utf-8"?><CreditNote xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">  <ext:UBLExtensions>    <ext:UBLExtension>      <ext:ExtensionContent>        <ds:Signature Id="signatureKG">          <ds:SignedInfo>            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>            <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>            <ds:Reference URI="">              <ds:Transforms>                <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>              </ds:Transforms>              <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>              <ds:DigestValue>e6sTM3UFTtTk+hRAdB78dxx0O8E=</ds:DigestValue>            </ds:Reference>          </ds:SignedInfo>          <ds:SignatureValue>A910p9NX32FNJsia1hMS9HjSo2cc1AT7S6gs4ZTbtT4zcrCYac7pZZ55MegsOdplBjKhA7l52syn6cL7PDC0Il+O7y4vEVeIEH6b0U6pkTNuoV9gOu+SheGvH8+UX9cM/H/WqhMhbJ4KPtyyby4+gmUGc++zZq9LmI4EfsCjEvdfdnvYQ4C4KDaiuErmNR1mT4qF3eLah6jePP40slXib3auWkjYNwSv8r/xgzo4lHjZrW6hqIlCMz0KgzileFKqQi9EVPenlMsLknJdbX62Ka58V5kr8a+5bwAbzW4mqAzsBJWpWKwNTL3JAgUvsfAwGcnp7Ga2mMspD4nIrkRtGw==</ds:SignatureValue>          <ds:KeyInfo>            <ds:X509Data>              <ds:X509Certificate>MIID8zCCAtugAwIBAgIUY968iRS4gHDjt9RwTaDaujmFLO0wDQYJKoZIhvcNAQELBQAwgYgxCzAJBgNVBAYTAlBFMS8wLQYDVQQKDCZURVNUIE9OTFkgLSBOT1QgVkFMSUQgRk9SIEFOWSBUQVhQQVlFUjESMBAGA1UECwwJVEVTVCBPTkxZMRQwEgYDVQQFEwsyMDAwMDAwMDAwMTEeMBwGA1UEAwwVVEVTVCBPTkxZIDIwMDAwMDAwMDAxMB4XDTI2MTAxNTIxMjc0NVoXDTM2MTAxMjIxMjc0NVowgYgxCzAJBgNVBAYTAlBFMS8wLQYDVQQKDCZURVNUIE9OTFkgLSBOT1QgVkFMSUQgRk9SIEFOWSBUQVhQQVlFUjESMBAGA1UECwwJVEVTVCBPTkxZMRQwEgYDVQQFEwsyMDAwMDAwMDAwMTEeMBwGA1UEAwwVVEVTVCBPTkxZIDIwMDAwMDAwMDAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6GZTtpFyih4C6ETakE6Q4+SFBFWJ/TQi2pbxJRD7GkQ1tKeB+ENcBk8EjnOocxdYWvSBpOd9UYkpc2C+jlbVWd04ey8psznwCHzJJ1+qgQqVI8PpH5A4eEw5LGXupHmnJSYpGXFGIJ6+tlJRqvZbq7RTh7Rpxs4DkCjUhUke/BKIZahYDzSGFLlsWx01Dq8Xeb6xF2sLlZXy/b0MvRZAe7I/xplIftS/rrDQ/rE5DfS0Dibayc/uNIRw1+NiKpT0wwY/VCzRQrM27dG7sTyhNAy6C3vtRmO5Bl9+0wrXldZcR4VSm1yrg65KRWv6DNcG2MkxRYBphaM+sJfkNECs6wIDAQABo1MwUTAdBgNVHQ4EFgQUE359gu7BEXWLRhx+VNBeec2Pp/kwHwYDVR0jBBgwFoAUE359gu7BEXWLRhx+VNBeec2Pp/kwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAzjWgukifoL9gZckM2jWW7a+N6+5W/0EkGJVFV9RbCceNpDpdMyVD4QyVm1nOJ/bQzOLdDnjyD3J34/1pEwo/hS/HehPy50twvf/uKEwPU4TNQTyjChnM3k+IX7cOusuPIBsC6trufeHOSky5lWiKWusMHo8VsPvVinE0n/RqTo47enHPFa6huF3egiQEJ6H+lxerXvWT8IkaGFA2YKjAGGsenlCSw9rRGX4tzQtUkJx0oFaEZGNpq+OYr334J3cZp9LskUFnrvRoAz3Fk8HdbVlfQTovFunFY9VzxbKjBfyWa6hymTxcvBR9x4ZfUKM9P3REeBKaTWdqe2oz4d6LLA==</ds:X509Certificate>            </ds:X509Data>          </ds:KeyInfo>        </ds:Signature>      </ext:ExtensionContent>    </ext:UBLExtension>  </ext:UBLExtensions>  <cbc:UBLVersionID>2.1</cbc:UBLVersionID>  <cbc:CustomizationID>2.0</cbc:CustomizationID>  <cbc:ID>FC01-1</cbc:ID>  <cbc:IssueDate>2026-10-15</cbc:IssueDate>  <cbc:IssueTime>10:30:00</cbc:IssueTime>  <cbc:Note languageLocaleID="1000"><![CDATA[SON CIENTO CUARENTA Y OCHO CON 00/100 SOLES]]></cbc:Note>  <cbc:DocumentCurrencyCode>PEN</cbc:DocumentCurrencyCode>  <cac:DiscrepancyResponse>    <cbc:ReferenceID>F001-1</cbc:ReferenceID>    <cbc:ResponseCode>01</cbc:ResponseCode>    <cbc:Description>ANULACION DE LA OPERACION</cbc:Description>  </cac:DiscrepancyResponse>  <cac:BillingReference>
Mostrar las 167 líneas restantes (207 en total)
    <cac:InvoiceDocumentReference>      <cbc:ID>F001-1</cbc:ID>      <cbc:DocumentTypeCode>01</cbc:DocumentTypeCode>    </cac:InvoiceDocumentReference>  </cac:BillingReference>  <cac:Signature>    <cbc:ID>IDSignKG</cbc:ID>    <cac:SignatoryParty>      <cac:PartyIdentification>        <cbc:ID>20123456789</cbc:ID>      </cac:PartyIdentification>      <cac:PartyName>        <cbc:Name><![CDATA[EMPRESA DEMO ORACULO S.A.C.]]></cbc:Name>      </cac:PartyName>    </cac:SignatoryParty>    <cac:DigitalSignatureAttachment>      <cac:ExternalReference>        <cbc:URI>#signatureKG</cbc:URI>      </cac:ExternalReference>    </cac:DigitalSignatureAttachment>  </cac:Signature>  <cac:AccountingSupplierParty>    <cac:Party>      <cac:PartyIdentification>        <cbc:ID schemeID="6">20123456789</cbc:ID>      </cac:PartyIdentification>      <cac:PartyName>        <cbc:Name><![CDATA[DEMO ORACULO]]></cbc:Name>      </cac:PartyName>      <cac:PartyLegalEntity>        <cbc:RegistrationName><![CDATA[EMPRESA DEMO ORACULO S.A.C.]]></cbc:RegistrationName>        <cac:RegistrationAddress>          <cbc:ID>150101</cbc:ID>          <cbc:AddressTypeCode>0000</cbc:AddressTypeCode>          <cbc:CitySubdivisionName>-</cbc:CitySubdivisionName>          <cbc:CityName>LIMA</cbc:CityName>          <cbc:CountrySubentity>LIMA</cbc:CountrySubentity>          <cbc:District>LIMA</cbc:District>          <cac:AddressLine>            <cbc:Line><![CDATA[AV. EJEMPLO 123]]></cbc:Line>          </cac:AddressLine>          <cac:Country>            <cbc:IdentificationCode>PE</cbc:IdentificationCode>          </cac:Country>        </cac:RegistrationAddress>      </cac:PartyLegalEntity>      <cac:Contact>        <cbc:Telephone>014000000</cbc:Telephone>        <cbc:ElectronicMail>facturacion@example.com</cbc:ElectronicMail>      </cac:Contact>    </cac:Party>  </cac:AccountingSupplierParty>  <cac:AccountingCustomerParty>    <cac:Party>      <cac:PartyIdentification>        <cbc:ID schemeID="6">20000000001</cbc:ID>      </cac:PartyIdentification>      <cac:PartyLegalEntity>        <cbc:RegistrationName><![CDATA[CLIENTE DEMO S.A.]]></cbc:RegistrationName>        <cac:RegistrationAddress>          <cbc:ID>150122</cbc:ID>          <cac:AddressLine>            <cbc:Line><![CDATA[CALLE CLIENTE 456]]></cbc:Line>          </cac:AddressLine>          <cac:Country>            <cbc:IdentificationCode>PE</cbc:IdentificationCode>          </cac:Country>        </cac:RegistrationAddress>      </cac:PartyLegalEntity>    </cac:Party>  </cac:AccountingCustomerParty>  <cac:TaxTotal>    <cbc:TaxAmount currencyID="PEN">22.58</cbc:TaxAmount>    <cac:TaxSubtotal>      <cbc:TaxableAmount currencyID="PEN">125.42</cbc:TaxableAmount>      <cbc:TaxAmount currencyID="PEN">22.58</cbc:TaxAmount>      <cac:TaxCategory>        <cac:TaxScheme>          <cbc:ID>1000</cbc:ID>          <cbc:Name>IGV</cbc:Name>          <cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>        </cac:TaxScheme>      </cac:TaxCategory>    </cac:TaxSubtotal>  </cac:TaxTotal>  <cac:LegalMonetaryTotal>    <cbc:PayableAmount currencyID="PEN">148.00</cbc:PayableAmount>  </cac:LegalMonetaryTotal>  <cac:CreditNoteLine>    <cbc:ID>1</cbc:ID>    <cbc:CreditedQuantity unitCode="ZZ">2</cbc:CreditedQuantity>    <cbc:LineExtensionAmount currencyID="PEN">100.00</cbc:LineExtensionAmount>    <cac:PricingReference>      <cac:AlternativeConditionPrice>        <cbc:PriceAmount currencyID="PEN">59</cbc:PriceAmount>        <cbc:PriceTypeCode>01</cbc:PriceTypeCode>      </cac:AlternativeConditionPrice>    </cac:PricingReference>    <cac:TaxTotal>      <cbc:TaxAmount currencyID="PEN">18.00</cbc:TaxAmount>      <cac:TaxSubtotal>        <cbc:TaxableAmount currencyID="PEN">100.00</cbc:TaxableAmount>        <cbc:TaxAmount currencyID="PEN">18.00</cbc:TaxAmount>        <cac:TaxCategory>          <cbc:Percent>18</cbc:Percent>          <cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>          <cac:TaxScheme>            <cbc:ID>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[Servicio de consultoria]]></cbc:Description>      <cac:SellersItemIdentification>        <cbc:ID>SRV001</cbc:ID>      </cac:SellersItemIdentification>      <cac:CommodityClassification>        <cbc:ItemClassificationCode>10191509</cbc:ItemClassificationCode>      </cac:CommodityClassification>    </cac:Item>    <cac:Price>      <cbc:PriceAmount currencyID="PEN">50</cbc:PriceAmount>    </cac:Price>  </cac:CreditNoteLine>  <cac:CreditNoteLine>    <cbc:ID>2</cbc:ID>    <cbc:CreditedQuantity unitCode="NIU">1</cbc:CreditedQuantity>    <cbc:LineExtensionAmount currencyID="PEN">25.42</cbc:LineExtensionAmount>    <cac:PricingReference>      <cac:AlternativeConditionPrice>        <cbc:PriceAmount currencyID="PEN">30</cbc:PriceAmount>        <cbc:PriceTypeCode>01</cbc:PriceTypeCode>      </cac:AlternativeConditionPrice>    </cac:PricingReference>    <cac:TaxTotal>      <cbc:TaxAmount currencyID="PEN">4.58</cbc:TaxAmount>      <cac:TaxSubtotal>        <cbc:TaxableAmount currencyID="PEN">25.42</cbc:TaxableAmount>        <cbc:TaxAmount currencyID="PEN">4.58</cbc:TaxAmount>        <cac:TaxCategory>          <cbc:Percent>18</cbc:Percent>          <cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>          <cac:TaxScheme>            <cbc:ID>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[Licencia mensual]]></cbc:Description>      <cac:SellersItemIdentification>        <cbc:ID>LIC001</cbc:ID>      </cac:SellersItemIdentification>      <cac:CommodityClassification>        <cbc:ItemClassificationCode>10191509</cbc:ItemClassificationCode>      </cac:CommodityClassification>    </cac:Item>    <cac:Price>      <cbc:PriceAmount currencyID="PEN">25.42</cbc:PriceAmount>    </cac:Price>  </cac:CreditNoteLine></CreditNote>

Formateado para leerlo. «Copiar» copia el archivo tal como está en el repositorio.

Reproducirlo

Con el SDK instalado como dice la guía de inicio, baja el caso y el certificado de prueba:

Terminal
curl -fsSL --remote-name-all \  https://fe.kembec.com/sdk/v1.0.0-rc.7/07-credit-note-void.json \  https://fe.kembec.com/sdk/v1.0.0-rc.7/test-cert.pem \  https://fe.kembec.com/sdk/v1.0.0-rc.7/test-key.pem

Fírmalo como en la guía: tu DigestValue tiene que ser el de arriba.

PHP

En firmar.php, la línea del JSON queda así:

firmar.php
$factura = file_get_contents(__DIR__ . '/07-credit-note-void.json');
Terminal
php firmar.php

JavaScript

En firmar.mjs, la línea del JSON queda así:

firmar.mjs
const built = JSON.parse(sdk.build(leer('07-credit-note-void.json')));
Terminal
node firmar.mjs

Python

En firmar.py, la línea del JSON queda así:

firmar.py
built = sunat_sdk.build(leer('07-credit-note-void.json'))
Terminal
python firmar.py

Swift

En Sources/firmar/firmar.swift, la línea del JSON queda así:

Sources/firmar/firmar.swift
let caso = "07-credit-note-void.json"
Terminal
swift run firmar

C#

En firmar.cs, la línea del JSON queda así:

firmar.cs
var factura = File.ReadAllText("07-credit-note-void.json");
Terminal
dotnet run

CLI

Terminal
sunat-sdk build < 07-credit-note-void.json \  | sunat-sdk sign --cert test-cert.pem --key test-key.pem > firmada.jsongrep -o '"digest_value":"[^"]*"' firmada.jsongrep -q '"digest_value":"e6sTM3UFTtTk+hRAdB78dxx0O8E="' firmada.json && echo "digest ok"