Bugzilla – Attachment 155235 Details for
Bug 34621
Patron import option to 'Renew existing patrons' 'from the current membership expiry date' not implemented
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Bug-34621-implement-Patron-import-option-to-Renew-.patch (text/plain), 10.33 KB, created by
Victor Grousset/tuxayo
on 2023-09-05 19:56:10 UTC
(
hide
)
Description:
Bug 34621: implement Patron import option to 'Renew existing patrons' 'from the current membership expiry date'
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2023-09-05 19:56:10 UTC
Size:
10.33 KB
patch
obsolete
>From 91cc4829d885d6284fd41122fae8c2bf3286bd8a Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 25 Aug 2023 17:37:46 +0000 >Subject: [PATCH] Bug 34621: implement Patron import option to 'Renew existing > patrons' 'from the current membership expiry date' > >Test Plan: >1) Test importing a patron with the "from the current membership expiry date" option, > note it does not work >2) Apply this patch >3) Restart all the things! >4) Re-test, note the expiration was renewed from the patron's current > expiration date! > >Signed-off-by: David Nind <david@davidnind.com> >Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > Koha/Patrons/Import.pm | 31 +++++++++++++++---------- > misc/import_patrons.pl | 34 ++++++++++++++++++---------- > t/db_dependent/Koha/Patrons/Import.t | 15 +++++++++++- > tools/import_borrowers.pl | 21 +++++++++-------- > 4 files changed, 66 insertions(+), 35 deletions(-) > >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index 73d5355149..65096efb22 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -69,18 +69,20 @@ sub import_patrons { > my $handle = $params->{file}; > unless( $handle ) { carp('No file handle passed in!'); return; } > >- my $matchpoint = $params->{matchpoint}; >- my $defaults = $params->{defaults}; >- my $preserve_fields = $params->{preserve_fields}; >- my $ext_preserve = $params->{preserve_extended_attributes}; >- my $overwrite_cardnumber = $params->{overwrite_cardnumber}; >- my $overwrite_passwords = $params->{overwrite_passwords}; >- my $dry_run = $params->{dry_run}; >- my $send_welcome = $params->{send_welcome}; >- my $extended = C4::Context->preference('ExtendedPatronAttributes'); >- my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences'); >- my $update_dateexpiry = $params->{update_dateexpiry}; >- my $update_dateexpiry_from_today = $params->{update_dateexpiry_from_today}; >+ my $matchpoint = $params->{matchpoint}; >+ my $defaults = $params->{defaults}; >+ my $preserve_fields = $params->{preserve_fields}; >+ my $ext_preserve = $params->{preserve_extended_attributes}; >+ my $overwrite_cardnumber = $params->{overwrite_cardnumber}; >+ my $overwrite_passwords = $params->{overwrite_passwords}; >+ my $dry_run = $params->{dry_run}; >+ my $send_welcome = $params->{send_welcome}; >+ my $update_dateexpiry = $params->{update_dateexpiry}; >+ my $update_dateexpiry_from_today = $params->{update_dateexpiry_from_today}; >+ my $update_dateexpiry_from_existing = $params->{update_dateexpiry_from_existing}; >+ >+ my $extended = C4::Context->preference('ExtendedPatronAttributes'); >+ my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences'); > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin if $dry_run; >@@ -203,6 +205,11 @@ sub import_patrons { > } > } > >+ if ( $patron && $update_dateexpiry_from_existing ) { >+ $patron->dateexpiry( Koha::Patron::Categories->find( $borrower{categorycode} )->get_expiry_date( $patron->dateexpiry ) ); >+ delete $borrower{dateexpiry}; >+ } >+ > my $is_new = 0; > if ($patron) { > $member = $patron->unblessed; >diff --git a/misc/import_patrons.pl b/misc/import_patrons.pl >index 6af1fcc71d..9b22aaf0d0 100755 >--- a/misc/import_patrons.pl >+++ b/misc/import_patrons.pl >@@ -39,6 +39,7 @@ my $help; > my @preserve_fields; > my $update_dateexpiry; > my $update_dateexpiry_from_today; >+my $update_dateexpiry_from_existing; > > GetOptions( > 'c|confirm' => \$confirm, >@@ -49,6 +50,7 @@ GetOptions( > 'op|overwrite_passwords' => \$overwrite_passwords, > 'ue|update-expiration' => \$update_dateexpiry, > 'et|expiration-from-today' => \$update_dateexpiry_from_today, >+ 'ee|expiration-from-existing' => \$update_dateexpiry_from_existing, > 'en|email-new' => \$welcome_new, > 'p|preserve-extended-attributes' => \$ext_preserve, > 'pf|preserve-field=s' => \@preserve_fields, >@@ -57,6 +59,7 @@ GetOptions( > ) or pod2usage(2); > > pod2usage(1) if $help; >+pod2usage(q|--ee and --et are mutually exclusive|) if $update_dateexpiry_from_today && $update_dateexpiry_from_existing; > pod2usage(q|--file is required|) unless $csv_file; > pod2usage(q|--matchpoint is required|) unless $matchpoint; > >@@ -67,17 +70,18 @@ open( $handle, "<", $csv_file ) or die $!; > > my $return = $Import->import_patrons( > { >- file => $handle, >- defaults => \%defaults, >- matchpoint => $matchpoint, >- overwrite_cardnumber => $overwrite_cardnumber, >- overwrite_passwords => $overwrite_passwords, >- preserve_extended_attributes => $ext_preserve, >- preserve_fields => \@preserve_fields, >- update_dateexpiry => $update_dateexpiry, >- update_dateexpiry_from_today => $update_dateexpiry_from_today, >- send_welcome => $welcome_new, >- dry_run => !$confirm, >+ file => $handle, >+ defaults => \%defaults, >+ matchpoint => $matchpoint, >+ overwrite_cardnumber => $overwrite_cardnumber, >+ overwrite_passwords => $overwrite_passwords, >+ preserve_extended_attributes => $ext_preserve, >+ preserve_fields => \@preserve_fields, >+ update_dateexpiry => $update_dateexpiry, >+ update_dateexpiry_from_today => $update_dateexpiry_from_today, >+ update_dateexpiry_from_existing => $update_dateexpiry_from_existing, >+ send_welcome => $welcome_new, >+ dry_run => !$confirm, > } > ); > >@@ -164,7 +168,13 @@ If a matching patron is found, extend the expiration date of their account using > > =item B<-et|--expiration-from-today> > >-If a matching patron is found, extend the expiration date of their account using the patron's enrollment date as the base >+If a matching patron is found, extend the expiration date of their account using today as the base >+Cannot by used in conjunction with --expiration-from-existing >+ >+=item B<-et|--expiration-from-existing> >+ >+If a matching patron is found, extend the expiration date of their account using the patron's current expiration date as the base >+Cannot by used in conjunction with --expiration-from-today > > =item B<-v|--verbose> > >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index 6bb4fde8b3..e549265d30 100755 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 177; >+use Test::More tests => 179; > use Test::Warn; > use Test::Exception; > use Encode qw( encode_utf8 ); >@@ -220,6 +220,19 @@ is( $patron_3c->dateexpiry, dt_from_string->add( months => 99, end_of_month => ' > is( $patron_3c->surname, "Nancy2", "Surname field is preserved from original" ); > is( $patron_3c->firstname, "Jenkins", "Firstname field is overwritten" ); > >+# test update_dateexpiry_from_current >+my $filename_3d = make_csv($temp_dir, $csv_headers, $csv_one_line_b); >+open(my $handle_3d, "<", $filename_3d) or die "cannot open < $filename_3: $!"; >+$patron_3c->dateexpiry('1980-01-01')->store(); >+my $params_3d = { file => $handle_3d, matchpoint => 'cardnumber', overwrite_cardnumber => 1, preserve_fields => [ 'firstname' ], update_dateexpiry => 1, update_dateexpiry_from_existing => 1 }; >+warning_is { $patrons_import->import_patrons($params_3d) } >+ undef, >+ "No warning raised by import_patrons"; >+$patron_3c = Koha::Patrons->find({ cardnumber => '1000' }); >+is( $patron_3c->dateexpiry, '1988-04-01', "Expiration date is correct with update_dateexpiry_from_existing => 1" ); >+my $result_3d; >+# /test update_dateexpiry_from_current >+ > # Given ... valid file handle, good matchpoint that does not match and conflicting userid. > my $filename_3b = make_csv($temp_dir, $csv_headers, $csv_one_line_a); > open(my $handle_3b, "<", $filename_3b) or die "cannot open < $filename_3: $!"; >diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl >index a02f14dc40..fa9812918c 100755 >--- a/tools/import_borrowers.pl >+++ b/tools/import_borrowers.pl >@@ -117,16 +117,17 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > my $update_dateexpiry = $input->param('update_dateexpiry'); > my $return = $Import->import_patrons( > { >- file => $handle, >- defaults => \%defaults, >- matchpoint => $matchpoint, >- overwrite_cardnumber => scalar $input->param( 'overwrite_cardnumber' ), >- overwrite_passwords => $overwrite_passwords, >- preserve_extended_attributes => scalar $input->param( 'ext_preserve' ) || 0, >- preserve_fields => \@preserve_fields, >- update_dateexpiry => $update_dateexpiry ? 1 : 0, >- update_dateexpiry_from_today => $update_dateexpiry eq "now" ? 1 : 0, >- send_welcome => $welcome_new, >+ file => $handle, >+ defaults => \%defaults, >+ matchpoint => $matchpoint, >+ overwrite_cardnumber => scalar $input->param('overwrite_cardnumber'), >+ overwrite_passwords => $overwrite_passwords, >+ preserve_extended_attributes => scalar $input->param('ext_preserve') || 0, >+ preserve_fields => \@preserve_fields, >+ update_dateexpiry => $update_dateexpiry ? 1 : 0, >+ update_dateexpiry_from_today => $update_dateexpiry eq "now" ? 1 : 0, >+ update_dateexpiry_from_existing => $update_dateexpiry eq "dateexpiry" ? 1 : 0, >+ send_welcome => $welcome_new, > } > ); > >-- >2.42.0
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 34621
:
154841
|
154842
|
154853
|
155235
|
161027
|
163304
|
163305
|
163306
|
164808
|
164809
|
164810