From 2dd729fff9aa52fcd0ca6ea6db3333276aaf2a93 Mon Sep 17 00:00:00 2001
From: Alex Buckley <alexbuckley@catalyst.net.nz>
Date: Tue, 27 Sep 2022 16:54:06 +1300
Subject: [PATCH] Bug 31631: Add new system preference

Sponsored-by: Waikato Institute of Technology, New Zealand

Signed-off-by: David Nind <david@davidnind.com>
---
 ...31-add_CalculateFundValuesIncludingTax_syspref.pl | 12 ++++++++++++
 installer/data/mysql/mandatory/sysprefs.sql          |  1 +
 .../en/modules/admin/preferences/acquisitions.pref   |  6 ++++++
 3 files changed, 19 insertions(+)
 create mode 100755 installer/data/mysql/atomicupdate/bug_31631-add_CalculateFundValuesIncludingTax_syspref.pl

diff --git a/installer/data/mysql/atomicupdate/bug_31631-add_CalculateFundValuesIncludingTax_syspref.pl b/installer/data/mysql/atomicupdate/bug_31631-add_CalculateFundValuesIncludingTax_syspref.pl
new file mode 100755
index 0000000000..fa21418f9f
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_31631-add_CalculateFundValuesIncludingTax_syspref.pl
@@ -0,0 +1,12 @@
+use Modern::Perl;
+
+return {
+    bug_number => "31631",
+    description => "Add new system preference CalculateFundValuesIncludingTax",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out)};
+
+        $dbh->do(q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('CalculateFundValuesIncludingTax', '1', NULL, 'Include tax in the calculated fund values (spent, ordered) for all supplier configurations', 'YesNo')});
+    },
+};
diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql
index beebd27a6f..c46dd4561f 100644
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ b/installer/data/mysql/mandatory/sysprefs.sql
@@ -123,6 +123,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('BundleNotLoanValue','3',NULL,'Sets the NOT_LOAN AV value that represents "Added to bundle" as a not for loan value','Free'),
 ('CalculateFinesOnReturn','1','','Switch to control if overdue fines are calculated on return or not','YesNo'),
 ('CalculateFinesOnBackdate','1','','Switch to control if overdue fines are calculated on return when backdating','YesNo'),
+('CalculateFundValuesIncludingTax', '1', NULL, 'Include tax in the calculated fund values (spent, ordered) for all supplier configurations', 'YesNo'),
 ('CalendarFirstDayOfWeek','0','0|1|2|3|4|5|6','Select the first day of week to use in the calendar.','Choice'),
 ('CanMarkHoldsToPullAsLost','do_not_allow','do_not_allow|allow|allow_and_notify','Add a button to the "Holds to pull" screen to mark an item as lost and notify the patron.','Choice'),
 ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library place a hold on an item from another library','YesNo'),
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref
index 3f0560aac5..551a0aa0ab 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref
@@ -40,6 +40,12 @@ Acquisitions:
             - . Enter in numeric form, 0.12 for 12%. The first item in the list will be selected by default. For more than one value, separate with | (pipe).
             - "<br/><strong>NOTE:</strong> The database will only accept values up to 4 decimals precision, further values will be rounded."
             - "<br/><strong>NOTE:</strong> Vendor tax rate information may need updating if tax rate values are removed."
+        -
+            - pref: CalculateFundValuesIncludingTax
+              choices:
+                  1: Include
+                  0: Exclude
+            - "tax in the calculated fund values (spent, ordered). Note this rule applies to all vendors regardless of their configuration"
         -
             - pref: AcqWarnOnDuplicateInvoice
               choices:
-- 
2.20.1