lingo: assert preconditions in handle_payment() (#46504)
It checks preconditions on item and remote_items, with specific preconditions for regie flagged "can_pay_only_one_basket_item".
This commit is contained in:
parent
16d9a5cbfc
commit
d93ecda18f
|
@ -349,6 +349,14 @@ class PayMixin(object):
|
|||
def handle_payment(
|
||||
self, request, regie, items, remote_items, next_url='/', email='', firstname='',
|
||||
lastname=''):
|
||||
# preconditions
|
||||
assert bool(len(items)) != bool(len(remote_items)), (
|
||||
'there should be at least one item or remote item to pay and not both'
|
||||
)
|
||||
if regie.can_pay_only_one_basket_item:
|
||||
assert (len(items) == 1) or (len(remote_items) == 1), (
|
||||
'regie can only pay one basket item, but handle_payment() received more'
|
||||
)
|
||||
|
||||
if remote_items:
|
||||
total_amount = sum([x.amount for x in remote_items])
|
||||
|
|
Loading…
Reference in New Issue