Bug 14048: Add syspref and atomic update
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 3 Jun 2016 14:24:07 +0000 (11:24 -0300)
committerJesse Weaver <jweaver@bywatersolutions.com>
Thu, 7 Jul 2016 16:37:01 +0000 (10:37 -0600)
This patch introduces the changes to the sysprefs and the atomic update
that creates the new table.

It picks the syspref value for RefundLostItemFeeOnReturn and uses it to
create a default (branchcode='*') rule on the new table.

Sponsored-by: DoverNet
Sponsored-by: South-East Kansas Library System
Sponsored-by: SWITCH Library Consortium
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jason Robb <jrobb@sekls.org>
Signed-off-by: Jennifer Schmidt <jschmidt@switchinc.org>
Signed-off-by: Margaret Thrasher <p.thrasher@dover.nh.gov>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
installer/data/mysql/atomicupdate/bug_14048_refundlostitemfeeonreturn.sql [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref

diff --git a/installer/data/mysql/atomicupdate/bug_14048_refundlostitemfeeonreturn.sql b/installer/data/mysql/atomicupdate/bug_14048_refundlostitemfeeonreturn.sql
new file mode 100644 (file)
index 0000000..2f372fb
--- /dev/null
@@ -0,0 +1,49 @@
+CREATE TABLE `refund_lost_item_fee_rules` (
+  `branchcode` varchar(10) NOT NULL default '',
+  `refund` tinyint(1) NOT NULL default 0,
+  PRIMARY KEY  (`branchcode`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+VALUES( 'RefundLostOnReturnControl',
+        'CheckinLibrary',
+        'If a lost item is returned, choose which branch to pick rules for refunding.',
+        'CheckinLibrary|PatronLibrary|ItemHomeBranch|ItemHoldingbranch',
+        'Choice');
+
+INSERT INTO refund_lost_item_fee_rules (branchcode,refund)
+    SELECT '*', COALESCE(value,'1') FROM systempreferences WHERE variable='RefundLostItemFeeOnReturn';
+
+DELETE IGNORE FROM systempreferences;
+
+-- $DBversion = "16.06.00.XXX";
+-- if ( CheckVersion($DBversion) ) {
+--     $dbh->do(q{
+--         CREATE TABLE `refund_lost_item_fee_rules` (
+--           `branchcode` varchar(10) NOT NULL default '',
+--           `refund` tinyint(1) NOT NULL default 0,
+--           PRIMARY KEY  (`branchcode`)
+--         ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+--     });
+--     $dbh->do(q{
+--         INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+--         VALUES( 'RefundLostOnReturnControl',
+--                 'CheckinLibrary',
+--                 'If a lost item is returned, choose which branch to pick rules for refunding.',
+--                 'CheckinLibrary|PatronLibrary|ItemHomeBranch|ItemHoldingbranch',
+--                 'Choice')
+--     });
+--     # Pick the old syspref as the default rule
+--     $dbh->do(q{
+--         INSERT INTO refund_lost_item_fee_rules (branchcode,refund)
+--             SELECT '*', COALESCE(value,'1') FROM systempreferences WHERE variable='RefundLostItemFeeOnReturn'
+--     });
+--     # Delete the old syspref
+--     $dbh->do(q{
+--         DELETE IGNORE FROM systempreferences
+--         WHERE variable='RefundLostItemFeeOnReturn'
+--     });
+
+--     print "Upgrade to $DBversion done (Bug 14048: Change RefundLostItemFeeOnReturn to be branch specific)\n";
+--     SetVersion($DBversion);
+-- }
index af42f66..512211a 100644 (file)
@@ -400,7 +400,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'),
 ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'),
 ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
-('RefundLostItemFeeOnReturn','1',NULL,'If enabled, the lost item fee charged to a borrower will be refunded when the lost item is returned.','YesNo'),
+('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingbranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
 ('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'),
 ('RenewalSendNotice','0','',NULL,'YesNo'),
 ('RenewSerialAddsSuggestion','0',NULL,'If ON, adds a new suggestion at serial subscription renewal','YesNo'),
index 9a37608..fffa4c6 100644 (file)
@@ -654,11 +654,12 @@ Circulation:
             - fines (when <code>misc/cronjobs/fines.pl</code> is being run).
             - <br><b>Note:</b> Fines can also be charged by the CalculateFinesOnReturn system preference.
         -
-            - pref: RefundLostItemFeeOnReturn
+            - If a lost item is returned, apply the refunding rules defined in the
+            - pref: RefundLostOnReturnControl
               choices:
-                  yes: Refund
-                  no: "Don't refund"
-            - lost item fees charged to a borrower when the lost item is returned.
+                  CheckinLibrary: "check-in library."
+                  ItemHomeBranch: "item home branch."
+                  ItemHoldingbranch: "item holding branch."
         -
             - pref: FinesIncludeGracePeriod
               choices: