From 062f1ac56478a1b11ffee6dbda4c8f6eb9036446 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 7 Feb 2025 12:12:24 +0000 Subject: [PATCH] Bug 38924: Add quota accessor to Koha::Checkout and use on checkouts page --- Koha/Checkout.pm | 21 +++++++++++++++++++++ Koha/Patron/Quotas.pm | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm index 242a71b9e18..272bd1b657a 100644 --- a/Koha/Checkout.pm +++ b/Koha/Checkout.pm @@ -181,6 +181,27 @@ sub booking { return Koha::Booking->_new_from_dbic($booking_rs); } +=head3 quota + +my $quota = $checkout->quota; + +Return the checked out quota + +=cut + +sub quota { + my ($self) = @_; + my $usage_rs = $self->_result->quota_usages->search( + {}, + { + rows => 1, + order_by => { '-desc' => 'creation_date' } + } + )->single; + return unless $usage_rs; + return Koha::Patron::Quota->_new_from_dbic( $usage_rs->patron_quota ); +} + =head3 attempt_auto_renew my ($success, $error, $updated) = $checkout->auto_renew({ confirm => 1 }); diff --git a/Koha/Patron/Quotas.pm b/Koha/Patron/Quotas.pm index fc55f26da23..98deeda4f7e 100644 --- a/Koha/Patron/Quotas.pm +++ b/Koha/Patron/Quotas.pm @@ -2,6 +2,7 @@ package Koha::Patron::Quotas; use base qw(Koha::Objects); use Modern::Perl; + use Koha::Patron::Quota; use Koha::Patrons; @@ -65,4 +66,14 @@ sub object_class { return 'Koha::Patron::Quota'; } +=head3 koha_object_class + +Returns the package name for patron quota objects + +=cut + +sub koha_object_class { + return 'Koha::Patron::Quota'; +} + 1; -- 2.39.5