Bugzilla – Attachment 153027 Details for
Bug 16223
Automatically remove any borrower debarments after a payment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16223: (QA follow-up) Remove GetDebarments
0004-Bug-16223-QA-follow-up-Remove-GetDebarments.patch (text/plain), 4.70 KB, created by
Emmi Takkinen
on 2023-07-05 06:38:11 UTC
(
hide
)
Description:
Bug 16223: (QA follow-up) Remove GetDebarments
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2023-07-05 06:38:11 UTC
Size:
4.70 KB
patch
obsolete
>From 9d4b9f8b861a482de9ea09314123401bcd359b59 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 11 Nov 2022 09:49:50 +0000 >Subject: [PATCH 4/6] Bug 16223: (QA follow-up) Remove GetDebarments > >We remove the GetDebarments routine in 31095. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Patron/Debarments.pm | 24 ++++++++++---------- > t/db_dependent/Patron/Borrower_Debarments.t | 25 ++++++++++----------- > 2 files changed, 24 insertions(+), 25 deletions(-) > >diff --git a/Koha/Patron/Debarments.pm b/Koha/Patron/Debarments.pm >index ca6e27c2ee..f8c5ca0cf7 100644 >--- a/Koha/Patron/Debarments.pm >+++ b/Koha/Patron/Debarments.pm >@@ -287,23 +287,23 @@ sub del_restrictions_after_payment { > my ($params) = @_; > > my $borrowernumber = $params->{'borrowernumber'}; >- return unless ( $borrowernumber ); >+ return unless ($borrowernumber); > >- my $patron_restrictions = GetDebarments( { borrowernumber => $borrowernumber } ); >- return unless ( $patron_restrictions ); >+ my $patron = Koha::Patrons->find($borrowernumber); >+ return unless ($patron); > >- my $patron = Koha::Patrons->find( $borrowernumber ); >- return unless ( $patron ); >+ my $restrictions = $patron->restrictions; >+ return unless ( $restrictions->count ); > >- my $lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber }); >+ my $lines = >+ Koha::Account::Lines->search( { borrowernumber => $borrowernumber } ); > my $total_due = $lines->total_outstanding; > >- foreach my $patron_restriction (@{ $patron_restrictions }){ >- my $restriction = Koha::Patron::Restriction::Types->find({ >- code => $patron_restriction->{type} >- }); >- if($restriction->lift_after_payment && $total_due <= $restriction->fee_limit){ >- DelDebarment($patron_restriction->{'borrower_debarment_id'}); >+ while ( my $restriction = $restrictions->next ) { >+ if ( $restriction->type->lift_after_payment >+ && $total_due <= $restriction->type->fee_limit ) >+ { >+ DelDebarment( $restriction->borrower_debarment_id ); > } > } > } >diff --git a/t/db_dependent/Patron/Borrower_Debarments.t b/t/db_dependent/Patron/Borrower_Debarments.t >index 86fe952f2b..e97ef48a5e 100755 >--- a/t/db_dependent/Patron/Borrower_Debarments.t >+++ b/t/db_dependent/Patron/Borrower_Debarments.t >@@ -252,21 +252,21 @@ $builder->build( > } > ); > >-my $borrowernumber4 = Koha::Patron->new( >+my $patron4 = Koha::Patron->new( > { > firstname => 'First', > surname => 'Sur', > categorycode => $patron_category->{categorycode}, > branchcode => $library->{branchcode}, > } >-)->store->borrowernumber; >+)->store; > >-my $account = Koha::Account->new({ patron_id => $borrowernumber4 }); >+my $account = $patron4->account; > my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); > > Koha::Patron::Debarments::AddDebarment( > { >- borrowernumber => $borrowernumber4, >+ borrowernumber => $patron4->borrowernumber, > expiration => '9999-06-10', > type => 'TEST', > comment => 'Test delete' >@@ -275,23 +275,22 @@ Koha::Patron::Debarments::AddDebarment( > > Koha::Patron::Debarments::AddDebarment( > { >- borrowernumber => $borrowernumber4, >+ borrowernumber => $patron4->borrowernumber, > expiration => '9999-10-10', > type => 'TEST2', > comment => 'Test delete again', > } > ); > >-$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); >+$restrictions = $patron4->restrictions; > >-is( @$debarments, 2, "GetDebarments returns 2 debarments before payment" ); >+is( $restrictions->count, 2, "->restrictions returns 2 restrictions before payment" ); > > $account->pay({amount => 5}); >- >-$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); >-is( @$debarments, 1, "GetDebarments returns 1 debarment after paying half of the fee" ); >-is( @$debarments[0]->{type}, "TEST2", "Debarment left has type value 'TEST2'" ); >+$restrictions = $patron4->restrictions; >+is( $restrictions->count, 1, "->restrictions returns 1 restriction after paying half of the fee" ); >+is( $restrictions->next->type->code, "TEST2", "Restriction left has type value 'TEST2'" ); > > $account->pay({amount => 5}); >-$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); >-is( @$debarments, 0, "GetDebarments returns 0 debarments after paying all fees" ); >+$restrictions = $patron4->restrictions; >+is( $restrictions->count, 0, "->restrictions returns 0 restrictions after paying all fees" ); >-- >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 16223
:
50078
|
50084
|
99697
|
99698
|
104399
|
104400
|
114272
|
114273
|
118526
|
118572
|
118574
|
118575
|
122768
|
122769
|
127252
|
128005
|
132284
|
132285
|
132286
|
132287
|
143388
|
143389
|
143390
|
143462
|
143670
|
143671
|
143672
|
143688
|
143689
|
143690
|
143765
|
143766
|
143767
|
143768
|
143769
|
143770
|
143936
|
146051
|
146052
|
146053
|
146054
|
146055
|
146056
|
146057
|
148307
|
148308
|
148309
|
148310
|
148311
|
148312
|
148313
|
150024
|
150025
|
150026
|
150027
|
150028
|
150029
|
153024
|
153025
|
153026
|
153027
|
153028
|
153029
|
155644
|
155645
|
155646
|
155647
|
155648
|
155649
|
155650
|
156841
|
156842
|
156843
|
156844
|
156845
|
156846
|
156847
|
156848
|
156849
|
156850