Urgent ... Weird behaviour when incrementing system variable

I guess I am using terminals although in the terminal section, it points to SERVER for each windows users, so I don’t know if I can do that. Do I have to define a terminal for each windows users, knowing that each windows users will start a separate instance of SambaPOS?

I don’t have a clue about that … You see in this country they ask you to print the tickets with a serial number which is obvious for a supermarket but not in a restaurant. For instance this month they come in the restaurant in my street and ask the first number of the day and the last number at the time they come just to see if you are cheating (=not printing bills) I don’t know if that {TICKET ID} can help me with that.

In my mind each SambaPOS instance connect to a database and the database does the job (lock the table while update, release the lock, get the next query) that avoid simultaneous update/reading but what happen here is bizarre because it is not even “simultaneous”, there are minutes between.

I don’t have account, when merged the ticket simply disappears and I can find it in the ticket list.

My guess is one of two things:

  • Your Rules are messing this up in a way that the increment is not happening when it should.

  • It does not work as you expect because of RDP, or the way you have RDP set up. Can’t help you there.

I’ll keep you informed and thank you very much for your time.

so TICKET ID is a unique ID assigned to a ticket once it is written to DB. It is unique and will never duplicate and it is created at time ticket is actually submitted. TICKET ID is the best way to track what you are doing. You can just put {TICKET ID} in your ticket template and print the ticket after its closed. Several ways to do that including using a print state. Or you can force it to write ticket to database at a set point to get the TICKET ID with Save Ticket action.

Ticket Id will be fine if you don’t need sequential numbering with no skipping. But if you Merge Tickets, then Ticket Ids will go missing for all the merged Tickets, and a new Id will be assigned.


No, Merged Tickets do not trigger Payment Processed.


Manage > Settings > Display > Rule Debugger

I would definitely look at the Debugger. You might have something firing that you are not aware of, or something is out of order.

1 Like

I am watching the SerialNumber since this morning, all sequential until now:

The second number (27.50) just put itself in between with the same SerialNumber - 161024.

Here is what we did:

(That ticket is split into 2 with MOVE)

  • Open the ticket
  • Select 2 products
  • MOVE them (so new ticket opens - we did not “close” that ticket) !
  • Immediately go to settle and cash

and that printed the ticket with the same SerialNumber (It did not increment the serialNumber)

My rule still is:

There is no reason I can see why it would not increment the SerialNumber.

  • SerialNumber ++

AND

  • Tagging the ticket with this number

only occurs in that rule and once.

Obiously something is wrong:

  • the SerialNumber is NOT incremented (at least in the DATABASE)
  • the ticket is tagged with database value
  • the ticket is printed out

I am using:
{GLOBAL SETTING:SerialNumber} to tag the ticket
IsLocal = False to increment the SerialNumber
So it looks like that

IsLocal : false does not work

For me it looks like an issue.

Now I got:

look at the SerialNumber in database (first line) and look the numbers I have in the tickets

I am sure the next ticket number will be 161028 …

Now it has “synchronized” again:

We are talking about minutes between these events you know, we are not talking about ms … so database concurrent writing/reading I doubt.

2 Instances of SambaPOSPresentation
1 Sql server running

Why don’t you implement this Serial Number thing on default database and see if it work before you jumping to conclusion that Is Local not working.

I can only tell you that it does work for many of us. It must be something in your configuration that causing this.

If it doesn’t work on default database just export your automation and post it here so I can import and see why it is not.

Because I am live, I am using SambaPOS right now for the restaurant, that’s also why it takes a lot of time to “debug” I have to wait for an error occuring, which always happens when 2 waiters (2 sambaPOS presentation.exe are running)

database when you first install SambaPOS

Local program settings work fine, I used them for logging last bill for my print last receipt (copy) button.
If you dont trust local program settings just use global (SQL stored) program settings and prefix with terminal name which I have also done in the past. ie
Bar1_LastBillId
In fact thinking about it I probably do that anyway so maybe I dont use local settings only termianl prefixed global program settings. Which isnt a bad thing as you can use SQL manager to check the settings values and update the query to refresh.

