package com.ffii.fpsms.modules.common

import java.time.LocalDate
import java.time.format.DateTimeFormatter

object CodeGenerator {
    private var dateFormat = DateTimeFormatter.ofPattern("yyMMdd")
    fun generateCode(prefix: String, itemId: Long, count: Int): String {
        // prefix = "ITEM" || "LOT"
        // count = number of record from db
        val todayStr = LocalDate.now().format(dateFormat)
        val itemStr = String.format("%04d", itemId)
        val countStr = String.format("%04d", count)
        return "$prefix-$todayStr$itemStr$countStr"
    }
}