Creating Ticket Logs to Improve Security


#1

:information_source: You need to install at least 5.1.51 version

Why we need logging?

SambaPOS contains improved ticket logging system to improve security. Adding Admin PIN’s or limiting staff permissions is always a good choice but each permission adds a little complexity to workflow. Instead of limiting users keeping track of how certain features used might be a better solution. By using techniques demonstrated here you can track anything done inside tickets. In this tutorial we’ll keep track of how many times print button clicked and which orders cancelled and how tickets settled.

Enabling Logging

Add Ticket Log action is used to keep logs for tickets.

We can use log category to group / separate logs for certain actions. As I’ll keep track of print button, order cancellations and payments I’ll have three categories. For this reason instead of typing a static category name inside action I’m configuring category as a variable with [:Category] syntax so I can define it inside rules. Log is also a variable data so I can add detailed info about log. To demonstrate the difference I named it as Details.

Display Ticket Log action shows log details inside tickets. I’m also configuring an action for it.

To see ticket logs I can add a button to ticket screen. I’m adding an Automation Command for that. Automation commands appears as buttons on Ticket Screen.

I’ve set Button Header as Log but you can change it if you want.

I want this button to appear in Ticket Screen with Log label. I may not want non-admin users to see logs so I can map Log button to a specific user role. I’m configuring it on Mappings page. I’ll also leave Enabled States empty to be able to use Log button on closed tickets.

Finally I need to create a new Rule to define what Log button will do when clicked.

  1. Select Event Name as Automation Command Executed.
  2. Add a constraint to define for which button this rule will work.
  3. Click Select Actions link and add Display Log action we recently created.

So when a button clicked Automation Command Executed event fires. If that button named as Display Ticket Log SambaPOS will execute Display Log action.

So we enabled basic Logging system. It is empty for now. We’ll use Add Ticket Log action to add logs.

Logging Printing

I’ll add a log when Print Bill button clicked. Print Bill button is also an Automation Command. I can modify pre-configured Print Bill Rule to include logging action or create a separate rule for Print Bill button. We can create multiple rules for events to be able to manage them easily. I’ll create a separate rule for logging.

That will add a log every time we click on Print Bill button. I named log category as Bill Printing and added Ticket Total. This is important because that will keep log of actual ticket total at the time Print Bill button clicked.

:bulb: Hint: To learn possible values that can be read with printing tags like {TICKET TOTAL} you can create a new printer template and refer to tag list.

Now we should sort rules to define which one will work first.

VERY IMPORTANT STEP!!!

When you have multiple rules for an automation command you need to order them properly to define which one will work first. Logging should work first. If Print Bill Rule works first it will close ticket and logs won’t gets saved. Click Sort Rules and move Logging rule on top.

Let’s see how it works. I’ll create a ticket, add two orders, print bill and add one more order.

So I can clearly see a Bill Printed when Ticket Total was $3.00 but final ticket total is $6.49. That case might be something we should question.

Log date and user also automatically stored. Ticket number will update when I close ticket.

Logging Payments

I’ll create another rule to log how exactly ticket settled. This is especially useful if you allow canceling payments.

I’ll store payment type name and amount as log description. You can see a list of available values by clicking drop down list. You can customize log for your needs by using these values. We can also use printer template tags here as I’ve demonstrated on previous rule.

This is how logs stored as user prints & settles ticket.

It will help a lot while trying to resolve some common issues.

Logging Order Cancellations

Here I’ll try to demonstrate how to log certain actions depended on some specific cases. In this sample I’ll show how to log cancelled orders and what added instead.

:information_source: Case Description: SambaPOS supports two types of order cancellations. You can just cancel a newly added order line to correct instant mistakes. When you print bill, close ticket or settle ticket; new orders submitted to kitchen and you can’t cancel orders anymore. To correct a submitted order you should void the order and add another order instead. Voided orders kept inside ticket so we can report them. However cancelled orders just disappears. This is not an issue for most venues but if you’re using customer display that might be an issue as cashier can use it like that.

  1. Cashier adds a $10 order.
  2. It appears on customer display.
  3. Customer pays $10.
  4. After customer leaves Cashier cancels it before submitting ticket, adds $1 product instead and settle ticket.

It is possible to prevent this by limiting permissions or adding admin confirmations for cancel button however that may happen frequently and we may just allow canceling orders but keep a log for that.

Let’s see how it can be implemented. As I’ll also demonstrate how ticket states can be used you may also want to follow it even you won’t need such logging.

1.Logging Orders

To be able to show exact implementation steps I’ll start from adding a log for all orders added inside ticket.

I’ll create a rule that works for all added orders and create a new log line for all of them. I’m adding a new rule that handles Order Added event and Add Ticket Log action.

You should be familiar with {QUANTITY} and {NAME} tag if you’ve customized your bill printing template. For rules that relates with Orders you can use order printing tags. I mean you can’t use {PAYMENT TYPE} tag here as this rule does not relates with payments. You can use this tag inside payment related rules like Payment Processed rule.

This is how log screen should appear.

2. Toggling (enabling & disabling) Order Logging

I don’t want to log all orders so I have to be able to control which orders are logged. I only want to log orders these added after canceling an order. I’ll enable it after an order gets cancelled and disable it after log created. First I’ll create an action that enables & disables order logging.

With this action I’ve configured a new Ticket State called Order Logging. When it’s value is Enabled I’ll log orders. I’ll also store a description about cancelled order.

:bulb: Hint: You don’t need to define such ticket states elsewhere. Referencing them with a state name inside rules is enough for defining them. You can consider defining them from Setting > States so you can access state names inside drop down lists but it is not a requirement.

