Bug 25417: Add unit test
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 7 May 2020 18:21:59 +0000 (14:21 -0400)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 12 May 2020 12:46:31 +0000 (13:46 +0100)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Didier Gautheron <didier.gautheron@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Circulation.t

index 7ae3b9f..d769a67 100755 (executable)
@@ -2827,7 +2827,7 @@ subtest '_FixAccountForLostAndFound' => sub {
 };
 
 subtest '_FixOverduesOnReturn' => sub {
-    plan tests => 11;
+    plan tests => 12;
 
     my $manager = $builder->build_object({ class => "Koha::Patrons" });
     t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
@@ -2891,6 +2891,21 @@ subtest '_FixOverduesOnReturn' => sub {
     is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
     is( $credit->amount + 0, -99, "Credit amount is set correctly" );
     is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
+    $offset->delete;
+
+    $accountline->set(
+        {
+            debit_type_code    => 'OVERDUE',
+            status         => 'UNRETURNED',
+            amountoutstanding => 0.00,
+        }
+    )->store();
+
+    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1, 'RETURNED' );
+
+    $accountline->_result()->discard_changes();
+    $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
+    is( $offset, undef, "No offset created when trying to forgive fine with no outstanding balance" );
 };
 
 subtest '_FixAccountForLostAndFound returns undef if patron is deleted' => sub {