Calculation Rate based on Report Expression

@emre am just wondering if it might be possible to set a calculation method of rate based on a report expression amount.
My discounts setup has gotten quite confusing in its automation to refresh the shown discount given several senarios where sometimes ticket refresh is required and others where its not and then working arround autoselect and the reset ticket for update calculation causing drop of the autoselect.
Just working on a service charge calculation and notice that a basic rate on ticket total refreshes without issue on portion change etc and no effect on autoselect.
Was wondering is it might be feasible to ad a field for a custom amount to calculate rate on?
So rate would be say 10% and method would be rate from custom expression then in the expression field you could use report expression to calculate the total amount to base the rate on. In my case {TICKET ORDER TOTAL EXP:

[=Math.floor((TN(’{TICKET ORDER TOTAL EXP:(OS.NewBook GLA=2101)&&(ODI=True)&&(OS.GStatus= )}’)*0.1)/0.05)*0.05]
Is my update calculation amount formula for 10% off drinks (newbook gla 2101) rounded to 5p

Have you tried using expressions in parameter for the add calcultation action.

Curently thats what i do using fixed method.
What method would you suggest?

Fixed amount doesnt update.
Custom does nothing.
Thats what I was getting at is you can set a rate which auto updates but rate alone doesnt work as its rate on just drinks.

What do you mean by this?

custom method doesnt seem to like the expression in calculation amount, not sure what its expecting.

To use custom you need to create a script for your expression with handle of Calculation_Your Calculation Name

1 Like

What function name would you use?

This is the only example ive found of a custom calcluation script.

result = 0.05 - ((Ticket.PSum + Ticket.PreSum + Ticket.Tax) % 0.05)

Where did you find that?
This might be what im after…

Long time ago 2015 we had a discussion in v4 for some reason I never forgot it so anytime someone mentions custom calculation it always pops in my head. [Resolved] Rounding by Ticket Total Exactly Type!

In fact I think it was just few days before you joined forum lol

Thanks, will have a play in a second

You show example also here

What are those value expressions, they are different to report values…

Its some hardcoded hidden stuff. Havnt used it in years so dont ask me lol May need to explore it.

1 Like

They predated custom reports. So it was some early expressions. Custom Reports kinda made them obsolete. Heck try using some modern expressions with custom reports and set handle as mentioned above… that may just work i Dunno.

1 Like

Hmmm, may need some input from @emre
Without reference for whatever format that is I can only take wild guesses.
Tested using a simple {TICKET TOTAL} as;

result = {TICKET TOTAL} * 0.1
result = TN(’{TICKET TOTAL}’) * 0.1
result = [=TN(’{TICKET TOTAL}’)] * 0.1

Without any luck.

Emre is very busy I wouldnt expect a response from him for a while. But I can say that tags like that probably wont work. We are dealing with scripts. Any tags need to be fed into it from sambapos side.

Ticket.X seems to be something…

But without a function how would you pass variables? Even if that were the case it would feed the value as apposed to the expression.
This ill just have to wait till emre gets time to elaborate.

Searched sugest that Fluentscript might be a key term which comes from v3 by looks of it.

1 Like