UNPKG

n8n-nodes-einvoice

Version:

n8n.io node to handle E-Invoices with PDF or XML Files (ZUGFeRD / XRechnung / Factur-X / EN-16931)

108 lines 4.24 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.EInvoice = void 0; const extraction = __importStar(require("./actions/exctraction.operation")); class EInvoice { constructor() { this.description = { displayName: 'E-Invoice', name: 'eInvoice', group: ['transform'], icon: { light: 'file:eInvoice.svg', dark: 'file:eInvoice.dark.svg' }, version: 1, subtitle: '={{ $parameter["operation"] + ": " + $parameter["resource"] }}', description: 'Handle E-Invoices (ZUGFeRD / XRechnung / Factur-X / EN-16931)', defaults: { name: 'E-Invoice', }, inputs: ["main"], outputs: ["main"], properties: [ { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, options: [ { name: 'PDF', value: 'pdf', action: 'Use PDF for E-Invoice', description: 'Handle the E-Invoice Informations with PDF files', }, { name: 'XML', value: 'xml', action: 'Use XML for E-Invoice', description: 'Handle the E-Invoice Informations with XML files', }, ], default: 'pdf', }, { displayName: 'Operation', name: 'operation', type: 'options', noDataExpression: true, options: [ { name: 'Extract Invoice Data', value: 'extraction', action: 'Extract invoice data', description: 'Extracts the invoice data from a PDF or XML file', }, ], default: 'extraction', }, ...extraction.description, ], }; } async execute() { const items = this.getInputData(); const operation = this.getNodeParameter('operation', 0); const resource = this.getNodeParameter('resource', 0); let returnData = []; if (operation === 'extraction') { if (resource === 'pdf' || resource === 'xml') { returnData = await extraction.execute.call(this, items); } } return [returnData]; } } exports.EInvoice = EInvoice; //# sourceMappingURL=EInvoice.node.js.map