From 88f71205a3373a999eab29bbeae90710801aa686 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Mon, 21 Jun 2021 16:39:38 +0100
Subject: [PATCH] Bug 22435: (QA follow-up) Fix test for offset total

This patch updates the test for the offset total method to adhere to the
new restricted set of offset types available.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
---
 t/db_dependent/Koha/Account/Offsets.t | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/t/db_dependent/Koha/Account/Offsets.t b/t/db_dependent/Koha/Account/Offsets.t
index cc271b5086..ee942527ee 100755
--- a/t/db_dependent/Koha/Account/Offsets.t
+++ b/t/db_dependent/Koha/Account/Offsets.t
@@ -38,7 +38,7 @@ subtest 'total() tests' => sub {
     my $line = $builder->build_object(
         {
             class => 'Koha::Account::Lines',
-            value => { debit_type_code => undef }
+            value => { debit_type_code => 'OVERDUE', credit_type_code => undef }
         }
     );
 
@@ -49,26 +49,26 @@ subtest 'total() tests' => sub {
     my $amount_5 = 500;
 
     my $offset_1 = Koha::Account::Offset->new(
-        { type => 'OVERDUE', amount => $amount_1, credit_id => $line->id } )->store;
+        { type => 'OVERDUE_INCREASE', amount => $amount_1, debit_id => $line->id } )->store;
     my $offset_2 = Koha::Account::Offset->new(
-        { type => 'OVERDUE', amount => $amount_2, credit_id => $line->id } )->store;
+        { type => 'OVERDUE_INCREASE', amount => $amount_2, debit_id => $line->id } )->store;
     my $offset_3 = Koha::Account::Offset->new(
-        { type => 'Payment', amount => $amount_3, credit_id => $line->id } )->store;
+        { type => 'OVERDUE_DECREASE', amount => $amount_3, debit_id => $line->id } )->store;
     my $offset_4 = Koha::Account::Offset->new(
-        { type => 'Payment', amount => $amount_4, credit_id => $line->id } )->store;
+        { type => 'OVERDUE_DECREASE', amount => $amount_4, debit_id => $line->id } )->store;
     my $offset_5 = Koha::Account::Offset->new(
-        { type => 'OVERDUE', amount => $amount_5, credit_id => $line->id } )->store;
+        { type => 'OVERDUE_INCREASE', amount => $amount_5, debit_id => $line->id } )->store;
 
-    my $debits = Koha::Account::Offsets->search( { type => 'OVERDUE', credit_id => $line->id } );
+    my $debits = Koha::Account::Offsets->search( { type => 'OVERDUE_INCREASE', debit_id => $line->id } );
     is( $debits->total, $amount_1 + $amount_2 + $amount_5 );
 
-    my $credits = Koha::Account::Offsets->search( { type => 'Payment', credit_id => $line->id } );
+    my $credits = Koha::Account::Offsets->search( { type => 'OVERDUE_DECREASE', debit_id => $line->id } );
     is( $credits->total, $amount_3 + $amount_4 );
 
-    my $all = Koha::Account::Offsets->search( { credit_id => $line->id } );
+    my $all = Koha::Account::Offsets->search( { debit_id => $line->id } );
     is( $all->total, $amount_1 + $amount_2 + $amount_3 + $amount_4 + $amount_5 );
 
-    my $none = Koha::Account::Offsets->search( { credit_id => $line->id + 1 } );
+    my $none = Koha::Account::Offsets->search( { debit_id => $line->id + 1 } );
     is( $none->total, 0, 'No offsets, returns 0' );
 
     $schema->storage->txn_rollback;
-- 
2.20.1