SambaPOS crashes when used the same action twice in a rule

Afraid not.

Where did the *-1 come from though?
Surely total minus discount will be positive? Discount isnt going to be more that total?
Can compairing to positive 12?
Wont it always be negative…

Oh, wait… :face_with_hand_over_mouth: its late, guessing discount comes back negative? cant remember off top on my head if that is the case or not.
Since discount and service are separate expressions I would question the difference if service is positive and discount is negative.

Could have just done + discount :stuck_out_tongue: if thats the case hehe

1 Like

:man_facepalming:

Sometimes I get so focused at making something work and once it does, I leave it and don’t really look at the whole picture.

I’m going through some of the code I wrote last year starting out and O…M…G…

There was only one thing to do:

2021-03-24_18;47_1616633227_firefox

And now for something completely different:

[=('{PLAIN TOTAL}' == '' ? '{TICKET TOTAL}' : TN('{PLAIN TOTAL}') + TN('{DISCOUNT TOTAL}'))] < 12

[=('{PLAIN TOTAL}' == '' ? '{TICKET TOTAL}' : TN('{PLAIN TOTAL}') + TN('{DISCOUNT TOTAL}'))] >= 12

1 Like

Still not sure its right?
So if plain total is null, do ticket total, if not plain total minus discount ?
Shouldn’t the minus discount be outside ternary?

Seems to be returning the right total

2021-03-24_18;41_1616632916_Samba.Presentation

No wait plain total would be unavailable if discount isn’t there right? So there wouldn’t be a discount needing taking off?

From what I can tell plain total is null/empty when there are no taxes, calculations, discounts, etc.

Am I missing something, so why not just use total minus discount?

Tax I guess, if you had tax free products?

Discount total returns a negative decimal.

Either way, your still off :-p he’s doing constraint not template so no line formatting wanted hehe

1 Like

Yeah, tax-free products/tickets would be a reason why s/he’s running into null/empty plain total

1 Like

Oh, FFS lol

20characters

Ternary seems excessive personally, got to be more overhead than si.ple math. Maybe.
Total minus tax, minus discounts, minus service? Lol

Yep, {PLAIN TOTAL} is blank when there are no calculations that modify {TICKET TOTAL}

So using plain total instead of ticket toal is more likely to misfire your constraints that not

Maybe not service. Actually delivery probably is a service lol, so, actually, yes, it would want to come off to get back to subtotal.

Ternary seems excessive personally, got to be more overhead than si.ple math. Maybe.
Total minus tax, minus discounts, minus service? Lol

Could very well be. I can over complicate things at times.

Actually, might be needed, else you could potentially end up in a loop where the service puts it over 12 so takes it of putting it under so puts back on etc etc etc…

[=F(TN('{TICKET TOTAL}')+TN('{ORDER STATE TOTAL:Gift}')-TN('{ORDER TAG TOTAL:Discount}')-TN('{CALCULATION TOTAL:Discount}') - TN('{CALCULATION TOTAL:Round}'))]

Should give PLAIN TOTAL :smile:

1 Like