How can i change Ticket Explorer Columns

i have been trying to get this Ticket Explorer to change columns using Column chooser but to no avail, im trying to change it to show Ticket Id not Ticket number coz the Ticket Number sometimes doesnt follow the sequence but the Ticket Id does

Can @Nizam or Sambapos Team please explain how to change it

I checked a lot of topics but looks like people are struggling to change and its been years it hasnt been fixed.

Whats the point of having a column chooser if its not working in Ticket explorer

Ticket Id does not necessarily follow the sequence either, it guarantees uniqueness but not sequence.
Very unlikely to happen with one terminal, but with many it could skip 10, 100, 1000 Ids.

You can adjust this with, but you might experience some performance difference. You can look into SQL Server’s Identity Cache to find out what it is.

Do test it out on a sample database before changing databases in use.

ALTER DATABASE SCOPED CONFIGURATION SET IDENTITY_CACHE = OFF;
GO

You cannot change Ticket Explorer widget, you can customize with Ticket Lister Widget.

edit %USERPROFILE%\My Documents\SambaPOS5\Layout\TicketExplorer.xml and look for the following block:

      <property name="Item2" isnull="true" iskey="true">
        <property name="GridRow">0</property>
        <property name="FieldName">Id</property>
        <property name="UnboundType">Integer</property>
        <property name="Name">TicketExplorer_2_Ticket_Id</property>
        <property name="Header" type="System.String">Ticket Id</property>
        <property name="Visible">false</property>
        <property name="VisibleIndex">1</property>
        <property name="Width">84</property>
        <property name="ActualWidth">84</property>
      </property>

change
<property name="Visible">false</property>

to

<property name="Visible">true</property>

to hide the ticket number column change the same property to false in the following block:

      <property name="Item1" isnull="true" iskey="true">
        <property name="GridRow">0</property>
        <property name="FieldName">TicketNumber</property>
        <property name="UnboundType">String</property>
        <property name="Name">TicketExplorer_1_Number</property>
        <property name="Header" type="System.String">Number</property>
        <property name="Visible">false</property>
        <property name="VisibleIndex">0</property>
        <property name="Width">82</property>
        <property name="ActualWidth">82</property>
      </property>

Repeating and adding to what Posflow said about uniqueness: table primary key’s are guaranteed to be unique and that’s it. Ticker numbers are guaranteed to be sequential but not necessarily without gaps.

SQL Server will, from time to time, bump an integer primary key sequence by 1000 if there was a dirty shutdown thus causing a gap.

SambaPOS assigns ticket numbers after the Before Ticket Closing event and before the Ticket Closing event. The db is queried for the current sequence value for the numerator, incremented in the db, assigned to the ticket in memory/client side, then eventually persisted to the db. If the last part is interrupted for some reason, then there would be a gap in the ticket number sequence. But this really shouldn’t be happening under normal circumstances.

If you’re seeing a lot of gaps in ticket numbers there may be something else going on.

Here’s a SQL query to run against the db to show the gaps.

WITH Tkts
AS (
   SELECT CAST(TicketNumber AS INT)                                                 AS TicketNr,
          Date                                                                      AS TicketDate,
          LEAD(CAST(TicketNumber AS INT)) OVER (ORDER BY CAST(TicketNumber AS INT)) AS NextTicketNr,
          LEAD(Date) OVER (ORDER BY CAST(TicketNumber AS INT))                      AS NextTicketDate
       FROM dbo.Tickets
   )
    SELECT TicketDate                  AS GapStartDate,
           NextTicketDate              AS GapEndDate,
           TicketNr                    AS GapStart,
           NextTicketNr                AS GapEnd,
           NextTicketNr - TicketNr - 1 AS Cnt
        FROM Tkts
        WHERE NextTicketNr - TicketNr > 1
        ORDER BY GapStart;

So how exactly will I have to do it? The reason I am asking is because where I am, when the tax revenue authorities come to inspect the system, they may see gaps in the ticket numbers and assume that some tickets are missing or have been deleted. I need the Ticket Explorer to show the correct sequence or at least make it clear that the tickets are not missing.

You can disable identity cache like Posflow suggested and deal with the possible performance hit.

For the ticket number, I don’t think it’s possible as it stands. There’s also the issue of splitting/merging tickets that can cause gaps as the old tickets are delete instead of just cleared (iirc).

You can show the tax guys these threads, one for SambaPOS and one for SQL Server:

Thank you for the info. I will look into disabling identity cache and see if there is any issues, i will keep you updated

i ran this sql script WITH Tkts AS
(
SELECT
Id,
TicketNumber,
Date,
LEAD(Id) OVER (ORDER BY Id) AS NextId,
LEAD(TicketNumber) OVER (ORDER BY Id) AS NextTicketNumber
FROM dbo.Tickets
)
SELECT
Id AS CurrentID,
NextId,
NextId - Id - 1 AS MissingIDCount,
TicketNumber AS CurrentTicketNumber,
NextTicketNumber,
Date
FROM Tkts
WHERE NextId - Id > 1;

wat will be the cause of the TicketId gaps

SQL Server default identity cache is 1000 so it looks like after start, some tickets were created and then SQL Server was restarted.

Run this in an admin powershell/terminal and see if the dates line up with what your query returns (this may be a slow query):

Get-WinEvent -LogName Application |
Where-Object { $_.Message -match 'SQL Server is starting|SQL Server is ready' } |
Select-Object TimeCreated, ProviderName, Message |
Sort-Object TimeCreated |
Format-Table -AutoSize -Wrap