Skip to content

Commit

Permalink
Refunds in state "done" should always have an execution date
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Dec 12, 2023
1 parent d4a32fd commit 7f948bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pretix/base/models/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,12 @@ def save(self, *args, **kwargs):
self.local_id = (self.order.refunds.aggregate(m=Max('local_id'))['m'] or 0) + 1
if 'update_fields' in kwargs:
kwargs['update_fields'] = {'local_id'}.union(kwargs['update_fields'])

if self.state == OrderRefund.REFUND_STATE_DONE and not self.execution_date:
self.execution_date = now()
if 'update_fields' in kwargs:
kwargs['update_fields'] = {'execution_date'}.union(kwargs['update_fields'])

super().save(*args, **kwargs)


Expand Down
1 change: 1 addition & 0 deletions src/tests/api/test_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,7 @@ def test_refund_create_webhook_sent(token_client, organizer, event, order):
assert r.provider == "manual"
assert r.amount == Decimal("23.00")
assert r.state == "done"
assert r.execution_date
with scopes_disabled():
assert order.all_logentries().get(action_type="pretix.event.order.refund.done")

Expand Down

0 comments on commit 7f948bf

Please sign in to comment.