Skip to content

Commit 9905fbf

Browse files
committed
Add option to require session total entry before starting a new session
Some sites are VERY bad at entering their daily totals into the till! Add an option that prevents a new session from being started when more than the configured number of session totals are missing. Closes #315 on github.
1 parent a2bc8d3 commit 9905fbf

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

quicktill/session.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
description="When a new session is started after this time of day, "
3232
"the date defaults to the next day instead of today.")
3333

34+
session_max_unconfirmed = config.PositiveIntConfigItem(
35+
'session:max_unconfirmed_sessions', None,
36+
display_name="Maximum number of unconfirmed sessions",
37+
description="If there are more than this number of sessions that "
38+
"do not yet have their totals confirmed, prevent a new session "
39+
"from being started. Leave blank to disable this feature.",
40+
allow_none=True)
41+
3442

3543
def trans_restore():
3644
"""Restore deferred transactions
@@ -112,8 +120,21 @@ def start():
112120
[f"There is already a session in progress (number {sc.id}, "
113121
f"started {sc.starttime:%H:%M on %A})."],
114122
title="Error")
115-
else:
116-
ssdialog()
123+
return
124+
if session_max_unconfirmed() is not None:
125+
unconfirmed_count = len(
126+
sessionlist(None, unpaidonly=True, closedonly=True))
127+
log.debug("unconfirmed sessions count %d", unconfirmed_count)
128+
if unconfirmed_count > session_max_unconfirmed():
129+
ui.infopopup(
130+
["You cannot start a new session yet, because there "
131+
"are sessions that have not yet had their totals confirmed.",
132+
"",
133+
'You can confirm session totals using Manage Till option 1 '
134+
'then option 3 ("Record session takings").'],
135+
title="Session totals missing")
136+
return
137+
ssdialog()
117138

118139

119140
def checkendsession():

0 commit comments

Comments
 (0)