plant wise filter

This commit is contained in:
gowthaman 2024-05-16 17:15:00 +05:30
parent bcdf15a034
commit e68b24b557
2 changed files with 12 additions and 7 deletions

View File

@ -19,6 +19,7 @@ data class CommonFilters(
val from: LocalDate = baseDate,
val to: LocalDate = maxDate,
val vendor: List<Long>? = null,
val plant: List<Long>? = null,
val sortAsc: Boolean = true,
val sortBy: String = IGNORE
)
@ -112,14 +113,18 @@ data class ReminderLogFilters(
fun <T> applyVendorHelper(q: io.ebean.ExpressionList<T>, vids: List<Long>?) {
if (vids.isNullOrEmpty()) return
// q.apply {
// q.`in`("vendor", vids)
// }
// println(vids)
// println(vids[0])
q.eq("vendor_sys_pk", vids[0])
}
fun <T> applyPlantFilter(q: io.ebean.ExpressionList<T>, vids: List<Long>?) {
if (vids.isNullOrEmpty()) {
q.`in`("unloadingPlantId", Session.currentUserPlants().map { it.plantId })
} else {
q.`in`("unloadingPlantId", vids)
}
}
fun <T> applySortHelper(q: io.ebean.ExpressionList<T>, sortBy: String, asc: Boolean) {
if (sortBy == IGNORE) return;
val order = if (asc) "ASC" else "DESC"
@ -232,7 +237,7 @@ fun searchIncomingInventory(
val q = database.find(IncomingInventory::class.java).where()
applyFromToHelper(q, commonFilters.from, commonFilters.to, "date")
applyVendorHelper(q, commonFilters.vendor)
q.`in`("unloadingPlantId", Session.currentUserPlants().map { it.plantId })
applyPlantFilter(q, commonFilters.plant)
applySortHelper(q, commonFilters.sortBy, commonFilters.sortAsc)
return q.findList()
}

View File

@ -21,7 +21,7 @@
</appender>
<!-- SQL and bind values -->
<logger name="io.ebean.SQL" level="WARN"/>
<logger name="io.ebean.SQL" level="DEBUG"/>
<logger name="org.apache.http.client.protocol.ResponseProcessCookies" level="ERROR"/>
<!-- Transaction Commit and Rollback events -->