Print Template IF [] with calcaluation [=F(xxx)]


#1

Hi,

It looks like that putting twice the [ … [ … ] …] give me problem.

[LAYOUT]

{ORDERS}

[ORDERS]

VL00VNIU|{QUANTITY}|CODE|-|{NAME}|{PRICE}|0|9997|0|EXO|VAT|E|20|0.0|-|0.00|||||0|{PRICE}|{TOTAL PRICE}|0|-|0|0|0|0|0|0|0
{ORDER TAGS}

[ORDER TAGS]
-- Format for order tags
[='{ORDER TAG PRICE}' != 0 ? 'NIU|{QUANTITY}|CODE|-|{ORDER TAG NAME}|{ORDER TAG PRICE}|0|9997|0|EXO|VAT|E|20|0.0|-|0.00|||||0|{ORDER TAG PRICE}|[=F(TN('{QUANTITY}') * TN('{ORDER TAG PRICE}'))]|0|-|0|0|0|0|0|0|0' : '']

When I put

|{QUANTITY}{ORDER TAG PRICE}|

it shows, e.g. : 2*25 (normal)

when I put the formula, nothing is displayed.

[=F(TN('{QUANTITY}') * TN('{ORDER TAG PRICE}'))]

Is it because the formula is inside the IF[]?

Marc


#2

IIs nothing being displayed when an order is added without an order tag?

This will be because adding square brackets around a line in the ticket template stops that line showing on the print out if it’s value is zero

So looking at your calculation:
[=F(TN(’{QUANTITY}’) * TN(’{ORDER TAG PRICE}’))]

If there is no order tag then there’s is no order tag price so that value becomes zero, so when quantity is multiplied by zero the result is zero. So the square brackets then act to hide that line from the ticket print out as

On your template is the line that has the square brackets at the start and end coloured in black? If so this is the reason it doesn’t show as those square brackets serve to only show a value on the ticket printout if the value is greater than zero

Might be useful to show that part of your ticket template


#3

There are values …

Here a small template to illustrate what I mean:

[LAYOUT]
<L00>A function, OK
<L00>    AAA|[=F(100 + 100)]|BBB
<L00>
<L00>A function in a IF function, OK
[= 0 == 0 ? '<L00>    AAA|[=F(100 + 100)]|BBB' : '']
<L00>
<L00>A variable in IF function, OK
[= 0 == 0 ? '<L00>    AAA|{CALCULATION TOTAL:Discount}|BBB' : '']
<L00>
<L00>A function with the same variable in IF function: NOT OK.
[= 0 == 0 ? '<L00>AAA|[=F(-1 * TN('{CALCULATION TOTAL:Discount}'))]|BBB' : '']
<L00>
<L00>Nothing displayed, however the function is correct, it returns 0.99:
<L00>    function returns: [=F(-1 * TN('{CALCULATION TOTAL:Discount}'))]

Result:

imagen

You can see that in 2. there are brackets [=F(100 + 100)] and it works
In 4. brackets (function) + variable and it returns nothing


#4

This is not a valid string so ternary operator won’t work properly.

0 == 0 ? '<L00>AAA|[=F(-1 * TN('{CALCULATION TOTAL:Discount}'))]|BBB' : ''

In fact it won’t work even you’ll be able to fix that because nesting expressions like [=x[=x]] is not supported.


#5

I got the same problem to print the DETAILED ORDER file (not paper print):

IF ORDER TAG has no price
  THEN don't print the TAG line
  ELSE print the tag line

which is:

[='{ORDER TAG PRICE}' != 0 ? 'Print the line' : '']

So one [] (brackets expression)

Now comes my issue.
If I have 2 ORDER TAGS with price and a multiple order (5 mediano), like below:

imagen

I need to have the total of each ORDER TAG line and:

  • I cannot use ORDER TAG PRICE, as it is the price of one ORDER TAG.
  • I cannot use ORDER TAG TOTAL, as it is the total price of BOTH order tags. (15)
  • I cannot use {Quantity}X{Order Tag Price}, as it would be nesting expressions like [=x[=x]] which is not possible.

Can I use a script?

If yes, as I don’t have the DB layout, can somebody help me with the SQL to

SELECT [Order Quantity]  X [Order Tag Price]) as [Order_Tag_Total_Price_Per_Tag]
WHERE ??? ORDER = the current ORDER and ORDER TAG = the current ORDER TAG

I have no clue on how to pass that information to the script/function in the [ORDER TAGS] section using {Order TAGS}, I don’t know if this is possible neigther

I am not trying to make things difficult, I am live and that scenario happened yesterday and the electronic bill was rejected by the tax administration system because the sum of the lines did not match the total; I was using ORDER TAG TOTAL

So
TAG jkl shows total tag price 15 instead of 10
TAG ghj shows total tag price 15 instead of 5

Marc


#6

OK. I added a new tag for next update so you’ll be able to configure order tag line as …

[ORDER TAGS]
-- Format for order tags
<J00> * {ORDER TAG NAME} | [={QUANTITY}>1 && {ORDER TAG PRICE} > 0?'({QUANTITY} x {ORDER TAG PRICE})':''] [{ORDER TAG TOTAL:{ORDER TAG GROUP}={ORDER TAG NAME}}]

This will print order tag total and also a breakdown of the price if order quantity is greater than one. If order quantity is 1 it will print just the price.


#7

Thank you very much emre.
Can you tell me more or less the period of issuing an update?

In the mean time, I’ll tell the waitress not to submit multiple orders with tags.


#8

I added your account to beta group so you’ll better track the updates. When it is released you’ll see it on the release notes section. Generally we update beta versions multiple times in a week. We release it to public when all new features tested.


#9

Could finally make it that way, however I am waiting for emre solution in the new release.

[='{ORDER TAG PRICE}' != 0 ? 'Sone fields' + Number({QUANTITY} * {ORDER TAG PRICE}).toFixed(2) + 'some fields' : '']

+ {QUANTITY} * {ORDER TAG PRICE} +

Works also but gives me some error due to the number format, I had:
3 x 2.70 = 8.1000000001 and [=FF()] cannot be use, so:

+ Number({QUANTITY} * {ORDER TAG PRICE}).toFixed(2) +

gives 8.10