- schema fin: fin.invoices + fin.invoice_items + fin.payments; totales con IVA, estados borrador→emitida→enviada→pagada, cobranza (pagos) y saldo automático - generar-factura-desde-embarque (toma conceptos de venta de la cotización) - ops.shipment_events: bitácora/hitos del embarque con secuencia por defecto según operación (importación/exportación) — cubre Diagrama 3 - subida de documentos a MinIO: POST /crm/uploads (multipart) + URL firmada - migración c4d5e6f7a8b9, routers/permisos (fin), seed del flujo hasta factura - 58 tests pytest en verde Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
import pytest
|
|
from fastapi import HTTPException
|
|
|
|
from api.v1.modules.ops.shipments import service
|
|
from api.v1.modules.ops.shipments.dto import ShipmentCreate
|
|
|
|
T, C = 1, 1
|
|
|
|
|
|
def test_seed_import_milestones(db):
|
|
s = service.create_shipment(db, ShipmentCreate(reference="IMP-1", operation_type="importacion"), T, C)
|
|
events = service.seed_default_milestones(db, s.id, T, C)
|
|
titles = [e.event_type for e in events]
|
|
assert "aviso_llegada" in titles
|
|
assert "despacho_importacion" in titles
|
|
assert "entrega" in titles
|
|
# idempotente: no duplica
|
|
again = service.seed_default_milestones(db, s.id, T, C)
|
|
assert len(again) == len(events)
|
|
|
|
|
|
def test_seed_export_milestones_and_complete(db):
|
|
s = service.create_shipment(db, ShipmentCreate(reference="EXP-1", operation_type="exportacion"), T, C)
|
|
events = service.seed_default_milestones(db, s.id, T, C)
|
|
assert any(e.event_type == "embarque" for e in events)
|
|
done = service.complete_shipment_event(db, events[0].id, T, C)
|
|
assert done.status == "completado" and done.actual_date is not None
|
|
|
|
|
|
def test_seed_requires_operation_type(db):
|
|
s = service.create_shipment(db, ShipmentCreate(reference="X-1"), T, C) # sin operation_type
|
|
with pytest.raises(HTTPException) as exc:
|
|
service.seed_default_milestones(db, s.id, T, C)
|
|
assert exc.value.status_code == 422
|