more changes to inward inventory

This commit is contained in:
gowthaman 2024-04-29 22:38:00 +05:30
parent d28a3215d1
commit 4d7f5ccdfb
6 changed files with 34 additions and 22 deletions

View File

@ -18,6 +18,7 @@ repositories {
dependencies {
testImplementation(kotlin("test"))
implementation("net.jodah:expiringmap:0.5.11")
implementation("javax.xml.bind:jaxb-api:2.3.1")
implementation("com.sun.xml.bind:jaxb-impl:2.3.9")
implementation("io.javalin:javalin:5.6.3")

View File

@ -70,7 +70,7 @@ fun main(args: Array<String>) {
before("/api/*") { ctx ->
NaiveRateLimit.requestPerTimeUnit(
ctx, appConfig.rateLimit().getOrDefault(30), TimeUnit.MINUTES
ctx, appConfig.rateLimit().getOrDefault(10000), TimeUnit.MINUTES
)
val authToken = ctx.getAuthHeader() ?: throw UnauthorizedResponse()

View File

@ -709,7 +709,6 @@ object VendorCtrl {
fun getAll(ctx: Context) {
val filters = ctx.bodyAsClass<VF>()
logger.info("filters = {}", filters)
val excel: String? = ctx.queryParam("excel")
val vendors = searchVendors(filters.common, filters.vendorFilters)
if (excel !== null) {

View File

@ -2,7 +2,9 @@ package com.restapi.controllers
import com.restapi.domain.*
import com.restapi.domain.Session.database
import net.jodah.expiringmap.ExpiringMap
import java.time.LocalDate
import java.util.concurrent.TimeUnit
//constants
const val IGNORE = "%"
@ -98,7 +100,6 @@ data class PaymentFilters(
) : CustomFilters
data class FleetFilters(
val fleetNameLike: String = IGNORE
) : CustomFilters
@ -108,6 +109,7 @@ data class ReminderLogFilters(
val actedUpon: Boolean? = null,
val fleetId: Long? = null
)
fun <T> applyVendorHelper(q: io.ebean.ExpressionList<T>, vids: List<Long>?) {
if (vids.isNullOrEmpty()) return
// q.apply {
@ -163,7 +165,12 @@ fun searchVendors(commonFilters: CommonFilters, vendorFilters: VendorFilters): L
return q.findList()
}
private val productCache = ExpiringMap.builder()
.expiration(5, TimeUnit.MINUTES)
.build<String, List<Product>>()
fun searchProducts(commonFilters: CommonFilters, productFilters: ProductFilters): List<Product> {
return productCache.computeIfAbsent("$commonFilters:$productFilters:${Session.currentUser()}") {
val q = database.find(Product::class.java)
.where()
.ilike("name", "%" + productFilters.nameLike + "%")
@ -173,7 +180,8 @@ fun searchProducts(commonFilters: CommonFilters, productFilters: ProductFilters)
q.eq("uom", productFilters.uom)
}
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
return q.findList()
q.findList()
}
}
fun searchDocs(commonFilters: CommonFilters, documentFilters: DocumentFilters): List<Document> {

View File

@ -17,6 +17,10 @@ data class POProducts(
val productName: String = "",
val unitPrice: Double = 0.0,
val quantity: Double = 0.0,
val billQty: Double = 0.0,
val gstPct: Double = 0.0,
val taxableValue: Double = 0.0,
val totalValue: Double = 0.0,
val description: String = "",
val uom: String = "",
)

View File

@ -21,7 +21,7 @@
</appender>
<!-- SQL and bind values -->
<logger name="io.ebean.SQL" level="TRACE"/>
<logger name="io.ebean.SQL" level="WARN"/>
<!-- Transaction Commit and Rollback events -->
<logger name="io.ebean.TXN" level="DEBUG"/>