Lineitems by Bib only supports filtering a single state

Bug #1744762 reported by Kyle Huckins
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Won't Fix
Medium
Unassigned
3.1
Won't Fix
Medium
Unassigned
3.2
Won't Fix
Medium
Unassigned
3.3
Won't Fix
Medium
Unassigned
3.4
Won't Fix
Medium
Unassigned
3.5
Won't Fix
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.

Revision history for this message
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
Revision history for this message
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
Revision history for this message
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)
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
Changed in evergreen:
milestone: 3.2.6 → 3.2.7
Changed in evergreen:
milestone: 3.2.7 → 3.3.3
Changed in evergreen:
milestone: 3.3.3 → 3.3.4
Changed in evergreen:
milestone: 3.3.4 → 3.3.5
Changed in evergreen:
milestone: 3.3.5 → none
milestone: none → 3.4.2
Changed in evergreen:
milestone: 3.4.2 → 3.4.3
Changed in evergreen:
milestone: 3.4.3 → 3.4.4
Changed in evergreen:
milestone: 3.4.4 → 3.5.1
Changed in evergreen:
milestone: 3.5.1 → 3.5.2
Revision history for this message
Terran McCanna (tmccanna) wrote :

I assume from Mike's last comment that this one needs additional work? Removing pullrequest tag for the time being.

tags: added: needsrepatch
removed: pullrequest
Changed in evergreen:
milestone: 3.5.2 → 3.6.1
Changed in evergreen:
milestone: 3.6.1 → 3.6.2
Changed in evergreen:
milestone: 3.6.2 → 3.6.3
Changed in evergreen:
milestone: 3.6.3 → none
Revision history for this message
Kyle Huckins (khuckins) wrote :

Only just noticed your reply on this, Terran. I took Mike's statement as confirmation about the issue being a typo, which the patch resolved, but I could be wrong on that. Throwing on the Catalyte test server to get eyes on it

Revision history for this message
Tiffany Little (tslittle) wrote :

Kyle, I'm not sure how to test this through the UI. In the new Angular line item search, the only operator options for Line Item-Status search are: is, is not, exists, does not exist, matches a term from a file. And the status options are a predefined list. Trying to select one term, and then manually add a ", [new term]" doesn't work. The search retrieves everything and ignores the search term(s).

Revision history for this message
Kyle Huckins (khuckins) wrote :

Hey Tiffany,

Some quick steps from a look at the Angular Acq search UI:

1. Set "Search for records matching x of the following terms" to "Any"
2. Set the initial search term to Line Item - Status, is, On-Order
3. Add an additional search row, set to Line Item - Status, is, Received

It's possible the Angular UI bypasses the issue, however, as I'm not running into the issue with the new search

Revision history for this message
Jennifer Pringle (jpringle-u) wrote :

Tested on the new search in 3.7beta and I can confirm that this is no longer an issue. I can retrieve items on-order and received in the same search.

Revision history for this message
Tiffany Little (tslittle) wrote :

Based on Kyle and Jennifer's testing, marking this one as Won't Fix. Thanks to you both!

Changed in evergreen:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.