Bug 21969: Fix Koha::Account->outstanding_* matching the opposite on pathological...
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 6 Dec 2018 18:59:10 +0000 (15:59 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 12 Dec 2018 11:11:08 +0000 (11:11 +0000)
This patch makes outstanding_* methods be safe regarding pathological
account lines that get converted into another type because of the value
of amountoutstanding

To test:
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/Account.t
=> FAIL: Tests fail because pathological account lines are wrongly
picked.
- Apply this patch
- Run:
 k$ prove t/db_dependent/Koha/Account.t
=>SUCCESS: All green!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit dbff938c7ff7eb277c6b94b56b5f03d3348f0017)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Account.pm

index 5630f41..4b68f2a 100644 (file)
@@ -430,6 +430,7 @@ sub outstanding_debits {
 
     my $lines = $self->lines->search(
         {
+            amount            => { '>' => 0 },
             amountoutstanding => { '>' => 0 }
         }
     );
@@ -448,6 +449,7 @@ sub outstanding_credits {
 
     my $lines = $self->lines->search(
         {
+            amount            => { '<' => 0 },
             amountoutstanding => { '<' => 0 }
         }
     );