Printer Template not functioning as expected

Hi,

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

Template:

Is that your whole template?
Please copy and paste it as text, makes it a bit easier for people to go through.

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.

I tried that, but it gives me remaining balance all the time, even if a payment hasn’t been made, which is rather redundant.

I only want balance to be displayed if a payment has been made.

Here is the full template in text:

[LAYOUT]
-- General layout
<EC>
<BMP>c:\logo\logo.bmp
<EL>
<J00>
<L00>
<C00>{TICKET DATE} {TIME}
{ENTITIES}
<F>-
{ORDERS}
<F>=
<EB>
{DISCOUNTS}
[<J10>Total Gift:|{ORDER STATE TOTAL:Gift}]
{TAXES}
<J00>GST inc:|{TAX TOTAL}
{SERVICES}
<J10>Total:|{TICKET TOTAL}
{PAYMENTS}
<DB>
<F>=
<C00>TAX INVOICE
<L00>
<C10>Thank you for dining at 
<L00>
<L00>

[DISCOUNTS]
<J00>{CALCULATION NAME} %{CALCULATION AMOUNT}|{CALCULATION TOTAL}

[SERVICES]
<J00>{CALCULATION NAME}|{CALCULATION TOTAL}

[PAYMENTS]
<J00>{PAYMENT NAME}|{PAYMENT AMOUNT}
<J10>Balance|{BALANCE}

[ORDERS]
-- Default format for orders
<J00>- {QUANTITY} {NAME}|{TOTAL AMOUNT}
{ORDER TAGS}

[ORDERS:Gift]
-- Format for gifted orders
<J00>- {QUANTITY} {NAME}|**GIFT**
{ORDER TAGS}

[ORDERS:Void]
-- Nothing will print for void lines

[ORDER TAGS]
-- Format for order tags
<J00> * {ORDER TAG NAME} | [{ORDER TAG PRICE}]

[ENTITIES:Table]
-- Table entity format
<C10>{ENTITY NAME}

[ENTITIES:Customer]
-- Customer entity format
<J00>Customer: {ENTITY NAME} | {ENTITY DATA:Phone}

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}']

Doing this:

[PAYMENTS]
<J00>{PAYMENT NAME}|{PAYMENT AMOUNT}
<J10>Balance|{BALANCE}

… will show the Balance after every Payment Type, so you probably don’t want that, because it looks like this:

Cash:                                      20.00
Balance                                    60.00
Credit Card:                               20.00
Balance                                    60.00
1111 1111-Celeste:                         50.00
Balance                                    60.00
Cash USD:                                  20.00
Balance                                    60.00
Credit Card USD:                           40.00
Balance                                    60.00

Doing this is more likely what you want:

<F>-
{PAYMENTS}
[<J00>CHANGE:|[=F(TN('{CHANGE TOTAL}'))]]
[<J00>Balance:|{BALANCE}]
[<F>=

Because that ^ producies this:

Cash:                                      20.00
Credit Card:                               20.00
1111 1111-Celeste:                         50.00
Cash USD:                                  20.00
Credit Card USD:                           40.00
Balance:                                   60.00

And when the Ticket is fully paid, the Balance line does not show at all …

Cash:                                      80.00
Credit Card:                               20.00
1111 1111-Celeste:                         50.00
Cash USD:                                  20.00
Credit Card USD:                           40.00
Cash:                                      60.00

You can make it a little more robust by using this:

[<J00>Balance:|[=F(TN('{BALANCE}'))]]
1 Like

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…

Actually, to prove a point i put both lines in link this:

{PAYMENTS}

[Balance:|[=F(TN(’{BALANCE}’))]]

[Balance:|{BALANCE}]

=

And this is what i got when there is no payment:

I think this might be a bug. worth looking into in any case.

Thanks again !

What? That mean SambaPOS interpret {BALANCE} alone is not 0 but [=F(TN(‘{BALANCE}’))] is 0?

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:

[<J10>Balance:|[=F(TN('{BALANCE}'))]]
[<J10>Balance:|[{BALANCE}]]
[<J10>Balance:|{BALANCE}]

yep perfect. Thanks again !