add plant to out

This commit is contained in:
gowthaman 2024-05-28 13:28:27 +05:30
parent ae539ae285
commit 916cd7b275

View File

@ -13,8 +13,9 @@ object IncomingInventoryCtrl {
Session.currentUserPlants()
)
}
fun updatePlant(ctx: Context) {
val p = ctx.bodyAsClass<Plant>()
val p = ctx.bodyAsClass<Plant>()
val plant = Session.database.find(Plant::class.java, ctx.pathParam("id"))
plant.patch(p)
ctx.json(
@ -121,11 +122,20 @@ object OutgoingInventoryCtrl {
fun getNextNum(ctx: Context) {
val prefix = "MDN/"
val cnt = Session.database.find(OutgoingInventory::class.java)
.findCount()
val plantId = ctx.queryParam("plantId") ?: throw BadRequestResponse("plantId not sent")
val plant = Session.database.find(Plant::class.java)
.where()
.eq("plantId", plantId)
.findOne() ?: throw BadRequestResponse("plant missing for $plantId")
val inventoryPrefix = plant.prefixes?.get("OUTBOUND") ?: prefix
val cnt = (Session.database.find(OutgoingInventory::class.java)
.where()
.eq("unloadingPlantId", plantId)
.findCount() + 1)
.toString()
.padStart(6, '0')
val seq = SequenceNumber(prefix + cnt)
val seq = SequenceNumber(inventoryPrefix + cnt)
ctx.json(seq).status(HttpStatus.OK)
}
}