nodefact
Version:
Biblioteca para facturación electrónica en Perú con Node.js. Compatible con UBL 2.1 y servicios web de SUNAT.
143 lines (133 loc) • 6.46 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.perception = void 0;
/**
* Plantilla para Comprobante de Percepción (Perception Document)
*/
const namespaces_1 = require("./namespaces");
exports.perception = `
<Perception xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:Perception-1"
xmlns:cac="${namespaces_1.namespaces.cac}"
xmlns:cbc="${namespaces_1.namespaces.cbc}"
xmlns:ccts="${namespaces_1.namespaces.ccts}"
xmlns:ds="${namespaces_1.namespaces.ds}"
xmlns:ext="${namespaces_1.namespaces.ext}"
xmlns:qdt="${namespaces_1.namespaces.qdt}"
xmlns:sac="${namespaces_1.namespaces.sac}"
xmlns:udt="${namespaces_1.namespaces.udt}"
xmlns:xsi="${namespaces_1.namespaces.xsi}">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent/>
</ext:UBLExtension>
</ext:UBLExtensions>
<!-- Versión del UBL -->
<cbc:UBLVersionID>2.0</cbc:UBLVersionID>
<!-- Versión de la estructura del documento -->
<cbc:CustomizationID>1.0</cbc:CustomizationID>
<!-- Número de comprobante: Serie-Correlativo -->
<cbc:ID>{{serie}}-{{correlativo}}</cbc:ID>
<!-- Fecha de emisión -->
<cbc:IssueDate>{{fechaEmision}}</cbc:IssueDate>
<!-- Hora de emisión -->
<cbc:IssueTime>{{horaEmision}}</cbc:IssueTime>
<!-- Firma Digital -->
<cac:Signature>
<cbc:ID>{{signatureID}}</cbc:ID>
<cac:SignatoryParty>
<cac:PartyIdentification>
<cbc:ID>{{emisor.ruc}}</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name>{{emisor.razonSocial}}</cbc:Name>
</cac:PartyName>
</cac:SignatoryParty>
<cac:DigitalSignatureAttachment>
<cac:ExternalReference>
<cbc:URI>{{signatureURI}}</cbc:URI>
</cac:ExternalReference>
</cac:DigitalSignatureAttachment>
</cac:Signature>
<!-- Datos del Agente de Percepción -->
<cac:AgentParty>
<cac:PartyIdentification>
<cbc:ID schemeID="6">{{emisor.ruc}}</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name>{{emisor.nombreComercial}}</cbc:Name>
</cac:PartyName>
<cac:PartyLegalEntity>
<cbc:RegistrationName>{{emisor.razonSocial}}</cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:ID>{{emisor.direccion.ubigeo}}</cbc:ID>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
<cbc:CityName>{{emisor.direccion.provincia}}</cbc:CityName>
<cbc:CountrySubentity>{{emisor.direccion.departamento}}</cbc:CountrySubentity>
<cbc:District>{{emisor.direccion.distrito}}</cbc:District>
<cac:AddressLine>
<cbc:Line>{{emisor.direccion.direccion}}</cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>PE</cbc:IdentificationCode>
</cac:Country>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:AgentParty>
<!-- Datos del Cliente (Sujeto de Percepción) -->
<cac:ReceiverParty>
<cac:PartyIdentification>
<cbc:ID schemeID="{{receptor.tipoDocumento}}">{{receptor.numeroDocumento}}</cbc:ID>
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName>{{receptor.razonSocial}}</cbc:RegistrationName>
{{#if receptor.direccion}}
<cac:RegistrationAddress>
{{#if receptor.direccion.ubigeo}}
<cbc:ID>{{receptor.direccion.ubigeo}}</cbc:ID>
{{/if}}
<cac:AddressLine>
<cbc:Line>{{receptor.direccion.direccion}}</cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>PE</cbc:IdentificationCode>
</cac:Country>
</cac:RegistrationAddress>
{{/if}}
</cac:PartyLegalEntity>
</cac:ReceiverParty>
<!-- Información de la Percepción -->
<sac:SUNATPerceptionSystemCode>{{sistemaPercepcion}}</sac:SUNATPerceptionSystemCode>
<sac:SUNATPerceptionPercent>{{porcentajePercepcion}}</sac:SUNATPerceptionPercent>
<!-- Información de totales -->
<cbc:TotalInvoiceAmount currencyID="PEN">{{importeTotalPercibido}}</cbc:TotalInvoiceAmount>
<sac:SUNATTotalCashed currencyID="PEN">{{importeTotalCobrado}}</sac:SUNATTotalCashed>
<!-- Detalle de documentos percibidos -->
{{#each documentos}}
<sac:SUNATPerceptionDocumentReference>
<cbc:ID schemeID="{{tipoDocumento}}">{{numeroDocumento}}</cbc:ID>
<cbc:IssueDate>{{fechaEmision}}</cbc:IssueDate>
<cbc:TotalInvoiceAmount currencyID="{{moneda}}">{{importeTotal}}</cbc:TotalInvoiceAmount>
<!-- Información de pago -->
<cac:Payment>
<cbc:ID>{{numeroPago}}</cbc:ID>
<cbc:PaidAmount currencyID="{{moneda}}">{{importePagado}}</cbc:PaidAmount>
<cbc:PaidDate>{{fechaPago}}</cbc:PaidDate>
</cac:Payment>
<!-- Información de la percepción -->
<sac:SUNATPerceptionInformation>
<sac:SUNATPerceptionAmount currencyID="{{moneda}}">{{importePercibido}}</sac:SUNATPerceptionAmount>
<sac:SUNATPerceptionDate>{{fechaPercepcion}}</sac:SUNATPerceptionDate>
<sac:SUNATNetTotalCashed currencyID="{{moneda}}">{{importeNetoCobrado}}</sac:SUNATNetTotalCashed>
<!-- Información de tipo de cambio -->
{{#if tipoCambio}}
<cac:ExchangeRate>
<cbc:SourceCurrencyCode>{{tipoCambio.monedaOrigen}}</cbc:SourceCurrencyCode>
<cbc:TargetCurrencyCode>{{tipoCambio.monedaDestino}}</cbc:TargetCurrencyCode>
<cbc:CalculationRate>{{tipoCambio.factor}}</cbc:CalculationRate>
<cbc:Date>{{tipoCambio.fecha}}</cbc:Date>
</cac:ExchangeRate>
{{/if}}
</sac:SUNATPerceptionInformation>
</sac:SUNATPerceptionDocumentReference>
{{/each}}
</Perception>`;