From b91d9daf40611032093e9a5a0c90acb7a460e8d0 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 | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Koha/Acquisition/Basket.pm b/Koha/Acquisition/Basket.pm index acdf544c38..40b39867c2 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 @@ -109,11 +124,11 @@ sub to_api_mapping { creationdate => 'creation_date', closedate => 'close_date', booksellerid => 'vendor_id', - authorisedby => 'authorised_by', + authorisedby => 'creator_id', booksellerinvoicenumber => undef, basketgroupid => 'basket_group_id', - deliveryplace => 'delivery_place', - billingplace => 'billing_place', + deliveryplace => 'delivery_library_id', + billingplace => 'billing_library_id', branch => 'library_id', is_standing => 'standing' }; -- 2.11.0