From 2802f20e386e6e51341a1ef77b1225f858b0d1c6 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 Signed-off-by: Nick Clemens --- 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 7d04d3f97f..3bee144e17 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2896,7 +2896,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 7ef6019a7a..3d52a1ffa4 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -3065,7 +3065,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(); @@ -3076,7 +3076,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(); @@ -3092,7 +3092,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.39.5