more changes to inward inventory
This commit is contained in:
parent
d28a3215d1
commit
4d7f5ccdfb
@ -18,6 +18,7 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
|
implementation("net.jodah:expiringmap:0.5.11")
|
||||||
implementation("javax.xml.bind:jaxb-api:2.3.1")
|
implementation("javax.xml.bind:jaxb-api:2.3.1")
|
||||||
implementation("com.sun.xml.bind:jaxb-impl:2.3.9")
|
implementation("com.sun.xml.bind:jaxb-impl:2.3.9")
|
||||||
implementation("io.javalin:javalin:5.6.3")
|
implementation("io.javalin:javalin:5.6.3")
|
||||||
|
|||||||
@ -70,7 +70,7 @@ fun main(args: Array<String>) {
|
|||||||
before("/api/*") { ctx ->
|
before("/api/*") { ctx ->
|
||||||
|
|
||||||
NaiveRateLimit.requestPerTimeUnit(
|
NaiveRateLimit.requestPerTimeUnit(
|
||||||
ctx, appConfig.rateLimit().getOrDefault(30), TimeUnit.MINUTES
|
ctx, appConfig.rateLimit().getOrDefault(10000), TimeUnit.MINUTES
|
||||||
)
|
)
|
||||||
|
|
||||||
val authToken = ctx.getAuthHeader() ?: throw UnauthorizedResponse()
|
val authToken = ctx.getAuthHeader() ?: throw UnauthorizedResponse()
|
||||||
|
|||||||
@ -709,7 +709,6 @@ object VendorCtrl {
|
|||||||
|
|
||||||
fun getAll(ctx: Context) {
|
fun getAll(ctx: Context) {
|
||||||
val filters = ctx.bodyAsClass<VF>()
|
val filters = ctx.bodyAsClass<VF>()
|
||||||
logger.info("filters = {}", filters)
|
|
||||||
val excel: String? = ctx.queryParam("excel")
|
val excel: String? = ctx.queryParam("excel")
|
||||||
val vendors = searchVendors(filters.common, filters.vendorFilters)
|
val vendors = searchVendors(filters.common, filters.vendorFilters)
|
||||||
if (excel !== null) {
|
if (excel !== null) {
|
||||||
|
|||||||
@ -2,7 +2,9 @@ package com.restapi.controllers
|
|||||||
|
|
||||||
import com.restapi.domain.*
|
import com.restapi.domain.*
|
||||||
import com.restapi.domain.Session.database
|
import com.restapi.domain.Session.database
|
||||||
|
import net.jodah.expiringmap.ExpiringMap
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
//constants
|
//constants
|
||||||
const val IGNORE = "%"
|
const val IGNORE = "%"
|
||||||
@ -98,16 +100,16 @@ data class PaymentFilters(
|
|||||||
) : CustomFilters
|
) : CustomFilters
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data class FleetFilters(
|
data class FleetFilters(
|
||||||
val fleetNameLike: String = IGNORE
|
val fleetNameLike: String = IGNORE
|
||||||
):CustomFilters
|
) : CustomFilters
|
||||||
|
|
||||||
data class ReminderLogFilters(
|
data class ReminderLogFilters(
|
||||||
val reminderType: String = IGNORE,
|
val reminderType: String = IGNORE,
|
||||||
val actedUpon: Boolean? = null,
|
val actedUpon: Boolean? = null,
|
||||||
val fleetId: Long? = null
|
val fleetId: Long? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
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 {
|
||||||
@ -163,17 +165,23 @@ fun searchVendors(commonFilters: CommonFilters, vendorFilters: VendorFilters): L
|
|||||||
return q.findList()
|
return q.findList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchProducts(commonFilters: CommonFilters, productFilters: ProductFilters): List<Product> {
|
private val productCache = ExpiringMap.builder()
|
||||||
val q = database.find(Product::class.java)
|
.expiration(5, TimeUnit.MINUTES)
|
||||||
.where()
|
.build<String, List<Product>>()
|
||||||
.ilike("name", "%" + productFilters.nameLike + "%")
|
|
||||||
.ilike("hsnCode", "%" + productFilters.hsnLike + "%")
|
|
||||||
|
|
||||||
if (productFilters.uom != UOM.ALL) {
|
fun searchProducts(commonFilters: CommonFilters, productFilters: ProductFilters): List<Product> {
|
||||||
q.eq("uom", productFilters.uom)
|
return productCache.computeIfAbsent("$commonFilters:$productFilters:${Session.currentUser()}") {
|
||||||
|
val q = database.find(Product::class.java)
|
||||||
|
.where()
|
||||||
|
.ilike("name", "%" + productFilters.nameLike + "%")
|
||||||
|
.ilike("hsnCode", "%" + productFilters.hsnLike + "%")
|
||||||
|
|
||||||
|
if (productFilters.uom != UOM.ALL) {
|
||||||
|
q.eq("uom", productFilters.uom)
|
||||||
|
}
|
||||||
|
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
||||||
|
q.findList()
|
||||||
}
|
}
|
||||||
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
|
|
||||||
return q.findList()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchDocs(commonFilters: CommonFilters, documentFilters: DocumentFilters): List<Document> {
|
fun searchDocs(commonFilters: CommonFilters, documentFilters: DocumentFilters): List<Document> {
|
||||||
@ -267,17 +275,17 @@ fun searchInvoices(commonFilters: CommonFilters, invoiceFilters: InvoiceFilters)
|
|||||||
|
|
||||||
fun searchPayments(commonFilters: CommonFilters, paymentFilters: PaymentFilters): List<Payment> {
|
fun searchPayments(commonFilters: CommonFilters, paymentFilters: PaymentFilters): List<Payment> {
|
||||||
val q = database.find(Payment::class.java)
|
val q = database.find(Payment::class.java)
|
||||||
.where()
|
.where()
|
||||||
.ilike("refNumber", "%" + paymentFilters.refNumberLike + "%")
|
.ilike("refNumber", "%" + paymentFilters.refNumberLike + "%")
|
||||||
// .ge("amount", paymentFilters.amountExceeds)
|
// .ge("amount", paymentFilters.amountExceeds)
|
||||||
//.le("amount", paymentFilters.amountLessThan)
|
//.le("amount", paymentFilters.amountLessThan)
|
||||||
applyFromToHelper(q, commonFilters.from, commonFilters.to, "date")
|
applyFromToHelper(q, commonFilters.from, commonFilters.to, "date")
|
||||||
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchFleets(filters: CommonFilters, fleetFilters: FleetFilters) : List<Fleet> {
|
fun searchFleets(filters: CommonFilters, fleetFilters: FleetFilters): List<Fleet> {
|
||||||
val q = database.find(Fleet::class.java)
|
val q = database.find(Fleet::class.java)
|
||||||
.where()
|
.where()
|
||||||
.ilike("name", "%" + fleetFilters.fleetNameLike + "%")
|
.ilike("name", "%" + fleetFilters.fleetNameLike + "%")
|
||||||
@ -290,17 +298,17 @@ fun searchFleets(filters: CommonFilters, fleetFilters: FleetFilters) : List<Flee
|
|||||||
// applyFromToHelper(q, filters.from, filters.to, "insuranceRenewalDate")
|
// applyFromToHelper(q, filters.from, filters.to, "insuranceRenewalDate")
|
||||||
// applyFromToHelper(q, filters.from, filters.to, "pollutionRenewalDate")
|
// applyFromToHelper(q, filters.from, filters.to, "pollutionRenewalDate")
|
||||||
// applyFromToHelper(q, filters.from, filters.to, "fitnessRenewalDate")
|
// applyFromToHelper(q, filters.from, filters.to, "fitnessRenewalDate")
|
||||||
return q.findList()
|
return q.findList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchReminderLogs(filters: CommonFilters, reminderLogFilters: ReminderLogFilters) : List<ReminderLog> {
|
fun searchReminderLogs(filters: CommonFilters, reminderLogFilters: ReminderLogFilters): List<ReminderLog> {
|
||||||
val q = database.find(ReminderLog::class.java)
|
val q = database.find(ReminderLog::class.java)
|
||||||
.where()
|
.where()
|
||||||
.ilike("reminder_type", reminderLogFilters.reminderType)
|
.ilike("reminder_type", reminderLogFilters.reminderType)
|
||||||
if(reminderLogFilters.actedUpon != null){
|
if (reminderLogFilters.actedUpon != null) {
|
||||||
q.eq("acted_upon", reminderLogFilters.actedUpon)
|
q.eq("acted_upon", reminderLogFilters.actedUpon)
|
||||||
}
|
}
|
||||||
if(reminderLogFilters.fleetId != null){
|
if (reminderLogFilters.fleetId != null) {
|
||||||
q.eq("fleet_sys_pk", reminderLogFilters.fleetId)
|
q.eq("fleet_sys_pk", reminderLogFilters.fleetId)
|
||||||
}
|
}
|
||||||
return q.findList()
|
return q.findList()
|
||||||
|
|||||||
@ -17,6 +17,10 @@ data class POProducts(
|
|||||||
val productName: String = "",
|
val productName: String = "",
|
||||||
val unitPrice: Double = 0.0,
|
val unitPrice: Double = 0.0,
|
||||||
val quantity: 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 description: String = "",
|
||||||
val uom: String = "",
|
val uom: String = "",
|
||||||
)
|
)
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- SQL and bind values -->
|
<!-- SQL and bind values -->
|
||||||
<logger name="io.ebean.SQL" level="TRACE"/>
|
<logger name="io.ebean.SQL" level="WARN"/>
|
||||||
|
|
||||||
<!-- Transaction Commit and Rollback events -->
|
<!-- Transaction Commit and Rollback events -->
|
||||||
<logger name="io.ebean.TXN" level="DEBUG"/>
|
<logger name="io.ebean.TXN" level="DEBUG"/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user