Class AjusteServiceImpl

java.lang.Object
com.deusto.coffeestack.service.AjusteServiceImpl
All Implemented Interfaces:
AjusteService

@Service public class AjusteServiceImpl extends Object implements AjusteService
  • Constructor Details

  • Method Details

    • registrarAjuste

      @Transactional public MovimientoResponse registrarAjuste(AjusteRequest request, String usuarioLogin)
      Registers the movement and updates the lote's current quantity.

      Business rules:

      1. The lote must exist.
      2. For MERMA / ROTURA / AJUSTE_NEGATIVO: quantity must not exceed the lote's current available stock.
      3. The lote's cantidadActual is decreased or increased accordingly.
      4. A MovimientoInventario audit record is persisted.
      Specified by:
      registrarAjuste in interface AjusteService
      Parameters:
      request - the adjustment details
      usuarioLogin - login of the authenticated user performing the action
      Returns:
      the persisted movement as a response DTO
    • listarMovimientos

      @Transactional(readOnly=true) public List<MovimientoResponse> listarMovimientos()
      Description copied from interface: AjusteService
      Returns all registered movements, most recent first.
      Specified by:
      listarMovimientos in interface AjusteService
    • listarMovimientosPorInsumo

      @Transactional(readOnly=true) public List<MovimientoResponse> listarMovimientosPorInsumo(Long insumoId)
      Description copied from interface: AjusteService
      Returns all movements for batches of a given insumo, most recent first.
      Specified by:
      listarMovimientosPorInsumo in interface AjusteService
    • listarMovimientosFiltrados

      @Transactional(readOnly=true) public List<MovimientoResponse> listarMovimientosFiltrados(Long insumoId, TipoMovimiento tipo, LocalDateTime desde, LocalDateTime hasta)
      Description copied from interface: AjusteService
      Returns movements filtered by optional criteria, most recent first.
      Specified by:
      listarMovimientosFiltrados in interface AjusteService
      Parameters:
      insumoId - restrict to a specific insumo (nullable)
      tipo - restrict to a specific movement type (nullable)
      desde - lower bound on fechaHora, inclusive (nullable)
      hasta - upper bound on fechaHora, inclusive (nullable)
    • reportePorMotivo

      @Transactional(readOnly=true) public List<ReporteMotivoResponse> reportePorMotivo(TipoMovimiento tipo, LocalDateTime desde, LocalDateTime hasta)
      Description copied from interface: AjusteService
      Genera el reporte de movimientos agrupado por motivo y tipo, con el número de incidencias y la cantidad total acumulada por cada combinación. Pensado para que el propietario detecte patrones de desperdicio y enfoque mejoras de proceso (issue #24).
      Specified by:
      reportePorMotivo in interface AjusteService
      Parameters:
      tipo - restringe a un tipo concreto (nullable: incluye todos)
      desde - inicio del rango, inclusivo (nullable)
      hasta - fin del rango, inclusivo (nullable)
      Returns:
      filas ordenadas por cantidad total descendente