From 692fb7e134396c85a4ddf7bdfc49fb52e9c5015c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 18 Jun 2020 12:16:45 +0100 Subject: [PATCH] Bug 24159: (QA follow-up) Make terminology consistent This patch changes the new circulation rule that's introduced from useDaysMode to daysmode to improve consistency with other rule names. We also update the accessors and code using them to reflect the new term. Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/Circulation.pm | 16 ++++++------ Koha/Checkouts.pm | 4 +-- Koha/CirculationRules.pm | 18 ++++++------- Koha/Hold.pm | 4 +-- admin/smart-rules.pl | 6 ++--- .../prog/en/modules/admin/smart-rules.tt | 8 +++--- .../thirdparty/TalkingTech_itiva_outbound.pl | 4 +-- t/db_dependent/Koha/CirculationRules.t | 26 +++++++++---------- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index cc4a95a3ea..67a986b417 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1241,14 +1241,14 @@ sub checkHighHolds { my $issuedate = dt_from_string(); my $itype = $item_object->effective_itemtype; - my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( + my $daysmode = Koha::CirculationRules->get_effective_daysmode( { categorycode => $borrower->{categorycode}, itemtype => $itype, branchcode => $branchcode, } ); - my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => $useDaysMode_value ); + my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => $daysmode ); my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $borrower ); @@ -3583,7 +3583,7 @@ sub updateWrongTransfer { $newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); this function calculates the due date given the start date and configured circulation rules, -checking against the holidays calendar as per the useDaysMode circulation rule. +checking against the holidays calendar as per the daysmode circulation rule. C<$startdate> = DateTime object representing start date of loan period (assumed to be today) C<$itemtype> = itemtype code of item in question C<$branch> = location whose calendar to use @@ -3617,7 +3617,7 @@ sub CalcDateDue { } - my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( + my $daysmode = Koha::CirculationRules->get_effective_daysmode( { categorycode => $borrower->{categorycode}, itemtype => $itemtype, @@ -3626,7 +3626,7 @@ sub CalcDateDue { ); # calculate the datedue as normal - if ( $useDaysMode_value eq 'Days' ) + if ( $daysmode eq 'Days' ) { # ignoring calendar if ( $loanlength->{lengthunit} eq 'hours' ) { $datedue->add( hours => $loanlength->{$length_key} ); @@ -3643,7 +3643,7 @@ sub CalcDateDue { else { # days $dur = DateTime::Duration->new( days => $loanlength->{$length_key}); } - my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value ); + my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $daysmode ); $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); if ($loanlength->{lengthunit} eq 'days') { $datedue->set_hour(23); @@ -3681,8 +3681,8 @@ sub CalcDateDue { $datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz ); } } - if ( $useDaysMode_value ne 'Days' ) { - my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value ); + if ( $daysmode ne 'Days' ) { + my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $daysmode ); if ( $calendar->is_holiday($datedue) ) { # Don't return on a closed day $datedue = $calendar->prev_open_days( $datedue, 1 ); diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm index 1f33cb1d81..2ade76e20e 100644 --- a/Koha/Checkouts.pm +++ b/Koha/Checkouts.pm @@ -48,14 +48,14 @@ sub calculate_dropbox_date { my $userenv = C4::Context->userenv; my $branchcode = $userenv->{branch} // q{}; - my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( + my $daysmode = Koha::CirculationRules->get_effective_daysmode( { categorycode => undef, itemtype => undef, branchcode => $branchcode, } ); - my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => $useDaysMode_value ); + my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => $daysmode ); my $today = dt_from_string; my $dropbox_date = $calendar->addDate( $today, -1 ); diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 17e7674130..790f30498d 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -109,7 +109,7 @@ our $RULE_KINDS = { issuelength => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, - useDaysMode => { + daysmode => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, lengthunit => { @@ -490,32 +490,32 @@ sub guess_article_requestable_itemtypes { return $res; } -=head3 get_useDaysMode_effective_value +=head3 get_daysmode_effective_value -Return the value for useDaysMode defined in the circulation rules. +Return the value for daysmode defined in the circulation rules. If not defined (or empty string), the value of the system preference useDaysMode is returned =cut -sub get_useDaysMode_effective_value { +sub get_effective_daysmode { my ( $class, $params ) = @_; my $categorycode = $params->{categorycode}; my $itemtype = $params->{itemtype}; my $branchcode = $params->{branchcode}; - my $useDaysMode_rule = $class->get_effective_rule( + my $daysmode_rule = $class->get_effective_rule( { categorycode => $categorycode, itemtype => $itemtype, branchcode => $branchcode, - rule_name => 'useDaysMode', + rule_name => 'daysmode', } ); - return ( defined($useDaysMode_rule) - and $useDaysMode_rule->rule_value ne '' ) - ? $useDaysMode_rule->rule_value + return ( defined($daysmode_rule) + and $daysmode_rule->rule_value ne '' ) + ? $daysmode_rule->rule_value : C4::Context->preference('useDaysMode'); } diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 700c85572a..8969e32839 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -184,14 +184,14 @@ sub set_waiting { if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; - my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( + my $daysmode = Koha::CirculationRules->get_effective_daysmode( { categorycode => $self->borrower->categorycode, itemtype => $itemtype, branchcode => $self->branchcode, } ); - my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $useDaysMode_value ); + my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); } diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index a76cbbac3c..20da1b1d6d 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -94,7 +94,7 @@ if ($op eq 'delete') { chargeperiod => undef, chargeperiod_charge_at => undef, issuelength => undef, - useDaysMode => undef, + daysmode => undef, lengthunit => undef, hardduedate => undef, hardduedatecompare => undef, @@ -279,7 +279,7 @@ elsif ($op eq 'add') { my $onshelfholds = $input->param('onshelfholds') || 0; my $issuelength = $input->param('issuelength'); $issuelength = $issuelength eq q{} ? undef : $issuelength; - my $useDaysMode = $input->param('useDaysMode'); + my $daysmode = $input->param('daysmode'); my $lengthunit = $input->param('lengthunit'); my $hardduedate = $input->param('hardduedate') || undef; $hardduedate = eval { dt_from_string( $input->param('hardduedate') ) } if ( $hardduedate ); @@ -305,7 +305,7 @@ elsif ($op eq 'add') { chargeperiod => $chargeperiod, chargeperiod_charge_at => $chargeperiod_charge_at, issuelength => $issuelength, - useDaysMode => $useDaysMode, + daysmode => $daysmode, lengthunit => $lengthunit, hardduedate => $hardduedate, hardduedatecompare => $hardduedatecompare, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index dcd53bbb13..ce3531596d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -131,7 +131,7 @@ [% SET maxissueqty = all_rules.$c.$i.maxissueqty %] [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %] [% SET issuelength = all_rules.$c.$i.issuelength %] - [% SET useDaysMode = all_rules.$c.$i.useDaysMode %] + [% SET daysmode = all_rules.$c.$i.daysmode %] [% SET lengthunit = all_rules.$c.$i.lengthunit %] [% SET hardduedate = all_rules.$c.$i.hardduedate %] [% SET hardduedatecompare = all_rules.$c.$i.hardduedatecompare %] @@ -158,7 +158,7 @@ [% SET article_requests = all_rules.$c.$i.article_requests %] [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %] - [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || useDaysMode || 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 || daysmode || 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 %] @@ -201,7 +201,7 @@ [% issuelength | html %] - [% SWITCH useDaysMode %] + [% SWITCH daysmode %] [% CASE 'Calendar' %]Calendar [% CASE 'Datedue' %]Datedue [% CASE 'Days' %]Days @@ -346,7 +346,7 @@ - diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index cbab04947d..dd4d2f9ff2 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -333,7 +333,7 @@ sub GetWaitingHolds { my @results; while ( my $issue = $sth->fetchrow_hashref() ) { my $item = Koha::Items->find({ barcode => $issue->{barcode} }); - my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( + my $daysmode = Koha::CirculationRules->get_effective_daysmode( { categorycode => $issue->{categorycode}, itemtype => $item->effective_itemtype, @@ -341,7 +341,7 @@ sub GetWaitingHolds { } ); - my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $useDaysMode_value ); + my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode ); my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' ); my $pickup_date = $waiting_date->clone->add( days => $pickupdelay ); diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t index d2868d26c8..f24542e2b6 100644 --- a/t/db_dependent/Koha/CirculationRules.t +++ b/t/db_dependent/Koha/CirculationRules.t @@ -284,7 +284,7 @@ subtest 'get_onshelfholds_policy() tests' => sub { $schema->storage->txn_rollback; }; -subtest 'get_useDaysMode_effective_value' => sub { +subtest 'get_effective_daysmode' => sub { plan tests => 4; $schema->storage->txn_begin; @@ -293,13 +293,13 @@ subtest 'get_useDaysMode_effective_value' => sub { my $item_2 = $builder->build_sample_item(); my $circ_rules = - Koha::CirculationRules->search( { rule_name => 'useDaysMode' } )->delete; + Koha::CirculationRules->search( { rule_name => 'daysmode' } )->delete; # Default value 'Datedue' at pref level t::lib::Mocks::mock_preference( 'useDaysMode', 'Datedue' ); is( - Koha::CirculationRules->get_useDaysMode_effective_value( + Koha::CirculationRules->get_effective_daysmode( { categorycode => undef, itemtype => $item_1->effective_itemtype, @@ -307,7 +307,7 @@ subtest 'get_useDaysMode_effective_value' => sub { } ), 'Datedue', - 'useDaysMode default to pref value if the rule does not exist' + 'daysmode default to pref value if the rule does not exist' ); Koha::CirculationRules->set_rule( @@ -315,7 +315,7 @@ subtest 'get_useDaysMode_effective_value' => sub { branchcode => '*', categorycode => '*', itemtype => '*', - rule_name => 'useDaysMode', + rule_name => 'daysmode', rule_value => 'Calendar', } ); @@ -324,13 +324,13 @@ subtest 'get_useDaysMode_effective_value' => sub { branchcode => '*', categorycode => '*', itemtype => $item_1->effective_itemtype, - rule_name => 'useDaysMode', + rule_name => 'daysmode', rule_value => 'Days', } ); is( - Koha::CirculationRules->get_useDaysMode_effective_value( + Koha::CirculationRules->get_effective_daysmode( { categorycode => undef, itemtype => $item_1->effective_itemtype, @@ -338,10 +338,10 @@ subtest 'get_useDaysMode_effective_value' => sub { } ), 'Days', - "useDaysMode for item_1 is the specific rule" + "daysmode for item_1 is the specific rule" ); is( - Koha::CirculationRules->get_useDaysMode_effective_value( + Koha::CirculationRules->get_effective_daysmode( { categorycode => undef, itemtype => $item_2->effective_itemtype, @@ -349,7 +349,7 @@ subtest 'get_useDaysMode_effective_value' => sub { } ), 'Calendar', - "useDaysMode for item_2 is the one defined for the default circ rule" + "daysmode for item_2 is the one defined for the default circ rule" ); Koha::CirculationRules->set_rule( @@ -357,13 +357,13 @@ subtest 'get_useDaysMode_effective_value' => sub { branchcode => '*', categorycode => '*', itemtype => $item_2->effective_itemtype, - rule_name => 'useDaysMode', + rule_name => 'daysmode', rule_value => '', } ); is( - Koha::CirculationRules->get_useDaysMode_effective_value( + Koha::CirculationRules->get_effective_daysmode( { categorycode => undef, itemtype => $item_2->effective_itemtype, @@ -371,7 +371,7 @@ subtest 'get_useDaysMode_effective_value' => sub { } ), 'Datedue', - 'useDaysMode default to pref value if the rule exists but set to""' + 'daysmode default to pref value if the rule exists but set to""' ); $schema->storage->txn_rollback; -- 2.39.5