Browse Source

Bug 26704: Update Koha::Item to use Koha::Object::Messages

Use the newly introduced Koha::Object::Messages system to pass
additional information provided by object methods internally in the
objects themselves.

This patch updates the existing bespoke passing scheme to something
we've formally agreed to adopt going forward.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
22.05.x
Martin Renvoize 3 years ago
committed by Fridolin Somers
parent
commit
68d566e60b
  1. 49
      C4/Circulation.pm
  2. 23
      Koha/Item.pm

49
C4/Circulation.pm

@ -2128,29 +2128,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;
}
}
}
}

23
Koha/Item.pm

@ -1158,7 +1158,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
@ -1208,7 +1214,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
@ -1218,7 +1230,12 @@ sub _set_found_trigger {
}
}
} elsif ( $lostreturn_policy eq 'charge' ) {
$self->{_charge} = 1;
$self->add_message(
{
type => 'info',
message => 'lost_charge',
}
);
}
}

Loading…
Cancel
Save