I'll not be able to help you more with Painless. I can only suggest to try some following expressions :
"inline" : "double d = doc['chargeamount'].value; return d;"
"inline" : "Double.valueOf(doc['chargeamount'].value);"
"inline" : "Double.valueOf(doc['chargeamount'].value).intValue;"
Or some else to determine the type of your field... Good luck !