Ignore:
Timestamp:
Nov 15, 2010, 11:48:34 AM (14 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.