Actions, Rules & Automation Commands Explanation

Do the coupons need to be tracked? If you print of a coupon would it say something like “Order 2 Pizza and get 1Free”?. personally i wouldnt want to track that as my coupon/voucher is printed on thermal 80mm paper and customers usually dont have something like that so wont be able to copy it. And if they did, at least they are coming back to your store for the pizzas :slight_smile:

Im not sure you would use Entities to do this but JTRTech can advise better

I think maybe we can discuss better my sugestion idea when I get home.

Just to keep things clear can we clarify some terminology so we are all on the same page.

An ORDER is a product/item line on a TICKET.
When you say customer spends so much on an ORDER I am presuming you mean TICKET.
I dont mean to be penicity but its better if we are all talking in the same way and that is the way things are called within samba so really the best way for us to refer to them.
A customers whole order is the TICKET, the things be has ordered are the ORDERS.

I too would personally like to track like you sugest.
This would also allow you to make a report to show the amount of unclaimed coupons. How much value to would place on a report like that is up to you but its a good thing to know I think.
Vouchers would obviously be tracked through their account. If your not using accounts I would recomend it that way myself.

We can go through my sugestions when I get home.

1 Like

ok @digithai am home.
so just recap what you currently have for coupons?

Any luck? The hotel entity setup give you any ideas?

good morning JTR, im working on it, things are starting to make more sense…

I’m located at GMT+7, so i had hit the bed last light. i’ll post my updates in a few hours.
thanks!

Ok, So i tried to read through the links properly and re-evaluated what im trying to accomplish.

So my current simplified conclusion to what i am trying to do is:

Coupons:
• An Entity object with Unique ID, Redemption status, expiry date and Text Description.
• On the Ticket screen, there will be an automation command (Button) ‘Issue Coupon’. OnClick generates a popup that will ask for Description. This description will be saved into the New Coupon generated. So technically submission of the message triggers ‘Create Coupon’ action which should be able to take the message as input. The created Coupon’s code has to be returned and added to the Ticket so that it can be printed along with the Bill for the customer(When Deliverer is assigned).

Vouchers:
• An Entity object with Unique ID, Redemption status, expiry date and Amount in numbers.
• Vouchers will be auto-generated depending on the total amount in the ticket. This generation will have to be done as soon as i assign the Deliverer to the ticket. Again, voucher code will be printed along with the customer Bill.

Redeeming Coupons and Vouchers
• Both Coupons and Vouchers will be redeemed by providing the code in the numberpad. If available, the coupon or voucher is assigned to the ticket.
• For Coupon the Description will need to be displayed in the ticket header so the sales employee is able to read that and mark relative products free/gift and flag it with the coupon.
• For Vouchers the amount has to be subtracted from the ticket as discount with the voucher code as the flag.

So that’s my whole idea.
To implement this, im following these two tutorials:
• Coupons: https://sambapos.org/wiki/doku.php/en/promotion_coupons_documentation
[The link i had shared earlier … The Coffee shop example]
• Vouchers: Printing Custom Discount Vouchers
[The Vouchers link from sid252uk]

So i currently need to figure out how to:
• Create a popup text input, and submit this to a Create Entity Action.
• set the date on the Create Entity Action.
• Add discounts to the Ticket with some explanation text (Voucher ID)

Ok. So far i have managed to generate a voucher or coupon at the correct point of time. what i need now is to get the Voucher ID from the Create action to that i can add that the ticket to be able to print it with the bill.

However i cant seem to figure out how to get the Voucher ID from the Create Entity Action and add that to the Ticket.

That was what I was saying.
On your crate coupon button or a confirmation ask question if you prefer it triggers one command rule which has an execute automation command action.
That action has a command value of the random/unique id and the command name triggers a seccond rule which creates entity with that id, then you add a action to select that entity using the command value for the name, then additional update entity actions using command value again for the entity name and using whatever source you need for the update data.
For description use [?Description] which will show a popup with keyboard.
Will demo in half hour for you.

How to use Constraints in an action?

I have a rule when an automation command is executed [Add Deliverer to ticket] At this point i need to make a check if the total amount is more than 1000.

For testing i added a Show Message box, and added {TICKET TOTAL} > 1000 but it doesn’t seem to work

