Bugzilla – Attachment 181827 Details for
Bug 39233
Non-patron guarantor info not dropped when patron category is updated
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39233: Drop non-patron guarantor info when guarantee is updated as an adult via update_patrons_category.pl
Bug-39233-Drop-non-patron-guarantor-info-when-guar.patch (text/plain), 3.22 KB, created by
David Nind
on 2025-05-01 13:09:01 UTC
(
hide
)
Description:
Bug 39233: Drop non-patron guarantor info when guarantee is updated as an adult via update_patrons_category.pl
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-05-01 13:09:01 UTC
Size:
3.22 KB
patch
obsolete
>From dd515852b6703b8da8bea863d04597a466d0731b Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Wed, 23 Apr 2025 12:48:40 +0300 >Subject: [PATCH] Bug 39233: Drop non-patron guarantor info when guarantee is > updated as an adult via update_patrons_category.pl > >When child patrons category is updated via update_patrons_category.pl >patrons relationship with their guarantor is dropped from >borrower_relationships table. But non-patron guarantees info >is still kept in borrowers table. This patch fixes this by >setting non-patron guarantor columns in borrower table as >undefined when patron is stored. > >To test: >1. Find child patron with non-patron guarantor or create one. >2. Update patrons age so that their category is updated when you run following: >perl misc/cronjobs/update_patrons_category.pl --confirm --too_old --from K --to PT >3. Check patrons info from patrons detail page. >=> Note that non-patron guarantors info was not dropped. >4. Apply this patch. >5. Run cronjob again. >=> Non-patron guarantors info should have now dropped. > >Alsp prove t/db_dependent/Patrons.t. > >Sponsored-by: Koha-Suomi Oy >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Patron.pm | 10 +++++++--- > t/db_dependent/Patrons.t | 6 +++++- > 2 files changed, 12 insertions(+), 4 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 56df7f9b8d..661ea9e952 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -377,9 +377,13 @@ sub store { > $self->add_enrolment_fee_if_needed(1) > if C4::Context->preference('FeeOnChangePatronCategory'); > >- # Clean up guarantors on category change if required >- $self->guarantor_relationships->delete >- unless ( $self->category->can_be_guarantee ); >+ # Clean up both patron and non-patron guarantors on category change if required >+ unless ( $self->category->can_be_guarantee ) { >+ $self->guarantor_relationships->delete; >+ $self->contactname(undef); >+ $self->contactfirstname(undef); >+ $self->relationship(undef); >+ } > > } > >diff --git a/t/db_dependent/Patrons.t b/t/db_dependent/Patrons.t >index e8ee2fd4f7..32b2b1d7b2 100755 >--- a/t/db_dependent/Patrons.t >+++ b/t/db_dependent/Patrons.t >@@ -116,7 +116,7 @@ foreach my $b ( $patrons->as_list() ) { > } > > subtest "Update patron categories" => sub { >- plan tests => 29; >+ plan tests => 30; > t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' ); > my $c_categorycode = $builder->build( > { >@@ -318,6 +318,10 @@ subtest "Update patron categories" => sub { > Koha::Patrons->find( $adult1->borrowernumber )->guarantee_relationships->guarantees->count, 1, > 'Guarantee was removed when made adult' > ); >+ is( >+ Koha::Patrons->find( $child3->borrowernumber )->relationship, undef, >+ 'Non-patron guarantor relationship dropped when child patron updated to adult' >+ ); > is( > Koha::Patrons->search_patrons_to_update_category( { from => $c_categorycode_2 } ) > ->update_category_to( { category => $a_categorycode_2 } ), 1, >-- >2.39.5
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 39233
:
181364
| 181827