Did you change it to use the +1 formula Q showed you as have never used increase only the formula on update like Q showed.

Hi JTRTech, that is exactly what I want. However watching the ProgramSettingsValue table, I see that:
While it seems to work with {GLOBAL SETTING:SerialNumber} - I can see that the ticket is tagged with the database value,
it does not seem the case for IsLocal : false because SerialNumber variable is not - always/immediately - SQL stored.

Now I already ask how terminal works and how I should setup the local settings for each windows user (each SambaPOSPresentation.exe instance) but I had no answer.

My understanding would be terminal is like a supermarket with lots of cashiers. 1 terminal = 1 cashier and related workperiod. Is it the case?
My setup is 1 computer with

  • 4 users - waiters that start their windows session and in that session open their SambaPOS, they start their session with RDP. each waiter is a cashier (takes money)
  • I don’t have terminal setup except the default one : server
  • I have 1 working period per day
  • Each waiter has their money report based on PU (what they settled)

Example of Celia SambaPOS user running under Celia windows session.

Do I have to have terminal defined for each waiters or can each waiter work on the same terminal (server)?
Do each terminal have its own working period?

My rule is:

  • Action Create Sunat Number (see picture) and update db (if this is what IsLocal:False does)
  • Action Tag the ticket with SerialNumber from DB ({GLOBAL SETTING:SerialNumber})
  • Action Print Bill

Look my report below:

The first line is a SQL report that takes the value of SerialNumber in the ProgramSettingValues Table in SambaPOS5 db.
It is : 160031

The next lines are the serialnumber tagged to the tickets

These numbers are bigger that the DB serialnumber, so somehow that value is kept somewhere but not (always) in the database
That (always) is my problem, I cannot reproduce the problem, it just happens, I am here watching that number since the morning. Before settling a tickent the waitress come in my office and we do it together watching that number in the DB.
I haven’t written SambaPOS I don’t know how it works, I can just imagine not more.

In my experience ive always defined terminals for each individual tablet.
E.g.
Server(main server machine)
Tab1
Tab2
Tab3
Pos2(of another wired terminal is there)

And ive checked ticket number increments and its never skipped. Its also useful to check which tab was used by which user when checking if there is an issue on a ticket.

Maybe you can take a copy of your database. Bring it over to your own laptop or test machine or something. Run the database on a seperate network so your live system(this can even be done at home using your home modem/router) take maybe after evening where ur done for the day both tablets home, link em up to your network, define a terminal for each tab, then test your serial number to see if it affects it or to see if its corrected. If its corrected then do it on your live machine and monitor it like youve been doing.

Thanks shivan,

I’ll give it a try because it’s a bit weird to have all users on 1 terminal.

Now before I do stupid things, making a terminal it is just to give him a name?
Is the workperiod dependant of each terminal or 1 workperiod for all terminals?

Right now it does not matter if X uses Y terminal until they login in SambaPOS with their usernames (X or Y), reports are based on PU SambaPOS users.

Ok I created terminal as you did but not helping … still double numbers.

Oh well. Sorry mate i tried. It was worth a go to test anyway

The fact that they are all duplicated to be makes me think its config issue rather than clashing requests as that would more likely be sporadic.

I suggest you to try your Serial Number set up on fresh default database. So, you don’t have to keep posting/looking at the same old places over and over if the new set up working.

And ^ Q suggestion to look at rule debugger. Everyone convinced it is your configuration issue. But you just want to blame Global Setting not working.

Is that report ordering by serial?
Thinking outloud but are you 100% using global and not local?
Ordering by serial makes it hard to tell.
You could do with adding terminal and time into the report to see how the number is progressing in relation to tickets…
What im getting at is if its ordered by serial you would stuggle to tell if there is actually two sequences running in tandem rather than duplicated/not increasing. if that makes sence.

Instead of having the actions in the same rule try creating the serial number and then trigger an execute automation command action and put the tag action in a separate rule. Actions in rules don’t always trigger sequentially based on order inside rule.