Revert "Bug 29012: Add default values for blank circulation rules that weren't saved to the database"

This reverts commit 387900a65c.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Lucas Gass 2022-10-13 17:31:41 +00:00
parent cd01c1f87e
commit c0063bbda2
5 changed files with 13 additions and 51 deletions

View File

@ -2900,7 +2900,7 @@ sub CanBookBeRenewed {
return ( 0, "too_unseen" )
if C4::Context->preference('UnseenRenewals') &&
looks_like_number($issuing_rule->{unseen_renewals_allowed}) &&
$issuing_rule->{unseen_renewals_allowed} &&
$issuing_rule->{unseen_renewals_allowed} <= $issue->unseen_renewals;
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
@ -3143,7 +3143,7 @@ sub AddRenewal {
rule_name => 'unseen_renewals_allowed'
}
);
if (!$seen && $rule && looks_like_number($rule->rule_value)) {
if (!$seen && $rule && $rule->rule_value) {
$unseen_renewals++;
} else {
# If the renewal is seen, unseen should revert to 0

View File

@ -264,7 +264,7 @@ elsif ($op eq 'add') {
my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') );
my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') );
my $renewalsallowed = $input->param('renewalsallowed');
my $unseen_renewals_allowed = strip_non_numeric( scalar $input->param('unseen_renewals_allowed') ) // '';
my $unseen_renewals_allowed = $input->param('unseen_renewals_allowed');
my $renewalperiod = $input->param('renewalperiod');
my $norenewalbefore = $input->param('norenewalbefore');
$norenewalbefore = '' if $norenewalbefore =~ /^\s*$/;
@ -278,20 +278,21 @@ elsif ($op eq 'add') {
my $holds_per_record = strip_non_numeric( scalar $input->param('holds_per_record') );
my $holds_per_day = strip_non_numeric( scalar $input->param('holds_per_day') );
my $onshelfholds = $input->param('onshelfholds') || 0;
my $issuelength = $input->param('issuelength') || 0;
my $issuelength = $input->param('issuelength');
$issuelength = $issuelength eq q{} ? undef : $issuelength;
my $daysmode = $input->param('daysmode');
my $lengthunit = $input->param('lengthunit');
my $hardduedate = $input->param('hardduedate') || '';
my $hardduedate = $input->param('hardduedate') || undef;
$hardduedate = eval { dt_from_string( scalar $hardduedate ) } if ( $hardduedate );
$hardduedate = output_pref( { dt => $hardduedate, dateonly => 1, dateformat => 'iso' } ) if ( $hardduedate );
my $hardduedatecompare = $input->param('hardduedatecompare');
my $rentaldiscount = $input->param('rentaldiscount') || 0;
my $rentaldiscount = $input->param('rentaldiscount');
my $opacitemholds = $input->param('opacitemholds') || 0;
my $article_requests = $input->param('article_requests') || 'no';
my $overduefinescap = $input->param('overduefinescap') || '';
my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
my $note = $input->param('note');
my $decreaseloanholds = $input->param('decreaseloanholds') || '';
my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
my $recalls_allowed = $input->param('recalls_allowed');
my $recalls_per_record = $input->param('recalls_per_record');
my $on_shelf_recalls = $input->param('on_shelf_recalls');

View File

@ -1,33 +0,0 @@
use Modern::Perl;
return {
bug_number => "29012",
description => "Some rules are not saved when left blank while editing a 'rule' line in smart-rules.pl",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
my %default_rule_values = (
issuelength => 0,
hardduedate => '',
unseenrenewalsallowed => '',
rentaldiscount => 0,
decreaseloanholds => '',
);
while (my ($rule_name, $rule_value) = each (%default_rule_values)) {
$dbh->do(q{
INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value)
SELECT branchcode, categorycode, itemtype, ?, ? FROM circulation_rules cr
WHERE NOT EXISTS (
SELECT * FROM circulation_rules cr2
WHERE
cr2.rule_name=?
AND ( (cr2.branchcode=cr.branchcode) OR ( ISNULL(cr2.branchcode) AND ISNULL(cr.branchcode) ) )
AND ( (cr2.categorycode=cr.categorycode) OR ( ISNULL(cr2.categorycode) AND ISNULL(cr.categorycode) ) )
AND ( (cr2.itemtype=cr.itemtype) OR ( ISNULL(cr2.itemtype) AND ISNULL(cr.itemtype) ) )
)
GROUP BY branchcode, categorycode, itemtype
}, undef, $rule_name, $rule_value, $rule_name);
}
say $out "Add default values for blank circulation rules that weren't saved to the database";
},
}

View File

@ -242,7 +242,7 @@ if ( $step == 5 ) {
my $categorycode = $input->param('categorycode');
my $itemtype = $input->param('itemtype');
my $maxissueqty = $input->param('maxissueqty');
my $issuelength = $input->param('issuelength') || 0;
my $issuelength = $input->param('issuelength');
my $lengthunit = $input->param('lengthunit');
my $renewalsallowed = $input->param('renewalsallowed');
my $renewalperiod = $input->param('renewalperiod');
@ -252,6 +252,7 @@ if ( $step == 5 ) {
my $onshelfholds = $input->param('onshelfholds') || 0;
$maxissueqty =~ s/\s//g;
$maxissueqty = undef if $maxissueqty !~ /^\d+/;
$issuelength = $issuelength eq q{} ? undef : $issuelength;
my $params = {
branchcode => $branchcode,
@ -285,9 +286,8 @@ if ( $step == 5 ) {
overduefinescap => "",
rentaldiscount => 0,
reservesallowed => $reservesallowed,
suspension_chargeperiod => 1,
decreaseloanholds => "",
unseen_renewals_allowed => "",
suspension_chargeperiod => undef,
decreaseloanholds => undef,
recalls_allowed => undef,
recalls_per_record => undef,
on_shelf_recalls => undef,

View File

@ -305,13 +305,7 @@
<td>[% suspension_chargeperiod | html %]</td>
<td>[% renewalsallowed | html %]</td>
[% IF Koha.Preference('UnseenRenewals') %]
<td>
[% IF unseenrenewalsallowed.defined && unseenrenewalsallowed != '' %]
[% unseenrenewalsallowed | html %]
[% ELSE %]
<span>Unlimited</span>
[% END %]
</td>
<td>[% unseenrenewalsallowed | html %]</td>
[% END %]
<td>[% renewalperiod | html %]</td>
<td>[% norenewalbefore | html %]</td>