Bugzilla – Attachment 182041 Details for
Bug 32266
Make the late orders page render using the API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32266: Add only_late filters to the endpoint
Bug-32266-Add-onlylate-filters-to-the-endpoint.patch (text/plain), 4.23 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-05-07 19:08:12 UTC
(
hide
)
Description:
Bug 32266: Add only_late filters to the endpoint
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-05-07 19:08:12 UTC
Size:
4.23 KB
patch
obsolete
>From f51f6460f8216f5b15264d548aa200a5987f1464 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 30 Apr 2025 14:45:49 -0300 >Subject: [PATCH] Bug 32266: Add only_late filters to the endpoint > >--- > Koha/REST/V1/Acquisitions/Orders.pm | 32 ++++++++++++++++--- > api/v1/swagger/definitions/order.yaml | 5 +++ > api/v1/swagger/paths/acquisitions_orders.yaml | 22 +++++++++++++ > 3 files changed, 54 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Acquisitions/Orders.pm b/Koha/REST/V1/Acquisitions/Orders.pm >index 39120dda3f8..49840e01bc8 100644 >--- a/Koha/REST/V1/Acquisitions/Orders.pm >+++ b/Koha/REST/V1/Acquisitions/Orders.pm >@@ -20,6 +20,7 @@ use Modern::Perl; > use Mojo::Base 'Mojolicious::Controller'; > > use Koha::Acquisition::Orders; >+use Koha::DateUtils qw(dt_from_string); > > use Clone qw( clone ); > use JSON; >@@ -49,14 +50,35 @@ sub list { > my $only_active = $c->param('only_active'); > my $order_id = $c->param('order_id'); > >- $c->req->params->remove('only_active')->remove('order_id'); >+ # handle late orders >+ my $only_late = $c->param('only_late'); >+ my $late_delay = $c->param('late_delay') // 0; >+ my $estimateddeliverydatefrom = $c->param('estimated_deliverydate_from'); >+ my $estimateddeliverydateto = $c->param('estimated_deliverydate_to'); > >- my $orders_rs; >+ $c->req->params->remove('only_active')->remove('order_id')->remove('only_late') >+ ->remove('estimated_deliverydate_from')->remove('estimated_deliverydate_to')->remove('late_delay'); >+ >+ my $orders_rs = Koha::Acquisition::Orders->new; > > if ($only_active) { >- $orders_rs = Koha::Acquisition::Orders->filter_by_active; >- } else { >- $orders_rs = Koha::Acquisition::Orders->new; >+ $orders_rs = $orders_rs->filter_by_active; >+ } elsif ($only_late) { >+ $orders_rs = $orders_rs->filter_by_lates( >+ { >+ delay => $late_delay, >+ ( >+ $estimateddeliverydatefrom >+ ? ( estimated_from => dt_from_string( $estimateddeliverydatefrom, 'iso' ) ) >+ : () >+ ), >+ ( >+ $estimateddeliverydateto >+ ? ( estimated_to => dt_from_string( $estimateddeliverydateto, 'iso' ) ) >+ : () >+ ) >+ } >+ ); > } > > $orders_rs = $orders_rs->filter_by_id_including_transfers( { ordernumber => $order_id } ) >diff --git a/api/v1/swagger/definitions/order.yaml b/api/v1/swagger/definitions/order.yaml >index 61aaae480d9..3eafa266620 100644 >--- a/api/v1/swagger/definitions/order.yaml >+++ b/api/v1/swagger/definitions/order.yaml >@@ -264,4 +264,9 @@ properties: > - object > - "null" > description: Patron that created the order >+ calculated_estimated_delivery_date: >+ type: >+ - string >+ - "null" >+ format: date > additionalProperties: false >diff --git a/api/v1/swagger/paths/acquisitions_orders.yaml b/api/v1/swagger/paths/acquisitions_orders.yaml >index 5b87bf4cc3c..36a5e5df86e 100644 >--- a/api/v1/swagger/paths/acquisitions_orders.yaml >+++ b/api/v1/swagger/paths/acquisitions_orders.yaml >@@ -35,6 +35,28 @@ > description: If only active orders should be listed > required: false > type: boolean >+ - name: only_late >+ in: query >+ description: Only retrieve late orders >+ required: false >+ type: boolean >+ - name: late_delay >+ in: query >+ description: Delay to consider an order late (days) >+ required: false >+ type: integer >+ - name: estimated_deliverydate_from >+ description: Estimated delivery date from >+ in: query >+ type: string >+ format: date >+ required: false >+ - name: estimated_deliverydate_to >+ description: Estimated delivery date to >+ in: query >+ type: string >+ format: date >+ required: false > - $ref: "../swagger.yaml#/parameters/match" > - $ref: "../swagger.yaml#/parameters/order_by" > - $ref: "../swagger.yaml#/parameters/page" >-- >2.49.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32266
:
144145
|
144165
|
144699
| 182041 |
182042
|
182043
|
182269