Skip to content

Commit e53feed

Browse files
committed
Prevent some ways of creating multiple pending payments
Prevent a new payment from being created when one is pending. Prevent transaction merges when either transaction has a pending payment.
1 parent 6657997 commit e53feed

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

quicktill/register.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,18 @@ def paymentkey(self, paytype_id):
20302030
self.clearbuffer()
20312031
self._redraw()
20322032
return
2033+
# If there are any pending payments in the transaction, we must not
2034+
# start a new payment. Pending payments must be resolved first.
2035+
if any(p.pending for p in trans.payments):
2036+
log.info("Register: paymentkey: pending payments exist")
2037+
ui.infopopup(["This transaction already has a pending payment.",
2038+
"",
2039+
"The pending payment must be completed or cancelled "
2040+
"before any other payments can be processed."],
2041+
title="Error")
2042+
self.clearbuffer()
2043+
self._redraw()
2044+
return
20332045
if self.hook("paymentkey", paytype, trans):
20342046
return
20352047
self.prompt = self.defaultprompt
@@ -2954,6 +2966,21 @@ def _mergetrans(self, othertransid):
29542966
if not sc:
29552967
return
29562968
othertrans = td.s.get(Transaction, othertransid)
2969+
# If either of the transactions has pending payments, merging
2970+
# cannot go ahead
2971+
if any(p.pending for p in trans.payments):
2972+
ui.infopopup([
2973+
f"Transaction {trans.id} (this one) has a pending payment. "
2974+
f"It can't be merged with another transaction until this "
2975+
f"payment is resolved."], title="Error")
2976+
return
2977+
if any(p.pending for p in othertrans.payments):
2978+
ui.infopopup([
2979+
f"Transaction {othertrans.id} (the one to be merged into) "
2980+
f"has a pending payment. This transaction can't be merged "
2981+
f"into it until the pending payment is resolved."
2982+
], title="Error")
2983+
return
29572984
if len(trans.payments) > 0 and not allow_mergetrans_with_payments():
29582985
ui.infopopup(
29592986
["Some payments have already been entered against "

0 commit comments

Comments
 (0)