In the message box, {TICKET TOTAL} displays the correct amount. but the same thing in constraints fails to have an affect.

I have tried these for Constrains already:
{TICKET TOTAL} > 1000
{:TICKET TOTAL} > 1000
[TICKET TOTAL] > 1000
[:TICKET TOTAL] > 1000

{TICKET TOTAL} >= 1000
{:TICKET TOTAL} >= 1000
[TICKET TOTAL] >= 1000
[:TICKET TOTAL] >= 1000

Even tried without spaces… without any success…

Firstly thats a bad place to put that as in theory the ticket was closed in the previous action :slight_smile:

When using > or < you should always TN the tag to ensure it is returned as a number not a string TN(’{TICKET TOTAL}’)
Additionally I have always had difficulties getting larger/smaller or = to to work (probably just me) but I opted to stick to just >/< and change the value;

TN('{TICKET TOTAL}') > 999

Where do you intend to put this?

lol! Fair point on the Action sequence! :slight_smile:

Ideally thats my trigger to generate the Vouchers depending on how much the client spent. After generating the voucher, it needs to be assigned to the ticket in order to print with the Customer Bill.

Since this is a purely delivery setup, the idea is to generate the voucher when a deliverer is assigned, print the customer bill and voucher, hand it over to the delivery guy.

When the delivery guy returns, we close the ticket.

*I tried the TN() thing and it doesn’t seem to work for some reason. Output shows TN(‘931.00’)

It seems our office building needs to run some electrical maintenance, and we will have to shut down our server overnight. So i’ve got about 30 minutes more here until i shut everything down for the night :frowning:

Sorry to put you on overnight holds…really appreciate you helping us out JR!

In the message it might be looking at the TN as text rather than a function… not sure…
You might want to split the rule if that’s the case as there might be some issues with it printing before the coupon entity etc is made.
The first rule being a starter command having two execute automation command actions;
Evaluate Coupon with TN(’{TICKET TOTAL}’) > 999 constraint which fires the rule to create the coupon and add to ticket.
Deliverer Command with no constraint but set to background = true so that it waits for other rules to finish before firing allowing the other action to fire if needed and its rule to happen before doing the deliverer command.
That make sense?

Makes Sense… i’ll try to move things to a trigger prior to this and see how things go.
Anyways, time to shut this down now…

Will touch base tomorrow, will let you know of my progress. :slight_smile:

Have a good day!
Thanks again.

Need to wrap that in an expression, as such:

[=TN('{TICKET TOTAL}')] > 999

The [= ... ] part is an expression that evaluates the data.

1 Like

Thanks QMcKay, [=TN(’{TICKET TOTAL}’)] > 999 did work. But not on the custom constraint box on the Action Item.

So, i created a new rule, triggered it on Entity Deliverer Change and check the net amount using that condition. Works perfectly and Voucher was generated with all the right fields including the Ticket number that it was issued with.

Next issue i landed up on now is how to load this newly created Voucher and assign it to the Ticket for printing.

I created a Load Voucher Action

and an Update Ticket Entity to assign the voucher to the ticket.

my Rule is:

Im assuming my problem is the way im searching for the Entity. What are your suggestions?
‘Creation Ticket Id’ thats the name of the field that stores the Ticket ID.

Already double checked with the generated vouchers, ticket id is correct.

You have mentioned ticket ID and used ticket number at least twice… you havent mixed them up along the way have you?

ok yeah… im using the {TICKET NUMBER} to generate the voucher, so i’d need the same to find that voucher and assign to the ticket.

Still think your going about it wrong way in my mind. Although I have never used the search value for changing entity only used the actual name.
If you triggered the creating of the voucher using execute automation command with a command value of {RANDOM} or whatever your using to generate the voucher code. That way you can very specifically name the entity rather than search.
Also you can use the change ticket entity action to also create setting can create entity to true.

ok yeah! if the search doesnt work, i could use the TICKET NUMBER to have the Entity Name for Voucher as that would always be Unique.

So Ideally, ticket numbers never repeat… that right ?

or is there {TICKET ID} that is a unique ID which i could use as Voucher Primary Field ?

Both will be unique, ID is not generated until ticket submission/closing so in theory should be sequential unlike ticket number excluding if you void all orders after closing.