Lineitems by Bib only supports filtering a single state

Bug #1744762 reported by Kyle Huckins on 2018-01-22
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Medium
Unassigned
3.1
Medium
Unassigned

Bug Description

API Call for openils.acq.lineitems_related_by_bib that specify multiple Lineitem States under the lineitem_state filter option does not work, however supplying a single state string does work. Interestingly, the po_state filter does work.

In Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem.pm:

if ($options && defined $options->{lineitem_state}) {
    $query->{'where'}{'jub'}{'state'} = $options->{lineitem_state};
}

if ($options && defined $options->{po_state}) {
    $query->{'where'}{'+acqpo'}{'state'} = $options->{po_state};
}

In the code for open-ils.acq.lineitem.search.by_attributes, the following code appears to work:

if ($li_states and @$li_states) {
    $where->{"+jub"} = {"state" => $li_states};
    $searched_for_something = 1;
}

Changing {'jub'} to {'+jub'} in the lineitems_related_by_bib should solve this issue.

Kyle Huckins (khuckins) wrote :

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/khuckins/lp1744762-lineitem-state-filtering-api

Here's a quick branch that solves the issue. Best way to test this would be to create three active lineitems for a bib record, cancel one, and mark the second as received. Then make an API call with ['on-order', 'received'] passed in for lineitem_state in our options object. It should retrieve the lineitems that weren't canceled.

tags: added: pullrequest
Bill Erickson (berick) wrote :

Added a 3.1 target, since this bug does not affect EG proper, because no existing code uses this filter.

Changed in evergreen:
status: New → Confirmed
milestone: none → 3.1-beta
Mike Rylander (mrylander) wrote :

Kyle, that missing "+" is just wrong, but it looks like it should work, if only incidentally, because "jub" is the core class of the query. I'm actually surprised that the in-list version doesn't work, but perhaps there is some subtle difference in the implicit-equals and the implicit-in-list code that's allowing the former to work in what amounts to an extra (useless) "AND" nesting but not the latter.

Bill, the lineitems_related_by_bib sub has been there since 2010 according to git-blame. You don't think the fix should be backported? It looks like a simple typo to me, in any case, right?.

Changed in evergreen:
milestone: 3.1-beta → 3.1-rc
Dan Wells (dbw2) on 2018-03-20
Changed in evergreen:
importance: Undecided → Medium
Changed in evergreen:
milestone: 3.1-rc → 3.1.1
Changed in evergreen:
milestone: 3.1.1 → 3.1.2
Changed in evergreen:
milestone: 3.1.2 → 3.1.3
Changed in evergreen:
milestone: 3.1.3 → 3.1.4
Changed in evergreen:
milestone: 3.1.4 → 3.1.5
Changed in evergreen:
milestone: 3.1.5 → 3.1.6
Changed in evergreen:
milestone: 3.1.6 → 3.2.1
Changed in evergreen:
milestone: 3.2.1 → 3.2.2
Changed in evergreen:
milestone: 3.2.2 → 3.2.3
Changed in evergreen:
milestone: 3.2.3 → 3.2.4
Changed in evergreen:
milestone: 3.2.4 → 3.2.5
Changed in evergreen:
milestone: 3.2.5 → 3.2.6
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers