Hey Jesse!
So I am still actually having this issue.
I tested it at home(my test system running 5.3.6) and no issues after updating. Even if I have a ticket opened on a physical terminal, it’ll still pay and close the ticket (and when I close the ticket on the physical terminal then the physical terminal will do a popup with the error: Ticket Changed. Latest changes not saved." The GQL terminal will close no problem)
Now the problem comes when I run this at the actual restaurant.
I have 8 physical terminals running, all updated to 5.3.6 (I don’t think it matters but 2 are used as actual POS terminals, 1 is a headless server, and 5 are used as Kitchen Task Displays) So 2 terminals are the only ones that constantly have open tickets.
To make sure that there’s no external factors.
I have checked the rules, I don’t think I have any print jobs that don’t exist.
I have logged out of every single terminal.
BUT I KEEP GETTING THIS ERROR!!!
So I did a database backup, and loaded it onto my home computer, and there was no issues closing the tickets.
I also made a script/message received rule: it will receive a JSON format of the tickets that need to be closed, and will execute a script for each ticket number in the array, load ticket->pay ticket->close ticket. This works fine, BUT a terminal must be running on the headless server(Which I’d like to avoid.)
I am completely stumped…
Would there be any other problem that you could think of?
(Also I’m thinking of just ignoring this route and just going the SQL route, but I’m unsure about the Accounts/Account Documents/etc.)
Also not sure if you need it but this is the code in node that I am running:
//register a GQL terminal
function openTerminal(){
return gql(getOpenTerminalScript())
.then(data => data.registerTerminal);
}
//load a ticket, make payments, and close ticket.
function payTicket(terminalId, ticketId, amount, paymentType){
return loadTicket(terminalId,ticketId).then( () => {
return payLoadedTicket(terminalId, amount, paymentType).then( resolve => {
return closeTicket(terminalId).then( data =>{
if(data == "Ticket changed. Your latest changes not saved.")
return false;
else
return true;
}, err => false);
}, err => false);
});
}
//loads a ticket to the specified terminal
function loadTicket(terminalId, ticketId){
return gql(getLoadTicketScript(terminalId,ticketId));
}
//pays a specified amount on the loaded ticket on the specified terminal.
function payLoadedTicket(terminalId, amount, paymentType){
return gql(getPayTicketScript(terminalId, amount, paymentType));
}
//close ticket
function closeTicket(terminalId){
return gql(getCloseTicketScript(terminalId));
}
//unregister gql terminal
function closeTerminal(terminalId){
return gql(getCloseTerminalScript(terminalId));
}
function getOpenTicketsScript(){
return `{getTickets(isClosed: false) {id, type, remainingAmount, states{state, stateName}, tags{tag, tagName}, entities{name}}}`;
}
function getOpenTerminalScript(){
return `mutation register {registerTerminal(user: "Server", ticketType: "Ticket", terminal: "Server", department: "Restaurant") }`;
}
function getLoadTicketScript(terminalId, ticketId){
return `mutation load {loadTerminalTicket(terminalId: "${terminalId}", ticketId: "${ticketId}") { id } }`;
}
function getPayTicketScript(terminalId, amount, paymentType){
return `mutation pay {payTerminalTicket(terminalId:"${terminalId}", paymentTypeName:"${paymentType}", amount:${amount}){ ticketId} }`;
}
function getCloseTicketScript(terminalId){
return `mutation close {closeTerminalTicket(terminalId:"${terminalId}") }`;
}
function getCloseTerminalScript(terminalId){
return `mutation unregister {unregisterTerminal(terminalId: "${terminalId}")}`;
}
PS sorry for the wall of text…