some changes
This commit is contained in:
@@ -10,6 +10,7 @@ import com.restapi.domain.Session.currentUser
|
||||
import com.restapi.domain.Session.database
|
||||
import com.restapi.domain.Session.findDataModelByEntityAndUniqId
|
||||
import com.restapi.integ.Scripting
|
||||
import com.restapi.integ.logger
|
||||
import io.ebean.CallableSql
|
||||
import io.ebean.RawSqlBuilder
|
||||
import io.javalin.http.*
|
||||
@@ -379,8 +380,8 @@ object PurchaseOrderCtrl {
|
||||
|
||||
fun getNextNum(ctx: Context) {
|
||||
val prefix = "PO/"
|
||||
val cnt = database.find(PurchaseOrder::class.java)
|
||||
.findCount()
|
||||
val cnt = (database.find(PurchaseOrder::class.java)
|
||||
.findCount() + 1)
|
||||
.toString()
|
||||
.padStart(6, '0')
|
||||
val seq = SequenceNumber(prefix + cnt)
|
||||
@@ -499,7 +500,27 @@ object ProductCtrl {
|
||||
}
|
||||
|
||||
data class PF(val common: CommonFilters, val productFilters: ProductFilters)
|
||||
data class GetPrice(val productId: Long, val vendor: Any)
|
||||
fun getPrice(ctx: Context){
|
||||
val gp = ctx.bodyAsClass<GetPrice>()
|
||||
val vendor = database.find(Vendor::class.java, gp.vendor) ?: throw BadRequestResponse("vendor not found for ${gp.vendor}")
|
||||
val product = database.find(Product::class.java, gp.productId) ?: throw BadRequestResponse("product not found for ${gp.productId}")
|
||||
val poProduct = database.find(PurchaseOrder::class.java)
|
||||
.where()
|
||||
.eq("vendor", vendor)
|
||||
.findList()
|
||||
.flatMap {
|
||||
it.products
|
||||
}
|
||||
.firstOrNull {
|
||||
it.productId == product.sysPk
|
||||
}
|
||||
|
||||
ctx.json(
|
||||
poProduct ?: throw BadRequestResponse("price not found for this vendor and product")
|
||||
)
|
||||
|
||||
}
|
||||
fun getAll(ctx: Context) {
|
||||
val filters = ctx.bodyAsClass<PF>()
|
||||
val prods = searchProducts(filters.common, filters.productFilters)
|
||||
|
||||
Reference in New Issue
Block a user