Bugzilla – Attachment 132535 Details for
Bug 30403
Update notforloan status also on check out
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30403: Add syspref UpdateNotForLoanStatusOnCheckout
0001-Bug-30403-Add-syspref-UpdateNotForLoanStatusOnChecko.patch (text/plain), 8.61 KB, created by
Emmi Takkinen
on 2022-03-30 07:36:48 UTC
(
hide
)
Description:
Bug 30403: Add syspref UpdateNotForLoanStatusOnCheckout
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2022-03-30 07:36:48 UTC
Size:
8.61 KB
patch
obsolete
>From 4ee530c68f2d945fb56e073b18fc5b2172e245ba Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Tue, 29 Mar 2022 12:51:01 +0300 >Subject: [PATCH] Bug 30403: Add syspref UpdateNotForLoanStatusOnCheckout > >We currently have syspref UpdateNotForLoanStatusOnCheckin which updates >notforloan status when item is checked in. We should also have >same kind of syspref for check outs. This would be usefull if for >example library has item in exhibition with status >"In exhibition, available for loan". When patron check outs the >item notforloan status can be reseted back to 0, informing staff >that the item is back on circulation. > >This patch adds new syspref Add syspref UpdateNotForLoanStatusOnCheckout. > >To test: >1. Set items notforloan status as e.g -1. >2. Check out item for a patron. >=> Note that items status doesn't change. >3. Apply patch and update database if needed. >4. Add "-1: 0" to syspref UpdateNotForLoanStatusOnCheckout. >5. Check item in and out again for a patron. >=> Note that items status is changed as 0. > >Also prove t/db_dependent/Circulation/issue.t > >Sponsored-by: Koha-Suomi Oy >--- > C4/Circulation.pm | 19 ++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../admin/preferences/circulation.pref | 8 +++++ > t/db_dependent/Circulation/issue.t | 31 ++++++++++++++++++- > 4 files changed, 58 insertions(+), 1 deletion(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index c6baf4892f..d20469d565 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1727,6 +1727,25 @@ sub AddIssue { > } > } > >+ my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckout'); >+ if ($yaml) { >+ $yaml = "$yaml\n\n"; >+ >+ my $rules; >+ eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; >+ if ($@) { >+ warn "Unable to parse UpdateNotForLoanStatusOnCheckout syspref : $@"; >+ } >+ else { >+ foreach my $key ( keys %$rules ) { >+ if ( $item_object->notforloan eq $key ) { >+ $item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); >+ last; >+ } >+ } >+ } >+ } >+ > # Record the fact that this book was issued. > C4::Stats::UpdateStats( > { >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 94e2463434..2675de8992 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -696,6 +696,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('UnsubscribeReflectionDelay','',NULL,'Delay for locking unsubscribers', 'Integer'), > ('UpdateItemLocationOnCheckin', '', 'NULL', 'This is a list of value pairs.\n Examples:\n\nPROC: FIC - causes an item in the Processing Center location to be updated into the Fiction location on check in.\nFIC: GEN - causes an item in the Fiction location to be updated into the General stacks location on check in.\n_BLANK_:FIC - causes an item that has no location to be updated into the Fiction location on check in.\nFIC: _BLANK_ - causes an item in location FIC to be updated to a blank location on check in.\n_ALL_:FIC - causes all items to be updated into the Fiction location on check in.\nPROC: _PERM_ - causes an item that is in the Processing Center to be updated to it''s permanent location.\n\nGeneral rule: if the location value on the left matches the item''s current location, it will be updated to match the location value on the right.\nNote: PROC and CART are special values, for these locations only can location and permanent_location differ, in all other cases an update will affect both. Items in the CART location will be returned to their permanent location on checkout.\n\nThe special term _BLANK_ may be used on either side of a value pair to update or remove the location from items with no location assigned.\nThe special term _ALL_ is used on the left side of the colon (:) to affect all items.\nThe special term _PERM_ is used on the right side of the colon (:) to return items to their permanent location.', 'Free'), > ('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free'), >+('UpdateNotForLoanStatusOnCheckout', '', 'NULL', 'This is a list of value pairs. When an item is checked out, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free'), > ('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'), > ('UploadPurgeTemporaryFilesDays','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer'), > ('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'), >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 3e81898de6..1fb1c92caf 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 >@@ -551,6 +551,14 @@ Circulation: > - "<br />ccode: [NEWFIC,NULL,DVD]" > - "<br />itype: [NEWBK,\"\"]" > - "<br /> <strong>NOTE:</strong> The word 'NULL' can be used to block renewal on undefined fields, while an empty string \"\" will block on an empty (but defined) field." >+ - >+ - pref: UpdateNotForLoanStatusOnCheckout >+ type: textarea >+ syntax: text/x-yaml >+ class: code >+ - This is a list of value pairs. When an item is checked out, if the not for loan value on the left matches the items not for loan value >+ - "it will be updated to the right-hand value. For example, '-1: 0' will cause an item that was set to 'Ordered' to now be available for loan." >+ - Each pair of values should be on a separate line. > Checkin policy: > - > - pref: TrapHoldsOnOrder >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index f953b04dc5..de7205a9b7 100755 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 48; >+use Test::More tests => 51; > use DateTime::Duration; > > use t::lib::Mocks; >@@ -535,5 +535,34 @@ AddRenewal( $unseen_patron->borrowernumber, $unseen_item->itemnumber, $branchcod > my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3]; > is( $unseen_reset, 0, 'seen renewal resets the unseen count' ); > >+my $itemnumber4 = Koha::Item->new( >+ { >+ biblionumber => $biblionumber, >+ barcode => 'barcode_6', >+ itemcallnumber => 'callnumber6', >+ homebranch => $branchcode_1, >+ holdingbranch => $branchcode_1, >+ notforloan => -1, >+ itype => $itemtype, >+ location => 'loc1' >+ }, >+)->store->itemnumber; >+ >+t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); >+AddIssue( $borrower_2, 'barcode_6', dt_from_string ); >+my $item = Koha::Items->find( $itemnumber4 ); >+ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); >+ >+t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', '-1: 0' ); >+AddReturn( 'barcode_6', $branchcode_1 ); >+my $test = AddIssue( $borrower_2, 'barcode_6', dt_from_string ); >+$item = Koha::Items->find( $itemnumber4 ); >+ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout updates notforloan value from -1 to 0 with setting "-1: 0"} ); >+ >+AddIssue( $borrower_2, 'barcode_6', dt_from_string ); >+AddReturn( 'barcode_6', $branchcode_1 ); >+$item = Koha::Items->find( $itemnumber4 ); >+ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} ); >+ > #End transaction > $schema->storage->txn_rollback; >-- >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 30403
:
132534
|
132535
|
132536
|
139675
|
142915
|
143883
|
144681
|
144682
|
144683
|
144684
|
149234