Koha/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t
Kyle M Hall caa753388a Bug 14577 - Allow restriction of checkouts based on fines of guarantor's guarantees
This enhancment allows a library to prevent patrons from checking out
items if his or her guarantees own too much.

Test Plan:
1) Apply this patch
2) Find or create a patron with a guarantor
3) Add a fine to the patron's account
4) Set the new system preference NoIssuesChargeGuarantees to be less
   than the amount owed by the patron
4) Attempt to check out an item to the guarantor, you will either
   be warned or prevented from checking out based on your system
   settings.

Signed-off-by: Cathi Wiggin <CWIGGINS@arcadiaca.gov>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-04-29 11:54:23 +00:00

67 lines
1.8 KiB
Perl

#!/usr/bin/perl
# 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 => 2;
use t::lib::TestBuilder;
use C4::Accounts qw( manualinvoice );
use C4::Circulation qw( CanBookBeIssued );
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new();
my $item = $builder->build(
{
source => 'Item',
value => {
notforloan => 0,
withdrawn => 0
}
}
);
my $patron = $builder->build(
{
source => 'Borrower',
}
);
my $guarantee = $builder->build(
{
source => 'Borrower',
value => {
guarantorid => $patron->{borrowernumber},
}
}
);
C4::Context->set_preference( 'NoIssuesChargeGuarantees', '5.00' );
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" );
manualinvoice( $guarantee->{borrowernumber}, undef, undef, 'L', 10.00 );
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
is( $issuingimpossible->{DEBT_GUARANTEES}, '10.00', "Patron cannot check out item due to debt for guarantee" );
$schema->storage->txn_rollback;
1;