Bug 16534: Make CanBookBeIssued test if the issue can be returned
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sun, 22 May 2016 09:01:48 +0000 (10:01 +0100)
committerFrédéric Demians <f.demians@tamil.fr>
Mon, 1 Aug 2016 06:49:47 +0000 (08:49 +0200)
commitdf9fbe0aefc7135ecf3e78c29a12cf780da28eae
tree35eb788b8f10368f5f5f98e02ac9f7319ae65d84
parent141ada91cc7de6e32e51ae5dfa203d4c89099c4e
Bug 16534: Make CanBookBeIssued test if the issue can be returned

If an issue is already checked out, CanBookBeIssued must check if the
issue can be checked in before processing the return.
In such cases (depending of the AllowReturnToBranch pref), the issue
should not be allowed.

Prior to this patch, the checkin was not done and the checkout failed
with "Duplicate entry '1204321' for key 'itemnumber'". Indeed since bug
14978, there is an uniq key on issues.itemnumber. Before bug 14978 the
issue existed but was hidden (and some weird behaviors certainly
happened!).

To avoid Koha to crash, a check is added to CanBookBeIssued (call to
CanBookBeReturned) and the librarian is not able to process the
checkout.

Test plan:

- Set AllowReturnToBranch to anywhere
- Check an item (homebranch Library 1, holding branch Library 1) out from Library 1
- Check the item out from Library 2
=> Confirm the checkout (should work with and without this patch)

- Set AllowReturnToBranch to holdinbranch ("only the library the item
  was checked out from").
- Check an item (homebranch Library 1, holding branch Library 1) out from Library 1
- Check the item out from Library 2
=> Without this patch, Koha crashed
=> With this patch, you will be warned that the checkin is not possible.

Try other combinations of the AllowReturnToBranch syspref

Followed test plan, works as expected
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 9427d44568e6d52fde3960bda3ad957ca6a5b7fe)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
C4/Circulation.pm
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt