# Evidencia auditoria dual-write lotes

Fecha: 2026-05-05
Entorno: local `demo.enterfarmaplus.test`

## Objetivo

Validar si los flujos que cambian `item_lots_group.quantity` tambien actualizan `item_lots_group_warehouse`.

## Hallazgos iniciales

Cubiertos antes del barrido:

- Compra manual: `PurchaseController`
- Anulacion de compra: `PurchaseController`
- Movimiento de inventario entrada/salida/traslado: `InventoryController`
- Traslado entre almacenes: `TransferController`
- Devolucion manual: `DevolutionController`
- Nota de venta/POS: `SaleNoteController`
- Anulacion/restauracion de CPE: `Facturalo::returnLotes`

Faltantes detectados:

- Importacion XML de compras: `PurchaseXmlImportService`
- Restauracion/anulacion por `InventoryTrait::updateDataLots`
- Eliminacion/restauracion por `InventoryTrait::deleteItemLots`
- Pedido legacy en `InventoryKardexServiceProvider`
- Borrado/restauracion de pedido en `InventoryKardexServiceProvider`
- Devolucion provider legacy en `InventoryKardexServiceProvider`
- Despacho provider legacy en `InventoryKardexServiceProvider`
- Venta de set en `Facturalo::save`

## Correccion aplicada

Se agrego dual-write hacia `ItemLotsGroupWarehouse` en:

- `app/Services/PurchaseXmlImport/PurchaseXmlImportService.php`
- `modules/Inventory/Traits/InventoryTrait.php`
- `modules/Inventory/Providers/InventoryKardexServiceProvider.php`
- `app/CoreFacturalo/Facturalo.php`

## Validacion

```text
No syntax errors detected in app/Services/PurchaseXmlImport/PurchaseXmlImportService.php
No syntax errors detected in modules/Inventory/Traits/InventoryTrait.php
No syntax errors detected in modules/Inventory/Providers/InventoryKardexServiceProvider.php
No syntax errors detected in app/CoreFacturalo/Facturalo.php
```

## Conclusion

Los flujos principales y legacy revisados ahora escriben tanto en `item_lots_group.quantity` como en `item_lots_group_warehouse`.
Quedan fuera de este barrido escrituras de `ItemLot`/series (`has_sale`) porque no representan stock por lote agrupado.
