Bug 12768: (QA follow-up) Use specific account offset types for Processing Fee and...
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 23 Oct 2017 15:01:25 +0000 (11:01 -0400)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 23 Oct 2017 15:36:12 +0000 (12:36 -0300)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Accounts.pm
installer/data/mysql/account_offset_types.sql
installer/data/mysql/atomicupdate/processing_fee.sql [new file with mode: 0644]
t/db_dependent/Circulation/Chargelostitem.t

index 7daff23..5fcbba0 100644 (file)
@@ -230,10 +230,15 @@ sub manualinvoice {
         }
     )->store();
 
+    my $offset_type =
+        $type eq 'L'  ? 'Lost Item'
+      : $type eq 'PF' ? 'Processing Fee'
+      :                 'Manual Debit';
+
     my $account_offset = Koha::Account::Offset->new(
         {
             debit_id => $accountline->id,
-            type     => 'Manual Debit',
+            type     => $offset_type,
             amount   => $amount,
         }
     )->store();
index 2f9004c..a0f2fb1 100644 (file)
@@ -2,6 +2,7 @@ INSERT INTO account_offset_types ( type ) VALUES
 ('Writeoff'),
 ('Payment'),
 ('Lost Item'),
+('Processing Fee'),
 ('Manual Debit'),
 ('Reverse Payment'),
 ('Forgiven'),
diff --git a/installer/data/mysql/atomicupdate/processing_fee.sql b/installer/data/mysql/atomicupdate/processing_fee.sql
new file mode 100644 (file)
index 0000000..98b9827
--- /dev/null
@@ -0,0 +1 @@
+INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Processing Fee' );
index 3ffb295..bb2f230 100644 (file)
@@ -2,7 +2,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 4;
+use Test::More tests => 6;
 use Test::MockModule;
 use t::lib::Mocks;
 use t::lib::TestBuilder;
@@ -62,6 +62,7 @@ AddIssue($borrower, '0101');
 AddIssue($borrower, '0203');
 
 # Begin tests...
+Koha::Account::Offsets->delete();
 my $issue = Koha::Checkouts->search( { borrowernumber => $borrowernumber } )->next()->unblessed();
 C4::Accounts::chargelostitem( $borrowernumber, $issue->{itemnumber}, '1.00');
 
@@ -70,3 +71,9 @@ my $accountline = Koha::Account::Lines->search( { borrowernumber => $borrowernum
 is( int($accountline->amount), $itemtype->{processfee}, "The accountline amount should be precessfee value " );
 is( $accountline->itemnumber, $itemnumber1, "The accountline itemnumber should the linked with barcode '0101'" );
 is( $accountline->note, C4::Context->preference("ProcessingFeeNote"), "The accountline description should be 'test'" );
+
+my $lost_ao = Koha::Account::Offsets->single( { type => 'Lost Item' } );
+ok( $lost_ao, 'Account offset of type "Lost Item" created' );
+
+my $processing_fee_ao = Koha::Account::Offsets->single( { type => 'Processing Fee' } );
+ok( $processing_fee_ao, 'Account offset of type "Processing Fee" created' );