Bugzilla – Attachment 114592 Details for
Bug 27259
HomeOrHoldingBranch is not used in all places
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27259: Test HomeOrHoldingBranch usage in _CalculateAndUpdateFine()
Bug-27259-Test-HomeOrHoldingBranch-usage-in-Calcul.patch (text/plain), 5.11 KB, created by
Joonas Kylmälä
on 2020-12-22 10:51:07 UTC
(
hide
)
Description:
Bug 27259: Test HomeOrHoldingBranch usage in _CalculateAndUpdateFine()
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2020-12-22 10:51:07 UTC
Size:
5.11 KB
patch
obsolete
>From 790105745beb1b58c3d4ce9d15e71db3cb8c5ec6 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <joonas.kylmala@helsinki.fi> >Date: Fri, 18 Dec 2020 17:47:40 +0200 >Subject: [PATCH] Bug 27259: Test HomeOrHoldingBranch usage in > _CalculateAndUpdateFine() > >This shows that HomeOrHoldingBranch syspref is incorrectly not used by >_CalculateAndUpdateFine() when it decides which circ rule to use. > >Run "prove t/db_dependent/Circulation/_CalculateAndUpdateFine.t" to >notice the tests now fail. >--- > .../Circulation/_CalculateAndUpdateFine.t | 137 +++++++++++++++++++++ > 1 file changed, 137 insertions(+) > create mode 100755 t/db_dependent/Circulation/_CalculateAndUpdateFine.t > >diff --git a/t/db_dependent/Circulation/_CalculateAndUpdateFine.t b/t/db_dependent/Circulation/_CalculateAndUpdateFine.t >new file mode 100755 >index 0000000000..7e9b98bc14 >--- /dev/null >+++ b/t/db_dependent/Circulation/_CalculateAndUpdateFine.t >@@ -0,0 +1,137 @@ >+#!/usr/bin/perl >+ >+# Copyright University of Helsinki 2020 >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+ >+use Koha::Database; >+use Koha::DateUtils qw( dt_from_string ); >+use Koha::CirculationRules; >+ >+use C4::Circulation; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+ >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new(); >+ >+my $branch = $builder->build({ >+ source => 'Branch', >+}); >+ >+my $branch2 = $builder->build({ >+ source => 'Branch', >+}); >+ >+my $category = $builder->build({ >+ source => 'Category', >+}); >+ >+my $patron = $builder->build({ >+ source => 'Borrower', >+ value => { >+ categorycode => $category->{categorycode}, >+ branchcode => $branch->{branchcode}, >+ }, >+}); >+ >+my $biblio = $builder->build_sample_biblio({ branchcode => $branch->{branchcode} }); >+ >+my $item = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ homebranch => $branch->{branchcode}, >+ holdingbranch => $branch2->{branchcode}, >+}); >+ >+Koha::CirculationRules->search()->delete(); >+ >+subtest 'HomeOrHoldingBranch is used' => sub { >+ plan tests => 2; >+ >+ # Homebranch rule with fine >+ Koha::CirculationRules->set_rules( >+ { >+ itemtype => undef, >+ categorycode => undef, >+ branchcode => $branch->{branchcode}, >+ rules => { >+ fine => '1.00', >+ lengthunit => 'days', >+ finedays => 0, >+ chargeperiod => 1, >+ } >+ } >+ ); >+ >+ # Holdingbranch rule without fine >+ Koha::CirculationRules->set_rules( >+ { >+ itemtype => undef, >+ categorycode => undef, >+ branchcode => $branch2->{branchcode}, >+ rules => { >+ fine => '0.00', >+ lengthunit => 'days', >+ finedays => 0, >+ chargeperiod => 1, >+ } >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference('finesMode', 'production'); >+ t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary'); >+ t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch'); >+ t::lib::Mocks::mock_userenv({ branchcode => $branch->{branchcode} }); >+ >+ my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() ); >+ >+ # Returning loan 1 day after due date >+ my $return_date = dt_from_string()->add( days => 1 )->set( hour => 23, minute => 59, second => 0 ); >+ C4::Circulation::_CalculateAndUpdateFine( >+ { >+ borrower => $patron, >+ issue => $issue, >+ item => $item->unblessed, >+ return_date => $return_date, >+ } >+ ); >+ >+ my $fines = Koha::Account::Lines->search({ borrowernumber => $patron->{borrowernumber} }); >+ is($fines->total_outstanding, 0, "Fine is not accrued for holdingbranch"); >+ >+ t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch'); >+ C4::Circulation::_CalculateAndUpdateFine( >+ { >+ borrower => $patron, >+ issue => $issue, >+ item => $item->unblessed, >+ return_date => $return_date, >+ } >+ ); >+ $fines = Koha::Account::Lines->search({ borrowernumber => $patron->{borrowernumber} }); >+ is($fines->total_outstanding, 1, "Fine is accrued for homebranch"); >+ >+}; >+ >+$schema->storage->txn_rollback; >-- >2.11.0
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 27259
:
114591
|
114592
|
114593
|
133700
|
133701
|
133702
|
140388
|
140389
|
140390
|
140391
|
141021
|
141022
|
141023
|
143013
|
143014
|
143015