Bugzilla – Attachment 189274 Details for
Bug 38924
Introduce an organization level loan 'Quota' system for Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38924: Add Usage relations to Quota objects
Bug-38924-Add-Usage-relations-to-Quota-objects.patch (text/plain), 1.97 KB, created by
Jacob O'Mara
on 2025-11-07 12:13:09 UTC
(
hide
)
Description:
Bug 38924: Add Usage relations to Quota objects
Filename:
MIME Type:
Creator:
Jacob O'Mara
Created:
2025-11-07 12:13:09 UTC
Size:
1.97 KB
patch
obsolete
>From 218763181701745af88258bd734ba0bf42bedf43 Mon Sep 17 00:00:00 2001 >From: Jacob O'Mara <jacobomara901@gmail.com> >Date: Thu, 30 Jan 2025 18:23:09 +0000 >Subject: [PATCH] Bug 38924: Add Usage relations to Quota objects > >--- > Koha/Patron/Quota.pm | 43 ++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 40 insertions(+), 3 deletions(-) > >diff --git a/Koha/Patron/Quota.pm b/Koha/Patron/Quota.pm >index 1f1da940425..8a49060ccf3 100644 >--- a/Koha/Patron/Quota.pm >+++ b/Koha/Patron/Quota.pm >@@ -1,9 +1,10 @@ > package Koha::Patron::Quota; > >+use base qw(Koha::Object); > use Modern::Perl; > use Koha::DateUtils qw( dt_from_string ); >+use Koha::Patron::Quotas; > use Koha::Exceptions::Quota; >-use base qw(Koha::Object); > > =head1 NAME > >@@ -114,8 +115,8 @@ Returns the Koha::Patron associated with this quota > =cut > > sub patron { >- my ( $self ) = @_; >- return Koha::Patron->_new_from_dbic($self->_result->patron); >+ my ($self) = @_; >+ return Koha::Patron->_new_from_dbic( $self->_result->patron ); > } > > =head3 is_active >@@ -143,6 +144,42 @@ sub is_active { > return ( $start <= $today && $end >= $today ); > } > >+=head3 usages >+ >+Returns all usage records for this quota >+ >+=cut >+ >+sub usages { >+ my ($self) = @_; >+ my $usages_rs = $self->_result->patron_quota_usages; >+ return Koha::Patron::Quota::Usages->_new_from_dbic($usages_rs); >+} >+ >+=head3 add_usage >+ >+Creates a new usage record for this quota with the specified parameters. >+Returns the new Koha::Patron::Quota::Usage object. >+ >+=cut >+ >+sub add_usage { >+ my ( $self, $params ) = @_; >+ >+ # Set defaults >+ $params->{patron_id} = $self->patron_id; >+ $params->{patron_quota_id} = $self->id; >+ $params->{issue_id} = undef unless exists $params->{issue_id}; >+ >+ # Create usage record >+ my $usage = Koha::Patron::Quota::Usage->new($params)->store; >+ >+ # Update quota used amount >+ $self->add_to_quota( $params->{amount} ); >+ >+ return $usage; >+} >+ > =head2 Internal methods > > =head3 _type >-- >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 38924
:
178582
|
178583
|
178584
|
178585
|
178586
|
178587
|
178588
|
178589
|
178590
|
178591
|
178592
|
178593
|
178594
|
178595
|
178596
|
178597
|
178598
|
178599
|
178600
|
178601
|
178602
|
178603
|
178604
|
178605
|
178606
|
178607
|
178608
|
185631
|
185632
|
185633
|
185634
|
185635
|
185636
|
185637
|
185638
|
185639
|
185640
|
185641
|
185642
|
185643
|
185644
|
185645
|
185646
|
185647
|
185648
|
185649
|
185650
|
185651
|
185652
|
185653
|
185654
|
185655
|
185656
|
185657
|
185675
|
185676
|
185677
|
185678
|
185679
|
185680
|
185681
|
185682
|
185683
|
185684
|
185685
|
185686
|
185687
|
185688
|
185689
|
185690
|
185691
|
185692
|
185693
|
185694
|
185695
|
185696
|
185697
|
185698
|
185699
|
185700
|
185701
|
185702
|
189266
|
189267
|
189268
|
189269
|
189270
|
189271
|
189272
|
189273
| 189274 |
189275
|
189276
|
189277
|
189278
|
189279
|
189280
|
189281
|
189282
|
189283
|
189284
|
189285
|
189286
|
189287
|
189288
|
189289
|
189290
|
189291
|
189292