diff --git a/src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt b/src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt index 0bce8f6..09edeb5 100644 --- a/src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt +++ b/src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt @@ -329,6 +329,7 @@ return result * Queries the database for Stock In Traceability Report data. * Joins stock_in_line, stock_in, items, qc_result, inventory_lot, inventory_lot_line, warehouse, and shop tables. * Supports comma-separated values for stockCategory (items.type) and itemCode. + * When "All" is selected, it expands to all categories: MAT, FG, WIP, NM, CMB. */ fun searchStockInTraceabilityReport( stockCategory: String?, @@ -338,7 +339,22 @@ return result ): List> { val args = mutableMapOf() - val stockCategorySql = buildMultiValueExactClause(stockCategory, "it.type", "stockCategory", args) + // Handle "All" option by expanding to all categories + val processedStockCategory = if (!stockCategory.isNullOrBlank()) { + val categories = stockCategory.split(",").map { it.trim() }.filter { it.isNotBlank() } + if (categories.contains("All")) { + // Replace "All" with all categories: MAT, FG, WIP, NM, CMB + val allCategories = listOf("MAT", "FG", "WIP", "NM", "CMB") + val otherCategories = categories.filter { it != "All" } + (allCategories + otherCategories).distinct().joinToString(",") + } else { + stockCategory + } + } else { + stockCategory + } + + val stockCategorySql = buildMultiValueExactClause(processedStockCategory, "it.type", "stockCategory", args) val itemCodeSql = buildMultiValueLikeClause(itemCode, "it.code", "itemCode", args) val lastInDateStartSql = if (!lastInDateStart.isNullOrBlank()) {