Skip to content

Commit

Permalink
Don't lock the register if a transaction closes within 3 seconds
Browse files Browse the repository at this point in the history
If a Square transaction was in progress when the user locked the
register, it is likely to complete very quickly the next time the user
taps in. If this happens within 3 seconds of the user tapping in, don't
lock automatically — the user probably wants to start a new transaction.

See #288 on github.
  • Loading branch information
sde1000 committed Jun 25, 2024
1 parent a1b3873 commit 2d451c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion quicktill/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from . import tillconfig
import math
import time
from . import td, ui, keyboard, printer
import quicktill.stocktype
from . import linekeys
Expand Down Expand Up @@ -778,6 +779,7 @@ def __init__(self, user, hotkeys, autolock=None, timeout=300):
# trans and user are needed for "pagename" which is called in
# basicpage.__init__()
# transid is now a transaction ID, not a models.Transaction object
self._start_time = time.time()
self.transid = None
self.user = user
log.info("Page created for %s", self.user.fullname)
Expand Down Expand Up @@ -1017,7 +1019,9 @@ def close_if_balanced(self):
self.balance = zero
td.s.flush()
self._clear_marks()
if self._autolock:
# Check how long it has been since the register was
# created — if it's under a few seconds, do not lock
if self._autolock and time.time() - self._start_time >= 3.0:
self.locked = True

def linekey(self, kb):
Expand Down

0 comments on commit 2d451c5

Please sign in to comment.