@@ -13,7 +13,7 @@ import grails.gorm.transactions.Transactional
1313import grails.plugins.csv.CSVWriter
1414import grails.validation.ValidationException
1515import org.hibernate.criterion.CriteriaSpecification
16-
16+ import org.hibernate.sql.JoinType
1717import org.pih.warehouse.PaginatedList
1818import org.pih.warehouse.api.AvailableItem
1919import org.pih.warehouse.auth.AuthService
@@ -3457,13 +3457,21 @@ class InventoryService implements ApplicationContextAware {
34573457
34583458PaginatedList<ExpirationHistoryReportRow > getExpirationHistoryReport (ExpirationHistoryReportFilterCommand command ) {
34593459List<TransactionEntry > entries= TransactionEntry . createCriteria(). list(offset : command. paginationParams. offset,max : command. paginationParams. max) {
3460- transaction {
3461- // Expired transaction type is hardcoded with id = "4"
3462- eq(" transactionType" ,TransactionType . read(Constants . EXPIRATION_TRANSACTION_TYPE_ID ))
3463- eq(" inventory" ,AuthService . currentLocation. inventory)
3464- between(" transactionDate" , command. startDate, command. endDate)
3465- order(" transactionDate" ," desc" )
3460+ createAlias(" transaction" ," t" ,JoinType . INNER_JOIN )
3461+ if (command. searchTerm) {
3462+ createAlias(" inventoryItem" ," ii" ,JoinType . INNER_JOIN )
3463+ createAlias(" ii.product" ," p" ,JoinType . INNER_JOIN )
3464+ or {
3465+ ilike(" t.transactionNumber" ," %" + command. searchTerm+ " %" )
3466+ ilike(" p.productCode" ," %" + command. searchTerm+ " %" )
3467+ ilike(" t.id" ," %" + command. searchTerm+ " %" )
3468+ }
34663469 }
3470+ // Expired transaction type is hardcoded with id = "4"
3471+ eq(" t.transactionType" ,TransactionType . read(Constants . EXPIRATION_TRANSACTION_TYPE_ID ))
3472+ eq(" t.inventory" ,AuthService . currentLocation. inventory)
3473+ between(" t.transactionDate" , command. startDate, command. endDate)
3474+ order(" t.transactionDate" ," desc" )
34673475 }
34683476return new PaginatedList<ExpirationHistoryReportRow > (entries. collect {ExpirationHistoryReportRow . fromTransactionEntry(it) }, entries. totalCount)
34693477 }