From e05d4568b197e1cdae4197574b0adf650da9a7ea Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Wed, 28 Oct 2020 16:16:52 +0200
Subject: [PATCH] KohaRest: Add support for mapping different "Lost" statuses.
 (#1771)

---
 config/vufind/KohaRest.ini                       |  7 ++++---
 module/VuFind/src/VuFind/ILS/Driver/KohaRest.php | 14 +++++++-------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/config/vufind/KohaRest.ini b/config/vufind/KohaRest.ini
index eba9e7a7aa2..8868fa8988c 100644
--- a/config/vufind/KohaRest.ini
+++ b/config/vufind/KohaRest.ini
@@ -89,11 +89,12 @@ acceptTermsText = "I accept the terms in any language."
 ; VuFind item statuses
 [ItemStatusMappings]
 ;Item::Held = "Held"
-; Custom "Not For Loan" statuses can be mapped by appending the authorized value to
-; the status key like this (first one is negative authorized value, second one is
-; positive):
+; "Not For Loan" or "Lost" statuses can be mapped by appending the authorized value
+; to the status key like this (first one is a negative authorized value, next ones
+; are positive):
 ;Item::NotForLoan-1 = "Ordered"
 ;Item::NotForLoan4 = "At Bindery"
+;Item::Lost4 = "Lost--Library Applied"
 ; Also "Not For Loan" item types can be mapped by appending the authorized value to
 ; the status key like this:
 ;ItemType::NotForLoan1 = "Reference Desk"
diff --git a/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php b/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
index 2d0a4a12060..d06d020d76e 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
@@ -182,7 +182,6 @@ class KohaRest extends \VuFind\ILS\Driver\AbstractBase implements
      */
     protected $itemStatusMappings = [
         'Item::Held' => 'On Hold',
-        'Item::Lost' => 'Lost--Library Applied',
         'Item::Waiting' => 'On Holdshelf',
     ];
 
@@ -194,10 +193,11 @@ class KohaRest extends \VuFind\ILS\Driver\AbstractBase implements
      */
     protected $itemStatusMappingMethods = [
         'Item::CheckedOut' => 'getStatusCodeItemCheckedOut',
-        'Item::NotForLoan' => 'getStatusCodeItemNotForLoan',
-        'Item::NotForLoanForcing' => 'getStatusCodeItemNotForLoan',
+        'Item::Lost' => 'getStatusCodeItemNotForLoanOrLost',
+        'Item::NotForLoan' => 'getStatusCodeItemNotForLoanOrLost',
+        'Item::NotForLoanForcing' => 'getStatusCodeItemNotForLoanOrLost',
         'Item::Transfer' => 'getStatusCodeItemTransfer',
-        'ItemType::NotForLoan' => 'getStatusCodeItemNotForLoan',
+        'ItemType::NotForLoan' => 'getStatusCodeItemNotForLoanOrLost',
     ];
 
     /**
@@ -1823,7 +1823,7 @@ class KohaRest extends \VuFind\ILS\Driver\AbstractBase implements
     }
 
     /**
-     * Get item status code for NotForLoan status
+     * Get item status code for NotForLoan or Lost status
      *
      * @param string $code Status code
      * @param array  $data Status data
@@ -1833,9 +1833,9 @@ class KohaRest extends \VuFind\ILS\Driver\AbstractBase implements
      *
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
-    protected function getStatusCodeItemNotForLoan($code, $data, $item)
+    protected function getStatusCodeItemNotForLoanOrLost($code, $data, $item)
     {
-        // NotForLoan is special: status has a library-specific
+        // NotForLoan and Lost are special: status has a library-specific
         // status number. Allow mapping of different status numbers
         // separately (e.g. Item::NotForLoan with status number 4
         // is mapped with key Item::NotForLoan4):
-- 
GitLab