Ecosistema completo de Facturación Electrónica Perú (SUNAT) — meta-paquete
Project description
xfep
Meta-paquete que instala el ecosistema completo de Facturación Electrónica Perú (SUNAT UBL 2.1).
Instalación
pip install xfep
Esto instala automáticamente todos los paquetes del ecosistema:
| Paquete | Descripción |
|---|---|
| xfep-models | Modelos de datos Pydantic v2 |
| xfep-xml | Generación de XML UBL 2.1 |
| xfep-sign | Firma digital XMLDSig |
| xfep-ws | Cliente SOAP/REST para SUNAT |
| xfep-parser | Parseo de respuestas CDR |
| xfep-consulta | Consulta de CPE (API SUNAT) |
| xfep-lookup | Consulta RUC/DNI |
| xfep-gre | Guías de Remisión Electrónica |
| xfep-pdf | Generación de PDF |
Uso rápido
from xfep.models import Invoice, Client, Detalle, Company
from xfep.xml import XmlBuilder
from xfep.sign import Certificate, XmlSigner
from xfep.ws import SunatSoap
from xfep.parser import parse_cdr
# 1. Definir empresa y documento
company = Company(
ruc="20123456789",
razon_social="MI EMPRESA S.A.C.",
direccion="Av. Principal 123",
ubigeo="150101", distrito="Lima",
provincia="Lima", departamento="Lima",
usuario_sol="MODDATOS", clave_sol="MODDATOS",
)
invoice = Invoice(
company_id=1, branch_id=1, serie="F001",
fecha_emision="2026-02-10", moneda="PEN",
tipo_operacion="0101", forma_pago_tipo="Contado",
client=Client(
tipo_documento="6",
numero_documento="20987654321",
razon_social="CLIENTE S.A.C.",
),
detalles=[
Detalle(
descripcion="Servicio de consultoría",
unidad="ZZ", cantidad=1,
mto_precio_unitario=5900,
porcentaje_igv=18, tip_afe_igv="10",
)
],
)
# 2. Generar XML
xml_bytes = XmlBuilder().build(invoice, company)
# 3. Firmar
cert = Certificate.from_file("empresa.p12", "password")
signed_xml = XmlSigner.sign(xml_bytes, cert)
# 4. Enviar a SUNAT
async with SunatSoap(company.ruc, company.usuario_sol, company.clave_sol) as ws:
response = await ws.send_bill(signed_xml, f"{company.ruc}-01-F001-1")
# 5. Parsear CDR
if response.cdr_bytes:
cdr = parse_cdr(response.cdr_bytes)
print(f"Estado: {cdr.status}") # ACEPTADO
Paquetes individuales
Si solo necesitás un componente específico:
pip install xfep-models # Solo modelos
pip install xfep-xml # Solo generación XML
pip install xfep-lookup # Solo consulta RUC/DNI
Stack
- Python >= 3.13
- Pydantic v2 (modelos)
- lxml + Jinja2 (XML)
- cryptography (firma digital)
- httpx (HTTP async)
- WeasyPrint (PDF)
Licencia
Apache License 2.0 — ver LICENSE.
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 xfep-0.1.0.tar.gz.
File metadata
- Download URL: xfep-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab9efeda40a34553cd8d9788c309d49c91b85da3c0ac1c5c4b142006d74484e3
|
|
| MD5 |
1f25a277bb75b80e415073def1816464
|
|
| BLAKE2b-256 |
e6b99226347c20ef53122c93f35c9543c8faf4398fb263d5949eff6a8c98c276
|
File details
Details for the file xfep-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xfep-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e119f7962f22a1fd146bf34b9fd38cac7d362f32542dbeee078ce16719d3d69
|
|
| MD5 |
0176087f3dbd8169a2109a9c6ba90a3e
|
|
| BLAKE2b-256 |
7dc9013a63fbfe282d0ef467a0e225571fe48443bd020403632d33e05e8d4150
|