Bug 20581: Provide status_alias on IllRequest
authorAndrew Isherwood <andrew.isherwood@ptfs-europe.com>
Tue, 17 Apr 2018 11:02:18 +0000 (12:02 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 22 Feb 2019 14:31:31 +0000 (14:31 +0000)
This patch provides status_alias support for the Koha::Illrequest
object.

- New 'statusalias' getter method, returns the request's status_alias
authorised value object if set, otherwise undef
- Overloads existing 'status' method, getter/setter accessors intact,
but setting the request's status now implicitly removes any status_alias
that has been set

Signed-off-by: Niamh.Walker-Headon@it-tallaght.ie

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha/Illrequest.pm

index ff834f1..18cd57e 100644 (file)
@@ -31,6 +31,7 @@ use Koha::Email;
 use Koha::Exceptions::Ill;
 use Koha::Illcomments;
 use Koha::Illrequestattributes;
+use Koha::AuthorisedValue;
 use Koha::Patron;
 
 use base qw(Koha::Object);
@@ -109,6 +110,19 @@ available for request.
 
 =head2 Class methods
 
+=head3 statusalias
+
+=cut
+
+sub statusalias {
+    my ( $self ) = @_;
+    return $self->status_alias ?
+        Koha::AuthorisedValue->_new_from_dbic(
+            scalar $self->_result->status_alias
+        ) :
+        undef;
+}
+
 =head3 illrequestattributes
 
 =cut
@@ -142,6 +156,22 @@ sub patron {
     );
 }
 
+=head3 status
+
+Overloaded getter/setter for request status,
+also nullifies status_alias
+
+=cut
+
+sub status {
+    my ( $self, $newval) = @_;
+    if ($newval) {
+        $self->status_alias(undef);
+        return $self->SUPER::status($newval);
+    }
+    return $self->SUPER::status;
+}
+
 =head3 load_backend
 
 Require "Base.pm" from the relevant ILL backend.