├── src ├── interfaces.ts ├── services │ ├── index.ts │ └── boleta.service.ts ├── index.ts └── templates │ ├── comunicacion_baja.xml │ ├── guia_remitente.xml │ ├── factura_gravada.xml │ ├── factura_exonerada.xml │ ├── factura_gratuita.xml │ ├── factura_percepcion.xml │ ├── boleta2.1.xml │ ├── factura_detraccion.xml │ ├── factura_deduccion_anticipo.xml │ ├── nota_debito.xml │ ├── nota_credito.xml │ ├── resumen_diario.xml │ └── factura_icbper.xml ├── .github ├── FUNDING.yml └── dependabot.yml ├── .gitignore ├── LICENSE ├── package.json ├── README.md └── tsconfig.json /src/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface Boleta {} 2 | -------------------------------------------------------------------------------- /src/services/index.ts: -------------------------------------------------------------------------------- 1 | export { default as BoletaService } from "./boleta.service"; 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [CodingMarin] 4 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { BoletaService } from "./services"; 2 | 3 | export function generateInvoice(ublVersion: string, document: JSON): String { 4 | const render = BoletaService.render(ublVersion, document); 5 | 6 | return render; 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | dist 3 | package-lock.json 4 | # dependencies 5 | node_modules 6 | 7 | # local env files 8 | .env.local 9 | .env.development.local 10 | .env.test.local 11 | .env.production.local -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /src/services/boleta.service.ts: -------------------------------------------------------------------------------- 1 | import * as Mustache from "mustache"; 2 | import * as fs from "fs"; 3 | import * as path from "path"; 4 | 5 | export default class BoletaService { 6 | /** 7 | * Generates invoice 8 | * @param data 9 | * @returns invoice 10 | */ 11 | static render = (ublVersion: String, data: JSON) => { 12 | // Construct the absolute path to the template file 13 | const templatePath = path.join( 14 | __dirname, 15 | "..", 16 | "templates", 17 | `boleta${ublVersion}.xml` 18 | ); 19 | 20 | // Read the template file content 21 | const template = fs.readFileSync(templatePath, "utf8"); 22 | 23 | // Render the template with the provided data 24 | const rendered = Mustache.render(template, data); 25 | 26 | return rendered; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Alexander Marin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "xml-gen-fee", 3 | "version": "0.0.1", 4 | "description": "A library for generating XML invoices using Mustache templates.", 5 | "main": "./dist/index.js", 6 | "exports": { 7 | "types": "./dist/types.d.ts", 8 | "require": "./dist/index.js" 9 | }, 10 | "directories": { 11 | "test": "./src/templates" 12 | }, 13 | "scripts": { 14 | "build": "npx tsc && copyfiles -u 1 src/templates/**/* dist", 15 | "dev": "ts-node ./src/index.ts", 16 | "start": "node ./dist/index.js", 17 | "test": "echo \"Error: no test specified\" && exit 1" 18 | }, 19 | "keywords": [ 20 | "XML Gen", 21 | "Boleta XML", 22 | "Generar Boleta XML" 23 | ], 24 | "author": "Alexander Marin ", 25 | "license": "MIT", 26 | "publishConfig": { 27 | "registry": "https://registry.npmjs.org/" 28 | }, 29 | "repository": { 30 | "type": "git", 31 | "url": "git+https://github.com/CodingMarin/xml-gen-fee.git" 32 | }, 33 | "bugs": { 34 | "url": "https://github.com/CodingMarin/xml-gen-fee/issues" 35 | }, 36 | "dependencies": { 37 | "mustache": "^4.2.0" 38 | }, 39 | "devDependencies": { 40 | "@types/mustache": "^4.2.5", 41 | "@types/node": "^20.14.2", 42 | "copyfiles": "^2.4.1", 43 | "ts-node": "^10.9.2", 44 | "typescript": "^5.4.5" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xml-gen-fee 2 | 3 | Paquete de código abierto para facilitar y mejorar la generación y creación de documentos xml en base las normas de SUNAT. Para generar Boletas de venta, Facturas, Notas de debito | Credito etc. 4 | 5 | ## Instalar: 6 | 7 | ```bash 8 | npm install @marin/xml-gen-fee 9 | ``` 10 | 11 | ## Ejemplo 12 | 13 | ```js 14 | const xmlGenFee = require("@marin/xml-gen-fee"); 15 | 16 | const data = { 17 | ublVersion: "2.1" // Version de ubl 18 | serie: "B001", // Serie 19 | correlativo: "01" // Correlation 20 | tipoMoneda: "PEN", // Moneda de la factura 21 | // Información de la empresa emisora 22 | company: { 23 | ruc: "20123456789", // RUC de la empresa 24 | nombreComercial: "Mi Empresa S.A.C.", // Nombre comercial de la empresa 25 | razonSocial: "Mi Empresa", // Razón social de la empresa 26 | address: { 27 | // Dirección de la empresa 28 | ubigueo: "150101", // Código de ubicación 29 | codLocal: "0000", // Código de local 30 | urbanizacion: "-", // Urbanización 31 | provincia: "LIMA", // Provincia 32 | departamento: "LIMA", // Departamento 33 | distrito: "LIMA", // Distrito 34 | direccion: "AV EJEMPLO 123", // Dirección completa 35 | codPais: "PE", // Código de país 36 | }, 37 | telefono: "03-392910", // Teléfono de contacto 38 | correo: "admin@miempresa.com", // Correo electrónico de contacto 39 | }, 40 | // Información del cliente 41 | client: { 42 | tipoDoc: "1", // Tipo de documento (1 = DNI) 43 | numDoc: "20203030", // Número de documento 44 | rznSocial: "PERSON 1", // Razón social o nombre del cliente 45 | ubigeo: "150102", // Código de ubicación del cliente 46 | direccion: "AV LIBERTAD 456", // Dirección del cliente 47 | codPais: "PE", // Código de país del cliente 48 | }, 49 | // Detalles de la venta 50 | saleDetails: [ 51 | { 52 | index: 1, // Índice del detalle 53 | unidad: "NIU", // Unidad de medida (NIU = unidad) 54 | cantidad: 10, // Cantidad de unidades vendidas 55 | mtoValorVenta: 100.0, // Valor de venta total 56 | mtoPrecioUnitario: 10.0, // Precio unitario 57 | mtoImpuesto: 18.0, // Monto del impuesto (IGV) 58 | mtoBaseIgv: 100.0, // Base imponible del IGV 59 | porcentajeIgv: 18, // Porcentaje del IGV 60 | descProducto: "Producto 1", // Descripción del producto 61 | codProducto: "C001", // Código del producto 62 | mtoValorUnitario: 10.0, // Valor unitario 63 | }, 64 | ], 65 | }; 66 | 67 | const result = xmlGenFee.generateInvoice(data); 68 | 69 | console.log(result); 70 | ``` 71 | -------------------------------------------------------------------------------- /src/templates/comunicacion_baja.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 2.0 14 | 1.0 15 | RA-20201129-1 16 | 2020-11-26 17 | 2020-11-29 18 | 19 | 20123456789 20 | 21 | 22 | 20123456789 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | #SUNAT-SIGN 31 | 32 | 33 | 34 | 35 | 20123456789 36 | 6 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 1 45 | 01 46 | F001 47 | 02132132 48 | 49 | 50 | 51 | 2 52 | 07 53 | FC01 54 | 222 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/templates/guia_remitente.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 2.1 14 | 2.0 15 | T001-121 16 | 2022-12-30 17 | 12:16:46 18 | 09 20 | 21 | 22 | 23 | 24 | F001-222 25 | 01 28 | Factura 29 | 30 | 31 | 20123456789 33 | 34 | 35 | 36 | 37 | 20123456789 38 | 39 | 40 | 20123456789 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | #SUNAT-SIGN 51 | 52 | 53 | 54 | 55 | 56 | 57 | 20123456789 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 20000000002 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | SUNAT_Envio 82 | 01 84 | 12.500 85 | 86 | 01 88 | 89 | 2022-12-30 90 | 91 | 92 | 93 | 20000000002 94 | 95 | 96 | 97 | 98 | 99 | 0001 100 | 101 | 102 | 103 | 104 | 105 | 150101 106 | 107 | AV LIMA 108 | 109 | 110 | 111 | 112 | 150203 113 | 114 | AV ITALIA 115 | 116 | 117 | 118 | 119 | 120 | 121 | 1 122 | 2 123 | 124 | 1 125 | 126 | 127 | 128 | 129 | 130 | 131 | PROD1 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /src/templates/factura_gravada.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | F001-123 15 | 2018-10-14 16 | 01:02:03 17 | 2018-10-15 18 | 01 19 | 20 | PEN 21 | 22 | 20000000001 23 | SUNAT 24 | 25 | 26 | 20000000001 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | #SIGN-GREEN 35 | 36 | 37 | 38 | 39 | 40 | 41 | 20000000001 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 150101 50 | 0000 51 | NONE 52 | LIMA 53 | LIMA 54 | LIMA 55 | 56 | 57 | 58 | 59 | PE 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 20000000001 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | PE 78 | 79 | 80 | 81 | 82 | 83 | 84 | FormaPago 85 | Contado 86 | 87 | 88 | 36.00 89 | 90 | 200.00 91 | 36.00 92 | 93 | 94 | 1000 95 | IGV 96 | VAT 97 | 98 | 99 | 100 | 101 | 102 | 200.00 103 | 236.00 104 | 236.00 105 | 106 | 107 | 1 108 | 2 109 | 200.00 110 | 111 | 112 | 118.000000 113 | 01 114 | 115 | 116 | 117 | 36.00 118 | 119 | 200.00 120 | 36.00 121 | 122 | 18 123 | 10 124 | 125 | 1000 126 | IGV 127 | VAT 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | P001 136 | 137 | 138 | 139 | 100.000000 140 | 141 | 142 | -------------------------------------------------------------------------------- /src/templates/factura_exonerada.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | F001-124 15 | 2021-02-06 16 | 17:48:01 17 | 01 18 | 19 | PEN 20 | 21 | 20123456789 22 | 23 | 24 | 20123456789 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | #SUNAT-SIGN 33 | 34 | 35 | 36 | 37 | 38 | 39 | 20123456789 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 150101 48 | 0000 49 | CASUARINAS 50 | LIMA 51 | LIMA 52 | LIMA 53 | 54 | 55 | 56 | 57 | PE 58 | 59 | 60 | 61 | 62 | 01-234455 63 | admin@sunat.com 64 | 65 | 66 | 67 | 68 | 69 | 70 | 20000000001 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | PE 80 | 81 | 82 | 83 | 84 | 01-445566 85 | client@corp.com 86 | 87 | 88 | 89 | 90 | FormaPago 91 | Contado 92 | 93 | 94 | 0.00 95 | 96 | 100.00 97 | 0 98 | 99 | 100 | 9997 101 | EXO 102 | VAT 103 | 104 | 105 | 106 | 107 | 108 | 100.00 109 | 100.00 110 | 100.00 111 | 112 | 113 | 1 114 | 2 115 | 100.00 116 | 117 | 118 | 50 119 | 01 120 | 121 | 122 | 123 | 0.00 124 | 125 | 100.00 126 | 0.00 127 | 128 | 0 129 | 20 130 | 131 | 9997 132 | EXO 133 | VAT 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | P001 142 | 143 | 144 | 145 | 50 146 | 147 | 148 | -------------------------------------------------------------------------------- /src/templates/factura_gratuita.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | F001-131 15 | 2021-02-06 16 | 17:48:57 17 | 01 18 | 19 | PEN 20 | 21 | 20123456789 22 | 23 | 24 | 20123456789 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | #SUNAT-SIGN 33 | 34 | 35 | 36 | 37 | 38 | 39 | 20123456789 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 150101 48 | 0000 49 | CASUARINAS 50 | LIMA 51 | LIMA 52 | LIMA 53 | 54 | 55 | 56 | 57 | PE 58 | 59 | 60 | 61 | 62 | 01-234455 63 | admin@sunat.com 64 | 65 | 66 | 67 | 68 | 69 | 70 | 20000000001 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | PE 80 | 81 | 82 | 83 | 84 | 01-445566 85 | client@corp.com 86 | 87 | 88 | 89 | 90 | FormaPago 91 | Contado 92 | 93 | 94 | 0.00 95 | 96 | 200.00 97 | 36.00 98 | 99 | 100 | 9996 101 | GRA 102 | FRE 103 | 104 | 105 | 106 | 107 | 108 | 0.00 109 | 0.00 110 | 0.00 111 | 112 | 113 | 1 114 | 2 115 | 200.00 116 | 117 | 118 | 100 119 | 02 120 | 121 | 122 | 123 | 36.00 124 | 125 | 200.00 126 | 36.00 127 | 128 | 18 129 | 11 130 | 131 | 9996 132 | GRA 133 | FRE 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | P001 142 | 143 | 144 | 145 | 0 146 | 147 | 148 | -------------------------------------------------------------------------------- /src/templates/factura_percepcion.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | F001-123 15 | 2018-10-15 16 | 01:11:46 17 | 01 18 | 19 | 20 | PEN 21 | 22 | 20123456789 23 | SUNAT 24 | 25 | 26 | 20123456789 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | #SIGN-SUNAT 35 | 36 | 37 | 38 | 39 | 40 | 41 | 20123456789 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 150101 50 | 0000 51 | - 52 | LIMA 53 | LIMA 54 | LIMA 55 | 56 | 57 | 58 | 59 | PE 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 20000000001 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | PE 78 | 79 | 80 | 81 | 82 | 83 | 84 | Percepcion 85 | 204.00 86 | 87 | 88 | FormaPago 89 | Contado 90 | 91 | 92 | true 93 | 51 94 | 0.02 95 | 4.00 96 | 200.00 97 | 98 | 99 | 36.00 100 | 101 | 200.00 102 | 36.00 103 | 104 | 105 | 1000 106 | IGV 107 | VAT 108 | 109 | 110 | 111 | 112 | 113 | 200.00 114 | 236.00 115 | 236.00 116 | 117 | 118 | 1 119 | 2 120 | 200.00 121 | 122 | 123 | 118.000000 124 | 01 125 | 126 | 127 | 128 | 36.00 129 | 130 | 200.00 131 | 36.00 132 | 133 | 18 134 | 10 135 | 136 | 1000 137 | IGV 138 | VAT 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | P001 147 | 148 | 149 | 150 | 100.000000 151 | 152 | 153 | -------------------------------------------------------------------------------- /src/templates/boleta2.1.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | {{serie}}-{{correlativo}} 15 | 2020-08-19 16 | 03:16:38 17 | 03 18 | 19 | {{tipoMoneda}} 20 | 21 | 20123456789 22 | 23 | 24 | 20123456789 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | #SUNAT-SIGN 33 | 34 | 35 | 36 | {{#company}} 37 | 38 | 39 | 40 | {{ruc}} 41 | 42 | 43 | 44 | 45 | 46 | 47 | {{#address}} 48 | 49 | {{ubigueo}} 50 | {{codLocal}} 51 | {{urbanizacion}} 52 | {provincia} 53 | {departamento} 54 | {{distrito}} 55 | 56 | 57 | 58 | 59 | {{codPais}} 60 | 61 | 62 | {{/address}} 63 | 64 | 65 | {{telefono}} 66 | {{correo}} 67 | 68 | 69 | 70 | {{/company}} 71 | {{#client}} 72 | 73 | 74 | 75 | {{numDoc}} 76 | 77 | 78 | 79 | 80 | {{#ubigeo}} 81 | 82 | {{ubigueo}} 83 | 84 | 85 | 86 | 87 | {{codPais}} 88 | 89 | 90 | {{/ubigeo}} 91 | 92 | 93 | 94 | {{/client}} 95 | 96 | 18.00 97 | 98 | 100.00 99 | 18.00 100 | 101 | 102 | 1000 103 | IGV 104 | VAT 105 | 106 | 107 | 108 | 109 | 110 | {{valorVenta}} 111 | {{subTotal}} 112 | {{mtoImpVenta}} 113 | 114 | {{#saleDetails}} 115 | 116 | {{index}} 117 | {{cantidad}} 118 | {{mtoValorVenta}} 119 | 120 | 121 | {{mtoPrecioUnitario}} 122 | 01 123 | 124 | 125 | 126 | {{mtoImpuesto}} 127 | 128 | {{mtoBaseIgv}} 129 | {{mtoImpuesto}} 130 | 131 | {{porcentajeIgv}} 132 | 10 133 | 134 | 1000 135 | IGV 136 | VAT 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | {{codProducto}} 145 | 146 | 147 | 148 | {{mtoValorUnitario}} 149 | 150 | 151 | {{/saleDetails}} 152 | -------------------------------------------------------------------------------- /src/templates/factura_detraccion.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | F001-127 15 | 2021-02-06 16 | 17:47:18 17 | 01 18 | 19 | 20 | PEN 21 | 22 | 20123456789 23 | 24 | 25 | 20123456789 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | #SUNAT-SIGN 34 | 35 | 36 | 37 | 38 | 39 | 40 | 20123456789 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 150101 49 | 0000 50 | CASUARINAS 51 | LIMA 52 | LIMA 53 | LIMA 54 | 55 | 56 | 57 | 58 | PE 59 | 60 | 61 | 62 | 63 | 01-234455 64 | admin@sunat.com 65 | 66 | 67 | 68 | 69 | 70 | 71 | 20000000001 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | PE 81 | 82 | 83 | 84 | 85 | 01-445566 86 | client@corp.com 87 | 88 | 89 | 90 | 91 | Detraccion 92 | 001 93 | 94 | 0004-3342343243 95 | 96 | 97 | 98 | Detraccion 99 | 014 100 | 4 101 | 37.76 102 | 103 | 104 | FormaPago 105 | Contado 106 | 107 | 108 | 144.00 109 | 110 | 800.00 111 | 144.00 112 | 113 | 114 | 1000 115 | IGV 116 | VAT 117 | 118 | 119 | 120 | 121 | 122 | 800.00 123 | 944.00 124 | 944.00 125 | 126 | 127 | 1 128 | 4 129 | 800.00 130 | 131 | 132 | 236 133 | 01 134 | 135 | 136 | 137 | 144.00 138 | 139 | 800.00 140 | 144.00 141 | 142 | 18 143 | 10 144 | 145 | 1000 146 | IGV 147 | VAT 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | P001 156 | 157 | 158 | 159 | 200 160 | 161 | 162 | -------------------------------------------------------------------------------- /src/templates/factura_deduccion_anticipo.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | F001-143 15 | 2021-02-10 16 | 19:09:59 17 | 01 18 | 19 | PEN 20 | 21 | F001-111 22 | 02 23 | 1 24 | 25 | 26 | 20123456789 27 | 28 | 29 | 30 | 31 | 20123456789 32 | 33 | 34 | 20123456789 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | #SUNAT-SIGN 43 | 44 | 45 | 46 | 47 | 48 | 49 | 20123456789 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 150101 58 | 0000 59 | CASUARINAS 60 | LIMA 61 | LIMA 62 | LIMA 63 | 64 | 65 | 66 | 67 | PE 68 | 69 | 70 | 71 | 72 | 01-234455 73 | admin@sunat.com 74 | 75 | 76 | 77 | 78 | 79 | 80 | 20000000001 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | PE 90 | 91 | 92 | 93 | 94 | 01-445566 95 | client@corp.com 96 | 97 | 98 | 99 | 100 | FormaPago 101 | Contado 102 | 103 | 104 | 1 105 | 100.00 106 | 107 | 108 | 36.00 109 | 110 | 200.00 111 | 36.00 112 | 113 | 114 | 1000 115 | IGV 116 | VAT 117 | 118 | 119 | 120 | 121 | 122 | 200.00 123 | 236.00 124 | 100.00 125 | 136.00 126 | 127 | 128 | 1 129 | 2 130 | 200.00 131 | 132 | 133 | 118 134 | 01 135 | 136 | 137 | 138 | 36.00 139 | 140 | 200.00 141 | 36.00 142 | 143 | 18 144 | 10 145 | 146 | 1000 147 | IGV 148 | VAT 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | P001 157 | 158 | 159 | 160 | 100 161 | 162 | 163 | -------------------------------------------------------------------------------- /src/templates/nota_debito.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | FF01-123 15 | 2018-10-15 16 | 00:00:03 17 | 18 | PEN 19 | 20 | F001-111 21 | 02 22 | AUMENTO EN EL VALOR 23 | 24 | 25 | 0014232 26 | 27 | 28 | 29 | F001-111 30 | 01 31 | 32 | 33 | 34 | 20123456789 35 | SUNAT 36 | 37 | 38 | 20123456789 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | #SIGN-GREEN 47 | 48 | 49 | 50 | 51 | 52 | 53 | 20123456789 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 150101 62 | 0000 63 | - 64 | LIMA 65 | LIMA 66 | LIMA 67 | 68 | 69 | 70 | 71 | PE 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 20000000001 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | PE 90 | 91 | 92 | 93 | 94 | 95 | 96 | 36.00 97 | 98 | 200.00 99 | 36.00 100 | 101 | 102 | 1000 103 | IGV 104 | VAT 105 | 106 | 107 | 108 | 109 | 110 | 236.00 111 | 112 | 113 | 1 114 | 2 115 | 100.00 116 | 117 | 118 | 59.000000 119 | 01 120 | 121 | 122 | 123 | 18.00 124 | 125 | 100.00 126 | 18.00 127 | 128 | 18 129 | 10 130 | 131 | 1000 132 | IGV 133 | VAT 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | C023 142 | 143 | 144 | 145 | 50.000000 146 | 147 | 148 | 149 | 2 150 | 2 151 | 100.00 152 | 153 | 154 | 59.000000 155 | 01 156 | 157 | 158 | 159 | 18.00 160 | 161 | 100.00 162 | 18.00 163 | 164 | 18 165 | 10 166 | 167 | 1000 168 | IGV 169 | VAT 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | C02 178 | 179 | 180 | 181 | 50.000000 182 | 183 | 184 | -------------------------------------------------------------------------------- /src/templates/nota_credito.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | FF01-123 15 | 2018-10-15 16 | 00:00:01 17 | 18 | PEN 19 | 20 | F001-111 21 | 07 22 | DEVOLUCION POR ITEM 23 | 24 | 25 | 26 | F001-111 27 | 01 28 | 29 | 30 | 31 | 001-213 32 | 09 33 | 34 | 35 | 20123456789 36 | SUNAT 37 | 38 | 39 | 20123456789 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | #SIGN-SUNAT 48 | 49 | 50 | 51 | 52 | 53 | 54 | 20123456789 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 150101 63 | 0000 64 | - 65 | LIMA 66 | LIMA 67 | LIMA 68 | 69 | 70 | 71 | 72 | PE 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 20000000001 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | PE 91 | 92 | 93 | 94 | 95 | 96 | 97 | 36.00 98 | 99 | 200.00 100 | 36.00 101 | 102 | 103 | 1000 104 | IGV 105 | VAT 106 | 107 | 108 | 109 | 110 | 111 | 236.00 112 | 113 | 114 | 1 115 | 2 116 | 100.00 117 | 118 | 119 | 59.000000 120 | 01 121 | 122 | 123 | 124 | 18.00 125 | 126 | 100.00 127 | 18.00 128 | 129 | 18 130 | 10 131 | 132 | 1000 133 | IGV 134 | VAT 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | C023 143 | 144 | 145 | 146 | 50.000000 147 | 148 | 149 | 150 | 2 151 | 2 152 | 100.00 153 | 154 | 155 | 59.000000 156 | 01 157 | 158 | 159 | 160 | 18.00 161 | 162 | 100.00 163 | 18.00 164 | 165 | 18 166 | 10 167 | 168 | 1000 169 | IGV 170 | VAT 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | C02 179 | 180 | 181 | 182 | 50.000000 183 | 184 | 185 | -------------------------------------------------------------------------------- /src/templates/resumen_diario.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 2.0 14 | 1.1 15 | RC-20210221-001 16 | 2021-02-19 17 | 2021-02-21 18 | 19 | 20123456789 20 | 21 | 22 | 20123456789 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | #SUNAT-SIGN 31 | 32 | 33 | 34 | 35 | 20123456789 36 | 6 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 1 45 | 03 46 | B001-1 47 | 48 | 00000000 49 | 1 50 | 51 | 52 | 3 53 | 54 | 129.56 55 | 56 | 20.00 57 | 01 58 | 59 | 60 | 50.00 61 | 02 62 | 63 | 64 | 24.40 65 | 03 66 | 67 | 68 | 10.56 69 | 04 70 | 71 | 72 | true 73 | 21.00 74 | 75 | 76 | 3.60 77 | 78 | 3.60 79 | 80 | 81 | 1000 82 | IGV 83 | VAT 84 | 85 | 86 | 87 | 88 | 89 | 90 | 2 91 | 07 92 | B001-4 93 | 94 | 00000000 95 | 1 96 | 97 | 98 | 99 | 0001-122 100 | 03 101 | 102 | 103 | 104 | 1 105 | 106 | 200.00 107 | 108 | 40.00 109 | 01 110 | 111 | 112 | 30.00 113 | 02 114 | 115 | 116 | 120.00 117 | 03 118 | 119 | 120 | 7.20 121 | 122 | 7.20 123 | 124 | 125 | 1000 126 | IGV 127 | VAT 128 | 129 | 130 | 131 | 132 | 133 | 2.80 134 | 135 | 2.80 136 | 137 | 138 | 2000 139 | ISC 140 | EXC 141 | 142 | 143 | 144 | 145 | 146 | 147 | 3 148 | 03 149 | B001-2 150 | 151 | 00000000 152 | 1 153 | 154 | 155 | 01 156 | 2.00 157 | 2.00 158 | 121.38 159 | 119.00 160 | 161 | 162 | 1 163 | 164 | 119.00 165 | 166 | 20.00 167 | 01 168 | 169 | 170 | 50.00 171 | 02 172 | 173 | 174 | 24.40 175 | 03 176 | 177 | 178 | true 179 | 21.00 180 | 181 | 182 | 3.60 183 | 184 | 3.60 185 | 186 | 187 | 1000 188 | IGV 189 | VAT 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /src/templates/factura_icbper.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 2.1 13 | 2.0 14 | F001-129 15 | 2021-02-06 16 | 17:50:13 17 | 01 18 | 19 | PEN 20 | 21 | 20123456789 22 | 23 | 24 | 20123456789 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | #SUNAT-SIGN 33 | 34 | 35 | 36 | 37 | 38 | 39 | 20123456789 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 150101 48 | 0000 49 | CASUARINAS 50 | LIMA 51 | LIMA 52 | LIMA 53 | 54 | 55 | 56 | 57 | PE 58 | 59 | 60 | 61 | 62 | 01-234455 63 | admin@sunat.com 64 | 65 | 66 | 67 | 68 | 69 | 70 | 20000000001 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | PE 80 | 81 | 82 | 83 | 84 | 01-445566 85 | client@corp.com 86 | 87 | 88 | 89 | 90 | FormaPago 91 | Contado 92 | 93 | 94 | 36.84 95 | 96 | 200.20 97 | 36.04 98 | 99 | 100 | 1000 101 | IGV 102 | VAT 103 | 104 | 105 | 106 | 107 | 0.80 108 | 109 | 110 | 7152 111 | ICBPER 112 | OTH 113 | 114 | 115 | 116 | 117 | 118 | 200.20 119 | 237.04 120 | 0.04 121 | 237.00 122 | 123 | 124 | 1 125 | 2 126 | 200.00 127 | 128 | 129 | 118 130 | 01 131 | 132 | 133 | 134 | 36.00 135 | 136 | 200.00 137 | 36.00 138 | 139 | 18 140 | 10 141 | 142 | 1000 143 | IGV 144 | VAT 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | P001 153 | 154 | 155 | 156 | 100 157 | 158 | 159 | 160 | 2 161 | 4 162 | 0.20 163 | 164 | 165 | 0.059 166 | 01 167 | 168 | 169 | 170 | 0.84 171 | 172 | 0.20 173 | 0.04 174 | 175 | 18 176 | 10 177 | 178 | 1000 179 | IGV 180 | VAT 181 | 182 | 183 | 184 | 185 | 0.80 186 | 4 187 | 188 | 0.20 189 | 190 | 7152 191 | ICBPER 192 | OTH 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | P002 201 | 202 | 203 | 204 | 0.05 205 | 206 | 207 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "./dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | }, 109 | "include": ["src/**/*.ts"], 110 | "exclude": ["node_modules"] 111 | } 112 | --------------------------------------------------------------------------------