Add inventory
This commit is contained in:
parent
f8263e8a35
commit
d475d3828b
5
api.http
5
api.http
@ -380,3 +380,8 @@ Authorization: {{auth-token}}
|
||||
GET http://localhost:9001/api/vendor/quote/next
|
||||
Content-Type: application/json
|
||||
Authorization: {{auth-token}}
|
||||
|
||||
### GET NEXT INCOMING SEW NUMBER
|
||||
GET http://localhost:9001/api/vendor/incoming/next
|
||||
Content-Type: application/json
|
||||
Authorization: {{auth-token}}
|
||||
|
||||
@ -115,18 +115,64 @@ fun main(args: Array<String>) {
|
||||
post("", VendorCtrl::create, Roles(Role.Explicit("ROLE_VENDOR_CREATE")))
|
||||
post("/batch", VendorCtrl::createBatch, Roles(Role.Explicit("ROLE_VENDOR_CREATE")))
|
||||
get("/{id}", VendorCtrl::get, Roles(Role.Explicit("ROLE_VENDOR_VIEW", "ROLE_VENDOR_CREATE")))
|
||||
post("/getAll", VendorCtrl::getAll, Roles(Role.Explicit("ROLE_VENDOR_VIEW", "ROLE_VENDOR_CREATE")))
|
||||
get("quotes/{id}", VendorCtrl::getQuotes, Roles(Role.Explicit("ROLE_QUOTE_VIEW", "ROLE_QUOTE_CREATE", "ROLE_VENDOR_VIEW")))
|
||||
post(
|
||||
"/getAll",
|
||||
VendorCtrl::getAll,
|
||||
Roles(Role.Explicit("ROLE_VENDOR_VIEW", "ROLE_VENDOR_CREATE"))
|
||||
)
|
||||
get(
|
||||
"quotes/{id}",
|
||||
VendorCtrl::getQuotes,
|
||||
Roles(Role.Explicit("ROLE_QUOTE_VIEW", "ROLE_QUOTE_CREATE", "ROLE_VENDOR_VIEW"))
|
||||
)
|
||||
get("pos/{id}", VendorCtrl::getPos, Roles(Role.Explicit("ROLE_PO_VIEW", "ROLE_PO_CREATE`")))
|
||||
put("/rate/{id}/{rating}", VendorCtrl::rate, Roles(Role.Explicit("ROLE_VENDOR_CREATE")))
|
||||
put("/{id}", VendorCtrl::update, Roles(Role.Explicit("ROLE_VENDOR_CREATE")))
|
||||
}
|
||||
path("/incoming") {
|
||||
post("", IncomingInventoryCtrl::create, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
||||
get("/next", IncomingInventoryCtrl::getNextNum, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
||||
get(
|
||||
"/{id}",
|
||||
IncomingInventoryCtrl::get,
|
||||
Roles(Role.Explicit("ROLE_INVENTORY_VIEW", "ROLE_INVENTORY_CREATE"))
|
||||
)
|
||||
put("/{id}", IncomingInventoryCtrl::update, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
||||
post(
|
||||
"/getAll",
|
||||
IncomingInventoryCtrl::getAll,
|
||||
Roles(Role.Explicit("ROLE_INVENTORY_CREATE", "ROLE_INVENTORY_VIEW"))
|
||||
)
|
||||
}
|
||||
path("/outgoing") {
|
||||
post("", OutgoingInventoryCtrl::create, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
||||
get("/next", OutgoingInventoryCtrl::getNextNum, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
||||
get(
|
||||
"/{id}",
|
||||
OutgoingInventoryCtrl::get,
|
||||
Roles(Role.Explicit("ROLE_INVENTORY_VIEW", "ROLE_INVENTORY_CREATE"))
|
||||
)
|
||||
put("/{id}", OutgoingInventoryCtrl::update, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
||||
post(
|
||||
"/getAll",
|
||||
OutgoingInventoryCtrl::getAll,
|
||||
Roles(Role.Explicit("ROLE_INVENTORY_CREATE", "ROLE_INVENTORY_VIEW"))
|
||||
)
|
||||
}
|
||||
path("/po") {
|
||||
get("/next", PurchaseOrderCtrl::getNextNum, Roles(Role.Explicit("ROLE_PO_CREATE")))
|
||||
post("", PurchaseOrderCtrl::create, Roles(Role.Explicit("ROLE_PO_CREATE")))
|
||||
post("/batch", PurchaseOrderCtrl::createBatch, Roles(Role.Explicit("ROLE_PO_CREATE")))
|
||||
post("/getAll", PurchaseOrderCtrl::getAll, Roles(Role.Explicit("ROLE_PO_CREATE", "ROLE_PO_VIEW", "ROLE_VENDOR_CREATE")))
|
||||
get("/{id}", PurchaseOrderCtrl::get, Roles(Role.Explicit("ROLE_PO_CREATE", "ROLE_PO_VIEW", "ROLE_QUOTE_CREATE")))
|
||||
post(
|
||||
"/getAll",
|
||||
PurchaseOrderCtrl::getAll,
|
||||
Roles(Role.Explicit("ROLE_PO_CREATE", "ROLE_PO_VIEW", "ROLE_VENDOR_CREATE"))
|
||||
)
|
||||
get(
|
||||
"/{id}",
|
||||
PurchaseOrderCtrl::get,
|
||||
Roles(Role.Explicit("ROLE_PO_CREATE", "ROLE_PO_VIEW", "ROLE_QUOTE_CREATE"))
|
||||
)
|
||||
put("/{id}", PurchaseOrderCtrl::update, Roles(Role.Explicit("ROLE_PO_CREATE")))
|
||||
put("/approve/{id}", PurchaseOrderCtrl::approve, Roles(Role.Explicit()))
|
||||
put("/reject/{id}", PurchaseOrderCtrl::reject, Roles(Role.Explicit()))
|
||||
@ -136,7 +182,11 @@ fun main(args: Array<String>) {
|
||||
get("/next", QuotationCtrl::getNextNum, Roles(Role.Explicit("ROLE_QUOTE_CREATE")))
|
||||
post("", QuotationCtrl::create, Roles(Role.Explicit("ROLE_QUOTE_CREATE")))
|
||||
post("/batch", QuotationCtrl::createBatch, Roles(Role.Explicit("ROLE_QUOTE_CREATE")))
|
||||
post("/getAll", QuotationCtrl::getAll, Roles(Role.Explicit("ROLE_QUOTE_CREATE", "ROLE_QUOTE_VIEW")))
|
||||
post(
|
||||
"/getAll",
|
||||
QuotationCtrl::getAll,
|
||||
Roles(Role.Explicit("ROLE_QUOTE_CREATE", "ROLE_QUOTE_VIEW"))
|
||||
)
|
||||
get("/{id}", QuotationCtrl::get, Roles(Role.Explicit("ROLE_QUOTE_VIEW", "ROLE_QUOTE_CREATE")))
|
||||
put("/{id}", QuotationCtrl::update, Roles(Role.Explicit("ROLE_QUOTE_CREATE")))
|
||||
delete("/{id}", QuotationCtrl::delete, Roles(Role.Explicit("ROLE_QUOTE_CREATE")))
|
||||
@ -152,15 +202,35 @@ fun main(args: Array<String>) {
|
||||
path("/doc") {
|
||||
post("", DocumentCtrl::create, Roles(Role.Explicit("ROLE_DOC_CREATE")))
|
||||
//why type and refid are clubbed ??
|
||||
get("/{type}/{refId}", DocumentCtrl::getWithRefId, Roles(Role.Explicit("ROLE_DOC_VIEW", "ROLE_PRODUCT_CREATE")))
|
||||
get(
|
||||
"/{type}/{refId}",
|
||||
DocumentCtrl::getWithRefId,
|
||||
Roles(Role.Explicit("ROLE_DOC_VIEW", "ROLE_PRODUCT_CREATE"))
|
||||
)
|
||||
get("/{id}", DocumentCtrl::get, Roles(Role.Explicit("ROLE_DOC_VIEW", "ROLE_PRODUCT_CREATE")))
|
||||
get("/print/{id}", DocumentCtrl::print, Roles(Role.Explicit("ROLE_DOC_CREATE", "ROLE_DOC_VIEW")))
|
||||
get(
|
||||
"/print/{id}",
|
||||
DocumentCtrl::print,
|
||||
Roles(Role.Explicit("ROLE_DOC_CREATE", "ROLE_DOC_VIEW"))
|
||||
)
|
||||
delete("/{id}", DocumentCtrl::delete, Roles(Role.Explicit("ROLE_DOC_CREATE")))
|
||||
}
|
||||
path("/reqForQuote") {
|
||||
post("", RequestForQuote::create, Roles(Role.Explicit("ROLE_QUOTE_CREATE", "ROLE_PO_CREATE", "ROLE_RFQ_CREATE")))
|
||||
get("/{id}", RequestForQuote::get, Roles(Role.Explicit("ROLE_RFQ_CREATE", "ROLE_RFQ_VIEW", "ROLE_QUOTE_VIEW", "ROLE_PO_VIEW")))
|
||||
put("/{id}", RequestForQuote::update, Roles(Role.Explicit("ROLE_QUOTE_CREATE", "ROLE_PO_CREATE", "ROLE_RFQ_CREATE")))
|
||||
post(
|
||||
"",
|
||||
RequestForQuote::create,
|
||||
Roles(Role.Explicit("ROLE_QUOTE_CREATE", "ROLE_PO_CREATE", "ROLE_RFQ_CREATE"))
|
||||
)
|
||||
get(
|
||||
"/{id}",
|
||||
RequestForQuote::get,
|
||||
Roles(Role.Explicit("ROLE_RFQ_CREATE", "ROLE_RFQ_VIEW", "ROLE_QUOTE_VIEW", "ROLE_PO_VIEW"))
|
||||
)
|
||||
put(
|
||||
"/{id}",
|
||||
RequestForQuote::update,
|
||||
Roles(Role.Explicit("ROLE_QUOTE_CREATE", "ROLE_PO_CREATE", "ROLE_RFQ_CREATE"))
|
||||
)
|
||||
}
|
||||
}
|
||||
post("/script/database/{name}", Entities::executeStoredProcedure, Roles(adminRole, Role.DbOps))
|
||||
|
||||
@ -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
|
||||
}
|
||||
@ -801,3 +803,104 @@ object RequestForQuote {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,6 +338,85 @@ fun exportPos(pos: List<PurchaseOrder>) {
|
||||
saveExcelFileLocally("Pos.xls", wb)
|
||||
}
|
||||
|
||||
fun exportIncomingInventory(tickets : List<IncomingInventory>) {
|
||||
val wb = HSSFWorkbook()
|
||||
val sh = wb.createSheet()
|
||||
|
||||
val headers: List<String> = listOf(
|
||||
"MRN",
|
||||
"Date",
|
||||
"Vendor Name",
|
||||
"Vendor Bill Number",
|
||||
"Vendor Bill Amount",
|
||||
"Product Id",
|
||||
"Product Name",
|
||||
"Unit Price",
|
||||
"Quantity",
|
||||
)
|
||||
createHeaderRow(headers, sh, wb)
|
||||
|
||||
var rowCnt = 1
|
||||
for (ticket in tickets) {
|
||||
val prodCnt = ticket.products?.size
|
||||
|
||||
for (j in 0..<prodCnt!!) {
|
||||
val row = sh.createRow(rowCnt++)
|
||||
var i = 0
|
||||
row.createCell(i++).setCellValue(ticket.mrn)
|
||||
row.createCell(i++).setCellValue(ticket.date)
|
||||
row.createCell(i++).setCellValue(ticket.vendor?.name)
|
||||
row.createCell(i++).setCellValue(ticket.vendorBillNum)
|
||||
row.createCell(i++).setCellValue(ticket.vendorBillAmount)
|
||||
|
||||
//6 would be repeated
|
||||
row.createCell(i++).setCellValue(ticket.products!![j].productId)
|
||||
row.createCell(i++).setCellValue(ticket.products!![j].productName)
|
||||
row.createCell(i++).setCellValue(ticket.products!![j].unitPrice)
|
||||
row.createCell(i++).setCellValue(ticket.products!![j].quantity)
|
||||
|
||||
}
|
||||
}
|
||||
saveExcelFileLocally("IncomingInventory.xls", wb)
|
||||
}
|
||||
|
||||
fun exportOutgoingInventory(tickets : List<OutgoingInventory>) {
|
||||
val wb = HSSFWorkbook()
|
||||
val sh = wb.createSheet()
|
||||
|
||||
val headers: List<String> = listOf(
|
||||
"MDN",
|
||||
"Date",
|
||||
"Out Mode",
|
||||
"Purpose",
|
||||
"Product Id",
|
||||
"Product Name",
|
||||
"Unit Price",
|
||||
"Quantity",
|
||||
)
|
||||
createHeaderRow(headers, sh, wb)
|
||||
|
||||
var rowCnt = 1
|
||||
for (ticket in tickets) {
|
||||
val prodCnt = ticket.products?.size
|
||||
|
||||
for (j in 0..<prodCnt!!) {
|
||||
val row = sh.createRow(rowCnt++)
|
||||
var i = 0
|
||||
row.createCell(i++).setCellValue(ticket.mdn)
|
||||
row.createCell(i++).setCellValue(ticket.date)
|
||||
row.createCell(i++).setCellValue(ticket.outMode.toString())
|
||||
row.createCell(i++).setCellValue(ticket.purpose)
|
||||
|
||||
//6 would be repeated
|
||||
row.createCell(i++).setCellValue(ticket.products!![j].productId)
|
||||
row.createCell(i++).setCellValue(ticket.products!![j].productName)
|
||||
row.createCell(i++).setCellValue(ticket.products!![j].unitPrice)
|
||||
row.createCell(i++).setCellValue(ticket.products!![j].quantity)
|
||||
|
||||
}
|
||||
}
|
||||
saveExcelFileLocally("OutgoingInventory.xls", wb)
|
||||
}
|
||||
fun main() {
|
||||
//ImportFromExcel(FileType.QUOTES, "C:\\Users\\arsalan\\Downloads\\Book.xlsx")
|
||||
TemplateExcelFile(FileType.PRODS)
|
||||
|
||||
@ -49,7 +49,7 @@ data class RFQFilters(
|
||||
val validBefore: LocalDate = maxDate,
|
||||
val validAfter: LocalDate = baseDate,
|
||||
val reqForQuoteNumLike: String = IGNORE,
|
||||
): CustomFilters
|
||||
) : CustomFilters
|
||||
|
||||
data class QuoteFilters(
|
||||
val quoteNumLike: String = IGNORE,
|
||||
@ -68,6 +68,21 @@ data class VendorFilters(
|
||||
val ratingLessThan: Double = RATING_MAX,
|
||||
) : CustomFilters
|
||||
|
||||
data class IncomingInventoryFilters(
|
||||
val mrnLike: String = IGNORE,
|
||||
val vehicleLike: String = IGNORE,
|
||||
val vendorBillAmountExceeds: Double = Double.MIN_VALUE,
|
||||
val vendorBillAmountLessThan: Double = Double.MAX_VALUE
|
||||
) : CustomFilters
|
||||
|
||||
data class OutgoingInventoryFilters(
|
||||
val mdnLike: String = IGNORE,
|
||||
val purposeLike: String = IGNORE,
|
||||
val personLike: String = IGNORE,
|
||||
val vehicleLike: String = IGNORE,
|
||||
val outMode: OutMode = OutMode.ALL
|
||||
) : CustomFilters
|
||||
|
||||
fun <T> applyVendorHelper(q: io.ebean.ExpressionList<T>, vids: List<Long>?) {
|
||||
if (vids.isNullOrEmpty()) return
|
||||
// q.apply {
|
||||
@ -123,18 +138,19 @@ fun searchVendors(commonFilters: CommonFilters, vendorFilters: VendorFilters): L
|
||||
return q.findList()
|
||||
}
|
||||
|
||||
fun searchProducts(commonFilters: CommonFilters, productFilters: ProductFilters) : List<Product> {
|
||||
fun searchProducts(commonFilters: CommonFilters, productFilters: ProductFilters): List<Product> {
|
||||
val q = database.find(Product::class.java)
|
||||
.where()
|
||||
.ilike("name", "%" + productFilters.nameLike + "%")
|
||||
.ilike("hsnCode", "%" + productFilters.hsnLike + "%")
|
||||
|
||||
if(productFilters.uom != UOM.ALL){
|
||||
if (productFilters.uom != UOM.ALL) {
|
||||
q.eq("uom", productFilters.uom)
|
||||
}
|
||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
return q.findList()
|
||||
}
|
||||
|
||||
fun searchDocs(commonFilters: CommonFilters, documentFilters: DocumentFilters): List<Document> {
|
||||
val q = database.find(Document::class.java)
|
||||
.where()
|
||||
@ -175,3 +191,38 @@ fun searchRFQ(commonFilters: CommonFilters, rfqFilters: RFQFilters): List<ReqFor
|
||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
return q.findList()
|
||||
}
|
||||
|
||||
fun searchIncomingInventory(
|
||||
commonFilters: CommonFilters,
|
||||
incomingInventoryFilters: IncomingInventoryFilters
|
||||
): List<IncomingInventory> {
|
||||
val q = database.find(IncomingInventory::class.java)
|
||||
.where()
|
||||
.ge("vendorBillAmount", incomingInventoryFilters.vendorBillAmountExceeds)
|
||||
.le("vendorBillAmount", incomingInventoryFilters.vendorBillAmountLessThan)
|
||||
.ilike("mrn", "%" + incomingInventoryFilters.mrnLike + "%")
|
||||
.ilike("vehicle", "%" + incomingInventoryFilters.vehicleLike + "%")
|
||||
applyFromToHelper(q, commonFilters.from, commonFilters.to, "date")
|
||||
applyVendorHelper(q, commonFilters.vendor)
|
||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
return q.findList()
|
||||
}
|
||||
|
||||
fun searchOutgoingInventory(
|
||||
commonFilters: CommonFilters,
|
||||
outgoingInventoryFilters: OutgoingInventoryFilters
|
||||
): List<OutgoingInventory> {
|
||||
val q = database.find(OutgoingInventory::class.java)
|
||||
.where()
|
||||
.ilike("mdn", "%" + outgoingInventoryFilters.mdnLike + "%")
|
||||
.ilike("purpose", "%" + outgoingInventoryFilters.purposeLike + "%")
|
||||
// .ilike("person", "%" + outgoingInventoryFilters.personLike + "%")
|
||||
//.ilike("vehicle", "%" + outgoingInventoryFilters.vehicleLike + "%")
|
||||
if (outgoingInventoryFilters.outMode != OutMode.ALL) {
|
||||
q.eq("outMode", outgoingInventoryFilters.outMode)
|
||||
}
|
||||
applyFromToHelper(q, commonFilters.from, commonFilters.to, "date")
|
||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
|
||||
return q.findList()
|
||||
}
|
||||
@ -8,7 +8,7 @@ object DBMigration {
|
||||
private fun create(){
|
||||
val dbMigration: DbMigration = DbMigration.create()
|
||||
dbMigration.setPlatform(Platform.POSTGRES)
|
||||
|
||||
//dbMigration.setGeneratePendingDrop("1.8")
|
||||
dbMigration.generateMigration()
|
||||
}
|
||||
|
||||
|
||||
@ -305,6 +305,10 @@ enum class UOM {
|
||||
NOS, LTR, MTR, ALL
|
||||
}
|
||||
|
||||
enum class TypeOfProduct {
|
||||
RAW_MATERIAL
|
||||
}
|
||||
|
||||
@Entity
|
||||
open class Product : BaseTenantModel() {
|
||||
fun patchValues(updatedProduct: Product) {
|
||||
@ -321,6 +325,11 @@ open class Product : BaseTenantModel() {
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
var uom: UOM? = null
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
var type: TypeOfProduct? = null
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Entity
|
||||
@ -355,6 +364,8 @@ open class Quotation : BaseTenantModel() {
|
||||
|
||||
@DbArray
|
||||
var documents: List<String>? = arrayListOf()
|
||||
|
||||
var taxesIncluded: Boolean ?= null
|
||||
}
|
||||
|
||||
enum class DocType {
|
||||
@ -387,10 +398,63 @@ open class ReqForQuote : BaseTenantModel() {
|
||||
@Enumerated(EnumType.STRING)
|
||||
var status: RFQStatus? = null
|
||||
|
||||
// @DbArray
|
||||
// var docs :List<Document>? = null
|
||||
@DbJsonB
|
||||
var products: List<POProducts>? = null
|
||||
var reqForQuoteNum: String? = null
|
||||
var openTill: LocalDate? = null
|
||||
}
|
||||
|
||||
@Entity
|
||||
open class IncomingInventory : BaseTenantModel() {
|
||||
fun patchValues(updated: IncomingInventory) {
|
||||
this.date = updated.date
|
||||
this.vendorBillNum = updated.vendorBillNum
|
||||
this.vendorBillAmount = updated.vendorBillAmount
|
||||
this.vehicle = updated.vehicle
|
||||
this.products = updated.products
|
||||
this.vendor = updated.vendor
|
||||
}
|
||||
|
||||
var mrn: String? = null
|
||||
var date: LocalDate? = null
|
||||
var vendorBillNum: String? = null
|
||||
var vendorBillAmount: Double = 0.0
|
||||
var vehicle: String = ""
|
||||
|
||||
@DbJsonB
|
||||
var products: List<POProducts>? = null
|
||||
|
||||
@ManyToOne
|
||||
var vendor: Vendor? = null
|
||||
}
|
||||
|
||||
|
||||
enum class OutMode {
|
||||
PERSON, VEHICLE, ALL
|
||||
}
|
||||
|
||||
@Entity
|
||||
open class OutgoingInventory : BaseTenantModel() {
|
||||
fun patchValues(updated: OutgoingInventory) {
|
||||
this.date = updated.date
|
||||
this.products = updated.products
|
||||
this.purpose = updated.purpose
|
||||
this.outMode = updated.outMode
|
||||
this.person = updated.person
|
||||
this.vehicle = updated.vehicle
|
||||
|
||||
}
|
||||
|
||||
var mdn: String? = null
|
||||
var date: LocalDate? = null
|
||||
|
||||
@DbJsonB
|
||||
var products: List<POProducts>? = null
|
||||
var purpose: String? = null
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
var outMode: OutMode? = null
|
||||
|
||||
var person: String? = null
|
||||
var vehicle: String? = null
|
||||
}
|
||||
2
src/main/resources/dbmigration/1.10__dropsFor_1.7.sql
Normal file
2
src/main/resources/dbmigration/1.10__dropsFor_1.7.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- apply alter tables
|
||||
alter table incoming_inventory drop column vendor_bil_num;
|
||||
3
src/main/resources/dbmigration/1.11__dropsFor_1.8.sql
Normal file
3
src/main/resources/dbmigration/1.11__dropsFor_1.8.sql
Normal file
@ -0,0 +1,3 @@
|
||||
-- apply alter tables
|
||||
alter table incoming_inventory drop column mdn;
|
||||
alter table outgoing_inventory drop column mrn;
|
||||
64
src/main/resources/dbmigration/1.6.sql
Normal file
64
src/main/resources/dbmigration/1.6.sql
Normal file
@ -0,0 +1,64 @@
|
||||
-- apply changes
|
||||
create table incoming_inventory (
|
||||
sys_pk bigint generated by default as identity not null,
|
||||
deleted_on timestamp,
|
||||
current_approval_level integer default 0 not null,
|
||||
required_approval_levels integer default 0 not null,
|
||||
date date,
|
||||
vendor_bill_amount float not null,
|
||||
vendor_sys_pk bigint,
|
||||
deleted boolean default false not null,
|
||||
version integer default 1 not null,
|
||||
created_at timestamp default 'now()' not null,
|
||||
modified_at timestamp default 'now()' not null,
|
||||
deleted_by varchar(255),
|
||||
approval_status varchar(8) default 'APPROVED' not null,
|
||||
tags varchar[] default '{}' not null,
|
||||
comments jsonb default '[]' not null,
|
||||
tenant_id varchar(255) not null,
|
||||
mdn varchar(255) not null,
|
||||
vendor_bil_num varchar(255) not null,
|
||||
vehicle varchar(255) not null,
|
||||
products jsonb,
|
||||
created_by varchar(255) not null,
|
||||
modified_by varchar(255) not null,
|
||||
constraint ck_incoming_inventory_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||
constraint pk_incoming_inventory primary key (sys_pk)
|
||||
);
|
||||
|
||||
create table outgoing_inventory (
|
||||
sys_pk bigint generated by default as identity not null,
|
||||
deleted_on timestamp,
|
||||
current_approval_level integer default 0 not null,
|
||||
required_approval_levels integer default 0 not null,
|
||||
date date,
|
||||
deleted boolean default false not null,
|
||||
version integer default 1 not null,
|
||||
created_at timestamp default 'now()' not null,
|
||||
modified_at timestamp default 'now()' not null,
|
||||
deleted_by varchar(255),
|
||||
approval_status varchar(8) default 'APPROVED' not null,
|
||||
tags varchar[] default '{}' not null,
|
||||
comments jsonb default '[]' not null,
|
||||
tenant_id varchar(255) not null,
|
||||
mrn varchar(255) not null,
|
||||
purpose varchar(255),
|
||||
out_mode varchar(7),
|
||||
person varchar(255),
|
||||
vehicle varchar(255),
|
||||
created_by varchar(255) not null,
|
||||
modified_by varchar(255) not null,
|
||||
constraint ck_outgoing_inventory_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||
constraint ck_outgoing_inventory_out_mode check ( out_mode in ('PERSON','VEHICLE','ALL')),
|
||||
constraint pk_outgoing_inventory primary key (sys_pk)
|
||||
);
|
||||
|
||||
-- apply alter tables
|
||||
alter table product add column if not exists type varchar(12);
|
||||
alter table quotation add column if not exists taxes_included boolean;
|
||||
-- apply post alter
|
||||
alter table product add constraint ck_product_type check ( type in ('RAW_MATERIAL'));
|
||||
-- foreign keys and indices
|
||||
create index ix_incoming_inventory_vendor_sys_pk on incoming_inventory (vendor_sys_pk);
|
||||
alter table incoming_inventory add constraint fk_incoming_inventory_vendor_sys_pk foreign key (vendor_sys_pk) references vendor (sys_pk) on delete restrict on update restrict;
|
||||
|
||||
2
src/main/resources/dbmigration/1.7.sql
Normal file
2
src/main/resources/dbmigration/1.7.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- apply alter tables
|
||||
alter table incoming_inventory add column if not exists vendor_bill_num varchar(255);
|
||||
4
src/main/resources/dbmigration/1.8.sql
Normal file
4
src/main/resources/dbmigration/1.8.sql
Normal file
@ -0,0 +1,4 @@
|
||||
-- apply alter tables
|
||||
alter table incoming_inventory add column if not exists mrn varchar(255);
|
||||
alter table outgoing_inventory add column if not exists mdn varchar(255);
|
||||
alter table outgoing_inventory add column if not exists products jsonb;
|
||||
2
src/main/resources/dbmigration/1.9__dropsFor_1.5.sql
Normal file
2
src/main/resources/dbmigration/1.9__dropsFor_1.5.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- apply alter tables
|
||||
alter table document drop column ref_id;
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply" dropsFor="1.7">
|
||||
<dropColumn columnName="vendor_bil_num" tableName="incoming_inventory"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply" dropsFor="1.8">
|
||||
<dropColumn columnName="mdn" tableName="incoming_inventory"/>
|
||||
<dropColumn columnName="mrn" tableName="outgoing_inventory"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
58
src/main/resources/dbmigration/model/1.6.model.xml
Normal file
58
src/main/resources/dbmigration/model/1.6.model.xml
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply">
|
||||
<createTable name="incoming_inventory" pkName="pk_incoming_inventory">
|
||||
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||
<column name="deleted_on" type="localdatetime"/>
|
||||
<column name="deleted_by" type="varchar"/>
|
||||
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_incoming_inventory_approval_status"/>
|
||||
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||
<column name="tenant_id" type="varchar" notnull="true"/>
|
||||
<column name="mdn" type="varchar" notnull="true"/>
|
||||
<column name="date" type="date"/>
|
||||
<column name="vendor_bil_num" type="varchar" notnull="true"/>
|
||||
<column name="vendor_bill_amount" type="double" notnull="true"/>
|
||||
<column name="vehicle" type="varchar" notnull="true"/>
|
||||
<column name="products" type="jsonb"/>
|
||||
<column name="vendor_sys_pk" type="bigint" references="vendor.sys_pk" foreignKeyName="fk_incoming_inventory_vendor_sys_pk" foreignKeyIndex="ix_incoming_inventory_vendor_sys_pk"/>
|
||||
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||
<column name="created_by" type="varchar" notnull="true"/>
|
||||
<column name="modified_by" type="varchar" notnull="true"/>
|
||||
</createTable>
|
||||
<createTable name="outgoing_inventory" pkName="pk_outgoing_inventory">
|
||||
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||
<column name="deleted_on" type="localdatetime"/>
|
||||
<column name="deleted_by" type="varchar"/>
|
||||
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_outgoing_inventory_approval_status"/>
|
||||
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||
<column name="tenant_id" type="varchar" notnull="true"/>
|
||||
<column name="mrn" type="varchar" notnull="true"/>
|
||||
<column name="date" type="date"/>
|
||||
<column name="purpose" type="varchar"/>
|
||||
<column name="out_mode" type="varchar(7)" checkConstraint="check ( out_mode in ('PERSON','VEHICLE','ALL'))" checkConstraintName="ck_outgoing_inventory_out_mode"/>
|
||||
<column name="person" type="varchar"/>
|
||||
<column name="vehicle" type="varchar"/>
|
||||
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||
<column name="created_by" type="varchar" notnull="true"/>
|
||||
<column name="modified_by" type="varchar" notnull="true"/>
|
||||
</createTable>
|
||||
<addColumn tableName="product">
|
||||
<column name="type" type="varchar(12)" checkConstraint="check ( type in ('RAW_MATERIAL'))" checkConstraintName="ck_product_type"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="quotation">
|
||||
<column name="taxes_included" type="boolean"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</migration>
|
||||
11
src/main/resources/dbmigration/model/1.7.model.xml
Normal file
11
src/main/resources/dbmigration/model/1.7.model.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?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="vendor_bill_num" type="varchar"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
<changeSet type="pendingDrops">
|
||||
<dropColumn columnName="vendor_bil_num" tableName="incoming_inventory"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
16
src/main/resources/dbmigration/model/1.8.model.xml
Normal file
16
src/main/resources/dbmigration/model/1.8.model.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?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="mrn" type="varchar"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="outgoing_inventory">
|
||||
<column name="mdn" type="varchar"/>
|
||||
<column name="products" type="jsonb"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
<changeSet type="pendingDrops">
|
||||
<dropColumn columnName="mdn" tableName="incoming_inventory"/>
|
||||
<dropColumn columnName="mrn" tableName="outgoing_inventory"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply" dropsFor="1.5">
|
||||
<dropColumn columnName="ref_id" tableName="document"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
Loading…
x
Reference in New Issue
Block a user