Bugzilla – Attachment 182128 Details for
Bug 39845
Add Koha::Acquisition::Orders->unreceived_totals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39845: Add Koha::Acquisition::Orders->unreceived_totals
Bug-39845-Add-KohaAcquisitionOrders-unreceivedtota.patch (text/plain), 1.93 KB, created by
David Nind
on 2025-05-08 22:00:56 UTC
(
hide
)
Description:
Bug 39845: Add Koha::Acquisition::Orders->unreceived_totals
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-05-08 22:00:56 UTC
Size:
1.93 KB
patch
obsolete
>From 2033eafa05d775a4bfa5b16f40a54d756dab38f2 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 6 May 2025 15:47:05 -0300 >Subject: [PATCH] Bug 39845: Add Koha::Acquisition::Orders->unreceived_totals > >This patch introduces a method for returning the following calculated values >for a `Koha::Acquisition::Orders` resultset: > >* items_count >* total_replacement_price > >To test: >1. Apply this patches >2. Run: > $ ktd --shell > k$ prove t/db_dependent/Koha/Acquisition/Orders.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Acquisition/Orders.pm | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > >diff --git a/Koha/Acquisition/Orders.pm b/Koha/Acquisition/Orders.pm >index c274e4b72a..9cfe339d7c 100644 >--- a/Koha/Acquisition/Orders.pm >+++ b/Koha/Acquisition/Orders.pm >@@ -276,6 +276,43 @@ sub filter_by_obsolete { > return $rs; > } > >+=head3 unreceived_totals >+ >+ my $unreceived_totals = $orders->unreceived_totals(); >+ >+Returns a hashref with the total unreceived items, and their total price, for the >+given I<Koha::Acquisition::Orders> resultset. >+ >+Example returned value: >+ >+ { >+ items_count => 36, >+ total_replacement_price => 87.5 >+ } >+ >+=cut >+ >+sub unreceived_totals { >+ my ($self) = @_; >+ >+ my $me = $self->_resultset()->current_source_alias; >+ my $result = $self->search( >+ {}, >+ { >+ select => [ >+ \"SUM($me.quantity - $me.quantityreceived)", >+ \"SUM(($me.quantity - $me.quantityreceived) * $me.rrp)" >+ ], >+ as => [ 'total_count', 'total_rrp' ], >+ } >+ )->next; >+ >+ return { >+ items_count => $result->get_column('total_count') // 0, >+ total_replacement_price => $result->get_column('total_rrp') // 0, >+ }; >+} >+ > =head3 cancel > > $orders_rs->cancel( { delete_biblio => 0|1 } ); >-- >2.39.5
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 39845
:
181992
|
181993
|
182127
| 182128