fixes
This commit is contained in:
@@ -374,8 +374,19 @@ object Entities {
|
||||
}
|
||||
}
|
||||
data class Filters(val common :CommonFilters, val custom :CustomFilters)
|
||||
data class SequenceNumber(val number:String)
|
||||
data class BatchPos(val pos :List<PurchaseOrder>)
|
||||
object PurchaseOrderCtrl {
|
||||
|
||||
fun getNextNum(ctx: Context){
|
||||
val prefix = "PO/"
|
||||
val cnt = database.find(PurchaseOrder::class.java)
|
||||
.findCount()
|
||||
.toString()
|
||||
.padStart(6, '0')
|
||||
val seq = SequenceNumber(prefix + cnt)
|
||||
ctx.json(seq).status(HttpStatus.OK)
|
||||
}
|
||||
fun get(ctx :Context){
|
||||
val id = ctx.pathParam("id")
|
||||
val po = database.find(PurchaseOrder::class.java, id) ?: throw NotFoundResponse("po not found for $id")
|
||||
@@ -441,10 +452,15 @@ data class ProductSearch(
|
||||
|
||||
object ProductCtrl {
|
||||
fun get(ctx :Context){
|
||||
val hsnCode = ctx.pathParam("hsnCode")
|
||||
val product = database.find(Product::class.java, hsnCode) ?: throw NotFoundResponse("Product not found for $hsnCode")
|
||||
|
||||
ctx.json(product)
|
||||
val id = ctx.pathParam("id")
|
||||
val product = database.find(Product::class.java)
|
||||
.where()
|
||||
.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)
|
||||
@@ -475,6 +491,15 @@ object ProductCtrl {
|
||||
}
|
||||
|
||||
object QuotationCtrl {
|
||||
fun getNextNum(ctx: Context){
|
||||
val prefix = "QUOTE/"
|
||||
val cnt = database.find(Quotation::class.java)
|
||||
.findCount()
|
||||
.toString()
|
||||
.padStart(6, '0')
|
||||
val seq = SequenceNumber(prefix + cnt)
|
||||
ctx.json(seq).status(HttpStatus.OK)
|
||||
}
|
||||
fun get(ctx :Context){
|
||||
val id = ctx.pathParam("id")
|
||||
val quote = database.find(Quotation::class.java, id) ?: throw NotFoundResponse("quote not found for $id")
|
||||
@@ -490,27 +515,8 @@ object QuotationCtrl {
|
||||
|
||||
fun create(ctx :Context){
|
||||
val quote = ctx.bodyAsClass<Quotation>()
|
||||
//we have to check if the quotation created date is below the expiry of rfq
|
||||
val rfq = database.find(com.restapi.domain.ReqForQuote::class.java)
|
||||
.where()
|
||||
.eq("reqForQuoteNum", quote.reqForQuoteNum)
|
||||
.findOne()
|
||||
if(rfq != null){
|
||||
//compare dates
|
||||
if(quote.quoteDate!! <= rfq.openTill) {
|
||||
//valid
|
||||
database.save(quote)
|
||||
ctx.status(HttpStatus.CREATED)
|
||||
ctx.json(quote)
|
||||
}else {
|
||||
ctx.status(HttpStatus.BAD_REQUEST)
|
||||
ctx.result("request for quote closed")
|
||||
}
|
||||
}else {
|
||||
throw NotFoundResponse("request for quote not found for this quotation")
|
||||
}
|
||||
|
||||
|
||||
database.save(quote)
|
||||
ctx.json(quote).status(HttpStatus.CREATED)
|
||||
}
|
||||
fun createBatch(ctx :Context){
|
||||
val quotes = ctx.bodyAsClass<List<Quotation>>()
|
||||
|
||||
Reference in New Issue
Block a user