inveniosoftware / invenio-circulation

Library circulation module for Invenio.
https://invenio-circulation.readthedocs.io
MIT License
0 stars 18 forks source link

Cannot `checkout` because of `CIRCULATION_STATES_ITEM_AVAILABLE` #71

Closed ntarocco closed 5 years ago

ntarocco commented 6 years ago

When loan is in state ITEM_AT_DESK and we perform the action checkout, the transition is checking is_item_available. This function will check if the there is loan on this item, and it will return false because there is actually a loan with state ITEM_AT_DESK.

This function must be changed to exclude the ITEM_AT_DESK loan for the current patron.

Solution

The config variable CIRCULATION_STATES_ITEM_AVAILABLE = ['ITEM_RETURNED', 'CANCELLED'] was supposed to define the list of states for which an item is considered available for loan, but it is not enough and it is very hard to compute the opposite, the list of states for which the item is not available for loan, or to know the last Loan state of an item.

The proposed solution is to replace this config with the opposite, something like: CIRCULATION_STATES_ITEM_ON_LOAN = ['ITEM_AT_DESK', 'ITEM_IN_TRANSIT_FOR_PICKUP', 'ITEM_ON_LOAN', 'ITEM_IN_TRANSIT_TO_HOUSE'] which defines the list of states for which an item is considered currently on loan. This will ensure that it is easy to compute if given an item_pid there is an existing loan on it. This change will require to change the methods and factories around item availability.