mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-09 12:29:13 +00:00
trabajando en la vista de peiddos
This commit is contained in:
@ -1,9 +1,23 @@
|
||||
package com.imprimelibros.erp.pedidos;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PedidoRepository extends JpaRepository<Pedido, Long>, JpaSpecificationExecutor<Pedido> {
|
||||
|
||||
// Suma de "total" para un "createdBy" desde una fecha dada
|
||||
@Query("""
|
||||
SELECT COALESCE(SUM(p.total), 0)
|
||||
FROM Pedido p
|
||||
WHERE p.createdBy.id = :userId
|
||||
AND p.createdAt >= :afterDate
|
||||
""")
|
||||
Double sumTotalByCreatedByAndCreatedAtAfter(@Param("userId") Long userId,
|
||||
@Param("afterDate") LocalDateTime afterDate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user