package com.ffii.fpsms.m18.entity

import com.ffii.core.entity.BaseEntity
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Table
import jakarta.validation.constraints.NotNull
import java.math.BigDecimal

/**
 * M18 `cunit` lines from GET /root/api/read/unit?id=… (data.cunit[]).
 * [ratioN] / [ratioD] here are **swapped** vs M18 JSON: DB ratioN ← JSON ratioD, DB ratioD ← JSON ratioN.
 */
@Entity
@Table(name = "m18_cunit")
open class M18Cunit : BaseEntity<Long>() {

    /** M18 unit id (same as unit.id / list value id). */
    @NotNull
    @Column(name = "m18Id", nullable = false)
    open var m18Id: Long = 0L

    /** M18 primary key of the cunit row (JSON `id`). */
    @NotNull
    @Column(name = "m18CunitLineId", nullable = false)
    open var m18CunitLineId: Long = 0L

    @Column(name = "ratioN", precision = 20, scale = 10)
    open var ratioN: BigDecimal? = null

    @Column(name = "ratioD", precision = 20, scale = 10)
    open var ratioD: BigDecimal? = null

    @Column(name = "hId")
    open var hId: Long? = null

    @Column(name = "unitId")
    open var unitId: Long? = null

    @Column(name = "iRev")
    open var iRev: Int? = null

    @Column(name = "itemNo", length = 32)
    open var itemNo: String? = null
}
