package com.ffii.fpsms.modules.master.entity

import com.ffii.core.support.AbstractRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository
import java.io.Serializable

@Repository
interface ItemUomRespository : AbstractRepository<ItemUom, Long> {
    fun findAllByItemIdAndDeletedIsFalse(itemId: Serializable): List<ItemUom>

    fun findByIdAndDeletedIsFalse(id: Serializable): ItemUom?

    fun findByM18IdAndDeletedIsFalse(m18Id: Serializable): ItemUom?

    fun deleteAllByIdIn(id: List<Serializable>)

    fun findByItemIdAndPurchaseUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom?

    fun findByItemIdAndSalesUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom?
    fun findByItemIdAndStockUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom?

    fun findByItemIdAndBaseUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom?
    fun findByItemIdAndPickingUnitIsTrueAndDeletedIsFalse(itemId: Serializable): ItemUom?

    fun findByItemM18IdAndPurchaseUnitIsTrueAndDeletedIsFalse(itemM18Id: Long): ItemUom?
    fun findBaseUnitByItemIdAndStockUnitIsTrueAndDeletedIsFalse(itemId: Long): ItemUom?
    fun findFirstByItemIdAndUomIdAndDeletedIsFalse(itemId: Long, uomId: Long): ItemUom?
    fun findByItemIdAndUomIdAndStockUnitAndDeletedIsFalse(itemId: Long, uomId: Long, stockUnit: Boolean): ItemUom?

    fun findFirstByItemIdAndStockUnitIsTrueAndDeletedIsFalseOrderByIdAsc(itemId: Long): ItemUom?
}