Bugzilla – Attachment 175578 Details for
Bug 38246
If using automatic return claim resolution on checkout, each checkout will overwrite the previous resolution
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38246: [24.05.x] Only check unresolved claims
Bug-38246-2405x-Only-check-unresolved-claims.patch (text/plain), 17.67 KB, created by
Emily Lamancusa (emlam)
on 2024-12-16 20:22:04 UTC
(
hide
)
Description:
Bug 38246: [24.05.x] Only check unresolved claims
Filename:
MIME Type:
Creator:
Emily Lamancusa (emlam)
Created:
2024-12-16 20:22:04 UTC
Size:
17.67 KB
patch
obsolete
>From bbcc5fdac5e75fcaa5345a535ad9e96bf260a1bf Mon Sep 17 00:00:00 2001 >From: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> >Date: Wed, 23 Oct 2024 15:33:51 -0400 >Subject: [PATCH] Bug 38246: [24.05.x] Only check unresolved claims > >To test: >1. Set up sysprefs: > - Set any non-empty value for ClaimReturnedLostValue > - Set AutoClaimReturnStatusOnCheckout to "found in library" > - Set AutoClaimReturnStatusOnCheckin to "returned by patron" >2. Check out an item to a patron >3. On the patron's account page, click the "Claim Return" button next to > that checkout >4. Check the item in. Note the message that the claim was auto-resolved. >5. Return to the patron's account page and open the Claims Returned tab >--> Note that the claim is resolved and hidden >6. Click the "Show all 1 claims" link to view the hidden claim. Make a > note of the resolution code and timestamp. >7. Check the item out again >--> Note the message saying that the claim was resolved, even though it > was already resolved previously >8. View the return claim again >--> Note that the timestamp and resolution code have changed >9. Apply patch and restart_all >10. Repeat steps 2-8 with a new item >--> Note you do not get a claim resolved message on checkout this time >--> Note that the timestamp and resolution code remain the same before > and after the checkout > >Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > circ/circulation.pl | 307 ++++++++++++++++++++++---------------------- > 1 file changed, 154 insertions(+), 153 deletions(-) > >diff --git a/circ/circulation.pl b/circ/circulation.pl >index a354c1257d..dbc200a81e 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -351,193 +351,194 @@ if (@$barcodes && $op eq 'cud-checkout') { > } > }; > >- my $blocker = $invalidduedate ? 1 : 0; >+ my $blocker = $invalidduedate ? 1 : 0; > >- $template_params->{alert} = $alerts; >- $template_params->{messages} = $messages; >+ $template_params->{alert} = $alerts; >+ $template_params->{messages} = $messages; > >- my $item = Koha::Items->find({ barcode => $barcode }); >+ my $item = Koha::Items->find({ barcode => $barcode }); > >- my $biblio; >- if ( $item ) { >- $biblio = $item->biblio; >- } >+ my $biblio; >+ if ( $item ) { >+ $biblio = $item->biblio; >+ } > >- if ( $issuingimpossible->{'STATS'} ) { >- my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = >- AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ); >+ if ( $issuingimpossible->{'STATS'} ) { >+ my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = >+ AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ); > >- $template->param( >- STATS => 1, >- CHECKEDIN => $stats_return, >- MESSAGES => $stats_messages, >- ITEM => $stats_iteminformation, >- BORROWER => $stats_borrower, >- ); >+ $template->param( >+ STATS => 1, >+ CHECKEDIN => $stats_return, >+ MESSAGES => $stats_messages, >+ ITEM => $stats_iteminformation, >+ BORROWER => $stats_borrower, >+ ); > >- #increment items.localuse >- my $localuse_count = $item->localuse; >- $localuse_count++; >- $item->localuse($localuse_count)->store; >- } >+ #increment items.localuse >+ my $localuse_count = $item->localuse; >+ $localuse_count++; >+ $item->localuse($localuse_count)->store; >+ } > >- # Fix for bug 7494: optional checkout-time fallback search for a book >+ # Fix for bug 7494: optional checkout-time fallback search for a book > >- if ( $issuingimpossible->{'UNKNOWN_BARCODE'} >- && C4::Context->preference("itemBarcodeFallbackSearch") >- && not $batch >- ) >- { >- $template_params->{FALLBACK} = 1; >- >- my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); >- my $query = "kw=" . $barcode; >- my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10); >- >- # if multiple hits, offer options to librarian >- if ( $total_hits > 0 ) { >- my @barcodes; >- foreach my $hit ( @{$results} ) { >- my $chosen = # Maybe easier to retrieve the itemnumber from $hit? >- TransformMarcToKoha({ record => C4::Search::new_record_from_zebra('biblioserver',$hit) }); >- >- # offer all barcodes individually >- if ( $chosen->{barcode} ) { >- push @barcodes, sort split(/\s*\|\s*/, $chosen->{barcode}); >+ if ( $issuingimpossible->{'UNKNOWN_BARCODE'} >+ && C4::Context->preference("itemBarcodeFallbackSearch") >+ && not $batch >+ ) >+ { >+ $template_params->{FALLBACK} = 1; >+ >+ my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); >+ my $query = "kw=" . $barcode; >+ my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10); >+ >+ # if multiple hits, offer options to librarian >+ if ( $total_hits > 0 ) { >+ my @barcodes; >+ foreach my $hit ( @{$results} ) { >+ my $chosen = # Maybe easier to retrieve the itemnumber from $hit? >+ TransformMarcToKoha({ record => C4::Search::new_record_from_zebra('biblioserver',$hit) }); >+ >+ # offer all barcodes individually >+ if ( $chosen->{barcode} ) { >+ push @barcodes, sort split(/\s*\|\s*/, $chosen->{barcode}); >+ } > } >+ my $items = Koha::Items->search({ barcode => {-in => \@barcodes}}); >+ $template_params->{options} = $items; > } >- my $items = Koha::Items->search({ barcode => {-in => \@barcodes}}); >- $template_params->{options} = $items; > } >- } > >- # Only some errors will block when performing forced onsite checkout, >- # for other cases all errors will block >- my @blocking_error_codes = >- ( $onsite_checkout and C4::Context->preference("OnSiteCheckoutsForce") ) >- ? qw( UNKNOWN_BARCODE NO_OPEN_DAYS ) >- : ( keys %$issuingimpossible ); >- >- if ( $issuingimpossible->{BOOKED_TO_ANOTHER} ) { >- $template_params->{BOOKED_TO_ANOTHER} = $issuingimpossible->{BOOKED_TO_ANOTHER}; >- $template_params->{IMPOSSIBLE} = 1; >- $blocker = 1; >- } >+ # Only some errors will block when performing forced onsite checkout, >+ # for other cases all errors will block >+ my @blocking_error_codes = >+ ( $onsite_checkout and C4::Context->preference("OnSiteCheckoutsForce") ) >+ ? qw( UNKNOWN_BARCODE NO_OPEN_DAYS ) >+ : ( keys %$issuingimpossible ); >+ >+ if ( $issuingimpossible->{BOOKED_TO_ANOTHER} ) { >+ $template_params->{BOOKED_TO_ANOTHER} = $issuingimpossible->{BOOKED_TO_ANOTHER}; >+ $template_params->{IMPOSSIBLE} = 1; >+ $blocker = 1; >+ } > >- foreach my $code ( @blocking_error_codes ) { >- if ($issuingimpossible->{$code}) { >- $template_params->{$code} = $issuingimpossible->{$code}; >+ foreach my $code ( @blocking_error_codes ) { >+ if ($issuingimpossible->{$code}) { >+ $template_params->{$code} = $issuingimpossible->{$code}; > >- $template_params->{IMPOSSIBLE} = 1; >- $blocker = 1; >+ $template_params->{IMPOSSIBLE} = 1; >+ $blocker = 1; >+ } > } >- } > >- delete $needsconfirmation->{'DEBT'} if ($debt_confirmed); >+ delete $needsconfirmation->{'DEBT'} if ($debt_confirmed); > >- if ( $item && C4::Context->preference('ClaimReturnedLostValue') ) { >- my $autoClaimReturnCheckout = C4::Context->preference('AutoClaimReturnStatusOnCheckout'); >+ if ( $item && C4::Context->preference('ClaimReturnedLostValue') ) { >+ my $autoClaimReturnCheckout = C4::Context->preference('AutoClaimReturnStatusOnCheckout'); > >- my $claims = Koha::Checkouts::ReturnClaims->search( >- { >- itemnumber => $item->id, >+ my $claims = Koha::Checkouts::ReturnClaims->search( >+ { >+ itemnumber => $item->id, >+ resolution => undef, >+ } >+ ); >+ if ( $claims->count ) { >+ if ($autoClaimReturnCheckout) { >+ my $claim = $claims->next; >+ >+ my $patron_id = $logged_in_user->borrowernumber; >+ my $resolution = $autoClaimReturnCheckout; >+ >+ $claim->resolve( >+ { >+ resolution => $resolution, >+ resolved_by => $patron_id, >+ } >+ ); >+ $template_params->{CLAIM_RESOLUTION} = $claim; >+ } > } >- ); >- if ( $claims->count ) { >- if ($autoClaimReturnCheckout) { >- my $claim = $claims->next; >- >- my $patron_id = $logged_in_user->borrowernumber; >- my $resolution = $autoClaimReturnCheckout; >+ } > >- $claim->resolve( >- { >- resolution => $resolution, >- resolved_by => $patron_id, >+ if( $item and ( !$blocker or $force_allow_issue ) ){ >+ my $confirm_required = 0; >+ unless($issueconfirmed){ >+ # Get the item title for more information >+ my $materials = $item->materials; >+ my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', authorised_value => $materials }); >+ $materials = $descriptions->{lib} // $materials; >+ $template_params->{ADDITIONAL_MATERIALS} = $materials; >+ $template_params->{itemhomebranch} = $item->homebranch; >+ >+ # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed. >+ foreach my $needsconfirmation_key ( keys %$needsconfirmation ) { >+ $template_params->{$needsconfirmation_key} = $needsconfirmation->{$needsconfirmation_key}; >+ $template_params->{getTitleMessageIteminfo} = $biblio->title; >+ $template_params->{getBarcodeMessageIteminfo} = $item->barcode; >+ $template_params->{NEEDSCONFIRMATION} = 1; >+ $confirm_required = 1; >+ if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { >+ my $reduceddue = >+ dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )->subtract( days => 1 ); >+ $template_params->{reduceddue} = $reduceddue; > } >- ); >- $template_params->{CLAIM_RESOLUTION} = $claim; >+ } > } >- } >- } >+ unless ($confirm_required) { >+ my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; >+ if ( C4::Context->preference('UseRecalls') && !$recall_id ) { >+ my $recall = Koha::Recalls->find( >+ { >+ biblio_id => $item->biblionumber, >+ item_id => [ undef, $item->itemnumber ], >+ status => [ 'requested', 'waiting' ], >+ completed => 0, >+ patron_id => $patron->borrowernumber, >+ } >+ ); >+ $recall_id = ( $recall and $recall->id ) ? $recall->id : undef; >+ } > >- if( $item and ( !$blocker or $force_allow_issue ) ){ >- my $confirm_required = 0; >- unless($issueconfirmed){ >- # Get the item title for more information >- my $materials = $item->materials; >- my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', authorised_value => $materials }); >- $materials = $descriptions->{lib} // $materials; >- $template_params->{ADDITIONAL_MATERIALS} = $materials; >- $template_params->{itemhomebranch} = $item->homebranch; >- >- # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed. >- foreach my $needsconfirmation_key ( keys %$needsconfirmation ) { >- $template_params->{$needsconfirmation_key} = $needsconfirmation->{$needsconfirmation_key}; >- $template_params->{getTitleMessageIteminfo} = $biblio->title; >- $template_params->{getBarcodeMessageIteminfo} = $item->barcode; >- $template_params->{NEEDSCONFIRMATION} = 1; >- $confirm_required = 1; >- if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { >- my $reduceddue = >- dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )->subtract( days => 1 ); >- $template_params->{reduceddue} = $reduceddue; >+ # If booked (alerts or confirmation) update datedue to end of booking >+ if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) { >+ $datedue = $booked->end_date; > } >- } >- } >- unless ($confirm_required) { >- my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; >- if ( C4::Context->preference('UseRecalls') && !$recall_id ) { >- my $recall = Koha::Recalls->find( >+ my $issue = AddIssue( >+ $patron, $barcode, $datedue, >+ $cancelreserve, >+ undef, undef, > { >- biblio_id => $item->biblionumber, >- item_id => [ undef, $item->itemnumber ], >- status => [ 'requested', 'waiting' ], >- completed => 0, >- patron_id => $patron->borrowernumber, >+ onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), >+ switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, >+ recall_id => $recall_id, > } > ); >- $recall_id = ( $recall and $recall->id ) ? $recall->id : undef; >+ $template_params->{issue} = $issue; >+ $session->clear('auto_renew'); >+ $inprocess = 1; > } >+ } > >- # If booked (alerts or confirmation) update datedue to end of booking >- if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) { >- $datedue = $booked->end_date; >- } >- my $issue = AddIssue( >- $patron, $barcode, $datedue, >- $cancelreserve, >- undef, undef, >- { >- onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), >- switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, >- recall_id => $recall_id, >- } >+ if ($needsconfirmation->{RESERVE_WAITING} or $needsconfirmation->{RESERVED} or $needsconfirmation->{TRANSFERRED} or $needsconfirmation->{PROCESSING}){ >+ $template->param( >+ reserveborrowernumber => $needsconfirmation->{'resborrowernumber'}, >+ reserve_id => $needsconfirmation->{reserve_id}, > ); >- $template_params->{issue} = $issue; >- $session->clear('auto_renew'); >- $inprocess = 1; > } >- } >- >- if ($needsconfirmation->{RESERVE_WAITING} or $needsconfirmation->{RESERVED} or $needsconfirmation->{TRANSFERRED} or $needsconfirmation->{PROCESSING}){ >- $template->param( >- reserveborrowernumber => $needsconfirmation->{'resborrowernumber'}, >- reserve_id => $needsconfirmation->{reserve_id}, >- ); >- } > > >- # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue >- $patron = Koha::Patrons->find( $borrowernumber ); >- $template_params->{issuecount} = $patron->checkouts->count; >+ # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue >+ $patron = Koha::Patrons->find( $borrowernumber ); >+ $template_params->{issuecount} = $patron->checkouts->count; > >- if ( $item ) { >- $template_params->{item} = $item; >- $template_params->{biblio} = $biblio; >- $template_params->{itembiblionumber} = $biblio->biblionumber; >- } >- push @$checkout_infos, $template_params; >+ if ( $item ) { >+ $template_params->{item} = $item; >+ $template_params->{biblio} = $biblio; >+ $template_params->{itembiblionumber} = $biblio->biblionumber; >+ } >+ push @$checkout_infos, $template_params; > } > unless ( $batch ) { > $template->param( %{$checkout_infos->[0]} ); >-- >2.34.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 38246
:
173238
|
173239
|
173248
|
173249
|
173497
|
173498
| 175578