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,itemsson obligatorios.tax_ratees opcional (por defecto 0%).- Cada item debe tener
description,quantity(positivo) yprice(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) itemsno es una lista o está vacía- Cada item debe tener
description,quantity(positivo) yprice(positivo) - Directorio de salida no escribible
- Errores de permisos al leer/escribir
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f92422528b7625955c1b80179e3064cf28138ee8ffb843cc594f8ee64d089c5
|
|
| MD5 |
263975d4fd8bdb709b21fdff7078159f
|
|
| BLAKE2b-256 |
f8a2ba6a40be690df80bd707466a8e06e808e654fede5c4f8106ad6e75ea423f
|
File details
Details for the file invoice_generator_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: invoice_generator_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a299366c1d5b563632ba11ff4451c2a0c37ae26c4c2e15ca7870e0f91f01244e
|
|
| MD5 |
a0eea2f9d2c92554ec15aab133a3d08c
|
|
| BLAKE2b-256 |
44ed0764729ded45e0454f404dd12b6e373e5b490b34982e05d7eb6cb54d414c
|