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 .

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-generator-cli 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-generator-cli 1.0.0
File Size Uploaded
invoice_generator_cli-1.0.0.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for invoice-generator-cli 1.0.0
File Interpreter ABI Platform
invoice_generator_cli-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / invoice_generator_cli-1.0.0.tar.gz

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

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

Download URL invoice_generator_cli-1.0.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a299366c1d5b563632ba11ff4451c2a0c37ae26c4c2e15ca7870e0f91f01244e
BLAKE2b-256 checksum
How to use checksums
44ed0764729ded45e0454f404dd12b6e373e5b490b34982e05d7eb6cb54d414c
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