fixes
This commit is contained in:
parent
9a60105ed3
commit
9633983dec
Binary file not shown.
@ -409,6 +409,11 @@ object PurchaseOrderCtrl {
|
||||
|
||||
fun create(ctx: Context) {
|
||||
val po = ctx.bodyAsClass<PurchaseOrder>()
|
||||
val prods = po.products
|
||||
if(prods.isEmpty()){
|
||||
ctx.json(mapOf("error" to "empty product list")).status(HttpStatus.BAD_REQUEST)
|
||||
return
|
||||
}
|
||||
database.save(po)
|
||||
ctx.json(po).status(HttpStatus.CREATED)
|
||||
}
|
||||
@ -489,13 +494,11 @@ object ProductCtrl {
|
||||
.eq("sys_pk", id.toLong())
|
||||
.findOne()
|
||||
?: throw NotFoundResponse("Product not found for $id")
|
||||
println("Product found")
|
||||
println(product)
|
||||
ctx.json(product).status(HttpStatus.OK)
|
||||
}
|
||||
|
||||
fun getAll(ctx: Context) {
|
||||
val productList = Session.database.find(Product::class.java)
|
||||
val productList = database.find(Product::class.java)
|
||||
.findList()
|
||||
.sortedBy { it.name }
|
||||
val excel = ctx.queryParam("excel")
|
||||
@ -505,7 +508,7 @@ object ProductCtrl {
|
||||
ctx.result(inputStream).status(HttpStatus.OK)
|
||||
|
||||
}else{
|
||||
ctx.json(productList)
|
||||
ctx.json(productList).status(HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
|
||||
@ -607,6 +610,12 @@ object QuotationCtrl {
|
||||
|
||||
fun create(ctx: Context) {
|
||||
val quote = ctx.bodyAsClass<Quotation>()
|
||||
//validation
|
||||
val prods = quote.products
|
||||
if(prods.isEmpty()){
|
||||
ctx.json(mapOf("error" to "empty product list")).status(HttpStatus.BAD_REQUEST)
|
||||
return
|
||||
}
|
||||
database.save(quote)
|
||||
ctx.json(quote).status(HttpStatus.CREATED)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user