Bugzilla – Attachment 130057 Details for
Bug 24239
Let the ILL module set ad hoc hard due dates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24239: Replace syspref with illrequests column date_due
Bug-24239-Replace-syspref-with-illrequests-column-.patch (text/plain), 9.72 KB, created by
Lari Taskula
on 2022-02-01 23:59:48 UTC
(
hide
)
Description:
Bug 24239: Replace syspref with illrequests column date_due
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2022-02-01 23:59:48 UTC
Size:
9.72 KB
patch
obsolete
>From e91192f3ea9d3bd3cef7b51f338704d432a0b139 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Tue, 1 Feb 2022 23:54:51 +0000 >Subject: [PATCH] Bug 24239: Replace syspref with illrequests column date_due > >This patch replaces system preference introduced in previous patch with >a column "date_due" for table illrequests. > >To test: >1. prove t/db_dependent/Circulation.t > >Sponsored-by: imCode Partner AB >--- > C4/Circulation.pm | 30 +++++++------- > Koha/Schema/Result/Illrequest.pm | 14 +++++++ > .../bug_24239-add_date_due_to_illrequests.pl | 15 +++++++ > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/mandatory/sysprefs.sql | 1 - > .../admin/preferences/circulation.pref | 4 -- > t/db_dependent/Circulation.t | 39 ++++++++++++++++++- > 7 files changed, 81 insertions(+), 23 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_24239-add_date_due_to_illrequests.pl > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 9722ca4234..076a2f14e3 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1474,24 +1474,20 @@ sub AddIssue { > } > > # Check if we need to use an exact due date set by the ILL module >- if ( C4::Context->preference('ILLUseExactDueDate') ) { >+ if ( C4::Context->preference('ILLModule') ) { > # Check if there is an ILL connected with the biblio of the item we are issuing >- my $biblionumber = $item_object->biblionumber; >- my @illrequests = Koha::Illrequests->search({ biblio_id => $biblionumber }); >- if ( @illrequests ) { >- # There could be more than one ILL request connected with a >- # given biblio, so we need to make sure we find the right one >- foreach my $req ( @illrequests ) { >- if ( $borrower->{ 'borrowernumber' } == $req->borrowernumber ) { >- # We found the right request, now get the proper attribute >- my $ill_date_string = $req->illrequestattributes->find({ type => C4::Context->preference('ILLUseExactDueDate') })->value; >- warn $ill_date_string; >- my $ill_dt = dt_from_string( $ill_date_string ); >- $ill_dt->set_hour(23); >- $ill_dt->set_minute(59); >- $datedue = $ill_dt; >- } >- } >+ my $ill_request = Koha::Illrequests->search({ >+ biblio_id => $item_object->biblionumber, >+ borrowernumber => $borrower->{'borrowernumber'}, >+ completed => undef, >+ date_due => { '!=', undef }, >+ })->next; >+ >+ if ( $ill_request and length( $ill_request->date_due ) > 0 ) { >+ my $ill_dt = dt_from_string( $ill_request->date_due ); >+ $ill_dt->set_hour(23); >+ $ill_dt->set_minute(59); >+ $datedue = $ill_dt; > } > } > >diff --git a/Koha/Schema/Result/Illrequest.pm b/Koha/Schema/Result/Illrequest.pm >index 16e7d9e6ed..ecc75eb797 100644 >--- a/Koha/Schema/Result/Illrequest.pm >+++ b/Koha/Schema/Result/Illrequest.pm >@@ -47,6 +47,14 @@ Patron associated with request > > Potential bib linked to request > >+=head2 date_due >+ >+ data_type: 'datetime' >+ datetime_undef_if_invalid: 1 >+ is_nullable: 1 >+ >+Custom date due specified by backend, leave NULL for default date_due calculation >+ > =head2 branchcode > > data_type: 'varchar' >@@ -180,6 +188,12 @@ __PACKAGE__->add_columns( > { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, > "biblio_id", > { data_type => "integer", is_nullable => 1 }, >+ "date_due", >+ { >+ data_type => "datetime", >+ datetime_undef_if_invalid => 1, >+ is_nullable => 1, >+ }, > "branchcode", > { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 50 }, > "status", >diff --git a/installer/data/mysql/atomicupdate/bug_24239-add_date_due_to_illrequests.pl b/installer/data/mysql/atomicupdate/bug_24239-add_date_due_to_illrequests.pl >new file mode 100755 >index 0000000000..a8eb9beda1 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_24239-add_date_due_to_illrequests.pl >@@ -0,0 +1,15 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "24239", >+ description => "Add date_due to illrequests", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ # Do you stuffs here >+ $dbh->do(q{ >+ ALTER TABLE `illrequests` >+ ADD `date_due` datetime DEFAULT NULL AFTER `biblio_id` >+ }); >+ }, >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 0aab2ff94e..2a0a5e268c 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2775,6 +2775,7 @@ CREATE TABLE `illrequests` ( > `illrequest_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ILL request number', > `borrowernumber` int(11) DEFAULT NULL COMMENT 'Patron associated with request', > `biblio_id` int(11) DEFAULT NULL COMMENT 'Potential bib linked to request', >+ `date_due` datetime DEFAULT NULL COMMENT 'Custom date due specified by backend, leave NULL for default date_due calculation', > `branchcode` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The branch associated with the request', > `status` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Current Koha status of request', > `status_alias` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Foreign key to relevant authorised_values.authorised_value', >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 7a95c898e8..dd83a00fd8 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -260,7 +260,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('ILLModuleUnmediated','0','','If enabled, try to immediately progress newly placed ILL requests.','YesNo'), > ('ILLOpacbackends',NULL,NULL,'ILL backends to enabled for OPAC initiated requests','multiple'), > ('ILLSendStaffNotices', NULL, NULL, 'Send these ILL notices to staff', 'multiple'), >-('ILLUseExactDueDate',NULL,NULL,'Use this ILL request attribute to set a specific due date when a document on ILL loan is issued.','multiple'), > ('ILS-DI','0','','Enables ILS-DI services at OPAC.','YesNo'), > ('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'), > ('ImageLimit','5','','Limit images stored in the database by the Patron Card image manager to this number.','Integer'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index 0fcbab7fbf..43ccf3fd33 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -940,10 +940,6 @@ Circulation: > 1: Enable > 0: Disable > - unmediated interlibrary loan requests. If enabled and the ILL backend supports it, the newly created requests are immediately requested by backend. >- - >- - Use the ILL request attribute >- - pref: ILLUseExactDueDate >- - to set an exact due date for an ILL loan, from the ILL module. Leave empty to calculate due dates the standard way. > - > - pref: CirculateILL > default: 0 >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 3b0b09b83f..10b78600a3 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 57; >+use Test::More tests => 58; > use Test::Exception; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); >@@ -1909,6 +1909,43 @@ subtest 'AddIssue & AllowReturnToBranch' => sub { > # TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); > }; > >+subtest 'AddIssue & illrequests.date_due' => sub { >+ plan tests => 2; >+ >+ t::lib::Mocks::mock_preference( 'ILLModule', 1 ); >+ my $library = $builder->build( { source => 'Branch' } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $item = $builder->build_sample_item(); >+ >+ set_userenv($library); >+ >+ my $custom_date_due = '9999-12-18 12:34:56'; >+ my $expected_date_due = '9999-12-18 23:59:00'; >+ my $illrequest = Koha::Illrequest->new({ >+ borrowernumber => $patron->borrowernumber, >+ biblio_id => $item->biblionumber, >+ branchcode => $library->{'branchcode'}, >+ date_due => $custom_date_due, >+ })->store; >+ >+ my $issue = AddIssue( $patron->unblessed, $item->barcode ); >+ is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); >+ >+ $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ $item = $builder->build_sample_item(); >+ $custom_date_due = '9999-12-19'; >+ $expected_date_due = '9999-12-19 23:59:00'; >+ $illrequest = Koha::Illrequest->new({ >+ borrowernumber => $patron->borrowernumber, >+ biblio_id => $item->biblionumber, >+ branchcode => $library->{'branchcode'}, >+ date_due => $custom_date_due, >+ })->store; >+ >+ $issue = AddIssue( $patron->unblessed, $item->barcode ); >+ is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); >+}; >+ > subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > plan tests => 8; > >-- >2.25.1
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 24239
:
96246
|
106409
|
130056
|
130057
|
130414
|
130415
|
130416
|
133475
|
133476
|
133477
|
135244
|
135245
|
135246
|
135943
|
135944
|
135945
|
136458
|
136459
|
136460
|
136461
|
136462
|
136463