package com.ffii.fpsms.modules.pickOrder.web.models

import com.ffii.fpsms.modules.stock.entity.SuggestedPickLot
import com.ffii.fpsms.modules.stock.entity.projection.CurrentInventoryItemInfo
import java.math.BigDecimal
import java.time.LocalDateTime
import java.time.LocalDate
// Final Response - Release Conso Pick Order Page
data class ReleasePickOrderInfoResponse(
    val consoCode: String,
    val pickOrders: List<ReleasePickOrderInfo>,
    val items: List<CurrentInventoryItemInfo>
)

data class GetPickOrderInfoResponse(
    val consoCode: String?,

    val pickOrders: List<GetPickOrderInfo>,
    val items: List<CurrentInventoryItemInfo>
)

// Components
data class ReleasePickOrderInfo(
    val id: Long?,
    val code: String?,
    val targetDate: LocalDateTime?,
    val type: String?,
    val status: String?,
    val pickOrderLines: List<ReleasePickOrderLineInfo>
)

data class GetPickOrderInfo(
    val id: Long?,
    val code: String?,
    val consoCode: String?,
    val targetDate: LocalDateTime?,
    val type: String?,
    val status: String?,
    val assignTo: Long?,
    val groupName: String?,
    val pickOrderLines: List<GetPickOrderLineInfo>
)

data class ReleasePickOrderLineInfo(
    val id: Long?,
    val itemId: Long?,
    val itemCode: String?,
    val itemName: String?,
    val availableQty: BigDecimal?,
    val requiredQty: BigDecimal?,
    val uomCode: String?,
    val uomDesc: String?,
)

data class GetPickOrderLineInfo(
    val id: Long?,
    val itemId: Long?,
    val itemCode: String?,
    val itemName: String?,
    val availableQty: BigDecimal?,
    val requiredQty: BigDecimal?,
    val uomCode: String?,
    val uomDesc: String?,
    val suggestedList: List<SuggestedPickLot>?,
    val pickedQty: BigDecimal?=BigDecimal.ZERO,
    val noLotLines: List<NoLotLineDto>?=emptyList()
)
data class NoLotLineDto(
    val stockOutLineId: Long,
    val status: String?,
    val qty: BigDecimal,
    val created: LocalDateTime?,
    val modified: LocalDateTime?
)
// Final Response - Conso Pick Order Detail
data class ConsoPickOrderResponse(
    val consoCode: String,
    val pickOrders: List<PickOrderInConso>,
    val items: List<ItemInConso>
)

// Components
data class PickOrderInConso(
    val id: Long?,
    val code: String?,
    val targetDate: LocalDateTime?,
    val completeDate: LocalDateTime?,
    val releasedDate: LocalDateTime?,
    val releasedBy: IdName,
    val assignTo: IdName,
    val pickOrderLines: List<PickOrderLineInConso>,
    val type: String?,
    val status: String?,
)

data class PickOrderLineInConso(
    val id: Long?,
    val item: IdCodeName,
    val qty: BigDecimal?,
    val uom: IdCodeDesc,
    val status: String?,
    val suggestedPickLots: List<SuggestedPickLotInConso>,
    val actualPickLots: List<ActualPickLotInConso>,
)

data class SuggestedPickLotInConso(
    val id: Long?,
    val type: String?,
    val inventoryLotLine: InventoryLotLineInConso,
    val qty: BigDecimal?,
    val pickSuggested: Boolean?,
)

data class ActualPickLotInConso(
    val id: Long,
    val type: String,
    val inventoryLotLine: InventoryLotLineInConso,
    val qty: BigDecimal,
)

data class InventoryLotLineInConso(
    val id: Long?,
    val lotNo: String?,
    val inQty: BigDecimal?,
    val outQty: BigDecimal?,
    val holdQty: BigDecimal?,
    val remainingQty: BigDecimal?,
    val stockUom: IdCodeDesc,
    val status: String?,
    val remarks: String?,
)

data class ItemInConso(
    val id: Long?,
    val code: String?,
    val name: String?,
    val qty: BigDecimal?,
    val suggestPickLots: List<SuggestedPickLotInConso>,
    val actualPickLots: List<ActualPickLotInConso>,
)

// Common
data class IdName(
    val id: Long?,
    val name: String?,
)

data class IdCodeName(
    val id: Long?,
    val code: String?,
    val name: String?,
)

data class IdCodeDesc(
    val id: Long?,
    val code: String?,
    val desc: String?,
)

data class PickOrderLineLotDetailResponse(
    val lotId: Long?,
    val lotNo: String?,
    val expiryDate: LocalDate?,
    val location: String?,
    val itemId: Long? = null,
    val stockInLineId: Long? = null,
    val stockUnit: String?,
    val availableQty: BigDecimal?,
    val requiredQty: BigDecimal?,
    val inQty: BigDecimal?,
    val outQty: BigDecimal?,
    val holdQty: BigDecimal?,
    val actualPickQty: BigDecimal?,
    val suggestedPickLotId: Long?,
    val lotStatus: String?,
    val stockOutLineId: Long?,
    val stockOutLineStatus: String?,
    val stockOutLineQty: BigDecimal?,
    val totalPickedByAllPickOrders: BigDecimal?,
    val remainingAfterAllPickOrders: BigDecimal?,
    val lotAvailability: String?,
    val noLot: Boolean = false 
)