package com.ffii.fpsms.modules.pickOrder.entity

import com.ffii.core.support.AbstractRepository
import org.springframework.stereotype.Repository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
@Repository
interface PickOrderLineRepository : AbstractRepository<PickOrderLine, Long> {
    @Query("""
    SELECT DISTINCT pol.pickOrder 
    FROM PickOrderLine pol 
    WHERE pol.item.id = :itemId 
    AND pol.pickOrder.status IN ('PENDING', 'PARTIALLY_COMPLETED', 'RELEASED')
    AND pol.pickOrder.deleted = false
""")
fun findAllPickOrdersByItemId(@Param("itemId") itemId: Long): List<PickOrder>


@Query("""
    SELECT pol FROM PickOrderLine pol 
    WHERE pol.pickOrder.id = :pickOrderId AND pol.deleted = false
""")
fun findAllByPickOrderId(@Param("pickOrderId") pickOrderId: Long): List<PickOrderLine>
}