package com.ffii.fpsms.modules.stock.entity.projection

import org.springframework.beans.factory.annotation.Value
import java.math.BigDecimal
import java.time.LocalDate

interface InventoryLotLineItemInfo {
    val id: Long
    val code: String
    val name: String
    val type: String
}

interface InventoryLotLineWarehouseInfo {
    val id: Long
    val code: String
    val name: String
    val description: String
    val capacity: BigDecimal
}

interface InventoryLotLineInfo {
    val id: Long?
    @get:Value("#{target.inventoryLot.lotNo}")
    val lotNo: String?
    @get:Value("#{target.inventoryLot.item}")
    val item: InventoryLotLineItemInfo?
    val warehouse: InventoryLotLineWarehouseInfo?
//    @get:Value("#{((target.inQty ?: 0) - (target.outQty ?: 0) - (target.holdQty ?: 0)) / (target.inventoryLot.item.itemUoms.^[stockUnit == true && deleted == false]?.ratioN / target.inventoryLot.item.itemUoms.^[stockUnit == true && deleted == false]?.ratioD)}")
    @get:Value("#{(target.inQty ?: 0) - (target.outQty ?: 0) - (target.holdQty ?: 0)}")
    var availableQty: BigDecimal?
//    @get:Value("#{(target.inQty ?: 0)/ (target.inventoryLot.item.itemUoms.^[stockUnit == true && deleted == false]?.ratioN / target.inventoryLot.item.itemUoms.^[stockUnit == true && deleted == false]?.ratioD)}")
    @get:Value("#{target.inQty ?: 0}")
    var inQty: BigDecimal?
//    @get:Value("#{(target.outQty ?: 0)/ (target.inventoryLot.item.itemUoms.^[stockUnit == true && deleted == false]?.ratioN / target.inventoryLot.item.itemUoms.^[stockUnit == true && deleted == false]?.ratioD)}")
    @get:Value("#{(target.outQty ?: 0)}")
    var outQty: BigDecimal?
//    @get:Value("#{(target.holdQty ?: 0)/ (target.inventoryLot.item.itemUoms.^[stockUnit == true && deleted == false]?.ratioN / target.inventoryLot.item.itemUoms.^[stockUnit == true && deleted == false]?.ratioD)}")
    @get:Value("#{(target.holdQty ?: 0)}")
    var holdQty: BigDecimal?
    @get:Value("#{(target.inQty ?: 0) - (target.outQty ?: 0) - (target.holdQty ?: 0)}")
    val qtyPerSmallestUnit: BigDecimal?
    @get:Value("#{target.inventoryLot.item?.itemUoms.^[baseUnit == true && deleted == false]?.uom?.udfudesc}")
    val baseUom: String?

    @get:Value("#{target.status.value}")
    val status: String?
    val remarks: String?

    @get:Value("#{target.stockUom?.uom?.udfudesc}")
    val uom: String?

    @get:Value("#{target.stockUom?.uom?.id}")
    val uomId: Long?

    @get:Value("#{target.inventoryLot.expiryDate}")
    val expiryDate: LocalDate
}

interface CurrentInventoryItemInfo {
    val id: Long? // item id
    val code: String?
    val name: String?
    val uomDesc: String?
    val availableQty: BigDecimal?
    val requiredQty: BigDecimal?
}