facturajs
Version:
Comunicación con los web services de AFIP utilizando nodejs.
66 lines • 2.21 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const AfipServices_1 = require("../AfipServices");
const moment_1 = __importDefault(require("moment"));
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 monotributoExample() {
const res = await afip.getLastBillNumber({
Auth: { Cuit: cuit },
params: {
CbteTipo: 11,
PtoVta: 2,
},
});
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: 2,
CbteTipo: 11,
},
FeDetReq: {
FECAEDetRequest: {
DocTipo: 99,
DocNro: 0,
Concepto: 1,
CondicionIVAReceptorId: 5,
CbteDesde: next,
CbteHasta: next,
CbteFch: (0, moment_1.default)().format('YYYYMMDD'),
ImpTotal: 75.0,
ImpTotConc: 0,
ImpNeto: 75.0,
ImpOpEx: 0,
ImpIVA: 0,
ImpTrib: 0,
MonId: 'PES',
MonCotiz: 1,
},
},
},
},
});
console.log('Created bill', JSON.stringify(resBill, null, 4));
}
monotributoExample().catch((err) => {
console.error('Something was wrong!');
console.error(err);
});
//# sourceMappingURL=create-bill-monotributo.js.map