| @@ -329,6 +329,7 @@ return result | |||||
| * Queries the database for Stock In Traceability Report data. | * 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. | * 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. | * 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( | fun searchStockInTraceabilityReport( | ||||
| stockCategory: String?, | stockCategory: String?, | ||||
| @@ -338,7 +339,22 @@ return result | |||||
| ): List<Map<String, Any>> { | ): List<Map<String, Any>> { | ||||
| val args = mutableMapOf<String, Any>() | val args = mutableMapOf<String, Any>() | ||||
| 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 itemCodeSql = buildMultiValueLikeClause(itemCode, "it.code", "itemCode", args) | ||||
| val lastInDateStartSql = if (!lastInDateStart.isNullOrBlank()) { | val lastInDateStartSql = if (!lastInDateStart.isNullOrBlank()) { | ||||