Bugzilla – Attachment 97180 Details for
Bug 15985
Include checkout library in fines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15985: (QA follow-up) Revert to Koha::Object bases
Bug-15985-QA-follow-up-Revert-to-KohaObject-bases.patch (text/plain), 5.48 KB, created by
Martin Renvoize (ashimema)
on 2020-01-10 10:37:44 UTC
(
hide
)
Description:
Bug 15985: (QA follow-up) Revert to Koha::Object bases
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-01-10 10:37:44 UTC
Size:
5.48 KB
patch
obsolete
>From 5185f632d8e484c5a2fcf6e6a09b80fc0ee93967 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 10 Jan 2020 10:08:50 +0000 >Subject: [PATCH] Bug 15985: (QA follow-up) Revert to Koha::Object bases > >Being pragmatic to try and move this bug on, I've reverted the changed >base class for the Old:: classes and cloned the required code from the >corresponding Object classes. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Checkout.pm | 2 +- > Koha/Old/Checkout.pm | 66 ++++++++++++++++++++++++++++++++-- > Koha/Old/Checkouts.pm | 2 +- > Koha/Schema/Result/OldIssue.pm | 44 +++++++++++++++++------ > 4 files changed, 100 insertions(+), 14 deletions(-) > >diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm >index e6d33fb05d..201faa84fd 100644 >--- a/Koha/Checkout.pm >+++ b/Koha/Checkout.pm >@@ -26,7 +26,7 @@ use Try::Tiny; > > use Koha::Checkouts::ReturnClaims; > use Koha::Database; >-use Koha::DateUtils; >+use Koha::DateUtils qw(dt_from_string); > use Koha::Items; > use Koha::Libraries; > >diff --git a/Koha/Old/Checkout.pm b/Koha/Old/Checkout.pm >index 8ac95de573..7210fc6ab9 100644 >--- a/Koha/Old/Checkout.pm >+++ b/Koha/Old/Checkout.pm >@@ -18,8 +18,9 @@ package Koha::Old::Checkout; > use Modern::Perl; > > use Koha::Database; >+use Koha::DateUtils qw(dt_from_string); > >-use base qw(Koha::Checkout); >+use base qw(Koha::Object); > > =head1 NAME > >@@ -54,7 +55,6 @@ Return the patron for who the checkout has been done > sub patron { > my ( $self ) = @_; > my $patron_rs = $self->_result->borrower; >- return unless $patron_rs; > return Koha::Patron->_new_from_dbic( $patron_rs ); > } > >@@ -79,6 +79,68 @@ sub to_api_mapping { > }; > } > >+=head3 claim_returned >+ >+my $return_claim = $checkout->claim_returned(); >+ >+=cut >+ >+sub claim_returned { >+ my ( $self, $params ) = @_; >+ >+ my $charge_lost_fee = $params->{charge_lost_fee}; >+ >+ try { >+ $self->_result->result_source->schema->txn_do( >+ sub { >+ my $claim = Koha::Checkouts::ReturnClaim->new( >+ { >+ issue_id => $self->id, >+ itemnumber => $self->itemnumber, >+ borrowernumber => $self->borrowernumber, >+ notes => $params->{notes}, >+ created_by => $params->{created_by}, >+ created_on => dt_from_string, >+ } >+ )->store(); >+ >+ my $ClaimReturnedLostValue = C4::Context->preference('ClaimReturnedLostValue'); >+ C4::Items::ModItem( { itemlost => $ClaimReturnedLostValue }, undef, $self->itemnumber ); >+ >+ my $ClaimReturnedChargeFee = C4::Context->preference('ClaimReturnedChargeFee'); >+ $charge_lost_fee = >+ $ClaimReturnedChargeFee eq 'charge' ? 1 >+ : $ClaimReturnedChargeFee eq 'no_charge' ? 0 >+ : $charge_lost_fee; # $ClaimReturnedChargeFee eq 'ask' >+ C4::Circulation::LostItem( $self->itemnumber, 'claim_returned' ) if $charge_lost_fee; >+ >+ return $claim; >+ } >+ ); >+ } >+ catch { >+ if ( $_->isa('Koha::Exceptions::Exception') ) { >+ $_->rethrow(); >+ } >+ else { >+ # ? >+ Koha::Exceptions::Exception->throw( "Unhandled exception" ); >+ } >+ }; >+} >+ >+=head3 library >+ >+my $library = $checkout->library; >+ >+=cut >+ >+sub library { >+ my ($self) = @_; >+ >+ my $library_rs = $self->_result->branch; >+ return Koha::Library->_new_from_dbic( $library_rs ); >+} > =head2 Internal methods > > =head3 _type >diff --git a/Koha/Old/Checkouts.pm b/Koha/Old/Checkouts.pm >index 1b5e21843a..c7f1a6a220 100644 >--- a/Koha/Old/Checkouts.pm >+++ b/Koha/Old/Checkouts.pm >@@ -20,7 +20,7 @@ use Modern::Perl; > use Koha::Database; > use Koha::Old::Checkout; > >-use base qw(Koha::Checkouts); >+use base qw(Koha::Objects); > > sub _type { > return 'OldIssue'; >diff --git a/Koha/Schema/Result/OldIssue.pm b/Koha/Schema/Result/OldIssue.pm >index 2ecbcab0d6..a0e2fc59aa 100644 >--- a/Koha/Schema/Result/OldIssue.pm >+++ b/Koha/Schema/Result/OldIssue.pm >@@ -233,16 +233,6 @@ __PACKAGE__->belongs_to( > }, > ); > >-__PACKAGE__->belongs_to( >- "branch", >- "Koha::Schema::Result::Branch", >- { branchcode => "branchcode" }, >- { >- is_deferrable => 1, >- join_type => "LEFT", >- }, >-); >- > > # Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-04-10 19:55:44 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E2N2paWcCHg916100ry+2A >@@ -252,6 +242,14 @@ __PACKAGE__->add_columns( > '+onsite_checkout' => { is_boolean => 1 } > ); > >+=head2 borrower >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Borrower> >+ >+=cut >+ > __PACKAGE__->belongs_to( > "borrower", > "Koha::Schema::Result::Borrower", >@@ -259,6 +257,14 @@ __PACKAGE__->belongs_to( > { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" }, > ); > >+=head2 item >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Item> >+ >+=cut >+ > __PACKAGE__->belongs_to( > "item", > "Koha::Schema::Result::Item", >@@ -271,6 +277,24 @@ __PACKAGE__->belongs_to( > }, > ); > >+=head2 branch >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Branch> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "branch", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "branchcode" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ }, >+); >+ > sub koha_object_class { > 'Koha::Old::Checkout'; > } >-- >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 15985
:
58157
|
58163
|
71165
|
72611
|
72612
|
90317
|
90318
|
90364
|
90478
|
97177
|
97178
|
97179
|
97180
|
99821
|
99822
|
99823
|
99824
|
99825
|
103152
|
103153
|
103154
|
103155
|
103156
|
103157
|
104491
|
104492
|
105144
|
105398