Skip to content

Commit

Permalink
PatronTransaction: fix event creation
Browse files Browse the repository at this point in the history
It was unable to create a `PatronTransactionEvent` without amount.
However, it must be allowed for some event (like a dispute).

Co-Authored-by: Renaud Michotte <[email protected]>
  • Loading branch information
zannkukai authored and jma committed Dec 7, 2021
1 parent 57b592d commit 0404ce0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rero_ils/modules/patron_transaction_events/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def create(cls, data, id_=None, delete_pid=False,
"""Create patron transaction event record."""
if 'creation_date' not in data:
data['creation_date'] = datetime.now(timezone.utc).isoformat()
data['amount'] = round(data['amount'], 2) # ensure multiple of 0.01
if 'amount' in data:
# ensure multiple of 0.01
data['amount'] = round(data['amount'], 2)
record = super().create(
data, id_, delete_pid, dbcommit, reindex, **kwargs)
if update_parent:
Expand Down

0 comments on commit 0404ce0

Please sign in to comment.