Bugzilla – Attachment 134233 Details for
Bug 30275
Checkout renewals should be stored in their own table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30275: Add Koha::Objects for Renewals
Bug-30275-Add-KohaObjects-for-Renewals.patch (text/plain), 6.69 KB, created by
Martin Renvoize (ashimema)
on 2022-04-28 12:21:31 UTC
(
hide
)
Description:
Bug 30275: Add Koha::Objects for Renewals
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-04-28 12:21:31 UTC
Size:
6.69 KB
patch
obsolete
>From c6ccefc388a6d62d7f80c288e57e65debe95300a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 11 Mar 2022 13:32:20 +0000 >Subject: [PATCH] Bug 30275: Add Koha::Objects for Renewals > >Add Koha::Checkouts::Renewals|Renewal classes > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Checkouts/Renewal.pm | 135 ++++++++++++++++++++++++++ > Koha/Checkouts/Renewals.pm | 61 ++++++++++++ > Koha/Exceptions/Checkouts/Renewals.pm | 49 ++++++++++ > 3 files changed, 245 insertions(+) > create mode 100644 Koha/Checkouts/Renewal.pm > create mode 100644 Koha/Checkouts/Renewals.pm > create mode 100644 Koha/Exceptions/Checkouts/Renewals.pm > >diff --git a/Koha/Checkouts/Renewal.pm b/Koha/Checkouts/Renewal.pm >new file mode 100644 >index 0000000000..e8a513d650 >--- /dev/null >+++ b/Koha/Checkouts/Renewal.pm >@@ -0,0 +1,135 @@ >+package Koha::Checkouts::Renewal; >+ >+# Copyright PTFS Europe 2022 >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use base qw(Koha::Object); >+ >+use Koha::Checkout; >+use Koha::Checkouts; >+use Koha::Exceptions; >+use Koha::Exceptions::Checkouts::Renewals; >+use Koha::Old::Checkouts; >+use Koha::Patron; >+ >+=head1 NAME >+ >+Koha::Checkouts::Renewal - Koha Renewal object class >+ >+=head1 API >+ >+=head2 Class methods >+ >+=cut >+ >+=head3 store >+ >+ my $return_claim = Koha::Checkout::Renewal->new($args)->store; >+ >+Overloaded I<store> method that validates the attributes and raises relevant >+exceptions as needed. >+ >+=cut >+ >+sub store { >+ my ( $self ) = @_; >+ >+ unless ( $self->in_storage || $self->renewer_id ) { >+ Koha::Exceptions::Checkouts::Renewals::NoRenewerID->throw(); >+ } >+ >+ unless ( ( !$self->issue_id && $self->in_storage ) >+ || Koha::Checkouts->find( $self->issue_id ) >+ || Koha::Old::Checkouts->find( $self->issue_id ) ) >+ { >+ Koha::Exceptions::Object::FKConstraint->throw( >+ error => 'Broken FK constraint', >+ broken_fk => 'issue_id' >+ ); >+ } >+ >+ return $self->SUPER::store; >+} >+ >+=head3 checkout >+ >+=cut >+ >+sub checkout { >+ my ($self) = @_; >+ >+ my $checkout_rs = $self->_result->checkout; >+ return unless $checkout_rs; >+ return Koha::Checkout->_new_from_dbic($checkout_rs); >+} >+ >+=head3 old_checkout >+ >+=cut >+ >+sub old_checkout { >+ my ($self) = @_; >+ >+ my $old_checkout_rs = $self->_result->old_checkout; >+ return unless $old_checkout_rs; >+ return Koha::Old::Checkout->_new_from_dbic($old_checkout_rs); >+} >+ >+=head3 renewer >+ >+=cut >+ >+sub renewer { >+ my ( $self ) = @_; >+ >+ my $renewer = $self->_result->renewer; >+ return Koha::Patron->_new_from_dbic( $renewer ) if $renewer; >+} >+ >+=head3 to_api_mapping >+ >+This method returns the mapping for representing a Koha::Checkouts::Renewal object >+on the API. >+ >+=cut >+ >+sub to_api_mapping { >+ return { >+ id => 'renewal_id', >+ issue_id => 'checkout_id' >+ }; >+} >+ >+=head2 Internal methods >+ >+=head3 _type >+ >+=cut >+ >+sub _type { >+ return 'CheckoutRenewal'; >+} >+ >+=head1 AUTHOR >+ >+Martin Renvoize <martin.renvoize@ptfs-europe.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Checkouts/Renewals.pm b/Koha/Checkouts/Renewals.pm >new file mode 100644 >index 0000000000..5ec654fa8e >--- /dev/null >+++ b/Koha/Checkouts/Renewals.pm >@@ -0,0 +1,61 @@ >+package Koha::Checkouts::Renewals; >+ >+# Copyright PTFS Europe 2022 >+# >+# This file is part of oha. >+# >+# oha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# oha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with oha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+ >+use Koha::Database; >+ >+use Koha::Checkouts::Renewal; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Checkouts::Renewals - Koha Renewal object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'CheckoutRenewal'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Checkouts::Renewal'; >+} >+ >+=head1 AUTHOR >+ >+Martin Renvoize <martin.renvoize@ptfs-europe.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Exceptions/Checkouts/Renewals.pm b/Koha/Exceptions/Checkouts/Renewals.pm >new file mode 100644 >index 0000000000..93ca7373d6 >--- /dev/null >+++ b/Koha/Exceptions/Checkouts/Renewals.pm >@@ -0,0 +1,49 @@ >+package Koha::Exceptions::Checkouts::Renewals; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Koha::Exception; >+ >+use Exception::Class ( >+ 'Koha::Exceptions::Checkouts::Renewals' => { >+ isa => 'Koha::Exception', >+ }, >+ 'Koha::Exceptions::Checkouts::Renewals::NoRenewerID' => { >+ isa => 'Koha::Exceptions::Checkouts::Renewals', >+ description => 'renewer_id is mandatory' >+ }, >+); >+ >+=head1 NAME >+ >+Koha::Exceptions::Checkouts - Base class for Checkouts exceptions >+ >+=head1 Exceptions >+ >+=head2 Koha::Exceptions::Checkouts::Renewals >+ >+Generic return claim exception >+ >+=head2 Koha::Exceptions::Checkouts::Renewals::NoRenewerID >+ >+Exception to be used when a renewal is requested to be store but >+the 'renewer_id' param is not passed. >+ >+=cut >+ >+1; >-- >2.20.1
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 30275
:
131593
|
131594
|
131595
|
131596
|
131597
|
131598
|
131599
|
131600
|
131601
|
131602
|
131603
|
131604
|
131605
|
131606
|
131607
|
131608
|
131609
|
131610
|
131611
|
131612
|
131613
|
131614
|
131615
|
131616
|
131879
|
131880
|
131881
|
131882
|
131883
|
131884
|
131885
|
131886
|
131887
|
131888
|
131889
|
131890
|
131897
|
131898
|
131899
|
131900
|
131901
|
131902
|
131903
|
131904
|
131905
|
131906
|
131907
|
131908
|
131909
|
131910
|
133908
|
133909
|
133910
|
133911
|
133912
|
133913
|
133914
|
133915
|
133916
|
133917
|
133918
|
133919
|
133920
|
133921
|
133922
|
133929
|
133930
|
133931
|
133932
|
133933
|
133934
|
133935
|
133936
|
133937
|
133938
|
133939
|
133940
|
133941
|
133942
|
133943
|
133944
|
133969
|
133970
|
133971
|
133972
|
133973
|
133974
|
133975
|
133976
|
133977
|
133978
|
133979
|
133980
|
133981
|
133982
|
133983
|
133984
|
134177
|
134178
|
134179
|
134180
|
134181
|
134182
|
134183
|
134184
|
134185
|
134186
|
134187
|
134188
|
134189
|
134190
|
134191
|
134192
|
134193
|
134210
|
134228
|
134229
|
134230
|
134231
|
134232
|
134233
|
134234
|
134235
|
134236
|
134237
|
134238
|
134239
|
134240
|
134241
|
134242
|
134243
|
134244
|
134245
|
134246
|
134247
|
134248
|
134470
|
134471
|
134472
|
134473
|
134869
|
134870
|
134871
|
134872
|
134873
|
134874
|
134875
|
134876
|
134877
|
134878
|
134879
|
134880
|
134881
|
134882
|
134883
|
134884
|
134885
|
134886
|
134887
|
134888
|
134889
|
135123
|
135124
|
135125
|
135126
|
135127
|
135128
|
135129
|
135130
|
135131
|
135132
|
135133
|
135134
|
135135
|
135136
|
135137
|
135138
|
135139
|
135140
|
135141
|
135142
|
135143
|
137146
|
137147
|
137148
|
137149
|
137150
|
137151
|
137152
|
137153
|
137154
|
137155
|
137156
|
137157
|
137158
|
137159
|
137160
|
137161
|
137162
|
137163
|
137164
|
137165
|
137166
|
137217
|
137598