my thought is there may be a corrupt/missing file somewhere as to why this isn't working... i'm assuming that you've added a debug to viewinvoice.tpl and checked $total is a price formatted variable ? i'm sure it should be.
I seemingly don't have any invoices on my v7.1.2 dev, but the above code worked on v7.4.2 and v7.2.3 and I don't recall anything in the changelog saying price formatting was bugged in v7.1...
you could try manually uploading the files from the full download version of your installed release and hoping that fixes it... otherwise, wait until you next upgrade.
if you're going to do a lot of manipulating of these price formatting variables, then it's going to be easier if you can get toNumeric() working... yes you can code around without it if you have to, but would be simpler if you had it working.