Skip to content

Commit

Permalink
items: fix status according to migrated loans
Browse files Browse the repository at this point in the history
Fixes problem when renewals of migrated loans was not possible.

* Fixes rero#1983
* Fixes rero#1974

Co-Authored-by: Aly Badr <aly.badr@rero.ch>
  • Loading branch information
Aly Badr committed Jun 9, 2021
1 parent 5573032 commit bff990b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions rero_ils/modules/loans/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,8 @@ def build_loan_record(transaction, transaction_type, item):
item: the item record.
"""
if transaction_type == 'checkout':
transaction['state'] = 'ITEM_ON_LOAN'
transaction['trigger'] = 'checkout'
transaction['document_pid'] = item.document_pid
transaction['to_anonymize'] = False
transaction['item_pid'] = {'value': transaction.get('item_pid'),
'type': 'item'}
transaction.pop('item_pid', None)
transaction.pop('organisation', None)
elif transaction_type == 'request':
transaction['state'] = 'PENDING'
transaction['trigger'] = 'request'
Expand Down Expand Up @@ -183,7 +179,10 @@ def load_virtua_transactions(
else:
build_loan_record(transaction, transaction_type, item)
try:
Loan.create(transaction, dbcommit=True, reindex=True)
if transaction_type == 'request':
Loan.create(transaction, dbcommit=True, reindex=True)
elif transaction_type == 'checkout':
item.checkout(**transaction)
click.secho(
'\ntransaction # {counter} created'.format(
counter=counter
Expand Down

0 comments on commit bff990b

Please sign in to comment.