Skip to content

Commit

Permalink
Add config switch for printing session totals after confirmation
Browse files Browse the repository at this point in the history
Closes #256 on github.
  • Loading branch information
sde1000 committed May 18, 2023
1 parent e773c0b commit d7f42ad
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions quicktill/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from . import ui, keyboard, td, printer, tillconfig, user, managestock
from . import payment
from . import config
from .models import PayType, Session, SessionTotal, Transaction, zero
from sqlalchemy.orm import undefer
from sqlalchemy.sql import select, func, desc
Expand All @@ -13,6 +14,12 @@
log = logging.getLogger(__name__)


sessiontotal_print = config.BooleanConfigItem(
'core:sessiontotal_print', True, display_name="Print session totals?",
description="Should session totals be printed after they have been "
"confirmed?")


def trans_restore():
"""Restore deferred transactions
Expand Down Expand Up @@ -422,10 +429,13 @@ def finish(self):
self.dismiss()
for i in SessionHooks.instances:
i.postRecordSessionTakings(session.id)
ui.toast("Printing the confirmed session totals.")
with ui.exception_guard("printing the confirmed session totals",
title="Printer error"):
printer.print_sessiontotals(session.id)
if sessiontotal_print():
ui.toast("Printing the confirmed session totals.")
with ui.exception_guard("printing the confirmed session totals",
title="Printer error"):
printer.print_sessiontotals(session.id)
else:
ui.toast(f"Totals for session {session.id} confirmed.")


@user.permission_required('record-takings', "Record takings for a session")
Expand Down

0 comments on commit d7f42ad

Please sign in to comment.