Can not make substraction of Json Results


#1

Hi people i am getting The Total Amount and Paid Amount but i can not make Balance of those two data , my app is getting crushed

indent preformatted text by 4 spaces

val id = data.getInt(“id”)
val names = data.getString(“names”)
val period = data.getString(“period”)
val totalAmount = data.getString(“total_amount”)
val paidAmount = data.getString(“paid_amount”)
val status = data.getString(“status”)

                        var paidAmountFormat = NumberFormat.getInstance().format(paidAmount.toInt())

                        var realPaidAmountFormat = paidAmountFormat+" RWF"

                        var balance = totalAmount.toInt().minus(realPaidAmountFormat.toInt())

                        //Will do this balance automatically once i get here again

                         val paymentRecord = ClientPaymentObject(id,R.drawable.payment,names, period,
                                "Total Amount : "+totalAmount,"Paid Amount : "+realPaidAmountFormat,"Balance : "+balance.toString(),status)

                         listOfPaymentObject!!.add(paymentRecord)