SambaPOS Forum
English Boards => V3 Development => Topic started by: JohnS on July 02, 2013, 06:19:33 am
-
Emre,
How do you use the Custom Constraint field in Rules?
I need to make a rule execute only if a customer has been selected.
-
It depends. Which rule is that?
-
Order Added to Ticket.
I am working on cash discounts based on the item/item group selected but only if a customer has been selected. So I need to check the value of a variable I created with Update System Settings.
-
You can use it on custom constraint area like
{:MySetting} == 1
Rule executes if MySetting equals 1;
-
Another Alternative might be using Ticket States
Ticket.IsInState("Promotion")
Rule executes if Any ticket state have Promotion Value.
-
That's the only thing I didn't try ==
Thx Emre
-
You can use it on custom constraint area like
{:MySetting} == 1
Rule executes if MySetting equals 1;
What about strings? Do we need to enclose them in quotes?
-
Another Alternative might be using Ticket States
Ticket.IsInState("Promotion")
Rule executes if Any ticket state have Promotion Value.
And now I can't get this working.
I have set the Ticket State to Member: Discount when a customer is selected - This works.
The rule for applying item discounts has Ticket.IsInState("Discount") set as the Custom Constraint and the rule executes whether a customer has been selected or not.
-
Let me test that. I'll be back.
Edit: Which rule are you using to apply item discounts?
Edit 2: I've tested it and it works fine for me. There might be two reasons.
1. There might be a typo. Check Trailing spaces.
2. Not every rules can access Ticket info. You can access Ticket data from rules related with tickets like "Ticket Closed, Ticket Created, Order Added, etc."
-
You can use it on custom constraint area like
{:MySetting} == 1
Rule executes if MySetting equals 1;
What about strings? Do we need to enclose them in quotes?
It should be:
"{:MySetting}" == "Blah"
That means we should enclose both parts.
When you have free time check http://fluentscript.codeplex.com/documentation. (http://fluentscript.codeplex.com/documentation) We are using it as the Expression Evaluator :)
-
1. There might be a typo. Check Trailing spaces.
Done.
2. Not every rules can access Ticket info. You can access Ticket data from rules related with tickets like "Ticket Closed, Ticket Created, Order Added, etc."
Rule I'm using is Order Added to Ticket
The process is
Customer is selected
- Update Ticket State, Statename Member, State Discount
- Order Added to Ticket, Constraint Ticket.IsInState("Discount"), and MenuItemGroupCode matches, give $ discount & tag item as discounted
-
Emre,
I still don't get what I'm doing wrong here.
I can set a Ticket State when I select a Member -> Discount: Member
But I cannot use - Ticket.IsInState("Member") as a constraint. The Rule always executes even when no Member has been selected.
What am I missing?
-
My bad. It looks like our script engine does not support overloaded methods. On next release it should work.
You'll be able to use:
Ticket.InState(StateName,State)
or
Ticket.IsInState(State)