calculate unpaid balance