On this step I’ll modify order logging rule to make it work if Order Logging is enabled.

You’ll remember I didn’t configured a constraint while adding this rule so it logs all orders. I’m adding a constraint to make it log orders if Order Logging is Enabled.

:bulb: Hint: {TICKET STATE:Order Logging} is a printing tag that reads current value of specified ticket state.

3.Disabling order logging.

I’ll show disabling order logging before enabling it as we’ll disable it just after adding an order log. I’ll keep modifying Log Order Details action to do that.

So order logging works when Order Logging value equals Enabled. Leaving Log State empty clears Enabled value so it won’t log next orders. Setting an empty value to a state will completely remove state from ticket so they won’t appear in reports or other places.

4. Enabling order logging.

Here comes the fun part. We’ll enable logging when an order line gets cancelled.

I’ve created a new rule that works when an order is cancelled. You know what happens here. Setting Log State to Enabled will enable logging so we’ll be able to log next added order instead of cancelled one.

You’ll notice I’m also storing quantity and name values for Cancelled order as state description. I can use that description to be able to know which order is cancelled. Now I’ll modify Log Order Details rule once more to include this description in logs.

I’ve used {TICKET STATE VALUE:Order Logging} tag to retrieve state description. You’ll remember state description (value) holds info about cancelled order. This table contains details about Order Logging State

Item Value How to read
State Name Order Logging
State Enabled or Empty {TICKET STATE:Order Logging}
State Value Holds additional descriptions about state. In this sample it holds details about cancelled order. {TICKET STATE VALUE:Order Logging}

5. How it Works?

What I did?

  1. I’ve created a new ticket.
  2. Added three orders.
  3. Cancelled Bacon and Tomato
  4. Added Large Drinks instead.

How log appears?

:bulb: Hint: After canceling an order you’ll see how Ticket State updates on ticket header. That won’t be visible for non-admin users unless it configured to display for all users through Management > Settings States.

Reporting Logs

Other than displaying logs inside ticket you can use {REPORT TICKET LOG DETAILS} tag to report log details.

{REPORT TICKET LOG DETAILS}

Field Identifiers
L => Ticket Log Value
T => Ticket

{REPORT TICKET LOG DETAILS:L.TicketNo,L.DateTime,L.UserName,L.Category,L.Log}

All possible ticket log values

TicketNo, DateTime, UserName, Category, Log, Date, Time

Sample Report

This report shows Order Cancellations and tickets printed more than once.

[Cancelled Orders:1,2,2,4]
>Ticket No|Date|User|Details
{REPORT TICKET LOG DETAILS:L.TicketNo,L.DateTime,L.UserName,L.Log:L.Category = "Order Cancelled"}

[Tickets Printed More Than Once:1,1,1,1]
>Ticket Number|Times Printed|User Name
@{REPORT TICKET LOG DETAILS:T.TicketNumber,L.TicketNo.Count:L.Category = "Bill Printing":{0}::$2>1:,}
{REPORT TICKET LOG DETAILS:T.TicketNumber.asc,L.TicketNo.Count,L.UserName:T.TicketNumber = "$1" and L.Category = "Bill Printing"}

The main purpose of these tutorials is demonstrating how SambaPOS features works so you can customize it for your needs. Feel free to asking questions regarding things you don’t understand or sharing your thoughts about the tutorial.


Event Logs using Tasks
Log when cash register is opened
Change table problem
Block user Void all Item on 1 ticket
Ticket log issue
How to "Show Printed Bills"?
Ticket Log DateTime only showing Date
How to keep track of answer?
Moving items between entity screens
Reopen closed ticket
Sales Report monthly
SambaPOS 5.1.52 Release
Any one tried this? if so how to get the report for the price change?
Dissappearing Tables
Protect Change Table With Pin
unlisted #2

listed #3

#4

@emre As the logging going good but how to disable on ticket header


#5

If you are logged in as an admin user states will be shown like that regardless to allow ‘debiging’ and monitoring by the admin.
Login as a non admin user and it shouldnt show.
If it does you have defined the Order Logging state in the states settings (they wont show to non admin unless defined as show on ticket in the states)


#6

That is awesome, think this will cover allot of those people worried about recording canceled orders etc.


#7

@gsreddy don’t use admin for regular user and that state won’t show.


#8

now i did all this tutorial and now want to add log for reopen close ticket and move order log .
what i do to get reopen closed ticket log ? and move order from ticket to another log ?


#9

How to Log Change Table?


i can’t log old entity name (old table name)?
for new table i log use {ENTITY NAME}


#10

Use [:OldEntityName]


#11

How to Log move order ?


#12

I am actually curious, is there a way we can when a table has moved to a different table?

I want to create a flow which notifies kitchen if a table has moved but also want to log that move.


#13

Cause you can, ticket entity changed event will do the job.


#14

We could use this logging method to a ticket entity changed event? interesting. I’ll give this a go!


#15

Yerr, the event has old and new entity name so you could log;

Moved from [:OldEntityName] to [:NewEntityName]


#16

Hmm I better find how what printer command i have to use to print it to kitchen also. hmm.
This is exciting though, thanks for confirming it can do it :slight_smile:


#17

Don’t think these tags would be available in printer template, if nothing else you could save to local setting or set as a ticket tag comment and print that.


#18

Hmm good point. So I could do something like ticket entity changed event, apply ticket tag, Table change from old to new, and I could potentially use that to print it.


#19

Yet, tag ticket then print to specific template which prints that tag.


#20

Just tested it. Works a charm :slight_smile: Thanks.