$item->withdrawn ||
($item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems'));
- my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
+ my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
if ($pickup_branchcode) {
my $destination = Koha::Libraries->find($pickup_branchcode);
use Carp qw( carp confess );
use Koha::Calendar;
-use Koha::IssuingRules;
use Koha::DateUtils qw( dt_from_string );
use Koha::Exceptions;
sub accumulate_rentalcharge {
my ($self) = @_;
- my $itemtype = Koha::ItemTypes->find( $self->item->effective_itemtype );
- my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
+ my $itemtype = Koha::ItemTypes->find( $self->item->effective_itemtype );
+ my $lengthunit_rule = Koha::CirculationRules->get_effective_rule(
{
categorycode => $self->patron->categorycode,
itemtype => $itemtype->id,
- branchcode => $self->library->id
+ branchcode => $self->library->id,
+ rule_name => 'lengthunit',
}
);
- return 0 unless $issuing_rule;
+ return 0 unless $lengthunit_rule;
- my $units = $issuing_rule->lengthunit;
+ my $units = $lengthunit_rule->rule_value;
my $rentalcharge_increment =
( $units eq 'days' )
? $itemtype->rentalcharge_daily
suspension_chargeperiod => {
scope => [ 'branchcode', 'categorycode', 'itemtype' ],
},
+ note => { # This is not really a rule. Maybe we will want to separate this later.
+ scope => [ 'branchcode', 'categorycode', 'itemtype' ],
+ },
# Not included (deprecated?):
# * accountsent
# * reservecharge
my $itemtype = $params->{itemtype};
my $branchcode = $params->{branchcode};
+ my @c = caller;
Koha::Exceptions::MissingParameter->throw(
- "Required parameter 'rule_name' missing")
+ "Required parameter 'rule_name' missing" . "@c")
unless $rule_name;
for my $v ( $branchcode, $categorycode, $itemtype ) {
return unless $item or $patron;
- my $rule = Koha::CirculationRules->get_effective_issuing_rule(
+ my $rule = Koha::CirculationRules->get_effective_rule(
{
categorycode => $patron->categorycode,
itemtype => $item->effective_itemtype,
use C4::Context;
use C4::Circulation;
use Koha::Checkouts;
-use Koha::IssuingRules;
use Koha::Old::Checkouts;
use Try::Tiny;
my $renewable = Mojo::JSON->false;
$renewable = Mojo::JSON->true if $can_renew;
- my $rule = Koha::IssuingRules->get_effective_issuing_rule(
+ my $rule = Koha::CirculationRules->get_effective_rule(
{
categorycode => $checkout->patron->categorycode,
itemtype => $checkout->item->effective_itemtype,
branchcode => $branch eq '*' ? undef : $branch,
itemtype => $itemtype eq '*' ? undef : $itemtype,
rules => {
- restrictedtype => undef,
+ maxissueqty => undef,
+ maxonsiteissueqty => undef,
rentaldiscount => undef,
fine => undef,
finedays => undef,
maxsuspensiondays => undef,
+ suspension_chargeperiod => undef,
firstremind => undef,
chargeperiod => undef,
chargeperiod_charge_at => undef,
- accountsent => undef,
issuelength => undef,
lengthunit => undef,
hardduedate => undef,
no_auto_renewal_after_hard_limit => undef,
reservesallowed => undef,
holds_per_record => undef,
- overduefinescap => undef,
- cap_fine_to_replacement_price => undef,
+ holds_per_day => undef,
onshelfholds => undef,
opacitemholds => undef,
+ overduefinescap => undef,
+ cap_fine_to_replacement_price => undef,
article_requests => undef,
+ note => undef,
}
}
);
my $rules = {
maxissueqty => $maxissueqty,
maxonsiteissueqty => $maxonsiteissueqty,
+ rentaldiscount => $rentaldiscount,
fine => $fine,
finedays => $finedays,
maxsuspensiondays => $maxsuspensiondays,
firstremind => $firstremind,
chargeperiod => $chargeperiod,
chargeperiod_charge_at => $chargeperiod_charge_at,
+ issuelength => $issuelength,
+ lengthunit => $lengthunit,
+ hardduedate => $hardduedate,
+ hardduedatecompare => $hardduedatecompare,
renewalsallowed => $renewalsallowed,
renewalperiod => $renewalperiod,
norenewalbefore => $norenewalbefore,
reservesallowed => $reservesallowed,
holds_per_record => $holds_per_record,
holds_per_day => $holds_per_day,
- issuelength => $issuelength,
- lengthunit => $lengthunit,
- hardduedate => $hardduedate,
- hardduedatecompare => $hardduedatecompare,
- rentaldiscount => $rentaldiscount,
onshelfholds => $onshelfholds,
opacitemholds => $opacitemholds,
overduefinescap => $overduefinescap,
{
branchcode => $branch,
categorycode => undef,
- itemtype => undef,
rule_name => 'max_holds',
rule_value => $max_holds,
}
[% SET row_count = 0 %]
[% FOREACH c IN categorycodes %]
[% FOREACH i IN itemtypes %]
- [% SET note = CirculationRules.Get( branchcode, c, i, 'note' ) %]
- [% SET maxissueqty = CirculationRules.Get( branchcode, c, i, 'maxissueqty' ) %]
- [% SET maxonsiteissueqty = CirculationRules.Get( branchcode, c, i, 'maxonsiteissueqty' ) %]
- [% SET issuelength = CirculationRules.Get( branchcode, c, i, 'issuelength' ) %]
- [% SET lengthunit = CirculationRules.Get( branchcode, c, i, 'lengthunit' ) %]
- [% SET hardduedate = CirculationRules.Get( branchcode, c, i, 'hardduedate' ) %]
- [% SET hardduedatecompare = CirculationRules.Get( branchcode, c, i, 'hardduedatecompare' ) %]
- [% SET fine = CirculationRules.Get( branchcode, c, i, 'fine' ) %]
- [% SET chargeperiod = CirculationRules.Get( branchcode, c, i, 'chargeperiod' ) %]
- [% SET chargeperiod_charge_at = CirculationRules.Get( branchcode, c, i, 'chargeperiod_charge_at' ) %]
- [% SET firstremind = CirculationRules.Get( branchcode, c, i, 'firstremind' ) %]
- [% SET overduefinescap = CirculationRules.Get( branchcode, c, i, 'overduefinescap' ) %]
- [% SET cap_fine_to_replacement_price = CirculationRules.Get( branchcode, c, i, 'cap_fine_to_replacement_price' ) %]
- [% SET finedays = CirculationRules.Get( branchcode, c, i, 'finedays' ) %]
- [% SET maxsuspensiondays = CirculationRules.Get( branchcode, c, i, 'maxsuspensiondays' ) %]
- [% SET suspension_chargeperiod = CirculationRules.Get( branchcode, c, i, 'suspension_chargeperiod' ) %]
- [% SET renewalsallowed = CirculationRules.Get( branchcode, c, i, 'renewalsallowed' ) %]
- [% SET renewalperiod = CirculationRules.Get( branchcode, c, i, 'renewalperiod' ) %]
- [% SET norenewalbefore = CirculationRules.Get( branchcode, c, i, 'norenewalbefore' ) %]
- [% SET auto_renew = CirculationRules.Get( branchcode, c, i, 'auto_renew' ) %]
- [% SET no_auto_renewal_after = CirculationRules.Get( branchcode, c, i, 'no_auto_renewal_after' ) %]
- [% SET no_auto_renewal_after_hard_limit = CirculationRules.Get( branchcode, c, i, 'no_auto_renewal_after_hard_limit' ) %]
- [% SET reservesallowed = CirculationRules.Get( branchcode, c, i, 'reservesallowed' ) %]
- [% SET holds_per_day = CirculationRules.Get( branchcode, c, i, 'holds_per_day' ) %]
- [% SET holds_per_record = CirculationRules.Get( branchcode, c, i, 'holds_per_record' ) %]
- [% SET onshelfholds = CirculationRules.Get( branchcode, c, i, 'onshelfholds' ) %]
- [% SET opacitemholds = CirculationRules.Get( branchcode, c, i, 'opacitemholds' ) %]
- [% SET article_requests = CirculationRules.Get( branchcode, c, i, 'article_requests' ) %]
- [% SET rentaldiscount = CirculationRules.Get( branchcode, c, i, 'rentaldiscount' ) %]
+ [% SET note = CirculationRules.Search( branchcode, c, i, 'note' ) %]
+ [% SET maxissueqty = CirculationRules.Search( branchcode, c, i, 'maxissueqty' ) %]
+ [% SET maxonsiteissueqty = CirculationRules.Search( branchcode, c, i, 'maxonsiteissueqty' ) %]
+ [% SET issuelength = CirculationRules.Search( branchcode, c, i, 'issuelength' ) %]
+ [% SET lengthunit = CirculationRules.Search( branchcode, c, i, 'lengthunit' ) %]
+ [% SET hardduedate = CirculationRules.Search( branchcode, c, i, 'hardduedate' ) %]
+ [% SET hardduedatecompare = CirculationRules.Search( branchcode, c, i, 'hardduedatecompare' ) %]
+ [% SET fine = CirculationRules.Search( branchcode, c, i, 'fine' ) %]
+ [% SET chargeperiod = CirculationRules.Search( branchcode, c, i, 'chargeperiod' ) %]
+ [% SET chargeperiod_charge_at = CirculationRules.Search( branchcode, c, i, 'chargeperiod_charge_at' ) %]
+ [% SET firstremind = CirculationRules.Search( branchcode, c, i, 'firstremind' ) %]
+ [% SET overduefinescap = CirculationRules.Search( branchcode, c, i, 'overduefinescap' ) %]
+ [% SET cap_fine_to_replacement_price = CirculationRules.Search( branchcode, c, i, 'cap_fine_to_replacement_price' ) %]
+ [% SET finedays = CirculationRules.Search( branchcode, c, i, 'finedays' ) %]
+ [% SET maxsuspensiondays = CirculationRules.Search( branchcode, c, i, 'maxsuspensiondays' ) %]
+ [% SET suspension_chargeperiod = CirculationRules.Search( branchcode, c, i, 'suspension_chargeperiod' ) %]
+ [% SET renewalsallowed = CirculationRules.Search( branchcode, c, i, 'renewalsallowed' ) %]
+ [% SET renewalperiod = CirculationRules.Search( branchcode, c, i, 'renewalperiod' ) %]
+ [% SET norenewalbefore = CirculationRules.Search( branchcode, c, i, 'norenewalbefore' ) %]
+ [% SET auto_renew = CirculationRules.Search( branchcode, c, i, 'auto_renew' ) %]
+ [% SET no_auto_renewal_after = CirculationRules.Search( branchcode, c, i, 'no_auto_renewal_after' ) %]
+ [% SET no_auto_renewal_after_hard_limit = CirculationRules.Search( branchcode, c, i, 'no_auto_renewal_after_hard_limit' ) %]
+ [% SET reservesallowed = CirculationRules.Search( branchcode, c, i, 'reservesallowed' ) %]
+ [% SET holds_per_day = CirculationRules.Search( branchcode, c, i, 'holds_per_day' ) %]
+ [% SET holds_per_record = CirculationRules.Search( branchcode, c, i, 'holds_per_record' ) %]
+ [% SET onshelfholds = CirculationRules.Search( branchcode, c, i, 'onshelfholds' ) %]
+ [% SET opacitemholds = CirculationRules.Search( branchcode, c, i, 'opacitemholds' ) %]
+ [% SET article_requests = CirculationRules.Search( branchcode, c, i, 'article_requests' ) %]
+ [% SET rentaldiscount = CirculationRules.Search( branchcode, c, i, 'rentaldiscount' ) %]
- [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod
- || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed
- || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed
- || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests %]
+ [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests %]
[% IF show_rule %]
[% SET row_count = row_count + 1 %]
<tr row_countd="row_[% row_count %]">
<a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&itemtype=[% rule.itemtype || '*' %]&categorycode=[% rule.categorycode || '*' %]&branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
</td>
<td>
- [% IF rule.note %]
- <a name="viewnote" data-toggle="popover" title="Note" data-content="[% rule.note | html %]" data-placement="top" data-trigger="hover">View note</a>
+ [% IF note.defined %]
+ <a name="viewnote" data-toggle="popover" title="Note" data-content="[% note | html %]" data-placement="top" data-trigger="hover">View note</a>
[% ELSE %]<span> </span>[% END %]
</td>
<td>
plan tests => 2;
t::lib::Mocks::mock_preference('useDefaultReplacementCost', '1');
- my $issuingrule = $builder->build_object(
+ Koha::CirculationRules->set_rules(
{
- class => 'Koha::IssuingRules',
- value => {
- branchcode => '*',
- categorycode => '*',
- itemtype => '*',
+ branchcode => undef,
+ categorycode => undef,
+ itemtype => undef,
+ rules => {
fine => '1.00',
lengthunit => 'days',
finedays => 0,
my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
is( int($amount), 3, 'Got the lesser of overduefinescap and replacement price where overduefinescap < replacement price' );
- $issuingrule->overduefinescap(6)->store();
+ Koha::CirculationRules->set_rule({ rule_name => 'overduefinescap', rule_value => 6, branchcode => undef, categorycode => undef, itemtype => undef });
($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
is( int($amount), 5, 'Get the lesser of overduefinescap and replacement price where overduefinescap > replacement price' );
});
# Set up an issuing rule
- my $rule = $builder->build({
- source => 'Issuingrule',
- value => {
+ Koha::CirculationRules->set_rules(
+ {
categorycode => '*',
itemtype => $itemtype->{itemtype},
branchcode => '*',
- issuelength => 1,
- firstremind => 1, # 1 day of grace
- finedays => 2, # 2 days of fine per day of overdue
- lengthunit => 'days',
+ rules => {
+ issuelength => 1,
+ firstremind => 1, # 1 day of grace
+ finedays => 2, # 2 days of fine per day of overdue
+ lengthunit => 'days',
+ }
}
- });
+ );
# Set an All->All for an itemtype
Koha::CirculationRules->set_rules(
})->{categorycode};
# A default issuingrule should always be present
-my $issuingrule = $builder->build(
+Koha::CirculationRules->set_rules(
{
- source => 'Issuingrule',
- value => {
- itemtype => '*',
- categorycode => '*',
- branchcode => '*',
- lengthunit => 'days',
- issuelength => 0,
- renewalperiod => 0,
+ itemtype => '*',
+ categorycode => '*',
+ branchcode => '*',
+ rules => {
+ lengthunit => 'days',
+ issuelength => 0,
+ renewalperiod => 0,
renewalsallowed => 0
}
}
$dbh->do('DELETE FROM reserves');
$dbh->do('DELETE FROM circulation_rules');
- $biblio = $builder->build_sample_biblio({ itemtype => 'TEST' });
+ $biblio = $builder->build_sample_biblio;
( $item_bibnum, $item_bibitemnum, $itemnumber ) =
AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 },
$biblio->biblionumber );
{
categorycode => undef,
branchcode => undef,
- itemtype => $testitemtype,
+ itemtype => $biblio->itemtype,
rules => {
reservesallowed => 99,
holds_per_record => 99,
my ( $item_bibnum, $item_bibitemnum, $itemnumber )
= AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $biblio->biblionumber );
#Add a default rule to allow some holds
- $dbh->do(
- q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
- VALUES (?, ?, ?, ?, ?)},
- {},
- '*', '*', '*', 25, 99
+
+ Koha::CirculationRules->set_rules(
+ {
+ branchcode => undef,
+ categorycode => undef,
+ itemtype => undef,
+ rules => {
+ reservesallowed => 25,
+ holds_per_record => 99,
+ }
+ }
);
my $item = Koha::Items->find($itemnumber);
my $branch_to = $builder->build({ source => 'Branch' })->{ branchcode };
);
# Raise reservesallowed to avoid tooManyReserves from it
- $issuingrule->set( { reservesallowed => 3 } )->store;
+ Koha::CirculationRules->set_rule(
+ {
+
+ categorycode => '*',
+ branchcode => '*',
+ itemtype => $itemtype->itemtype,
+ rule_name => 'reservesallowed',
+ rule_value => 3,
+ }
+ );
is_deeply(
CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ),
);
# Set holds_per_day to 0
- $issuingrule->set( { holds_per_day => 0 } )->store;
+ Koha::CirculationRules->set_rule(
+ {
+
+ categorycode => '*',
+ branchcode => '*',
+ itemtype => $itemtype->itemtype,
+ rule_name => 'holds_per_day',
+ rule_value => 0,
+ }
+ );
+
# Delete existing holds
Koha::Holds->search->delete;
'Patron cannot reserve if holds_per_day is 0 (i.e. 0 is 0)'
);
- $issuingrule->set( { holds_per_day => undef } )->store;
+ Koha::CirculationRules->set_rule(
+ {
+
+ categorycode => '*',
+ branchcode => '*',
+ itemtype => $itemtype->itemtype,
+ rule_name => 'holds_per_day',
+ rule_value => undef,
+ }
+ );
+
Koha::Holds->search->delete;
is_deeply(
CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ),
source => 'Item',
value => {
biblionumber => $biblio2->{biblionumber},
- damaged => 0
+ damaged => 0,
+ itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype,
}
});
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' );
- my $issuingrule = $builder->build({
- source => 'Issuingrule',
- value => {
+ Koha::CirculationRules->set_rule(
+ {
categorycode => $patron->{categorycode},
- itemtype => $item2->{itype},
- branchcode => $patron->{branchcode},
- reservesallowed => 0,
+ itemtype => $item2->{itype},
+ branchcode => $patron->{branchcode},
+ rule_name => 'reservesallowed',
+ rule_value => 0,
}
- });
+ );
$query = new CGI;
$query->param( 'patron_id', $patron->{borrowernumber});
value => {
biblionumber => $biblio3->{biblionumber},
damaged => 0,
+ itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype,
}
});
value => {
biblionumber => $biblio3->{biblionumber},
damaged => 1,
+ itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype,
}
});
- my $issuingrule2 = $builder->build({
- source => 'Issuingrule',
- value => {
+ Koha::CirculationRules->set_rule(
+ {
categorycode => $patron->{categorycode},
- itemtype => $item3->{itype},
- branchcode => $patron->{branchcode},
- reservesallowed => 10,
+ itemtype => $item3->{itype},
+ branchcode => $patron->{branchcode},
+ rule_name => 'reservesallowed',
+ rule_value => 10,
}
- });
+ );
$query = new CGI;
$query->param( 'patron_id', $patron->{borrowernumber});
biblionumber => $biblio->{biblionumber},
damaged => 0,
itemlost => 0,
+ itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype,
}
});
- Koha::IssuingRules->search()->delete();
- my $issuingrule = $builder->build({
- source => 'Issuingrule',
- value => {
- categorycode => '*',
- itemtype => '*',
- branchcode => '*',
- reservesallowed => 99,
+ Koha::CirculationRules->set_rule(
+ {
+ categorycode => undef,
+ itemtype => undef,
+ branchcode => undef,
+ rule_name => 'reservesallowed',
+ rule_value => 99,
}
- });
+ );
my $limit = Koha::Item::Transfer::Limit->new({
toBranch => $pickup_branch->{branchcode},
use Modern::Perl;
-use Test::More tests => 3;
+use Test::More tests => 2;
use Test::Deep qw( cmp_methods );
use Test::Exception;
categorycode => undef,
itemtype => undef,
rule_name => 'fine',
+ rule_value => 1,
});
is($rule, undef, 'When I attempt to get effective issuing rule by'
.' providing undefined values, then undef is returned.');
categorycode => undef,
itemtype => undef,
rule_name => 'fine',
+ rule_value => 2,
})->store, 'Given I added an issuing rule branchcode => undef,'
.' categorycode => undef, itemtype => undef,');
$rule = Koha::CirculationRules->get_effective_rule({
categorycode => undef,
itemtype => undef,
rule_name => 'fine',
+ rule_value => 3,
});
_is_row_match(
$rule,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 4,
});
is($rule, undef, 'When I attempt to get effective issuing rule, then undef'
.' is returned.');
categorycode => undef,
itemtype => undef,
rule_name => 'fine',
+ rule_value => 5,
})->store, 'Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => undef,');
$rule = Koha::CirculationRules->get_effective_rule({
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 6,
});
_is_row_match(
$rule,
categorycode => undef,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 7,
})->store, "Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => $itemtype,");
$rule = Koha::CirculationRules->get_effective_rule({
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 8,
});
_is_row_match(
$rule,
categorycode => $categorycode,
itemtype => undef,
rule_name => 'fine',
+ rule_value => 9,
})->store, "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => undef,");
$rule = Koha::CirculationRules->get_effective_rule({
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 10,
});
_is_row_match(
$rule,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 11,
})->store, "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => $itemtype,");
$rule = Koha::CirculationRules->get_effective_rule({
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 12,
});
_is_row_match(
$rule,
categorycode => undef,
itemtype => undef,
rule_name => 'fine',
+ rule_value => 13,
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => undef,");
$rule = Koha::CirculationRules->get_effective_rule({
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 14,
});
_is_row_match(
$rule,
categorycode => undef,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 15,
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => $itemtype,");
$rule = Koha::CirculationRules->get_effective_rule({
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 16,
});
_is_row_match(
$rule,
categorycode => $categorycode,
itemtype => undef,
rule_name => 'fine',
+ rule_value => 17,
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => undef,");
$rule = Koha::CirculationRules->get_effective_rule({
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 18,
});
_is_row_match(
$rule,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 19,
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype,");
$rule = Koha::CirculationRules->get_effective_rule({
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
+ rule_value => 20,
});
_is_row_match(
$rule,
};
};
-subtest 'delete' => sub {
- plan tests => 1;
-
- my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
- my $library = $builder->build_object({ class => 'Koha::Libraries' });
- my $category = $builder->build_object({ class => 'Koha::Patron::Categories' });
-
- # We make an issuing rule
- my $issue_rule = $builder->build_object({ class => 'Koha::IssuingRules', value => {
- categorycode => $category->categorycode,
- itemtype => $itemtype->itemtype,
- branchcode => $library->branchcode
- }
- });
-
- my $count = Koha::CirculationRules->search()->count;
- # Note how many circulation rules we start with
-
- # We make some circulation rules for the same thing
- $builder->build_object({ class => 'Koha::CirculationRules', value => {
- categorycode => $category->categorycode,
- itemtype => $itemtype->itemtype,
- branchcode => $library->branchcode,
- rule_name => 'maxissueqty',
- }
- });
- $builder->build_object({ class => 'Koha::CirculationRules', value => {
- categorycode => $category->categorycode,
- itemtype => $itemtype->itemtype,
- branchcode => $library->branchcode,
- rule_name => 'maxonsiteissueqty',
- }
- });
- $builder->build_object({ class => 'Koha::CirculationRules', value => {
- categorycode => $category->categorycode,
- itemtype => $itemtype->itemtype,
- branchcode => $library->branchcode,
- rule_name => 'another_rule', # That must not be deleted
- }
- });
-
- # Now we delete the issuing rule
- $issue_rule->delete;
- is( Koha::CirculationRules->search()->count ,$count + 1, "We remove related circ rules maxissueqty and maxonsiteissueqty with our issuing rule");
-
-};
-
sub _is_row_match {
my ( $rule, $expected, $message ) = @_;
use C4::SIP::ILS::Transaction::Hold;
use C4::Reserves;
-use Koha::IssuingRules;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
$elt = $driver->find_elements('//table[@id="default-circulation-rules"]/tbody/tr/td[contains(text(),"'.$itype->description.'")]/following-sibling::td/span[text() = "Unlimited"]');
is( @$elt,2,"We have unlimited checkouts");
#Clean up
- Koha::IssuingRules->find({itemtype=>$itype->itemtype})->delete();
+ Koha::CirculationRules->search( { itemtype => $itype->itemtype } )->delete;
$itype->delete;
# TODO Create more smart rules navigation here
};