Bug 23404

Summary: Circulation::TooMany error on itemtype when at biblio level
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: CirculationAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: gmcharlt, kyle.m.hall, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16787
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00,19.05.04
Attachments: Bug 23404: add UT to show bug
Bug 23404: fix Circulation::TooMany error on itemtype when at biblio level
Bug 23404: Change UT calls
Bug 23404: add UT to show bug
Bug 23404: fix Circulation::TooMany error on itemtype when at biblio level
Bug 23404: Change UT calls
Bug 23404: add UT to show bug
Bug 23404: fix Circulation::TooMany error on itemtype when at biblio level
Bug 23404: Change UT calls
Bug 23404: (QA follow-up) Minor fix

Description Fridolin Somers 2019-07-31 13:02:25 UTC
Circulation::TooMany gets itemtype from $item var beeing a Koha::Item unblessed.
When itemtype is at biblio level, calling $item->{'itemtype'} is wrong.
Comment 1 Fridolin Somers 2019-07-31 14:00:42 UTC
Created attachment 91891 [details] [review]
Bug 23404: add UT to show bug

Run prove t/db_dependent/Circulation/TooMany.t
It fails on :
    #   Failed test 'We are only allowed one, and we have one (itemtype on biblioitem)'
    #   at t/db_dependent/Circulation/TooMany.t line 547.
    #     Structures begin differing at:
    #          $got->{reason} = 'NO_RULE_DEFINED'
    #     $expected->{reason} = 'TOO_MANY_CHECKOUTS'
Comment 2 Fridolin Somers 2019-07-31 14:01:00 UTC
Created attachment 91892 [details] [review]
Bug 23404: fix Circulation::TooMany error on itemtype when at biblio level

Circulation::TooMany gets itemtype from $item var beeing a Koha::Item unblessed.
When itemtype is at biblio level, calling $item->{'itemtype'} is wrong.

Test plan :
1) On a catalog with itemtype at item level : pref item-level_itypes=1
2) Create a biblio record with itemtype BOOK
3) Create an item on this biblio record with itemtype BOOK
4) Delete all issuing rules
5) Create a issuing rule with itemtype BOOK, any catagorie, any branch
6) Check-out the item
7) => Checkout is allowed
8) Check-in item
9) Change itemtype at biblio level : pref item-level_itypes=0
10) Check-out the item
11) => Checkout is not allowed
    You see message "No circulation rule is defined for this patron and itemtype combination"
Comment 3 Fridolin Somers 2019-07-31 14:01:14 UTC
Created attachment 91893 [details] [review]
Bug 23404: Change UT calls

Run prove t/db_dependent/Circulation/TooMany.t
Tests are OK
Comment 4 Fridolin Somers 2019-07-31 14:41:01 UTC
(In reply to Fridolin SOMERS from comment #2)
> Created attachment 91892 [details] [review] [review]
> Bug 23404: fix Circulation::TooMany error on itemtype when at biblio level
> 
> Circulation::TooMany gets itemtype from $item var beeing a Koha::Item
> unblessed.
> When itemtype is at biblio level, calling $item->{'itemtype'} is wrong.
> 

Note that patch removes in TooMany() method second arg $biblionumber, it is useless.
Comment 5 Fridolin Somers 2019-07-31 14:49:36 UTC
18.11.x needs to add to C4::Circulation::CanBookBeIssued :

    my $item_object = Koha::Items->find({barcode => $barcode });
after
    my $item = GetItem(undef, $barcode );
Comment 6 Kyle M Hall 2019-09-06 10:32:48 UTC
Created attachment 92626 [details] [review]
Bug 23404: add UT to show bug

Run prove t/db_dependent/Circulation/TooMany.t
It fails on :
    #   Failed test 'We are only allowed one, and we have one (itemtype on biblioitem)'
    #   at t/db_dependent/Circulation/TooMany.t line 547.
    #     Structures begin differing at:
    #          $got->{reason} = 'NO_RULE_DEFINED'
    #     $expected->{reason} = 'TOO_MANY_CHECKOUTS'

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 7 Kyle M Hall 2019-09-06 10:33:02 UTC
Created attachment 92627 [details] [review]
Bug 23404: fix Circulation::TooMany error on itemtype when at biblio level

Circulation::TooMany gets itemtype from $item var beeing a Koha::Item unblessed.
When itemtype is at biblio level, calling $item->{'itemtype'} is wrong.

Test plan :
1) On a catalog with itemtype at item level : pref item-level_itypes=1
2) Create a biblio record with itemtype BOOK
3) Create an item on this biblio record with itemtype BOOK
4) Delete all issuing rules
5) Create a issuing rule with itemtype BOOK, any catagorie, any branch
6) Check-out the item
7) => Checkout is allowed
8) Check-in item
9) Change itemtype at biblio level : pref item-level_itypes=0
10) Check-out the item
11) => Checkout is not allowed
    You see message "No circulation rule is defined for this patron and itemtype combination"

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 8 Kyle M Hall 2019-09-06 10:33:05 UTC
Created attachment 92628 [details] [review]
Bug 23404: Change UT calls

Run prove t/db_dependent/Circulation/TooMany.t
Tests are OK

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 9 Tomás Cohen Arazi 2019-09-06 18:54:58 UTC
Created attachment 92655 [details] [review]
Bug 23404: add UT to show bug

Run prove t/db_dependent/Circulation/TooMany.t
It fails on :
    #   Failed test 'We are only allowed one, and we have one (itemtype on biblioitem)'
    #   at t/db_dependent/Circulation/TooMany.t line 547.
    #     Structures begin differing at:
    #          $got->{reason} = 'NO_RULE_DEFINED'
    #     $expected->{reason} = 'TOO_MANY_CHECKOUTS'

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 10 Tomás Cohen Arazi 2019-09-06 18:55:03 UTC
Created attachment 92656 [details] [review]
Bug 23404: fix Circulation::TooMany error on itemtype when at biblio level

Circulation::TooMany gets itemtype from $item var beeing a Koha::Item unblessed.
When itemtype is at biblio level, calling $item->{'itemtype'} is wrong.

Test plan :
1) On a catalog with itemtype at item level : pref item-level_itypes=1
2) Create a biblio record with itemtype BOOK
3) Create an item on this biblio record with itemtype BOOK
4) Delete all issuing rules
5) Create a issuing rule with itemtype BOOK, any catagorie, any branch
6) Check-out the item
7) => Checkout is allowed
8) Check-in item
9) Change itemtype at biblio level : pref item-level_itypes=0
10) Check-out the item
11) => Checkout is not allowed
    You see message "No circulation rule is defined for this patron and itemtype combination"

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 11 Tomás Cohen Arazi 2019-09-06 18:55:13 UTC
Created attachment 92657 [details] [review]
Bug 23404: Change UT calls

Run prove t/db_dependent/Circulation/TooMany.t
Tests are OK

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 12 Tomás Cohen Arazi 2019-09-06 18:55:17 UTC
Created attachment 92658 [details] [review]
Bug 23404: (QA follow-up) Minor fix

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 13 Martin Renvoize 2019-09-09 10:17:01 UTC
Nice work!

Pushed to master for 19.11.00
Comment 14 Fridolin Somers 2019-09-13 12:35:47 UTC
Pushed to 19.05.x for 19.05.04