From eb5b04d5251fa3df6ccbfacd7c7a5ef2edc65edc Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 20 Feb 2019 08:49:44 +0000 Subject: [PATCH] Bug 20912: (follow-up) Prevent double charging on renewal This patch updates the tests the ensure we do not double charge for renewals that take place before the original due date and fixes the corresponding loging in C4::Circulation::AddRenewal. Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 3 ++- t/db_dependent/Circulation.t | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index cec20c820a..b4f35679a2 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2910,7 +2910,8 @@ sub AddRenewal { patron => $patron, library => $circ_library, item => $item_object, - to_date => dt_from_string( $datedue ), + from_date => dt_from_string( $issue->date_due, 'sql' ), + to_date => dt_from_string($datedue), } ); diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 839e3fd818..91f636ca98 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -3052,7 +3052,7 @@ subtest 'Incremented fee tests' => sub { $accountline->delete(); AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); $accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); - is( $accountline->amount, '13.000000', "Daily rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal" ); + is( $accountline->amount, '6.000000', "Daily rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal" ); $accountline->delete(); $issue->delete(); @@ -3063,7 +3063,7 @@ subtest 'Incremented fee tests' => sub { $accountline->delete(); AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); $accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); - is( $accountline->amount, '13.000000', "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal" ); + is( $accountline->amount, '6.000000', "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal" ); $accountline->delete(); $issue->delete(); @@ -3079,7 +3079,7 @@ subtest 'Incremented fee tests' => sub { $accountline->delete(); AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); $accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); - is( $accountline->amount, '11.000000', "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays, for renewal" ); + is( $accountline->amount, '5.000000', "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays, for renewal" ); $accountline->delete(); $issue->delete(); -- 2.20.1