Compare commits
3 Commits
cb184dee3b
...
dd55cd22cf
| Author | SHA1 | Date | |
|---|---|---|---|
| dd55cd22cf | |||
| aa97275b9c | |||
| cfdb792aa5 |
@ -36,6 +36,8 @@ dependencies {
|
||||
implementation("org.yaml:snakeyaml:2.2")
|
||||
implementation("io.minio:minio:8.5.7")
|
||||
implementation("org.apache.httpcomponents:httpclient:4.5.14")
|
||||
implementation("org.apache.poi:poi:5.0.0")
|
||||
implementation("org.apache.poi:poi-ooxml:5.0.0")
|
||||
api ("net.cactusthorn.config:config-core:0.81")
|
||||
api ("net.cactusthorn.config:config-yaml:0.81")
|
||||
kapt("net.cactusthorn.config:config-compiler:0.81")
|
||||
|
||||
@ -590,5 +590,4 @@ object RequestForQuote {
|
||||
//shuld we compare the new body fields with preexisting ones and prepare a sql query to update those fields??
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
9
src/main/kotlin/com/restapi/controllers/Excel.kt
Normal file
9
src/main/kotlin/com/restapi/controllers/Excel.kt
Normal file
@ -0,0 +1,9 @@
|
||||
package com.restapi.controllers
|
||||
import org.apache.poi
|
||||
import java.io.FileOutputStream
|
||||
enum class DataType {
|
||||
QUOTE, PO, VENDOR
|
||||
}
|
||||
fun CreateExcel(cols :List<String>, excelFor :DataType) {
|
||||
val wb = HSSFWorkbook()
|
||||
}
|
||||
138
src/main/kotlin/com/restapi/controllers/Filters.kt
Normal file
138
src/main/kotlin/com/restapi/controllers/Filters.kt
Normal file
@ -0,0 +1,138 @@
|
||||
package com.restapi.controllers
|
||||
|
||||
import com.restapi.domain.DocType
|
||||
import com.restapi.domain.PurchaseOrder
|
||||
import com.restapi.domain.Quotation
|
||||
import com.restapi.domain.ReqForQuote
|
||||
import com.restapi.domain.UOM
|
||||
import java.time.LocalDate
|
||||
import com.restapi.domain.Session.database
|
||||
|
||||
//constants
|
||||
const val IGNORE = "%"
|
||||
val baseDate :LocalDate = LocalDate.MIN
|
||||
val maxDate :LocalDate = LocalDate.MAX
|
||||
const val RATING_MAX = 10.0
|
||||
const val RATING_MIN = 0.0
|
||||
//common filters would be used by most of the handlers
|
||||
//require a list of vendor ids to be passed
|
||||
data class CommonFilters (
|
||||
val fromDate :LocalDate = baseDate,
|
||||
val toDate :LocalDate = maxDate,
|
||||
val vendor :List<Long>? = null,
|
||||
val sortAsc :Boolean = true,
|
||||
val sortBy :String = IGNORE
|
||||
)
|
||||
data class POFilters (
|
||||
val poNumLike :String = IGNORE,
|
||||
val totalAmountExceeds :Long = Long.MIN_VALUE,
|
||||
val totalAmountLessThan :Long = Long.MAX_VALUE,
|
||||
val validAfter: LocalDate = baseDate,
|
||||
val validBefore: LocalDate = maxDate,
|
||||
val refQuotation :String = IGNORE,
|
||||
)
|
||||
data class ProductFilters (
|
||||
val nameLike :String = IGNORE,
|
||||
val hsnLike :String = IGNORE,
|
||||
val uom :UOM = UOM.ALL,
|
||||
)
|
||||
data class DocumentFilters (
|
||||
val nameLike :String = IGNORE,
|
||||
val typeOfDoc :DocType = DocType.ALL,
|
||||
)
|
||||
data class RFQFilters (
|
||||
val validBefore :LocalDate = maxDate,
|
||||
val validAfter :LocalDate = baseDate,
|
||||
val reqForQuoteNumLike :String = IGNORE,
|
||||
)
|
||||
data class QuoteFilters (
|
||||
val quoteNumLike :String = IGNORE,
|
||||
val validBefore :LocalDate = baseDate,
|
||||
val validAfter :LocalDate = maxDate,
|
||||
val totalAmountExceeds :Long = Long.MIN_VALUE,
|
||||
val totalAmountLessThan :Long = Long.MAX_VALUE,
|
||||
)
|
||||
data class VendorFilters (
|
||||
val nameLike :String = IGNORE,
|
||||
val msmeLike :String = IGNORE,
|
||||
val gstNumLike :String = IGNORE,
|
||||
val addressLike :String = IGNORE,
|
||||
val ratingExceeds :Double = RATING_MIN,
|
||||
val ratingLessThan :Double = RATING_MAX,
|
||||
)
|
||||
fun<T> applyVendorHelper(q :io.ebean.ExpressionList<T>, vids :List<Long>?) {
|
||||
if (vids.isNullOrEmpty()) return
|
||||
q.apply {
|
||||
q.`in`("vendor", vids)
|
||||
}
|
||||
}
|
||||
fun<T> applySortHelper(q :io.ebean.ExpressionList<T>, sortBy :String, asc :Boolean) {
|
||||
if(sortBy == IGNORE) return;
|
||||
val order = if (asc) "ASC" else "DESC"
|
||||
q.orderBy("$sortBy $order")
|
||||
}
|
||||
fun<T> applyCommonFilters(q :io.ebean.ExpressionList<T>, commonFilters: CommonFilters) {
|
||||
applyVendorHelper<T>(q, commonFilters.vendor)
|
||||
applySortHelper<T>(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
}
|
||||
fun searchQuotes(commonFilters: CommonFilters, quoteFilters: QuoteFilters) : List<Quotation> {
|
||||
val q = database.find(Quotation::class.java)
|
||||
.where()
|
||||
.between("quoteDate", commonFilters.fromDate, commonFilters.toDate)
|
||||
.ilike("quoteNum", quoteFilters.quoteNumLike )
|
||||
.ge("validTill",quoteFilters.validAfter)
|
||||
.le("validTill", quoteFilters.validBefore)
|
||||
.le("totalAmount", quoteFilters.totalAmountLessThan)
|
||||
.ge("totalAmount", quoteFilters.totalAmountExceeds)
|
||||
.apply {
|
||||
if(!commonFilters.vendor?.isEmpty()!!){
|
||||
commonFilters.vendor.let { this.`in`("vendor", it) }
|
||||
}
|
||||
}
|
||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
return q.findList()
|
||||
}
|
||||
fun searchVendors(commonFilters: CommonFilters, vendorFilters: VendorFilters) : List<Vendor> {
|
||||
val q = database.find(Vendor::class.java)
|
||||
.where()
|
||||
.ge("rating", vendorFilters.ratingExceeds)
|
||||
.le("rating", vendorFilters.ratingLessThan)
|
||||
.ilike("name", vendorFilters.nameLike)
|
||||
.ilike("msme", vendorFilters.msmeLike)
|
||||
.ilike("gstNum", vendorFilters.gstNumLike)
|
||||
.ilike("address", vendorFilters.addressLike)
|
||||
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()
|
||||
.apply {
|
||||
if(documentFilters.typeOfDoc != DocType.ALL){
|
||||
this.eq("docType", documentFilters.typeOfDoc)
|
||||
}
|
||||
}
|
||||
.ilike("name", documentFilters.nameLike )
|
||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
return q.findList()
|
||||
}
|
||||
fun searchPos(commonFilters: CommonFilters, poFilters: POFilters) : List<PurchaseOrder> {
|
||||
val q = database.find(PurchaseOrder::class.java)
|
||||
.where()
|
||||
.between("totalAmount", poFilters.totalAmountExceeds, poFilters.totalAmountLessThan)
|
||||
.between("validTill", poFilters.validAfter, poFilters.validBefore)
|
||||
.ilike("poNum", poFilters.poNumLike )
|
||||
.ilike("referenceQuotation", poFilters.refQuotation )
|
||||
applyVendorHelper(q, commonFilters.vendor)
|
||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
return q.findList()
|
||||
}
|
||||
fun searchRFQ(commonFilters: CommonFilters, rfqFilters: RFQFilters) : List<ReqForQuote> {
|
||||
val q = database.find(ReqForQuote::class.java)
|
||||
.where()
|
||||
.between("validTill", rfqFilters.validAfter, rfqFilters.validBefore)
|
||||
.ilike("reqForQuoteNum", rfqFilters.reqForQuoteNumLike)
|
||||
applyVendorHelper(q, commonFilters.vendor)
|
||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||
return q.findList()
|
||||
}
|
||||
@ -239,7 +239,6 @@ class SafeStringDeserializer : JsonDeserializer<String>() {
|
||||
if (!regex.matches(text)) throw IllegalArgumentException()
|
||||
return text
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class ContactPerson(val name: String, val email: String, val mobile: String)
|
||||
@ -271,7 +270,7 @@ open class PurchaseOrder :BaseTenantModel() {
|
||||
}
|
||||
|
||||
enum class UOM {
|
||||
NOS, LTR, MTR
|
||||
NOS, LTR, MTR, ALL
|
||||
}
|
||||
@Entity
|
||||
open class Product :BaseTenantModel() {
|
||||
@ -289,7 +288,7 @@ open class Quotation :BaseTenantModel() {
|
||||
var products :MutableList<POProducts> = mutableListOf()
|
||||
@ManyToOne
|
||||
var vendor :Vendor? = null
|
||||
var totalAmount :Int = 0
|
||||
var totalAmount :Long = 0
|
||||
|
||||
var reqForQuoteNum: String = ""
|
||||
var quoteNum: String = ""
|
||||
@ -302,14 +301,14 @@ open class Quotation :BaseTenantModel() {
|
||||
var documents: MutableList<Long> = arrayListOf()
|
||||
}
|
||||
|
||||
enum class DOCTYPE{
|
||||
PO, QUOTE, INVOICE
|
||||
enum class DocType{
|
||||
PO, QUOTE, INVOICE, ALL
|
||||
}
|
||||
@Entity
|
||||
open class Document :BaseTenantModel() {
|
||||
var name :String = ""
|
||||
@Enumerated(EnumType.STRING)
|
||||
var typeOfDoc :DOCTYPE? = null
|
||||
var typeOfDoc :DocType? = null
|
||||
var refId: Long? = null
|
||||
var description :String = ""
|
||||
var url :String = ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user