From 566b09bd0d12204c2d595d9ebc7860990cd17257 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 | 12 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm index 3c8218cea0..f22e4539ba 100644 --- a/Koha/Checkout.pm +++ b/Koha/Checkout.pm @@ -165,6 +165,27 @@ sub renewals { return Koha::Checkouts::Renewals->_new_from_dbic($renewals_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 fc55f26da2..4d9c39f195 100644 --- a/Koha/Patron/Quotas.pm +++ b/Koha/Patron/Quotas.pm @@ -2,6 +2,8 @@ package Koha::Patron::Quotas; use base qw(Koha::Objects); use Modern::Perl; +use base qw(Koha::Objects); + use Koha::Patron::Quota; use Koha::Patrons; @@ -65,4 +67,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.50.1