UNPKG

facturajs

Version:

Comunicación con los web services de AFIP utilizando nodejs.

75 lines • 2.54 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const moment_1 = __importDefault(require("moment")); const AfipServices_1 = require("../AfipServices"); const config = { certPath: './private/dev/cert.pem', privateKeyPath: './private/dev/private_key.key', cacheTokensPath: './.lastTokens', homo: true, tokensExpireInHours: 12, }; const afip = new AfipServices_1.AfipServices(config); const cuit = 27310090854; async function facturaBExample() { const res = await afip.getLastBillNumber({ Auth: { Cuit: cuit }, params: { CbteTipo: 6, PtoVta: 7, }, }); console.log('Last bill number: ', res.CbteNro); const num = res.CbteNro; const next = num + 1; console.log('Next bill number to create: ', next); const resBill = await afip.createBill({ Auth: { Cuit: cuit }, params: { FeCAEReq: { FeCabReq: { CantReg: 1, PtoVta: 7, CbteTipo: 6, }, FeDetReq: { FECAEDetRequest: { DocTipo: 99, DocNro: 0, Concepto: 1, CondicionIVAReceptorId: 5, CbteDesde: next, CbteHasta: next, CbteFch: (0, moment_1.default)().format('YYYYMMDD'), ImpTotal: 121.0, ImpTotConc: 0, ImpNeto: 100, ImpOpEx: 0, ImpIVA: 21, ImpTrib: 0, MonId: 'PES', MonCotiz: 1, Iva: [ { AlicIva: { Id: 5, BaseImp: 100, Importe: 21, }, }, ], }, }, }, }, }); console.log('Created bill', JSON.stringify(resBill, null, 4)); } facturaBExample().catch((err) => { console.error('Something was wrong!'); console.error(err); }); //# sourceMappingURL=create-bill-facturaB.js.map