Index: /trunk/grails-app/services/CreateDataService.groovy
===================================================================
--- /trunk/grails-app/services/CreateDataService.groovy	(revision 528)
+++ /trunk/grails-app/services/CreateDataService.groovy	(revision 529)
@@ -845,5 +845,5 @@
                 targetStartDate: dateUtilService.tomorrow,
                 targetCompletionDate: dateUtilService.tomorrow,
-                parentTask: Task.get(1)]
+                parentTask: Task.list()[0]]
 
         taskResult = taskService.save(p)
@@ -858,5 +858,5 @@
                 targetStartDate: dateUtilService.yesterday,
                 targetCompletionDate: dateUtilService.yesterday,
-                parentTask: Task.get(1)]
+                parentTask: Task.list()[0]]
 
         taskResult = taskService.save(p)
@@ -871,5 +871,5 @@
                 targetStartDate: dateUtilService.today,
                 targetCompletionDate: dateUtilService.oneWeekFromNow,
-                parentTask: Task.get(1)]
+                parentTask: Task.list()[0]]
 
         taskResult = taskService.save(p)
@@ -927,5 +927,5 @@
 
         //Entry #1
-        p = [task: Task.get(1),
+        p = [task: Task.list()[0],
                 entryType: EntryType.get(1),
                 comment: "This level sensor is causing us trouble.",
@@ -935,5 +935,5 @@
 
         //Entry #2
-        p = [task: Task.get(1),
+        p = [task: Task.list()[0],
                 entryType: EntryType.get(3),
                 comment: "Cleaned sensor, see how it goes.",
@@ -943,5 +943,5 @@
 
         //Entry #3
-        p = [task: Task.get(1),
+        p = [task: Task.list()[0],
                 entryType: EntryType.get(3),
                 comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.",
@@ -958,5 +958,5 @@
         //AssignedGroup #1
         p = [personGroup: PersonGroup.get(1),
-                task: Task.get(1),
+                task: Task.list()[0],
                 estimatedHour: 2,
                 estimatedMinute: 30]
@@ -965,5 +965,5 @@
         //AssignedGroup #2
         p = [personGroup: PersonGroup.get(2),
-                task: Task.get(1),
+                task: Task.list()[0],
                 estimatedHour: 1,
                 estimatedMinute: 0]
@@ -978,5 +978,5 @@
         //AssignedPerson #1
         p = [person: Person.get(4),
-                task: Task.get(1),
+                task: Task.list()[0],
                 estimatedHour: 1,
                 estimatedMinute: 20]
@@ -985,5 +985,5 @@
         //AssignedPerson #2
         p = [person: Person.get(5),
-                task: Task.get(1),
+                task: Task.list()[0],
                 estimatedHour: 3,
                 estimatedMinute: 30]
@@ -997,5 +997,5 @@
 
         //TaskRecurringSchedule #1
-        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1),
+        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[0],
                                                                                                     recurEvery: 1,
                                                                                                     recurPeriod: Period.get(2),
@@ -1008,5 +1008,5 @@
 
         //TaskRecurringSchedule #2
-        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6),
+        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[0],
                                                                                                     recurEvery: 1,
                                                                                                     recurPeriod: Period.get(1),
@@ -1270,5 +1270,5 @@
         taskProcedureInstance = new TaskProcedure(name: "Daily check")
         saveAndTest(taskProcedureInstance)
-        taskProcedureInstance.addToTasks(Task.get(1))
+        taskProcedureInstance.addToTasks(Task.list()[0])
     }
 
Index: /trunk/grails-app/services/TaskSearchService.groovy
===================================================================
--- /trunk/grails-app/services/TaskSearchService.groovy	(revision 528)
+++ /trunk/grails-app/services/TaskSearchService.groovy	(revision 529)
@@ -251,5 +251,5 @@
     * @param endDate The end date to get tasks for, defaults to the start of tomorrow and is exclusive (less than).
     */
-    def getBudgetTasks(params, budgetStatus=null, startDate=null, endDate=null) {
+    def getBudgetTasks(params, taskBudgetStatus=null, startDate=null, endDate=null) {
         def paginateParams = [:]
         paginateParams.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax)
@@ -261,11 +261,11 @@
 
         def namedParams = [:]
-        namedParams.budgetStatus = budgetStatus ?: TaskBudgetStatus.read(2) // Planned.
+        namedParams.taskBudgetStatus = taskBudgetStatus ?: TaskBudgetStatus.read(2) // Planned.
         namedParams.startDate = startDate ?: dateUtilService.today
-        namedParams.endDate = endDate ?: dateUtilService.oneWeekAgo
+        namedParams.endDate = endDate ?: dateUtilService.tomorrow
 
         def baseQuery = "from Task as task \
                                         where (task.trash = false \
-                                                    and task.budgetStatus = :budgetStatus \
+                                                    and task.taskBudgetStatus = :taskBudgetStatus \
                                                     and task.targetStartDate < :endDate \
                                                     and task.targetCompletionDate >= :startDate \
Index: /trunk/test/integration/TaskSearchServiceTests.groovy
===================================================================
--- /trunk/test/integration/TaskSearchServiceTests.groovy	(revision 528)
+++ /trunk/test/integration/TaskSearchServiceTests.groovy	(revision 529)
@@ -121,9 +121,9 @@
     void testGetPersonsTasks() {
 
-        def result
         def p = [:]
+        def params = [:]
 
         // Todays tasks should be returned, since Person #1 is lead and created the tasks.
-        def tasks = taskSearchService.getPersonsTasks([:])
+        def tasks = taskSearchService.getPersonsTasks(params)
         assert tasks.totalCount == taskCount
 
@@ -131,16 +131,16 @@
         taskA.trash = true
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
+        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
         taskB.trash = true
         taskB.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 2
+        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 2
 
         // Restored tasks should be returned.
         taskA.trash = false
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
+        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
         taskB.trash = false
         taskB.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount
+        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount
 
         // Tomorrows tasks should not be returned.
@@ -148,8 +148,8 @@
         taskA.targetCompletionDate = dateUtilService.tomorrow
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
+        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
 
         // Tomorrows tasks should be returned, if we ask for them.
-        assert taskSearchService.getPersonsTasks([:], null, dateUtilService.today, dateUtilService.tomorrow+1).totalCount == taskCount
+        assert taskSearchService.getPersonsTasks(params, null, dateUtilService.today, dateUtilService.tomorrow+1).totalCount == taskCount
 
         // Yesterdays tasks should not be returned.
@@ -157,8 +157,8 @@
         taskA.targetCompletionDate = dateUtilService.yesterday
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
+        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
 
         // Yesterdays tasks should be returned, if we ask for them.
-        assert taskSearchService.getPersonsTasks([:], null, dateUtilService.yesterday, dateUtilService.tomorrow).totalCount == taskCount
+        assert taskSearchService.getPersonsTasks(params, null, dateUtilService.yesterday, dateUtilService.tomorrow).totalCount == taskCount
 
         // Tasks that span today should be returned.
@@ -166,10 +166,10 @@
         taskA.targetCompletionDate = dateUtilService.tomorrow
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount
+        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount
 
         // Tasks for a different person should not be returned.
         taskA.leadPerson = Person.get(2)
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
+        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
 
         // Tasks for a specified leadPerson should be returned.
@@ -177,12 +177,12 @@
         taskA.leadPerson = Person.get(2)
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 0
+        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0
         taskA.approved = true
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 1
+        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1
         // Moving the task to the trash, stops it being returned.
         taskA.trash = true
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 0
+        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0
 
         // Tasks assigned to a person should be returned.
@@ -193,8 +193,8 @@
                 estimatedMinute: 20]
         assert assignedPersonService.save(p).error == null
-        assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 0
+        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0
         taskB.approved = true
         taskB.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 1
+        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1
 
         // Tasks assigned to a person via a group should be returned.
@@ -209,10 +209,64 @@
                 estimatedMinute: 30]
         assert assignedGroupService.save(p).error == null
-        assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 1 // Only taskB from above.
+        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1 // Only taskB from above.
         taskA.approved = true
         taskA.save(flush:true)
-        assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 2 // taskA and taskB.
+        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 2 // taskA and taskB.
 
     } // testGetTasks()
 
+    void testGetBudgetTasks() {
+
+        def tasks
+        def params = [:]
+        def today = dateUtilService.today
+        def yesterday = dateUtilService.yesterday
+        def tomorrow = dateUtilService.tomorrow
+        def unplanned = TaskBudgetStatus.read(1)
+        def planned = TaskBudgetStatus.read(2)
+
+        assert planned != null
+        assert unplanned != null
+
+        // Default is to return planned.
+        // TaskA and taskB should be unplanned and therefore not returned.
+        tasks = taskSearchService.getBudgetTasks(params)
+        assert tasks.totalCount == 0
+        tasks = taskSearchService.getBudgetTasks(params, planned)
+        assert tasks.totalCount == 0
+
+        tasks = taskSearchService.getBudgetTasks(params, unplanned)
+        assert tasks.totalCount == taskCount
+        assert tasks.contains(taskA)
+        assert tasks.contains(taskB)
+
+        // Planned tasks are returned.
+        taskA.taskBudgetStatus = planned
+        taskA.save(flush:true)
+        tasks = taskSearchService.getBudgetTasks(params, planned)
+        assert tasks.totalCount == 1
+        assert tasks.contains(taskA)
+
+        // Tasks are returned when dates and budget status are specified.
+        tasks = taskSearchService.getBudgetTasks(params, planned, today, tomorrow)
+        assert tasks.totalCount == 1
+        assert tasks.contains(taskA)
+        tasks = taskSearchService.getBudgetTasks(params, unplanned, today, tomorrow)
+        assert tasks.totalCount == 1
+        assert tasks.contains(taskB)
+
+        // No tasks for yesterday
+        tasks = taskSearchService.getBudgetTasks(params, null, yesterday, today)
+        assert tasks.totalCount == 0
+
+        // Tasks that span today are returned.
+        taskA.targetStartDate = yesterday
+        taskA.targetCompletionDate = tomorrow+2
+        taskA.save(flush:true)
+        tasks = taskSearchService.getBudgetTasks(params, planned, today, tomorrow)
+        assert tasks.totalCount == 1
+        assert tasks.contains(taskA)
+
+    } // testGetBudgetTasks()
+
 } // end class
