Bugzilla – Attachment 107505 Details for
Bug 26059
Create guarantor/guarantee links on patron import
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26059: Create guarantor/guarantee links on patron import
0001-Bug-26059-Create-guarantor-guarantee-links-on-patron.patch (text/plain), 5.16 KB, created by
Amit Gupta
on 2020-07-29 14:46:58 UTC
(
hide
)
Description:
Bug 26059: Create guarantor/guarantee links on patron import
Filename:
MIME Type:
Creator:
Amit Gupta
Created:
2020-07-29 14:46:58 UTC
Size:
5.16 KB
patch
obsolete
>From 0592388fcd24bdaa83984cb04145f1cb31bf0257 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 24 Jul 2020 12:18:44 -0400 >Subject: [PATCH] Bug 26059: Create guarantor/guarantee links on patron import > >The change to allow multiple guarantors was meant to maintain the >ability to import patrons with a Koha patron guarantor, but is not >working as intended. > >A) Adding the guarantor simply doesn't work >B) We have two columns named 'relationship', one for the borrowers >table, and one for the guarantor relationships table. This clearly >doesn't work and will cause confusion. The one for the guarantor >relationships table should be renamed. >C) guarantor_firstname and guarantor_surname in the CSV file do nothing >and should be removed. > >This patch also fixes a minor issue that causes warnings like: >CGI::param called in list context from >/kohadevbox/koha/tools/import_borrowers.pl line 124 > >Test Plan: >1) Create a CSV with contents like: >cardnumber,surname,firstname,branchcode,categorycode,guarantor_relationship,guarantor_id >bloop,gloop,froop,MPL,J,father,48 >brim,flim,zim,MPL,J,father,48 >2) Attempt to upload this file, ensure you have a borrowernumber 48 that >can have guarantors >3) Note the accounts are not linked >4) Apply this patch >5) Restart all the things! >6) Upload the file again >7) The patrons should now be linked! >8) Download the starter CSV file >9) Note the second relationship column is now guarantor_relationship >10) Note the columns guarantor_firstname and guarantor_surname are no longer present > >Signed-off-by: Amit Gupta <amit.gupta@informaticsglobal.com> >--- > Koha/Patrons/Import.pm | 27 +++++++++++++++++++++------ > tools/import_borrowers.pl | 6 +++--- > 2 files changed, 24 insertions(+), 9 deletions(-) > >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index 7839c4f..d2de255 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -223,9 +223,9 @@ sub import_patrons { > next LINE; > } > >- my $relationship = $borrower{relationship}; >- my $guarantor_id = $borrower{guarantor_id}; >- delete $borrower{relationship}; >+ my $guarantor_relationship = $borrower{guarantor_relationship}; >+ delete $borrower{guarantor_relationship}; >+ my $guarantor_id = $borrower{guarantor_id}; > delete $borrower{guarantor_id}; > > # Remove warning for int datatype that cannot be null >@@ -354,6 +354,7 @@ sub import_patrons { > Koha::Patron->new(\%borrower)->store; > }; > unless ( $@ ) { >+ $borrowernumber = $patron->id; > > if ( $patron->is_debarred ) { > AddDebarment( >@@ -406,13 +407,26 @@ sub import_patrons { > > # Add a guarantor if we are given a relationship > if ( $guarantor_id ) { >- Koha::Patron::Relationship->new( >+ my $relationship = Koha::Patron::Relationships->find( > { > guarantee_id => $borrowernumber, >- relationship => $relationship, > guarantor_id => $guarantor_id, > } >- )->store(); >+ ); >+ >+ if ( $relationship ) { >+ $relationship->relationship( $guarantor_relationship ); >+ $relationship->store(); >+ } >+ else { >+ Koha::Patron::Relationship->new( >+ { >+ guarantee_id => $borrowernumber, >+ relationship => $guarantor_relationship, >+ guarantor_id => $guarantor_id, >+ } >+ )->store(); >+ } > } > } > >@@ -488,6 +502,7 @@ sub set_column_keys { > > my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } Koha::Patrons->columns(); > push( @columnkeys, 'patron_attributes' ) if $extended; >+ push( @columnkeys, qw( guarantor_relationship guarantor_id ) ); > > return @columnkeys; > } >diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl >index 1b5e44f..5d6d975 100755 >--- a/tools/import_borrowers.pl >+++ b/tools/import_borrowers.pl >@@ -62,7 +62,7 @@ my $extended = C4::Context->preference('ExtendedPatronAttributes'); > > my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } Koha::Patrons->columns(); > push( @columnkeys, 'patron_attributes' ) if $extended; >-push( @columnkeys, qw( relationship guarantor_id guarantor_firstname guarantor_surname ) ); >+push( @columnkeys, qw( guarantor_relationship guarantor_id ) ); > > my $input = CGI->new(); > >@@ -124,9 +124,9 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > file => $handle, > defaults => \%defaults, > matchpoint => $matchpoint, >- overwrite_cardnumber => $input->param('overwrite_cardnumber'), >+ overwrite_cardnumber => scalar $input->param('overwrite_cardnumber'), > overwrite_passwords => $overwrite_passwords, >- preserve_extended_attributes => $input->param('ext_preserve') || 0, >+ preserve_extended_attributes => scalar $input->param('ext_preserve') || 0, > } > ); > >-- >2.7.4 >
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 26059
:
107360
|
107364
|
107505
|
107703
|
108319
|
108634
|
108635