From 9a3bb6ba8db65e2f4276d8427bd8c906d5d83a72 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Thu, 28 Jun 2018 15:51:06 -0300
Subject: [PATCH] Bug 20997: Add new offset type

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
---
 installer/data/mysql/account_offset_types.sql         |  3 ++-
 installer/data/mysql/atomicupdate/bug_20997.perl      | 11 +++++++++++
 .../prog/en/includes/account_offset_type.inc          |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 installer/data/mysql/atomicupdate/bug_20997.perl

diff --git a/installer/data/mysql/account_offset_types.sql b/installer/data/mysql/account_offset_types.sql
index 7b96abfdbd..baf3a26a6a 100644
--- a/installer/data/mysql/account_offset_types.sql
+++ b/installer/data/mysql/account_offset_types.sql
@@ -11,4 +11,5 @@ INSERT INTO account_offset_types ( type ) VALUES
 ('Rental Fee'),
 ('Fine Update'),
 ('Fine'),
-('Void Payment');
+('Void Payment'),
+('credit_applied');
diff --git a/installer/data/mysql/atomicupdate/bug_20997.perl b/installer/data/mysql/atomicupdate/bug_20997.perl
new file mode 100644
index 0000000000..159917aacb
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_20997.perl
@@ -0,0 +1,11 @@
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+
+    # Add 'credit_applied' offset type
+    $dbh->do(q{
+        INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('credit_applied');
+    });
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 20997 - Add Koha::Account::Line::apply)\n";
+}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc
index 6ec71d1f09..7241c73391 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc
@@ -1,4 +1,5 @@
 [% SWITCH account_offset.type %]
+    [% CASE 'credit_applied' %]Credit applied
     [% CASE 'Payment' %]Payment
     [% CASE 'Manual Credit' %]Manual credit
     [% CASE 'Manual Debit' %]Manual invoice
-- 
2.18.0