Bugzilla – Attachment 62698 Details for
Bug 6758
Capture membership renewal date for reporting purposes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6758 - Add new patron column for date of renewal
Bug-6758---Add-new-patron-column-for-date-of-renew.patch (text/plain), 7.11 KB, created by
Kyle M Hall (khall)
on 2017-04-25 17:58:16 UTC
(
hide
)
Description:
Bug 6758 - Add new patron column for date of renewal
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-04-25 17:58:16 UTC
Size:
7.11 KB
patch
obsolete
>From ff6ca37433bab26a594516531cfd8792584312e5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 25 Apr 2017 13:27:00 -0400 >Subject: [PATCH] Bug 6758 - Add new patron column for date of renewal > >Test Plan: >1) Apply this patch >2) Run updatedatabase >3) Create a new patron >4) Note the new column date_renewed is NULL >5) Renew the patron >6) Note the date in the column date_renewed is today's date >--- > Koha/Patron.pm | 4 +++- > installer/data/mysql/atomicupdate/bug_6758.perl | 24 ++++++++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 3 +++ > t/db_dependent/Koha/Patrons.t | 10 ++++++++-- > 4 files changed, 38 insertions(+), 3 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_6758.perl > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index b79b58a..4fe7929 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -359,7 +359,9 @@ sub renew_account { > } > my $expiry_date = $self->category->get_expiry_date($date); > >- $self->dateexpiry($expiry_date)->store; >+ $self->dateexpiry($expiry_date); >+ $self->date_renewed( dt_from_string() ); >+ $self->store(); > > $self->add_enrolment_fee_if_needed; > >diff --git a/installer/data/mysql/atomicupdate/bug_6758.perl b/installer/data/mysql/atomicupdate/bug_6758.perl >new file mode 100644 >index 0000000..c7bf74b >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_6758.perl >@@ -0,0 +1,24 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ >+ unless ( column_exists( 'borrowers', 'date_renewed' ) ) { >+ $dbh->do(q{ >+ ALTER TABLE borrowers ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry; >+ }); >+ } >+ >+ unless ( column_exists( 'deletedborrowers', 'date_renewed' ) ) { >+ $dbh->do(q{ >+ ALTER TABLE deletedborrowers ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry; >+ }); >+ } >+ >+ unless ( column_exists( 'borrower_modifications', 'date_renewed' ) ) { >+ $dbh->do(q{ >+ ALTER TABLE borrower_modifications ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry; >+ }); >+ } >+ >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 6758 - Capture membership renewal date for reporting purposes)\n"; >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 857de55..6aa6bf4 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -598,6 +598,7 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower > `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category > `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD) > `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD) >+ `date_renewed` date default NULL, -- date the patron/borrower's card was last renewed > `gonenoaddress` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address > `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card > `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD) >@@ -1629,6 +1630,7 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons > `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category > `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD) > `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD) >+ `date_renewed` date default NULL, -- date the patron/borrower's card was last renewed > `gonenoaddress` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address > `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card > `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD) >@@ -3403,6 +3405,7 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` ( > `categorycode` varchar(10) DEFAULT NULL, > `dateenrolled` date DEFAULT NULL, > `dateexpiry` date DEFAULT NULL, >+ `date_renewed` date default NULL, > `gonenoaddress` tinyint(1) DEFAULT NULL, > `lost` tinyint(1) DEFAULT NULL, > `debarred` date DEFAULT NULL, >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 74f0e7f..e12af33 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -242,7 +242,7 @@ subtest 'is_going_to_expire' => sub { > > > subtest 'renew_account' => sub { >- plan tests => 10; >+ plan tests => 12; > my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); > my $a_year_later = dt_from_string->add( months => 12 )->truncate( to => 'day' ); > my $a_year_later_minus_a_month = dt_from_string->add( months => 11 )->truncate( to => 'day' ); >@@ -261,6 +261,7 @@ subtest 'renew_account' => sub { > value => { > dateexpiry => $a_month_ago, > categorycode => $patron_category->{categorycode}, >+ date_renewed => undef, # Force builder to not popular the column for new patron > } > } > ); >@@ -284,6 +285,8 @@ subtest 'renew_account' => sub { > my $retrieved_patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} ); > my $retrieved_patron_3 = Koha::Patrons->find( $patron_3->{borrowernumber} ); > >+ is( $retrieved_patron->date_renewed, undef, "Date renewed is not set for patrons that have never been renewed" ); >+ > t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' ); > t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); > my $expiry_date = $retrieved_patron->renew_account; >@@ -297,7 +300,10 @@ subtest 'renew_account' => sub { > t::lib::Mocks::mock_preference( 'BorrowersLog', 0 ); > $expiry_date = $retrieved_patron->renew_account; > is( $expiry_date, $a_year_later, ); >- $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry; >+ >+ $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ ok( $retrieved_patron->date_renewed, "Date renewed is set when calling renew_account" ); >+ $retrieved_expiry_date = $retrieved_patron->dateexpiry; > is( dt_from_string($retrieved_expiry_date), $a_year_later ); > $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; > is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' ); >-- >2.10.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 6758
:
62696
|
62697
|
62698
|
62699
|
62929
|
65490
|
65491
|
65492
|
67218
|
67219