Changeset 708 for trunk


Ignore:
Timestamp:
Nov 15, 2010, 11:48:34 AM (13 years ago)
Author:
gav
Message:

Fix small bug in reactive ratio report, where BigDecimal? not returned and therefore setScale() not available.
Also return error message for endDate < startDate.

Location:
trunk/grails-app
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/ReportController.groovy

    r706 r708  
    9191        params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate)
    9292
    93         def dataModel = taskReportService.getReactiveRatio(params, RCU.getLocale(request))
    94 
    95         // Jasper plugin controller expects data to be a Collection.
    96         chain(controller:'jasper', action:'index', model:[data: [dataModel]], params:params)
     93        def result = taskReportService.getReactiveRatio(params, RCU.getLocale(request))
     94
     95        if(!result.error) {
     96            // Jasper plugin controller expects data to be a Collection.
     97            chain(controller:'jasper', action:'index', model:[data: [result]], params:params)
     98            return
     99        }
     100
     101        flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     102        redirect(controller: 'appCore', action: 'start', params: [showTab:'showReportsTab'])
    97103
    98104    } // reactiveRatio
  • trunk/grails-app/i18n/messages.properties

    r701 r708  
    264264default.file.no.header=The supplied file does not have the correct header lines, please see the template file.
    265265default.not.development.environment.failure=Could not complete operation, dev environment not detected.
     266default.end.date.before.start.date=The end date must be equal to or greater than \
     267    the start date.
    266268
    267269default.doesnt.match.message=Property [{0}] of class [{1}] with value [{2}] does not match the required pattern [{3}]
  • trunk/grails-app/services/TaskReportService.groovy

    r651 r708  
    2424        def result = [:]
    2525
     26        def fail = { Map m ->
     27            result.error = [ code: m.code, args: [] ]
     28            return result
     29        }
     30
    2631        def namedParams = [:]
    2732        namedParams.startDate = params.startDate ?: dateUtilService.today
    2833        namedParams.endDate = params.endDate ?: dateUtilService.today
     34
     35        if(namedParams.endDate < namedParams.startDate)
     36            return fail(code: "default.end.date.before.start.date")
     37
    2938        namedParams.endDate++ // Start of next day required.
     39
    3040        namedParams.immediateCallout = TaskType.read(1)
    3141        namedParams.unscheduledBreakin = TaskType.read(2)
     
    94104        }
    95105        catch(ArithmeticException e) {
    96             log.error "Could not calculate: Assets on Tasks Percentages: "+e
     106            log.info "Could not calculate: Assets on Tasks Percentages: "+e
    97107        }
    98108
    99109        // Work Done.
    100         result.immediateCalloutWorkDone = [total:0, hours:0, minutes:0, percentage:0]
     110        result.immediateCalloutWorkDone = [total:0, hours:0, minutes:0, percentage: new BigDecimal(0)]
    101111        result.unscheduledBreakinWorkDone = [total:0, hours:0, minutes:0]
    102112        result.preventativeMaintenanceWorkDone = [total:0, hours:0, minutes:0]
    103         result.totalPreventativeWorkDone = [total:0, hours:0, minutes:0, percentage:0]
     113        result.totalPreventativeWorkDone = [total:0, hours:0, minutes:0, percentage: new BigDecimal(0)]
    104114        result.totalWorkDone = [total:0, hours:0, minutes:0]
    105115
     
    139149        // Work Done Percentages.
    140150        try {
    141             result.immediateCalloutWorkDone.percentage = (result.immediateCalloutWorkDone.total / result.totalWorkDone.total)*100
    142             result.totalPreventativeWorkDone.percentage = (result.totalPreventativeWorkDone.total / result.totalWorkDone.total)*100
     151            result.immediateCalloutWorkDone.percentage = (BigDecimal)(result.immediateCalloutWorkDone.total / result.totalWorkDone.total)*100
     152            result.totalPreventativeWorkDone.percentage = (BigDecimal)(result.totalPreventativeWorkDone.total / result.totalWorkDone.total)*100
    143153        }
    144154        catch(ArithmeticException e) {
    145             log.error "Could not calculate: Work Done Percentages: "+e
     155            log.info "Could not calculate: Work Done Percentages: "+e
    146156        }
    147157
Note: See TracChangeset for help on using the changeset viewer.