Bugzilla – Attachment 155171 Details for
Bug 28688
Automatically renew patron membership
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28688: Add renew option to membership_expiry.pl
Bug-28688-Add-renew-option-to-membershipexpirypl.patch (text/plain), 5.52 KB, created by
Marcel de Rooy
on 2023-09-02 12:37:08 UTC
(
hide
)
Description:
Bug 28688: Add renew option to membership_expiry.pl
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-09-02 12:37:08 UTC
Size:
5.52 KB
patch
obsolete
>From 3dc59ec7e46cbe8f0f2121b9c2bfdb5bc91fd693 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 14 Jun 2023 13:34:11 +0000 >Subject: [PATCH] Bug 28688: Add renew option to membership_expiry.pl >Content-Type: text/plain; charset=utf-8 > >Test plan: >[1] Pick an account to expire soon. >[2] Choose MembershipExpiryDaysNotice so that it will be selected. > (Note: You can extend the selection with -before or -after.) >[3] Run misc/cronjobs/membership_expiry.pl -c -v -renew >[4] Check new expiry date in the notice. Does it correspond with > enrollment period of category and pref BorrowerRenewalPeriodBase? >[5] If the patron category has an enrollment fee, check account too. >[6] Reset dateexpiry of this patron to original date. >[7] Run misc/cronjobs/membership_expiry.pl -c -v >[8] Check if you got an expiry notice instead and dateexpiry did not > change. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > misc/cronjobs/membership_expiry.pl | 36 +++++++++++++++++++++++++----- > 1 file changed, 30 insertions(+), 6 deletions(-) > >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index c80eccf07b..e0e453b780 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -41,8 +41,9 @@ Options: > --before=X include patrons expiring a number of days BEFORE the date set by the preference > --after=X include patrons expiring a number of days AFTER the date set by the preference > -l --letter <lettercode> use a specific notice rather than the default >- --active=X only send notices to active patrons (active within X months) >- --inactive=X only send notices to inactive patrons (inactive within X months) >+ --active=X only deal with active patrons (active within X months) >+ --inactive=X only deal with inactive patrons (inactive within X months) >+ --renew renew patrons and send notice (instead of expiry notice only) > > =head1 DESCRIPTION > >@@ -109,7 +110,12 @@ Optional parameter to include active patrons only (active within passed number o > =item B<-inactive> > > Optional parameter to include inactive patrons only (inactive within passed number of months). >-This allows you to skip active patrons when you renew them automatically (see bug 28688). >+This allows you to e.g. send expiry warnings only to inactive patrons. >+ >+=item B<-renew> >+ >+Optional parameter to automatically renew patrons instead of sending them an expiry notice. >+They will be informed by a patron renewal notice. > > =back > >@@ -171,6 +177,7 @@ my ( $branch, $letter_type ); > my @where; > my $active; > my $inactive; >+my $renew; > > my $command_line_options = join(" ",@ARGV); > >@@ -187,6 +194,7 @@ GetOptions( > 'where=s' => \@where, > 'active:i' => \$active, > 'inactive:i' => \$inactive, >+ 'renew' => \$renew, > ) or pod2usage(2); > > pod2usage( -verbose => 2 ) if $man; >@@ -223,7 +231,8 @@ warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members' > > # main loop > $letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; >-my ( $count_skipped, $count_enqueued ) = ( 0, 0 ); >+my ( $count_skipped, $count_renewed, $count_enqueued ) = ( 0, 0, 0 ); >+my $fees = {}; > while ( my $recent = $upcoming_mem_expires->next ) { > if ( $active && !$recent->is_active( { months => $active } ) ) { > $count_skipped++; >@@ -232,16 +241,29 @@ while ( my $recent = $upcoming_mem_expires->next ) { > $count_skipped++; > next; > } >+ >+ my ($which_notice, $substitute); >+ if( $renew ) { >+ $recent->renew_account; >+ $which_notice = 'MEMBERSHIP_RENEWED'; >+ $fees->{$recent->branchcode} = $recent->category->enrolmentfee if !exists $fees->{$recent->branchcode}; >+ $substitute->{enrollment_fee} = $fees->{$recent->branchcode} if $fees->{$recent->branchcode} > 0; >+ $count_renewed++; >+ } else { >+ $which_notice = $letter_type; >+ } >+ > my $from_address = $recent->library->from_email_address; > my $letter = C4::Letters::GetPreparedLetter( > module => 'members', >- letter_code => $letter_type, >+ letter_code => $which_notice, > branchcode => $recent->branchcode, > lang => $recent->lang, > tables => { > borrowers => $recent->borrowernumber, > branches => $recent->branchcode, > }, >+ substitute => $substitute, > ); > last if !$letter; # Letters.pm already warned, just exit > if( $nomail ) { >@@ -260,13 +282,14 @@ while ( my $recent = $upcoming_mem_expires->next ) { > if ($recent->smsalertnumber) { > my $smsletter = C4::Letters::GetPreparedLetter( > module => 'members', >- letter_code => $letter_type, >+ letter_code => $which_notice, > branchcode => $recent->branchcode, > lang => $recent->lang, > tables => { > borrowers => $recent->borrowernumber, > branches => $recent->branchcode, > }, >+ substitute => $substitute, > message_transport_type => 'sms', > ); > if ($smsletter) { >@@ -280,6 +303,7 @@ while ( my $recent = $upcoming_mem_expires->next ) { > } > > if ($verbose) { >+ print "Membership renewed for $count_renewed patrons\n" if $count_renewed; > print "Enqueued notices for $count_enqueued patrons\n"; > print "Skipped $count_skipped inactive patrons\n" if $active; > print "Skipped $count_skipped active patrons\n" if $inactive; >-- >2.30.2
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 28688
:
152378
|
152379
|
152380
|
152381
|
155170
|
155171
|
155172
|
155173
|
155222
|
155223
|
155224
|
155225
|
156522
|
156523
|
156524
|
156525
|
156533
|
156534
|
156535
|
156536
|
156537
|
156540