Metadata-Version: 2.4
Name: xfep
Version: 0.1.0
Summary: Ecosistema completo de Facturación Electrónica Perú (SUNAT) — meta-paquete
Project-URL: Homepage, https://github.com/Xpertik/xfep
Project-URL: Repository, https://github.com/Xpertik/xfep
Project-URL: Issues, https://github.com/Xpertik/xfep/issues
Project-URL: Documentation, https://github.com/Xpertik/xfep#readme
Author-email: Jhonatan Mosquera Tabra <jhonatanmt83@gmail.com>
Maintainer-email: Jhonatan Mosquera Tabra <jhonatanmt83@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: cpe,e-invoicing,facturacion-electronica,meta-package,peru,sdk,sunat,ubl
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Accounting
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.13
Requires-Dist: xfep-consulta>=0.1.0
Requires-Dist: xfep-gre>=0.1.0
Requires-Dist: xfep-lookup>=0.1.0
Requires-Dist: xfep-models>=0.1.0
Requires-Dist: xfep-parser>=0.1.0
Requires-Dist: xfep-pdf>=0.1.0
Requires-Dist: xfep-sign>=0.1.0
Requires-Dist: xfep-ws>=0.1.0
Requires-Dist: xfep-xml>=0.1.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# xfep

Meta-paquete que instala el ecosistema completo de **Facturación Electrónica Perú** (SUNAT UBL 2.1).

## Instalación

```bash
pip install xfep
```

Esto instala automáticamente todos los paquetes del ecosistema:

| Paquete | Descripción |
|---------|-------------|
| [xfep-models](https://github.com/xpertik/xfep-models) | Modelos de datos Pydantic v2 |
| [xfep-xml](https://github.com/xpertik/xfep-xml) | Generación de XML UBL 2.1 |
| [xfep-sign](https://github.com/xpertik/xfep-sign) | Firma digital XMLDSig |
| [xfep-ws](https://github.com/xpertik/xfep-ws) | Cliente SOAP/REST para SUNAT |
| [xfep-parser](https://github.com/xpertik/xfep-parser) | Parseo de respuestas CDR |
| [xfep-consulta](https://github.com/xpertik/xfep-consulta) | Consulta de CPE (API SUNAT) |
| [xfep-lookup](https://github.com/xpertik/xfep-lookup) | Consulta RUC/DNI |
| [xfep-gre](https://github.com/xpertik/xfep-gre) | Guías de Remisión Electrónica |
| [xfep-pdf](https://github.com/xpertik/xfep-pdf) | Generación de PDF |

## Uso rápido

```python
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:

```bash
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](LICENSE).
