package com.ffii.fpsms.modules.purchaseOrder.enums

import jakarta.persistence.AttributeConverter
import jakarta.persistence.Converter

@Converter(autoApply = true)
class PurchaseOrderLineStatusConverter : AttributeConverter<PurchaseOrderLineStatus, String> {
    override fun convertToDatabaseColumn(status: PurchaseOrderLineStatus?): String? {
        return status?.value
    }

    override fun convertToEntityAttribute(value: String?): PurchaseOrderLineStatus? {
        return value?.let { v ->
            PurchaseOrderLineStatus.entries.find { it.value == v }
        }
    }
}