Grails groovy boolean returns as null

I have this function that returns two integers and a boolean in the Service class:

def setEntityRecordBalance(EntityRecord entRec, Map params) {
        float totalBalance = 0
        int redIssues = 0, yellowIssues = 0
        boolean insured = false

        /* For each account owned by this entity, get its figure in USD and then add to running total. */
        if (entRec.accounts == []) {
            redIssues++
            setCleanFlag(entRec.redIssues, 'No accounts found.')
            return [redIssues, yellowIssues]
        }
        else {
            entRec.accounts.each {
                def account = AccountRecord.findWhere(uniqueId: it.uniqueId, accountId: it.accountId,
                                                    batchID: params.selectedBatch.id)
                if (account.amount == null)
                    totalBalance += 0
                else
                if (account.currencyType == null || account.currencyType.equalsIgnoreCase('USD'))
                    totalBalance += account.amount
                else
                    totalBalance += getUSDamount(account)

                if (account.insurance != null && (account.insurance.equalsIgnoreCase('Y') || account.insurance.equalsIgnoreCase('YES')))
                    insured = true  
            }
        }
        entRec.balance = totalBalance
        return [redIssues, yellowIssues, insured]
    }

      

Now, in the same service class, I have another operator in a function calling this function like this:

def (redFlags, yellowFlags, insured) = setEntityRecordBalance(newEntityRecord, params)
    println "<><><> Value of insured: " + insured + " " + redFlags + " " + yellowFlags
def (redFlgs, yellowFlgs, isReportable) = setEntityRecordBalanceFlags (newEntityRecord, insured)

      

I am getting two integers, but the boolean is returned as null, why?

This is the error I am getting:

<><><> Value of insured: null 1 0
| Error 2014-08-16 18:34:34,857 [http-bio-8080-exec-10] ERROR errors.GrailsExceptionResolver  - MissingMethodException occurred when processing request: [POST] /FatcaOne_0/customer/saveNewEntityRecord - parameters:
status:
entityJurisdiction:
countryCode:
taxIdNumber:
uniqueId: 123
entityName: asdf
generalComments:
secondaryId: 234
address:
subStatus:
cityTown:
telephone:
giin:
No signature of method: com.twc.fatcaone.FileImportService.setEntityRecordBalanceFlags() is applicable for argument types: (com.twc.fatcaone.EntityRecord, null) values: [com.twc.fatcaone.EntityRecord : (unsaved), ...]
Possible solutions: setEntityRecordBalanceFlags(com.twc.fatcaone.EntityRecord, boolean). Stacktrace follows:
Message: No signature of method: com.twc.fatcaone.FileImportService.setEntityRecordBalanceFlags() is applicable for argument types: (com.twc.fatcaone.EntityRecord, null) values: [com.twc.fatcaone.EntityRecord : (unsaved), ...]
Possible solutions: setEntityRecordBalanceFlags(com.twc.fatcaone.EntityRecord, boolean)
    Line | Method
->> 1672 | $tt__createNewEntityRecord in com.twc.fatcaone.FileImportService$$EOn7yRsm
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    323 | saveNewEntityRecord        in com.twc.fatcaone.CustomerController$$EOn7xmG8
|    198 | doFilter . . . . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter                   in grails.plugin.cache.web.filter.AbstractFilter
|   1145 | runWorker . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run                        in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run . . . . . . . . . . .  in java.lang.Thread

      

+3


source to share


1 answer


Because here

return [redIssues, yellowIssues]

      



You only return two elements without the third boolean

+2


source







All Articles