Go to file
Philipp Kunz 78ba483d35
Some checks failed
Default (tags) / security (push) Failing after 14s
Default (tags) / test (push) Failing after 12s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
1.0.6
2024-07-02 15:45:59 +02:00
.gitea/workflows fix(core): update 2024-04-22 16:30:55 +02:00
.vscode fix(core): update 2024-04-22 16:30:55 +02:00
test fix(core): update 2024-04-22 16:30:55 +02:00
ts fix(core): Project files committed with initial structure and class implementation 2024-07-02 15:45:59 +02:00
.gitignore fix(core): update 2024-04-22 16:30:55 +02:00
changelog.md fix(core): Project files committed with initial structure and class implementation 2024-07-02 15:45:59 +02:00
npmextra.json fix(core): update 2024-04-22 16:30:55 +02:00
package.json 1.0.6 2024-07-02 15:45:59 +02:00
pnpm-lock.yaml fix(core): update 2024-04-22 16:30:55 +02:00
readme.hints.md fix(core): update 2024-04-22 16:30:55 +02:00
readme.md fix(core): update 2024-04-22 16:30:55 +02:00
tsconfig.json fix(core): update 2024-04-22 16:30:55 +02:00

@fin.cx/xinvoice

a module for working with xinvoice packages.

Install

To install @fin.cx/xinvoice, you'll need npm (Node Package Manager). Run this command in your terminal:

npm install @fin.cx/xinvoice

This command fetches the xinvoice package from the npm registry and installs it in your project.

Usage

The @fin.cx/xinvoice module is designed to work with xinvoice packages, specifically aimed at managing invoices with ease. This document will guide you through using all the features offered by the module, ensuring you can effectively incorporate it into your projects.

Getting Started with ESM and TypeScript

To use @fin.cx/xinvoice in a TypeScript project, first, make sure you have configured TypeScript to support ECMAScript modules (ESM). Here's a basic tsconfig.json for reference:

{
  "compilerOptions": {
    "module": "ESNext",
    "target": "ESNext",
    "moduleResolution": "node",
    "strict": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "outDir": "./dist",
    "types": ["node"]
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

Importing the Module

With TypeScript configured, import the module into your project using ESM syntax:

import { XInvoice } from '@fin.cx/xinvoice';

Working with Invoices

The core functionality revolves around creating and managing XInvoice instances, which represent your invoices. Let's dive into how we can create and manipulate these instances.

Creating an XInvoice Instance

To create a new instance of XInvoice, you'll need a PDF path, an XML path (which contains the invoice data), and an output path where the processed file will be saved:

const pdfPath = './path/to/your/invoice.pdf';
const xmlPath = './path/to/your/invoice.xml';
const outputPath = './path/to/save/processed_invoice.pdf';

const xInvoice = new XInvoice(pdfPath, xmlPath, outputPath);

Embedding XML into a PDF

One of the key features is embedding XML data into a PDF. This is crucial for ensuring that your invoice contains all necessary data in a format that's both human-readable and machine-processable. Heres how to embed XML into a PDF:

await xInvoice.embedXml();

This method asynchronously processes the PDF and XML files, embedding the XML data into the PDF. Upon completion, it saves the modified PDF to the specified outputPath.

Parsing XML to Create an Invoice Object

While the provided example doesn't directly expose a parsing method, @fin.cx/xinvoice is designed to facilitate the extension and customization of such functionalities. If parsing from XML to a structured invoice object is necessary, consider implementing a parser that utilizes the interfaces provided by the module.

For illustrative purposes, if there was a method parseXmlToInvoice(xmlContent: string) within XInvoice, it could be used like this:

const xmlContent = `<Your XML content here>`;
const invoiceData = xInvoice.parseXmlToInvoice(xmlContent);

console.log(invoiceData);

Conclusion

The @fin.cx/xinvoice module provides a foundational framework for working with xinvoices, focusing on embedding XML data into PDFs and facilitating the potential parsing of XML to structured invoice data. Its usage in a TypeScript environment ensures type safety and enhances the development experience.

This guide covered installing the module, setting up a TypeScript project to use ESM syntax, creating an XInvoice instance, and embedding XML into PDFs. With these capabilities, @fin.cx/xinvoice is a robust tool for managing xinvoice packages within your application.

This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the license file within this repository.

Please note: The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.

Company Information

Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany

For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.