Skip to main content

Invoice Generator

Herramienta CLI para generar facturas en HTML a partir de un archivo JSON. Combina las funcionalidades de dos proyectos anteriores: un generador CLI y un generador web.

Instalación

pip install invoice-gen-tool

O bien ejecuta directamente:

python cli.py --help

Uso

Generar una factura

invogen generate example.json

También puedes especificar un directorio de salida:

invogen generate example.json --output-dir ./facturas

Listar facturas generadas

invogen list
invogen list --output-dir ./facturas

Formato del JSON

{
  "number": "001",
  "date": "2023-01-15",
  "issuer": "ACME Corp",
  "client": "John Doe",
  "items": [
    {"description": "Widget", "quantity": 2, "price": 9.99},
    {"description": "Gadget", "quantity": 1, "price": 19.99}
  ],
  "tax_rate": 21
}
  • number, date, issuer, client, items son obligatorios.
  • tax_rate es opcional (por defecto 0%).
  • Cada item debe tener description, quantity (positivo) y price (positivo).

Versión Web

Abre web/index.html en un navegador para una interfaz gráfica que genera la factura en el navegador y permite imprimir/PDF.

Pruebas

python -m pytest tests/

Licencia

MIT

## Manejo de errores

El CLI incluye validaciones robustas con mensajes claros. Ejemplos de errores:

```bash
$ invogen generate nonexistent.json
Error: File not found: nonexistent.json

$ invogen generate ejemplo.json --output-dir /root/test
Error: Cannot create output directory '/root/test': [Errno 13] Permission denied: '/root/test'

$ echo '{"invalid": true}' > bad.json && invogen generate bad.json
Error: Missing required field 'number' in bad.json

$ invogen list --output-dir /directorio/inexistente
Error: No invoices found. Directory does not exist: /directorio/inexistente

Errores adicionales que captura el CLI:

  • Archivo sin extensión .json
  • JSON mal formado
  • Campos requeridos faltantes (number, date, issuer, client, items)
  • items no es una lista o está vacía
  • Cada item debe tener description, quantity (positivo) y price (positivo)
  • Directorio de salida no escribible
  • Errores de permisos al leer/escribir

Release files for invoice-gen-tool 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for invoice-gen-tool 1.0.0
File Size Uploaded
invoice_gen_tool-1.0.0.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for invoice-gen-tool 1.0.0
File Interpreter ABI Platform
invoice_gen_tool-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / invoice_gen_tool-1.0.0.tar.gz

Download URL invoice_gen_tool-1.0.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
28470019d4ca9d942eadae783bfdef3785c5eba0d511de2e54ab043edc203dc7
BLAKE2b-256 checksum
How to use checksums
2315823962af91ad5a0e46a1ed12ca567537171e9721ebd4c4ddc638592bff58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / invoice_gen_tool-1.0.0-py3-none-any.whl

Download URL invoice_gen_tool-1.0.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97cec3a511c01945d54d9f3021e42fa99b418eff937366804f92ed84d4be9a90
BLAKE2b-256 checksum
How to use checksums
a6e4731f11548a966a26f9e240c5707818573ce0b217942f4928a45c6c9c2ac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page