package com.ffii.fpsms.modules.deliveryOrder.entity

import com.ffii.core.support.AbstractRepository
import com.ffii.fpsms.modules.deliveryOrder.entity.models.DeliveryOrderInfo
import com.ffii.fpsms.modules.deliveryOrder.enums.DeliveryOrderStatus
import org.springframework.stereotype.Repository
import java.io.Serializable
import java.time.LocalDateTime

@Repository
interface DeliveryOrderRepository : AbstractRepository<DeliveryOrder, Long> {
    fun findTopByM18DataLogIdAndDeletedIsFalseOrderByModifiedDesc(m18datalogId: Serializable): DeliveryOrder?

    fun findDeliveryOrderInfoByDeletedIsFalse(): List<DeliveryOrderInfo>

    fun findByIdAndDeletedIsFalse(id: Serializable): DeliveryOrder?

    fun findAllByCodeContainsAndDeletedIsFalse(code: String?): List<DeliveryOrderInfo>

    fun findAllByShopNameContainsAndDeletedIsFalse(shopName: String?): List<DeliveryOrderInfo>

    fun findAllByStatusAndDeletedIsFalse(status: DeliveryOrderStatus?): List<DeliveryOrderInfo>

    fun findByOrderDateBetweenAndDeletedIsFalse(startDate: LocalDateTime?, endDate: LocalDateTime?) : List<DeliveryOrderInfo>

    fun findDeliveryOrderInfoById(id: Long): List<DeliveryOrderInfo>

    //GET FULL LIST
    fun findAllBy() : List<DeliveryOrderInfo>;

    //SEARCH ALL
    fun findAllByCodeContainsAndShopNameContainsAndStatusAndOrderDateBetweenAndEstimatedArrivalDateBetweenAndDeletedIsFalse(code: String?, shopName: String?, status: DeliveryOrderStatus?, orderStartDate: LocalDateTime?, orderEndDate: LocalDateTime?, estArrStartDate: LocalDateTime?, estArrEndDate: LocalDateTime?) : List<DeliveryOrderInfo>;
    //SEARCH WITHOUT STATUS
    fun findAllByCodeContainsAndShopNameContainsAndOrderDateBetweenAndEstimatedArrivalDateBetweenAndDeletedIsFalse(code: String?, shopName: String?, orderStartDate: LocalDateTime?, orderEndDate: LocalDateTime?, estArrStartDate: LocalDateTime?, estArrEndDate: LocalDateTime?) : List<DeliveryOrderInfo>;

    //SEARCH WITHOUT EST ARR DATE
    fun findAllByCodeContainsAndShopNameContainsAndStatusAndOrderDateBetweenAndDeletedIsFalse(code: String?, shopName: String?, status: DeliveryOrderStatus?, orderStartDate: LocalDateTime?, orderEndDate: LocalDateTime?) : List<DeliveryOrderInfo>;
    //SEARCH WITHOUT EST ARR DATE + STATUS
    fun findAllByCodeContainsAndShopNameContainsAndOrderDateBetweenAndDeletedIsFalse(code: String?, shopName: String?, orderStartDate: LocalDateTime?, orderEndDate: LocalDateTime?) : List<DeliveryOrderInfo>;

    //SEARCH WITHOUT ORDER DATE
    fun findAllByCodeContainsAndShopNameContainsAndStatusAndEstimatedArrivalDateBetweenAndDeletedIsFalse(code: String?, shopName: String?, status: DeliveryOrderStatus?, estArrStartDate: LocalDateTime?, estArrEndDate: LocalDateTime?) : List<DeliveryOrderInfo>;
    //SEARCH WITHOUT ORDER DATE + STATUS
    fun findAllByCodeContainsAndShopNameContainsAndEstimatedArrivalDateBetweenAndDeletedIsFalse(code: String?, shopName: String?, estArrStartDate: LocalDateTime?, estArrEndDate: LocalDateTime?): List<DeliveryOrderInfo>;

    //SEARCH WITHOUT DATE + STATUS
    fun findAllByCodeContainsAndShopNameContainsAndDeletedIsFalse(code: String?, shopName: String?) : List<DeliveryOrderInfo>;

    //SEARCH WITHOUT DATE
    fun findAllByCodeContainsAndShopNameContainsAndStatusAndDeletedIsFalse(code: String?, shopName: String?, staus: DeliveryOrderStatus?) : List<DeliveryOrderInfo>;


}
