Bugzilla – Attachment 122180 Details for
Bug 28588
Add Koha::Checkouts::ReturnClaim->resolve
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28588: Add Koha::Checkouts::ReturnClaim->resolve
Bug-28588-Add-KohaCheckoutsReturnClaim-resolve.patch (text/plain), 2.48 KB, created by
David Nind
on 2021-06-18 20:16:20 UTC
(
hide
)
Description:
Bug 28588: Add Koha::Checkouts::ReturnClaim->resolve
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-06-18 20:16:20 UTC
Size:
2.48 KB
patch
obsolete
>From 235bf758e00ac0493a24668acc4452c6aff7a27f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 18 Jun 2021 16:15:15 -0300 >Subject: [PATCH] Bug 28588: Add Koha::Checkouts::ReturnClaim->resolve > >This patch introduces a high-level method for resolving claims. >The behavior intends to replace the code in the API controller that is >used for resolving a claim. > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Checkouts/ReturnClaim.t >=> SUCCESS: Tests pass >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Checkouts/ReturnClaim.pm | 45 +++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > >diff --git a/Koha/Checkouts/ReturnClaim.pm b/Koha/Checkouts/ReturnClaim.pm >index 624c725949..3488e51626 100644 >--- a/Koha/Checkouts/ReturnClaim.pm >+++ b/Koha/Checkouts/ReturnClaim.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use base qw(Koha::Object); > > use Koha::Checkouts; >+use Koha::Exceptions; > use Koha::Exceptions::Checkouts::ReturnClaims; > use Koha::Old::Checkouts; > use Koha::Patrons; >@@ -79,6 +80,50 @@ sub patron { > return Koha::Patron->_new_from_dbic( $borrower ) if $borrower; > } > >+=head3 resolve >+ >+ $claim->resolve( >+ { >+ resolution => $resolution, >+ resolved_by => $patron_id, >+ [ resolved_on => $dt >+ new_lost_status => $status, ] >+ } >+ ); >+ >+Resolve the claim. >+ >+=cut >+ >+sub resolve { >+ my ( $self, $params ) = @_; >+ >+ my @mandatory = ( 'resolution', 'resolved_by' ); >+ for my $param (@mandatory) { >+ unless ( defined( $params->{$param} ) ) { >+ Koha::Exceptions::MissingParameter->throw( error => "The $param parameter is mandatory" ); >+ } >+ } >+ >+ $self->_result->result_source->schema->txn_do( >+ sub { >+ $self->set( >+ { resolution => $params->{resolution}, >+ resolved_by => $params->{resolved_by}, >+ resolved_on => $params->{resolved_on} // \'NOW()', >+ updated_by => $params->{resolved_by} >+ } >+ )->store; >+ >+ if ( defined $params->{new_lost_status} ) { >+ $self->checkout->item->itemlost( $params->{new_lost_status} )->store; >+ } >+ } >+ ); >+ >+ return $self; >+} >+ > =head3 to_api_mapping > > This method returns the mapping for representing a Koha::Checkouts::ReturnClaim object >-- >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 28588
:
122174
|
122175
|
122176
|
122179
|
122180
|
122181
|
122219
|
122220
|
122221