Bugzilla – Attachment 103247 Details for
Bug 25089
Add checkout_type to circulation rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25089: Add checkout_type to get_effective_rules
Bug-25089-Add-checkouttype-to-geteffectiverules.patch (text/plain), 26.55 KB, created by
Lari Taskula
on 2020-04-20 09:28:29 UTC
(
hide
)
Description:
Bug 25089: Add checkout_type to get_effective_rules
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2020-04-20 09:28:29 UTC
Size:
26.55 KB
patch
obsolete
>From a66fc5ea204a9ec8f5566946e8497cf3ca7fff7b Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Wed, 15 Apr 2020 16:08:17 +0000 >Subject: [PATCH] Bug 25089: Add checkout_type to get_effective_rules > >To test: >1. Find all occurrences of get_effective_rules that are missing > checkout_type where required > >grep --exclude-dir '.git' --exclude-dir 'misc/translator' \ >--exclude-dir 'koha-tmpl' \ >-Przo '(?s)(::|->)get_effective_rules.*?\)' | \ >grep -avz 'checkout_type' && echo "" > > 1.1. Verify command output. Only reserve related calls to > get_effective_rules() should be returned. > >2. Find all subroutines using get_effective_rules() > >git grep --no-index -n -p -P 'get_effective_rules\s*\(' \ >| grep -v 'sub {' | grep -P 'sub .*' > > This list should be returned: > >git grep --no-index -n -p 'get_effective_rules' | grep -P 'sub .*' > >3. Check modification made to C4::Circulation::CalcDateDue() >4. Check modification made to C4::Circulation::CalcFine() >5. Check modification made to C4::Circulation::GetLoanLength() >6. Check modification made to C4::Circulation::GetHardDueDate() > > Make sure all matches (where rule scope allows checkout_type) are > updated. > >7. Run these unit tests: > >grep -Prl --color=never 'get_effective_rule\(|set_rule\(|set_rules\(' \ >t/db_dependent/ | grep '^.*\.t$' | xargs prove > >8. Test onboarding tool >8.1. Drop&create your database (take backups first if needed) >8.2. Navigate to web installer >8.3. Continue until you reach onboarding tool step where circulation > rules are added. >8.4. Observe new drop down selection "Checkout type". >8.5. Select any checkout type and continue the onboarding process. >8.6. Investigate your database table "circulation_rules". You should > now have rules with checkout_type of your choice. > >Sponsored-by: The National Library of Finland >--- > C4/Circulation.pm | 33 +++++++++++-------- > C4/Overdues.pm | 3 +- > t/db_dependent/Circulation.t | 4 +-- > t/db_dependent/Circulation/CalcDateDue.t | 36 ++++++++++----------- > t/db_dependent/Circulation/CalcFine.t | 10 +++--- > t/db_dependent/Circulation/GetHardDueDate.t | 11 +++++-- > t/db_dependent/Fines.t | 8 ++--- > 7 files changed, 58 insertions(+), 47 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 38662f993f..632cba44a1 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -708,7 +708,7 @@ sub CanBookBeIssued { > unless ( $duedate ) { > my $issuedate = $now->clone(); > >- $duedate = CalcDateDue( $issuedate, $effective_itemtype, $circ_library->branchcode, $patron_unblessed ); >+ $duedate = CalcDateDue( $issuedate, $effective_itemtype, $circ_library->branchcode, $patron_unblessed, $checkout_type ); > > # Offline circ calls AddIssue directly, doesn't run through here > # So issuingimpossible should be ok. >@@ -1240,7 +1240,7 @@ sub checkHighHolds { > my $calendar = Koha::Calendar->new( branchcode => $branchcode ); > > my $itype = $item_object->effective_itemtype; >- my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $borrower ); >+ my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $borrower, $Koha::Checkouts::type->{checkout}, undef ); > > my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration'); > >@@ -1354,7 +1354,7 @@ sub AddIssue { > else { > unless ($datedue) { > my $itype = $item_object->effective_itemtype; >- $datedue = CalcDateDue( $issuedate, $itype, $branchcode, $borrower ); >+ $datedue = CalcDateDue( $issuedate, $itype, $branchcode, $borrower, $checkout_type ); > > } > $datedue->truncate( to => 'minute' ); >@@ -1415,7 +1415,7 @@ sub AddIssue { > # Record in the database the fact that the book was issued. > unless ($datedue) { > my $itype = $item_object->effective_itemtype; >- $datedue = CalcDateDue( $issuedate, $itype, $branchcode, $borrower ); >+ $datedue = CalcDateDue( $issuedate, $itype, $branchcode, $borrower, $checkout_type ); > > } > $datedue->truncate( to => 'minute' ); >@@ -1537,14 +1537,14 @@ sub AddIssue { > > =head2 GetLoanLength > >- my $loanlength = &GetLoanLength($borrowertype,$itemtype,branchcode) >+ my $loanlength = &GetLoanLength($borrowertype,$itemtype,branchcode,$checkout_type) > > Get loan length for an itemtype, a borrower type and a branch > > =cut > > sub GetLoanLength { >- my ( $categorycode, $itemtype, $branchcode ) = @_; >+ my ( $categorycode, $itemtype, $branchcode, $checkout_type ) = @_; > > # Initialize default values > my $rules = { >@@ -1557,6 +1557,7 @@ sub GetLoanLength { > branchcode => $branchcode, > categorycode => $categorycode, > itemtype => $itemtype, >+ checkout_type => $checkout_type, > rules => [ > 'issuelength', > 'renewalperiod', >@@ -1575,20 +1576,21 @@ sub GetLoanLength { > > =head2 GetHardDueDate > >- my ($hardduedate,$hardduedatecompare) = &GetHardDueDate($borrowertype,$itemtype,branchcode) >+ my ($hardduedate,$hardduedatecompare) = &GetHardDueDate($borrowertype,$itemtype,branchcode,$checkout_type) > > Get the Hard Due Date and it's comparison for an itemtype, a borrower type and a branch > > =cut > > sub GetHardDueDate { >- my ( $borrowertype, $itemtype, $branchcode ) = @_; >+ my ( $borrowertype, $itemtype, $branchcode, $checkout_type ) = @_; > > my $rules = Koha::CirculationRules->get_effective_rules( > { > categorycode => $borrowertype, > itemtype => $itemtype, > branchcode => $branchcode, >+ checkout_type => $checkout_type, > rules => [ 'hardduedate', 'hardduedatecompare' ], > } > ); >@@ -2682,6 +2684,7 @@ sub CanBookBeRenewed { > categorycode => $patron->categorycode, > itemtype => $item->effective_itemtype, > branchcode => $branchcode, >+ checkout_type => $issue->checkout_type, > rules => [ > 'renewalsallowed', > 'no_auto_renewal_after', >@@ -2929,7 +2932,7 @@ sub AddRenewal { > $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? > dt_from_string( $issue->date_due, 'sql' ) : > dt_from_string(); >- $datedue = CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal'); >+ $datedue = CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, $issue->checkout_type, 'is a renewal'); > } > > my $fees = Koha::Charges::Fees->new( >@@ -3107,6 +3110,7 @@ sub GetSoonestRenewDate { > { categorycode => $patron->categorycode, > itemtype => $item->effective_itemtype, > branchcode => $branchcode, >+ checkout_type => $itemissue->checkout_type, > rules => [ > 'norenewalbefore', > 'lengthunit', >@@ -3171,6 +3175,7 @@ sub GetLatestAutoRenewDate { > categorycode => $patron->categorycode, > itemtype => $item->effective_itemtype, > branchcode => $branchcode, >+ checkout_type => $itemissue->checkout_type, > rules => [ > 'no_auto_renewal_after', > 'no_auto_renewal_after_hard_limit', >@@ -3521,7 +3526,7 @@ sub updateWrongTransfer { > > =head2 CalcDateDue > >-$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); >+$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower,$checkout_type); > > this function calculates the due date given the start date and configured circulation rules, > checking against the holidays calendar as per the 'useDaysMode' syspref. >@@ -3534,13 +3539,13 @@ C<$isrenewal> = Boolean: is true if we want to calculate the date due for a rene > =cut > > sub CalcDateDue { >- my ( $startdate, $itemtype, $branch, $borrower, $isrenewal ) = @_; >+ my ( $startdate, $itemtype, $branch, $borrower, $checkout_type, $isrenewal ) = @_; > > $isrenewal ||= 0; > > # loanlength now a href > my $loanlength = >- GetLoanLength( $borrower->{'categorycode'}, $itemtype, $branch ); >+ GetLoanLength( $borrower->{'categorycode'}, $itemtype, $branch, $checkout_type ); > > my $length_key = ( $isrenewal and defined $loanlength->{renewalperiod} ) > ? qq{renewalperiod} >@@ -3586,7 +3591,7 @@ sub CalcDateDue { > > # if Hard Due Dates are used, retrieve them and apply as necessary > my ( $hardduedate, $hardduedatecompare ) = >- GetHardDueDate( $borrower->{'categorycode'}, $itemtype, $branch ); >+ GetHardDueDate( $borrower->{'categorycode'}, $itemtype, $branch, $checkout_type ); > if ($hardduedate) { # hardduedates are currently dates > $hardduedate->truncate( to => 'minute' ); > $hardduedate->set_hour(23); >@@ -4168,7 +4173,7 @@ sub _CalculateAndUpdateFine { > my $date_returned = $return_date ? $return_date : dt_from_string(); > > my ( $amount, $unitcounttotal, $unitcount ) = >- C4::Overdues::CalcFine( $item, $borrower->{categorycode}, $control_branchcode, $datedue, $date_returned ); >+ C4::Overdues::CalcFine( $item, $borrower->{categorycode}, $control_branchcode, $issue->{checkout_type}, $datedue, $date_returned ); > > if ( C4::Context->preference('finesMode') eq 'production' ) { > if ( $amount > 0 ) { >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 2f1212ba0c..59934ad9fa 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -222,7 +222,7 @@ or "Final Notice". But CalcFine never defined any value. > =cut > > sub CalcFine { >- my ( $item, $bortype, $branchcode, $due_dt, $end_date ) = @_; >+ my ( $item, $bortype, $branchcode, $checkout_type, $due_dt, $end_date ) = @_; > > # Skip calculations if item is not overdue > return ( 0, 0, 0 ) unless (DateTime->compare( $due_dt, $end_date ) == -1); >@@ -235,6 +235,7 @@ sub CalcFine { > categorycode => $bortype, > itemtype => $itemtype, > branchcode => $branchcode, >+ checkout_type => $checkout_type, > rules => [ > 'lengthunit', > 'firstremind', >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 86ed9fc1d0..ef8959a4ab 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -541,7 +541,7 @@ subtest "CanBookBeRenewed tests" => sub { > my $passeddatedue1 = AddIssue($renewing_borrower, $item_7->barcode, $five_weeks_ago); > is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: " . $passeddatedue1->date_due); > >- my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now ); >+ my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower->{categorycode}, $branch, undef, $five_weeks_ago, $now ); > C4::Overdues::UpdateFine( > { > issue_id => $passeddatedue1->id(), >@@ -2435,7 +2435,7 @@ subtest 'AddReturn | is_overdue' => sub { > > # Fake fines cronjob on this checkout > my ($fine) = >- CalcFine( $item, $patron->categorycode, $library->{branchcode}, >+ CalcFine( $item, $patron->categorycode, $library->{branchcode}, undef, > $ten_days_ago, $now ); > UpdateFine( > { >diff --git a/t/db_dependent/Circulation/CalcDateDue.t b/t/db_dependent/Circulation/CalcDateDue.t >index 219bf4524d..72df353277 100644 >--- a/t/db_dependent/Circulation/CalcDateDue.t >+++ b/t/db_dependent/Circulation/CalcDateDue.t >@@ -53,9 +53,9 @@ my $dateexpiry = '2013-01-01'; > > my $borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; > my $start_date = DateTime->new({year => 2013, month => 2, day => 9}); >-my $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >+my $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); > is($date, $dateexpiry . 'T23:59:00', 'date expiry'); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); > > > #Set syspref ReturnBeforeExpiry = 1 and useDaysMode != 'Days' >@@ -64,7 +64,7 @@ t::lib::Mocks::mock_preference('useDaysMode', 'noDays'); > > $borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; > $start_date = DateTime->new({year => 2013, month => 2, day => 9}); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); > is($date, $dateexpiry . 'T23:59:00', 'date expiry with useDaysMode to noDays'); > > # Let's add a special holiday on 2013-01-01. With ReturnBeforeExpiry and >@@ -77,7 +77,7 @@ $calendar->insert_single_holiday( > title =>'holidayTest', > description => 'holidayDesc' > ); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); > is($date, '2012-12-31T23:59:00', 'date expiry should be 2013-01-01 -1 day'); > $calendar->insert_single_holiday( > day => 31, >@@ -86,11 +86,11 @@ $calendar->insert_single_holiday( > title =>'holidayTest', > description => 'holidayDesc' > ); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); > is($date, '2012-12-30T23:59:00', 'date expiry should be 2013-01-01 -2 day'); > > >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); > > > #Set syspref ReturnBeforeExpiry = 0 and useDaysMode = 'Days' >@@ -99,10 +99,10 @@ t::lib::Mocks::mock_preference('useDaysMode', 'Days'); > > $borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; > $start_date = DateTime->new({year => 2013, month => 2, day => 9}); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); > is($date, '2013-02-' . (9 + $issuelength) . 'T23:59:00', "date expiry ( 9 + $issuelength )"); > >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); > is($date, '2013-02-' . (9 + $renewalperiod) . 'T23:59:00', "date expiry ( 9 + $renewalperiod )"); > > >@@ -116,10 +116,10 @@ t::lib::Mocks::mock_preference('ReturnBeforeExpiry', 0); > t::lib::Mocks::mock_preference('useDaysMode', 'Dayweek'); > > # No closed day interfering, so we should get the regular due date >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); > is($date, '2013-02-' . (9 + $issuelength) . 'T23:59:00', "useDaysMode = Dayweek, no closed days, issue date expiry ( start + $issuelength )"); > >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); > is($date, '2013-02-' . (9 + $renewalperiod) . 'T23:59:00', "useDaysMode = Dayweek, no closed days, renewal date expiry ( start + $renewalperiod )"); > > # Now let's add a closed day on the expected renewal date, it should >@@ -132,7 +132,7 @@ $calendar->insert_single_holiday( > title =>'DayweekTest1', > description => 'DayweekTest1' > ); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); > is($date, '2013-02-' . (9 + $issuelength + 1) . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 10 day loan (should not trigger 7 day roll forward), issue date expiry ( start + $issuelength + 1 )"); > # Remove the holiday we just created > $calendar->delete_holiday( >@@ -149,7 +149,7 @@ $calendar->insert_single_holiday( > title =>'DayweekTest2', > description => 'DayweekTest2' > ); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); > is($date, '2013-02-' . (9 + $renewalperiod + 1) . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 5 day renewal (should not trigger 7 day roll forward), renewal date expiry ( start + $renewalperiod + 1 )"); > # Remove the holiday we just created > $calendar->delete_holiday( >@@ -192,7 +192,7 @@ $calendar->insert_single_holiday( > title =>'DayweekTest3', > description => 'DayweekTest3' > ); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type ); > my $issue_should_add = $dayweek_issuelength + 7; > my $dayweek_issue_expected = $start_date->add( days => $issue_should_add ); > is($date, $dayweek_issue_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 14 day loan (should trigger 7 day roll forward), issue date expiry ( start + $issue_should_add )"); >@@ -212,7 +212,7 @@ $calendar->insert_single_holiday( > title => 'DayweekTest4', > description => 'DayweekTest4' > ); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, 1 ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type, 1 ); > my $renewal_should_add = $dayweek_renewalperiod + 7; > my $dayweek_renewal_expected = $start_date->add( days => $renewal_should_add ); > is($date, $dayweek_renewal_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 7 day renewal (should trigger 7 day roll forward), renewal date expiry ( start + $renewal_should_add )"); >@@ -253,12 +253,12 @@ $calendar->insert_single_holiday( > description => 'DayweekTest7' > ); > # For issues... >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type ); > $dayweek_issue_expected = $start_date->add( days => $issue_should_add ); > is($date, $expected_rolled_date->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date and two subequent due dates, 14 day loan (should trigger 2 x 7 day roll forward), issue date expiry ( start + 28 )"); > # ...and for renewals... > $start_date = DateTime->new({year => 2013, month => 2, day => 9}); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, 1 ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type, 1 ); > $dayweek_issue_expected = $start_date->add( days => $renewal_should_add ); > is($date, $expected_rolled_date->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date and three subsequent due dates, 7 day renewal (should trigger 3 x 7 day roll forward), issue date expiry ( start + 28 )"); > # Remove the holidays we just created >@@ -293,12 +293,12 @@ $calendar->insert_week_day_holiday( > description => "Closed on Saturdays" > ); > # For issues... >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type ); > $dayweek_issue_expected = $start_date->add( days => $dayweek_issuelength + 1 ); > is($date, $dayweek_issue_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, due on Saturday, closed on Saturdays, 14 day loan (should trigger 1 day roll forward), issue date expiry ( start + 15 )"); > # ...and for renewals... > $start_date = DateTime->new({year => 2013, month => 2, day => 9}); >-$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, 1 ); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type, 1 ); > $dayweek_renewal_expected = $start_date->add( days => $dayweek_renewalperiod + 1 ); > is($date, $dayweek_renewal_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, due on Saturday, closed on Saturdays, 7 day renewal (should trigger 1 day roll forward), issue date expiry ( start + 8 )"); > # Remove the holiday we just created >diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t >index 2adf88ed75..d69fa474ad 100644 >--- a/t/db_dependent/Circulation/CalcFine.t >+++ b/t/db_dependent/Circulation/CalcFine.t >@@ -108,7 +108,7 @@ subtest 'Test basic functionality' => sub { > day => 30, > ); > >- my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, undef, $start_dt, $end_dt ); > > is( $amount, 29, 'Amount is calculated correctly' ); > >@@ -149,7 +149,7 @@ subtest 'Test cap_fine_to_replacement_price' => sub { > day => 30, > ); > >- my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, undef, $start_dt, $end_dt ); > > is( int($amount), 5, 'Amount is calculated correctly' ); > >@@ -157,7 +157,7 @@ subtest 'Test cap_fine_to_replacement_price' => sub { > # Use default replacement cost (useDefaultReplacementCost) is item's replacement price is 0 > my $item_obj = Koha::Items->find($item->{itemnumber}); > $item_obj->replacementprice(0)->store; >- ($amount) = CalcFine( $item_obj->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ ($amount) = CalcFine( $item_obj->unblessed, $patron->{categorycode}, $branch->{branchcode}, undef, $start_dt, $end_dt ); > is( int($amount), 6, 'Amount is calculated correctly' ); > > teardown(); >@@ -197,11 +197,11 @@ subtest 'Test cap_fine_to_replacement_pricew with overduefinescap' => sub { > day => 30, > ); > >- my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, undef, $start_dt, $end_dt ); > is( int($amount), 3, 'Got the lesser of overduefinescap and replacement price where overduefinescap < replacement price' ); > > Koha::CirculationRules->set_rule({ rule_name => 'overduefinescap', rule_value => 6, branchcode => undef, categorycode => undef, itemtype => undef, checkout_type => undef }); >- ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, undef, $start_dt, $end_dt ); > is( int($amount), 5, 'Get the lesser of overduefinescap and replacement price where overduefinescap > replacement price' ); > > teardown(); >diff --git a/t/db_dependent/Circulation/GetHardDueDate.t b/t/db_dependent/Circulation/GetHardDueDate.t >index 6f81ccd30f..9f43fd12d8 100644 >--- a/t/db_dependent/Circulation/GetHardDueDate.t >+++ b/t/db_dependent/Circulation/GetHardDueDate.t >@@ -11,7 +11,7 @@ use Koha::Library; > > use t::lib::TestBuilder; > >-use Test::More tests => 9; >+use Test::More tests => 10; > > BEGIN { > use_ok('C4::Circulation'); >@@ -220,7 +220,7 @@ Koha::CirculationRules->set_rules( $sampleissuingrule3 ); > is_deeply( > C4::Circulation::GetLoanLength( > $samplecat->{categorycode}, >- $sampleitemtype1, $samplebranch1->{branchcode} >+ $sampleitemtype1, $samplebranch1->{branchcode}, $Koha::Checkouts::type->{checkout} > ), > { issuelength => 5, lengthunit => 'days', renewalperiod => 5 }, > "GetLoanLength" >@@ -248,6 +248,11 @@ is_deeply( > ); #NOTE : is that really what is expected? > is_deeply( > C4::Circulation::GetLoanLength( $samplecat->{categorycode}, $sampleitemtype1, $samplebranch1->{branchcode} ), >+ $default, >+ "With only three parameters, GetLoanLength returns hardcoded values" >+); #NOTE : is that really what is expected? >+is_deeply( >+ C4::Circulation::GetLoanLength( $samplecat->{categorycode}, $sampleitemtype1, $samplebranch1->{branchcode}, $Koha::Checkouts::type->{checkout} ), > { > issuelength => 5, > renewalperiod => 5, >@@ -258,7 +263,7 @@ is_deeply( > > #Test GetHardDueDate > my @hardduedate = C4::Circulation::GetHardDueDate( $samplecat->{categorycode}, >- $sampleitemtype1, $samplebranch1->{branchcode} ); >+ $sampleitemtype1, $samplebranch1->{branchcode}, $Koha::Checkouts::type->{checkout} ); > is_deeply( > \@hardduedate, > [ >diff --git a/t/db_dependent/Fines.t b/t/db_dependent/Fines.t >index 4968d3b134..a7c88e59bb 100644 >--- a/t/db_dependent/Fines.t >+++ b/t/db_dependent/Fines.t >@@ -37,11 +37,11 @@ ok( $issuingrule, 'Issuing rule created' ); > my $period_start = dt_from_string('2000-01-01'); > my $period_end = dt_from_string('2000-01-05'); > >-my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end ); >+my ( $fine ) = CalcFine( {}, q{}, q{}, q{}, $period_start, $period_end ); > is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' ); > > $period_end = dt_from_string('2000-01-10'); >-( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end ); >+( $fine ) = CalcFine( {}, q{}, q{}, q{}, $period_start, $period_end ); > is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' ); > > # Test charging fine at the *beginning* of each charge period >@@ -58,9 +58,9 @@ $issuingrule = Koha::CirculationRules->set_rules( > ); > > $period_end = dt_from_string('2000-01-05'); >-( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end ); >+( $fine ) = CalcFine( {}, q{}, q{}, q{}, $period_start, $period_end ); > is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' ); > > $period_end = dt_from_string('2000-01-10'); >-( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end ); >+( $fine ) = CalcFine( {}, q{}, q{}, q{}, $period_start, $period_end ); > is( $fine, 2, '9 days overdue, charge period 7 days, charge at start of interval gives fine of $2' ); >-- >2.17.1
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 25089
:
103046
|
103047
|
103048
|
103049
|
103050
|
103051
|
103052
|
103053
|
103054
|
103239
|
103240
|
103241
|
103242
|
103243
|
103244
|
103245
|
103246
|
103247
|
103248
|
103283
|
103284
|
103285
|
103286
|
103287
|
103288
|
103289
|
103290
|
103291
|
103292
|
103339
|
103340
|
103341
|
103342
|
103343
|
103344
|
103345
|
103346
|
103347
|
103348
|
103349
|
103351
|
103352
|
103353
|
103354
|
103355
|
103356
|
103357
|
103358
|
103359
|
103360
|
103361
|
103537
|
103538
|
103539
|
103540
|
103541
|
103542
|
103543
|
103544
|
103545
|
103546
|
103547
|
104274
|
104275
|
107523
|
107524
|
107525
|
107526
|
107527
|
107528
|
107529
|
107530
|
107531
|
107532
|
107533