Add inventory
This commit is contained in:
@@ -397,12 +397,12 @@ object PurchaseOrderCtrl {
|
||||
fun getAll(ctx: Context) {
|
||||
val filters = ctx.bodyAsClass<PF>()
|
||||
val pos = searchPos(filters.common, filters.poFilters)
|
||||
val excel = ctx.queryParam("excel")
|
||||
if(excel != null){
|
||||
val excel = ctx.queryParam("excel")
|
||||
if (excel != null) {
|
||||
exportPos(pos)
|
||||
val inputStream = FileInputStream("./excel/Pos.xls")
|
||||
ctx.result(inputStream).status(HttpStatus.OK)
|
||||
}else{
|
||||
} else {
|
||||
ctx.json(pos).status(HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
@@ -410,7 +410,7 @@ object PurchaseOrderCtrl {
|
||||
fun create(ctx: Context) {
|
||||
val po = ctx.bodyAsClass<PurchaseOrder>()
|
||||
val prods = po.products
|
||||
if(prods.isEmpty()){
|
||||
if (prods.isEmpty()) {
|
||||
ctx.json(mapOf("error" to "empty product list")).status(HttpStatus.BAD_REQUEST)
|
||||
return
|
||||
}
|
||||
@@ -496,17 +496,19 @@ object ProductCtrl {
|
||||
?: throw NotFoundResponse("Product not found for $id")
|
||||
ctx.json(product).status(HttpStatus.OK)
|
||||
}
|
||||
data class PF(val common: CommonFilters, val productFilters: ProductFilters)
|
||||
|
||||
data class PF(val common: CommonFilters, val productFilters: ProductFilters)
|
||||
|
||||
fun getAll(ctx: Context) {
|
||||
val filters = ctx.bodyAsClass<PF>()
|
||||
val prods = searchProducts(filters.common, filters.productFilters)
|
||||
val excel = ctx.queryParam("excel")
|
||||
if(excel != null){
|
||||
if (excel != null) {
|
||||
exportProds(prods)
|
||||
val inputStream = FileInputStream("./excel/Products.xls")
|
||||
ctx.result(inputStream).status(HttpStatus.OK)
|
||||
|
||||
}else{
|
||||
} else {
|
||||
ctx.json(prods).status(HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
@@ -611,7 +613,7 @@ object QuotationCtrl {
|
||||
val quote = ctx.bodyAsClass<Quotation>()
|
||||
//validation
|
||||
val prods = quote.products
|
||||
if(prods.isEmpty()){
|
||||
if (prods.isEmpty()) {
|
||||
ctx.json(mapOf("error" to "empty product list")).status(HttpStatus.BAD_REQUEST)
|
||||
return
|
||||
}
|
||||
@@ -800,4 +802,105 @@ object RequestForQuote {
|
||||
//shuld we compare the new body fields with preexisting ones and prepare a sql query to update those fields??
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object IncomingInventoryCtrl {
|
||||
fun create(ctx: Context) {
|
||||
val ticket = ctx.bodyAsClass<IncomingInventory>()
|
||||
database.save(ticket)
|
||||
ctx.json(ticket).status(HttpStatus.CREATED)
|
||||
}
|
||||
|
||||
fun update(ctx: Context) {
|
||||
val id = ctx.pathParam("id").toLong()
|
||||
val ticket =
|
||||
database.find(IncomingInventory::class.java, id) ?: throw NotFoundResponse("quote not found for $id")
|
||||
val updatedTicket = ctx.bodyAsClass<IncomingInventory>()
|
||||
ticket.patchValues(updatedTicket)
|
||||
ticket.update()
|
||||
ctx.json(ticket).status(HttpStatus.OK)
|
||||
}
|
||||
|
||||
fun get(ctx: Context) {
|
||||
val id = ctx.pathParam("id").toLong()
|
||||
val ticket = database.find(IncomingInventory::class.java, id)
|
||||
?: throw NotFoundResponse("No incoming inventory ticket found with id $id")
|
||||
ctx.json(ticket).status(HttpStatus.OK)
|
||||
}
|
||||
|
||||
data class IIF(val common: CommonFilters, val incomingInventoryFilters: IncomingInventoryFilters)
|
||||
|
||||
fun getAll(ctx: Context) {
|
||||
val filters = ctx.bodyAsClass<IIF>()
|
||||
val tickets = searchIncomingInventory(filters.common, filters.incomingInventoryFilters)
|
||||
val excel = ctx.queryParam("excel")
|
||||
if (excel !== null) {
|
||||
exportIncomingInventory(tickets)
|
||||
val inputStream = FileInputStream("./excel/IncomingInventory.xls")
|
||||
ctx.result(inputStream).status(HttpStatus.OK)
|
||||
} else {
|
||||
ctx.json(tickets).status(HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
|
||||
fun getNextNum(ctx: Context) {
|
||||
val prefix = "MRN/"
|
||||
val cnt = database.find(IncomingInventory::class.java)
|
||||
.findCount()
|
||||
.toString()
|
||||
.padStart(6, '0')
|
||||
val seq = SequenceNumber(prefix + cnt)
|
||||
ctx.json(seq).status(HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
|
||||
object OutgoingInventoryCtrl {
|
||||
fun create(ctx: Context) {
|
||||
val ticket = ctx.bodyAsClass<OutgoingInventory>()
|
||||
database.save(ticket)
|
||||
ctx.json(ticket).status(HttpStatus.CREATED)
|
||||
}
|
||||
|
||||
fun update(ctx: Context) {
|
||||
val id = ctx.pathParam("id").toLong()
|
||||
val ticket =
|
||||
database.find(OutgoingInventory::class.java, id) ?: throw NotFoundResponse("quote not found for $id")
|
||||
val updatedTicket = ctx.bodyAsClass<OutgoingInventory>()
|
||||
ticket.patchValues(updatedTicket)
|
||||
ticket.update()
|
||||
ctx.json(ticket).status(HttpStatus.OK)
|
||||
}
|
||||
|
||||
fun get(ctx: Context) {
|
||||
val id = ctx.pathParam("id").toLong()
|
||||
val ticket = database.find(OutgoingInventory::class.java, id)
|
||||
?: throw NotFoundResponse("No incoming inventory ticket found with id $id")
|
||||
ctx.json(ticket).status(HttpStatus.OK)
|
||||
}
|
||||
|
||||
data class OIF(val common: CommonFilters, val outgoingInventoryFilters: OutgoingInventoryFilters)
|
||||
|
||||
fun getAll(ctx: Context) {
|
||||
val filters = ctx.bodyAsClass<OIF>()
|
||||
val tickets = searchOutgoingInventory(filters.common, filters.outgoingInventoryFilters)
|
||||
val excel = ctx.queryParam("excel")
|
||||
if (excel !== null) {
|
||||
exportOutgoingInventory(tickets)
|
||||
val inputStream = FileInputStream("./excel/OutgoingInventory.xls")
|
||||
ctx.result(inputStream).status(HttpStatus.OK)
|
||||
} else {
|
||||
ctx.json(tickets).status(HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
|
||||
fun getNextNum(ctx: Context) {
|
||||
println("inside next num")
|
||||
val prefix = "MDN/"
|
||||
val cnt = database.find(OutgoingInventory::class.java)
|
||||
.findCount()
|
||||
.toString()
|
||||
.padStart(6, '0')
|
||||
val seq = SequenceNumber(prefix + cnt)
|
||||
ctx.json(seq).status(HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user