plant wise filter
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user