Compare commits

..

No commits in common. "dd55cd22cfee23d1d23a08758a9282b71a1f4ba0" and "cb184dee3bedaace7620b4ca5eb0dee5eb3285d9" have entirely different histories.

5 changed files with 7 additions and 154 deletions

View File

@ -36,8 +36,6 @@ 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")

View File

@ -590,4 +590,5 @@ object RequestForQuote {
//shuld we compare the new body fields with preexisting ones and prepare a sql query to update those fields??
}
}

View File

@ -1,9 +0,0 @@
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()
}

View File

@ -1,138 +0,0 @@
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()
}

View File

@ -239,6 +239,7 @@ class SafeStringDeserializer : JsonDeserializer<String>() {
if (!regex.matches(text)) throw IllegalArgumentException()
return text
}
}
data class ContactPerson(val name: String, val email: String, val mobile: String)
@ -270,7 +271,7 @@ open class PurchaseOrder :BaseTenantModel() {
}
enum class UOM {
NOS, LTR, MTR, ALL
NOS, LTR, MTR
}
@Entity
open class Product :BaseTenantModel() {
@ -288,7 +289,7 @@ open class Quotation :BaseTenantModel() {
var products :MutableList<POProducts> = mutableListOf()
@ManyToOne
var vendor :Vendor? = null
var totalAmount :Long = 0
var totalAmount :Int = 0
var reqForQuoteNum: String = ""
var quoteNum: String = ""
@ -301,14 +302,14 @@ open class Quotation :BaseTenantModel() {
var documents: MutableList<Long> = arrayListOf()
}
enum class DocType{
PO, QUOTE, INVOICE, ALL
enum class DOCTYPE{
PO, QUOTE, INVOICE
}
@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 = ""