Compare commits
1 Commits
7e8f70a7c2
...
Vinay
| Author | SHA1 | Date | |
|---|---|---|---|
| cfa3a7e289 |
Binary file not shown.
274
api.http
274
api.http
@@ -93,264 +93,50 @@ Authorization: {{auth-token}}
|
|||||||
DELETE http://localhost:9001/api/vehicle/KA01HD6667
|
DELETE http://localhost:9001/api/vehicle/KA01HD6667
|
||||||
Authorization: {{auth-token}}
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
### create vendor
|
### get products
|
||||||
POST http://localhost:9001/api/vendor/
|
GET http://localhost:9001/api/vendor/product
|
||||||
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
|
### get products by hsn code
|
||||||
|
GET http://localhost:9001/api/vendor/product/#123
|
||||||
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
|
### create excel for products
|
||||||
|
POST http://localhost:9001/api/vendor/product/product-excel
|
||||||
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
|
### excel read
|
||||||
|
GET http://localhost:9001/api/vendor/product/validation
|
||||||
|
Authorization: Bearer {{auth-token}}
|
||||||
|
|
||||||
|
### create product
|
||||||
|
POST http://localhost:9001/api/vendor/product
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: {{auth-token}}
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "arsalan",
|
"name": "Shirt",
|
||||||
"msme": "1234",
|
"description": "Black Shirt",
|
||||||
"gstNumber": "GST123",
|
"hsnCode": "BSM1XL"
|
||||||
"address": "Bangalore",
|
|
||||||
"rating": 2,
|
|
||||||
"contacts": [
|
|
||||||
{
|
|
||||||
"name": "contact1",
|
|
||||||
"email": "abc@cyz.com",
|
|
||||||
"mobile": "01234567890"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
### create batch vendor
|
### update field
|
||||||
POST http://localhost:9001/api/vendor/batch
|
PATCH http://localhost:9001/api/vendor/product/11
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: {{auth-token}}
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "john",
|
|
||||||
"description": "5678",
|
|
||||||
"hsnCode": "5678",
|
|
||||||
"gstNumber": "GST567",
|
|
||||||
"address": "Mumbai",
|
|
||||||
"rating": 4,
|
|
||||||
"contacts": [
|
|
||||||
{
|
|
||||||
"name": "contact1",
|
|
||||||
"email": "xyz@abc.com",
|
|
||||||
"phone": "9876543210"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "emma",
|
|
||||||
"description": "7890",
|
|
||||||
"hsnCode": "7890",
|
|
||||||
"gstNumber": "GST789",
|
|
||||||
"address": "Delhi",
|
|
||||||
"rating": 3,
|
|
||||||
"contacts": [
|
|
||||||
{
|
|
||||||
"name": "contact2",
|
|
||||||
"email": "def@uvw.com",
|
|
||||||
"phone": "8765432109"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "alex",
|
|
||||||
"description": "2345",
|
|
||||||
"hsnCode": "2345",
|
|
||||||
"gstNumber": "GST234",
|
|
||||||
"address": "Chennai",
|
|
||||||
"rating": 5,
|
|
||||||
"contacts": [
|
|
||||||
{
|
|
||||||
"name": "contact3",
|
|
||||||
"email": "ghi@rst.com",
|
|
||||||
"phone": "7654321098"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
### GET ALL VENDORS
|
### upate a row
|
||||||
POST http://localhost:9001/api/vendor/getAll
|
PUT http://localhost:9001/api/vendor/product/11
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: {{auth-token}}
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
{
|
|
||||||
"common": {
|
|
||||||
"sortAsc": true
|
|
||||||
},
|
|
||||||
"vendorFilters": {
|
|
||||||
"nameLike": "a"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
### create batch pos
|
### delete a row
|
||||||
POST http://localhost:9001/api/vendor/po/batch
|
DELETE http://localhost:9001/api/vendor/product/#1
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: {{auth-token}}
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
[
|
###
|
||||||
{
|
POST http://localhost:9001/api/vendor/product/import
|
||||||
"products": [
|
|
||||||
{
|
|
||||||
"productId": "1232",
|
|
||||||
"productName": "chair",
|
|
||||||
"unitPrice": 34.2,
|
|
||||||
"quantity": 10,
|
|
||||||
"description": "wooden chair"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"referenceQuotation": "12323",
|
|
||||||
"totalAmount": 342,
|
|
||||||
"poNum": "1",
|
|
||||||
"poDate": "2024-01-10",
|
|
||||||
"validTill": "2024-02-10",
|
|
||||||
"tnc": ["tnc1", "tnc2"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"products": [
|
|
||||||
{
|
|
||||||
"productId": "5678",
|
|
||||||
"productName": "table",
|
|
||||||
"unitPrice": 45.5,
|
|
||||||
"quantity": 5,
|
|
||||||
"description": "glass table"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"referenceQuotation": "56789",
|
|
||||||
"totalAmount": 227.5,
|
|
||||||
"poNum": "2",
|
|
||||||
"poDate": "2024-10-25",
|
|
||||||
"validTill": "2024-10-25",
|
|
||||||
"tnc": ["tnc3", "tnc4"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"products": [
|
|
||||||
{
|
|
||||||
"productId": "91011",
|
|
||||||
"productName": "lamp",
|
|
||||||
"unitPrice": 15.75,
|
|
||||||
"quantity": 20,
|
|
||||||
"description": "floor lamp"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"referenceQuotation": "9101112",
|
|
||||||
"totalAmount": 315,
|
|
||||||
"poNum": "3",
|
|
||||||
"poDate": "2024-10-25",
|
|
||||||
"validTill": "2024-12-25",
|
|
||||||
"tnc": ["tnc5", "tnc6"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
### GET ALL POS
|
|
||||||
POST http://localhost:9001/api/vendor/po/getAll
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
{
|
|
||||||
"common" : {},
|
|
||||||
"poFilters": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
### CREATE QUOTES
|
|
||||||
POST http://localhost:9001/api/vendor/quote/batch
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"products": [
|
|
||||||
{
|
|
||||||
"productId": "1232",
|
|
||||||
"productName": "chair",
|
|
||||||
"unitPrice": 34.2,
|
|
||||||
"quantity": 10,
|
|
||||||
"description": "wooden chair"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"reqForQuoteNum": "12323",
|
|
||||||
"totalAmount": 342,
|
|
||||||
"quoteNum": "1",
|
|
||||||
"quoteDate": "2024-10-24",
|
|
||||||
"validTill": "2024-11-24",
|
|
||||||
"tnc": ["tnc1", "tnc2"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"products": [
|
|
||||||
{
|
|
||||||
"productId": "5678",
|
|
||||||
"productName": "table",
|
|
||||||
"unitPrice": 45.5,
|
|
||||||
"quantity": 5,
|
|
||||||
"description": "glass table"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"reqForQuoteNum": "56789",
|
|
||||||
"totalAmount": 227.5,
|
|
||||||
"quoteNum": "2",
|
|
||||||
"quoteDate": "2024-10-25",
|
|
||||||
"validTill": "2024-11-25",
|
|
||||||
"tnc": ["tnc3", "tnc4"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"products": [
|
|
||||||
{
|
|
||||||
"productId": "91011",
|
|
||||||
"productName": "lamp",
|
|
||||||
"unitPrice": 15.75,
|
|
||||||
"quantity": 20,
|
|
||||||
"description": "floor lamp"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"reqForQuoteNum": "9101112",
|
|
||||||
"totalAmount": 315,
|
|
||||||
"quoteNum": "3",
|
|
||||||
"quoteDate": "2024-10-25",
|
|
||||||
"validTill": "2024-12-25",
|
|
||||||
"tnc": ["tnc5", "tnc6"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
### GET ALL QUOTES
|
|
||||||
POST http://localhost:9001/api/vendor/quote/getAll
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
{
|
|
||||||
"common" : {},
|
|
||||||
"quoteFilters": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
### CREATE PRODUCT
|
|
||||||
POST http://localhost:9001/api/vendor/product/create
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
{
|
|
||||||
"name" : "aa",
|
|
||||||
"description": "aa",
|
|
||||||
"hsnCode" : "aa",
|
|
||||||
"uom": "NOS"
|
|
||||||
}
|
|
||||||
|
|
||||||
### GET ALL PRODUCTS
|
|
||||||
GET http://localhost:9001/api/vendor/product/getAll
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
### GET PRODUCT BY KEY
|
|
||||||
GET http://localhost:9001/api/vendor/product/of/6
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
### GET PRODUCT BY HSNCODE
|
|
||||||
DELETE http://localhost:9001/api/vendor/product/3
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
### PRODUCT EXCEl
|
|
||||||
GET http://localhost:9001/api/vendor/product/to/excel
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
### EXCEL VALIDATE
|
|
||||||
GET http://localhost:9001/api/vendor/product/valid/excel
|
|
||||||
Authorization: {{auth-token}}
|
|
||||||
|
|
||||||
### EXCEL TO DB (IMPORT)
|
|
||||||
POST http://localhost:9001/api/vendor/product/excelToDb
|
|
||||||
Authorization: {{auth-token}}
|
Authorization: {{auth-token}}
|
||||||
@@ -38,7 +38,6 @@ dependencies {
|
|||||||
implementation("org.apache.httpcomponents:httpclient:4.5.14")
|
implementation("org.apache.httpcomponents:httpclient:4.5.14")
|
||||||
implementation("org.apache.poi:poi:5.2.3")
|
implementation("org.apache.poi:poi:5.2.3")
|
||||||
implementation("org.apache.poi:poi-ooxml:5.2.3")
|
implementation("org.apache.poi:poi-ooxml:5.2.3")
|
||||||
implementation("com.google.code.gson:gson:2.8.8")
|
|
||||||
api ("net.cactusthorn.config:config-core:0.81")
|
api ("net.cactusthorn.config:config-core:0.81")
|
||||||
api ("net.cactusthorn.config:config-yaml:0.81")
|
api ("net.cactusthorn.config:config-yaml:0.81")
|
||||||
kapt("net.cactusthorn.config:config-compiler:0.81")
|
kapt("net.cactusthorn.config:config-compiler:0.81")
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import io.javalin.Javalin
|
|||||||
import io.javalin.apibuilder.ApiBuilder.*
|
import io.javalin.apibuilder.ApiBuilder.*
|
||||||
import io.javalin.http.ContentType
|
import io.javalin.http.ContentType
|
||||||
import io.javalin.http.Context
|
import io.javalin.http.Context
|
||||||
import io.javalin.http.HandlerType
|
|
||||||
import io.javalin.http.UnauthorizedResponse
|
import io.javalin.http.UnauthorizedResponse
|
||||||
import io.javalin.http.util.NaiveRateLimit
|
import io.javalin.http.util.NaiveRateLimit
|
||||||
import io.javalin.http.util.RateLimitUtil
|
import io.javalin.http.util.RateLimitUtil
|
||||||
@@ -33,6 +32,7 @@ import java.util.*
|
|||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlin.jvm.optionals.getOrDefault
|
import kotlin.jvm.optionals.getOrDefault
|
||||||
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val logger = LoggerFactory.getLogger("api")
|
val logger = LoggerFactory.getLogger("api")
|
||||||
val adminRole = Role.Standard(Action.ADMIN)
|
val adminRole = Role.Standard(Action.ADMIN)
|
||||||
@@ -80,8 +80,6 @@ fun main(args: Array<String>) {
|
|||||||
TimeUnit.MINUTES
|
TimeUnit.MINUTES
|
||||||
)
|
)
|
||||||
|
|
||||||
if(ctx.method() == HandlerType.OPTIONS) return@before
|
|
||||||
|
|
||||||
val authToken = ctx.getAuthHeader() ?: throw UnauthorizedResponse()
|
val authToken = ctx.getAuthHeader() ?: throw UnauthorizedResponse()
|
||||||
|
|
||||||
|
|
||||||
@@ -117,54 +115,125 @@ fun main(args: Array<String>) {
|
|||||||
|
|
||||||
path("/vendor") {
|
path("/vendor") {
|
||||||
path("/") {
|
path("/") {
|
||||||
post("", VendorCtrl::create, Roles(Role.Explicit(listOf("ROLE_VENDOR_CREATE", "ROLE_ADMIN"))))
|
post("", Vendor::create, Roles(Role.Explicit(listOf("ROLE_VENDOR_CREATE", "ROLE_ADMIN"))))
|
||||||
post("/batch", VendorCtrl::createBatch, Roles(Role.Explicit(listOf("ROLE_VENDOR_CREATE", "ROLE_ADMIN"))))
|
get(
|
||||||
get("/{id}", VendorCtrl::get, Roles(Role.Explicit(listOf("ROLE_VENDOR_VIEW", "ROLE_VENDOR_CREATE", "ROLE_ADMIN"))))
|
"",
|
||||||
post("/getAll", VendorCtrl::getAll, Roles(Role.Explicit(listOf("ROLE_VENDOR_VIEW", "ROLE_VENDOR_CREATE"))))
|
Vendor::get,
|
||||||
get("quotes/{id}", VendorCtrl::getQuotes, Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_QUOTE_VIEW", "ROLE_QUOTE_CREATE", "ROLE_VENDOR_VIEW"))))
|
Roles(Role.Explicit(listOf("ROLE_VENDOR_VIEW", "ROLE_VENDOR_CREATE", "ROLE_ADMIN")))
|
||||||
get("pos/{id}", VendorCtrl::getPos, Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_PO_VIEW", "ROLE_PO_CREATE`"))))
|
)
|
||||||
put("/rate/{id}/{rating}", VendorCtrl::rate, Roles(Role.Explicit(listOf("ROLE_VENDOR_CREATE"))))
|
get(
|
||||||
|
"quotes/{id}",
|
||||||
|
Vendor::getQuotes,
|
||||||
|
Roles(
|
||||||
|
Role.Explicit(
|
||||||
|
listOf(
|
||||||
|
"ROLE_ADMIN",
|
||||||
|
"ROLE_QUOTE_VIEW",
|
||||||
|
"ROLE_QUOTE_CREATE",
|
||||||
|
"ROLE_VENDOR_VIEW"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
get(
|
||||||
|
"pos/{id}",
|
||||||
|
Vendor::getPos,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_PO_VIEW", "ROLE_PO_CREATE`")))
|
||||||
|
)
|
||||||
|
put("/rate/{id}/{rating}", Vendor::rate, Roles(Role.Explicit(listOf("ROLE_VENDOR_CREATE"))))
|
||||||
}
|
}
|
||||||
path("/po") {
|
path("/po") {
|
||||||
post("", PurchaseOrderCtrl::create, Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_ADMIN"))))
|
post("", PurchaseOrder::create, Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_ADMIN"))))
|
||||||
post("/batch", PurchaseOrderCtrl::createBatch, Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_VENDOR_CREATE", "ROLE_ADMIN"))))
|
get(
|
||||||
post("/getAll", PurchaseOrderCtrl::getAll, Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_PO_CREATE", "ROLE_VENDOR_CREATE", "ROLE_ADMIN"))))
|
"/{id}",
|
||||||
get("/{id}", PurchaseOrderCtrl::get, Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_PO_VIEW", "ROLE_QUOTE_CREATE"))))
|
PurchaseOrder::get,
|
||||||
put("/approve/{id}", PurchaseOrderCtrl::approve, Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_APPROVE"))))
|
Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_PO_VIEW", "ROLE_QUOTE_CREATE")))
|
||||||
put("/reject/{id}", PurchaseOrderCtrl::reject, Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_APPROVE"))))
|
)
|
||||||
get("/refQuote/{id}", PurchaseOrderCtrl::quoteReference, Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_PO_VIEW"))))
|
put(
|
||||||
|
"/approve/{id}",
|
||||||
|
PurchaseOrder::approve,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_APPROVE")))
|
||||||
|
)
|
||||||
|
put(
|
||||||
|
"/reject/{id}",
|
||||||
|
PurchaseOrder::reject,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_APPROVE")))
|
||||||
|
)
|
||||||
|
get(
|
||||||
|
"/refQuote/{id}",
|
||||||
|
PurchaseOrder::quoteReference,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_PO_VIEW")))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
path("/quote") {
|
path("/quote") {
|
||||||
post("", QuotationCtrl::create, Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_ADMIN"))))
|
post("", Quotation::create, Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_ADMIN"))))
|
||||||
post("/batch", QuotationCtrl::createBatch, Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_ADMIN", "ROLE_VENDOR_CREATE"))))
|
get(
|
||||||
post("/getAll", QuotationCtrl::getAll, Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_ADMIN", "ROLE_VENDOR_CREATE"))))
|
"/{id}",
|
||||||
get("/{id}", QuotationCtrl::get, Roles(Role.Explicit(listOf("ROLE_QUOTE_VIEW", "ROLE_ADMIN", "ROLE_PO_CREATE", "ROLE_QUOTE_CREATE"))))
|
Quotation::get,
|
||||||
get("/po/{id}", QuotationCtrl::generatePO, Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_PO_CRETE"))))
|
Roles(
|
||||||
get("/rfq/{rfqNum}", QuotationCtrl::reqForQuote, Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_QUOTE_VIEW"))))
|
Role.Explicit(
|
||||||
delete("/{id}", QuotationCtrl::delete, Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_ADMIN"))))
|
listOf(
|
||||||
|
"ROLE_QUOTE_VIEW",
|
||||||
|
"ROLE_ADMIN",
|
||||||
|
"ROLE_PO_CREATE",
|
||||||
|
"ROLE_QUOTE_CREATE"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
get(
|
||||||
|
"/po/{id}",
|
||||||
|
Quotation::generatePO,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_PO_CRETE")))
|
||||||
|
)
|
||||||
|
get(
|
||||||
|
"/rfq/{rfqNum}",
|
||||||
|
Quotation::reqForQuote,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_QUOTE_VIEW")))
|
||||||
|
)
|
||||||
|
delete(
|
||||||
|
"/{id}",
|
||||||
|
Quotation::delete,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_ADMIN")))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
path("/product") {
|
path("/product") {
|
||||||
post("/create", ProductCtrl::create, Roles(Role.Explicit(listOf("ROLE_PRODUCT_CREATE", "ROLE_ADMIN"))))
|
post("", ProductCtrl::create, Roles(Role.Explicit(listOf("ROLE_PRODUCT_CREATE", "ROLE_ADMIN"))))
|
||||||
get("/getAll", ProductCtrl::getAll, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN"))))
|
get("/{hsnCode}", ProductCtrl::get, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN"))))
|
||||||
get("/of/{key}", ProductCtrl::get, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN"))))
|
|
||||||
put("/{id}", ProductCtrl::update, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN"))))
|
|
||||||
patch("/{id}", ProductCtrl::patch, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN"))))
|
patch("/{id}", ProductCtrl::patch, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN"))))
|
||||||
|
put("/{id}", ProductCtrl::update, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN"))))
|
||||||
delete("/{id}", ProductCtrl::delete, Roles(Role.Explicit(listOf("ROLE_PRODUCT_DELETE", "ROLE_ADMIN"))))
|
delete("/{id}", ProductCtrl::delete, Roles(Role.Explicit(listOf("ROLE_PRODUCT_DELETE", "ROLE_ADMIN"))))
|
||||||
get("/to/excel", ProductCtrl::prodExcel)
|
get("", ProductCtrl::getAll, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN"))))
|
||||||
get("/valid/excel") { ctx -> ctx.json(ExcelRead()) }
|
post("/product-excel", ProductCtrl::prodExcel)
|
||||||
post("/excelToDb") {ctx -> ctx.json(excelToDb())}
|
post("/import") {ctx -> ctx.json(excelToDb())}
|
||||||
}
|
}
|
||||||
path("/doc") {
|
path("/doc") {
|
||||||
post("", Document::create, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE", "ROLE_ADMIN"))))
|
post("", Document::create, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE", "ROLE_ADMIN"))))
|
||||||
//why type and refid are clubbed ??
|
//why type and refid are clubbed ??
|
||||||
get("/{type}/{refId}", Document::getWithRefId, Roles(Role.Explicit(listOf("ROLE_DOC_VIEW", "ROLE_ADMIN", "ROLE_PRODUCT_CREATE"))))
|
get(
|
||||||
get("/{id}", Document::get, Roles(Role.Explicit(listOf("ROLE_DOC_VIEW", "ROLE_ADMIN", "ROLE_PRODUCT_CREATE"))))
|
"/{type}/{refId}",
|
||||||
get("/print/{id}", Document::print, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE", "ROLE_DOC_VIEW"))))
|
Document::getWithRefId,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_DOC_VIEW", "ROLE_ADMIN", "ROLE_PRODUCT_CREATE")))
|
||||||
|
)
|
||||||
|
get(
|
||||||
|
"/{id}",
|
||||||
|
Document::get,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_DOC_VIEW", "ROLE_ADMIN", "ROLE_PRODUCT_CREATE")))
|
||||||
|
)
|
||||||
|
get(
|
||||||
|
"/print/{id}",
|
||||||
|
Document::print,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_DOC_CREATE", "ROLE_DOC_VIEW")))
|
||||||
|
)
|
||||||
delete("/{id}", Document::delete, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE"))))
|
delete("/{id}", Document::delete, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE"))))
|
||||||
}
|
}
|
||||||
path("/reqForQuote") {
|
path("/reqForQuote") {
|
||||||
post("", RequestForQuote::create, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
|
post("", RequestForQuote::create, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
|
||||||
get("/{id}", RequestForQuote::get, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE", "ROLE_RFQ_VIEW"))))
|
get(
|
||||||
|
"/{id}",
|
||||||
|
RequestForQuote::get,
|
||||||
|
Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE", "ROLE_RFQ_VIEW")))
|
||||||
|
)
|
||||||
put("/{id}", RequestForQuote::update, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
|
put("/{id}", RequestForQuote::update, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import com.restapi.integ.Scripting
|
|||||||
import io.ebean.CallableSql
|
import io.ebean.CallableSql
|
||||||
import io.ebean.RawSqlBuilder
|
import io.ebean.RawSqlBuilder
|
||||||
import io.javalin.http.*
|
import io.javalin.http.*
|
||||||
|
import org.apache.poi.ss.usermodel.Cell
|
||||||
|
import org.apache.poi.ss.usermodel.CellType
|
||||||
import org.apache.poi.ss.usermodel.WorkbookFactory
|
import org.apache.poi.ss.usermodel.WorkbookFactory
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -377,47 +379,25 @@ object Entities {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data class Filters(val common :CommonFilters, val custom :CustomFilters)
|
|
||||||
data class BatchPos(val pos :List<PurchaseOrder>)
|
object PurchaseOrder {
|
||||||
object PurchaseOrderCtrl {
|
|
||||||
fun get(ctx :Context){
|
fun get(ctx :Context){
|
||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val po = database.find(PurchaseOrder::class.java, id) ?: throw NotFoundResponse("po not found for $id")
|
val po = database.find(PurchaseOrder::class.java, id) ?: throw NotFoundResponse("po not found for $id")
|
||||||
ctx.json(po).status(HttpStatus.OK)
|
|
||||||
}
|
ctx.json(po)
|
||||||
data class PF(val common: CommonFilters, val poFilters: POFilters)
|
|
||||||
fun getAll(ctx :Context){
|
|
||||||
val filters = ctx.bodyAsClass<PF>()
|
|
||||||
val pos = searchPos(filters.common, filters.poFilters)
|
|
||||||
ctx.json(pos).status(HttpStatus.OK)
|
|
||||||
}
|
}
|
||||||
fun create(ctx :Context){
|
fun create(ctx :Context){
|
||||||
val po = ctx.bodyAsClass<PurchaseOrder>()
|
val po = ctx.bodyAsClass<PurchaseOrder>()
|
||||||
database.save(po)
|
database.save(po)
|
||||||
ctx.json(po).status(HttpStatus.CREATED)
|
ctx.result("po created")
|
||||||
}
|
|
||||||
fun createBatch(ctx :Context){
|
|
||||||
val pos = ctx.bodyAsClass<List<PurchaseOrder>>()
|
|
||||||
val txn = database.beginTransaction()
|
|
||||||
try {
|
|
||||||
txn.isBatchMode = true
|
|
||||||
for(po in pos) database.save(po)
|
|
||||||
txn.commit()
|
|
||||||
ctx.status(HttpStatus.CREATED).result("POS Created")
|
|
||||||
} catch(e :Exception){
|
|
||||||
txn.rollback()
|
|
||||||
ctx.status(HttpStatus.INTERNAL_SERVER_ERROR).result("Pos Creation failed" + e.message)
|
|
||||||
} finally {
|
|
||||||
txn.end()
|
|
||||||
}
|
|
||||||
ctx.result("pos batch created").status(HttpStatus.CREATED)
|
|
||||||
}
|
}
|
||||||
fun approve(ctx :Context){
|
fun approve(ctx :Context){
|
||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val po = database.find(PurchaseOrder::class.java, id) ?: throw NotFoundResponse("po not found for $id")
|
val po = database.find(PurchaseOrder::class.java, id) ?: throw NotFoundResponse("po not found for $id")
|
||||||
po.approvalStatus = ApprovalStatus.APPROVED
|
po.approvalStatus = ApprovalStatus.APPROVED
|
||||||
po.save()
|
po.save()
|
||||||
ctx.json(po).status(HttpStatus.CREATED)
|
ctx.result("po with id $id approved")
|
||||||
//reject all other pos pertaining to the same tx ??
|
//reject all other pos pertaining to the same tx ??
|
||||||
}
|
}
|
||||||
fun reject(ctx :Context){
|
fun reject(ctx :Context){
|
||||||
@@ -425,7 +405,7 @@ object PurchaseOrderCtrl {
|
|||||||
val po = database.find(PurchaseOrder::class.java, id) ?: throw NotFoundResponse("po not found for $id")
|
val po = database.find(PurchaseOrder::class.java, id) ?: throw NotFoundResponse("po not found for $id")
|
||||||
po.approvalStatus = ApprovalStatus.REJECTED
|
po.approvalStatus = ApprovalStatus.REJECTED
|
||||||
po.save()
|
po.save()
|
||||||
ctx.json(po).status(HttpStatus.CREATED)
|
ctx.result("po with id $id rejected")
|
||||||
}
|
}
|
||||||
fun quoteReference(ctx :Context){
|
fun quoteReference(ctx :Context){
|
||||||
//gets the quote reference on which this po is based on
|
//gets the quote reference on which this po is based on
|
||||||
@@ -444,27 +424,26 @@ data class ProductSearch(
|
|||||||
|
|
||||||
object ProductCtrl {
|
object ProductCtrl {
|
||||||
fun get(ctx :Context){
|
fun get(ctx :Context){
|
||||||
val key = ctx.pathParam("key")
|
val hsnCode = ctx.pathParam("hsnCode")
|
||||||
val product = database.find(Product::class.java, key) ?: throw NotFoundResponse("Product not found for $key")
|
val product = database.find(Product::class.java, hsnCode) ?: throw NotFoundResponse("Product not found for $hsnCode")
|
||||||
|
|
||||||
ctx.json(product)
|
ctx.json(product)
|
||||||
}
|
}
|
||||||
fun getAll(ctx: Context){
|
fun getAll(ctx: Context){
|
||||||
val productList = database.find(Product::class.java)
|
val productList = Session.database.find(Product::class.java)
|
||||||
.findList()
|
.findList()
|
||||||
//.removeAt(4)
|
//.sortedBy { it.hsnCode }
|
||||||
|
|
||||||
ctx.json(productList)
|
ctx.json(productList)
|
||||||
}
|
}
|
||||||
fun create(ctx :Context){
|
fun create(ctx :Context){
|
||||||
val product = ctx.bodyAsClass<Product>()
|
val product = ctx.bodyAsClass<Product>()
|
||||||
database.save(product)
|
database.save(product)
|
||||||
ctx.json(product).status(HttpStatus.CREATED)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun delete(ctx: Context) {
|
fun delete(ctx: Context) {
|
||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val product = database.deletePermanent(Product::class.java,id)
|
val product = database.delete(Product::class.java, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun patch(ctx: Context) {
|
fun patch(ctx: Context) {
|
||||||
@@ -472,7 +451,7 @@ object ProductCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun update(ctx: Context) {
|
fun update(ctx: Context) {
|
||||||
//have to implement
|
|
||||||
}
|
}
|
||||||
fun prodExcel(it: Context) {
|
fun prodExcel(it: Context) {
|
||||||
val product = database.find(Product::class.java).findList()
|
val product = database.find(Product::class.java).findList()
|
||||||
@@ -480,49 +459,14 @@ object ProductCtrl {
|
|||||||
.header("Content-Disposition", "attachment; filename=\"product.xlsx\"")
|
.header("Content-Disposition", "attachment; filename=\"product.xlsx\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ProductList(
|
|
||||||
val name: String,
|
|
||||||
val description: String,
|
|
||||||
val hsnCode: String,
|
|
||||||
val uom: String?,
|
|
||||||
)
|
|
||||||
|
|
||||||
fun excelToDb(it: Context){
|
|
||||||
val inputStream = FileInputStream("C:\\Users\\vinay\\IdeaProjects\\readymixerp_modules_api_git\\Untitled 1.xlsx")
|
|
||||||
val workbook = WorkbookFactory.create(inputStream)
|
|
||||||
val workSheet = workbook.getSheetAt(0)
|
|
||||||
|
|
||||||
val dataList = mutableListOf<ProductList>()
|
|
||||||
|
|
||||||
for (row in workSheet) {
|
|
||||||
val cell1Value = row.getCell(0).stringCellValue
|
|
||||||
val cell2Value = row.getCell(1).stringCellValue
|
|
||||||
val cell3Value = row.getCell(2).stringCellValue
|
|
||||||
val cell4Value = row.getCell(3).stringCellValue
|
|
||||||
|
|
||||||
val data = ProductList(cell1Value, cell2Value, cell3Value, cell4Value)
|
|
||||||
dataList.add(data)
|
|
||||||
|
|
||||||
}
|
|
||||||
database.saveAll(dataList)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
object Quotation {
|
||||||
|
|
||||||
object QuotationCtrl {
|
|
||||||
fun get(ctx :Context){
|
fun get(ctx :Context){
|
||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val quote = database.find(Quotation::class.java, id) ?: throw NotFoundResponse("quote not found for $id")
|
val quote = database.find(Quotation::class.java, id) ?: throw NotFoundResponse("quote not found for $id")
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(quote)
|
ctx.json(quote)
|
||||||
}
|
}
|
||||||
data class QF(val common: CommonFilters, val quoteFilters: QuoteFilters)
|
|
||||||
fun getAll(ctx :Context){
|
|
||||||
val filters = ctx.bodyAsClass<QF>()
|
|
||||||
val quotes = searchQuotes(filters.common, filters.quoteFilters)
|
|
||||||
ctx.json(quotes).status(HttpStatus.OK)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create(ctx :Context){
|
fun create(ctx :Context){
|
||||||
val quote = ctx.bodyAsClass<Quotation>()
|
val quote = ctx.bodyAsClass<Quotation>()
|
||||||
//we have to check if the quotation created date is below the expiry of rfq
|
//we have to check if the quotation created date is below the expiry of rfq
|
||||||
@@ -535,44 +479,25 @@ object QuotationCtrl {
|
|||||||
if(quote.quoteDate!! <= rfq.openTill) {
|
if(quote.quoteDate!! <= rfq.openTill) {
|
||||||
//valid
|
//valid
|
||||||
database.save(quote)
|
database.save(quote)
|
||||||
ctx.status(HttpStatus.CREATED)
|
ctx.result("quote created")
|
||||||
ctx.json(quote)
|
|
||||||
}else {
|
}else {
|
||||||
ctx.status(HttpStatus.BAD_REQUEST)
|
|
||||||
ctx.result("request for quote closed")
|
ctx.result("request for quote closed")
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
throw NotFoundResponse("request for quote not found for this quotation")
|
throw NotFoundResponse("request for quote not found for this quotation")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
fun createBatch(ctx :Context){
|
|
||||||
val quotes = ctx.bodyAsClass<List<Quotation>>()
|
|
||||||
val txn = database.beginTransaction()
|
|
||||||
try {
|
|
||||||
txn.isBatchMode = true
|
|
||||||
for(quote in quotes) database.save(quote)
|
|
||||||
txn.commit()
|
|
||||||
ctx.status(HttpStatus.CREATED).result("Quotes Created")
|
|
||||||
} catch(e :Exception){
|
|
||||||
txn.rollback()
|
|
||||||
ctx.status(HttpStatus.INTERNAL_SERVER_ERROR).result("Quotes Creation failed" + e.message)
|
|
||||||
} finally {
|
|
||||||
txn.end()
|
|
||||||
}
|
|
||||||
ctx.result("Quotes batch created").status(HttpStatus.CREATED)
|
|
||||||
}
|
}
|
||||||
fun delete(ctx :Context){
|
fun delete(ctx :Context){
|
||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val quote = database.find(Quotation::class.java, id) ?: throw NotFoundResponse("quote not found for id $id")
|
val quote = database.find(Quotation::class.java, id) ?: throw NotFoundResponse("quote not found for id $id")
|
||||||
quote.delete()
|
quote.delete()
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.result("quote with $id deleted")
|
ctx.result("quote with $id deleted")
|
||||||
}
|
}
|
||||||
fun generatePO(ctx :Context){
|
fun generatePO(ctx :Context){
|
||||||
//user should be redirected to a po form submission with prefilled values
|
//user should be redirected to a po form submission with prefilled values
|
||||||
//create a PO object with values from the quote and then send it as body to vendor/po/create ??
|
//create a PO object with values from the quote and then send it as body to vendor/po/create ??
|
||||||
|
|
||||||
}
|
}
|
||||||
fun reqForQuote(ctx :Context){
|
fun reqForQuote(ctx :Context){
|
||||||
val reqForQuoteNum = ctx.pathParam(("rfqNum"))
|
val reqForQuoteNum = ctx.pathParam(("rfqNum"))
|
||||||
@@ -580,7 +505,6 @@ object QuotationCtrl {
|
|||||||
.where()
|
.where()
|
||||||
.eq("reqForQuoteNum", reqForQuoteNum)
|
.eq("reqForQuoteNum", reqForQuoteNum)
|
||||||
?: throw NotFoundResponse("request for quote not found for this quotation")
|
?: throw NotFoundResponse("request for quote not found for this quotation")
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(rfq)
|
ctx.json(rfq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,14 +512,12 @@ object Document {
|
|||||||
fun get(ctx :Context){
|
fun get(ctx :Context){
|
||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val doc = database.find(Document::class.java, id) ?: throw NotFoundResponse("no doc found with id $id")
|
val doc = database.find(Document::class.java, id) ?: throw NotFoundResponse("no doc found with id $id")
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(doc)
|
ctx.json(doc)
|
||||||
}
|
}
|
||||||
fun create(ctx :Context){
|
fun create(ctx :Context){
|
||||||
val doc = ctx.bodyAsClass<Document>()
|
val doc = ctx.bodyAsClass<Document>()
|
||||||
database.save(doc)
|
database.save(doc)
|
||||||
ctx.status(HttpStatus.CREATED)
|
ctx.result("doc created")
|
||||||
ctx.json(doc)
|
|
||||||
}
|
}
|
||||||
fun print(ctx :Context){
|
fun print(ctx :Context){
|
||||||
//would be handled in the frontend ??
|
//would be handled in the frontend ??
|
||||||
@@ -604,8 +526,7 @@ object Document {
|
|||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val doc = database.find(Document::class.java, id) ?: throw NotFoundResponse("no doc found with id $id")
|
val doc = database.find(Document::class.java, id) ?: throw NotFoundResponse("no doc found with id $id")
|
||||||
//doc.delete()
|
//doc.delete()
|
||||||
ctx.status(HttpStatus.OK)
|
ctx.result("document deleted")
|
||||||
ctx.result("document deleted with id $id")
|
|
||||||
}
|
}
|
||||||
fun getWithRefId(ctx :Context){
|
fun getWithRefId(ctx :Context){
|
||||||
//fetches a particular doc (po, quote) with ref id
|
//fetches a particular doc (po, quote) with ref id
|
||||||
@@ -614,47 +535,20 @@ object Document {
|
|||||||
.where()
|
.where()
|
||||||
.eq("refId", refId)
|
.eq("refId", refId)
|
||||||
?: throw NotFoundResponse("no doc found for refId $refId")
|
?: throw NotFoundResponse("no doc found for refId $refId")
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(doc)
|
ctx.json(doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
object VendorCtrl {
|
object Vendor {
|
||||||
fun get(ctx :Context){
|
fun get(ctx :Context){
|
||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val vendor = database.find(Vendor::class.java, id) ?: throw NotFoundResponse("no vendor found with id $id")
|
val vendor = database.find(Vendor::class.java, id) ?: throw NotFoundResponse("no vendor found with id $id")
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(vendor)
|
ctx.json(vendor)
|
||||||
}
|
}
|
||||||
data class VF(val common : CommonFilters, val vendorFilters: VendorFilters)
|
|
||||||
fun getAll(ctx :Context){
|
|
||||||
val filters = ctx.bodyAsClass<VF>()
|
|
||||||
println(filters.common)
|
|
||||||
println(filters.vendorFilters)
|
|
||||||
val pos = searchVendors(filters.common, filters.vendorFilters)
|
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(pos)
|
|
||||||
}
|
|
||||||
fun createBatch(ctx: Context){
|
|
||||||
val vendors = ctx.bodyAsClass<List<Vendor>>()
|
|
||||||
val txn = database.beginTransaction()
|
|
||||||
try {
|
|
||||||
txn.isBatchMode = true
|
|
||||||
for(v in vendors) database.save(v)
|
|
||||||
txn.commit()
|
|
||||||
ctx.status(HttpStatus.CREATED).result("Vendors Created")
|
|
||||||
} catch(e :Exception){
|
|
||||||
txn.rollback()
|
|
||||||
ctx.status(HttpStatus.INTERNAL_SERVER_ERROR).result("Vendor Creation failed" + e.message)
|
|
||||||
} finally {
|
|
||||||
txn.end()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun create(ctx :Context){
|
fun create(ctx :Context){
|
||||||
val vendor = ctx.bodyAsClass<Vendor>()
|
val vendor = ctx.bodyAsClass<Vendor>()
|
||||||
database.save(vendor)
|
database.save(vendor)
|
||||||
ctx.status(HttpStatus.CREATED)
|
ctx.result("vendor created")
|
||||||
ctx.json(vendor)
|
|
||||||
}
|
}
|
||||||
fun update(ctx :Context){
|
fun update(ctx :Context){
|
||||||
|
|
||||||
@@ -668,7 +562,6 @@ object VendorCtrl {
|
|||||||
.where()
|
.where()
|
||||||
.eq("vendor", id)
|
.eq("vendor", id)
|
||||||
.findList()
|
.findList()
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(quotes)
|
ctx.json(quotes)
|
||||||
}
|
}
|
||||||
fun getPos(ctx :Context){
|
fun getPos(ctx :Context){
|
||||||
@@ -677,7 +570,6 @@ object VendorCtrl {
|
|||||||
.where()
|
.where()
|
||||||
.eq("vendor", id)
|
.eq("vendor", id)
|
||||||
.findList()
|
.findList()
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(pos)
|
ctx.json(pos)
|
||||||
}
|
}
|
||||||
fun rate(ctx :Context){
|
fun rate(ctx :Context){
|
||||||
@@ -687,7 +579,6 @@ object VendorCtrl {
|
|||||||
//could place some rating validation checks
|
//could place some rating validation checks
|
||||||
vendor.rating = rating
|
vendor.rating = rating
|
||||||
vendor.save()
|
vendor.save()
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.result("rating changed")
|
ctx.result("rating changed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -697,18 +588,14 @@ object RequestForQuote {
|
|||||||
database.save(rfq)
|
database.save(rfq)
|
||||||
//ctx.result("request for quote created")
|
//ctx.result("request for quote created")
|
||||||
//ctx.json(rfq)
|
//ctx.json(rfq)
|
||||||
ctx.status(HttpStatus.CREATED)
|
//ctx.status(HttpStatus.CREATED)
|
||||||
ctx.json("asss")
|
//ctx.json("asss")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun get(ctx :Context){
|
fun get(ctx :Context){
|
||||||
val id = ctx.pathParam("id")
|
val id = ctx.pathParam("id")
|
||||||
val rfq = database.find(ReqForQuote::class.java, id)
|
val rfq = database.find(ReqForQuote::class.java, id) ?: throw NotFoundResponse("request for quote not found for id $id")
|
||||||
?: throw NotFoundResponse("request for quote not found for id $id")
|
|
||||||
ctx.status(HttpStatus.OK)
|
|
||||||
ctx.json(rfq)
|
ctx.json(rfq)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(ctx :Context){
|
fun update(ctx :Context){
|
||||||
//shuld we compare the new body fields with preexisting ones and prepare a sql query to update those fields??
|
//shuld we compare the new body fields with preexisting ones and prepare a sql query to update those fields??
|
||||||
|
|
||||||
|
|||||||
@@ -1,419 +1,51 @@
|
|||||||
package com.restapi.controllers
|
package com.restapi.controllers
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import com.google.gson.Gson
|
import com.restapi.domain.Product
|
||||||
import com.restapi.domain.*
|
import com.restapi.domain.Session
|
||||||
import com.restapi.domain.Document
|
|
||||||
import com.restapi.domain.PurchaseOrder
|
|
||||||
import com.restapi.domain.Quotation
|
|
||||||
import com.restapi.domain.Session.currentUser
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook
|
|
||||||
import com.restapi.domain.Session.database
|
import com.restapi.domain.Session.database
|
||||||
import com.restapi.domain.Vendor
|
import com.restapi.domain.UOM
|
||||||
import org.apache.poi.hssf.usermodel.DVConstraint
|
import io.ebean.text.json.JsonContext
|
||||||
import org.apache.poi.hssf.usermodel.HSSFDataValidation
|
import io.javalin.http.Context
|
||||||
import org.apache.poi.ss.usermodel.*
|
import org.apache.poi.ss.usermodel.Cell
|
||||||
import org.apache.poi.ss.util.CellRangeAddressList
|
import org.apache.poi.ss.usermodel.CellType
|
||||||
|
import org.apache.poi.ss.usermodel.Row
|
||||||
|
import org.apache.poi.ss.usermodel.WorkbookFactory
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||||
import java.io.*
|
import java.io.ByteArrayInputStream
|
||||||
import java.text.SimpleDateFormat
|
import java.io.ByteArrayOutputStream
|
||||||
import java.time.LocalDate
|
import java.io.FileInputStream
|
||||||
import java.time.ZoneId
|
import java.io.InputStream
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
fun createHeaderRow(cols :List<String>, sh :HSSFSheet, wb: Workbook) {
|
fun CreateExcel(productList: List<Product>): InputStream {
|
||||||
val boldFont = wb.createFont()
|
val wb = XSSFWorkbook()
|
||||||
boldFont.bold = true
|
|
||||||
val style = wb.createCellStyle()
|
|
||||||
style.setFont(boldFont)
|
|
||||||
style.locked = true
|
|
||||||
|
|
||||||
sh.createRow(0).apply {
|
|
||||||
cols.forEachIndexed{index, value ->
|
|
||||||
val cell = createCell(index)
|
|
||||||
cell.setCellValue(value)
|
|
||||||
cell.setCellStyle(style)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun String.parseDate(format: String): Date? {
|
|
||||||
val locale = Locale.getDefault()
|
|
||||||
return try {
|
|
||||||
SimpleDateFormat(format, locale).parse(this)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun dateFromCellHelper(cell: Cell): LocalDate?{
|
|
||||||
val date = when(cell.cellType){
|
|
||||||
CellType.STRING -> cell.stringCellValue.parseDate("yyyy-MM-dd")
|
|
||||||
CellType.NUMERIC -> {
|
|
||||||
if (DateUtil.isCellDateFormatted(cell)) {
|
|
||||||
cell.getDateCellValue()
|
|
||||||
} else{
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
return date?.toInstant()?.atZone(ZoneId.systemDefault())?.toLocalDate()
|
|
||||||
}
|
|
||||||
fun stringFromCellHelper(cell: Cell): String {
|
|
||||||
val string = when(cell.cellType){
|
|
||||||
CellType.NUMERIC -> cell.numericCellValue.toString()
|
|
||||||
CellType.STRING -> cell.stringCellValue
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
return string
|
|
||||||
}
|
|
||||||
fun doubleFromCellHelper(cell: Cell): Double {
|
|
||||||
val double = when(cell.cellType){
|
|
||||||
CellType.NUMERIC -> cell.numericCellValue
|
|
||||||
CellType.STRING -> cell.stringCellValue.toDoubleOrNull()
|
|
||||||
else -> 0.0
|
|
||||||
}
|
|
||||||
return double?:0.0
|
|
||||||
}
|
|
||||||
|
|
||||||
fun longIntFromCellHelper(cell : Cell) :Long {
|
|
||||||
val long = when(cell.cellType){
|
|
||||||
CellType.NUMERIC -> cell.numericCellValue.toLong()
|
|
||||||
CellType.STRING -> cell.stringCellValue.toLong()
|
|
||||||
else -> 0
|
|
||||||
}
|
|
||||||
return long
|
|
||||||
}
|
|
||||||
enum class FileType {
|
|
||||||
QUOTES, POS, VENDORS, PRODS, DOCS
|
|
||||||
}
|
|
||||||
enum class EnumFor {
|
|
||||||
UOM, DocType
|
|
||||||
}
|
|
||||||
fun saveExcelFileLocally(fileName :String, wb: Workbook){
|
|
||||||
val out = FileOutputStream(fileName)
|
|
||||||
wb.use {
|
|
||||||
it.write(out)
|
|
||||||
}
|
|
||||||
out.close()
|
|
||||||
}
|
|
||||||
fun TemplateExcelFile(fileType: FileType){
|
|
||||||
when(fileType){
|
|
||||||
FileType.QUOTES -> {
|
|
||||||
val headers : List<String> = listOf("Quotation Number", "Date", "Open Till", "Product Id", "Product Name", "Product Unit Price", "Quantity", "Vendor Name", "Vendor Address", "RFQ Number", "Total Amount", "Terms and Conditions")
|
|
||||||
val wb = HSSFWorkbook()
|
|
||||||
val sh = wb.createSheet()
|
val sh = wb.createSheet()
|
||||||
createHeaderRow(headers, sh, wb)
|
val rows: Row = sh.createRow(0)
|
||||||
saveExcelFileLocally("Quotes_Template.xls", wb)
|
rows.createCell(0).setCellValue("Name")
|
||||||
}
|
rows.createCell(1).setCellValue("Description")
|
||||||
FileType.POS -> {
|
rows.createCell(2).setCellValue("HSN")
|
||||||
val headers : List<String> = listOf("Number", "Date", "Open Till", "Reference Quotation Number", "Vendor Name", "Vendor Address", "Product Id", "Product Name", "Unit Price", "Quantity", "Total Amount", "Terms and Conditions")
|
rows.createCell(3).setCellValue("UOM")
|
||||||
val wb = HSSFWorkbook()
|
|
||||||
val sh = wb.createSheet()
|
|
||||||
createHeaderRow(headers, sh, wb)
|
|
||||||
saveExcelFileLocally("Purchase_Order_Template.xls", wb)
|
|
||||||
}
|
|
||||||
FileType.VENDORS -> {
|
|
||||||
val headers : List<String> = listOf("Name", "MSME", "GST Number", "Address", "Rating", "Contact Name", "Contact Email", "Contact Mobile")
|
|
||||||
val wb = HSSFWorkbook()
|
|
||||||
val sh = wb.createSheet()
|
|
||||||
createHeaderRow(headers, sh, wb)
|
|
||||||
saveExcelFileLocally("Vendors_Template.xls", wb)
|
|
||||||
}
|
|
||||||
FileType.PRODS -> {
|
|
||||||
val headers : List<String> = listOf("Id", "Name", "Description", "HSN Code", "UOM")
|
|
||||||
val wb = HSSFWorkbook()
|
|
||||||
val sh = wb.createSheet()
|
|
||||||
createHeaderRow(headers, sh, wb)
|
|
||||||
val r0 = CellRangeAddressList(0, 1000, 4, 4)
|
|
||||||
val dv0 = HSSFDataValidation(r0, DVConstraint.createExplicitListConstraint(arrayOf("LTR", "MTR", "NOS", "ALL"))).apply {
|
|
||||||
suppressDropDownArrow = true
|
|
||||||
}
|
|
||||||
sh.addValidationData(dv0)
|
|
||||||
saveExcelFileLocally("Products_Template.xls", wb)
|
|
||||||
}
|
|
||||||
FileType.DOCS -> {
|
|
||||||
|
|
||||||
}
|
var rowNum = 1
|
||||||
}
|
for (product in productList) {
|
||||||
}
|
val row: Row = sh.createRow(rowNum++)
|
||||||
fun ExportQuotations(quotes :List<Quotation>) {
|
|
||||||
val wb = HSSFWorkbook()
|
|
||||||
val sh = wb.createSheet()
|
|
||||||
|
|
||||||
val headers : List<String> = listOf("Quotation Number", "Date", "Open Till", "Product Id", "Product Name", "Product Unit Price", "Quantity", "Vendor Name", "Vendor Address", "RFQ Number", "Total AMount", "Terms and Conditions")
|
row.createCell(0).setCellValue(product.name)
|
||||||
createHeaderRow(headers, sh, wb)
|
row.createCell(1).setCellValue(product.description)
|
||||||
val totalCols = headers.size
|
row.createCell(2).setCellValue(product.hsnCode)
|
||||||
var rowCnt = 1
|
|
||||||
for(quote in quotes){
|
|
||||||
val prodCnt = quote.products.size
|
|
||||||
|
|
||||||
for (j in 0..prodCnt - 1){
|
val uomCell: Cell = row.createCell(3)
|
||||||
val row = sh.createRow(rowCnt++)
|
uomCell.setCellValue(product.uom?.name ?: "")
|
||||||
var i = 0;
|
|
||||||
row.createCell(i++).setCellValue(quote.quoteNum)
|
|
||||||
row.createCell(i++).setCellValue(quote.quoteDate)
|
|
||||||
row.createCell(i++).setCellValue(quote.validTill)
|
|
||||||
//6 would be repeated
|
|
||||||
row.createCell(i++).setCellValue(quote.products[j].productId)
|
|
||||||
row.createCell(i++).setCellValue(quote.products[j].productName)
|
|
||||||
row.createCell(i++).setCellValue(quote.products[j].unitPrice)
|
|
||||||
row.createCell(i++).setCellValue(quote.products[j].quantity)
|
|
||||||
|
|
||||||
row.createCell(i++).setCellValue(quote.vendor?.name)
|
|
||||||
row.createCell(i++).setCellValue(quote.vendor?.address)
|
|
||||||
|
|
||||||
row.createCell(i++).setCellValue(quote.reqForQuoteNum)
|
|
||||||
row.createCell(i++).setCellValue(quote.totalAmount)
|
|
||||||
|
|
||||||
row.createCell(i++).setCellValue(quote.tnc.joinToString(";"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ExportVendors(vendors :List<Vendor>){
|
val baos = ByteArrayOutputStream()
|
||||||
val wb = HSSFWorkbook()
|
wb.write(baos)
|
||||||
val sh = wb.createSheet()
|
wb.close()
|
||||||
|
|
||||||
val headers : List<String> = listOf("Name", "MSME", "GST Number", "Address", "Rating", "Contact Name", "Contact Email", "Contact Mobile")
|
return ByteArrayInputStream(baos.toByteArray())
|
||||||
createHeaderRow(headers, sh, wb)
|
|
||||||
|
|
||||||
val totalCols = headers.size
|
|
||||||
var rowCnt = 1
|
|
||||||
|
|
||||||
for (vendor in vendors){
|
|
||||||
val contactCnt = vendor.contacts.size
|
|
||||||
for (j in 0..contactCnt - 1){
|
|
||||||
val row = sh.createRow(rowCnt++)
|
|
||||||
var i = 0
|
|
||||||
row.createCell(i++).setCellValue(vendor.msme)
|
|
||||||
row.createCell(i++).setCellValue(vendor.gstNumber)
|
|
||||||
row.createCell(i++).setCellValue(vendor.address)
|
|
||||||
row.createCell(i++).setCellValue(vendor.rating)
|
|
||||||
row.createCell(i++).setCellValue(vendor.contacts[j].name)
|
|
||||||
row.createCell(i++).setCellValue(vendor.contacts[j].email)
|
|
||||||
row.createCell(i++).setCellValue(vendor.contacts[j].mobile)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ExportProds(prods :List<Product>){
|
|
||||||
val wb = HSSFWorkbook()
|
|
||||||
val sh = wb.createSheet()
|
|
||||||
|
|
||||||
val headers : List<String> = listOf("Id", "Name", "Description", "HSN Code", "UOM")
|
|
||||||
createHeaderRow(headers, sh, wb)
|
|
||||||
|
|
||||||
val totalCols = headers.size
|
|
||||||
var rowCnt = 1
|
|
||||||
|
|
||||||
for (prod in prods){
|
|
||||||
val row = sh.createRow(rowCnt++)
|
|
||||||
var i = 0
|
|
||||||
row.createCell(i++).setCellValue(prod.id.toString())
|
|
||||||
row.createCell(i++).setCellValue(prod.name)
|
|
||||||
row.createCell(i++).setCellValue(prod.description)
|
|
||||||
row.createCell(i++).setCellValue(prod.hsnCode)
|
|
||||||
row.createCell(i++).setCellValue(prod.uom?.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun ExportPos(pos :List<PurchaseOrder>){
|
|
||||||
val wb = HSSFWorkbook()
|
|
||||||
val sh = wb.createSheet()
|
|
||||||
|
|
||||||
val headers : List<String> = listOf("Number", "Date", "Open Till", "Reference Quotation Number", "Vendor Name", "Vendor Address", "Product Id", "Product Name", "Unit Price", "Quantity", "Total Amount", "Terms and Conditions")
|
|
||||||
createHeaderRow(headers, sh, wb)
|
|
||||||
|
|
||||||
val totalCols = headers.size
|
|
||||||
var rowCnt = 1
|
|
||||||
for(po in pos){
|
|
||||||
val prodCnt = po.products.size
|
|
||||||
|
|
||||||
for (j in 0..prodCnt - 1){
|
|
||||||
val row = sh.createRow(rowCnt++)
|
|
||||||
var i = 0
|
|
||||||
row.createCell(i++).setCellValue(po.poNum)
|
|
||||||
row.createCell(i++).setCellValue(po.poDate)
|
|
||||||
row.createCell(i++).setCellValue(po.validTill)
|
|
||||||
row.createCell(i++).setCellValue(po.referenceQuotation)
|
|
||||||
row.createCell(i++).setCellValue(po.vendor?.name)
|
|
||||||
row.createCell(i++).setCellValue(po.vendor?.address)
|
|
||||||
|
|
||||||
//6 would be repeated
|
|
||||||
row.createCell(i++).setCellValue(po.products[j].productId)
|
|
||||||
row.createCell(i++).setCellValue(po.products[j].productName)
|
|
||||||
row.createCell(i++).setCellValue(po.products[j].unitPrice)
|
|
||||||
row.createCell(i++).setCellValue(po.products[j].quantity)
|
|
||||||
|
|
||||||
row.createCell(i++).setCellValue(po.totalAmount)
|
|
||||||
row.createCell(i++).setCellValue(po.tnc?.joinToString(";"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun main() {
|
|
||||||
//ImportFromExcel(FileType.QUOTES, "C:\\Users\\arsalan\\Downloads\\Book.xlsx")
|
|
||||||
TemplateExcelFile(FileType.PRODS)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ImportFromExcel(fileType: FileType, filePath : String) {
|
|
||||||
val wb = WorkbookFactory.create(File(filePath))
|
|
||||||
val sh = wb.getSheetAt(0)
|
|
||||||
|
|
||||||
when(fileType){
|
|
||||||
FileType.QUOTES -> {
|
|
||||||
//Quote Number, ProductName, Product Quantity, Total Amount, RFQ Number, Quote Date, Valid Till, TNC[], Documents[]
|
|
||||||
val quotesMap : MutableMap<String, Quotation> = mutableMapOf()
|
|
||||||
val quotesList : List<Quotation> = mutableListOf()
|
|
||||||
sh.rowIterator().forEach { row ->
|
|
||||||
if(row == null){
|
|
||||||
//reached eof
|
|
||||||
return@forEach
|
|
||||||
}
|
|
||||||
val quoteNumber = stringFromCellHelper(row.getCell(0))
|
|
||||||
val quoteDt = dateFromCellHelper(row.getCell(1))
|
|
||||||
val rfqNum = stringFromCellHelper(row.getCell(2))
|
|
||||||
val quoteValidTill = dateFromCellHelper(row.getCell(3))
|
|
||||||
val vendorName = stringFromCellHelper(row.getCell(4))
|
|
||||||
val vendorGstNum = stringFromCellHelper(row.getCell(5))
|
|
||||||
val vendorAddress = stringFromCellHelper(row.getCell(6))
|
|
||||||
val prodName = stringFromCellHelper(row.getCell(7))
|
|
||||||
val prodQuantity = doubleFromCellHelper(row.getCell(8))
|
|
||||||
val prodUnitPrice = doubleFromCellHelper(row.getCell(9))
|
|
||||||
val totalQuoteAmount = doubleFromCellHelper(row.getCell(10))
|
|
||||||
val prod = POProducts("", prodName, prodUnitPrice, prodQuantity)
|
|
||||||
|
|
||||||
if (quotesMap.containsKey(quoteNumber)) {
|
|
||||||
//duplicated row
|
|
||||||
quotesMap.get(quoteNumber)?.products?.add(prod)
|
|
||||||
}else {
|
|
||||||
val v = Vendor()
|
|
||||||
v.apply {
|
|
||||||
name = vendorName
|
|
||||||
address = vendorAddress
|
|
||||||
gstNumber = vendorGstNum
|
|
||||||
}
|
|
||||||
val quote = Quotation()
|
|
||||||
quote.apply {
|
|
||||||
quoteNum = quoteNumber
|
|
||||||
quoteDate = quoteDt
|
|
||||||
reqForQuoteNum = rfqNum
|
|
||||||
validTill = quoteValidTill
|
|
||||||
products = mutableListOf(prod)
|
|
||||||
vendor = v
|
|
||||||
totalAmount = totalQuoteAmount
|
|
||||||
}
|
|
||||||
quotesMap.put(quoteNumber, quote)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//docs, tncs
|
|
||||||
// println("$quotesMap")
|
|
||||||
|
|
||||||
// quotesMap.forEach { (k, v) ->
|
|
||||||
// println("$v")
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
FileType.POS -> {
|
|
||||||
//poNum, poDate, validTill, refQuoteNum, prodName, prodQuantity, totalAmount, products, vendorName, vendorGst, vendorAddress, tnc[]. docs[]
|
|
||||||
val PoMap : MutableMap<String, PurchaseOrder> = mutableMapOf()
|
|
||||||
sh.rowIterator().forEach { row ->
|
|
||||||
if(row == null) return@forEach
|
|
||||||
val poNum = stringFromCellHelper(row.getCell(0))
|
|
||||||
val poDate = dateFromCellHelper(row.getCell(1))
|
|
||||||
val refQuoteNum = stringFromCellHelper(row.getCell(2))
|
|
||||||
val poValidTill = dateFromCellHelper(row.getCell(3))
|
|
||||||
val prodName = stringFromCellHelper(row.getCell(4))
|
|
||||||
val prodQuantity = doubleFromCellHelper(row.getCell(5))
|
|
||||||
val vendorName = stringFromCellHelper(row.getCell(6))
|
|
||||||
val vendorGstNum = stringFromCellHelper(row.getCell(7))
|
|
||||||
val vendorAddress = stringFromCellHelper(row.getCell(8))
|
|
||||||
val totalPoAmount = doubleFromCellHelper(row.getCell(9))
|
|
||||||
//tncs, docs
|
|
||||||
|
|
||||||
val prod = POProducts("", prodName, 0.0, prodQuantity,"")
|
|
||||||
if(PoMap.containsKey(poNum)){
|
|
||||||
//repeated row
|
|
||||||
PoMap.get(poNum)?.products?.add(prod)
|
|
||||||
}else{
|
|
||||||
val vendor = Vendor()
|
|
||||||
vendor.name = vendorName
|
|
||||||
vendor.address = vendorAddress
|
|
||||||
vendor.gstNumber = vendorGstNum
|
|
||||||
val po = PurchaseOrder()
|
|
||||||
po.poNum = poNum
|
|
||||||
po.poDate = poDate
|
|
||||||
po.referenceQuotation = refQuoteNum
|
|
||||||
po.validTill = poValidTill
|
|
||||||
PoMap.put(poNum, po)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FileType.VENDORS -> {
|
|
||||||
sh.rowIterator().forEach { row ->
|
|
||||||
//name, msme, gstNum, addresss, rating, contacts
|
|
||||||
if(row == null) return@forEach
|
|
||||||
val name = stringFromCellHelper(row.getCell(0))
|
|
||||||
val msme = stringFromCellHelper(row.getCell(1))
|
|
||||||
val gstNum = stringFromCellHelper(row.getCell(2))
|
|
||||||
val address = stringFromCellHelper(row.getCell(3))
|
|
||||||
val rating = doubleFromCellHelper(row.getCell(4))
|
|
||||||
|
|
||||||
//vendor object
|
|
||||||
val vendor = Vendor()
|
|
||||||
vendor.name = name
|
|
||||||
vendor.address = address
|
|
||||||
vendor.msme = msme
|
|
||||||
vendor.gstNumber = gstNum
|
|
||||||
vendor.rating = rating
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FileType.PRODS -> {
|
|
||||||
sh.rowIterator().forEach { row ->
|
|
||||||
if(row == null) return@forEach
|
|
||||||
//id, name, description, hsnCode, uom
|
|
||||||
val prodId = longIntFromCellHelper(row.getCell(0))
|
|
||||||
val prodName = stringFromCellHelper(row.getCell(1))
|
|
||||||
val prodDesc = stringFromCellHelper(row.getCell(2))
|
|
||||||
val prodHsnCode = stringFromCellHelper(row.getCell(3))
|
|
||||||
val prodUom = stringFromCellHelper(row.getCell(4))
|
|
||||||
|
|
||||||
//new prod object
|
|
||||||
val prod = Product()
|
|
||||||
prod.id = prodId
|
|
||||||
prod.name = prodName
|
|
||||||
prod.description = prodDesc
|
|
||||||
prod.hsnCode = prodHsnCode
|
|
||||||
prod.uom = when(prodUom) {
|
|
||||||
"nos" -> UOM.NOS
|
|
||||||
"ltr" -> UOM.LTR
|
|
||||||
"mtr" -> UOM.MTR
|
|
||||||
else -> UOM.LTR
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FileType.DOCS -> {
|
|
||||||
sh.rowIterator().forEach { row ->
|
|
||||||
//Document Name, Document Type, RefID, url
|
|
||||||
if (row == null) return@forEach
|
|
||||||
val docName = stringFromCellHelper(row.getCell(0))
|
|
||||||
val docType = stringFromCellHelper(row.getCell(1))
|
|
||||||
val refId = stringFromCellHelper(row.getCell(2))
|
|
||||||
val url = stringFromCellHelper(row.getCell(3))
|
|
||||||
|
|
||||||
//new doc object
|
|
||||||
val doc = Document()
|
|
||||||
doc.name = docName
|
|
||||||
doc.typeOfDoc = when(docType) {
|
|
||||||
"quote" -> DocType.QUOTE
|
|
||||||
"po" -> DocType.PO
|
|
||||||
"invoice" -> DocType.INVOICE
|
|
||||||
else -> DocType.ALL
|
|
||||||
}
|
|
||||||
doc.refId = refId
|
|
||||||
doc.url = url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data class validateExcel(
|
data class validateExcel(
|
||||||
@@ -430,7 +62,7 @@ val app_common_om = jacksonObjectMapper().apply {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun ExcelRead(): String{
|
fun ExcelRead(): String{
|
||||||
val inputStream = FileInputStream("C:\\Users\\vinay\\IdeaProjects\\readymixerp_modules_api_git\\Untitled 1.xlsx")
|
val inputStream = FileInputStream("C:\\Users\\vinay\\IdeaProjects\\readymixerp_modules_api_git\\product-4.xlsx")
|
||||||
val workbook = WorkbookFactory.create(inputStream)
|
val workbook = WorkbookFactory.create(inputStream)
|
||||||
val workSheet = workbook.getSheetAt(0)
|
val workSheet = workbook.getSheetAt(0)
|
||||||
var h = true
|
var h = true
|
||||||
@@ -523,38 +155,8 @@ fun ExcelRead(): String{
|
|||||||
return app_common_om.writeValueAsString(resp)
|
return app_common_om.writeValueAsString(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun CreateExcel(productList: List<Product>): InputStream {
|
|
||||||
val wb = XSSFWorkbook()
|
|
||||||
val sh = wb.createSheet()
|
|
||||||
val rows: Row = sh.createRow(0)
|
|
||||||
rows.createCell(0).setCellValue("Name")
|
|
||||||
rows.createCell(1).setCellValue("Description")
|
|
||||||
rows.createCell(2).setCellValue("HSN")
|
|
||||||
rows.createCell(3).setCellValue("UOM")
|
|
||||||
|
|
||||||
var rowNum = 1
|
|
||||||
for (product in productList) {
|
|
||||||
val row: Row = sh.createRow(rowNum++)
|
|
||||||
|
|
||||||
row.createCell(0).setCellValue(product.name)
|
|
||||||
row.createCell(1).setCellValue(product.description)
|
|
||||||
row.createCell(2).setCellValue(product.hsnCode)
|
|
||||||
|
|
||||||
val uomCell: Cell = row.createCell(3)
|
|
||||||
uomCell.setCellValue(product.uom?.name ?: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
val baos = ByteArrayOutputStream()
|
|
||||||
wb.write(baos)
|
|
||||||
wb.close()
|
|
||||||
|
|
||||||
return ByteArrayInputStream(baos.toByteArray())
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun excelToDb(): List<Product> {
|
fun excelToDb(): List<Product> {
|
||||||
val inputStream = FileInputStream("C:\\Users\\vinay\\IdeaProjects\\readymixerp_modules_api_git\\Untitled 1.xlsx")
|
val inputStream = FileInputStream("C:\\Users\\vinay\\IdeaProjects\\readymixerp_modules_api_git\\product-4.xlsx")
|
||||||
val workbook = WorkbookFactory.create(inputStream)
|
val workbook = WorkbookFactory.create(inputStream)
|
||||||
val workSheet = workbook.getSheetAt(0)
|
val workSheet = workbook.getSheetAt(0)
|
||||||
|
|
||||||
@@ -562,7 +164,7 @@ fun excelToDb(): List<Product> {
|
|||||||
val cell1Value = row.getCell(0).stringCellValue
|
val cell1Value = row.getCell(0).stringCellValue
|
||||||
val cell2Value = row.getCell(1).stringCellValue
|
val cell2Value = row.getCell(1).stringCellValue
|
||||||
val cell3Value = row.getCell(2).stringCellValue
|
val cell3Value = row.getCell(2).stringCellValue
|
||||||
val cell4Value = row?.getCell(3)?.stringCellValue
|
val cell4Value = row.getCell(3).stringCellValue
|
||||||
|
|
||||||
val prod = Product()
|
val prod = Product()
|
||||||
prod.name = cell1Value
|
prod.name = cell1Value
|
||||||
@@ -579,3 +181,4 @@ fun excelToDb(): List<Product> {
|
|||||||
val productList = Session.database.find(Product::class.java).findList()
|
val productList = Session.database.find(Product::class.java).findList()
|
||||||
return productList
|
return productList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package com.restapi.controllers
|
package com.restapi.controllers
|
||||||
|
|
||||||
import com.restapi.domain.*
|
import com.restapi.domain.*
|
||||||
|
import com.restapi.domain.PurchaseOrder
|
||||||
import com.restapi.domain.Quotation
|
import com.restapi.domain.Quotation
|
||||||
import com.restapi.domain.Session.database
|
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import com.restapi.domain.Session.database
|
||||||
|
|
||||||
//constants
|
//constants
|
||||||
const val IGNORE = "%"
|
const val IGNORE = "%"
|
||||||
val baseDate :LocalDate = LocalDate.of(1500, 1,1, )
|
val baseDate :LocalDate = LocalDate.MIN
|
||||||
val maxDate :LocalDate = LocalDate.of(3000, 1 ,1)
|
val maxDate :LocalDate = LocalDate.MAX
|
||||||
const val RATING_MAX = 10.0
|
const val RATING_MAX = 10.0
|
||||||
const val RATING_MIN = 0.0
|
const val RATING_MIN = 0.0
|
||||||
//common filters would be used by most of the handlers
|
//common filters would be used by most of the handlers
|
||||||
@@ -20,7 +21,6 @@ data class CommonFilters (
|
|||||||
val sortAsc :Boolean = true,
|
val sortAsc :Boolean = true,
|
||||||
val sortBy :String = IGNORE
|
val sortBy :String = IGNORE
|
||||||
)
|
)
|
||||||
interface CustomFilters{}
|
|
||||||
data class POFilters (
|
data class POFilters (
|
||||||
val poNumLike :String = IGNORE,
|
val poNumLike :String = IGNORE,
|
||||||
val totalAmountExceeds :Long = Long.MIN_VALUE,
|
val totalAmountExceeds :Long = Long.MIN_VALUE,
|
||||||
@@ -28,22 +28,16 @@ data class POFilters (
|
|||||||
val validAfter: LocalDate = baseDate,
|
val validAfter: LocalDate = baseDate,
|
||||||
val validBefore: LocalDate = maxDate,
|
val validBefore: LocalDate = maxDate,
|
||||||
val refQuotation :String = IGNORE,
|
val refQuotation :String = IGNORE,
|
||||||
) : CustomFilters
|
)
|
||||||
|
|
||||||
enum class UOMFilter {
|
|
||||||
ALL //fixme: later
|
|
||||||
}
|
|
||||||
data class ProductFilters (
|
data class ProductFilters (
|
||||||
val nameLike :String = IGNORE,
|
val nameLike :String = IGNORE,
|
||||||
val hsnLike :String = IGNORE,
|
val hsnLike :String = IGNORE,
|
||||||
val uom :UOMFilter = UOMFilter.ALL,
|
val uom :UOM = UOM.ALL,
|
||||||
) : CustomFilters
|
)
|
||||||
data class DocumentFilters (
|
data class DocumentFilters (
|
||||||
val nameLike :String = IGNORE,
|
val nameLike :String = IGNORE,
|
||||||
val typeOfDoc :DocType = DocType.ALL,
|
val typeOfDoc :DocType = DocType.ALL,
|
||||||
val docDateFrom :LocalDate = baseDate,
|
)
|
||||||
val docDataTo :LocalDate = maxDate,
|
|
||||||
) :CustomFilters
|
|
||||||
data class RFQFilters (
|
data class RFQFilters (
|
||||||
val validBefore :LocalDate = maxDate,
|
val validBefore :LocalDate = maxDate,
|
||||||
val validAfter :LocalDate = baseDate,
|
val validAfter :LocalDate = baseDate,
|
||||||
@@ -51,11 +45,11 @@ data class RFQFilters (
|
|||||||
)
|
)
|
||||||
data class QuoteFilters (
|
data class QuoteFilters (
|
||||||
val quoteNumLike :String = IGNORE,
|
val quoteNumLike :String = IGNORE,
|
||||||
val validBefore :LocalDate = maxDate,
|
val validBefore :LocalDate = baseDate,
|
||||||
val validAfter :LocalDate = baseDate,
|
val validAfter :LocalDate = maxDate,
|
||||||
val totalAmountExceeds :Long = Long.MIN_VALUE,
|
val totalAmountExceeds :Long = Long.MIN_VALUE,
|
||||||
val totalAmountLessThan :Long = Long.MAX_VALUE,
|
val totalAmountLessThan :Long = Long.MAX_VALUE,
|
||||||
) :CustomFilters
|
)
|
||||||
data class VendorFilters (
|
data class VendorFilters (
|
||||||
val nameLike :String = IGNORE,
|
val nameLike :String = IGNORE,
|
||||||
val msmeLike :String = IGNORE,
|
val msmeLike :String = IGNORE,
|
||||||
@@ -63,7 +57,7 @@ data class VendorFilters (
|
|||||||
val addressLike :String = IGNORE,
|
val addressLike :String = IGNORE,
|
||||||
val ratingExceeds :Double = RATING_MIN,
|
val ratingExceeds :Double = RATING_MIN,
|
||||||
val ratingLessThan :Double = RATING_MAX,
|
val ratingLessThan :Double = RATING_MAX,
|
||||||
) :CustomFilters
|
)
|
||||||
fun<T> applyVendorHelper(q :io.ebean.ExpressionList<T>, vids :List<Long>?) {
|
fun<T> applyVendorHelper(q :io.ebean.ExpressionList<T>, vids :List<Long>?) {
|
||||||
if (vids.isNullOrEmpty()) return
|
if (vids.isNullOrEmpty()) return
|
||||||
q.apply {
|
q.apply {
|
||||||
@@ -75,10 +69,6 @@ fun<T> applySortHelper(q :io.ebean.ExpressionList<T>, sortBy :String, asc :Boole
|
|||||||
val order = if (asc) "ASC" else "DESC"
|
val order = if (asc) "ASC" else "DESC"
|
||||||
q.orderBy("$sortBy $order")
|
q.orderBy("$sortBy $order")
|
||||||
}
|
}
|
||||||
fun<T> applyFromToHelper(q :io.ebean.ExpressionList<T>, fromDate: LocalDate, toDate: LocalDate, colName :String) {
|
|
||||||
q.ge(colName, fromDate)
|
|
||||||
.le(colName, toDate)
|
|
||||||
}
|
|
||||||
fun<T> applyCommonFilters(q :io.ebean.ExpressionList<T>, commonFilters: CommonFilters) {
|
fun<T> applyCommonFilters(q :io.ebean.ExpressionList<T>, commonFilters: CommonFilters) {
|
||||||
applyVendorHelper<T>(q, commonFilters.vendor)
|
applyVendorHelper<T>(q, commonFilters.vendor)
|
||||||
applySortHelper<T>(q, commonFilters.sortBy, commonFilters.sortAsc)
|
applySortHelper<T>(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||||
@@ -86,14 +76,17 @@ fun<T> applyCommonFilters(q :io.ebean.ExpressionList<T>, commonFilters: CommonFi
|
|||||||
fun searchQuotes(commonFilters: CommonFilters, quoteFilters: QuoteFilters) : List<Quotation> {
|
fun searchQuotes(commonFilters: CommonFilters, quoteFilters: QuoteFilters) : List<Quotation> {
|
||||||
val q = database.find(Quotation::class.java)
|
val q = database.find(Quotation::class.java)
|
||||||
.where()
|
.where()
|
||||||
.ge("quoteDate", commonFilters.fromDate)
|
.between("quoteDate", commonFilters.fromDate, commonFilters.toDate)
|
||||||
.le("quoteDate", commonFilters.toDate)
|
.ilike("quoteNum", quoteFilters.quoteNumLike )
|
||||||
.ge("validTill",quoteFilters.validAfter)
|
.ge("validTill",quoteFilters.validAfter)
|
||||||
.le("validTill", quoteFilters.validBefore)
|
.le("validTill", quoteFilters.validBefore)
|
||||||
.ge("totalAmount", quoteFilters.totalAmountExceeds)
|
|
||||||
.le("totalAmount", quoteFilters.totalAmountLessThan)
|
.le("totalAmount", quoteFilters.totalAmountLessThan)
|
||||||
.ilike("quoteNum", "%" + quoteFilters.quoteNumLike + "%")
|
.ge("totalAmount", quoteFilters.totalAmountExceeds)
|
||||||
applyVendorHelper(q, commonFilters.vendor)
|
.apply {
|
||||||
|
if(!commonFilters.vendor?.isEmpty()!!){
|
||||||
|
commonFilters.vendor.let { this.`in`("vendor", it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||||
return q.findList()
|
return q.findList()
|
||||||
}
|
}
|
||||||
@@ -102,10 +95,10 @@ fun searchVendors(commonFilters: CommonFilters, vendorFilters: VendorFilters) :
|
|||||||
.where()
|
.where()
|
||||||
.ge("rating", vendorFilters.ratingExceeds)
|
.ge("rating", vendorFilters.ratingExceeds)
|
||||||
.le("rating", vendorFilters.ratingLessThan)
|
.le("rating", vendorFilters.ratingLessThan)
|
||||||
.ilike("name", "%" + vendorFilters.nameLike + "%")
|
.ilike("name", vendorFilters.nameLike)
|
||||||
.ilike("msme", "%" + vendorFilters.msmeLike + "%")
|
.ilike("msme", vendorFilters.msmeLike)
|
||||||
.ilike("gstNumber", "%" + vendorFilters.gstNumLike + "%")
|
.ilike("gstNum", vendorFilters.gstNumLike)
|
||||||
.ilike("address", "%" + vendorFilters.addressLike + "%")
|
.ilike("address", vendorFilters.addressLike)
|
||||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||||
return q.findList()
|
return q.findList()
|
||||||
}
|
}
|
||||||
@@ -117,21 +110,17 @@ fun searchDocs(commonFilters: CommonFilters, documentFilters: DocumentFilters) :
|
|||||||
this.eq("docType", documentFilters.typeOfDoc)
|
this.eq("docType", documentFilters.typeOfDoc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.ilike("name", "%" + documentFilters.nameLike + "%")
|
.ilike("name", documentFilters.nameLike )
|
||||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||||
applyVendorHelper(q, commonFilters.vendor)
|
|
||||||
return q.findList()
|
return q.findList()
|
||||||
}
|
}
|
||||||
fun searchPos(commonFilters: CommonFilters, poFilters: POFilters?) : List<PurchaseOrder> {
|
fun searchPos(commonFilters: CommonFilters, poFilters: POFilters) : List<PurchaseOrder> {
|
||||||
val poFilters = poFilters ?: POFilters()
|
|
||||||
val q = database.find(PurchaseOrder::class.java)
|
val q = database.find(PurchaseOrder::class.java)
|
||||||
.where()
|
.where()
|
||||||
.ge("totalAmount", poFilters.totalAmountExceeds)
|
.between("totalAmount", poFilters.totalAmountExceeds, poFilters.totalAmountLessThan)
|
||||||
.le("totalAmount", poFilters.totalAmountLessThan)
|
.between("validTill", poFilters.validAfter, poFilters.validBefore)
|
||||||
.ge("validTill", poFilters.validAfter)
|
.ilike("poNum", poFilters.poNumLike )
|
||||||
.le("validTill", poFilters.validBefore)
|
.ilike("referenceQuotation", poFilters.refQuotation )
|
||||||
.ilike("poNum", "%" + poFilters.poNumLike + "%")
|
|
||||||
.ilike("referenceQuotation", "%" + poFilters.refQuotation + "%")
|
|
||||||
applyVendorHelper(q, commonFilters.vendor)
|
applyVendorHelper(q, commonFilters.vendor)
|
||||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||||
return q.findList()
|
return q.findList()
|
||||||
@@ -139,9 +128,8 @@ fun searchPos(commonFilters: CommonFilters, poFilters: POFilters?) : List<Purcha
|
|||||||
fun searchRFQ(commonFilters: CommonFilters, rfqFilters: RFQFilters) : List<ReqForQuote> {
|
fun searchRFQ(commonFilters: CommonFilters, rfqFilters: RFQFilters) : List<ReqForQuote> {
|
||||||
val q = database.find(ReqForQuote::class.java)
|
val q = database.find(ReqForQuote::class.java)
|
||||||
.where()
|
.where()
|
||||||
.ge("validTill", rfqFilters.validAfter)
|
.between("validTill", rfqFilters.validAfter, rfqFilters.validBefore)
|
||||||
.le("validTill", rfqFilters.validBefore)
|
.ilike("reqForQuoteNum", rfqFilters.reqForQuoteNumLike)
|
||||||
.ilike("reqForQuoteNum", "%" + rfqFilters.reqForQuoteNumLike + "%")
|
|
||||||
applyVendorHelper(q, commonFilters.vendor)
|
applyVendorHelper(q, commonFilters.vendor)
|
||||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||||
return q.findList()
|
return q.findList()
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ import java.util.*
|
|||||||
import javax.persistence.*
|
import javax.persistence.*
|
||||||
|
|
||||||
data class Comments(val text: String = "", val by: String = "", val at: LocalDateTime = LocalDateTime.now())
|
data class Comments(val text: String = "", val by: String = "", val at: LocalDateTime = LocalDateTime.now())
|
||||||
data class POProducts(val productId: String = "", val productName: String = "", val unitPrice :Double = 0.0, val quantity: Double = 0.0, val description :String = "")
|
data class POProducts(val productId: String = "", val unitPrice :Double = 0.0, val quantity: Double = 0.0, val description :String = "")
|
||||||
|
|
||||||
|
|
||||||
enum class ApprovalStatus {
|
enum class ApprovalStatus {
|
||||||
PENDING, APPROVED, REJECTED
|
PENDING, APPROVED, REJECTED
|
||||||
}
|
}
|
||||||
@@ -244,7 +242,7 @@ class SafeStringDeserializer : JsonDeserializer<String>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ContactPerson(val name: String = "", val email: String = "", val mobile: String = "")
|
data class ContactPerson(val name: String, val email: String, val mobile: String)
|
||||||
@Entity
|
@Entity
|
||||||
open class Vendor :BaseTenantModel() {
|
open class Vendor :BaseTenantModel() {
|
||||||
var name :String = ""
|
var name :String = ""
|
||||||
@@ -261,15 +259,15 @@ open class PurchaseOrder :BaseTenantModel() {
|
|||||||
var products :MutableList<POProducts> = mutableListOf()
|
var products :MutableList<POProducts> = mutableListOf()
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
var vendor :Vendor? = null
|
var vendor :Vendor? = null
|
||||||
var referenceQuotation :String? = ""
|
var referenceQuotation :String = ""
|
||||||
var totalAmount :Double = 0.0
|
var totalAmount :Int = 0
|
||||||
var poNum: String = ""
|
var poNum: String = ""
|
||||||
var poDate: LocalDate? = null
|
var poDate: LocalDate? = null
|
||||||
var validTill: LocalDate? = null
|
var validTill: LocalDate? = null
|
||||||
@DbArray
|
@DbArray
|
||||||
var tnc: List<String>? = arrayListOf()
|
var tnc: List<String> = arrayListOf()
|
||||||
@DbArray
|
@DbArray
|
||||||
var documents: MutableList<Long>? = arrayListOf()
|
var documents: MutableList<Long> = arrayListOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class UOM {
|
enum class UOM {
|
||||||
@@ -278,7 +276,7 @@ enum class UOM {
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
open class Product :BaseTenantModel() {
|
open class Product :BaseTenantModel() {
|
||||||
var id: Long? = null
|
var id: Int? = null
|
||||||
var name :String = ""
|
var name :String = ""
|
||||||
var description :String = ""
|
var description :String = ""
|
||||||
var hsnCode :String = ""
|
var hsnCode :String = ""
|
||||||
@@ -292,9 +290,9 @@ open class Quotation :BaseTenantModel() {
|
|||||||
var products :MutableList<POProducts> = mutableListOf()
|
var products :MutableList<POProducts> = mutableListOf()
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
var vendor :Vendor? = null
|
var vendor :Vendor? = null
|
||||||
var totalAmount :Double = 0.0
|
var totalAmount :Long = 0
|
||||||
|
|
||||||
var reqForQuoteNum: String? = ""
|
var reqForQuoteNum: String = ""
|
||||||
var quoteNum: String = ""
|
var quoteNum: String = ""
|
||||||
var quoteDate: LocalDate? = null
|
var quoteDate: LocalDate? = null
|
||||||
var validTill: LocalDate? = null
|
var validTill: LocalDate? = null
|
||||||
@@ -313,12 +311,9 @@ open class Document :BaseTenantModel() {
|
|||||||
var name :String = ""
|
var name :String = ""
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
var typeOfDoc :DocType? = null
|
var typeOfDoc :DocType? = null
|
||||||
//could be quoteNum, PoNum, InvoiceNum
|
var refId: Long? = null
|
||||||
var refId: String? = null
|
|
||||||
var description :String = ""
|
var description :String = ""
|
||||||
var url :String = ""
|
var url :String = ""
|
||||||
var docDate :LocalDate? = null
|
|
||||||
var vendor :Vendor? = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class RFQStatus{
|
enum class RFQStatus{
|
||||||
@@ -330,10 +325,10 @@ open class ReqForQuote :BaseTenantModel() {
|
|||||||
var potentialVendors :List<Long>? = null
|
var potentialVendors :List<Long>? = null
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
var status :RFQStatus? = null
|
var status :RFQStatus? = null
|
||||||
// @DbArray
|
@DbArray
|
||||||
// var docs :List<Document>? = null
|
var docs :List<Document>? = null
|
||||||
@DbJsonB
|
@DbJsonB
|
||||||
var products :List<POProducts>? = null
|
var products :List<POProducts>? = null
|
||||||
var reqForQuoteNum: String? = null
|
var reqForQuoteNum: String = ""
|
||||||
var openTill: LocalDate? = null
|
var openTill: LocalDate? = null
|
||||||
}
|
}
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
-- drop dependencies
|
|
||||||
alter table document drop constraint if exists ck_document_type_of_doc;
|
|
||||||
alter table product drop constraint if exists ck_product_uom;
|
|
||||||
-- apply changes
|
|
||||||
create table req_for_quote (
|
|
||||||
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,
|
|
||||||
potential_vendors bigint[],
|
|
||||||
open_till 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,
|
|
||||||
status varchar(9),
|
|
||||||
products jsonb,
|
|
||||||
req_for_quote_num varchar(255),
|
|
||||||
created_by varchar(255) not null,
|
|
||||||
modified_by varchar(255) not null,
|
|
||||||
constraint ck_req_for_quote_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
|
||||||
constraint ck_req_for_quote_status check ( status in ('DELIVERED','PO','QUOTE','CANCELLED')),
|
|
||||||
constraint pk_req_for_quote primary key (sys_pk)
|
|
||||||
);
|
|
||||||
|
|
||||||
-- apply alter tables
|
|
||||||
alter table document alter column type_of_doc type varchar(7) using type_of_doc::varchar(7);
|
|
||||||
alter table document alter column type_of_doc drop not null;
|
|
||||||
alter table document add column if not exists ref_id varchar(255);
|
|
||||||
alter table document add column if not exists doc_date date;
|
|
||||||
alter table product add column if not exists id bigint;
|
|
||||||
alter table purchase_order alter column reference_quotation drop not null;
|
|
||||||
alter table purchase_order alter column total_amount type float using total_amount::float;
|
|
||||||
alter table quotation alter column total_amount type float using total_amount::float;
|
|
||||||
alter table quotation add column if not exists req_for_quote_num varchar(255);
|
|
||||||
-- apply post alter
|
|
||||||
alter table document add constraint ck_document_type_of_doc check ( type_of_doc in ('PO','QUOTE','INVOICE','ALL'));
|
|
||||||
alter table product add constraint ck_product_uom check ( uom in ('NOS','LTR','MTR','ALL'));
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
||||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
|
||||||
<changeSet type="apply">
|
|
||||||
<alterColumn columnName="type_of_doc" tableName="document" type="varchar(7)" currentType="varchar" notnull="false" currentNotnull="true" checkConstraint="check ( type_of_doc in ('PO','QUOTE','INVOICE','ALL'))" checkConstraintName="ck_document_type_of_doc"/>
|
|
||||||
<addColumn tableName="document">
|
|
||||||
<column name="ref_id" type="varchar"/>
|
|
||||||
<column name="doc_date" type="date"/>
|
|
||||||
</addColumn>
|
|
||||||
<alterColumn columnName="uom" tableName="product" checkConstraint="check ( uom in ('NOS','LTR','MTR','ALL'))" checkConstraintName="ck_product_uom"/>
|
|
||||||
<addColumn tableName="product">
|
|
||||||
<column name="id" type="bigint"/>
|
|
||||||
</addColumn>
|
|
||||||
<alterColumn columnName="reference_quotation" tableName="purchase_order" currentType="varchar" notnull="false" currentNotnull="true"/>
|
|
||||||
<alterColumn columnName="total_amount" tableName="purchase_order" type="double" currentType="integer" currentNotnull="true"/>
|
|
||||||
<alterColumn columnName="total_amount" tableName="quotation" type="double" currentType="integer" currentNotnull="true"/>
|
|
||||||
<addColumn tableName="quotation">
|
|
||||||
<column name="req_for_quote_num" type="varchar"/>
|
|
||||||
</addColumn>
|
|
||||||
<createTable name="req_for_quote" pkName="pk_req_for_quote">
|
|
||||||
<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_req_for_quote_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="potential_vendors" type="bigint[]"/>
|
|
||||||
<column name="status" type="varchar(9)" checkConstraint="check ( status in ('DELIVERED','PO','QUOTE','CANCELLED'))" checkConstraintName="ck_req_for_quote_status"/>
|
|
||||||
<column name="products" type="jsonb"/>
|
|
||||||
<column name="req_for_quote_num" type="varchar"/>
|
|
||||||
<column name="open_till" type="date"/>
|
|
||||||
<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>
|
|
||||||
</changeSet>
|
|
||||||
</migration>
|
|
||||||
Reference in New Issue
Block a user