Bugzilla – Attachment 128070 Details for
Bug 26704
Koha::Item store triggers should utilise Koha::Object::Messages for message passing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Bug-26704-Update-KohaItem-to-use-KohaObjectMessage.patch (text/plain), 4.92 KB, created by
Martin Renvoize (ashimema)
on 2021-11-29 13:34:41 UTC
(
hide
)
Description:
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-11-29 13:34:41 UTC
Size:
4.92 KB
patch
obsolete
>From 86abd96797d6a74881b71952cb1bac04cb05c043 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 19 Mar 2021 14:51:57 +0000 >Subject: [PATCH] Bug 26704: Update Koha::Item to use Koha::Object::Messages > >--- > C4/Circulation.pm | 49 ++++++++++++++++++++++++++--------------------- > Koha/Item.pm | 23 +++++++++++++++++++--- > 2 files changed, 47 insertions(+), 25 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index c2edf81f94..7303c58fb7 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2129,29 +2129,34 @@ sub AddReturn { > if ($item_was_lost) { > $messages->{'WasLost'} = 1; > unless ( C4::Context->preference("BlockReturnOfLostItems") ) { >- $messages->{'LostItemFeeRefunded'} = 1 if $updated_item->{_refunded}; >- $messages->{'LostItemFeeRestored'} = 1 if $updated_item->{_restored}; >- >- if ( $updated_item->{_charge} ) { >- $issue //= Koha::Old::Checkouts->search( >- { itemnumber => $item->itemnumber }, >- { order_by => { '-desc' => 'returndate' }, rows => 1 } ) >- ->single; >- unless ( exists( $patron_unblessed->{branchcode} ) ) { >- my $patron = $issue->patron; >- $patron_unblessed = $patron->unblessed; >- } >- _CalculateAndUpdateFine( >- { >- issue => $issue, >- item => $item->unblessed, >- borrower => $patron_unblessed, >- return_date => $return_date >+ my @object_messages = @{ $updated_item->messages }; >+ for my $message (@object_messages) { >+ $messages->{'LostItemFeeRefunded'} = 1 >+ if $message->message eq 'lost_refunded'; >+ $messages->{'LostItemFeeRestored'} = 1 >+ if $message->message eq 'lost_restored'; >+ >+ if ( $message->message eq 'lost_charge' ) { >+ $issue //= Koha::Old::Checkouts->search( >+ { itemnumber => $item->itemnumber }, >+ { order_by => { '-desc' => 'returndate' }, rows => 1 } >+ )->single; >+ unless ( exists( $patron_unblessed->{branchcode} ) ) { >+ my $patron = $issue->patron; >+ $patron_unblessed = $patron->unblessed; > } >- ); >- _FixOverduesOnReturn( $patron_unblessed->{borrowernumber}, >- $item->itemnumber, undef, 'RETURNED' ); >- $messages->{'LostItemFeeCharged'} = 1; >+ _CalculateAndUpdateFine( >+ { >+ issue => $issue, >+ item => $item->unblessed, >+ borrower => $patron_unblessed, >+ return_date => $return_date >+ } >+ ); >+ _FixOverduesOnReturn( $patron_unblessed->{borrowernumber}, >+ $item->itemnumber, undef, 'RETURNED' ); >+ $messages->{'LostItemFeeCharged'} = 1; >+ } > } > } > } >diff --git a/Koha/Item.pm b/Koha/Item.pm >index d70fbc3f8f..e3332abe42 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1151,7 +1151,13 @@ sub _set_found_trigger { > ); > > $credit->apply( { debits => [$lost_charge] } ); >- $self->{_refunded} = 1; >+ $self->add_message( >+ { >+ type => 'info', >+ message => 'lost_refunded', >+ payload => { credit_id => $credit->id } >+ } >+ ); > } > > # Update the account status >@@ -1201,7 +1207,13 @@ sub _set_found_trigger { > if ( $refund ) { > # Revert the forgive credit > $refund->void({ interface => 'trigger' }); >- $self->{_restored} = 1; >+ $self->add_message( >+ { >+ type => 'info', >+ message => 'lost_restored', >+ payload => { refund_id => $refund->id } >+ } >+ ); > } > > # Reconcile balances if required >@@ -1211,7 +1223,12 @@ sub _set_found_trigger { > } > } > } elsif ( $lostreturn_policy eq 'charge' ) { >- $self->{_charge} = 1; >+ $self->add_message( >+ { >+ type => 'info', >+ message => 'lost_charge', >+ } >+ ); > } > } > >-- >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 26704
:
118548
|
122004
|
128070
|
128084
|
128085
|
130027
|
130028
|
130484
|
130485
|
130486
|
130657
|
130658