Skip to main content

CLI tool to generate HTML invoices from JSON

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

invoice_gen_tool-1.0.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

invoice_gen_tool-1.0.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file invoice_gen_tool-1.0.0.tar.gz.

File metadata

  • Download URL: invoice_gen_tool-1.0.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for invoice_gen_tool-1.0.0.tar.gz
Algorithm Hash digest
SHA256 28470019d4ca9d942eadae783bfdef3785c5eba0d511de2e54ab043edc203dc7
MD5 f82654dc0ba849bdedc2503f5391b49f
BLAKE2b-256 2315823962af91ad5a0e46a1ed12ca567537171e9721ebd4c4ddc638592bff58

See more details on using hashes here.

File details

Details for the file invoice_gen_tool-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for invoice_gen_tool-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97cec3a511c01945d54d9f3021e42fa99b418eff937366804f92ed84d4be9a90
MD5 de2e54bd579f09a27fcc5c754699fa4e
BLAKE2b-256 a6e4731f11548a966a26f9e240c5707818573ce0b217942f4928a45c6c9c2ac4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page