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 .

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_generator_cli-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_generator_cli-1.0.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: invoice_generator_cli-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_generator_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4f92422528b7625955c1b80179e3064cf28138ee8ffb843cc594f8ee64d089c5
MD5 263975d4fd8bdb709b21fdff7078159f
BLAKE2b-256 f8a2ba6a40be690df80bd707466a8e06e808e654fede5c4f8106ad6e75ea423f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for invoice_generator_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a299366c1d5b563632ba11ff4451c2a0c37ae26c4c2e15ca7870e0f91f01244e
MD5 a0eea2f9d2c92554ec15aab133a3d08c
BLAKE2b-256 44ed0764729ded45e0454f404dd12b6e373e5b490b34982e05d7eb6cb54d414c

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