From 48500f4948d2ec51199622a2a291c0de643156ca Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 20 Jan 2020 16:00:05 -0300 Subject: [PATCH] Bug 24464: Add K::A::Basket->creator This patch adds a ->creator method to Koha::Acquisition::Basket to retrieve the related Koha::Patron object. Note: this should be re-done once 22658 is pushed, but at the time being, there's not patch submitted, and it is not a trivial task because of the column type missmatch. That said, the implementation of ->creator in this class is simple enough to just rewrite it once 22658 is submitted, and the tests will reflect the expected/unchanged behavior. To test: 1. Apply this patches 2. Run: $ kshell k$ prove t/db_dependent/Koha/Acquisition/Basket.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: David Nind --- Koha/Acquisition/Basket.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Koha/Acquisition/Basket.pm b/Koha/Acquisition/Basket.pm index b80b35fdff..4d9a87c3cd 100644 --- a/Koha/Acquisition/Basket.pm +++ b/Koha/Acquisition/Basket.pm @@ -21,6 +21,7 @@ use Modern::Perl; use Koha::Database; use Koha::Acquisition::BasketGroups; +use Koha::Patrons; use base qw( Koha::Object Koha::Object::Mixin::AdditionalFields ); @@ -30,7 +31,7 @@ Koha::Acquisition::Basket - Koha Basket Object class =head1 API -=head2 Class Methods +=head2 Class methods =cut @@ -46,6 +47,20 @@ sub bookseller { return Koha::Acquisition::Bookseller->_new_from_dbic( $bookseller_rs ); } +=head3 creator + + my $creator = $basket->creator; + +Returns the I for the basket creator. + +=cut + +sub creator { + my ($self) = @_; + return Koha::Patrons->find( $self->authorisedby ) + if $self->authorisedby; +} + =head3 basket_group Returns the basket group associated to this basket -- 2.25.2