@@ -, +, @@ $ kshell k$ prove t/db_dependent/api/v1/holds.t --- Koha/REST/V1/Holds.pm | 27 ++++++++++++++++++++++++- api/v1/swagger/definitions/library.json | 4 ++++ 2 files changed, 30 insertions(+), 1 deletion(-) --- a/Koha/REST/V1/Holds.pm +++ a/Koha/REST/V1/Holds.pm @@ -473,10 +473,35 @@ sub pickup_locations { } my $pickup_locations = $c->objects->search( $ps_set ); + my @response = (); + + if ( C4::Context->preference('AllowHoldPolicyOverride') ) { + + my $libraries_rs = Koha::Libraries->search( { pickup_location => 1 } ); + my $libraries = $c->objects->search($libraries_rs); + + @response = map { + my $library = $_; + $library->{needs_override} = ( + any { $_->{library_id} eq $library->{library_id} } + @{$pickup_locations} + ) + ? Mojo::JSON->false + : Mojo::JSON->true; + $library; + } @{$libraries}; + + return $c->render( + status => 200, + openapi => \@response + ); + } + + @response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations}; return $c->render( status => 200, - openapi => $pickup_locations + openapi => \@response ); } catch { --- a/api/v1/swagger/definitions/library.json +++ a/api/v1/swagger/definitions/library.json @@ -91,6 +91,10 @@ "smtp_server": { "type": ["object", "null"], "description": "The library effective SMTP server" + }, + "needs_override": { + "type": "boolean", + "description": "If the library needs an override to act as pickup location for a hold" } }, "additionalProperties": false, --