Index: trunk/grails-app/services/InventoryReportService.groovy
===================================================================
--- trunk/grails-app/services/InventoryReportService.groovy	(revision 671)
+++ trunk/grails-app/services/InventoryReportService.groovy	(revision 676)
@@ -243,3 +243,103 @@
     } // getInventoryValueDetailed()
 
+    /**
+    * Get the data for the inventory overiew value.
+    * @param params The request params, may contain params to specify the search.
+    * @param locale The locale to use when generating result.message.
+    */
+    def getInventoryValueOverview(params, locale) {
+        def result = [:]
+
+        result.inventoryItemCount = 0
+        result.inventoryItemTotalValue = new BigDecimal(0)
+        result.currency = null
+        result.errorMessage = null
+        result.summaryOfCalculationMethod = "This report does not convert between different currency.\n"
+        result.summaryOfCalculationMethod += "Therefore all item's are checked to ensure that currency is the same."
+
+        result.site = Site.get(params.site.id.toLong())
+
+        if(params.inventoryTypes)
+            result.inventoryTypes = params.inventoryTypes.collect { InventoryType.get(it.toInteger()) }
+        else
+            result.inventoryTypes = InventoryType.findAllByIsActive(true, [max:254, sort:'name'])
+
+        if(params.inventoryGroups)
+            result.inventoryGroups = params.inventoryGroups.collect { InventoryGroup.get(it.toInteger()) }
+        else
+            result.inventoryGroups = InventoryGroup.findAllByIsActive(true, [max:254, sort:'name'])
+
+        def fail = { Map m ->
+            result.error = [ code: m.code, args: m.args ]
+            result.errorMessage = g.message(result.error)
+            result.currency = null
+            //result.inventoryItemTotalValue = new BigDecimal(0)
+            return result
+        }
+
+        // Base query.
+        def q = new HqlBuilder().query {
+            select ''
+            from 'InventoryItem as inventoryItem',
+                    'left join inventoryItem.inventoryLocation as inventoryLocation',
+                    'left join inventoryLocation.inventoryStore as inventoryStore'
+            where 'inventoryItem.isActive = true'
+                namedParams.siteId = result.site.id
+                and 'inventoryStore.site.id = :siteId'
+        }
+        def baseWhereLogic = new ArrayList(q.whereClauseTerms)
+
+        // Count the inventoryItems.
+        q.select = 'count(distinct inventoryItem)'
+        result.inventoryItemCount = InventoryItem.executeQuery(q.query, q.namedParams, q.paginateParams)[0]
+
+        // Get the first currency found on this site.
+        q.paginateParams.max = 1
+        q.select = 'inventoryItem.estimatedUnitPriceCurrency'
+        result.currency = InventoryItem.executeQuery(q.query, q.namedParams, q.paginateParams)[0]
+
+        // Count the distinct currency found.
+        q.select = 'count(distinct inventoryItem.estimatedUnitPriceCurrency)'
+        def currencyCount = InventoryItem.executeQuery(q.query, q.namedParams)[0]
+
+        // Get total value.
+        q.select = 'sum (inventoryItem.estimatedUnitPriceAmount * inventoryItem.unitsInStock)'
+        result.inventoryItemTotalValue = InventoryItem.executeQuery(q.query, q.namedParams)[0]
+
+        // Get values for each group.
+        q.and 'inventoryItem.inventoryGroup.id = :groupId'
+        def tempGroups = []
+        result.inventoryGroups.each() { group ->
+            q.namedParams.groupId = group.id
+            def groupValue = InventoryItem.executeQuery(q.query, q.namedParams)[0] ?: 0
+            tempGroups << [name: group.name, value: groupValue]
+        }
+
+        // Cleanup and reset query.
+        q.namedParams.remove('groupId')
+        q.whereClauseTerms = baseWhereLogic
+        result.inventoryGroups = tempGroups
+
+        // Get values for each type.
+        q.and 'inventoryItem.inventoryType.id = :typeId'
+        def tempTypes = []
+        result.inventoryTypes.each() { type ->
+            q.namedParams.typeId = type.id
+            def typeValue = InventoryItem.executeQuery(q.query, q.namedParams)[0] ?: 0
+            tempTypes << [name: type.name, value: typeValue]
+        }
+
+        // Cleanup and reset query.
+        q.namedParams.remove('typeId')
+        q.whereClauseTerms = baseWhereLogic
+        result.inventoryTypes = tempTypes
+
+        if(currencyCount != 1)
+            fail(code:'report.error.multiple.currency.found') // No return, populate errors but continue report.
+
+        // Success.
+        return result
+
+    } // getInventoryValueOverview()
+
 } // end class
