Bugzilla – Attachment 154697 Details for
Bug 25813
Enhance patron expiration in SIP display
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25813: Enhance patron expiration in SIP display
Bug-25813-Enhance-patron-expiration-in-SIP-display.patch (text/plain), 5.65 KB, created by
Matthias Meusburger
on 2023-08-22 13:59:15 UTC
(
hide
)
Description:
Bug 25813: Enhance patron expiration in SIP display
Filename:
MIME Type:
Creator:
Matthias Meusburger
Created:
2023-08-22 13:59:15 UTC
Size:
5.65 KB
patch
obsolete
>From 29a9f6f804e1d2ecd237e8b116e47f74d7911a2b Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Tue, 10 Sep 2019 16:59:30 +0200 >Subject: [PATCH] Bug 25813: Enhance patron expiration in SIP display > > Currently, the patron information returned by SIP only shows > "PATRON EXPIRED" when the patron card has expired. > > This patch makes the display more consistant with the Opac display > and also complies with the NotifyBorrowerDeparture system preference. > > Test plan: > > - apply the patch > > - set NotifyBorrowerDeparture to 0 > > - check that nothing is ever displayed about the card expiration > > - set NotifyBorrowerDeparture to a value greater than 0 > > - check that the following message will be displayed for a card that will > expire within NotifyBorrowerDeparture days: > "Your card will expire on {correctly formatted date}" > > - check that the following message will be displayed for a card that has > expired: > "Your account has expired as of {correctly formatted date}" > > You can use src/C4/SIP/interactive_patron_dump.pl for easier testing. >--- > C4/SIP/ILS/Patron.pm | 32 +++++++++++++++++++------- > t/db_dependent/SIP/Patron.t | 45 ++++++++++++++++++++++++++++++++++++- > 2 files changed, 68 insertions(+), 9 deletions(-) > >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index 4b3e76f1a8..7f30ffdcca 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -28,10 +28,12 @@ use Koha::Libraries; > use Koha::Patrons; > use Koha::Checkouts; > use Koha::TemplateUtils qw( process_tt ); >+use Date::Calc qw/Today Date_to_Days/; >+use Koha::DateUtils qw(dt_from_string output_pref);; > > our $kp; # koha patron > >-=head1 METHODS >+=head1 Methods > > =cut > >@@ -62,14 +64,28 @@ sub new { > my $pw = $kp->{password}; > my $flags = C4::Members::patronflags( $kp ); > my $debarred = $patron->is_debarred; >- my ($day, $month, $year) = (localtime)[3,4,5]; >- my $today = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day; >- my $expired = ($today gt $kp->{dateexpiry}) ? 1 : 0; >- if ($expired) { >- if ($kp->{opacnote} ) { >- $kp->{opacnote} .= q{ }; >+ siplog("LOG_DEBUG", "Debarred = %s : ", ($debarred||'undef')); # Do we need more debug info here? >+ my $expired = 0; >+ if ( $kp->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') ) { >+ my ( $today_year, $today_month, $today_day) = Today(); >+ my ($warning_year, $warning_month, $warning_day) = split /-/, $kp->{'dateexpiry'}; >+ my $days_to_expiry = Date_to_Days( $warning_year, $warning_month, $warning_day ) - Date_to_Days( $today_year, $today_month, $today_day ); >+ my $dt = dt_from_string( $kp->{'dateexpiry'}, 'iso' ); >+ my $dateexpiry = output_pref({ dt => $dt, dateonly => 1}); >+ if ( $days_to_expiry < 0 ) { >+ #borrower card has expired, warn the borrower >+ if ($kp->{opacnote} ) { >+ $kp->{opacnote} .= q{ }; >+ } >+ $kp->{opacnote} .= "Your account has expired as of $dateexpiry"; >+ $expired = 1; >+ } elsif ( $days_to_expiry < C4::Context->preference('NotifyBorrowerDeparture') ) { >+ # borrower card soon to expire, warn the borrower >+ if ($kp->{opacnote} ) { >+ $kp->{opacnote} .= q{ }; >+ } >+ $kp->{opacnote} .= "Your card will expire on $dateexpiry"; > } >- $kp->{opacnote} .= 'PATRON EXPIRED'; > } > my %ilspatron; > my $adr = _get_address($kp); >diff --git a/t/db_dependent/SIP/Patron.t b/t/db_dependent/SIP/Patron.t >index d7e86eb444..8d27901909 100755 >--- a/t/db_dependent/SIP/Patron.t >+++ b/t/db_dependent/SIP/Patron.t >@@ -4,7 +4,7 @@ > # This needs to be extended! Your help is appreciated.. > > use Modern::Perl; >-use Test::More tests => 10; >+use Test::More tests => 11; > > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -274,6 +274,49 @@ subtest "fine_items tests" => sub { > > $schema->storage->txn_rollback; > >+subtest "Patron expiration tests" => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => >+ { >+ opacnote => "", >+ # dateexpiry is today when unspecified >+ } >+ }); >+ >+ t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); >+ my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); >+ like( $sip_patron->screen_msg, qr/^Greetings from Koha. $/, "No message is displayed when NotifyBorrowerDeparture is disabled"); >+ >+ t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 1); >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); >+ like( $sip_patron->screen_msg, qr/Your card will expire on/, "A message is displayed when the card expires within NotifyBorrowerDeparture days"); >+ >+ $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => >+ { >+ opacnote => "", >+ dateexpiry => "1900-01-01", >+ } >+ }); >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); >+ like( $sip_patron->screen_msg, qr/Your account has expired as of/, "A message is displayed when the card has expired and NotifyBorrowerDeparture is not disabled"); >+ >+ t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); >+ $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); >+ like( $sip_patron->screen_msg, qr/^Greetings from Koha. $/, "No message is displayed when the card has expired and NotifyBorrowerDeparture is disabled"); >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ > subtest "NoIssuesChargeGuarantees tests" => sub { > > plan tests => 6; >-- >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 25813
:
106057
|
154697
|
160730
|
160794
|
161084