Bugzilla – Attachment 108611 Details for
Bug 18501
Automatic refunds need protection from failure
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18501: Prepare the ground
Bug-18501-Prepare-the-ground.patch (text/plain), 4.88 KB, created by
Jonathan Druart
on 2020-08-19 12:42:08 UTC
(
hide
)
Description:
Bug 18501: Prepare the ground
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-08-19 12:42:08 UTC
Size:
4.88 KB
patch
obsolete
>From 41ffdeb7319c0127ef146d294c8517b420c5701e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 10 Aug 2020 16:39:08 +0200 >Subject: [PATCH] Bug 18501: Prepare the ground > >This code was duplicated and we are going to need it. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Circulation.pm | 57 +++++++---------------------------------------- > Koha/Item.pm | 37 ++++++++++++++++++++++++++++++ > 2 files changed, 45 insertions(+), 49 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 7951fbe471..31f9e91ba4 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1510,30 +1510,7 @@ sub AddIssue { > > ## If item was lost, it has now been found, reverse any list item charges if necessary. > if ( $item_object->itemlost ) { >- my $refund = 1; >- my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge'); >- if ($no_refund_after_days) { >- my $today = dt_from_string(); >- my $lost_age_in_days = >- dt_from_string( $item_object->itemlost_on ) >- ->delta_days($today) >- ->in_units('days'); >- >- $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days ); >- } >- >- if ( >- $refund && Koha::CirculationRules->get_lostreturn_policy( >- { >- return_branch => C4::Context->userenv->{branch}, >- item => $item_object >- } >- ) >- ) >- { >- _FixAccountForLostAndFound( $item_object->itemnumber, undef, >- $item_object->barcode ); >- } >+ $item_object->set_found; > } > > $item_object->issues( ( $item_object->issues || 0 ) + 1); >@@ -2068,32 +2045,14 @@ sub AddReturn { > if ( $item->itemlost ) { > $messages->{'WasLost'} = 1; > unless ( C4::Context->preference("BlockReturnOfLostItems") ) { >- my $refund = 1; >- my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge'); >- if ($no_refund_after_days) { >- my $today = dt_from_string(); >- my $lost_age_in_days = >- dt_from_string( $item->itemlost_on ) >- ->delta_days($today) >- ->in_units('days'); >- >- $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days ); >- } >+ my $refunded = $item->set_found( >+ { >+ holdingbranch => $item_holding_branch, >+ borrowernumber => $borrowernumber >+ } >+ ); > >- if ( >- $refund && >- Koha::CirculationRules->get_lostreturn_policy( >- { >- return_branch => C4::Context->userenv->{branch}, >- item => $item, >- } >- ) >- ) >- { >- _FixAccountForLostAndFound( $item->itemnumber, >- $borrowernumber, $barcode ); >- $messages->{'LostItemFeeRefunded'} = 1; >- } >+ $messages->{'LostItemFeeRefunded'} = $refunded; > } > } > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 8602b9a308..fbc0983fee 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -763,6 +763,43 @@ sub renewal_branchcode { > return $branchcode; > } > >+sub set_found { >+ my ($self, $params) = @_; >+ >+ my $holdingbranch = $params->{holdingbranch} || $self->holdingbranch; >+ my $borrowernumber = $params->{borrowernumber} || undef; >+ >+ ## If item was lost, it has now been found, reverse any list item charges if necessary. >+ my $refund = 1; >+ my $no_refund_after_days = >+ C4::Context->preference('NoRefundOnLostReturnedItemsAge'); >+ if ($no_refund_after_days) { >+ my $today = dt_from_string(); >+ my $lost_age_in_days = >+ dt_from_string( $self->itemlost_on )->delta_days($today) >+ ->in_units('days'); >+ >+ $refund = 0 unless ( $lost_age_in_days < $no_refund_after_days ); >+ } >+ >+ my $refunded; >+ if ( >+ $refund >+ && Koha::CirculationRules->get_lostreturn_policy( >+ { >+ current_branch => C4::Context->userenv->{branch}, >+ item => $self, >+ } >+ ) >+ ) >+ { >+ _FixAccountForLostAndFound( $self->itemnumber, borrowernumber, $self->barcode ); >+ $refunded = 1; >+ } >+ >+ return $refunded; >+} >+ > =head3 to_api_mapping > > This method returns the mapping for representing a Koha::Item 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 18501
:
108004
|
108005
|
108006
|
108121
|
108122
|
108123
|
108167
|
108168
|
108169
|
108170
|
108193
|
108194
|
108195
|
108243
|
108248
|
108249
|
108291
|
108292
|
108293
|
108294
|
108295
|
108296
|
108297
|
108298
|
108299
|
108300
|
108301
|
108482
|
108483
|
108484
|
108485
|
108486
|
108487
|
108488
|
108489
|
108490
|
108491
|
108492
|
108493
|
108494
|
108575
|
108576
|
108577
|
108578
|
108579
|
108580
|
108581
|
108582
|
108583
|
108584
|
108585
|
108586
|
108596
|
108597
|
108598
|
108599
|
108600
|
108601
|
108602
|
108603
|
108604
|
108605
|
108606
|
108607
|
108608
|
108610
| 108611 |
108612
|
108613
|
108614
|
108615
|
108616
|
108617
|
108618
|
108619
|
108620
|
108621
|
108717
|
108732
|
108738
|
108739
|
108740
|
108741
|
108784
|
108785
|
108786
|
108787
|
108788
|
108795
|
111295