I’m trying to get the balance to show on an invoice only where a payment has been made.
Balance is displayed correctly when a payment has been made and a reduced total is there, but when no payment has been made, the word “balance” is still displayed on the invoice… see below.
With payment:
Without payment:
Am I doing something wrong or is this an issue ? am using v5.1.58
Try using {REMAINING TOTAL} instead of {BALANCE}.
I remember changing this before, not sure if it was a similar issue to this though, it was a while back.
Hmm…Your template look fine. It should not display Balance: when {BALANCE} is zero.
Maybe try another square bracket [<J10>Balance|{BALANCE}] but I doubt that because the whole section already wrap in bracket [PAYMENTS]
Or you can use script as workaround if it don’t work. or ternary expression <J10>[=TN('{BALANCE}') > 0 ? 'Balance:']|{BALANCE}
Or [=TN('{BALANCE}') > 0 ? '<J10>Balance:|{BALANCE}']
yeah thanks @QMcKay… I realised that i just copied and pasted the wrong template… because i had to change it back to what i had when the changes weren’t working… and yes i figured that out… but it was working ok for one payment which is probably the most that we would get on any given day.
I had tried the [<J00>Balance:|{BALANCE}] but that was what was producing the issue that i highlighted above.
I have tried this [<J00>Balance:|[=F(TN('{BALANCE}'))]] as you suggested and it worked perfectly, thankyou…
The TN() function means “To Number”, so it ensures a value is returned no matter what.
Than means if {BALANCE} (or any other tag) contains NULL or some other non-numeric content, then TN() will convert the content to the numeric value of 0.
I suspect {BALANCE} might hold NULL when no Payment has been made, which is not the same as 0, so the [conditional brackets] fail to suppress the line.
I did some more tests, and this appears to work as well:
[<J10>Balance:|[{BALANCE}]]
^ ^
That “double bracketing” was introduced late in V5 so that we can distinguish which value needs to be checked to suppress the line when you have multiple values on the same line. But even if you have only a single value on the line it is still safe to use, and probably more accurate to do so.
So the first 2 of these work, but the last one does not: