|
31 | 31 | description="When a new session is started after this time of day, "
|
32 | 32 | "the date defaults to the next day instead of today.")
|
33 | 33 |
|
| 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 | + |
34 | 42 |
|
35 | 43 | def trans_restore():
|
36 | 44 | """Restore deferred transactions
|
@@ -112,8 +120,21 @@ def start():
|
112 | 120 | [f"There is already a session in progress (number {sc.id}, "
|
113 | 121 | f"started {sc.starttime:%H:%M on %A})."],
|
114 | 122 | 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() |
117 | 138 |
|
118 | 139 |
|
119 | 140 | def checkendsession():
|
|
0 commit comments