After ending a work period then starting a new one the order numbers are continuing instead of starting from 1

Ahhh, that makes sense!

:wink: but it would be simpler if SambaPOS could allow you to set Tag numbers like this on terminals that are connected to a server.

Server will be S1, S2 , S3 etc.
Terminal 1 will be T1, T2,T3 etc.
Terminal 2will be Z1, Z2,Z3 etc.

Where S, T, Z is whatever you define.

I think we can come up with something…
How are you separating order types (dine in, take away, delivery, etc)?
Ticket types, ticket tags or departments?
Is a terminals assigned to a order type? If so, is there a chance that would change in the future?

You could do that. Take a look at some of the print last bill setups.
My print last bill button uses global settings with a setting name of LastBill_{:CURRENTTERMINAL}
So you could do something like OrderNumber_{:CURRENTTERMINAL}
Or multiple rules mapped to terminals but above would be cleaner.
Might be better to use script or sql to reset counts though using a LIKE OrderNumber_% to keep fully dynamic since end of day only triggered on one machine current terminal would only reset that terminal you ended wp on.

I never really use local settings as prefer to be able to see and check the values in DB when setting up so use variables in setting name.
My dual user pin setup does similar but using current user rather than terminal when they change their pin (main pin is set from their swipe rfid, they can set a manual pin for using on the tablets which don’t have rfid reader.)

But you could use local settings also, pretty sure they are cleared on samba restart so would just need to do your add to value first so the null of first ticket becomes 1. Fine so long as you don’t close samba or restart till during the day.

I am using 2 different Order Number series.

Here’s a script for a sequence with floating zeros:

function get()
{
  var q = "SELECT Value From dbo.ProgramSettingValues WHERE Name = 'SequenceNumber'";
  var r = sql.Query(q).First;
  var sequenceNumber = r;
  
  if (r == null)
  {
    var q = "INSERT INTO dbo.ProgramSettingValues (Value, Name) VALUES ('1', 'SequenceNumber')";
    sql.Exec(q);
    
    sequenceNumber = 1;
  }
  else
  {
    sequenceNumber++;
  }
  
  q = "UPDATE dbo.ProgramSettingValues SET Value = '"+sequenceNumber+"' WHERE Name = 'SequenceNumber'";
  sql.Exec(q);
  
  return Helper.Format(sequenceNumber,'0000');
}

function reset()
{
  q = "UPDATE ProgramSettingValues SET Value = '0' WHERE Name = 'SequenceNumber'";
  sql.Exec(q);
}

2020-06-25_16;22_1593123760_Samba.Presentation

When you need to get a value for a ticket tag use {CALL:orderNumber.get()}

Whatever rule you use for resetting create the following action and add it to the rule:
2020-06-25_16;25_1593123901_Samba.Presentation

Action Name: Execute Script
Action Type: Execute Script
Function: [:Function x.y()]
Run in Background: False

In your reset counter rule:

2020-06-25_16;29_1593124146_Samba.Presentation

Function x.y(): orderNumber.reset()

This will give you 0001, 0002, etc. which should help with your sorting issue.

2 Likes

I tried but I think I am missing or doing something wrong. Thank you btw.

Do I need to replace anything?

YOu’ll have to configure your ticket created rule to tag the ticket with the number provided by the script. Something like this:

For tagging the ticket:
2020-06-25_17;18_1593127134_Samba.Presentation

Assuming to clear order sequence on work period end:
2020-06-25_17;19_1593127197_Samba.Presentation

We are currently using it in the following way.

Server (server) with 2 terminals for customer walk in sales with the number sequence 1,2,3 etc.

Delivery (another server) with 1 terminal and two tablets for delivery orders with the number sequence D1,D2,D3 etc.

We are not using the Dine in/Reservation part of it as customers pay and sit if they wish or consume at home.

Terminals are just pulling from the servers information at the moment.(reason being when I changed printer on terminal then it changed it on the server and then I followed what Shivan advised to call all usb printers server as I thought ticket tag numbers could not be changed for terminals)

Nevermind i got it to work. Thak you

1 Like

May I ask you a huge favor please? Normally I had a decrease counter action with a rule if Order Count is 0 to apply so I they open a ticket and close it wouldnt skip an Order No. I would appreciate it if you can help me with this. Thanks a ton.

that would be messy if more than kne terminal as another terminal could call a value while that ticket is open.
If you need to account for 0 order/value orders move your tagging of ticket to a later event like before ticket closing and make sure to sort rules so it is tageed before any print events using the tag.

Or maybe a manual entry action for the ones that skipped just in case if it happens?

If your rule to tag the ticket is on ‘Ticket Created’ there should be no missed numbers. 1 ticket = 1 order number.

If you’re using a different Event for the rule, additional constraints may be needed.

First of all thank you very much for the help, I do appreciate it a lot.

Let me explain the situation;
Server selects an entity and the ticket is created.
If the server close the ticket and no order is entered then there is an Order No skipped.
I can use the Update Ticket Tag Action to solve this but if you have any other suggestion I am all ears.

Thanks

Ahh, okay, let me check something I’ll be right back…

if closing 0 order ticket is issue like I said tag and increase setting on different event.
Order added where tag == ‘’
Or before ticket closing.
Pretty sure I have my kitchen daily order counter number set on before ticket closing as it has a constraint to knly tag if there are food items so only orders going to kitchen get tagged.

Alright, we’ll have to change the Event in the rule for Tagging Ticket:

2020-06-26_23;21_1593235278_Samba.Presentation

Event Name: Before Ticket Closing

Custom Constraints:
{TICKET TAG:orderNumber} [IS NULL]
[=TN('{ORDER COUNT}')] [GREATER] 0

THis will now only tag a ticket when there is an order on it and the ticket has not been tagged yet for an order number.

EDIT: updated with recommended Event Name

Thank you a lot! You are great man. :smiley: