package com.ffii.fpsms.m18

/**
 * M18 PO [createUid] is stored on [com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrder.m18CreatedUId].
 * For these M18 user ids, FPSMS does not post GRN to M18 (see [com.ffii.fpsms.modules.stock.service.StockInLineService]).
 * Remarks are shown on PO stock-in traceability report ([com.ffii.fpsms.modules.report.service.ReportService.searchStockInTraceabilityReport]).
 */
object M18GrnRules {
    private val REMARKS_FOR_M18_CREATED_UID: Map<Long, String> = mapOf(
        2569L to "legato",
        2676L to "xtech",
    )

    val SKIP_GRN_FOR_M18_CREATED_UIDS: Set<Long> = REMARKS_FOR_M18_CREATED_UID.keys

    /** Display string for PDF/Excel: `2569 (legato)`, or plain id when unknown. */
    fun formatM18CreatedUidForReport(uid: Long?): String {
        if (uid == null) return ""
        val remark = REMARKS_FOR_M18_CREATED_UID[uid]
        return if (remark != null) "$uid ($remark)" else uid.toString()
    }
}
