Change to acq patron request status logic, which now looks like this:
If a cancel_reason is set on the patron request, then status = "Canceled"
If there is an associated hold request that has fulfillment_time set,
then status = 'Fulfilled"
If there is an associated lineitem has a state of "received", then status =
"Received"
If there is an associated purchase order with a state of "on-order" and an
associated hold request, then status = "Ordered, Hold Placed"
If there is an associated purchase order with a state of "on-order" but no
associated hold request (created through the automated process), then status =
"Ordered, Hold Not Placed"
If there is an associated lineitem (selection list), then status = "Pending"
If there is no associated lineitem, then status = "New"
Any other condition, which should be impossible (I should never say that), will
give a status of "Error"
Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
SELECT r.*, CASE
WHEN r.cancel_reason IS NOT NULL THEN 7 -- Canceled
WHEN h.fulfillment_time IS NOT NULL THEN 6 -- Fulfilled
- WHEN p.state = 'received' THEN 5 -- Received
- WHEN p.id IS NOT NULL AND h.id IS NOT NULL THEN 4 -- Ordered, Hold Placed
- WHEN p.id IS NOT NULL AND h.id IS NULL THEN 3 -- Ordered, Hold Not Placed
+ WHEN l.state = 'received' THEN 5 -- Received
+ WHEN p.state = 'on-order' AND h.id IS NOT NULL THEN 4 -- Ordered, Hold Placed
+ WHEN p.state = 'on-order' AND h.id IS NULL THEN 3 -- Ordered, Hold Not Placed
WHEN l.id IS NOT NULL THEN 2 -- Pending
WHEN l.id IS NULL THEN 1 -- New
ELSE 0 -- Error