handle prefixes
This commit is contained in:
parent
d17ea1da6a
commit
fb4f1a0995
@ -851,11 +851,20 @@ object IncomingInventoryCtrl {
|
||||
|
||||
fun getNextNum(ctx: Context) {
|
||||
val prefix = "MRN/"
|
||||
val plantId = ctx.queryParam("plantId") ?: throw BadRequestResponse("plantId not sent")
|
||||
val plant = database.find(Plant::class.java)
|
||||
.where()
|
||||
.eq("plantId", plantId)
|
||||
.findOne() ?: throw BadRequestResponse("plant missing for $plantId")
|
||||
val inventoryPrefix = plant.prefixes?.get("INBOUND") ?: prefix
|
||||
|
||||
val cnt = (database.find(IncomingInventory::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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,11 +434,13 @@ open class IncomingInventory : BaseTenantModel() {
|
||||
this.vendor = updated.vendor
|
||||
this.loading = updated.loading
|
||||
this.unloading = updated.unloading
|
||||
this.unloadingPlantId = updated.unloadingPlantId
|
||||
}
|
||||
|
||||
var mrn: String? = null
|
||||
var date: LocalDate? = null
|
||||
var vendorBillNum: String? = null
|
||||
var unloadingPlantId: String? = null
|
||||
var vendorBillAmount: Double = 0.0
|
||||
var vehicle: String = ""
|
||||
var loading: String? = ""
|
||||
@ -659,4 +661,6 @@ open class ReminderLog : BaseTenantModel() {
|
||||
open class Plant : BaseModel() {
|
||||
var plantId: String = ""
|
||||
var plantName: String = ""
|
||||
@DbJsonB
|
||||
var prefixes: Map<String,String>? = emptyMap()
|
||||
}
|
||||
2
src/main/resources/dbmigration/1.28.sql
Normal file
2
src/main/resources/dbmigration/1.28.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- apply alter tables
|
||||
alter table incoming_inventory add column if not exists unloading_plant_id varchar(255);
|
||||
2
src/main/resources/dbmigration/1.29.sql
Normal file
2
src/main/resources/dbmigration/1.29.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- apply alter tables
|
||||
alter table plant add column if not exists prefixes jsonb;
|
||||
8
src/main/resources/dbmigration/model/1.28.model.xml
Normal file
8
src/main/resources/dbmigration/model/1.28.model.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply">
|
||||
<addColumn tableName="incoming_inventory">
|
||||
<column name="unloading_plant_id" type="varchar"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</migration>
|
||||
8
src/main/resources/dbmigration/model/1.29.model.xml
Normal file
8
src/main/resources/dbmigration/model/1.29.model.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply">
|
||||
<addColumn tableName="plant">
|
||||
<column name="prefixes" type="jsonb"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</migration>
|
||||
Loading…
x
Reference in New Issue
Block a user